]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/bgp_vty.c
Merge remote-tracking branch 'origin/stable/3.0'
[mirror_frr.git] / bgpd / bgp_vty.c
CommitLineData
718e3744 1/* BGP VTY interface.
896014f4
DL
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 along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
718e3744 20
21#include <zebra.h>
22
23#include "command.h"
afec25d9 24#include "lib/json.h"
718e3744 25#include "prefix.h"
26#include "plist.h"
27#include "buffer.h"
28#include "linklist.h"
29#include "stream.h"
30#include "thread.h"
31#include "log.h"
3b8b1855 32#include "memory.h"
fc7948fa 33#include "memory_vty.h"
4bf6a362 34#include "hash.h"
3f9c7369 35#include "queue.h"
039f3a34 36#include "filter.h"
718e3744 37
38#include "bgpd/bgpd.h"
4bf6a362 39#include "bgpd/bgp_advertise.h"
718e3744 40#include "bgpd/bgp_attr.h"
41#include "bgpd/bgp_aspath.h"
42#include "bgpd/bgp_community.h"
4bf6a362 43#include "bgpd/bgp_ecommunity.h"
57d187bc 44#include "bgpd/bgp_lcommunity.h"
4bf6a362 45#include "bgpd/bgp_damp.h"
718e3744 46#include "bgpd/bgp_debug.h"
e0701b79 47#include "bgpd/bgp_fsm.h"
4bf6a362 48#include "bgpd/bgp_nexthop.h"
718e3744 49#include "bgpd/bgp_open.h"
4bf6a362 50#include "bgpd/bgp_regex.h"
718e3744 51#include "bgpd/bgp_route.h"
c016b6c7 52#include "bgpd/bgp_mplsvpn.h"
718e3744 53#include "bgpd/bgp_zebra.h"
fee0f4c6 54#include "bgpd/bgp_table.h"
94f2b392 55#include "bgpd/bgp_vty.h"
165b5fff 56#include "bgpd/bgp_mpath.h"
cb1faec9 57#include "bgpd/bgp_packet.h"
3f9c7369 58#include "bgpd/bgp_updgrp.h"
c43ed2e4 59#include "bgpd/bgp_bfd.h"
718e3744 60
20eb8864 61static struct peer_group *
62listen_range_exists (struct bgp *bgp, struct prefix *range, int exact);
20aeb970 63
f51bae9c
DS
64static enum node_type
65bgp_node_type (afi_t afi, safi_t safi)
66{
67 switch (afi)
68 {
69 case AFI_IP:
70 switch (safi)
71 {
72 case SAFI_UNICAST:
73 return BGP_IPV4_NODE;
74 break;
75 case SAFI_MULTICAST:
76 return BGP_IPV4M_NODE;
77 break;
78 case SAFI_LABELED_UNICAST:
79 return BGP_IPV4L_NODE;
80 break;
81 case SAFI_MPLS_VPN:
82 return BGP_VPNV4_NODE;
83 break;
84 case SAFI_ENCAP:
85 return BGP_ENCAP_NODE;
86 break;
f51bae9c
DS
87 }
88 break;
89 case AFI_IP6:
90 switch (safi)
91 {
92 case SAFI_UNICAST:
93 return BGP_IPV6_NODE;
94 break;
95 case SAFI_MULTICAST:
96 return BGP_IPV6M_NODE;
97 break;
98 case SAFI_LABELED_UNICAST:
99 return BGP_IPV6L_NODE;
100 break;
101 case SAFI_MPLS_VPN:
102 return BGP_VPNV6_NODE;
103 break;
104 case SAFI_ENCAP:
20aeb970 105 return BGP_ENCAPV6_NODE;
f51bae9c 106 break;
f51bae9c
DS
107 }
108 break;
b3b3879c
DS
109 case AFI_L2VPN:
110 return BGP_EVPN_NODE;
111 break;
112 case AFI_MAX:
113 // We should never be here but to clarify the switch statement..
114 return BGP_IPV4_NODE;
f51bae9c
DS
115 break;
116 }
b3b3879c
DS
117
118 // Impossible to happen
119 return BGP_IPV4_NODE;
f51bae9c 120}
20eb8864 121
718e3744 122/* Utility function to get address family from current node. */
123afi_t
124bgp_node_afi (struct vty *vty)
125{
4e851f1f
LB
126 afi_t afi;
127 switch (vty->node)
128 {
129 case BGP_IPV6_NODE:
130 case BGP_IPV6M_NODE:
f51bae9c 131 case BGP_IPV6L_NODE:
4e851f1f
LB
132 case BGP_VPNV6_NODE:
133 case BGP_ENCAPV6_NODE:
134 afi = AFI_IP6;
135 break;
4e0b7b6d
PG
136 case BGP_EVPN_NODE:
137 afi = AFI_L2VPN;
138 break;
4e851f1f
LB
139 default:
140 afi = AFI_IP;
141 break;
142 }
143 return afi;
718e3744 144}
145
146/* Utility function to get subsequent address family from current
147 node. */
148safi_t
149bgp_node_safi (struct vty *vty)
150{
4e851f1f
LB
151 safi_t safi;
152 switch (vty->node)
153 {
154 case BGP_ENCAP_NODE:
155 case BGP_ENCAPV6_NODE:
156 safi = SAFI_ENCAP;
157 break;
158 case BGP_VPNV4_NODE:
159 case BGP_VPNV6_NODE:
160 safi = SAFI_MPLS_VPN;
161 break;
162 case BGP_IPV4M_NODE:
163 case BGP_IPV6M_NODE:
164 safi = SAFI_MULTICAST;
165 break;
4e0b7b6d
PG
166 case BGP_EVPN_NODE:
167 safi = SAFI_EVPN;
168 break;
f51bae9c
DS
169 case BGP_IPV4L_NODE:
170 case BGP_IPV6L_NODE:
171 safi = SAFI_LABELED_UNICAST;
172 break;
4e851f1f
LB
173 default:
174 safi = SAFI_UNICAST;
175 break;
176 }
177 return safi;
718e3744 178}
179
46f296b4
LB
180/* supports <ipv4|ipv6> */
181afi_t
182bgp_vty_afi_from_arg(const char *afi_str)
8b1fb8be 183{
46f296b4
LB
184 afi_t afi = AFI_MAX; /* unknown */
185 if (!strcmp(afi_str, "ipv4")) {
186 afi = AFI_IP;
8b1fb8be 187 }
46f296b4
LB
188 else if (!strcmp(afi_str, "ipv6")) {
189 afi = AFI_IP6;
190 }
4e0b7b6d
PG
191 else if (!strcmp(afi_str, "l2vpn")) {
192 afi = AFI_L2VPN;
193 }
46f296b4
LB
194 return afi;
195}
196
197int
198bgp_parse_afi(const char *str, afi_t *afi)
199{
200 *afi = bgp_vty_afi_from_arg(str);
201 if (*afi != AFI_MAX)
202 return 0;
203 else
8b1fb8be
LB
204 return -1;
205}
206
46f296b4
LB
207int
208argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, afi_t *afi)
209{
210 int ret = 0;
211 if (argv_find (argv, argc, "ipv4", index))
212 {
213 ret = 1;
214 if (afi)
215 *afi = AFI_IP;
216 }
217 else if (argv_find (argv, argc, "ipv6", index))
218 {
219 ret = 1;
220 if (afi)
221 *afi = AFI_IP6;
222 }
223 return ret;
224}
225
f51bae9c 226/* supports <unicast|multicast|vpn|encap|labeled-unicast> */
ccbb332a 227safi_t
3b14d86e 228bgp_vty_safi_from_arg(const char *safi_str)
ccbb332a
LB
229{
230 safi_t safi = SAFI_MAX; /* unknown */
231 if (strncmp (safi_str, "m", 1) == 0)
232 safi = SAFI_MULTICAST;
233 else if (strncmp (safi_str, "u", 1) == 0)
234 safi = SAFI_UNICAST;
235 else if (strncmp (safi_str, "e", 1) == 0)
236 safi = SAFI_ENCAP;
237 else if (strncmp (safi_str, "v", 1) == 0)
46f296b4 238 safi = SAFI_MPLS_VPN;
f51bae9c
DS
239 else if (strncmp (safi_str, "l", 1) == 0)
240 safi = SAFI_LABELED_UNICAST;
ccbb332a
LB
241 return safi;
242}
243
8b1fb8be 244int
3289141f 245argv_find_and_parse_safi (struct cmd_token **argv, int argc, int *index, safi_t *safi)
46f296b4
LB
246{
247 int ret = 0;
248 if (argv_find (argv, argc, "unicast", index))
249 {
250 ret = 1;
251 if (safi)
252 *safi = SAFI_UNICAST;
253 }
254 else if (argv_find (argv, argc, "multicast", index))
255 {
256 ret = 1;
257 if (safi)
258 *safi = SAFI_MULTICAST;
259 }
b60f5275
DS
260 else if (argv_find (argv, argc, "labeled-unicast", index))
261 {
262 ret = 1;
263 if (safi)
264 *safi = SAFI_LABELED_UNICAST;
265 }
46f296b4
LB
266 else if (argv_find (argv, argc, "vpn", index))
267 {
268 ret = 1;
269 if (safi)
270 *safi = SAFI_MPLS_VPN;
271 }
272 else if (argv_find (argv, argc, "encap", index))
273 {
274 ret = 1;
275 if (safi)
276 *safi = SAFI_ENCAP;
277 }
4e0b7b6d
PG
278 else if (argv_find (argv, argc, "evpn", index))
279 {
280 ret = 1;
281 if (safi)
282 *safi = SAFI_EVPN;
283 }
46f296b4
LB
284 return ret;
285}
286
7eeee51e 287/*
f212a857 288 * bgp_vty_find_and_parse_afi_safi_bgp
7eeee51e 289 *
f212a857
DS
290 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
291 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
7eeee51e
DS
292 * to appropriate values for the calling function. This is to allow the
293 * calling function to make decisions appropriate for the show command
294 * that is being parsed.
295 *
296 * The show commands are generally of the form:
b60f5275 297 * "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6> [<unicast|multicast|vpn|encap|labeled-unicast>]] ..."
7eeee51e
DS
298 *
299 * Since we use argv_find if the show command in particular doesn't have:
300 * [ip]
301 * [<view|vrf> WORD]
b60f5275 302 * [<ipv4|ipv6> [<unicast|multicast|vpn|encap|labeled-unicast>]]
7eeee51e
DS
303 * The command parsing should still be ok.
304 *
305 * vty -> The vty for the command so we can output some useful data in
306 * the event of a parse error in the vrf.
307 * argv -> The command tokens
308 * argc -> How many command tokens we have
309 * idx -> The current place in the command, generally should be 0 for this function
310 * afi -> The parsed afi if it was included in the show command, returned here
311 * safi -> The parsed safi if it was included in the show command, returned here
f212a857 312 * bgp -> Pointer to the bgp data structure we need to fill in.
7eeee51e
DS
313 *
314 * The function returns the correct location in the parse tree for the
315 * last token found.
0e37c258
DS
316 *
317 * Returns 0 for failure to parse correctly, else the idx position of where
318 * it found the last token.
7eeee51e 319 */
af462945 320int
f212a857
DS
321bgp_vty_find_and_parse_afi_safi_bgp (struct vty *vty, struct cmd_token **argv, int argc, int *idx,
322 afi_t *afi, safi_t *safi, struct bgp **bgp)
af462945
DS
323{
324 char *vrf_name = NULL;
325
b4898a38
DS
326 assert (afi);
327 assert (safi);
f212a857 328 assert (bgp);
b4898a38 329
9317e17d 330 if (argv_find (argv, argc, "ip", idx))
af462945
DS
331 *afi = AFI_IP;
332
9317e17d 333 if (argv_find (argv, argc, "view", idx) || argv_find (argv, argc, "vrf", idx))
af462945 334 {
9317e17d 335 vrf_name = argv[*idx + 1]->arg;
af462945 336
f212a857
DS
337 if (strmatch (vrf_name, "all"))
338 *bgp = NULL;
af462945 339 else
f212a857
DS
340 {
341 *bgp = bgp_lookup_by_name (vrf_name);
342 if (!*bgp)
343 {
344 vty_out (vty, "View/Vrf specified is unknown: %s%s", vrf_name, VTY_NEWLINE);
345 *idx = 0;
346 return 0;
347 }
348 }
af462945 349 }
f212a857 350 else
af462945 351 {
f212a857
DS
352 *bgp = bgp_get_default ();
353 if (!*bgp)
354 {
355 vty_out (vty, "Unable to find default BGP instance%s", VTY_NEWLINE);
356 *idx = 0;
357 return 0;
358 }
af462945 359 }
9317e17d 360
f212a857
DS
361 if (argv_find_and_parse_afi (argv, argc, idx, afi))
362 argv_find_and_parse_safi (argv, argc, idx, safi);
363
9317e17d
DS
364 *idx += 1;
365 return *idx;
af462945
DS
366}
367
94f2b392 368static int
6aeb9e78 369peer_address_self_check (struct bgp *bgp, union sockunion *su)
718e3744 370{
371 struct interface *ifp = NULL;
372
373 if (su->sa.sa_family == AF_INET)
6aeb9e78 374 ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr, bgp->vrf_id);
718e3744 375 else if (su->sa.sa_family == AF_INET6)
f2345335 376 ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr,
6aeb9e78 377 su->sin6.sin6_scope_id, bgp->vrf_id);
718e3744 378
379 if (ifp)
380 return 1;
381
382 return 0;
383}
384
385/* Utility function for looking up peer from VTY. */
f14e6fdb
DS
386/* This is used only for configuration, so disallow if attempted on
387 * a dynamic neighbor.
388 */
94f2b392 389static struct peer *
fd79ac91 390peer_lookup_vty (struct vty *vty, const char *ip_str)
718e3744 391{
cdc2d765 392 struct bgp *bgp = VTY_GET_CONTEXT(bgp);
718e3744 393 int ret;
718e3744 394 union sockunion su;
395 struct peer *peer;
396
cdc2d765
DL
397 if (!bgp) {
398 return NULL;
399 }
718e3744 400
401 ret = str2sockunion (ip_str, &su);
402 if (ret < 0)
403 {
a80beece
DS
404 peer = peer_lookup_by_conf_if (bgp, ip_str);
405 if (!peer)
406 {
04b6bdc0
DW
407 if ((peer = peer_lookup_by_hostname(bgp, ip_str)) == NULL)
408 {
409 vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE);
410 return NULL;
411 }
a80beece 412 }
718e3744 413 }
a80beece 414 else
718e3744 415 {
a80beece
DS
416 peer = peer_lookup (bgp, &su);
417 if (! peer)
418 {
419 vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
420 VTY_NEWLINE);
421 return NULL;
422 }
f14e6fdb
DS
423 if (peer_dynamic_neighbor (peer))
424 {
425 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
426 VTY_NEWLINE);
427 return NULL;
428 }
429
718e3744 430 }
431 return peer;
432}
433
434/* Utility function for looking up peer or peer group. */
f14e6fdb
DS
435/* This is used only for configuration, so disallow if attempted on
436 * a dynamic neighbor.
437 */
c43ed2e4 438struct peer *
fd79ac91 439peer_and_group_lookup_vty (struct vty *vty, const char *peer_str)
718e3744 440{
cdc2d765 441 struct bgp *bgp = VTY_GET_CONTEXT(bgp);
718e3744 442 int ret;
718e3744 443 union sockunion su;
f14e6fdb
DS
444 struct peer *peer = NULL;
445 struct peer_group *group = NULL;
718e3744 446
cdc2d765
DL
447 if (!bgp) {
448 return NULL;
449 }
718e3744 450
451 ret = str2sockunion (peer_str, &su);
452 if (ret == 0)
453 {
f14e6fdb 454 /* IP address, locate peer. */
718e3744 455 peer = peer_lookup (bgp, &su);
718e3744 456 }
457 else
458 {
f14e6fdb 459 /* Not IP, could match either peer configured on interface or a group. */
a80beece 460 peer = peer_lookup_by_conf_if (bgp, peer_str);
f14e6fdb
DS
461 if (!peer)
462 group = peer_group_lookup (bgp, peer_str);
463 }
a80beece 464
f14e6fdb
DS
465 if (peer)
466 {
467 if (peer_dynamic_neighbor (peer))
468 {
469 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
470 VTY_NEWLINE);
471 return NULL;
472 }
473
474 return peer;
718e3744 475 }
476
f14e6fdb
DS
477 if (group)
478 return group->conf;
479
718e3744 480 vty_out (vty, "%% Specify remote-as or peer-group commands first%s",
481 VTY_NEWLINE);
482
483 return NULL;
484}
485
c43ed2e4 486int
718e3744 487bgp_vty_return (struct vty *vty, int ret)
488{
fd79ac91 489 const char *str = NULL;
718e3744 490
491 switch (ret)
492 {
493 case BGP_ERR_INVALID_VALUE:
494 str = "Invalid value";
495 break;
496 case BGP_ERR_INVALID_FLAG:
497 str = "Invalid flag";
498 break;
718e3744 499 case BGP_ERR_PEER_GROUP_SHUTDOWN:
500 str = "Peer-group has been shutdown. Activate the peer-group first";
501 break;
718e3744 502 case BGP_ERR_PEER_FLAG_CONFLICT:
503 str = "Can't set override-capability and strict-capability-match at the same time";
504 break;
718e3744 505 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS:
506 str = "Specify remote-as or peer-group remote AS first";
507 break;
508 case BGP_ERR_PEER_GROUP_CANT_CHANGE:
509 str = "Cannot change the peer-group. Deconfigure first";
510 break;
511 case BGP_ERR_PEER_GROUP_MISMATCH:
4c48cf63 512 str = "Peer is not a member of this peer-group";
718e3744 513 break;
514 case BGP_ERR_PEER_FILTER_CONFLICT:
515 str = "Prefix/distribute list can not co-exist";
516 break;
517 case BGP_ERR_NOT_INTERNAL_PEER:
518 str = "Invalid command. Not an internal neighbor";
519 break;
520 case BGP_ERR_REMOVE_PRIVATE_AS:
5000f21c 521 str = "remove-private-AS cannot be configured for IBGP peers";
718e3744 522 break;
523 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP:
524 str = "Local-AS allowed only for EBGP peers";
525 break;
526 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS:
527 str = "Cannot have local-as same as BGP AS number";
528 break;
0df7c91f
PJ
529 case BGP_ERR_TCPSIG_FAILED:
530 str = "Error while applying TCP-Sig to session(s)";
531 break;
fa411a21
NH
532 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK:
533 str = "ebgp-multihop and ttl-security cannot be configured together";
534 break;
f5a4827d
SH
535 case BGP_ERR_NO_IBGP_WITH_TTLHACK:
536 str = "ttl-security only allowed for EBGP peers";
537 break;
c7122e14
DS
538 case BGP_ERR_AS_OVERRIDE:
539 str = "as-override cannot be configured for IBGP peers";
540 break;
f14e6fdb
DS
541 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT:
542 str = "Invalid limit for number of dynamic neighbors";
543 break;
544 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS:
545 str = "Dynamic neighbor listen range already exists";
546 break;
547 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER:
548 str = "Operation not allowed on a dynamic neighbor";
549 break;
63fa10b5
QY
550 case BGP_ERR_INVALID_FOR_DIRECT_PEER:
551 str = "Operation not allowed on a directly connected neighbor";
552 break;
718e3744 553 }
554 if (str)
555 {
556 vty_out (vty, "%% %s%s", str, VTY_NEWLINE);
557 return CMD_WARNING;
558 }
559 return CMD_SUCCESS;
560}
561
7aafcaca
DS
562/* BGP clear sort. */
563enum clear_sort
564{
565 clear_all,
566 clear_peer,
567 clear_group,
568 clear_external,
569 clear_as
570};
571
7aafcaca
DS
572static void
573bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi,
574 safi_t safi, int error)
575{
576 switch (error)
577 {
578 case BGP_ERR_AF_UNCONFIGURED:
579 vty_out (vty,
46f296b4
LB
580 "%%BGP: Enable %s address family for the neighbor %s%s",
581 afi_safi_print(afi, safi), peer->host, VTY_NEWLINE);
7aafcaca
DS
582 break;
583 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED:
584 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);
585 break;
586 default:
587 break;
588 }
589}
590
591/* `clear ip bgp' functions. */
592static int
593bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
594 enum clear_sort sort,enum bgp_clear_type stype, const char *arg)
595{
596 int ret;
597 struct peer *peer;
598 struct listnode *node, *nnode;
599
600 /* Clear all neighbors. */
601 /*
602 * Pass along pointer to next node to peer_clear() when walking all nodes
603 * on the BGP instance as that may get freed if it is a doppelganger
604 */
605 if (sort == clear_all)
606 {
607 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
608 {
609 if (stype == BGP_CLEAR_SOFT_NONE)
610 ret = peer_clear (peer, &nnode);
611 else if (peer->afc[afi][safi])
612 ret = peer_clear_soft (peer, afi, safi, stype);
613 else
614 ret = 0;
615
616 if (ret < 0)
617 bgp_clear_vty_error (vty, peer, afi, safi, ret);
618 }
619
620 /* This is to apply read-only mode on this clear. */
621 if (stype == BGP_CLEAR_SOFT_NONE)
622 bgp->update_delay_over = 0;
623
624 return CMD_SUCCESS;
625 }
626
627 /* Clear specified neighbors. */
628 if (sort == clear_peer)
629 {
630 union sockunion su;
631 int ret;
632
633 /* Make sockunion for lookup. */
634 ret = str2sockunion (arg, &su);
635 if (ret < 0)
636 {
637 peer = peer_lookup_by_conf_if (bgp, arg);
638 if (!peer)
639 {
04b6bdc0
DW
640 peer = peer_lookup_by_hostname(bgp, arg);
641 if (!peer)
642 {
643 vty_out (vty, "Malformed address or name: %s%s", arg, VTY_NEWLINE);
644 return CMD_WARNING;
645 }
7aafcaca
DS
646 }
647 }
648 else
649 {
650 peer = peer_lookup (bgp, &su);
651 if (! peer)
652 {
653 vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE);
654 return CMD_WARNING;
655 }
656 }
657
658 if (stype == BGP_CLEAR_SOFT_NONE)
659 ret = peer_clear (peer, NULL);
660 else
661 ret = peer_clear_soft (peer, afi, safi, stype);
662
663 if (ret < 0)
664 bgp_clear_vty_error (vty, peer, afi, safi, ret);
665
666 return CMD_SUCCESS;
667 }
668
669 /* Clear all peer-group members. */
670 if (sort == clear_group)
671 {
672 struct peer_group *group;
673
674 group = peer_group_lookup (bgp, arg);
675 if (! group)
676 {
677 vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE);
678 return CMD_WARNING;
679 }
680
681 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
682 {
683 if (stype == BGP_CLEAR_SOFT_NONE)
684 {
18f1dc06 685 peer_clear (peer, NULL);
7aafcaca
DS
686 continue;
687 }
688
c8560b44 689 if (! peer->afc[afi][safi])
7aafcaca
DS
690 continue;
691
692 ret = peer_clear_soft (peer, afi, safi, stype);
693
694 if (ret < 0)
695 bgp_clear_vty_error (vty, peer, afi, safi, ret);
696 }
697 return CMD_SUCCESS;
698 }
699
700 if (sort == clear_external)
701 {
702 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
703 {
704 if (peer->sort == BGP_PEER_IBGP)
705 continue;
706
707 if (stype == BGP_CLEAR_SOFT_NONE)
708 ret = peer_clear (peer, &nnode);
709 else
710 ret = peer_clear_soft (peer, afi, safi, stype);
711
712 if (ret < 0)
713 bgp_clear_vty_error (vty, peer, afi, safi, ret);
714 }
715 return CMD_SUCCESS;
716 }
717
718 if (sort == clear_as)
719 {
720 as_t as;
721 int find = 0;
722
723 VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX);
724
725 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
726 {
727 if (peer->as != as)
728 continue;
729
730 find = 1;
731 if (stype == BGP_CLEAR_SOFT_NONE)
732 ret = peer_clear (peer, &nnode);
733 else
734 ret = peer_clear_soft (peer, afi, safi, stype);
735
736 if (ret < 0)
737 bgp_clear_vty_error (vty, peer, afi, safi, ret);
738 }
739 if (! find)
740 vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg,
741 VTY_NEWLINE);
742 return CMD_SUCCESS;
743 }
744
745 return CMD_SUCCESS;
746}
747
748static int
749bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi,
750 enum clear_sort sort, enum bgp_clear_type stype,
751 const char *arg)
752{
753 struct bgp *bgp;
754
755 /* BGP structure lookup. */
756 if (name)
757 {
758 bgp = bgp_lookup_by_name (name);
759 if (bgp == NULL)
760 {
6aeb9e78 761 vty_out (vty, "Can't find BGP instance %s%s", name, VTY_NEWLINE);
7aafcaca
DS
762 return CMD_WARNING;
763 }
764 }
765 else
766 {
f31fa004 767 bgp = bgp_get_default ();
7aafcaca
DS
768 if (bgp == NULL)
769 {
770 vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
771 return CMD_WARNING;
772 }
773 }
774
775 return bgp_clear (vty, bgp, afi, safi, sort, stype, arg);
776}
777
778/* clear soft inbound */
779static void
f31fa004 780bgp_clear_star_soft_in (struct vty *vty, const char *name)
7aafcaca 781{
b09b5ae0 782 bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all,
7aafcaca 783 BGP_CLEAR_SOFT_IN, NULL);
f31fa004 784 bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all,
7aafcaca 785 BGP_CLEAR_SOFT_IN, NULL);
7aafcaca
DS
786}
787
788/* clear soft outbound */
789static void
f31fa004 790bgp_clear_star_soft_out (struct vty *vty, const char *name)
7aafcaca 791{
f31fa004 792 bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all,
7aafcaca 793 BGP_CLEAR_SOFT_OUT, NULL);
f31fa004 794 bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all,
7aafcaca 795 BGP_CLEAR_SOFT_OUT, NULL);
7aafcaca
DS
796}
797
798
718e3744 799/* BGP global configuration. */
800
801DEFUN (bgp_multiple_instance_func,
802 bgp_multiple_instance_cmd,
803 "bgp multiple-instance",
804 BGP_STR
805 "Enable bgp multiple instance\n")
806{
807 bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE);
808 return CMD_SUCCESS;
809}
810
811DEFUN (no_bgp_multiple_instance,
812 no_bgp_multiple_instance_cmd,
813 "no bgp multiple-instance",
814 NO_STR
815 BGP_STR
816 "BGP multiple instance\n")
817{
818 int ret;
819
820 ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE);
821 if (ret < 0)
822 {
823 vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE);
824 return CMD_WARNING;
825 }
826 return CMD_SUCCESS;
827}
828
829DEFUN (bgp_config_type,
830 bgp_config_type_cmd,
6147e2c6 831 "bgp config-type <cisco|zebra>",
718e3744 832 BGP_STR
833 "Configuration type\n"
834 "cisco\n"
835 "zebra\n")
836{
c500ae40
DW
837 int idx_vendor = 2;
838 if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0)
718e3744 839 bgp_option_set (BGP_OPT_CONFIG_CISCO);
840 else
841 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
842
843 return CMD_SUCCESS;
844}
845
846DEFUN (no_bgp_config_type,
847 no_bgp_config_type_cmd,
c7178fe7 848 "no bgp config-type [<cisco|zebra>]",
718e3744 849 NO_STR
850 BGP_STR
838758ac
DW
851 "Display configuration type\n"
852 "cisco\n"
853 "zebra\n")
718e3744 854{
855 bgp_option_unset (BGP_OPT_CONFIG_CISCO);
856 return CMD_SUCCESS;
857}
858
813d4307 859
718e3744 860DEFUN (no_synchronization,
861 no_synchronization_cmd,
862 "no synchronization",
863 NO_STR
864 "Perform IGP synchronization\n")
865{
866 return CMD_SUCCESS;
867}
868
869DEFUN (no_auto_summary,
870 no_auto_summary_cmd,
871 "no auto-summary",
872 NO_STR
873 "Enable automatic network number summarization\n")
874{
875 return CMD_SUCCESS;
876}
3d515fd9 877
718e3744 878/* "router bgp" commands. */
505e5056 879DEFUN_NOSH (router_bgp,
f412b39a 880 router_bgp_cmd,
31500417 881 "router bgp [(1-4294967295) [<view|vrf> WORD]]",
718e3744 882 ROUTER_STR
883 BGP_STR
31500417
DW
884 AS_STR
885 BGP_INSTANCE_HELP_STR)
718e3744 886{
31500417
DW
887 int idx_asn = 2;
888 int idx_view_vrf = 3;
889 int idx_vrf = 4;
718e3744 890 int ret;
891 as_t as;
892 struct bgp *bgp;
fd79ac91 893 const char *name = NULL;
ad4cbda1 894 enum bgp_instance_type inst_type;
718e3744 895
2385a876 896 // "router bgp" without an ASN
31500417 897 if (argc == 2)
2385a876 898 {
6aeb9e78 899 //Pending: Make VRF option available for ASN less config
2385a876 900 bgp = bgp_get_default();
718e3744 901
2385a876
DW
902 if (bgp == NULL)
903 {
904 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
905 return CMD_WARNING;
906 }
718e3744 907
2385a876
DW
908 if (listcount(bm->bgp) > 1)
909 {
910 vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE);
911 return CMD_WARNING;
912 }
913 }
914
915 // "router bgp X"
916 else
718e3744 917 {
31500417 918 VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX);
2385a876 919
ad4cbda1 920 inst_type = BGP_INSTANCE_TYPE_DEFAULT;
31500417 921 if (argc > 3)
ad4cbda1 922 {
31500417
DW
923 name = argv[idx_vrf]->arg;
924
e52702f2 925 if (!strcmp(argv[idx_view_vrf]->text, "vrf"))
ad4cbda1 926 inst_type = BGP_INSTANCE_TYPE_VRF;
e52702f2 927 else if (!strcmp(argv[idx_view_vrf]->text, "view"))
ad4cbda1 928 inst_type = BGP_INSTANCE_TYPE_VIEW;
929 }
2385a876 930
ad4cbda1 931 ret = bgp_get (&bgp, &as, name, inst_type);
2385a876
DW
932 switch (ret)
933 {
934 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
935 vty_out (vty, "Please specify 'bgp multiple-instance' first%s",
936 VTY_NEWLINE);
937 return CMD_WARNING;
938 case BGP_ERR_AS_MISMATCH:
939 vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE);
940 return CMD_WARNING;
941 case BGP_ERR_INSTANCE_MISMATCH:
6aeb9e78 942 vty_out (vty, "BGP instance name and AS number mismatch%s", VTY_NEWLINE);
2385a876
DW
943 vty_out (vty, "BGP instance is already running; AS is %u%s",
944 as, VTY_NEWLINE);
945 return CMD_WARNING;
946 }
6aeb9e78
DS
947
948 /* Pending: handle when user tries to change a view to vrf n vv. */
718e3744 949 }
950
cdc2d765 951 VTY_PUSH_CONTEXT(BGP_NODE, bgp);
718e3744 952
953 return CMD_SUCCESS;
954}
955
718e3744 956/* "no router bgp" commands. */
957DEFUN (no_router_bgp,
958 no_router_bgp_cmd,
31500417 959 "no router bgp [(1-4294967295) [<view|vrf> WORD]]",
718e3744 960 NO_STR
961 ROUTER_STR
962 BGP_STR
31500417
DW
963 AS_STR
964 BGP_INSTANCE_HELP_STR)
718e3744 965{
31500417 966 int idx_asn = 3;
31500417 967 int idx_vrf = 5;
718e3744 968 as_t as;
969 struct bgp *bgp;
fd79ac91 970 const char *name = NULL;
718e3744 971
7fb21a9f 972 // "no router bgp" without an ASN
31500417 973 if (argc == 3)
7fb21a9f
QY
974 {
975 //Pending: Make VRF option available for ASN less config
976 bgp = bgp_get_default();
718e3744 977
7fb21a9f
QY
978 if (bgp == NULL)
979 {
980 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
981 return CMD_WARNING;
982 }
983
984 if (listcount(bm->bgp) > 1)
985 {
986 vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE);
987 return CMD_WARNING;
988 }
989 }
990 else
718e3744 991 {
31500417 992 VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX);
7fb21a9f 993
31500417
DW
994 if (argc > 4)
995 name = argv[idx_vrf]->arg;
7fb21a9f
QY
996
997 /* Lookup bgp structure. */
998 bgp = bgp_lookup (as, name);
999 if (! bgp)
1000 {
1001 vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE);
1002 return CMD_WARNING;
1003 }
718e3744 1004 }
1005
1006 bgp_delete (bgp);
1007
1008 return CMD_SUCCESS;
1009}
1010
6b0655a2 1011
7fb21a9f 1012
718e3744 1013/* BGP router-id. */
1014
1015DEFUN (bgp_router_id,
1016 bgp_router_id_cmd,
1017 "bgp router-id A.B.C.D",
1018 BGP_STR
1019 "Override configured router identifier\n"
1020 "Manually configured router identifier\n")
1021{
cdc2d765 1022 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40 1023 int idx_ipv4 = 2;
718e3744 1024 int ret;
1025 struct in_addr id;
718e3744 1026
c500ae40 1027 ret = inet_aton (argv[idx_ipv4]->arg, &id);
718e3744 1028 if (! ret)
1029 {
1030 vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE);
1031 return CMD_WARNING;
1032 }
1033
0e6cb743 1034 bgp_router_id_static_set (bgp, id);
718e3744 1035
1036 return CMD_SUCCESS;
1037}
1038
1039DEFUN (no_bgp_router_id,
1040 no_bgp_router_id_cmd,
31500417 1041 "no bgp router-id [A.B.C.D]",
718e3744 1042 NO_STR
1043 BGP_STR
31500417
DW
1044 "Override configured router identifier\n"
1045 "Manually configured router identifier\n")
718e3744 1046{
cdc2d765 1047 VTY_DECLVAR_CONTEXT(bgp, bgp);
31500417 1048 int idx_router_id = 3;
718e3744 1049 int ret;
1050 struct in_addr id;
718e3744 1051
31500417 1052 if (argc > idx_router_id)
718e3744 1053 {
31500417 1054 ret = inet_aton (argv[idx_router_id]->arg, &id);
718e3744 1055 if (! ret)
e018c7cc
SK
1056 {
1057 vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE);
1058 return CMD_WARNING;
1059 }
718e3744 1060
18a6dce6 1061 if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id))
e018c7cc
SK
1062 {
1063 vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
1064 return CMD_WARNING;
1065 }
718e3744 1066 }
1067
0e6cb743
DL
1068 id.s_addr = 0;
1069 bgp_router_id_static_set (bgp, id);
718e3744 1070
1071 return CMD_SUCCESS;
1072}
1073
6b0655a2 1074
718e3744 1075/* BGP Cluster ID. */
718e3744 1076DEFUN (bgp_cluster_id,
1077 bgp_cluster_id_cmd,
838758ac 1078 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
718e3744 1079 BGP_STR
1080 "Configure Route-Reflector Cluster-id\n"
838758ac
DW
1081 "Route-Reflector Cluster-id in IP address format\n"
1082 "Route-Reflector Cluster-id as 32 bit quantity\n")
718e3744 1083{
cdc2d765 1084 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40 1085 int idx_ipv4 = 2;
718e3744 1086 int ret;
718e3744 1087 struct in_addr cluster;
1088
c500ae40 1089 ret = inet_aton (argv[idx_ipv4]->arg, &cluster);
718e3744 1090 if (! ret)
1091 {
1092 vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE);
1093 return CMD_WARNING;
1094 }
1095
1096 bgp_cluster_id_set (bgp, &cluster);
f31fa004 1097 bgp_clear_star_soft_out (vty, bgp->name);
718e3744 1098
1099 return CMD_SUCCESS;
1100}
1101
718e3744 1102DEFUN (no_bgp_cluster_id,
1103 no_bgp_cluster_id_cmd,
c7178fe7 1104 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
718e3744 1105 NO_STR
1106 BGP_STR
838758ac
DW
1107 "Configure Route-Reflector Cluster-id\n"
1108 "Route-Reflector Cluster-id in IP address format\n"
1109 "Route-Reflector Cluster-id as 32 bit quantity\n")
718e3744 1110{
cdc2d765 1111 VTY_DECLVAR_CONTEXT(bgp, bgp);
718e3744 1112 bgp_cluster_id_unset (bgp);
f31fa004 1113 bgp_clear_star_soft_out (vty, bgp->name);
718e3744 1114
1115 return CMD_SUCCESS;
1116}
1117
718e3744 1118DEFUN (bgp_confederation_identifier,
1119 bgp_confederation_identifier_cmd,
9ccf14f7 1120 "bgp confederation identifier (1-4294967295)",
718e3744 1121 "BGP specific commands\n"
1122 "AS confederation parameters\n"
1123 "AS number\n"
1124 "Set routing domain confederation AS\n")
1125{
cdc2d765 1126 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40 1127 int idx_number = 3;
718e3744 1128 as_t as;
1129
c500ae40 1130 VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX);
718e3744 1131
1132 bgp_confederation_id_set (bgp, as);
1133
1134 return CMD_SUCCESS;
1135}
1136
1137DEFUN (no_bgp_confederation_identifier,
1138 no_bgp_confederation_identifier_cmd,
838758ac 1139 "no bgp confederation identifier [(1-4294967295)]",
718e3744 1140 NO_STR
1141 "BGP specific commands\n"
1142 "AS confederation parameters\n"
3a2d747c
QY
1143 "AS number\n"
1144 "Set routing domain confederation AS\n")
718e3744 1145{
cdc2d765 1146 VTY_DECLVAR_CONTEXT(bgp, bgp);
718e3744 1147 bgp_confederation_id_unset (bgp);
1148
1149 return CMD_SUCCESS;
1150}
1151
718e3744 1152DEFUN (bgp_confederation_peers,
1153 bgp_confederation_peers_cmd,
12dcf78e 1154 "bgp confederation peers (1-4294967295)...",
718e3744 1155 "BGP specific commands\n"
1156 "AS confederation parameters\n"
1157 "Peer ASs in BGP confederation\n"
1158 AS_STR)
1159{
cdc2d765 1160 VTY_DECLVAR_CONTEXT(bgp, bgp);
58749582 1161 int idx_asn = 3;
718e3744 1162 as_t as;
1163 int i;
1164
58749582 1165 for (i = idx_asn; i < argc; i++)
718e3744 1166 {
afec25d9 1167 VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX);
718e3744 1168
1169 if (bgp->as == as)
1170 {
1171 vty_out (vty, "%% Local member-AS not allowed in confed peer list%s",
1172 VTY_NEWLINE);
1173 continue;
1174 }
1175
1176 bgp_confederation_peers_add (bgp, as);
1177 }
1178 return CMD_SUCCESS;
1179}
1180
1181DEFUN (no_bgp_confederation_peers,
1182 no_bgp_confederation_peers_cmd,
e83a9414 1183 "no bgp confederation peers (1-4294967295)...",
718e3744 1184 NO_STR
1185 "BGP specific commands\n"
1186 "AS confederation parameters\n"
1187 "Peer ASs in BGP confederation\n"
1188 AS_STR)
1189{
cdc2d765 1190 VTY_DECLVAR_CONTEXT(bgp, bgp);
58749582 1191 int idx_asn = 4;
718e3744 1192 as_t as;
1193 int i;
1194
58749582 1195 for (i = idx_asn; i < argc; i++)
718e3744 1196 {
afec25d9 1197 VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX);
0b2aa3a0 1198
718e3744 1199 bgp_confederation_peers_remove (bgp, as);
1200 }
1201 return CMD_SUCCESS;
1202}
6b0655a2 1203
5e242b0d
DS
1204/**
1205 * Central routine for maximum-paths configuration.
1206 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1207 * @set: 1 for setting values, 0 for removing the max-paths config.
1208 */
ffd0c037
DS
1209static int
1210bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths,
5e242b0d 1211 u_int16_t options, int set)
165b5fff 1212{
cdc2d765 1213 VTY_DECLVAR_CONTEXT(bgp, bgp);
4c9dee98 1214 u_int16_t maxpaths = 0;
165b5fff 1215 int ret;
5e242b0d
DS
1216 afi_t afi;
1217 safi_t safi;
165b5fff 1218
5e242b0d
DS
1219 afi = bgp_node_afi (vty);
1220 safi = bgp_node_safi (vty);
165b5fff 1221
5e242b0d 1222 if (set)
4c9dee98 1223 {
c59f2066 1224 maxpaths = strtol(mpaths, NULL, 10);
37fe7731
DS
1225 if (maxpaths > multipath_num)
1226 {
1227 vty_out (vty,
1228 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1229 maxpaths, multipath_num);
1230 return CMD_WARNING;
1231 }
dff6764a 1232 ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths, options);
4c9dee98 1233 }
5e242b0d
DS
1234 else
1235 ret = bgp_maximum_paths_unset (bgp, afi, safi, peer_type);
165b5fff 1236
165b5fff
JB
1237 if (ret < 0)
1238 {
1239 vty_out (vty,
5e242b0d
DS
1240 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u%s",
1241 (set == 1) ? "" : "un",
1242 (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp",
1243 maxpaths, afi, safi, VTY_NEWLINE);
165b5fff
JB
1244 return CMD_WARNING;
1245 }
1246
7aafcaca
DS
1247 bgp_recalculate_all_bestpaths (bgp);
1248
165b5fff
JB
1249 return CMD_SUCCESS;
1250}
1251
abc920f8
DS
1252DEFUN (bgp_maxmed_admin,
1253 bgp_maxmed_admin_cmd,
1254 "bgp max-med administrative ",
1255 BGP_STR
1256 "Advertise routes with max-med\n"
1257 "Administratively applied, for an indefinite period\n")
1258{
cdc2d765 1259 VTY_DECLVAR_CONTEXT(bgp, bgp);
abc920f8
DS
1260
1261 bgp->v_maxmed_admin = 1;
1262 bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT;
1263
1264 bgp_maxmed_update(bgp);
1265
1266 return CMD_SUCCESS;
1267}
1268
1269DEFUN (bgp_maxmed_admin_medv,
1270 bgp_maxmed_admin_medv_cmd,
6147e2c6 1271 "bgp max-med administrative (0-4294967294)",
abc920f8
DS
1272 BGP_STR
1273 "Advertise routes with max-med\n"
1274 "Administratively applied, for an indefinite period\n"
1275 "Max MED value to be used\n")
1276{
cdc2d765 1277 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40 1278 int idx_number = 3;
abc920f8
DS
1279
1280 bgp->v_maxmed_admin = 1;
c500ae40 1281 VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[idx_number]->arg);
abc920f8
DS
1282
1283 bgp_maxmed_update(bgp);
1284
1285 return CMD_SUCCESS;
1286}
1287
1288DEFUN (no_bgp_maxmed_admin,
1289 no_bgp_maxmed_admin_cmd,
8334fd5a 1290 "no bgp max-med administrative [(0-4294967294)]",
abc920f8
DS
1291 NO_STR
1292 BGP_STR
1293 "Advertise routes with max-med\n"
838758ac
DW
1294 "Administratively applied, for an indefinite period\n"
1295 "Max MED value to be used\n")
abc920f8 1296{
cdc2d765 1297 VTY_DECLVAR_CONTEXT(bgp, bgp);
abc920f8
DS
1298 bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED;
1299 bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT;
abc920f8
DS
1300 bgp_maxmed_update(bgp);
1301
1302 return CMD_SUCCESS;
1303}
1304
abc920f8
DS
1305DEFUN (bgp_maxmed_onstartup,
1306 bgp_maxmed_onstartup_cmd,
6147e2c6 1307 "bgp max-med on-startup (5-86400)",
abc920f8
DS
1308 BGP_STR
1309 "Advertise routes with max-med\n"
1310 "Effective on a startup\n"
1311 "Time (seconds) period for max-med\n")
1312{
cdc2d765 1313 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40 1314 int idx_number = 3;
c500ae40 1315 VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg);
abc920f8 1316 bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT;
abc920f8
DS
1317 bgp_maxmed_update(bgp);
1318
1319 return CMD_SUCCESS;
1320}
1321
1322DEFUN (bgp_maxmed_onstartup_medv,
1323 bgp_maxmed_onstartup_medv_cmd,
6147e2c6 1324 "bgp max-med on-startup (5-86400) (0-4294967294)",
abc920f8
DS
1325 BGP_STR
1326 "Advertise routes with max-med\n"
1327 "Effective on a startup\n"
1328 "Time (seconds) period for max-med\n"
1329 "Max MED value to be used\n")
1330{
cdc2d765 1331 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40
DW
1332 int idx_number = 3;
1333 int idx_number_2 = 4;
c500ae40
DW
1334 VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg);
1335 VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[idx_number_2]->arg);
abc920f8
DS
1336 bgp_maxmed_update(bgp);
1337
1338 return CMD_SUCCESS;
1339}
1340
1341DEFUN (no_bgp_maxmed_onstartup,
1342 no_bgp_maxmed_onstartup_cmd,
8334fd5a 1343 "no bgp max-med on-startup [(5-86400) [(0-4294967294)]]",
abc920f8
DS
1344 NO_STR
1345 BGP_STR
1346 "Advertise routes with max-med\n"
838758ac
DW
1347 "Effective on a startup\n"
1348 "Time (seconds) period for max-med\n"
1349 "Max MED value to be used\n")
abc920f8 1350{
cdc2d765 1351 VTY_DECLVAR_CONTEXT(bgp, bgp);
abc920f8
DS
1352
1353 /* Cancel max-med onstartup if its on */
1354 if (bgp->t_maxmed_onstartup)
1355 {
1356 THREAD_TIMER_OFF (bgp->t_maxmed_onstartup);
1357 bgp->maxmed_onstartup_over = 1;
1358 }
1359
1360 bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED;
1361 bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT;
1362
1363 bgp_maxmed_update(bgp);
1364
1365 return CMD_SUCCESS;
1366}
1367
f188f2c4
DS
1368static int
1369bgp_update_delay_config_vty (struct vty *vty, const char *delay,
1370 const char *wait)
1371{
cdc2d765 1372 VTY_DECLVAR_CONTEXT(bgp, bgp);
f188f2c4
DS
1373 u_int16_t update_delay;
1374 u_int16_t establish_wait;
1375
f188f2c4
DS
1376 VTY_GET_INTEGER_RANGE ("update-delay", update_delay, delay,
1377 BGP_UPDATE_DELAY_MIN, BGP_UPDATE_DELAY_MAX);
1378
1379 if (!wait) /* update-delay <delay> */
1380 {
1381 bgp->v_update_delay = update_delay;
1382 bgp->v_establish_wait = bgp->v_update_delay;
1383 return CMD_SUCCESS;
1384 }
1385
1386 /* update-delay <delay> <establish-wait> */
1387 establish_wait = atoi (wait);
1388 if (update_delay < establish_wait)
1389 {
1390 vty_out (vty, "%%Failed: update-delay less than the establish-wait!%s",
1391 VTY_NEWLINE);
1392 return CMD_WARNING;
1393 }
1394
1395 bgp->v_update_delay = update_delay;
1396 bgp->v_establish_wait = establish_wait;
1397
1398 return CMD_SUCCESS;
1399}
1400
1401static int
1402bgp_update_delay_deconfig_vty (struct vty *vty)
1403{
cdc2d765 1404 VTY_DECLVAR_CONTEXT(bgp, bgp);
f188f2c4
DS
1405
1406 bgp->v_update_delay = BGP_UPDATE_DELAY_DEF;
1407 bgp->v_establish_wait = bgp->v_update_delay;
1408
1409 return CMD_SUCCESS;
1410}
1411
1412int
1413bgp_config_write_update_delay (struct vty *vty, struct bgp *bgp)
1414{
1415 if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF)
1416 {
1417 vty_out (vty, " update-delay %d", bgp->v_update_delay);
1418 if (bgp->v_update_delay != bgp->v_establish_wait)
1419 vty_out (vty, " %d", bgp->v_establish_wait);
1420 vty_out (vty, "%s", VTY_NEWLINE);
1421 }
1422
1423 return 0;
1424}
1425
1426
1427/* Update-delay configuration */
1428DEFUN (bgp_update_delay,
1429 bgp_update_delay_cmd,
6147e2c6 1430 "update-delay (0-3600)",
f188f2c4
DS
1431 "Force initial delay for best-path and updates\n"
1432 "Seconds\n")
1433{
c500ae40
DW
1434 int idx_number = 1;
1435 return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL);
f188f2c4
DS
1436}
1437
1438DEFUN (bgp_update_delay_establish_wait,
1439 bgp_update_delay_establish_wait_cmd,
6147e2c6 1440 "update-delay (0-3600) (1-3600)",
f188f2c4
DS
1441 "Force initial delay for best-path and updates\n"
1442 "Seconds\n"
1443 "Wait for peers to be established\n"
1444 "Seconds\n")
1445{
c500ae40
DW
1446 int idx_number = 1;
1447 int idx_number_2 = 2;
1448 return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, argv[idx_number_2]->arg);
f188f2c4
DS
1449}
1450
1451/* Update-delay deconfiguration */
1452DEFUN (no_bgp_update_delay,
1453 no_bgp_update_delay_cmd,
838758ac
DW
1454 "no update-delay [(0-3600) [(1-3600)]]",
1455 NO_STR
f188f2c4 1456 "Force initial delay for best-path and updates\n"
838758ac
DW
1457 "Seconds\n"
1458 "Wait for peers to be established\n")
f188f2c4
DS
1459{
1460 return bgp_update_delay_deconfig_vty(vty);
1461}
1462
5e242b0d 1463
ffd0c037
DS
1464static int
1465bgp_wpkt_quanta_config_vty (struct vty *vty, const char *num, char set)
cb1faec9 1466{
cdc2d765 1467 VTY_DECLVAR_CONTEXT(bgp, bgp);
cb1faec9
DS
1468
1469 if (set)
1470 VTY_GET_INTEGER_RANGE ("write-quanta", bgp->wpkt_quanta, num,
4543bbb4 1471 1, 10000);
cb1faec9
DS
1472 else
1473 bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX;
1474
1475 return CMD_SUCCESS;
1476}
1477
1478int
1479bgp_config_write_wpkt_quanta (struct vty *vty, struct bgp *bgp)
1480{
1481 if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX)
1482 vty_out (vty, " write-quanta %d%s",
1483 bgp->wpkt_quanta, VTY_NEWLINE);
1484
1485 return 0;
1486}
1487
1488
1489/* Update-delay configuration */
1490DEFUN (bgp_wpkt_quanta,
1491 bgp_wpkt_quanta_cmd,
6147e2c6 1492 "write-quanta (1-10000)",
cb1faec9
DS
1493 "How many packets to write to peer socket per run\n"
1494 "Number of packets\n")
1495{
c500ae40
DW
1496 int idx_number = 1;
1497 return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1);
cb1faec9
DS
1498}
1499
1500/* Update-delay deconfiguration */
1501DEFUN (no_bgp_wpkt_quanta,
1502 no_bgp_wpkt_quanta_cmd,
6147e2c6 1503 "no write-quanta (1-10000)",
d7fa34c1 1504 NO_STR
cb1faec9
DS
1505 "How many packets to write to peer socket per run\n"
1506 "Number of packets\n")
1507{
c500ae40
DW
1508 int idx_number = 2;
1509 return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0);
cb1faec9
DS
1510}
1511
ffd0c037 1512static int
3f9c7369
DS
1513bgp_coalesce_config_vty (struct vty *vty, const char *num, char set)
1514{
cdc2d765 1515 VTY_DECLVAR_CONTEXT(bgp, bgp);
3f9c7369
DS
1516
1517 if (set)
1518 VTY_GET_INTEGER_RANGE ("coalesce-time", bgp->coalesce_time, num,
1519 0, 4294967295);
1520 else
1521 bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME;
1522
1523 return CMD_SUCCESS;
1524}
1525
1526int
1527bgp_config_write_coalesce_time (struct vty *vty, struct bgp *bgp)
1528{
1529 if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME)
1530 vty_out (vty, " coalesce-time %d%s",
1531 bgp->coalesce_time, VTY_NEWLINE);
1532
1533 return 0;
1534}
1535
1536
1537DEFUN (bgp_coalesce_time,
1538 bgp_coalesce_time_cmd,
6147e2c6 1539 "coalesce-time (0-4294967295)",
3f9c7369
DS
1540 "Subgroup coalesce timer\n"
1541 "Subgroup coalesce timer value (in ms)\n")
1542{
c500ae40
DW
1543 int idx_number = 1;
1544 return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 1);
3f9c7369
DS
1545}
1546
1547DEFUN (no_bgp_coalesce_time,
1548 no_bgp_coalesce_time_cmd,
6147e2c6 1549 "no coalesce-time (0-4294967295)",
3a2d747c 1550 NO_STR
3f9c7369
DS
1551 "Subgroup coalesce timer\n"
1552 "Subgroup coalesce timer value (in ms)\n")
1553{
c500ae40
DW
1554 int idx_number = 2;
1555 return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 0);
3f9c7369
DS
1556}
1557
5e242b0d
DS
1558/* Maximum-paths configuration */
1559DEFUN (bgp_maxpaths,
1560 bgp_maxpaths_cmd,
9ccf14f7 1561 "maximum-paths (1-255)",
5e242b0d
DS
1562 "Forward packets over multiple paths\n"
1563 "Number of paths\n")
1564{
c500ae40
DW
1565 int idx_number = 1;
1566 return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[idx_number]->arg, 0, 1);
5e242b0d
DS
1567}
1568
596c17ba
DW
1569ALIAS_HIDDEN (bgp_maxpaths,
1570 bgp_maxpaths_hidden_cmd,
1571 "maximum-paths (1-255)",
1572 "Forward packets over multiple paths\n"
1573 "Number of paths\n")
1574
165b5fff
JB
1575DEFUN (bgp_maxpaths_ibgp,
1576 bgp_maxpaths_ibgp_cmd,
9ccf14f7 1577 "maximum-paths ibgp (1-255)",
165b5fff
JB
1578 "Forward packets over multiple paths\n"
1579 "iBGP-multipath\n"
1580 "Number of paths\n")
1581{
c500ae40
DW
1582 int idx_number = 2;
1583 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, 0, 1);
5e242b0d 1584}
165b5fff 1585
596c17ba
DW
1586ALIAS_HIDDEN (bgp_maxpaths_ibgp,
1587 bgp_maxpaths_ibgp_hidden_cmd,
1588 "maximum-paths ibgp (1-255)",
1589 "Forward packets over multiple paths\n"
1590 "iBGP-multipath\n"
1591 "Number of paths\n")
1592
5e242b0d
DS
1593DEFUN (bgp_maxpaths_ibgp_cluster,
1594 bgp_maxpaths_ibgp_cluster_cmd,
9ccf14f7 1595 "maximum-paths ibgp (1-255) equal-cluster-length",
5e242b0d
DS
1596 "Forward packets over multiple paths\n"
1597 "iBGP-multipath\n"
1598 "Number of paths\n"
1599 "Match the cluster length\n")
1600{
c500ae40
DW
1601 int idx_number = 2;
1602 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg,
5e242b0d 1603 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1);
165b5fff
JB
1604}
1605
596c17ba
DW
1606ALIAS_HIDDEN (bgp_maxpaths_ibgp_cluster,
1607 bgp_maxpaths_ibgp_cluster_hidden_cmd,
1608 "maximum-paths ibgp (1-255) equal-cluster-length",
1609 "Forward packets over multiple paths\n"
1610 "iBGP-multipath\n"
1611 "Number of paths\n"
1612 "Match the cluster length\n")
1613
165b5fff
JB
1614DEFUN (no_bgp_maxpaths,
1615 no_bgp_maxpaths_cmd,
9ccf14f7 1616 "no maximum-paths [(1-255)]",
165b5fff
JB
1617 NO_STR
1618 "Forward packets over multiple paths\n"
1619 "Number of paths\n")
1620{
5e242b0d 1621 return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0);
165b5fff
JB
1622}
1623
596c17ba
DW
1624ALIAS_HIDDEN (no_bgp_maxpaths,
1625 no_bgp_maxpaths_hidden_cmd,
1626 "no maximum-paths [(1-255)]",
1627 NO_STR
1628 "Forward packets over multiple paths\n"
1629 "Number of paths\n")
1630
165b5fff
JB
1631DEFUN (no_bgp_maxpaths_ibgp,
1632 no_bgp_maxpaths_ibgp_cmd,
9ccf14f7 1633 "no maximum-paths ibgp [(1-255) [equal-cluster-length]]",
165b5fff
JB
1634 NO_STR
1635 "Forward packets over multiple paths\n"
1636 "iBGP-multipath\n"
838758ac
DW
1637 "Number of paths\n"
1638 "Match the cluster length\n")
165b5fff 1639{
5e242b0d 1640 return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0);
165b5fff
JB
1641}
1642
596c17ba
DW
1643ALIAS_HIDDEN (no_bgp_maxpaths_ibgp,
1644 no_bgp_maxpaths_ibgp_hidden_cmd,
1645 "no maximum-paths ibgp [(1-255) [equal-cluster-length]]",
1646 NO_STR
1647 "Forward packets over multiple paths\n"
1648 "iBGP-multipath\n"
1649 "Number of paths\n"
1650 "Match the cluster length\n")
1651
165b5fff
JB
1652int
1653bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi,
1654 safi_t safi, int *write)
1655{
d5b77cc2 1656 if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM)
165b5fff
JB
1657 {
1658 bgp_config_write_family_header (vty, afi, safi, write);
0b960b4d 1659 vty_out (vty, " maximum-paths %d%s",
165b5fff
JB
1660 bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE);
1661 }
1662
d5b77cc2 1663 if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM)
165b5fff
JB
1664 {
1665 bgp_config_write_family_header (vty, afi, safi, write);
0b960b4d 1666 vty_out (vty, " maximum-paths ibgp %d",
5e242b0d
DS
1667 bgp->maxpaths[afi][safi].maxpaths_ibgp);
1668 if (CHECK_FLAG (bgp->maxpaths[afi][safi].ibgp_flags,
1669 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN))
1670 vty_out (vty, " equal-cluster-length");
1671 vty_out (vty, "%s", VTY_NEWLINE);
165b5fff
JB
1672 }
1673
1674 return 0;
1675}
6b0655a2 1676
718e3744 1677/* BGP timers. */
1678
1679DEFUN (bgp_timers,
1680 bgp_timers_cmd,
6147e2c6 1681 "timers bgp (0-65535) (0-65535)",
718e3744 1682 "Adjust routing timers\n"
1683 "BGP timers\n"
1684 "Keepalive interval\n"
1685 "Holdtime\n")
1686{
cdc2d765 1687 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40
DW
1688 int idx_number = 2;
1689 int idx_number_2 = 3;
718e3744 1690 unsigned long keepalive = 0;
1691 unsigned long holdtime = 0;
1692
c500ae40
DW
1693 VTY_GET_INTEGER ("keepalive", keepalive, argv[idx_number]->arg);
1694 VTY_GET_INTEGER ("holdtime", holdtime, argv[idx_number_2]->arg);
718e3744 1695
1696 /* Holdtime value check. */
1697 if (holdtime < 3 && holdtime != 0)
1698 {
1699 vty_out (vty, "%% hold time value must be either 0 or greater than 3%s",
1700 VTY_NEWLINE);
1701 return CMD_WARNING;
1702 }
1703
1704 bgp_timers_set (bgp, keepalive, holdtime);
1705
1706 return CMD_SUCCESS;
1707}
1708
1709DEFUN (no_bgp_timers,
1710 no_bgp_timers_cmd,
838758ac 1711 "no timers bgp [(0-65535) (0-65535)]",
718e3744 1712 NO_STR
1713 "Adjust routing timers\n"
838758ac
DW
1714 "BGP timers\n"
1715 "Keepalive interval\n"
1716 "Holdtime\n")
718e3744 1717{
cdc2d765 1718 VTY_DECLVAR_CONTEXT(bgp, bgp);
718e3744 1719 bgp_timers_unset (bgp);
1720
1721 return CMD_SUCCESS;
1722}
1723
6b0655a2 1724
718e3744 1725DEFUN (bgp_client_to_client_reflection,
1726 bgp_client_to_client_reflection_cmd,
1727 "bgp client-to-client reflection",
1728 "BGP specific commands\n"
1729 "Configure client to client route reflection\n"
1730 "reflection of routes allowed\n")
1731{
cdc2d765 1732 VTY_DECLVAR_CONTEXT(bgp, bgp);
718e3744 1733 bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
f31fa004 1734 bgp_clear_star_soft_out (vty, bgp->name);
7aafcaca 1735
718e3744 1736 return CMD_SUCCESS;
1737}
1738
1739DEFUN (no_bgp_client_to_client_reflection,
1740 no_bgp_client_to_client_reflection_cmd,
1741 "no bgp client-to-client reflection",
1742 NO_STR
1743 "BGP specific commands\n"
1744 "Configure client to client route reflection\n"
1745 "reflection of routes allowed\n")
1746{
cdc2d765 1747 VTY_DECLVAR_CONTEXT(bgp, bgp);
718e3744 1748 bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT);
f31fa004 1749 bgp_clear_star_soft_out (vty, bgp->name);
7aafcaca 1750
718e3744 1751 return CMD_SUCCESS;
1752}
1753
1754/* "bgp always-compare-med" configuration. */
1755DEFUN (bgp_always_compare_med,
1756 bgp_always_compare_med_cmd,
1757 "bgp always-compare-med",
1758 "BGP specific commands\n"
1759 "Allow comparing MED from different neighbors\n")
1760{
cdc2d765 1761 VTY_DECLVAR_CONTEXT(bgp, bgp);
718e3744 1762 bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
7aafcaca
DS
1763 bgp_recalculate_all_bestpaths (bgp);
1764
718e3744 1765 return CMD_SUCCESS;
1766}
1767
1768DEFUN (no_bgp_always_compare_med,
1769 no_bgp_always_compare_med_cmd,
1770 "no bgp always-compare-med",
1771 NO_STR
1772 "BGP specific commands\n"
1773 "Allow comparing MED from different neighbors\n")
1774{
cdc2d765 1775 VTY_DECLVAR_CONTEXT(bgp, bgp);
718e3744 1776 bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED);
7aafcaca
DS
1777 bgp_recalculate_all_bestpaths (bgp);
1778
718e3744 1779 return CMD_SUCCESS;
1780}
6b0655a2 1781
718e3744 1782/* "bgp deterministic-med" configuration. */
1783DEFUN (bgp_deterministic_med,
1784 bgp_deterministic_med_cmd,
1785 "bgp deterministic-med",
1786 "BGP specific commands\n"
1787 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1788{
cdc2d765 1789 VTY_DECLVAR_CONTEXT(bgp, bgp);
1475ac87
DW
1790
1791 if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED))
1792 {
1793 bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED);
1794 bgp_recalculate_all_bestpaths (bgp);
1795 }
7aafcaca 1796
718e3744 1797 return CMD_SUCCESS;
1798}
1799
1800DEFUN (no_bgp_deterministic_med,
1801 no_bgp_deterministic_med_cmd,
1802 "no bgp deterministic-med",
1803 NO_STR
1804 "BGP specific commands\n"
1805 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1806{
cdc2d765 1807 VTY_DECLVAR_CONTEXT(bgp, bgp);
06370dac
DW
1808 int bestpath_per_as_used;
1809 afi_t afi;
1810 safi_t safi;
1811 struct peer *peer;
1812 struct listnode *node, *nnode;
718e3744 1813
1475ac87
DW
1814 if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED))
1815 {
06370dac
DW
1816 bestpath_per_as_used = 0;
1817
1818 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
1819 {
1820 for (afi = AFI_IP; afi < AFI_MAX; afi++)
1821 for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
1822 if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
1823 {
1824 bestpath_per_as_used = 1;
1825 break;
1826 }
1827
1828 if (bestpath_per_as_used)
1829 break;
1830 }
1831
1832 if (bestpath_per_as_used)
1833 {
1834 vty_out (vty, "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use%s",
1835 VTY_NEWLINE);
1836 return CMD_WARNING;
1837 }
1838 else
1839 {
1840 bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED);
1841 bgp_recalculate_all_bestpaths (bgp);
1842 }
1475ac87 1843 }
7aafcaca 1844
718e3744 1845 return CMD_SUCCESS;
1846}
538621f2 1847
1848/* "bgp graceful-restart" configuration. */
1849DEFUN (bgp_graceful_restart,
1850 bgp_graceful_restart_cmd,
1851 "bgp graceful-restart",
1852 "BGP specific commands\n"
1853 "Graceful restart capability parameters\n")
1854{
cdc2d765 1855 VTY_DECLVAR_CONTEXT(bgp, bgp);
538621f2 1856 bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART);
1857 return CMD_SUCCESS;
1858}
1859
1860DEFUN (no_bgp_graceful_restart,
1861 no_bgp_graceful_restart_cmd,
1862 "no bgp graceful-restart",
1863 NO_STR
1864 "BGP specific commands\n"
1865 "Graceful restart capability parameters\n")
1866{
cdc2d765 1867 VTY_DECLVAR_CONTEXT(bgp, bgp);
538621f2 1868 bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART);
1869 return CMD_SUCCESS;
1870}
1871
93406d87 1872DEFUN (bgp_graceful_restart_stalepath_time,
1873 bgp_graceful_restart_stalepath_time_cmd,
6147e2c6 1874 "bgp graceful-restart stalepath-time (1-3600)",
93406d87 1875 "BGP specific commands\n"
1876 "Graceful restart capability parameters\n"
1877 "Set the max time to hold onto restarting peer's stale paths\n"
1878 "Delay value (seconds)\n")
1879{
cdc2d765 1880 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40 1881 int idx_number = 3;
93406d87 1882 u_int32_t stalepath;
1883
c500ae40 1884 VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[idx_number]->arg, 1, 3600);
93406d87 1885 bgp->stalepath_time = stalepath;
1886 return CMD_SUCCESS;
1887}
1888
eb6f1b41
PG
1889DEFUN (bgp_graceful_restart_restart_time,
1890 bgp_graceful_restart_restart_time_cmd,
6147e2c6 1891 "bgp graceful-restart restart-time (1-3600)",
eb6f1b41
PG
1892 "BGP specific commands\n"
1893 "Graceful restart capability parameters\n"
1894 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1895 "Delay value (seconds)\n")
1896{
cdc2d765 1897 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40 1898 int idx_number = 3;
eb6f1b41
PG
1899 u_int32_t restart;
1900
c500ae40 1901 VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[idx_number]->arg, 1, 3600);
eb6f1b41
PG
1902 bgp->restart_time = restart;
1903 return CMD_SUCCESS;
1904}
1905
93406d87 1906DEFUN (no_bgp_graceful_restart_stalepath_time,
1907 no_bgp_graceful_restart_stalepath_time_cmd,
838758ac 1908 "no bgp graceful-restart stalepath-time [(1-3600)]",
93406d87 1909 NO_STR
1910 "BGP specific commands\n"
1911 "Graceful restart capability parameters\n"
838758ac
DW
1912 "Set the max time to hold onto restarting peer's stale paths\n"
1913 "Delay value (seconds)\n")
93406d87 1914{
cdc2d765 1915 VTY_DECLVAR_CONTEXT(bgp, bgp);
93406d87 1916
1917 bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME;
1918 return CMD_SUCCESS;
1919}
1920
eb6f1b41
PG
1921DEFUN (no_bgp_graceful_restart_restart_time,
1922 no_bgp_graceful_restart_restart_time_cmd,
838758ac 1923 "no bgp graceful-restart restart-time [(1-3600)]",
eb6f1b41
PG
1924 NO_STR
1925 "BGP specific commands\n"
1926 "Graceful restart capability parameters\n"
838758ac
DW
1927 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1928 "Delay value (seconds)\n")
eb6f1b41 1929{
cdc2d765 1930 VTY_DECLVAR_CONTEXT(bgp, bgp);
eb6f1b41
PG
1931
1932 bgp->restart_time = BGP_DEFAULT_RESTART_TIME;
1933 return CMD_SUCCESS;
1934}
1935
43fc21b3
JC
1936DEFUN (bgp_graceful_restart_preserve_fw,
1937 bgp_graceful_restart_preserve_fw_cmd,
1938 "bgp graceful-restart preserve-fw-state",
1939 "BGP specific commands\n"
1940 "Graceful restart capability parameters\n"
1941 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
1942{
1943 VTY_DECLVAR_CONTEXT(bgp, bgp);
1944 bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD);
1945 return CMD_SUCCESS;
1946}
1947
1948DEFUN (no_bgp_graceful_restart_preserve_fw,
1949 no_bgp_graceful_restart_preserve_fw_cmd,
1950 "no bgp graceful-restart preserve-fw-state",
1951 NO_STR
1952 "BGP specific commands\n"
1953 "Graceful restart capability parameters\n"
1954 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
1955{
1956 VTY_DECLVAR_CONTEXT(bgp, bgp);
1957 bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD);
1958 return CMD_SUCCESS;
1959}
1960
718e3744 1961/* "bgp fast-external-failover" configuration. */
1962DEFUN (bgp_fast_external_failover,
1963 bgp_fast_external_failover_cmd,
1964 "bgp fast-external-failover",
1965 BGP_STR
1966 "Immediately reset session if a link to a directly connected external peer goes down\n")
1967{
cdc2d765 1968 VTY_DECLVAR_CONTEXT(bgp, bgp);
718e3744 1969 bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
1970 return CMD_SUCCESS;
1971}
1972
1973DEFUN (no_bgp_fast_external_failover,
1974 no_bgp_fast_external_failover_cmd,
1975 "no bgp fast-external-failover",
1976 NO_STR
1977 BGP_STR
1978 "Immediately reset session if a link to a directly connected external peer goes down\n")
1979{
cdc2d765 1980 VTY_DECLVAR_CONTEXT(bgp, bgp);
718e3744 1981 bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER);
1982 return CMD_SUCCESS;
1983}
6b0655a2 1984
718e3744 1985/* "bgp enforce-first-as" configuration. */
1986DEFUN (bgp_enforce_first_as,
1987 bgp_enforce_first_as_cmd,
1988 "bgp enforce-first-as",
1989 BGP_STR
1990 "Enforce the first AS for EBGP routes\n")
1991{
cdc2d765 1992 VTY_DECLVAR_CONTEXT(bgp, bgp);
718e3744 1993 bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
f31fa004 1994 bgp_clear_star_soft_in (vty, bgp->name);
7aafcaca 1995
718e3744 1996 return CMD_SUCCESS;
1997}
1998
1999DEFUN (no_bgp_enforce_first_as,
2000 no_bgp_enforce_first_as_cmd,
2001 "no bgp enforce-first-as",
2002 NO_STR
2003 BGP_STR
2004 "Enforce the first AS for EBGP routes\n")
2005{
cdc2d765 2006 VTY_DECLVAR_CONTEXT(bgp, bgp);
718e3744 2007 bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS);
f31fa004 2008 bgp_clear_star_soft_in (vty, bgp->name);
7aafcaca 2009
718e3744 2010 return CMD_SUCCESS;
2011}
6b0655a2 2012
718e3744 2013/* "bgp bestpath compare-routerid" configuration. */
2014DEFUN (bgp_bestpath_compare_router_id,
2015 bgp_bestpath_compare_router_id_cmd,
2016 "bgp bestpath compare-routerid",
2017 "BGP specific commands\n"
2018 "Change the default bestpath selection\n"
2019 "Compare router-id for identical EBGP paths\n")
2020{
cdc2d765 2021 VTY_DECLVAR_CONTEXT(bgp, bgp);
718e3744 2022 bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
7aafcaca
DS
2023 bgp_recalculate_all_bestpaths (bgp);
2024
718e3744 2025 return CMD_SUCCESS;
2026}
2027
2028DEFUN (no_bgp_bestpath_compare_router_id,
2029 no_bgp_bestpath_compare_router_id_cmd,
2030 "no bgp bestpath compare-routerid",
2031 NO_STR
2032 "BGP specific commands\n"
2033 "Change the default bestpath selection\n"
2034 "Compare router-id for identical EBGP paths\n")
2035{
cdc2d765 2036 VTY_DECLVAR_CONTEXT(bgp, bgp);
718e3744 2037 bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID);
7aafcaca
DS
2038 bgp_recalculate_all_bestpaths (bgp);
2039
718e3744 2040 return CMD_SUCCESS;
2041}
6b0655a2 2042
718e3744 2043/* "bgp bestpath as-path ignore" configuration. */
2044DEFUN (bgp_bestpath_aspath_ignore,
2045 bgp_bestpath_aspath_ignore_cmd,
2046 "bgp bestpath as-path ignore",
2047 "BGP specific commands\n"
2048 "Change the default bestpath selection\n"
2049 "AS-path attribute\n"
2050 "Ignore as-path length in selecting a route\n")
2051{
cdc2d765 2052 VTY_DECLVAR_CONTEXT(bgp, bgp);
718e3744 2053 bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE);
7aafcaca
DS
2054 bgp_recalculate_all_bestpaths (bgp);
2055
718e3744 2056 return CMD_SUCCESS;
2057}
2058
2059DEFUN (no_bgp_bestpath_aspath_ignore,
2060 no_bgp_bestpath_aspath_ignore_cmd,
2061 "no bgp bestpath as-path ignore",
2062 NO_STR
2063 "BGP specific commands\n"
2064 "Change the default bestpath selection\n"
2065 "AS-path attribute\n"
2066 "Ignore as-path length in selecting a route\n")
2067{
cdc2d765 2068 VTY_DECLVAR_CONTEXT(bgp, bgp);
718e3744 2069 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE);
7aafcaca
DS
2070 bgp_recalculate_all_bestpaths (bgp);
2071
718e3744 2072 return CMD_SUCCESS;
2073}
6b0655a2 2074
6811845b 2075/* "bgp bestpath as-path confed" configuration. */
2076DEFUN (bgp_bestpath_aspath_confed,
2077 bgp_bestpath_aspath_confed_cmd,
2078 "bgp bestpath as-path confed",
2079 "BGP specific commands\n"
2080 "Change the default bestpath selection\n"
2081 "AS-path attribute\n"
2082 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2083{
cdc2d765 2084 VTY_DECLVAR_CONTEXT(bgp, bgp);
6811845b 2085 bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED);
7aafcaca
DS
2086 bgp_recalculate_all_bestpaths (bgp);
2087
6811845b 2088 return CMD_SUCCESS;
2089}
2090
2091DEFUN (no_bgp_bestpath_aspath_confed,
2092 no_bgp_bestpath_aspath_confed_cmd,
2093 "no bgp bestpath as-path confed",
2094 NO_STR
2095 "BGP specific commands\n"
2096 "Change the default bestpath selection\n"
2097 "AS-path attribute\n"
2098 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2099{
cdc2d765 2100 VTY_DECLVAR_CONTEXT(bgp, bgp);
6811845b 2101 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED);
7aafcaca
DS
2102 bgp_recalculate_all_bestpaths (bgp);
2103
6811845b 2104 return CMD_SUCCESS;
2105}
6b0655a2 2106
2fdd455c
PM
2107/* "bgp bestpath as-path multipath-relax" configuration. */
2108DEFUN (bgp_bestpath_aspath_multipath_relax,
2109 bgp_bestpath_aspath_multipath_relax_cmd,
c7178fe7 2110 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
16fc1eec
DS
2111 "BGP specific commands\n"
2112 "Change the default bestpath selection\n"
2113 "AS-path attribute\n"
2114 "Allow load sharing across routes that have different AS paths (but same length)\n"
219178b6 2115 "Generate an AS_SET\n"
16fc1eec
DS
2116 "Do not generate an AS_SET\n")
2117{
cdc2d765 2118 VTY_DECLVAR_CONTEXT(bgp, bgp);
4c4ff4c1 2119 int idx = 0;
16fc1eec 2120 bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
219178b6
DW
2121
2122 /* no-as-set is now the default behavior so we can silently
2123 * ignore it */
4c4ff4c1 2124 if (argv_find (argv, argc, "as-set", &idx))
219178b6
DW
2125 bgp_flag_set (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
2126 else
2127 bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET) ;
2128
7aafcaca
DS
2129 bgp_recalculate_all_bestpaths (bgp);
2130
16fc1eec
DS
2131 return CMD_SUCCESS;
2132}
2133
219178b6
DW
2134DEFUN (no_bgp_bestpath_aspath_multipath_relax,
2135 no_bgp_bestpath_aspath_multipath_relax_cmd,
c7178fe7 2136 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
16fc1eec
DS
2137 NO_STR
2138 "BGP specific commands\n"
2139 "Change the default bestpath selection\n"
2140 "AS-path attribute\n"
2141 "Allow load sharing across routes that have different AS paths (but same length)\n"
219178b6 2142 "Generate an AS_SET\n"
16fc1eec
DS
2143 "Do not generate an AS_SET\n")
2144{
cdc2d765 2145 VTY_DECLVAR_CONTEXT(bgp, bgp);
16fc1eec 2146 bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX);
219178b6 2147 bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET);
7aafcaca
DS
2148 bgp_recalculate_all_bestpaths (bgp);
2149
2fdd455c
PM
2150 return CMD_SUCCESS;
2151}
6b0655a2 2152
848973c7 2153/* "bgp log-neighbor-changes" configuration. */
2154DEFUN (bgp_log_neighbor_changes,
2155 bgp_log_neighbor_changes_cmd,
2156 "bgp log-neighbor-changes",
2157 "BGP specific commands\n"
2158 "Log neighbor up/down and reset reason\n")
2159{
cdc2d765 2160 VTY_DECLVAR_CONTEXT(bgp, bgp);
848973c7 2161 bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
2162 return CMD_SUCCESS;
2163}
2164
2165DEFUN (no_bgp_log_neighbor_changes,
2166 no_bgp_log_neighbor_changes_cmd,
2167 "no bgp log-neighbor-changes",
2168 NO_STR
2169 "BGP specific commands\n"
2170 "Log neighbor up/down and reset reason\n")
2171{
cdc2d765 2172 VTY_DECLVAR_CONTEXT(bgp, bgp);
848973c7 2173 bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES);
2174 return CMD_SUCCESS;
2175}
6b0655a2 2176
718e3744 2177/* "bgp bestpath med" configuration. */
2178DEFUN (bgp_bestpath_med,
2179 bgp_bestpath_med_cmd,
2d8c1a4d 2180 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
718e3744 2181 "BGP specific commands\n"
2182 "Change the default bestpath selection\n"
2183 "MED attribute\n"
2184 "Compare MED among confederation paths\n"
838758ac
DW
2185 "Treat missing MED as the least preferred one\n"
2186 "Treat missing MED as the least preferred one\n"
2187 "Compare MED among confederation paths\n")
718e3744 2188{
cdc2d765 2189 VTY_DECLVAR_CONTEXT(bgp, bgp);
6cbd1915
QY
2190
2191 int idx = 0;
2192 if (argv_find (argv, argc, "confed", &idx))
2193 bgp_flag_set (bgp, BGP_FLAG_MED_CONFED);
2194 idx = 0;
2195 if (argv_find (argv, argc, "missing-as-worst", &idx))
2196 bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
e52702f2 2197
7aafcaca
DS
2198 bgp_recalculate_all_bestpaths (bgp);
2199
718e3744 2200 return CMD_SUCCESS;
2201}
2202
718e3744 2203DEFUN (no_bgp_bestpath_med,
2204 no_bgp_bestpath_med_cmd,
2d8c1a4d 2205 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
718e3744 2206 NO_STR
2207 "BGP specific commands\n"
2208 "Change the default bestpath selection\n"
2209 "MED attribute\n"
2210 "Compare MED among confederation paths\n"
3a2d747c
QY
2211 "Treat missing MED as the least preferred one\n"
2212 "Treat missing MED as the least preferred one\n"
2213 "Compare MED among confederation paths\n")
718e3744 2214{
cdc2d765 2215 VTY_DECLVAR_CONTEXT(bgp, bgp);
e52702f2 2216
6cbd1915
QY
2217 int idx = 0;
2218 if (argv_find (argv, argc, "confed", &idx))
718e3744 2219 bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED);
6cbd1915
QY
2220 idx = 0;
2221 if (argv_find (argv, argc, "missing-as-worst", &idx))
718e3744 2222 bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST);
2223
7aafcaca
DS
2224 bgp_recalculate_all_bestpaths (bgp);
2225
718e3744 2226 return CMD_SUCCESS;
2227}
2228
718e3744 2229/* "no bgp default ipv4-unicast". */
2230DEFUN (no_bgp_default_ipv4_unicast,
2231 no_bgp_default_ipv4_unicast_cmd,
2232 "no bgp default ipv4-unicast",
2233 NO_STR
2234 "BGP specific commands\n"
2235 "Configure BGP defaults\n"
2236 "Activate ipv4-unicast for a peer by default\n")
2237{
cdc2d765 2238 VTY_DECLVAR_CONTEXT(bgp, bgp);
718e3744 2239 bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
2240 return CMD_SUCCESS;
2241}
2242
2243DEFUN (bgp_default_ipv4_unicast,
2244 bgp_default_ipv4_unicast_cmd,
2245 "bgp default ipv4-unicast",
2246 "BGP specific commands\n"
2247 "Configure BGP defaults\n"
2248 "Activate ipv4-unicast for a peer by default\n")
2249{
cdc2d765 2250 VTY_DECLVAR_CONTEXT(bgp, bgp);
718e3744 2251 bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4);
2252 return CMD_SUCCESS;
2253}
6b0655a2 2254
04b6bdc0
DW
2255/* Display hostname in certain command outputs */
2256DEFUN (bgp_default_show_hostname,
2257 bgp_default_show_hostname_cmd,
2258 "bgp default show-hostname",
2259 "BGP specific commands\n"
2260 "Configure BGP defaults\n"
2261 "Show hostname in certain command ouputs\n")
2262{
cdc2d765 2263 VTY_DECLVAR_CONTEXT(bgp, bgp);
04b6bdc0
DW
2264 bgp_flag_set (bgp, BGP_FLAG_SHOW_HOSTNAME);
2265 return CMD_SUCCESS;
2266}
2267
2268DEFUN (no_bgp_default_show_hostname,
2269 no_bgp_default_show_hostname_cmd,
2270 "no bgp default show-hostname",
2271 NO_STR
2272 "BGP specific commands\n"
2273 "Configure BGP defaults\n"
2274 "Show hostname in certain command ouputs\n")
2275{
cdc2d765 2276 VTY_DECLVAR_CONTEXT(bgp, bgp);
04b6bdc0
DW
2277 bgp_flag_unset (bgp, BGP_FLAG_SHOW_HOSTNAME);
2278 return CMD_SUCCESS;
2279}
2280
8233ef81 2281/* "bgp network import-check" configuration. */
718e3744 2282DEFUN (bgp_network_import_check,
2283 bgp_network_import_check_cmd,
5623e905 2284 "bgp network import-check",
718e3744 2285 "BGP specific commands\n"
2286 "BGP network command\n"
5623e905 2287 "Check BGP network route exists in IGP\n")
718e3744 2288{
cdc2d765 2289 VTY_DECLVAR_CONTEXT(bgp, bgp);
078430f6
DS
2290 if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK))
2291 {
2292 bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK);
5623e905 2293 bgp_static_redo_import_check(bgp);
078430f6
DS
2294 }
2295
718e3744 2296 return CMD_SUCCESS;
2297}
2298
8233ef81
DW
2299ALIAS_HIDDEN (bgp_network_import_check,
2300 bgp_network_import_check_exact_cmd,
2301 "bgp network import-check exact",
2302 "BGP specific commands\n"
2303 "BGP network command\n"
2304 "Check BGP network route exists in IGP\n"
2305 "Match route precisely\n")
2306
718e3744 2307DEFUN (no_bgp_network_import_check,
2308 no_bgp_network_import_check_cmd,
5623e905 2309 "no bgp network import-check",
718e3744 2310 NO_STR
2311 "BGP specific commands\n"
2312 "BGP network command\n"
2313 "Check BGP network route exists in IGP\n")
2314{
cdc2d765 2315 VTY_DECLVAR_CONTEXT(bgp, bgp);
078430f6
DS
2316 if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK))
2317 {
2318 bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK);
078430f6
DS
2319 bgp_static_redo_import_check(bgp);
2320 }
5623e905 2321
718e3744 2322 return CMD_SUCCESS;
2323}
6b0655a2 2324
718e3744 2325DEFUN (bgp_default_local_preference,
2326 bgp_default_local_preference_cmd,
6147e2c6 2327 "bgp default local-preference (0-4294967295)",
718e3744 2328 "BGP specific commands\n"
2329 "Configure BGP defaults\n"
2330 "local preference (higher=more preferred)\n"
2331 "Configure default local preference value\n")
2332{
cdc2d765 2333 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40 2334 int idx_number = 3;
718e3744 2335 u_int32_t local_pref;
2336
c500ae40 2337 VTY_GET_INTEGER ("local preference", local_pref, argv[idx_number]->arg);
718e3744 2338
2339 bgp_default_local_preference_set (bgp, local_pref);
f31fa004 2340 bgp_clear_star_soft_in (vty, bgp->name);
718e3744 2341
2342 return CMD_SUCCESS;
2343}
2344
2345DEFUN (no_bgp_default_local_preference,
2346 no_bgp_default_local_preference_cmd,
838758ac 2347 "no bgp default local-preference [(0-4294967295)]",
718e3744 2348 NO_STR
2349 "BGP specific commands\n"
2350 "Configure BGP defaults\n"
838758ac
DW
2351 "local preference (higher=more preferred)\n"
2352 "Configure default local preference value\n")
718e3744 2353{
cdc2d765 2354 VTY_DECLVAR_CONTEXT(bgp, bgp);
718e3744 2355 bgp_default_local_preference_unset (bgp);
f31fa004 2356 bgp_clear_star_soft_in (vty, bgp->name);
7aafcaca 2357
718e3744 2358 return CMD_SUCCESS;
2359}
2360
6b0655a2 2361
3f9c7369
DS
2362DEFUN (bgp_default_subgroup_pkt_queue_max,
2363 bgp_default_subgroup_pkt_queue_max_cmd,
6147e2c6 2364 "bgp default subgroup-pkt-queue-max (20-100)",
3f9c7369
DS
2365 "BGP specific commands\n"
2366 "Configure BGP defaults\n"
2367 "subgroup-pkt-queue-max\n"
2368 "Configure subgroup packet queue max\n")
8bd9d948 2369{
cdc2d765 2370 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40 2371 int idx_number = 3;
3f9c7369 2372 u_int32_t max_size;
8bd9d948 2373
c500ae40 2374 VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[idx_number]->arg);
3f9c7369
DS
2375
2376 bgp_default_subgroup_pkt_queue_max_set (bgp, max_size);
2377
2378 return CMD_SUCCESS;
2379}
2380
2381DEFUN (no_bgp_default_subgroup_pkt_queue_max,
2382 no_bgp_default_subgroup_pkt_queue_max_cmd,
838758ac 2383 "no bgp default subgroup-pkt-queue-max [(20-100)]",
3f9c7369
DS
2384 NO_STR
2385 "BGP specific commands\n"
2386 "Configure BGP defaults\n"
838758ac
DW
2387 "subgroup-pkt-queue-max\n"
2388 "Configure subgroup packet queue max\n")
3f9c7369 2389{
cdc2d765 2390 VTY_DECLVAR_CONTEXT(bgp, bgp);
3f9c7369
DS
2391 bgp_default_subgroup_pkt_queue_max_unset (bgp);
2392 return CMD_SUCCESS;
8bd9d948
DS
2393}
2394
813d4307 2395
8bd9d948
DS
2396DEFUN (bgp_rr_allow_outbound_policy,
2397 bgp_rr_allow_outbound_policy_cmd,
2398 "bgp route-reflector allow-outbound-policy",
2399 "BGP specific commands\n"
2400 "Allow modifications made by out route-map\n"
2401 "on ibgp neighbors\n")
2402{
cdc2d765 2403 VTY_DECLVAR_CONTEXT(bgp, bgp);
8bd9d948
DS
2404
2405 if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
2406 {
2407 bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
3f9c7369 2408 update_group_announce_rrclients(bgp);
f31fa004 2409 bgp_clear_star_soft_out (vty, bgp->name);
8bd9d948
DS
2410 }
2411
2412 return CMD_SUCCESS;
2413}
2414
2415DEFUN (no_bgp_rr_allow_outbound_policy,
2416 no_bgp_rr_allow_outbound_policy_cmd,
2417 "no bgp route-reflector allow-outbound-policy",
2418 NO_STR
2419 "BGP specific commands\n"
2420 "Allow modifications made by out route-map\n"
2421 "on ibgp neighbors\n")
2422{
cdc2d765 2423 VTY_DECLVAR_CONTEXT(bgp, bgp);
8bd9d948
DS
2424
2425 if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY))
2426 {
2427 bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY);
3f9c7369 2428 update_group_announce_rrclients(bgp);
f31fa004 2429 bgp_clear_star_soft_out (vty, bgp->name);
8bd9d948
DS
2430 }
2431
2432 return CMD_SUCCESS;
2433}
2434
f14e6fdb
DS
2435DEFUN (bgp_listen_limit,
2436 bgp_listen_limit_cmd,
9ccf14f7 2437 "bgp listen limit (1-5000)",
f14e6fdb
DS
2438 "BGP specific commands\n"
2439 "Configure BGP defaults\n"
2440 "maximum number of BGP Dynamic Neighbors that can be created\n"
2441 "Configure Dynamic Neighbors listen limit value\n")
2442{
cdc2d765 2443 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40 2444 int idx_number = 3;
f14e6fdb
DS
2445 int listen_limit;
2446
c500ae40 2447 VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[idx_number]->arg,
f14e6fdb
DS
2448 BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN,
2449 BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX);
2450
2451 bgp_listen_limit_set (bgp, listen_limit);
2452
2453 return CMD_SUCCESS;
2454}
2455
2456DEFUN (no_bgp_listen_limit,
2457 no_bgp_listen_limit_cmd,
838758ac 2458 "no bgp listen limit [(1-5000)]",
f14e6fdb
DS
2459 "BGP specific commands\n"
2460 "Configure BGP defaults\n"
2461 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
838758ac
DW
2462 "Configure Dynamic Neighbors listen limit value to default\n"
2463 "Configure Dynamic Neighbors listen limit value\n")
f14e6fdb 2464{
cdc2d765 2465 VTY_DECLVAR_CONTEXT(bgp, bgp);
f14e6fdb
DS
2466 bgp_listen_limit_unset (bgp);
2467 return CMD_SUCCESS;
2468}
2469
2470
20eb8864 2471/*
2472 * Check if this listen range is already configured. Check for exact
2473 * match or overlap based on input.
2474 */
2475static struct peer_group *
2476listen_range_exists (struct bgp *bgp, struct prefix *range, int exact)
2477{
2478 struct listnode *node, *nnode;
2479 struct listnode *node1, *nnode1;
2480 struct peer_group *group;
2481 struct prefix *lr;
2482 afi_t afi;
2483 int match;
2484
2485 afi = family2afi(range->family);
2486 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
2487 {
2488 for (ALL_LIST_ELEMENTS (group->listen_range[afi], node1,
2489 nnode1, lr))
2490 {
2491 if (exact)
2492 match = prefix_same (range, lr);
2493 else
2494 match = (prefix_match (range, lr) || prefix_match (lr, range));
2495 if (match)
2496 return group;
2497 }
2498 }
2499
2500 return NULL;
2501}
2502
f14e6fdb
DS
2503DEFUN (bgp_listen_range,
2504 bgp_listen_range_cmd,
9ccf14f7 2505 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
f14e6fdb 2506 "BGP specific commands\n"
d7fa34c1
QY
2507 "Configure BGP dynamic neighbors listen range\n"
2508 "Configure BGP dynamic neighbors listen range\n"
16cedbb0
QY
2509 NEIGHBOR_ADDR_STR
2510 "Member of the peer-group\n"
2511 "Peer-group name\n")
f14e6fdb 2512{
cdc2d765 2513 VTY_DECLVAR_CONTEXT(bgp, bgp);
f14e6fdb 2514 struct prefix range;
20eb8864 2515 struct peer_group *group, *existing_group;
f14e6fdb
DS
2516 afi_t afi;
2517 int ret;
d7fa34c1 2518 int idx = 0;
f14e6fdb 2519
d7fa34c1
QY
2520 argv_find (argv, argc, "A.B.C.D/M", &idx);
2521 argv_find (argv, argc, "X:X::X:X/M", &idx);
2522 char *prefix = argv[idx]->arg;
2523 argv_find (argv, argc, "WORD", &idx);
2524 char *peergroup = argv[idx]->arg;
f14e6fdb 2525
f14e6fdb 2526 /* Convert IP prefix string to struct prefix. */
d7fa34c1 2527 ret = str2prefix (prefix, &range);
f14e6fdb
DS
2528 if (! ret)
2529 {
2530 vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE);
2531 return CMD_WARNING;
2532 }
2533
2534 afi = family2afi(range.family);
2535
f14e6fdb
DS
2536 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6))
2537 {
2538 vty_out (vty, "%% Malformed listen range (link-local address)%s",
2539 VTY_NEWLINE);
2540 return CMD_WARNING;
2541 }
f14e6fdb
DS
2542
2543 apply_mask (&range);
2544
20eb8864 2545 /* Check if same listen range is already configured. */
2546 existing_group = listen_range_exists (bgp, &range, 1);
2547 if (existing_group)
2548 {
d7fa34c1 2549 if (strcmp (existing_group->name, peergroup) == 0)
20eb8864 2550 return CMD_SUCCESS;
2551 else
2552 {
2553 vty_out (vty, "%% Same listen range is attached to peer-group %s%s",
2554 existing_group->name, VTY_NEWLINE);
2555 return CMD_WARNING;
2556 }
2557 }
2558
2559 /* Check if an overlapping listen range exists. */
2560 if (listen_range_exists (bgp, &range, 0))
2561 {
2562 vty_out (vty, "%% Listen range overlaps with existing listen range%s",
2563 VTY_NEWLINE);
2564 return CMD_WARNING;
2565 }
f14e6fdb 2566
d7fa34c1 2567 group = peer_group_lookup (bgp, peergroup);
f14e6fdb
DS
2568 if (! group)
2569 {
2570 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
2571 return CMD_WARNING;
2572 }
2573
2574 ret = peer_group_listen_range_add(group, &range);
2575 return bgp_vty_return (vty, ret);
2576}
2577
2578DEFUN (no_bgp_listen_range,
2579 no_bgp_listen_range_cmd,
d7fa34c1
QY
2580 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2581 NO_STR
f14e6fdb 2582 "BGP specific commands\n"
d7fa34c1
QY
2583 "Unconfigure BGP dynamic neighbors listen range\n"
2584 "Unconfigure BGP dynamic neighbors listen range\n"
2585 NEIGHBOR_ADDR_STR
2586 "Member of the peer-group\n"
2587 "Peer-group name\n")
f14e6fdb 2588{
cdc2d765 2589 VTY_DECLVAR_CONTEXT(bgp, bgp);
f14e6fdb
DS
2590 struct prefix range;
2591 struct peer_group *group;
2592 afi_t afi;
2593 int ret;
d7fa34c1
QY
2594 int idx = 0;
2595
2596 argv_find (argv, argc, "A.B.C.D/M", &idx);
2597 argv_find (argv, argc, "X:X::X:X/M", &idx);
2598 char *prefix = argv[idx]->arg;
2599 argv_find (argv, argc, "WORD", &idx);
2600 char *peergroup = argv[idx]->arg;
f14e6fdb 2601
c500ae40 2602 // VTY_GET_IPV4_PREFIX ("listen range", range, argv[idx_ipv4_prefixlen]->arg);
f14e6fdb
DS
2603
2604 /* Convert IP prefix string to struct prefix. */
d7fa34c1 2605 ret = str2prefix (prefix, &range);
f14e6fdb
DS
2606 if (! ret)
2607 {
2608 vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE);
2609 return CMD_WARNING;
2610 }
2611
2612 afi = family2afi(range.family);
2613
f14e6fdb
DS
2614 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6))
2615 {
2616 vty_out (vty, "%% Malformed listen range (link-local address)%s",
2617 VTY_NEWLINE);
2618 return CMD_WARNING;
2619 }
f14e6fdb
DS
2620
2621 apply_mask (&range);
2622
d7fa34c1 2623 group = peer_group_lookup (bgp, peergroup);
f14e6fdb
DS
2624 if (! group)
2625 {
2626 vty_out (vty, "%% Peer-group does not exist%s", VTY_NEWLINE);
2627 return CMD_WARNING;
2628 }
2629
2630 ret = peer_group_listen_range_del(group, &range);
2631 return bgp_vty_return (vty, ret);
2632}
2633
2634int
2635bgp_config_write_listen (struct vty *vty, struct bgp *bgp)
2636{
2637 struct peer_group *group;
2638 struct listnode *node, *nnode, *rnode, *nrnode;
2639 struct prefix *range;
2640 afi_t afi;
4690c7d7 2641 char buf[PREFIX2STR_BUFFER];
f14e6fdb
DS
2642
2643 if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT)
2644 vty_out (vty, " bgp listen limit %d%s",
2645 bgp->dynamic_neighbors_limit, VTY_NEWLINE);
2646
2647 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
2648 {
2649 for (afi = AFI_IP; afi < AFI_MAX; afi++)
2650 {
2651 for (ALL_LIST_ELEMENTS (group->listen_range[afi], rnode, nrnode, range))
2652 {
2653 prefix2str(range, buf, sizeof(buf));
2654 vty_out(vty, " bgp listen range %s peer-group %s%s",
2655 buf, group->name, VTY_NEWLINE);
2656 }
2657 }
2658 }
2659
2660 return 0;
2661}
2662
2663
907f92c8
DS
2664DEFUN (bgp_disable_connected_route_check,
2665 bgp_disable_connected_route_check_cmd,
2666 "bgp disable-ebgp-connected-route-check",
2667 "BGP specific commands\n"
2668 "Disable checking if nexthop is connected on ebgp sessions\n")
2669{
cdc2d765 2670 VTY_DECLVAR_CONTEXT(bgp, bgp);
907f92c8 2671 bgp_flag_set (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
f31fa004 2672 bgp_clear_star_soft_in (vty, bgp->name);
7aafcaca 2673
907f92c8
DS
2674 return CMD_SUCCESS;
2675}
2676
2677DEFUN (no_bgp_disable_connected_route_check,
2678 no_bgp_disable_connected_route_check_cmd,
2679 "no bgp disable-ebgp-connected-route-check",
2680 NO_STR
2681 "BGP specific commands\n"
2682 "Disable checking if nexthop is connected on ebgp sessions\n")
2683{
cdc2d765 2684 VTY_DECLVAR_CONTEXT(bgp, bgp);
907f92c8 2685 bgp_flag_unset (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK);
f31fa004 2686 bgp_clear_star_soft_in (vty, bgp->name);
7aafcaca 2687
907f92c8
DS
2688 return CMD_SUCCESS;
2689}
2690
2691
718e3744 2692static int
e52702f2 2693peer_remote_as_vty (struct vty *vty, const char *peer_str,
fd79ac91 2694 const char *as_str, afi_t afi, safi_t safi)
718e3744 2695{
cdc2d765 2696 VTY_DECLVAR_CONTEXT(bgp, bgp);
718e3744 2697 int ret;
718e3744 2698 as_t as;
0299c004 2699 int as_type = AS_SPECIFIED;
718e3744 2700 union sockunion su;
2701
7ae5fc81 2702 if (as_str[0] == 'i')
0299c004
DS
2703 {
2704 as = 0;
2705 as_type = AS_INTERNAL;
2706 }
7ae5fc81 2707 else if (as_str[0] == 'e')
0299c004
DS
2708 {
2709 as = 0;
2710 as_type = AS_EXTERNAL;
2711 }
2712 else
2713 {
2714 /* Get AS number. */
2715 VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX);
2716 }
718e3744 2717
2718 /* If peer is peer group, call proper function. */
2719 ret = str2sockunion (peer_str, &su);
2720 if (ret < 0)
2721 {
a80beece 2722 /* Check for peer by interface */
0299c004 2723 ret = peer_remote_as (bgp, NULL, peer_str, &as, as_type, afi, safi);
718e3744 2724 if (ret < 0)
a80beece 2725 {
0299c004 2726 ret = peer_group_remote_as (bgp, peer_str, &as, as_type);
a80beece
DS
2727 if (ret < 0)
2728 {
2729 vty_out (vty, "%% Create the peer-group or interface first%s",
2730 VTY_NEWLINE);
2731 return CMD_WARNING;
2732 }
2733 return CMD_SUCCESS;
2734 }
718e3744 2735 }
a80beece 2736 else
718e3744 2737 {
6aeb9e78 2738 if (peer_address_self_check (bgp, &su))
a80beece
DS
2739 {
2740 vty_out (vty, "%% Can not configure the local system as neighbor%s",
2741 VTY_NEWLINE);
2742 return CMD_WARNING;
2743 }
0299c004 2744 ret = peer_remote_as (bgp, &su, NULL, &as, as_type, afi, safi);
718e3744 2745 }
2746
718e3744 2747 /* This peer belongs to peer group. */
2748 switch (ret)
2749 {
2750 case BGP_ERR_PEER_GROUP_MEMBER:
aea339f7 2751 vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE);
718e3744 2752 return CMD_WARNING;
718e3744 2753 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT:
aea339f7 2754 vty_out (vty, "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external%s", as, as_str, VTY_NEWLINE);
718e3744 2755 return CMD_WARNING;
718e3744 2756 }
2757 return bgp_vty_return (vty, ret);
2758}
2759
2760DEFUN (neighbor_remote_as,
2761 neighbor_remote_as_cmd,
3a2d747c 2762 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
718e3744 2763 NEIGHBOR_STR
2764 NEIGHBOR_ADDR_STR2
2765 "Specify a BGP neighbor\n"
d7fa34c1 2766 AS_STR
3a2d747c
QY
2767 "Internal BGP peer\n"
2768 "External BGP peer\n")
718e3744 2769{
c500ae40
DW
2770 int idx_peer = 1;
2771 int idx_remote_as = 3;
2772 return peer_remote_as_vty (vty, argv[idx_peer]->arg, argv[idx_remote_as]->arg, AFI_IP, SAFI_UNICAST);
718e3744 2773}
6b0655a2 2774
4c48cf63
DW
2775static int
2776peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi,
b3a39dc5
DD
2777 safi_t safi, int v6only, const char *peer_group_name,
2778 const char *as_str)
a80beece 2779{
cdc2d765 2780 VTY_DECLVAR_CONTEXT(bgp, bgp);
b3a39dc5
DD
2781 as_t as = 0;
2782 int as_type = AS_UNSPECIFIED;
a80beece
DS
2783 struct peer *peer;
2784 struct peer_group *group;
4c48cf63
DW
2785 int ret = 0;
2786 union sockunion su;
a80beece 2787
4c48cf63
DW
2788 group = peer_group_lookup (bgp, conf_if);
2789
a80beece
DS
2790 if (group)
2791 {
2792 vty_out (vty, "%% Name conflict with peer-group %s", VTY_NEWLINE);
2793 return CMD_WARNING;
2794 }
2795
b3a39dc5
DD
2796 if (as_str)
2797 {
7ae5fc81 2798 if (as_str[0] == 'i')
b3a39dc5
DD
2799 {
2800 as_type = AS_INTERNAL;
2801 }
7ae5fc81 2802 else if (as_str[0] == 'e')
b3a39dc5
DD
2803 {
2804 as_type = AS_EXTERNAL;
2805 }
2806 else
2807 {
2808 /* Get AS number. */
2809 VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX);
2810 as_type = AS_SPECIFIED;
2811 }
2812 }
2813
4c48cf63 2814 peer = peer_lookup_by_conf_if (bgp, conf_if);
464598de
DW
2815 if (peer)
2816 {
2817 if (as_str)
3bd07551 2818 ret = peer_remote_as (bgp, &su, conf_if, &as, as_type, afi, safi);
464598de
DW
2819 }
2820 else
4c48cf63
DW
2821 {
2822 if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4)
2823 && afi == AFI_IP && safi == SAFI_UNICAST)
b3a39dc5
DD
2824 peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, 0, 0,
2825 NULL);
4c48cf63 2826 else
b3a39dc5
DD
2827 peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, afi, safi,
2828 NULL);
4c48cf63 2829
c358f112
DS
2830 if (!peer)
2831 return CMD_WARNING;
2832
2833 if (v6only)
4c48cf63 2834 SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY);
4a04e5f7 2835
2836 /* Request zebra to initiate IPv6 RAs on this interface. We do this
2837 * any unnumbered peer in order to not worry about run-time transitions
2838 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 address
2839 * gets deleted later etc.)
2840 */
2841 if (peer->ifp)
c358f112 2842 bgp_zebra_initiate_radv (bgp, peer);
4c48cf63 2843 }
464598de
DW
2844
2845 if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) ||
2846 (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)))
4c48cf63
DW
2847 {
2848 if (v6only)
2849 SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY);
2850 else
2851 UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY);
2852
2853 /* v6only flag changed. Reset bgp seesion */
2854 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
2855 {
2856 peer->last_reset = PEER_DOWN_V6ONLY_CHANGE;
2857 bgp_notify_send (peer, BGP_NOTIFY_CEASE,
2858 BGP_NOTIFY_CEASE_CONFIG_CHANGE);
2859 }
2860 else
2861 bgp_session_reset(peer);
2862 }
2863
c358f112
DS
2864 if (!CHECK_FLAG (peer->flags, PEER_FLAG_CAPABILITY_ENHE))
2865 peer_flag_set (peer, PEER_FLAG_CAPABILITY_ENHE);
a80beece 2866
4c48cf63
DW
2867 if (peer_group_name)
2868 {
2869 group = peer_group_lookup (bgp, peer_group_name);
2870 if (! group)
2871 {
2872 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
2873 return CMD_WARNING;
2874 }
2875
2876 ret = peer_group_bind (bgp, &su, peer, group, &as);
2877 }
2878
2879 return bgp_vty_return (vty, ret);
a80beece
DS
2880}
2881
4c48cf63
DW
2882DEFUN (neighbor_interface_config,
2883 neighbor_interface_config_cmd,
31500417 2884 "neighbor WORD interface [peer-group WORD]",
4c48cf63
DW
2885 NEIGHBOR_STR
2886 "Interface name or neighbor tag\n"
31500417
DW
2887 "Enable BGP on interface\n"
2888 "Member of the peer-group\n"
16cedbb0 2889 "Peer-group name\n")
4c48cf63 2890{
c500ae40 2891 int idx_word = 1;
31500417
DW
2892 int idx_peer_group_word = 4;
2893
2894 if (argc > idx_peer_group_word)
c500ae40 2895 return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0,
31500417 2896 argv[idx_peer_group_word]->arg, NULL);
4c48cf63 2897 else
c500ae40 2898 return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0,
b3a39dc5 2899 NULL, NULL);
4c48cf63
DW
2900}
2901
4c48cf63
DW
2902DEFUN (neighbor_interface_config_v6only,
2903 neighbor_interface_config_v6only_cmd,
31500417 2904 "neighbor WORD interface v6only [peer-group WORD]",
4c48cf63
DW
2905 NEIGHBOR_STR
2906 "Interface name or neighbor tag\n"
2907 "Enable BGP on interface\n"
31500417
DW
2908 "Enable BGP with v6 link-local only\n"
2909 "Member of the peer-group\n"
16cedbb0 2910 "Peer-group name\n")
4c48cf63 2911{
c500ae40 2912 int idx_word = 1;
31500417
DW
2913 int idx_peer_group_word = 5;
2914
2915 if (argc > idx_peer_group_word)
2916 return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1,
2917 argv[idx_peer_group_word]->arg, NULL);
2918
c500ae40 2919 return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1,
31500417 2920 NULL, NULL);
4c48cf63
DW
2921}
2922
a80beece 2923
b3a39dc5
DD
2924DEFUN (neighbor_interface_config_remote_as,
2925 neighbor_interface_config_remote_as_cmd,
3a2d747c 2926 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
b3a39dc5
DD
2927 NEIGHBOR_STR
2928 "Interface name or neighbor tag\n"
2929 "Enable BGP on interface\n"
3a2d747c 2930 "Specify a BGP neighbor\n"
d7fa34c1 2931 AS_STR
3a2d747c
QY
2932 "Internal BGP peer\n"
2933 "External BGP peer\n")
b3a39dc5 2934{
c500ae40
DW
2935 int idx_word = 1;
2936 int idx_remote_as = 4;
2937 return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0,
2938 NULL, argv[idx_remote_as]->arg);
b3a39dc5
DD
2939}
2940
2941DEFUN (neighbor_interface_v6only_config_remote_as,
2942 neighbor_interface_v6only_config_remote_as_cmd,
3a2d747c 2943 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
b3a39dc5
DD
2944 NEIGHBOR_STR
2945 "Interface name or neighbor tag\n"
3a2d747c 2946 "Enable BGP with v6 link-local only\n"
b3a39dc5 2947 "Enable BGP on interface\n"
3a2d747c 2948 "Specify a BGP neighbor\n"
d7fa34c1 2949 AS_STR
3a2d747c
QY
2950 "Internal BGP peer\n"
2951 "External BGP peer\n")
b3a39dc5 2952{
c500ae40
DW
2953 int idx_word = 1;
2954 int idx_remote_as = 5;
2955 return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1,
2956 NULL, argv[idx_remote_as]->arg);
b3a39dc5
DD
2957}
2958
718e3744 2959DEFUN (neighbor_peer_group,
2960 neighbor_peer_group_cmd,
2961 "neighbor WORD peer-group",
2962 NEIGHBOR_STR
a80beece 2963 "Interface name or neighbor tag\n"
718e3744 2964 "Configure peer-group\n")
2965{
cdc2d765 2966 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40 2967 int idx_word = 1;
a80beece 2968 struct peer *peer;
718e3744 2969 struct peer_group *group;
2970
c500ae40 2971 peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg);
a80beece
DS
2972 if (peer)
2973 {
2974 vty_out (vty, "%% Name conflict with interface: %s", VTY_NEWLINE);
2975 return CMD_WARNING;
2976 }
718e3744 2977
c500ae40 2978 group = peer_group_get (bgp, argv[idx_word]->arg);
718e3744 2979 if (! group)
2980 return CMD_WARNING;
2981
2982 return CMD_SUCCESS;
2983}
2984
2985DEFUN (no_neighbor,
2986 no_neighbor_cmd,
dab8cd00 2987 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
718e3744 2988 NO_STR
2989 NEIGHBOR_STR
3a2d747c
QY
2990 NEIGHBOR_ADDR_STR2
2991 "Specify a BGP neighbor\n"
2992 AS_STR
2993 "Internal BGP peer\n"
2994 "External BGP peer\n")
718e3744 2995{
cdc2d765 2996 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40 2997 int idx_peer = 2;
718e3744 2998 int ret;
2999 union sockunion su;
3000 struct peer_group *group;
3001 struct peer *peer;
1ff9a340 3002 struct peer *other;
718e3744 3003
c500ae40 3004 ret = str2sockunion (argv[idx_peer]->arg, &su);
718e3744 3005 if (ret < 0)
3006 {
a80beece 3007 /* look up for neighbor by interface name config. */
cdc2d765 3008 peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg);
a80beece
DS
3009 if (peer)
3010 {
4a04e5f7 3011 /* Request zebra to terminate IPv6 RAs on this interface. */
3012 if (peer->ifp)
3013 bgp_zebra_terminate_radv (peer->bgp, peer);
a80beece
DS
3014 peer_delete (peer);
3015 return CMD_SUCCESS;
3016 }
3017
cdc2d765 3018 group = peer_group_lookup (bgp, argv[idx_peer]->arg);
718e3744 3019 if (group)
3020 peer_group_delete (group);
3021 else
3022 {
3023 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
3024 return CMD_WARNING;
3025 }
3026 }
3027 else
3028 {
cdc2d765 3029 peer = peer_lookup (bgp, &su);
718e3744 3030 if (peer)
1ff9a340 3031 {
f14e6fdb
DS
3032 if (peer_dynamic_neighbor (peer))
3033 {
3034 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
3035 VTY_NEWLINE);
3036 return CMD_WARNING;
3037 }
3038
1ff9a340
DS
3039 other = peer->doppelganger;
3040 peer_delete (peer);
3041 if (other && other->status != Deleted)
3042 peer_delete(other);
3043 }
718e3744 3044 }
3045
3046 return CMD_SUCCESS;
3047}
3048
a80beece
DS
3049DEFUN (no_neighbor_interface_config,
3050 no_neighbor_interface_config_cmd,
31500417 3051 "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]",
a80beece
DS
3052 NO_STR
3053 NEIGHBOR_STR
3054 "Interface name\n"
31500417
DW
3055 "Configure BGP on interface\n"
3056 "Enable BGP with v6 link-local only\n"
3057 "Member of the peer-group\n"
16cedbb0 3058 "Peer-group name\n"
3a2d747c
QY
3059 "Specify a BGP neighbor\n"
3060 AS_STR
3061 "Internal BGP peer\n"
3062 "External BGP peer\n")
a80beece 3063{
cdc2d765 3064 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40 3065 int idx_word = 2;
a80beece
DS
3066 struct peer *peer;
3067
3068 /* look up for neighbor by interface name config. */
cdc2d765 3069 peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg);
a80beece
DS
3070 if (peer)
3071 {
4a04e5f7 3072 /* Request zebra to terminate IPv6 RAs on this interface. */
3073 if (peer->ifp)
3074 bgp_zebra_terminate_radv (peer->bgp, peer);
a80beece
DS
3075 peer_delete (peer);
3076 }
3077 else
3078 {
3079 vty_out (vty, "%% Create the bgp interface first%s", VTY_NEWLINE);
3080 return CMD_WARNING;
3081 }
3082 return CMD_SUCCESS;
3083}
3084
718e3744 3085DEFUN (no_neighbor_peer_group,
3086 no_neighbor_peer_group_cmd,
3087 "no neighbor WORD peer-group",
3088 NO_STR
3089 NEIGHBOR_STR
3090 "Neighbor tag\n"
3091 "Configure peer-group\n")
3092{
cdc2d765 3093 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40 3094 int idx_word = 2;
718e3744 3095 struct peer_group *group;
3096
cdc2d765 3097 group = peer_group_lookup (bgp, argv[idx_word]->arg);
718e3744 3098 if (group)
3099 peer_group_delete (group);
3100 else
3101 {
3102 vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE);
3103 return CMD_WARNING;
3104 }
3105 return CMD_SUCCESS;
3106}
3107
a80beece
DS
3108DEFUN (no_neighbor_interface_peer_group_remote_as,
3109 no_neighbor_interface_peer_group_remote_as_cmd,
9ccf14f7 3110 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
718e3744 3111 NO_STR
3112 NEIGHBOR_STR
a80beece 3113 "Interface name or neighbor tag\n"
718e3744 3114 "Specify a BGP neighbor\n"
3a2d747c
QY
3115 AS_STR
3116 "Internal BGP peer\n"
3117 "External BGP peer\n")
718e3744 3118{
cdc2d765 3119 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40 3120 int idx_word = 2;
718e3744 3121 struct peer_group *group;
a80beece
DS
3122 struct peer *peer;
3123
3124 /* look up for neighbor by interface name config. */
cdc2d765 3125 peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg);
a80beece
DS
3126 if (peer)
3127 {
0299c004 3128 peer_as_change (peer, 0, AS_SPECIFIED);
a80beece
DS
3129 return CMD_SUCCESS;
3130 }
718e3744 3131
cdc2d765 3132 group = peer_group_lookup (bgp, argv[idx_word]->arg);
718e3744 3133 if (group)
3134 peer_group_remote_as_delete (group);
3135 else
3136 {
a80beece 3137 vty_out (vty, "%% Create the peer-group or interface first%s", VTY_NEWLINE);
718e3744 3138 return CMD_WARNING;
3139 }
3140 return CMD_SUCCESS;
3141}
6b0655a2 3142
718e3744 3143DEFUN (neighbor_local_as,
3144 neighbor_local_as_cmd,
9ccf14f7 3145 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
718e3744 3146 NEIGHBOR_STR
3147 NEIGHBOR_ADDR_STR2
3148 "Specify a local-as number\n"
3149 "AS number used as local AS\n")
3150{
c500ae40
DW
3151 int idx_peer = 1;
3152 int idx_number = 3;
718e3744 3153 struct peer *peer;
3154 int ret;
e14fda0f 3155 as_t as;
718e3744 3156
c500ae40 3157 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 3158 if (! peer)
3159 return CMD_WARNING;
3160
b6f1faf0 3161 VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX);
e14fda0f 3162 ret = peer_local_as_set (peer, as, 0, 0);
718e3744 3163 return bgp_vty_return (vty, ret);
3164}
3165
3166DEFUN (neighbor_local_as_no_prepend,
3167 neighbor_local_as_no_prepend_cmd,
9ccf14f7 3168 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
718e3744 3169 NEIGHBOR_STR
3170 NEIGHBOR_ADDR_STR2
3171 "Specify a local-as number\n"
3172 "AS number used as local AS\n"
3173 "Do not prepend local-as to updates from ebgp peers\n")
3174{
c500ae40
DW
3175 int idx_peer = 1;
3176 int idx_number = 3;
718e3744 3177 struct peer *peer;
3178 int ret;
e14fda0f 3179 as_t as;
718e3744 3180
c500ae40 3181 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 3182 if (! peer)
3183 return CMD_WARNING;
3184
b6f1faf0 3185 VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX);
e14fda0f 3186 ret = peer_local_as_set (peer, as, 1, 0);
718e3744 3187 return bgp_vty_return (vty, ret);
3188}
3189
9d3f9705
AC
3190DEFUN (neighbor_local_as_no_prepend_replace_as,
3191 neighbor_local_as_no_prepend_replace_as_cmd,
9ccf14f7 3192 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
9d3f9705
AC
3193 NEIGHBOR_STR
3194 NEIGHBOR_ADDR_STR2
3195 "Specify a local-as number\n"
3196 "AS number used as local AS\n"
3197 "Do not prepend local-as to updates from ebgp peers\n"
3198 "Do not prepend local-as to updates from ibgp peers\n")
3199{
c500ae40
DW
3200 int idx_peer = 1;
3201 int idx_number = 3;
9d3f9705
AC
3202 struct peer *peer;
3203 int ret;
e14fda0f 3204 as_t as;
9d3f9705 3205
c500ae40 3206 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
9d3f9705
AC
3207 if (! peer)
3208 return CMD_WARNING;
3209
b6f1faf0 3210 VTY_GET_INTEGER_RANGE ("Local AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX);
e14fda0f 3211 ret = peer_local_as_set (peer, as, 1, 1);
9d3f9705
AC
3212 return bgp_vty_return (vty, ret);
3213}
3214
718e3744 3215DEFUN (no_neighbor_local_as,
3216 no_neighbor_local_as_cmd,
a636c635 3217 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
718e3744 3218 NO_STR
3219 NEIGHBOR_STR
3220 NEIGHBOR_ADDR_STR2
a636c635
DW
3221 "Specify a local-as number\n"
3222 "AS number used as local AS\n"
3223 "Do not prepend local-as to updates from ebgp peers\n"
3224 "Do not prepend local-as to updates from ibgp peers\n")
718e3744 3225{
c500ae40 3226 int idx_peer = 2;
718e3744 3227 struct peer *peer;
3228 int ret;
3229
c500ae40 3230 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 3231 if (! peer)
3232 return CMD_WARNING;
3233
3234 ret = peer_local_as_unset (peer);
3235 return bgp_vty_return (vty, ret);
3236}
3237
718e3744 3238
9d3f9705 3239
6b0655a2 3240
3f9c7369
DS
3241DEFUN (neighbor_solo,
3242 neighbor_solo_cmd,
9ccf14f7 3243 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3f9c7369
DS
3244 NEIGHBOR_STR
3245 NEIGHBOR_ADDR_STR2
3246 "Solo peer - part of its own update group\n")
3247{
c500ae40 3248 int idx_peer = 1;
3f9c7369
DS
3249 struct peer *peer;
3250 int ret;
3251
c500ae40 3252 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
3f9c7369
DS
3253 if (! peer)
3254 return CMD_WARNING;
3255
3256 ret = update_group_adjust_soloness(peer, 1);
3257 return bgp_vty_return (vty, ret);
3258}
3259
3260DEFUN (no_neighbor_solo,
3261 no_neighbor_solo_cmd,
9ccf14f7 3262 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3f9c7369
DS
3263 NO_STR
3264 NEIGHBOR_STR
3265 NEIGHBOR_ADDR_STR2
3266 "Solo peer - part of its own update group\n")
3267{
c500ae40 3268 int idx_peer = 2;
3f9c7369
DS
3269 struct peer *peer;
3270 int ret;
3271
c500ae40 3272 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
3f9c7369
DS
3273 if (! peer)
3274 return CMD_WARNING;
3275
3276 ret = update_group_adjust_soloness(peer, 0);
3277 return bgp_vty_return (vty, ret);
3278}
3279
0df7c91f
PJ
3280DEFUN (neighbor_password,
3281 neighbor_password_cmd,
9ccf14f7 3282 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
0df7c91f
PJ
3283 NEIGHBOR_STR
3284 NEIGHBOR_ADDR_STR2
3285 "Set a password\n"
3286 "The password\n")
3287{
c500ae40
DW
3288 int idx_peer = 1;
3289 int idx_line = 3;
0df7c91f
PJ
3290 struct peer *peer;
3291 int ret;
3292
c500ae40 3293 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
0df7c91f
PJ
3294 if (! peer)
3295 return CMD_WARNING;
3296
c500ae40 3297 ret = peer_password_set (peer, argv[idx_line]->arg);
0df7c91f
PJ
3298 return bgp_vty_return (vty, ret);
3299}
3300
3301DEFUN (no_neighbor_password,
3302 no_neighbor_password_cmd,
a636c635 3303 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
0df7c91f
PJ
3304 NO_STR
3305 NEIGHBOR_STR
3306 NEIGHBOR_ADDR_STR2
16cedbb0
QY
3307 "Set a password\n"
3308 "The password\n")
0df7c91f 3309{
c500ae40 3310 int idx_peer = 2;
0df7c91f
PJ
3311 struct peer *peer;
3312 int ret;
3313
c500ae40 3314 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
0df7c91f
PJ
3315 if (! peer)
3316 return CMD_WARNING;
3317
3318 ret = peer_password_unset (peer);
3319 return bgp_vty_return (vty, ret);
3320}
6b0655a2 3321
813d4307 3322
718e3744 3323DEFUN (neighbor_activate,
3324 neighbor_activate_cmd,
9ccf14f7 3325 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
718e3744 3326 NEIGHBOR_STR
3327 NEIGHBOR_ADDR_STR2
3328 "Enable the Address Family for this Neighbor\n")
3329{
c500ae40 3330 int idx_peer = 1;
c8560b44 3331 int ret;
718e3744 3332 struct peer *peer;
3333
c500ae40 3334 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 3335 if (! peer)
3336 return CMD_WARNING;
3337
c8560b44 3338 ret = peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
718e3744 3339
c8560b44
DW
3340 if (ret)
3341 return CMD_WARNING;
718e3744 3342 return CMD_SUCCESS;
3343}
3344
596c17ba
DW
3345ALIAS_HIDDEN (neighbor_activate,
3346 neighbor_activate_hidden_cmd,
3347 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3348 NEIGHBOR_STR
3349 NEIGHBOR_ADDR_STR2
3350 "Enable the Address Family for this Neighbor\n")
3351
718e3744 3352DEFUN (no_neighbor_activate,
3353 no_neighbor_activate_cmd,
9ccf14f7 3354 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
718e3744 3355 NO_STR
3356 NEIGHBOR_STR
3357 NEIGHBOR_ADDR_STR2
3358 "Enable the Address Family for this Neighbor\n")
3359{
c500ae40 3360 int idx_peer = 2;
718e3744 3361 int ret;
3362 struct peer *peer;
3363
3364 /* Lookup peer. */
c500ae40 3365 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 3366 if (! peer)
3367 return CMD_WARNING;
3368
3369 ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty));
3370
c8560b44
DW
3371 if (ret)
3372 return CMD_WARNING;
3373 return CMD_SUCCESS;
718e3744 3374}
6b0655a2 3375
596c17ba
DW
3376ALIAS_HIDDEN (no_neighbor_activate,
3377 no_neighbor_activate_hidden_cmd,
3378 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3379 NO_STR
3380 NEIGHBOR_STR
3381 NEIGHBOR_ADDR_STR2
3382 "Enable the Address Family for this Neighbor\n")
3383
718e3744 3384DEFUN (neighbor_set_peer_group,
3385 neighbor_set_peer_group_cmd,
9ccf14f7 3386 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
718e3744 3387 NEIGHBOR_STR
a80beece 3388 NEIGHBOR_ADDR_STR2
718e3744 3389 "Member of the peer-group\n"
16cedbb0 3390 "Peer-group name\n")
718e3744 3391{
cdc2d765 3392 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40
DW
3393 int idx_peer = 1;
3394 int idx_word = 3;
718e3744 3395 int ret;
3396 as_t as;
3397 union sockunion su;
a80beece 3398 struct peer *peer;
718e3744 3399 struct peer_group *group;
3400
a80beece 3401 peer = NULL;
718e3744 3402
c500ae40 3403 ret = str2sockunion (argv[idx_peer]->arg, &su);
718e3744 3404 if (ret < 0)
3405 {
c500ae40 3406 peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg);
a80beece
DS
3407 if (!peer)
3408 {
c500ae40 3409 vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
a80beece
DS
3410 return CMD_WARNING;
3411 }
3412 }
3413 else
3414 {
6aeb9e78 3415 if (peer_address_self_check (bgp, &su))
a80beece
DS
3416 {
3417 vty_out (vty, "%% Can not configure the local system as neighbor%s",
3418 VTY_NEWLINE);
3419 return CMD_WARNING;
3420 }
f14e6fdb
DS
3421
3422 /* Disallow for dynamic neighbor. */
3423 peer = peer_lookup (bgp, &su);
3424 if (peer && peer_dynamic_neighbor (peer))
3425 {
3426 vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s",
3427 VTY_NEWLINE);
3428 return CMD_WARNING;
3429 }
718e3744 3430 }
3431
c500ae40 3432 group = peer_group_lookup (bgp, argv[idx_word]->arg);
718e3744 3433 if (! group)
3434 {
3435 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
3436 return CMD_WARNING;
3437 }
3438
c8560b44 3439 ret = peer_group_bind (bgp, &su, peer, group, &as);
718e3744 3440
3441 if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT)
3442 {
aea339f7 3443 vty_out (vty, "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external%s", as, VTY_NEWLINE);
718e3744 3444 return CMD_WARNING;
3445 }
3446
3447 return bgp_vty_return (vty, ret);
3448}
3449
596c17ba
DW
3450ALIAS_HIDDEN (neighbor_set_peer_group,
3451 neighbor_set_peer_group_hidden_cmd,
3452 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3453 NEIGHBOR_STR
3454 NEIGHBOR_ADDR_STR2
3455 "Member of the peer-group\n"
3456 "Peer-group name\n")
3457
718e3744 3458DEFUN (no_neighbor_set_peer_group,
3459 no_neighbor_set_peer_group_cmd,
9ccf14f7 3460 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
718e3744 3461 NO_STR
3462 NEIGHBOR_STR
a80beece 3463 NEIGHBOR_ADDR_STR2
718e3744 3464 "Member of the peer-group\n"
16cedbb0 3465 "Peer-group name\n")
718e3744 3466{
cdc2d765 3467 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40
DW
3468 int idx_peer = 2;
3469 int idx_word = 4;
718e3744 3470 int ret;
718e3744 3471 struct peer *peer;
3472 struct peer_group *group;
3473
c500ae40 3474 peer = peer_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 3475 if (! peer)
3476 return CMD_WARNING;
3477
c500ae40 3478 group = peer_group_lookup (bgp, argv[idx_word]->arg);
718e3744 3479 if (! group)
3480 {
3481 vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE);
3482 return CMD_WARNING;
3483 }
3484
c8560b44 3485 ret = peer_group_unbind (bgp, peer, group);
718e3744 3486
3487 return bgp_vty_return (vty, ret);
3488}
6b0655a2 3489
596c17ba
DW
3490ALIAS_HIDDEN (no_neighbor_set_peer_group,
3491 no_neighbor_set_peer_group_hidden_cmd,
3492 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3493 NO_STR
3494 NEIGHBOR_STR
3495 NEIGHBOR_ADDR_STR2
3496 "Member of the peer-group\n"
3497 "Peer-group name\n")
3498
94f2b392 3499static int
e52702f2 3500peer_flag_modify_vty (struct vty *vty, const char *ip_str,
fd79ac91 3501 u_int16_t flag, int set)
718e3744 3502{
3503 int ret;
3504 struct peer *peer;
3505
3506 peer = peer_and_group_lookup_vty (vty, ip_str);
3507 if (! peer)
3508 return CMD_WARNING;
3509
8cdabf90
SK
3510 /*
3511 * If 'neighbor <interface>', then this is for directly connected peers,
3512 * we should not accept disable-connected-check.
3513 */
3514 if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) {
3515 vty_out (vty, "%s is directly connected peer, cannot accept disable-"
3516 "connected-check%s", ip_str, VTY_NEWLINE);
3517 return CMD_WARNING;
3518 }
3519
ae9b0e11
DS
3520 if (!set && flag == PEER_FLAG_SHUTDOWN)
3521 peer_tx_shutdown_message_unset (peer);
3522
718e3744 3523 if (set)
3524 ret = peer_flag_set (peer, flag);
3525 else
3526 ret = peer_flag_unset (peer, flag);
3527
3528 return bgp_vty_return (vty, ret);
3529}
3530
94f2b392 3531static int
fd79ac91 3532peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
718e3744 3533{
3534 return peer_flag_modify_vty (vty, ip_str, flag, 1);
3535}
3536
94f2b392 3537static int
fd79ac91 3538peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
718e3744 3539{
3540 return peer_flag_modify_vty (vty, ip_str, flag, 0);
3541}
3542
3543/* neighbor passive. */
3544DEFUN (neighbor_passive,
3545 neighbor_passive_cmd,
9ccf14f7 3546 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
718e3744 3547 NEIGHBOR_STR
3548 NEIGHBOR_ADDR_STR2
3549 "Don't send open messages to this neighbor\n")
3550{
c500ae40
DW
3551 int idx_peer = 1;
3552 return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE);
718e3744 3553}
3554
3555DEFUN (no_neighbor_passive,
3556 no_neighbor_passive_cmd,
9ccf14f7 3557 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
718e3744 3558 NO_STR
3559 NEIGHBOR_STR
3560 NEIGHBOR_ADDR_STR2
3561 "Don't send open messages to this neighbor\n")
3562{
c500ae40
DW
3563 int idx_peer = 2;
3564 return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE);
718e3744 3565}
6b0655a2 3566
718e3744 3567/* neighbor shutdown. */
73d70fa6
DL
3568DEFUN (neighbor_shutdown_msg,
3569 neighbor_shutdown_msg_cmd,
3570 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
718e3744 3571 NEIGHBOR_STR
3572 NEIGHBOR_ADDR_STR2
73d70fa6
DL
3573 "Administratively shut down this neighbor\n"
3574 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3575 "Shutdown message\n")
718e3744 3576{
c500ae40 3577 int idx_peer = 1;
73d70fa6
DL
3578
3579 if (argc >= 5)
3580 {
ae9b0e11 3581 struct peer *peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
73d70fa6
DL
3582 char *message;
3583
ae9b0e11
DS
3584 if (!peer)
3585 return CMD_WARNING;
73d70fa6
DL
3586 message = argv_concat (argv, argc, 4);
3587 peer_tx_shutdown_message_set (peer, message);
3588 XFREE (MTYPE_TMP, message);
3589 }
3590
c500ae40 3591 return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN);
718e3744 3592}
3593
73d70fa6
DL
3594ALIAS (neighbor_shutdown_msg,
3595 neighbor_shutdown_cmd,
3596 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
718e3744 3597 NEIGHBOR_STR
3598 NEIGHBOR_ADDR_STR2
3599 "Administratively shut down this neighbor\n")
73d70fa6
DL
3600
3601DEFUN (no_neighbor_shutdown_msg,
3602 no_neighbor_shutdown_msg_cmd,
3603 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3604 NO_STR
3605 NEIGHBOR_STR
3606 NEIGHBOR_ADDR_STR2
3607 "Administratively shut down this neighbor\n"
3608 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3609 "Shutdown message\n")
718e3744 3610{
c500ae40 3611 int idx_peer = 2;
73d70fa6 3612
c500ae40 3613 return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN);
718e3744 3614}
6b0655a2 3615
73d70fa6
DL
3616ALIAS (no_neighbor_shutdown_msg,
3617 no_neighbor_shutdown_cmd,
3618 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3619 NO_STR
3620 NEIGHBOR_STR
3621 NEIGHBOR_ADDR_STR2
3622 "Administratively shut down this neighbor\n")
3623
718e3744 3624/* neighbor capability dynamic. */
3625DEFUN (neighbor_capability_dynamic,
3626 neighbor_capability_dynamic_cmd,
9ccf14f7 3627 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
718e3744 3628 NEIGHBOR_STR
3629 NEIGHBOR_ADDR_STR2
3630 "Advertise capability to the peer\n"
3631 "Advertise dynamic capability to this neighbor\n")
3632{
c500ae40
DW
3633 int idx_peer = 1;
3634 return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY);
718e3744 3635}
3636
3637DEFUN (no_neighbor_capability_dynamic,
3638 no_neighbor_capability_dynamic_cmd,
9ccf14f7 3639 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
718e3744 3640 NO_STR
3641 NEIGHBOR_STR
3642 NEIGHBOR_ADDR_STR2
3643 "Advertise capability to the peer\n"
3644 "Advertise dynamic capability to this neighbor\n")
3645{
c500ae40
DW
3646 int idx_peer = 2;
3647 return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY);
718e3744 3648}
6b0655a2 3649
718e3744 3650/* neighbor dont-capability-negotiate */
3651DEFUN (neighbor_dont_capability_negotiate,
3652 neighbor_dont_capability_negotiate_cmd,
9ccf14f7 3653 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
718e3744 3654 NEIGHBOR_STR
3655 NEIGHBOR_ADDR_STR2
3656 "Do not perform capability negotiation\n")
3657{
c500ae40
DW
3658 int idx_peer = 1;
3659 return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY);
718e3744 3660}
3661
3662DEFUN (no_neighbor_dont_capability_negotiate,
3663 no_neighbor_dont_capability_negotiate_cmd,
9ccf14f7 3664 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
718e3744 3665 NO_STR
3666 NEIGHBOR_STR
3667 NEIGHBOR_ADDR_STR2
3668 "Do not perform capability negotiation\n")
3669{
c500ae40
DW
3670 int idx_peer = 2;
3671 return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY);
718e3744 3672}
6b0655a2 3673
8a92a8a0
DS
3674/* neighbor capability extended next hop encoding */
3675DEFUN (neighbor_capability_enhe,
3676 neighbor_capability_enhe_cmd,
9ccf14f7 3677 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
8a92a8a0
DS
3678 NEIGHBOR_STR
3679 NEIGHBOR_ADDR_STR2
3680 "Advertise capability to the peer\n"
3681 "Advertise extended next-hop capability to the peer\n")
3682{
c500ae40
DW
3683 int idx_peer = 1;
3684 return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE);
8a92a8a0
DS
3685}
3686
3687DEFUN (no_neighbor_capability_enhe,
3688 no_neighbor_capability_enhe_cmd,
9ccf14f7 3689 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
8a92a8a0
DS
3690 NO_STR
3691 NEIGHBOR_STR
3692 NEIGHBOR_ADDR_STR2
3693 "Advertise capability to the peer\n"
3694 "Advertise extended next-hop capability to the peer\n")
3695{
c500ae40
DW
3696 int idx_peer = 2;
3697 return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE);
8a92a8a0
DS
3698}
3699
94f2b392 3700static int
fd79ac91 3701peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi,
fee0f4c6 3702 safi_t safi, u_int32_t flag, int set)
718e3744 3703{
3704 int ret;
3705 struct peer *peer;
3706
3707 peer = peer_and_group_lookup_vty (vty, peer_str);
3708 if (! peer)
3709 return CMD_WARNING;
3710
3711 if (set)
3712 ret = peer_af_flag_set (peer, afi, safi, flag);
3713 else
3714 ret = peer_af_flag_unset (peer, afi, safi, flag);
3715
3716 return bgp_vty_return (vty, ret);
3717}
3718
94f2b392 3719static int
fd79ac91 3720peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi,
fee0f4c6 3721 safi_t safi, u_int32_t flag)
718e3744 3722{
3723 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1);
3724}
3725
94f2b392 3726static int
fd79ac91 3727peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi,
fee0f4c6 3728 safi_t safi, u_int32_t flag)
718e3744 3729{
3730 return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0);
3731}
6b0655a2 3732
718e3744 3733/* neighbor capability orf prefix-list. */
3734DEFUN (neighbor_capability_orf_prefix,
3735 neighbor_capability_orf_prefix_cmd,
9ccf14f7 3736 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
718e3744 3737 NEIGHBOR_STR
3738 NEIGHBOR_ADDR_STR2
3739 "Advertise capability to the peer\n"
3740 "Advertise ORF capability to the peer\n"
3741 "Advertise prefixlist ORF capability to this neighbor\n"
3742 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3743 "Capability to RECEIVE the ORF from this neighbor\n"
3744 "Capability to SEND the ORF to this neighbor\n")
3745{
c500ae40
DW
3746 int idx_peer = 1;
3747 int idx_send_recv = 5;
718e3744 3748 u_int16_t flag = 0;
3749
c500ae40 3750 if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0)
718e3744 3751 flag = PEER_FLAG_ORF_PREFIX_SM;
c500ae40 3752 else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0)
718e3744 3753 flag = PEER_FLAG_ORF_PREFIX_RM;
c500ae40 3754 else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0)
718e3744 3755 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
3756 else
3757 return CMD_WARNING;
3758
c500ae40 3759 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 3760 bgp_node_safi (vty), flag);
3761}
3762
596c17ba
DW
3763ALIAS_HIDDEN (neighbor_capability_orf_prefix,
3764 neighbor_capability_orf_prefix_hidden_cmd,
3765 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3766 NEIGHBOR_STR
3767 NEIGHBOR_ADDR_STR2
3768 "Advertise capability to the peer\n"
3769 "Advertise ORF capability to the peer\n"
3770 "Advertise prefixlist ORF capability to this neighbor\n"
3771 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3772 "Capability to RECEIVE the ORF from this neighbor\n"
3773 "Capability to SEND the ORF to this neighbor\n")
3774
718e3744 3775DEFUN (no_neighbor_capability_orf_prefix,
3776 no_neighbor_capability_orf_prefix_cmd,
9ccf14f7 3777 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
718e3744 3778 NO_STR
3779 NEIGHBOR_STR
3780 NEIGHBOR_ADDR_STR2
3781 "Advertise capability to the peer\n"
3782 "Advertise ORF capability to the peer\n"
3783 "Advertise prefixlist ORF capability to this neighbor\n"
3784 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3785 "Capability to RECEIVE the ORF from this neighbor\n"
3786 "Capability to SEND the ORF to this neighbor\n")
3787{
c500ae40
DW
3788 int idx_peer = 2;
3789 int idx_send_recv = 6;
718e3744 3790 u_int16_t flag = 0;
3791
c500ae40 3792 if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0)
718e3744 3793 flag = PEER_FLAG_ORF_PREFIX_SM;
c500ae40 3794 else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0)
718e3744 3795 flag = PEER_FLAG_ORF_PREFIX_RM;
c500ae40 3796 else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0)
718e3744 3797 flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM;
3798 else
3799 return CMD_WARNING;
3800
c500ae40 3801 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 3802 bgp_node_safi (vty), flag);
3803}
6b0655a2 3804
596c17ba
DW
3805ALIAS_HIDDEN (no_neighbor_capability_orf_prefix,
3806 no_neighbor_capability_orf_prefix_hidden_cmd,
3807 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3808 NO_STR
3809 NEIGHBOR_STR
3810 NEIGHBOR_ADDR_STR2
3811 "Advertise capability to the peer\n"
3812 "Advertise ORF capability to the peer\n"
3813 "Advertise prefixlist ORF capability to this neighbor\n"
3814 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3815 "Capability to RECEIVE the ORF from this neighbor\n"
3816 "Capability to SEND the ORF to this neighbor\n")
3817
718e3744 3818/* neighbor next-hop-self. */
3819DEFUN (neighbor_nexthop_self,
3820 neighbor_nexthop_self_cmd,
9ccf14f7 3821 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
718e3744 3822 NEIGHBOR_STR
3823 NEIGHBOR_ADDR_STR2
a538debe 3824 "Disable the next hop calculation for this neighbor\n")
718e3744 3825{
c500ae40
DW
3826 int idx_peer = 1;
3827 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
a538debe
DS
3828 bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
3829}
9e7a53c1 3830
596c17ba
DW
3831ALIAS_HIDDEN (neighbor_nexthop_self,
3832 neighbor_nexthop_self_hidden_cmd,
3833 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3834 NEIGHBOR_STR
3835 NEIGHBOR_ADDR_STR2
3836 "Disable the next hop calculation for this neighbor\n")
3837
a538debe
DS
3838/* neighbor next-hop-self. */
3839DEFUN (neighbor_nexthop_self_force,
3840 neighbor_nexthop_self_force_cmd,
9ccf14f7 3841 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
a538debe
DS
3842 NEIGHBOR_STR
3843 NEIGHBOR_ADDR_STR2
3844 "Disable the next hop calculation for this neighbor\n"
3845 "Set the next hop to self for reflected routes\n")
3846{
c500ae40
DW
3847 int idx_peer = 1;
3848 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
a538debe 3849 bgp_node_safi (vty),
88b8ed8d 3850 PEER_FLAG_FORCE_NEXTHOP_SELF);
718e3744 3851}
3852
596c17ba
DW
3853ALIAS_HIDDEN (neighbor_nexthop_self_force,
3854 neighbor_nexthop_self_force_hidden_cmd,
3855 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3856 NEIGHBOR_STR
3857 NEIGHBOR_ADDR_STR2
3858 "Disable the next hop calculation for this neighbor\n"
3859 "Set the next hop to self for reflected routes\n")
3860
718e3744 3861DEFUN (no_neighbor_nexthop_self,
3862 no_neighbor_nexthop_self_cmd,
9ccf14f7 3863 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
718e3744 3864 NO_STR
3865 NEIGHBOR_STR
3866 NEIGHBOR_ADDR_STR2
a538debe 3867 "Disable the next hop calculation for this neighbor\n")
718e3744 3868{
c500ae40
DW
3869 int idx_peer = 2;
3870 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
9e7a53c1 3871 bgp_node_safi (vty),
88b8ed8d 3872 PEER_FLAG_NEXTHOP_SELF);
718e3744 3873}
6b0655a2 3874
596c17ba
DW
3875ALIAS_HIDDEN (no_neighbor_nexthop_self,
3876 no_neighbor_nexthop_self_hidden_cmd,
3877 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3878 NO_STR
3879 NEIGHBOR_STR
3880 NEIGHBOR_ADDR_STR2
3881 "Disable the next hop calculation for this neighbor\n")
3882
88b8ed8d 3883DEFUN (no_neighbor_nexthop_self_force,
a538debe 3884 no_neighbor_nexthop_self_force_cmd,
9ccf14f7 3885 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
a538debe
DS
3886 NO_STR
3887 NEIGHBOR_STR
3888 NEIGHBOR_ADDR_STR2
3889 "Disable the next hop calculation for this neighbor\n"
3890 "Set the next hop to self for reflected routes\n")
88b8ed8d 3891{
c500ae40
DW
3892 int idx_peer = 2;
3893 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
88b8ed8d
DW
3894 bgp_node_safi (vty),
3895 PEER_FLAG_FORCE_NEXTHOP_SELF);
3896}
a538debe 3897
596c17ba
DW
3898ALIAS_HIDDEN (no_neighbor_nexthop_self_force,
3899 no_neighbor_nexthop_self_force_hidden_cmd,
3900 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3901 NO_STR
3902 NEIGHBOR_STR
3903 NEIGHBOR_ADDR_STR2
3904 "Disable the next hop calculation for this neighbor\n"
3905 "Set the next hop to self for reflected routes\n")
3906
c7122e14
DS
3907/* neighbor as-override */
3908DEFUN (neighbor_as_override,
3909 neighbor_as_override_cmd,
9ccf14f7 3910 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
c7122e14
DS
3911 NEIGHBOR_STR
3912 NEIGHBOR_ADDR_STR2
3913 "Override ASNs in outbound updates if aspath equals remote-as\n")
3914{
c500ae40
DW
3915 int idx_peer = 1;
3916 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
c7122e14
DS
3917 bgp_node_safi (vty),
3918 PEER_FLAG_AS_OVERRIDE);
3919}
3920
596c17ba
DW
3921ALIAS_HIDDEN (neighbor_as_override,
3922 neighbor_as_override_hidden_cmd,
3923 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3924 NEIGHBOR_STR
3925 NEIGHBOR_ADDR_STR2
3926 "Override ASNs in outbound updates if aspath equals remote-as\n")
3927
c7122e14
DS
3928DEFUN (no_neighbor_as_override,
3929 no_neighbor_as_override_cmd,
9ccf14f7 3930 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
c7122e14
DS
3931 NO_STR
3932 NEIGHBOR_STR
3933 NEIGHBOR_ADDR_STR2
3934 "Override ASNs in outbound updates if aspath equals remote-as\n")
3935{
c500ae40
DW
3936 int idx_peer = 2;
3937 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
c7122e14
DS
3938 bgp_node_safi (vty),
3939 PEER_FLAG_AS_OVERRIDE);
3940}
3941
596c17ba
DW
3942ALIAS_HIDDEN (no_neighbor_as_override,
3943 no_neighbor_as_override_hidden_cmd,
3944 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3945 NO_STR
3946 NEIGHBOR_STR
3947 NEIGHBOR_ADDR_STR2
3948 "Override ASNs in outbound updates if aspath equals remote-as\n")
3949
718e3744 3950/* neighbor remove-private-AS. */
3951DEFUN (neighbor_remove_private_as,
3952 neighbor_remove_private_as_cmd,
9ccf14f7 3953 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
718e3744 3954 NEIGHBOR_STR
3955 NEIGHBOR_ADDR_STR2
5000f21c 3956 "Remove private ASNs in outbound updates\n")
718e3744 3957{
c500ae40
DW
3958 int idx_peer = 1;
3959 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 3960 bgp_node_safi (vty),
3961 PEER_FLAG_REMOVE_PRIVATE_AS);
3962}
3963
596c17ba
DW
3964ALIAS_HIDDEN (neighbor_remove_private_as,
3965 neighbor_remove_private_as_hidden_cmd,
3966 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3967 NEIGHBOR_STR
3968 NEIGHBOR_ADDR_STR2
3969 "Remove private ASNs in outbound updates\n")
3970
5000f21c
DS
3971DEFUN (neighbor_remove_private_as_all,
3972 neighbor_remove_private_as_all_cmd,
9ccf14f7 3973 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5000f21c
DS
3974 NEIGHBOR_STR
3975 NEIGHBOR_ADDR_STR2
3976 "Remove private ASNs in outbound updates\n"
3977 "Apply to all AS numbers")
3978{
c500ae40
DW
3979 int idx_peer = 1;
3980 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5000f21c 3981 bgp_node_safi (vty),
5000f21c
DS
3982 PEER_FLAG_REMOVE_PRIVATE_AS_ALL);
3983}
3984
596c17ba
DW
3985ALIAS_HIDDEN (neighbor_remove_private_as_all,
3986 neighbor_remove_private_as_all_hidden_cmd,
3987 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3988 NEIGHBOR_STR
3989 NEIGHBOR_ADDR_STR2
3990 "Remove private ASNs in outbound updates\n"
3991 "Apply to all AS numbers")
3992
5000f21c
DS
3993DEFUN (neighbor_remove_private_as_replace_as,
3994 neighbor_remove_private_as_replace_as_cmd,
9ccf14f7 3995 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5000f21c
DS
3996 NEIGHBOR_STR
3997 NEIGHBOR_ADDR_STR2
3998 "Remove private ASNs in outbound updates\n"
3999 "Replace private ASNs with our ASN in outbound updates\n")
4000{
c500ae40
DW
4001 int idx_peer = 1;
4002 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5000f21c 4003 bgp_node_safi (vty),
5000f21c
DS
4004 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
4005}
4006
596c17ba
DW
4007ALIAS_HIDDEN (neighbor_remove_private_as_replace_as,
4008 neighbor_remove_private_as_replace_as_hidden_cmd,
4009 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4010 NEIGHBOR_STR
4011 NEIGHBOR_ADDR_STR2
4012 "Remove private ASNs in outbound updates\n"
4013 "Replace private ASNs with our ASN in outbound updates\n")
4014
5000f21c
DS
4015DEFUN (neighbor_remove_private_as_all_replace_as,
4016 neighbor_remove_private_as_all_replace_as_cmd,
9ccf14f7 4017 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5000f21c
DS
4018 NEIGHBOR_STR
4019 NEIGHBOR_ADDR_STR2
4020 "Remove private ASNs in outbound updates\n"
16cedbb0 4021 "Apply to all AS numbers\n"
5000f21c
DS
4022 "Replace private ASNs with our ASN in outbound updates\n")
4023{
c500ae40
DW
4024 int idx_peer = 1;
4025 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5000f21c 4026 bgp_node_safi (vty),
88b8ed8d 4027 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE);
5000f21c
DS
4028}
4029
596c17ba
DW
4030ALIAS_HIDDEN (neighbor_remove_private_as_all_replace_as,
4031 neighbor_remove_private_as_all_replace_as_hidden_cmd,
4032 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4033 NEIGHBOR_STR
4034 NEIGHBOR_ADDR_STR2
4035 "Remove private ASNs in outbound updates\n"
4036 "Apply to all AS numbers\n"
4037 "Replace private ASNs with our ASN in outbound updates\n")
4038
718e3744 4039DEFUN (no_neighbor_remove_private_as,
4040 no_neighbor_remove_private_as_cmd,
9ccf14f7 4041 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
718e3744 4042 NO_STR
4043 NEIGHBOR_STR
4044 NEIGHBOR_ADDR_STR2
5000f21c 4045 "Remove private ASNs in outbound updates\n")
718e3744 4046{
c500ae40
DW
4047 int idx_peer = 2;
4048 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4049 bgp_node_safi (vty),
88b8ed8d 4050 PEER_FLAG_REMOVE_PRIVATE_AS);
718e3744 4051}
6b0655a2 4052
596c17ba
DW
4053ALIAS_HIDDEN (no_neighbor_remove_private_as,
4054 no_neighbor_remove_private_as_hidden_cmd,
4055 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4056 NO_STR
4057 NEIGHBOR_STR
4058 NEIGHBOR_ADDR_STR2
4059 "Remove private ASNs in outbound updates\n")
4060
88b8ed8d 4061DEFUN (no_neighbor_remove_private_as_all,
5000f21c 4062 no_neighbor_remove_private_as_all_cmd,
9ccf14f7 4063 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5000f21c
DS
4064 NO_STR
4065 NEIGHBOR_STR
4066 NEIGHBOR_ADDR_STR2
4067 "Remove private ASNs in outbound updates\n"
16cedbb0 4068 "Apply to all AS numbers\n")
88b8ed8d 4069{
c500ae40
DW
4070 int idx_peer = 2;
4071 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
88b8ed8d
DW
4072 bgp_node_safi (vty),
4073 PEER_FLAG_REMOVE_PRIVATE_AS_ALL);
4074}
5000f21c 4075
596c17ba
DW
4076ALIAS_HIDDEN (no_neighbor_remove_private_as_all,
4077 no_neighbor_remove_private_as_all_hidden_cmd,
4078 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4079 NO_STR
4080 NEIGHBOR_STR
4081 NEIGHBOR_ADDR_STR2
4082 "Remove private ASNs in outbound updates\n"
4083 "Apply to all AS numbers\n")
4084
88b8ed8d 4085DEFUN (no_neighbor_remove_private_as_replace_as,
5000f21c 4086 no_neighbor_remove_private_as_replace_as_cmd,
9ccf14f7 4087 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5000f21c
DS
4088 NO_STR
4089 NEIGHBOR_STR
4090 NEIGHBOR_ADDR_STR2
4091 "Remove private ASNs in outbound updates\n"
4092 "Replace private ASNs with our ASN in outbound updates\n")
88b8ed8d 4093{
c500ae40
DW
4094 int idx_peer = 2;
4095 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
88b8ed8d
DW
4096 bgp_node_safi (vty),
4097 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE);
4098}
5000f21c 4099
596c17ba
DW
4100ALIAS_HIDDEN (no_neighbor_remove_private_as_replace_as,
4101 no_neighbor_remove_private_as_replace_as_hidden_cmd,
4102 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4103 NO_STR
4104 NEIGHBOR_STR
4105 NEIGHBOR_ADDR_STR2
4106 "Remove private ASNs in outbound updates\n"
4107 "Replace private ASNs with our ASN in outbound updates\n")
4108
88b8ed8d 4109DEFUN (no_neighbor_remove_private_as_all_replace_as,
5000f21c 4110 no_neighbor_remove_private_as_all_replace_as_cmd,
9ccf14f7 4111 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5000f21c
DS
4112 NO_STR
4113 NEIGHBOR_STR
4114 NEIGHBOR_ADDR_STR2
4115 "Remove private ASNs in outbound updates\n"
16cedbb0 4116 "Apply to all AS numbers\n"
5000f21c 4117 "Replace private ASNs with our ASN in outbound updates\n")
88b8ed8d 4118{
c500ae40
DW
4119 int idx_peer = 2;
4120 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
88b8ed8d
DW
4121 bgp_node_safi (vty),
4122 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE);
4123}
5000f21c 4124
596c17ba
DW
4125ALIAS_HIDDEN (no_neighbor_remove_private_as_all_replace_as,
4126 no_neighbor_remove_private_as_all_replace_as_hidden_cmd,
4127 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4128 NO_STR
4129 NEIGHBOR_STR
4130 NEIGHBOR_ADDR_STR2
4131 "Remove private ASNs in outbound updates\n"
4132 "Apply to all AS numbers\n"
4133 "Replace private ASNs with our ASN in outbound updates\n")
4134
5000f21c 4135
718e3744 4136/* neighbor send-community. */
4137DEFUN (neighbor_send_community,
4138 neighbor_send_community_cmd,
9ccf14f7 4139 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
718e3744 4140 NEIGHBOR_STR
4141 NEIGHBOR_ADDR_STR2
4142 "Send Community attribute to this neighbor\n")
4143{
c500ae40
DW
4144 int idx_peer = 1;
4145 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4146 bgp_node_safi (vty),
4147 PEER_FLAG_SEND_COMMUNITY);
4148}
4149
596c17ba
DW
4150ALIAS_HIDDEN (neighbor_send_community,
4151 neighbor_send_community_hidden_cmd,
4152 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4153 NEIGHBOR_STR
4154 NEIGHBOR_ADDR_STR2
4155 "Send Community attribute to this neighbor\n")
4156
718e3744 4157DEFUN (no_neighbor_send_community,
4158 no_neighbor_send_community_cmd,
9ccf14f7 4159 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
718e3744 4160 NO_STR
4161 NEIGHBOR_STR
4162 NEIGHBOR_ADDR_STR2
4163 "Send Community attribute to this neighbor\n")
4164{
c500ae40
DW
4165 int idx_peer = 2;
4166 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4167 bgp_node_safi (vty),
4168 PEER_FLAG_SEND_COMMUNITY);
4169}
6b0655a2 4170
596c17ba
DW
4171ALIAS_HIDDEN (no_neighbor_send_community,
4172 no_neighbor_send_community_hidden_cmd,
4173 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4174 NO_STR
4175 NEIGHBOR_STR
4176 NEIGHBOR_ADDR_STR2
4177 "Send Community attribute to this neighbor\n")
4178
718e3744 4179/* neighbor send-community extended. */
4180DEFUN (neighbor_send_community_type,
4181 neighbor_send_community_type_cmd,
57d187bc 4182 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
718e3744 4183 NEIGHBOR_STR
4184 NEIGHBOR_ADDR_STR2
4185 "Send Community attribute to this neighbor\n"
4186 "Send Standard and Extended Community attributes\n"
57d187bc 4187 "Send Standard, Large and Extended Community attributes\n"
718e3744 4188 "Send Extended Community attributes\n"
57d187bc
JS
4189 "Send Standard Community attributes\n"
4190 "Send Large Community attributes\n")
718e3744 4191{
4c4ff4c1
QY
4192 int idx = 0;
4193 u_int32_t flag = 0;
718e3744 4194
4c4ff4c1
QY
4195 char *peer = argv[1]->arg;
4196
4197 if (argv_find (argv, argc, "standard", &idx))
4198 SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY);
4199 else if (argv_find (argv, argc, "extended", &idx))
4200 SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY);
57d187bc
JS
4201 else if (argv_find (argv, argc, "large", &idx))
4202 SET_FLAG (flag, PEER_FLAG_SEND_LARGE_COMMUNITY);
4203 else if (argv_find (argv, argc, "both", &idx))
4204 {
4205 SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY);
4206 SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY);
4207 }
4c4ff4c1 4208 else
57d187bc
JS
4209 {
4210 SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY);
4211 SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY);
4212 SET_FLAG (flag, PEER_FLAG_SEND_LARGE_COMMUNITY);
4213 }
4c4ff4c1
QY
4214
4215 return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flag);
718e3744 4216}
4217
596c17ba
DW
4218ALIAS_HIDDEN (neighbor_send_community_type,
4219 neighbor_send_community_type_hidden_cmd,
4220 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4221 NEIGHBOR_STR
4222 NEIGHBOR_ADDR_STR2
4223 "Send Community attribute to this neighbor\n"
4224 "Send Standard and Extended Community attributes\n"
4225 "Send Standard, Large and Extended Community attributes\n"
4226 "Send Extended Community attributes\n"
4227 "Send Standard Community attributes\n"
4228 "Send Large Community attributes\n")
4229
718e3744 4230DEFUN (no_neighbor_send_community_type,
4231 no_neighbor_send_community_type_cmd,
57d187bc 4232 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
718e3744 4233 NO_STR
4234 NEIGHBOR_STR
4235 NEIGHBOR_ADDR_STR2
4236 "Send Community attribute to this neighbor\n"
4237 "Send Standard and Extended Community attributes\n"
57d187bc 4238 "Send Standard, Large and Extended Community attributes\n"
718e3744 4239 "Send Extended Community attributes\n"
57d187bc
JS
4240 "Send Standard Community attributes\n"
4241 "Send Large Community attributes\n")
718e3744 4242{
c500ae40
DW
4243 int idx_peer = 2;
4244 int idx_type = 4;
4245 if (strncmp (argv[idx_type]->arg, "s", 1) == 0)
4246 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4247 bgp_node_safi (vty),
4248 PEER_FLAG_SEND_COMMUNITY);
c500ae40
DW
4249 if (strncmp (argv[idx_type]->arg, "e", 1) == 0)
4250 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4251 bgp_node_safi (vty),
4252 PEER_FLAG_SEND_EXT_COMMUNITY);
57d187bc
JS
4253 if (strncmp (argv[idx_type]->arg, "l", 1) == 0)
4254 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
4255 bgp_node_safi (vty),
4256 PEER_FLAG_SEND_LARGE_COMMUNITY);
4257 if (strncmp (argv[idx_type]->arg, "b", 1) == 0)
4258 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
4259 bgp_node_safi (vty),
4260 PEER_FLAG_SEND_COMMUNITY |
4261 PEER_FLAG_SEND_EXT_COMMUNITY);
718e3744 4262
c500ae40 4263 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4264 bgp_node_safi (vty),
4265 (PEER_FLAG_SEND_COMMUNITY |
57d187bc
JS
4266 PEER_FLAG_SEND_EXT_COMMUNITY|
4267 PEER_FLAG_SEND_LARGE_COMMUNITY));
718e3744 4268}
6b0655a2 4269
596c17ba
DW
4270ALIAS_HIDDEN (no_neighbor_send_community_type,
4271 no_neighbor_send_community_type_hidden_cmd,
4272 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4273 NO_STR
4274 NEIGHBOR_STR
4275 NEIGHBOR_ADDR_STR2
4276 "Send Community attribute to this neighbor\n"
4277 "Send Standard and Extended Community attributes\n"
4278 "Send Standard, Large and Extended Community attributes\n"
4279 "Send Extended Community attributes\n"
4280 "Send Standard Community attributes\n"
4281 "Send Large Community attributes\n")
4282
718e3744 4283/* neighbor soft-reconfig. */
4284DEFUN (neighbor_soft_reconfiguration,
4285 neighbor_soft_reconfiguration_cmd,
9ccf14f7 4286 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
718e3744 4287 NEIGHBOR_STR
4288 NEIGHBOR_ADDR_STR2
4289 "Per neighbor soft reconfiguration\n"
4290 "Allow inbound soft reconfiguration for this neighbor\n")
4291{
c500ae40
DW
4292 int idx_peer = 1;
4293 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg,
718e3744 4294 bgp_node_afi (vty), bgp_node_safi (vty),
4295 PEER_FLAG_SOFT_RECONFIG);
4296}
4297
596c17ba
DW
4298ALIAS_HIDDEN (neighbor_soft_reconfiguration,
4299 neighbor_soft_reconfiguration_hidden_cmd,
4300 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4301 NEIGHBOR_STR
4302 NEIGHBOR_ADDR_STR2
4303 "Per neighbor soft reconfiguration\n"
4304 "Allow inbound soft reconfiguration for this neighbor\n")
4305
718e3744 4306DEFUN (no_neighbor_soft_reconfiguration,
4307 no_neighbor_soft_reconfiguration_cmd,
9ccf14f7 4308 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
718e3744 4309 NO_STR
4310 NEIGHBOR_STR
4311 NEIGHBOR_ADDR_STR2
4312 "Per neighbor soft reconfiguration\n"
4313 "Allow inbound soft reconfiguration for this neighbor\n")
4314{
c500ae40
DW
4315 int idx_peer = 2;
4316 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg,
718e3744 4317 bgp_node_afi (vty), bgp_node_safi (vty),
4318 PEER_FLAG_SOFT_RECONFIG);
4319}
6b0655a2 4320
596c17ba
DW
4321ALIAS_HIDDEN (no_neighbor_soft_reconfiguration,
4322 no_neighbor_soft_reconfiguration_hidden_cmd,
4323 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4324 NO_STR
4325 NEIGHBOR_STR
4326 NEIGHBOR_ADDR_STR2
4327 "Per neighbor soft reconfiguration\n"
4328 "Allow inbound soft reconfiguration for this neighbor\n")
4329
718e3744 4330DEFUN (neighbor_route_reflector_client,
4331 neighbor_route_reflector_client_cmd,
9ccf14f7 4332 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
718e3744 4333 NEIGHBOR_STR
4334 NEIGHBOR_ADDR_STR2
4335 "Configure a neighbor as Route Reflector client\n")
4336{
c500ae40 4337 int idx_peer = 1;
718e3744 4338 struct peer *peer;
4339
4340
c500ae40 4341 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 4342 if (! peer)
4343 return CMD_WARNING;
4344
c500ae40 4345 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4346 bgp_node_safi (vty),
4347 PEER_FLAG_REFLECTOR_CLIENT);
4348}
4349
596c17ba
DW
4350ALIAS_HIDDEN (neighbor_route_reflector_client,
4351 neighbor_route_reflector_client_hidden_cmd,
4352 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4353 NEIGHBOR_STR
4354 NEIGHBOR_ADDR_STR2
4355 "Configure a neighbor as Route Reflector client\n")
4356
718e3744 4357DEFUN (no_neighbor_route_reflector_client,
4358 no_neighbor_route_reflector_client_cmd,
9ccf14f7 4359 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
718e3744 4360 NO_STR
4361 NEIGHBOR_STR
4362 NEIGHBOR_ADDR_STR2
4363 "Configure a neighbor as Route Reflector client\n")
4364{
c500ae40
DW
4365 int idx_peer = 2;
4366 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4367 bgp_node_safi (vty),
4368 PEER_FLAG_REFLECTOR_CLIENT);
4369}
6b0655a2 4370
596c17ba
DW
4371ALIAS_HIDDEN (no_neighbor_route_reflector_client,
4372 no_neighbor_route_reflector_client_hidden_cmd,
4373 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4374 NO_STR
4375 NEIGHBOR_STR
4376 NEIGHBOR_ADDR_STR2
4377 "Configure a neighbor as Route Reflector client\n")
4378
718e3744 4379/* neighbor route-server-client. */
4380DEFUN (neighbor_route_server_client,
4381 neighbor_route_server_client_cmd,
9ccf14f7 4382 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
718e3744 4383 NEIGHBOR_STR
4384 NEIGHBOR_ADDR_STR2
4385 "Configure a neighbor as Route Server client\n")
4386{
c500ae40 4387 int idx_peer = 1;
2a3d5731
DW
4388 struct peer *peer;
4389
c500ae40 4390 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
2a3d5731
DW
4391 if (! peer)
4392 return CMD_WARNING;
c500ae40 4393 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
2a3d5731
DW
4394 bgp_node_safi (vty),
4395 PEER_FLAG_RSERVER_CLIENT);
718e3744 4396}
4397
596c17ba
DW
4398ALIAS_HIDDEN (neighbor_route_server_client,
4399 neighbor_route_server_client_hidden_cmd,
4400 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4401 NEIGHBOR_STR
4402 NEIGHBOR_ADDR_STR2
4403 "Configure a neighbor as Route Server client\n")
4404
718e3744 4405DEFUN (no_neighbor_route_server_client,
4406 no_neighbor_route_server_client_cmd,
9ccf14f7 4407 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
718e3744 4408 NO_STR
4409 NEIGHBOR_STR
4410 NEIGHBOR_ADDR_STR2
4411 "Configure a neighbor as Route Server client\n")
fee0f4c6 4412{
c500ae40
DW
4413 int idx_peer = 2;
4414 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
2a3d5731
DW
4415 bgp_node_safi (vty),
4416 PEER_FLAG_RSERVER_CLIENT);
fee0f4c6 4417}
6b0655a2 4418
596c17ba
DW
4419ALIAS_HIDDEN (no_neighbor_route_server_client,
4420 no_neighbor_route_server_client_hidden_cmd,
4421 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4422 NO_STR
4423 NEIGHBOR_STR
4424 NEIGHBOR_ADDR_STR2
4425 "Configure a neighbor as Route Server client\n")
4426
fee0f4c6 4427DEFUN (neighbor_nexthop_local_unchanged,
4428 neighbor_nexthop_local_unchanged_cmd,
9ccf14f7 4429 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
fee0f4c6 4430 NEIGHBOR_STR
4431 NEIGHBOR_ADDR_STR2
4432 "Configure treatment of outgoing link-local nexthop attribute\n"
4433 "Leave link-local nexthop unchanged for this peer\n")
4434{
c500ae40
DW
4435 int idx_peer = 1;
4436 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
fee0f4c6 4437 bgp_node_safi (vty),
4438 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
4439}
6b0655a2 4440
fee0f4c6 4441DEFUN (no_neighbor_nexthop_local_unchanged,
4442 no_neighbor_nexthop_local_unchanged_cmd,
9ccf14f7 4443 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
fee0f4c6 4444 NO_STR
4445 NEIGHBOR_STR
4446 NEIGHBOR_ADDR_STR2
4447 "Configure treatment of outgoing link-local-nexthop attribute\n"
4448 "Leave link-local nexthop unchanged for this peer\n")
718e3744 4449{
c500ae40
DW
4450 int idx_peer = 2;
4451 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4452 bgp_node_safi (vty),
fee0f4c6 4453 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED );
718e3744 4454}
6b0655a2 4455
718e3744 4456DEFUN (neighbor_attr_unchanged,
4457 neighbor_attr_unchanged_cmd,
1084263f
QY
4458 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\
4459 [<\
ddbaf941
QY
4460 as-path [<next-hop [med]|med [next-hop]>]|\
4461 next-hop [<as-path [med]|med [as-path]>]|\
4462 med [<as-path [next-hop]|next-hop [as-path]>]\
1084263f 4463 >]",
718e3744 4464 NEIGHBOR_STR
4465 NEIGHBOR_ADDR_STR2
4466 "BGP attribute is propagated unchanged to this neighbor\n"
4467 "As-path attribute\n"
4468 "Nexthop attribute\n"
40e718b5 4469 "Med attribute\n"
1084263f
QY
4470 "Med attribute\n"
4471 "Nexthop attribute\n"
4472 "Nexthop attribute\n"
4473 "As-path attribute\n"
4474 "Med attribute\n"
40e718b5 4475 "Med attribute\n"
718e3744 4476 "As-path attribute\n"
1084263f
QY
4477 "Med attribute\n"
4478 "As-path attribute\n"
4479 "Nexthop attribute\n"
40e718b5 4480 "Nexthop attribute\n"
1084263f 4481 "As-path attribute\n")
718e3744 4482{
40e718b5
QY
4483 int idx = 0;
4484 char *peer = argv[1]->arg;
4485 u_int16_t flags = 0;
718e3744 4486
40e718b5 4487 if (argv_find (argv, argc, "as-path", &idx))
718e3744 4488 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
40e718b5
QY
4489 idx = 0;
4490 if (argv_find (argv, argc, "next-hop", &idx))
4491 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4492 idx = 0;
4493 if (argv_find (argv, argc, "med", &idx))
718e3744 4494 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4495
40e718b5
QY
4496 if (!flags) // no flags means all of them!
4497 {
718e3744 4498 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
718e3744 4499 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
40e718b5
QY
4500 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4501 }
718e3744 4502
40e718b5 4503 return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags);
718e3744 4504}
4505
596c17ba
DW
4506ALIAS_HIDDEN (neighbor_attr_unchanged,
4507 neighbor_attr_unchanged_hidden_cmd,
4508 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\
4509 [<\
4510 as-path [<next-hop [med]|med [next-hop]>]|\
4511 next-hop [<as-path [med]|med [as-path]>]|\
4512 med [<as-path [next-hop]|next-hop [as-path]>]\
4513 >]",
4514 NEIGHBOR_STR
4515 NEIGHBOR_ADDR_STR2
4516 "BGP attribute is propagated unchanged to this neighbor\n"
4517 "As-path attribute\n"
4518 "Nexthop attribute\n"
4519 "Med attribute\n"
4520 "Med attribute\n"
4521 "Nexthop attribute\n"
4522 "Nexthop attribute\n"
4523 "As-path attribute\n"
4524 "Med attribute\n"
4525 "Med attribute\n"
4526 "As-path attribute\n"
4527 "Med attribute\n"
4528 "As-path attribute\n"
4529 "Nexthop attribute\n"
4530 "Nexthop attribute\n"
4531 "As-path attribute\n")
4532
718e3744 4533DEFUN (no_neighbor_attr_unchanged,
4534 no_neighbor_attr_unchanged_cmd,
1084263f
QY
4535 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\
4536 [<\
ddbaf941
QY
4537 as-path [<next-hop [med]|med [next-hop]>]|\
4538 next-hop [<as-path [med]|med [as-path]>]|\
4539 med [<as-path [next-hop]|next-hop [as-path]>]\
1084263f 4540 >]",
e52702f2 4541 NO_STR
718e3744 4542 NEIGHBOR_STR
4543 NEIGHBOR_ADDR_STR2
31500417
DW
4544 "BGP attribute is propagated unchanged to this neighbor\n"
4545 "As-path attribute\n"
40e718b5 4546 "Nexthop attribute\n"
31500417 4547 "Med attribute\n"
1084263f
QY
4548 "Med attribute\n"
4549 "Nexthop attribute\n"
4550 "Nexthop attribute\n"
4551 "As-path attribute\n"
4552 "Med attribute\n"
40e718b5 4553 "Med attribute\n"
718e3744 4554 "As-path attribute\n"
1084263f
QY
4555 "Med attribute\n"
4556 "As-path attribute\n"
4557 "Nexthop attribute\n"
718e3744 4558 "Nexthop attribute\n"
1084263f 4559 "As-path attribute\n")
718e3744 4560{
40e718b5
QY
4561 int idx = 0;
4562 char *peer = argv[2]->arg;
4563 u_int16_t flags = 0;
718e3744 4564
40e718b5 4565 if (argv_find (argv, argc, "as-path", &idx))
718e3744 4566 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
40e718b5
QY
4567 idx = 0;
4568 if (argv_find (argv, argc, "next-hop", &idx))
4569 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
4570 idx = 0;
4571 if (argv_find (argv, argc, "med", &idx))
718e3744 4572 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4573
40e718b5
QY
4574 if (!flags) // no flags means all of them!
4575 {
718e3744 4576 SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED);
718e3744 4577 SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED);
40e718b5
QY
4578 SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED);
4579 }
718e3744 4580
40e718b5 4581 return peer_af_flag_unset_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags);
718e3744 4582}
4583
596c17ba
DW
4584ALIAS_HIDDEN (no_neighbor_attr_unchanged,
4585 no_neighbor_attr_unchanged_hidden_cmd,
4586 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\
4587 [<\
4588 as-path [<next-hop [med]|med [next-hop]>]|\
4589 next-hop [<as-path [med]|med [as-path]>]|\
4590 med [<as-path [next-hop]|next-hop [as-path]>]\
4591 >]",
4592 NO_STR
4593 NEIGHBOR_STR
4594 NEIGHBOR_ADDR_STR2
4595 "BGP attribute is propagated unchanged to this neighbor\n"
4596 "As-path attribute\n"
4597 "Nexthop attribute\n"
4598 "Med attribute\n"
4599 "Med attribute\n"
4600 "Nexthop attribute\n"
4601 "Nexthop attribute\n"
4602 "As-path attribute\n"
4603 "Med attribute\n"
4604 "Med attribute\n"
4605 "As-path attribute\n"
4606 "Med attribute\n"
4607 "As-path attribute\n"
4608 "Nexthop attribute\n"
4609 "Nexthop attribute\n"
4610 "As-path attribute\n")
4611
718e3744 4612
718e3744 4613/* EBGP multihop configuration. */
94f2b392 4614static int
e52702f2 4615peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str,
fd79ac91 4616 const char *ttl_str)
718e3744 4617{
4618 struct peer *peer;
fd79ac91 4619 unsigned int ttl;
718e3744 4620
4621 peer = peer_and_group_lookup_vty (vty, ip_str);
4622 if (! peer)
4623 return CMD_WARNING;
4624
63fa10b5
QY
4625 if (peer->conf_if)
4626 return bgp_vty_return (vty, BGP_ERR_INVALID_FOR_DIRECT_PEER);
4627
718e3744 4628 if (! ttl_str)
9b1be336 4629 ttl = MAXTTL;
718e3744 4630 else
9b1be336 4631 VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, MAXTTL);
718e3744 4632
89b6d1f8 4633 return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl));
718e3744 4634}
4635
94f2b392 4636static int
e52702f2 4637peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str)
718e3744 4638{
4639 struct peer *peer;
4640
4641 peer = peer_and_group_lookup_vty (vty, ip_str);
4642 if (! peer)
4643 return CMD_WARNING;
4644
89b6d1f8 4645 return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer));
718e3744 4646}
4647
4648/* neighbor ebgp-multihop. */
4649DEFUN (neighbor_ebgp_multihop,
4650 neighbor_ebgp_multihop_cmd,
9ccf14f7 4651 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
718e3744 4652 NEIGHBOR_STR
4653 NEIGHBOR_ADDR_STR2
4654 "Allow EBGP neighbors not on directly connected networks\n")
4655{
c500ae40
DW
4656 int idx_peer = 1;
4657 return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, NULL);
718e3744 4658}
4659
4660DEFUN (neighbor_ebgp_multihop_ttl,
4661 neighbor_ebgp_multihop_ttl_cmd,
9ccf14f7 4662 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
718e3744 4663 NEIGHBOR_STR
4664 NEIGHBOR_ADDR_STR2
4665 "Allow EBGP neighbors not on directly connected networks\n"
4666 "maximum hop count\n")
4667{
c500ae40
DW
4668 int idx_peer = 1;
4669 int idx_number = 3;
4670 return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg);
718e3744 4671}
4672
4673DEFUN (no_neighbor_ebgp_multihop,
4674 no_neighbor_ebgp_multihop_cmd,
a636c635 4675 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
718e3744 4676 NO_STR
4677 NEIGHBOR_STR
4678 NEIGHBOR_ADDR_STR2
a636c635
DW
4679 "Allow EBGP neighbors not on directly connected networks\n"
4680 "maximum hop count\n")
718e3744 4681{
c500ae40
DW
4682 int idx_peer = 2;
4683 return peer_ebgp_multihop_unset_vty (vty, argv[idx_peer]->arg);
718e3744 4684}
4685
6b0655a2 4686
6ffd2079 4687/* disable-connected-check */
4688DEFUN (neighbor_disable_connected_check,
4689 neighbor_disable_connected_check_cmd,
a636c635 4690 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6ffd2079 4691 NEIGHBOR_STR
4692 NEIGHBOR_ADDR_STR2
a636c635
DW
4693 "one-hop away EBGP peer using loopback address\n"
4694 "Enforce EBGP neighbors perform multihop\n")
6ffd2079 4695{
c500ae40
DW
4696 int idx_peer = 1;
4697 return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK);
6ffd2079 4698}
4699
4700DEFUN (no_neighbor_disable_connected_check,
4701 no_neighbor_disable_connected_check_cmd,
a636c635 4702 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6ffd2079 4703 NO_STR
4704 NEIGHBOR_STR
4705 NEIGHBOR_ADDR_STR2
a636c635
DW
4706 "one-hop away EBGP peer using loopback address\n"
4707 "Enforce EBGP neighbors perform multihop\n")
6ffd2079 4708{
c500ae40
DW
4709 int idx_peer = 2;
4710 return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK);
6ffd2079 4711}
4712
718e3744 4713DEFUN (neighbor_description,
4714 neighbor_description_cmd,
e961923c 4715 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
718e3744 4716 NEIGHBOR_STR
4717 NEIGHBOR_ADDR_STR2
4718 "Neighbor specific description\n"
4719 "Up to 80 characters describing this neighbor\n")
4720{
c500ae40 4721 int idx_peer = 1;
58749582 4722 int idx_line = 3;
718e3744 4723 struct peer *peer;
718e3744 4724 char *str;
718e3744 4725
c500ae40 4726 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 4727 if (! peer)
4728 return CMD_WARNING;
4729
58749582 4730 str = argv_concat(argv, argc, idx_line);
718e3744 4731
4732 peer_description_set (peer, str);
4733
3b8b1855 4734 XFREE (MTYPE_TMP, str);
718e3744 4735
4736 return CMD_SUCCESS;
4737}
4738
4739DEFUN (no_neighbor_description,
4740 no_neighbor_description_cmd,
a636c635 4741 "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]",
718e3744 4742 NO_STR
4743 NEIGHBOR_STR
4744 NEIGHBOR_ADDR_STR2
a636c635
DW
4745 "Neighbor specific description\n"
4746 "Up to 80 characters describing this neighbor\n")
718e3744 4747{
c500ae40 4748 int idx_peer = 2;
718e3744 4749 struct peer *peer;
4750
c500ae40 4751 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 4752 if (! peer)
4753 return CMD_WARNING;
4754
4755 peer_description_unset (peer);
4756
4757 return CMD_SUCCESS;
4758}
4759
6b0655a2 4760
718e3744 4761/* Neighbor update-source. */
94f2b392 4762static int
e52702f2 4763peer_update_source_vty (struct vty *vty, const char *peer_str,
fd79ac91 4764 const char *source_str)
718e3744 4765{
4766 struct peer *peer;
3b69fd51 4767 struct prefix p;
718e3744 4768
4769 peer = peer_and_group_lookup_vty (vty, peer_str);
4770 if (! peer)
4771 return CMD_WARNING;
4772
a80beece
DS
4773 if (peer->conf_if)
4774 return CMD_WARNING;
4775
718e3744 4776 if (source_str)
4777 {
c63b83fe
JBD
4778 union sockunion su;
4779 int ret = str2sockunion (source_str, &su);
4780
4781 if (ret == 0)
4782 peer_update_source_addr_set (peer, &su);
718e3744 4783 else
3b69fd51
DS
4784 {
4785 if (str2prefix (source_str, &p))
4786 {
4787 vty_out (vty, "%% Invalid update-source, remove prefix length %s",
4788 VTY_NEWLINE);
4789 return CMD_WARNING;
4790 }
4791 else
4792 peer_update_source_if_set (peer, source_str);
4793 }
718e3744 4794 }
4795 else
4796 peer_update_source_unset (peer);
4797
4798 return CMD_SUCCESS;
4799}
4800
369688c0
PJ
4801#define BGP_UPDATE_SOURCE_HELP_STR \
4802 "IPv4 address\n" \
9a1a331d
PJ
4803 "IPv6 address\n" \
4804 "Interface name (requires zebra to be running)\n"
369688c0 4805
718e3744 4806DEFUN (neighbor_update_source,
4807 neighbor_update_source_cmd,
9ccf14f7 4808 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
718e3744 4809 NEIGHBOR_STR
4810 NEIGHBOR_ADDR_STR2
4811 "Source of routing updates\n"
369688c0 4812 BGP_UPDATE_SOURCE_HELP_STR)
718e3744 4813{
c500ae40
DW
4814 int idx_peer = 1;
4815 int idx_peer_2 = 3;
4816 return peer_update_source_vty (vty, argv[idx_peer]->arg, argv[idx_peer_2]->arg);
718e3744 4817}
4818
4819DEFUN (no_neighbor_update_source,
4820 no_neighbor_update_source_cmd,
c7178fe7 4821 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
718e3744 4822 NO_STR
4823 NEIGHBOR_STR
4824 NEIGHBOR_ADDR_STR2
dcb52bd5
DS
4825 "Source of routing updates\n"
4826 BGP_UPDATE_SOURCE_HELP_STR)
718e3744 4827{
c500ae40
DW
4828 int idx_peer = 2;
4829 return peer_update_source_vty (vty, argv[idx_peer]->arg, NULL);
718e3744 4830}
6b0655a2 4831
94f2b392 4832static int
e52702f2
QY
4833peer_default_originate_set_vty (struct vty *vty, const char *peer_str,
4834 afi_t afi, safi_t safi,
fd79ac91 4835 const char *rmap, int set)
718e3744 4836{
4837 int ret;
4838 struct peer *peer;
4839
4840 peer = peer_and_group_lookup_vty (vty, peer_str);
4841 if (! peer)
4842 return CMD_WARNING;
4843
4844 if (set)
4845 ret = peer_default_originate_set (peer, afi, safi, rmap);
4846 else
4847 ret = peer_default_originate_unset (peer, afi, safi);
4848
4849 return bgp_vty_return (vty, ret);
4850}
4851
4852/* neighbor default-originate. */
4853DEFUN (neighbor_default_originate,
4854 neighbor_default_originate_cmd,
9ccf14f7 4855 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
718e3744 4856 NEIGHBOR_STR
4857 NEIGHBOR_ADDR_STR2
4858 "Originate default route to this neighbor\n")
4859{
c500ae40
DW
4860 int idx_peer = 1;
4861 return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4862 bgp_node_safi (vty), NULL, 1);
4863}
4864
596c17ba
DW
4865ALIAS_HIDDEN (neighbor_default_originate,
4866 neighbor_default_originate_hidden_cmd,
4867 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4868 NEIGHBOR_STR
4869 NEIGHBOR_ADDR_STR2
4870 "Originate default route to this neighbor\n")
4871
718e3744 4872DEFUN (neighbor_default_originate_rmap,
4873 neighbor_default_originate_rmap_cmd,
9ccf14f7 4874 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
718e3744 4875 NEIGHBOR_STR
4876 NEIGHBOR_ADDR_STR2
4877 "Originate default route to this neighbor\n"
4878 "Route-map to specify criteria to originate default\n"
4879 "route-map name\n")
4880{
c500ae40
DW
4881 int idx_peer = 1;
4882 int idx_word = 4;
4883 return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
4884 bgp_node_safi (vty), argv[idx_word]->arg, 1);
718e3744 4885}
4886
596c17ba
DW
4887ALIAS_HIDDEN (neighbor_default_originate_rmap,
4888 neighbor_default_originate_rmap_hidden_cmd,
4889 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4890 NEIGHBOR_STR
4891 NEIGHBOR_ADDR_STR2
4892 "Originate default route to this neighbor\n"
4893 "Route-map to specify criteria to originate default\n"
4894 "route-map name\n")
4895
718e3744 4896DEFUN (no_neighbor_default_originate,
4897 no_neighbor_default_originate_cmd,
a636c635 4898 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
718e3744 4899 NO_STR
4900 NEIGHBOR_STR
4901 NEIGHBOR_ADDR_STR2
a636c635
DW
4902 "Originate default route to this neighbor\n"
4903 "Route-map to specify criteria to originate default\n"
4904 "route-map name\n")
718e3744 4905{
c500ae40
DW
4906 int idx_peer = 2;
4907 return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 4908 bgp_node_safi (vty), NULL, 0);
4909}
4910
596c17ba
DW
4911ALIAS_HIDDEN (no_neighbor_default_originate,
4912 no_neighbor_default_originate_hidden_cmd,
4913 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4914 NO_STR
4915 NEIGHBOR_STR
4916 NEIGHBOR_ADDR_STR2
4917 "Originate default route to this neighbor\n"
4918 "Route-map to specify criteria to originate default\n"
4919 "route-map name\n")
4920
6b0655a2 4921
718e3744 4922/* Set neighbor's BGP port. */
94f2b392 4923static int
e52702f2 4924peer_port_vty (struct vty *vty, const char *ip_str, int afi,
fd79ac91 4925 const char *port_str)
718e3744 4926{
4927 struct peer *peer;
4928 u_int16_t port;
4929 struct servent *sp;
4930
4931 peer = peer_lookup_vty (vty, ip_str);
4932 if (! peer)
4933 return CMD_WARNING;
4934
4935 if (! port_str)
e52702f2 4936 {
718e3744 4937 sp = getservbyname ("bgp", "tcp");
4938 port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port);
4939 }
4940 else
4941 {
4942 VTY_GET_INTEGER("port", port, port_str);
4943 }
4944
4945 peer_port_set (peer, port);
4946
4947 return CMD_SUCCESS;
4948}
4949
f418446b 4950/* Set specified peer's BGP port. */
718e3744 4951DEFUN (neighbor_port,
4952 neighbor_port_cmd,
9ccf14f7 4953 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
718e3744 4954 NEIGHBOR_STR
4955 NEIGHBOR_ADDR_STR
4956 "Neighbor's BGP port\n"
4957 "TCP port number\n")
4958{
c500ae40
DW
4959 int idx_ip = 1;
4960 int idx_number = 3;
4961 return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, argv[idx_number]->arg);
718e3744 4962}
4963
4964DEFUN (no_neighbor_port,
4965 no_neighbor_port_cmd,
9ccf14f7 4966 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
718e3744 4967 NO_STR
4968 NEIGHBOR_STR
4969 NEIGHBOR_ADDR_STR
8334fd5a
DW
4970 "Neighbor's BGP port\n"
4971 "TCP port number\n")
718e3744 4972{
c500ae40
DW
4973 int idx_ip = 2;
4974 return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, NULL);
718e3744 4975}
4976
6b0655a2 4977
718e3744 4978/* neighbor weight. */
94f2b392 4979static int
e52702f2 4980peer_weight_set_vty (struct vty *vty, const char *ip_str,
d93f7ffc 4981 afi_t afi, safi_t safi,
fd79ac91 4982 const char *weight_str)
718e3744 4983{
1f9a9fff 4984 int ret;
718e3744 4985 struct peer *peer;
4986 unsigned long weight;
4987
4988 peer = peer_and_group_lookup_vty (vty, ip_str);
4989 if (! peer)
4990 return CMD_WARNING;
4991
4992 VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535);
4993
d93f7ffc 4994 ret = peer_weight_set (peer, afi, safi, weight);
1f9a9fff 4995 return bgp_vty_return (vty, ret);
718e3744 4996}
4997
94f2b392 4998static int
d93f7ffc
DW
4999peer_weight_unset_vty (struct vty *vty, const char *ip_str,
5000 afi_t afi, safi_t safi)
718e3744 5001{
1f9a9fff 5002 int ret;
718e3744 5003 struct peer *peer;
5004
5005 peer = peer_and_group_lookup_vty (vty, ip_str);
5006 if (! peer)
5007 return CMD_WARNING;
5008
d93f7ffc 5009 ret = peer_weight_unset (peer, afi, safi);
1f9a9fff 5010 return bgp_vty_return (vty, ret);
718e3744 5011}
5012
5013DEFUN (neighbor_weight,
5014 neighbor_weight_cmd,
9ccf14f7 5015 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
718e3744 5016 NEIGHBOR_STR
5017 NEIGHBOR_ADDR_STR2
5018 "Set default weight for routes from this neighbor\n"
5019 "default weight\n")
5020{
c500ae40
DW
5021 int idx_peer = 1;
5022 int idx_number = 3;
e52702f2
QY
5023 return peer_weight_set_vty (vty,
5024 argv[idx_peer]->arg,
5025 bgp_node_afi (vty),
5026 bgp_node_safi (vty),
5027 argv[idx_number]->arg);
718e3744 5028}
5029
596c17ba
DW
5030ALIAS_HIDDEN (neighbor_weight,
5031 neighbor_weight_hidden_cmd,
5032 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5033 NEIGHBOR_STR
5034 NEIGHBOR_ADDR_STR2
5035 "Set default weight for routes from this neighbor\n"
5036 "default weight\n")
5037
718e3744 5038DEFUN (no_neighbor_weight,
5039 no_neighbor_weight_cmd,
9ccf14f7 5040 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
718e3744 5041 NO_STR
5042 NEIGHBOR_STR
5043 NEIGHBOR_ADDR_STR2
8334fd5a
DW
5044 "Set default weight for routes from this neighbor\n"
5045 "default weight\n")
718e3744 5046{
c500ae40 5047 int idx_peer = 2;
e52702f2 5048 return peer_weight_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty));
718e3744 5049}
5050
596c17ba
DW
5051ALIAS_HIDDEN (no_neighbor_weight,
5052 no_neighbor_weight_hidden_cmd,
5053 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5054 NO_STR
5055 NEIGHBOR_STR
5056 NEIGHBOR_ADDR_STR2
5057 "Set default weight for routes from this neighbor\n"
5058 "default weight\n")
5059
6b0655a2 5060
718e3744 5061/* Override capability negotiation. */
5062DEFUN (neighbor_override_capability,
5063 neighbor_override_capability_cmd,
9ccf14f7 5064 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
718e3744 5065 NEIGHBOR_STR
5066 NEIGHBOR_ADDR_STR2
5067 "Override capability negotiation result\n")
5068{
c500ae40
DW
5069 int idx_peer = 1;
5070 return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY);
718e3744 5071}
5072
5073DEFUN (no_neighbor_override_capability,
5074 no_neighbor_override_capability_cmd,
9ccf14f7 5075 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
718e3744 5076 NO_STR
5077 NEIGHBOR_STR
5078 NEIGHBOR_ADDR_STR2
5079 "Override capability negotiation result\n")
5080{
c500ae40
DW
5081 int idx_peer = 2;
5082 return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY);
718e3744 5083}
6b0655a2 5084
718e3744 5085DEFUN (neighbor_strict_capability,
5086 neighbor_strict_capability_cmd,
9ccf14f7 5087 "neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
718e3744 5088 NEIGHBOR_STR
5089 NEIGHBOR_ADDR_STR
5090 "Strict capability negotiation match\n")
5091{
c500ae40
DW
5092 int idx_ip = 1;
5093 return peer_flag_set_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH);
718e3744 5094}
5095
5096DEFUN (no_neighbor_strict_capability,
5097 no_neighbor_strict_capability_cmd,
9ccf14f7 5098 "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
718e3744 5099 NO_STR
5100 NEIGHBOR_STR
5101 NEIGHBOR_ADDR_STR
5102 "Strict capability negotiation match\n")
5103{
c500ae40
DW
5104 int idx_ip = 2;
5105 return peer_flag_unset_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH);
718e3744 5106}
6b0655a2 5107
94f2b392 5108static int
e52702f2 5109peer_timers_set_vty (struct vty *vty, const char *ip_str,
fd79ac91 5110 const char *keep_str, const char *hold_str)
718e3744 5111{
5112 int ret;
5113 struct peer *peer;
5114 u_int32_t keepalive;
5115 u_int32_t holdtime;
5116
5117 peer = peer_and_group_lookup_vty (vty, ip_str);
5118 if (! peer)
5119 return CMD_WARNING;
5120
5121 VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535);
5122 VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535);
5123
5124 ret = peer_timers_set (peer, keepalive, holdtime);
5125
5126 return bgp_vty_return (vty, ret);
5127}
6b0655a2 5128
94f2b392 5129static int
fd79ac91 5130peer_timers_unset_vty (struct vty *vty, const char *ip_str)
718e3744 5131{
5132 int ret;
5133 struct peer *peer;
5134
0c412461 5135 peer = peer_and_group_lookup_vty (vty, ip_str);
718e3744 5136 if (! peer)
5137 return CMD_WARNING;
5138
5139 ret = peer_timers_unset (peer);
5140
5141 return bgp_vty_return (vty, ret);
5142}
5143
5144DEFUN (neighbor_timers,
5145 neighbor_timers_cmd,
9ccf14f7 5146 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
718e3744 5147 NEIGHBOR_STR
5148 NEIGHBOR_ADDR_STR2
5149 "BGP per neighbor timers\n"
5150 "Keepalive interval\n"
5151 "Holdtime\n")
5152{
c500ae40
DW
5153 int idx_peer = 1;
5154 int idx_number = 3;
5155 int idx_number_2 = 4;
5156 return peer_timers_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg);
718e3744 5157}
5158
5159DEFUN (no_neighbor_timers,
5160 no_neighbor_timers_cmd,
9ccf14f7 5161 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
718e3744 5162 NO_STR
5163 NEIGHBOR_STR
5164 NEIGHBOR_ADDR_STR2
8334fd5a
DW
5165 "BGP per neighbor timers\n"
5166 "Keepalive interval\n"
5167 "Holdtime\n")
718e3744 5168{
c500ae40
DW
5169 int idx_peer = 2;
5170 return peer_timers_unset_vty (vty, argv[idx_peer]->arg);
718e3744 5171}
6b0655a2 5172
813d4307 5173
94f2b392 5174static int
e52702f2 5175peer_timers_connect_set_vty (struct vty *vty, const char *ip_str,
fd79ac91 5176 const char *time_str)
718e3744 5177{
5178 int ret;
5179 struct peer *peer;
5180 u_int32_t connect;
5181
966f821c 5182 peer = peer_and_group_lookup_vty (vty, ip_str);
718e3744 5183 if (! peer)
5184 return CMD_WARNING;
5185
5186 VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535);
5187
5188 ret = peer_timers_connect_set (peer, connect);
5189
966f821c 5190 return bgp_vty_return (vty, ret);
718e3744 5191}
5192
94f2b392 5193static int
fd79ac91 5194peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str)
718e3744 5195{
5196 int ret;
5197 struct peer *peer;
5198
5199 peer = peer_and_group_lookup_vty (vty, ip_str);
5200 if (! peer)
5201 return CMD_WARNING;
5202
5203 ret = peer_timers_connect_unset (peer);
5204
966f821c 5205 return bgp_vty_return (vty, ret);
718e3744 5206}
5207
5208DEFUN (neighbor_timers_connect,
5209 neighbor_timers_connect_cmd,
9ccf14f7 5210 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
718e3744 5211 NEIGHBOR_STR
966f821c 5212 NEIGHBOR_ADDR_STR2
718e3744 5213 "BGP per neighbor timers\n"
5214 "BGP connect timer\n"
5215 "Connect timer\n")
5216{
c500ae40
DW
5217 int idx_peer = 1;
5218 int idx_number = 4;
5219 return peer_timers_connect_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg);
718e3744 5220}
5221
5222DEFUN (no_neighbor_timers_connect,
5223 no_neighbor_timers_connect_cmd,
9ccf14f7 5224 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
718e3744 5225 NO_STR
5226 NEIGHBOR_STR
966f821c 5227 NEIGHBOR_ADDR_STR2
718e3744 5228 "BGP per neighbor timers\n"
8334fd5a
DW
5229 "BGP connect timer\n"
5230 "Connect timer\n")
718e3744 5231{
c500ae40
DW
5232 int idx_peer = 2;
5233 return peer_timers_connect_unset_vty (vty, argv[idx_peer]->arg);
718e3744 5234}
5235
6b0655a2 5236
94f2b392 5237static int
e52702f2
QY
5238peer_advertise_interval_vty (struct vty *vty, const char *ip_str,
5239 const char *time_str, int set)
718e3744 5240{
5241 int ret;
5242 struct peer *peer;
5243 u_int32_t routeadv = 0;
5244
966f821c 5245 peer = peer_and_group_lookup_vty (vty, ip_str);
718e3744 5246 if (! peer)
5247 return CMD_WARNING;
5248
5249 if (time_str)
5250 VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600);
5251
5252 if (set)
5253 ret = peer_advertise_interval_set (peer, routeadv);
5254 else
5255 ret = peer_advertise_interval_unset (peer);
5256
966f821c 5257 return bgp_vty_return (vty, ret);
718e3744 5258}
5259
5260DEFUN (neighbor_advertise_interval,
5261 neighbor_advertise_interval_cmd,
9ccf14f7 5262 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
718e3744 5263 NEIGHBOR_STR
966f821c 5264 NEIGHBOR_ADDR_STR2
718e3744 5265 "Minimum interval between sending BGP routing updates\n"
5266 "time in seconds\n")
5267{
c500ae40
DW
5268 int idx_peer = 1;
5269 int idx_number = 3;
5270 return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, 1);
718e3744 5271}
5272
5273DEFUN (no_neighbor_advertise_interval,
5274 no_neighbor_advertise_interval_cmd,
9ccf14f7 5275 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
718e3744 5276 NO_STR
5277 NEIGHBOR_STR
966f821c 5278 NEIGHBOR_ADDR_STR2
8334fd5a
DW
5279 "Minimum interval between sending BGP routing updates\n"
5280 "time in seconds\n")
718e3744 5281{
c500ae40
DW
5282 int idx_peer = 2;
5283 return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, NULL, 0);
718e3744 5284}
5285
6b0655a2 5286
518f0eb1
DS
5287/* Time to wait before processing route-map updates */
5288DEFUN (bgp_set_route_map_delay_timer,
5289 bgp_set_route_map_delay_timer_cmd,
6147e2c6 5290 "bgp route-map delay-timer (0-600)",
518f0eb1
DS
5291 SET_STR
5292 "BGP route-map delay timer\n"
5293 "Time in secs to wait before processing route-map changes\n"
f414725f 5294 "0 disables the timer, no route updates happen when route-maps change\n")
518f0eb1 5295{
c500ae40 5296 int idx_number = 3;
518f0eb1 5297 u_int32_t rmap_delay_timer;
518f0eb1 5298
c500ae40 5299 if (argv[idx_number]->arg)
518f0eb1 5300 {
c500ae40 5301 VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[idx_number]->arg, 0, 600);
5fe9f963 5302 bm->rmap_update_timer = rmap_delay_timer;
518f0eb1
DS
5303
5304 /* if the dynamic update handling is being disabled, and a timer is
5305 * running, stop the timer and act as if the timer has already fired.
5306 */
5fe9f963 5307 if (!rmap_delay_timer && bm->t_rmap_update )
518f0eb1 5308 {
5fe9f963 5309 BGP_TIMER_OFF(bm->t_rmap_update);
5310 thread_execute (bm->master, bgp_route_map_update_timer, NULL, 0);
518f0eb1
DS
5311 }
5312 return CMD_SUCCESS;
5313 }
5314 else
ffd0c037 5315 return CMD_WARNING;
518f0eb1
DS
5316}
5317
5318DEFUN (no_bgp_set_route_map_delay_timer,
5319 no_bgp_set_route_map_delay_timer_cmd,
8334fd5a 5320 "no bgp route-map delay-timer [(0-600)]",
518f0eb1 5321 NO_STR
3a2d747c 5322 BGP_STR
518f0eb1 5323 "Default BGP route-map delay timer\n"
8334fd5a
DW
5324 "Reset to default time to wait for processing route-map changes\n"
5325 "0 disables the timer, no route updates happen when route-maps change\n")
518f0eb1 5326{
518f0eb1 5327
5fe9f963 5328 bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER;
518f0eb1
DS
5329
5330 return CMD_SUCCESS;
5331}
5332
f414725f 5333
718e3744 5334/* neighbor interface */
94f2b392 5335static int
fd79ac91 5336peer_interface_vty (struct vty *vty, const char *ip_str, const char *str)
718e3744 5337{
718e3744 5338 struct peer *peer;
5339
5340 peer = peer_lookup_vty (vty, ip_str);
a80beece 5341 if (! peer || peer->conf_if)
718e3744 5342 return CMD_WARNING;
5343
5344 if (str)
ffd0c037 5345 peer_interface_set (peer, str);
718e3744 5346 else
ffd0c037 5347 peer_interface_unset (peer);
718e3744 5348
5349 return CMD_SUCCESS;
5350}
5351
5352DEFUN (neighbor_interface,
5353 neighbor_interface_cmd,
9ccf14f7 5354 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
718e3744 5355 NEIGHBOR_STR
5356 NEIGHBOR_ADDR_STR
5357 "Interface\n"
5358 "Interface name\n")
5359{
c500ae40
DW
5360 int idx_ip = 1;
5361 int idx_word = 3;
00d7d2d3 5362 return peer_interface_vty (vty, argv[idx_ip]->arg, argv[idx_word]->arg);
718e3744 5363}
5364
5365DEFUN (no_neighbor_interface,
5366 no_neighbor_interface_cmd,
9ccf14f7 5367 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
718e3744 5368 NO_STR
5369 NEIGHBOR_STR
16cedbb0 5370 NEIGHBOR_ADDR_STR2
718e3744 5371 "Interface\n"
5372 "Interface name\n")
5373{
c500ae40
DW
5374 int idx_peer = 2;
5375 return peer_interface_vty (vty, argv[idx_peer]->arg, NULL);
718e3744 5376}
6b0655a2 5377
718e3744 5378/* Set distribute list to the peer. */
94f2b392 5379static int
e52702f2 5380peer_distribute_set_vty (struct vty *vty, const char *ip_str,
fd79ac91 5381 afi_t afi, safi_t safi,
5382 const char *name_str, const char *direct_str)
718e3744 5383{
5384 int ret;
5385 struct peer *peer;
5386 int direct = FILTER_IN;
5387
5388 peer = peer_and_group_lookup_vty (vty, ip_str);
5389 if (! peer)
5390 return CMD_WARNING;
5391
5392 /* Check filter direction. */
5393 if (strncmp (direct_str, "i", 1) == 0)
5394 direct = FILTER_IN;
5395 else if (strncmp (direct_str, "o", 1) == 0)
5396 direct = FILTER_OUT;
5397
5398 ret = peer_distribute_set (peer, afi, safi, direct, name_str);
5399
5400 return bgp_vty_return (vty, ret);
5401}
5402
94f2b392 5403static int
fd79ac91 5404peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5405 safi_t safi, const char *direct_str)
718e3744 5406{
5407 int ret;
5408 struct peer *peer;
5409 int direct = FILTER_IN;
5410
5411 peer = peer_and_group_lookup_vty (vty, ip_str);
5412 if (! peer)
5413 return CMD_WARNING;
5414
5415 /* Check filter direction. */
5416 if (strncmp (direct_str, "i", 1) == 0)
5417 direct = FILTER_IN;
5418 else if (strncmp (direct_str, "o", 1) == 0)
5419 direct = FILTER_OUT;
5420
5421 ret = peer_distribute_unset (peer, afi, safi, direct);
5422
5423 return bgp_vty_return (vty, ret);
5424}
5425
5426DEFUN (neighbor_distribute_list,
5427 neighbor_distribute_list_cmd,
9ccf14f7 5428 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
718e3744 5429 NEIGHBOR_STR
5430 NEIGHBOR_ADDR_STR2
5431 "Filter updates to/from this neighbor\n"
5432 "IP access-list number\n"
5433 "IP access-list number (expanded range)\n"
5434 "IP Access-list name\n"
5435 "Filter incoming updates\n"
5436 "Filter outgoing updates\n")
5437{
c500ae40
DW
5438 int idx_peer = 1;
5439 int idx_acl = 3;
5440 int idx_in_out = 4;
5441 return peer_distribute_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5442 bgp_node_safi (vty), argv[idx_acl]->arg, argv[idx_in_out]->arg);
718e3744 5443}
5444
596c17ba
DW
5445ALIAS_HIDDEN (neighbor_distribute_list,
5446 neighbor_distribute_list_hidden_cmd,
5447 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5448 NEIGHBOR_STR
5449 NEIGHBOR_ADDR_STR2
5450 "Filter updates to/from this neighbor\n"
5451 "IP access-list number\n"
5452 "IP access-list number (expanded range)\n"
5453 "IP Access-list name\n"
5454 "Filter incoming updates\n"
5455 "Filter outgoing updates\n")
5456
718e3744 5457DEFUN (no_neighbor_distribute_list,
5458 no_neighbor_distribute_list_cmd,
9ccf14f7 5459 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
718e3744 5460 NO_STR
5461 NEIGHBOR_STR
5462 NEIGHBOR_ADDR_STR2
5463 "Filter updates to/from this neighbor\n"
5464 "IP access-list number\n"
5465 "IP access-list number (expanded range)\n"
5466 "IP Access-list name\n"
5467 "Filter incoming updates\n"
5468 "Filter outgoing updates\n")
5469{
c500ae40
DW
5470 int idx_peer = 2;
5471 int idx_in_out = 5;
5472 return peer_distribute_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5473 bgp_node_safi (vty), argv[idx_in_out]->arg);
718e3744 5474}
6b0655a2 5475
596c17ba
DW
5476ALIAS_HIDDEN (no_neighbor_distribute_list,
5477 no_neighbor_distribute_list_hidden_cmd,
5478 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5479 NO_STR
5480 NEIGHBOR_STR
5481 NEIGHBOR_ADDR_STR2
5482 "Filter updates to/from this neighbor\n"
5483 "IP access-list number\n"
5484 "IP access-list number (expanded range)\n"
5485 "IP Access-list name\n"
5486 "Filter incoming updates\n"
5487 "Filter outgoing updates\n")
5488
718e3744 5489/* Set prefix list to the peer. */
94f2b392 5490static int
fd79ac91 5491peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
e52702f2 5492 safi_t safi, const char *name_str,
fd79ac91 5493 const char *direct_str)
718e3744 5494{
5495 int ret;
5496 struct peer *peer;
5497 int direct = FILTER_IN;
5498
5499 peer = peer_and_group_lookup_vty (vty, ip_str);
5500 if (! peer)
5501 return CMD_WARNING;
5502
5503 /* Check filter direction. */
5504 if (strncmp (direct_str, "i", 1) == 0)
5505 direct = FILTER_IN;
5506 else if (strncmp (direct_str, "o", 1) == 0)
5507 direct = FILTER_OUT;
5508
5509 ret = peer_prefix_list_set (peer, afi, safi, direct, name_str);
5510
5511 return bgp_vty_return (vty, ret);
5512}
5513
94f2b392 5514static int
fd79ac91 5515peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5516 safi_t safi, const char *direct_str)
718e3744 5517{
5518 int ret;
5519 struct peer *peer;
5520 int direct = FILTER_IN;
5521
5522 peer = peer_and_group_lookup_vty (vty, ip_str);
5523 if (! peer)
5524 return CMD_WARNING;
e52702f2 5525
718e3744 5526 /* Check filter direction. */
5527 if (strncmp (direct_str, "i", 1) == 0)
5528 direct = FILTER_IN;
5529 else if (strncmp (direct_str, "o", 1) == 0)
5530 direct = FILTER_OUT;
5531
5532 ret = peer_prefix_list_unset (peer, afi, safi, direct);
5533
5534 return bgp_vty_return (vty, ret);
5535}
5536
5537DEFUN (neighbor_prefix_list,
5538 neighbor_prefix_list_cmd,
9ccf14f7 5539 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
718e3744 5540 NEIGHBOR_STR
5541 NEIGHBOR_ADDR_STR2
5542 "Filter updates to/from this neighbor\n"
5543 "Name of a prefix list\n"
5544 "Filter incoming updates\n"
5545 "Filter outgoing updates\n")
5546{
c500ae40
DW
5547 int idx_peer = 1;
5548 int idx_word = 3;
5549 int idx_in_out = 4;
5550 return peer_prefix_list_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5551 bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg);
718e3744 5552}
5553
596c17ba
DW
5554ALIAS_HIDDEN (neighbor_prefix_list,
5555 neighbor_prefix_list_hidden_cmd,
5556 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5557 NEIGHBOR_STR
5558 NEIGHBOR_ADDR_STR2
5559 "Filter updates to/from this neighbor\n"
5560 "Name of a prefix list\n"
5561 "Filter incoming updates\n"
5562 "Filter outgoing updates\n")
5563
718e3744 5564DEFUN (no_neighbor_prefix_list,
5565 no_neighbor_prefix_list_cmd,
9ccf14f7 5566 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
718e3744 5567 NO_STR
5568 NEIGHBOR_STR
5569 NEIGHBOR_ADDR_STR2
5570 "Filter updates to/from this neighbor\n"
5571 "Name of a prefix list\n"
5572 "Filter incoming updates\n"
5573 "Filter outgoing updates\n")
5574{
c500ae40
DW
5575 int idx_peer = 2;
5576 int idx_in_out = 5;
5577 return peer_prefix_list_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5578 bgp_node_safi (vty), argv[idx_in_out]->arg);
718e3744 5579}
6b0655a2 5580
596c17ba
DW
5581ALIAS_HIDDEN (no_neighbor_prefix_list,
5582 no_neighbor_prefix_list_hidden_cmd,
5583 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5584 NO_STR
5585 NEIGHBOR_STR
5586 NEIGHBOR_ADDR_STR2
5587 "Filter updates to/from this neighbor\n"
5588 "Name of a prefix list\n"
5589 "Filter incoming updates\n"
5590 "Filter outgoing updates\n")
5591
94f2b392 5592static int
e52702f2 5593peer_aslist_set_vty (struct vty *vty, const char *ip_str,
fd79ac91 5594 afi_t afi, safi_t safi,
5595 const char *name_str, const char *direct_str)
718e3744 5596{
5597 int ret;
5598 struct peer *peer;
5599 int direct = FILTER_IN;
5600
5601 peer = peer_and_group_lookup_vty (vty, ip_str);
5602 if (! peer)
5603 return CMD_WARNING;
5604
5605 /* Check filter direction. */
5606 if (strncmp (direct_str, "i", 1) == 0)
5607 direct = FILTER_IN;
5608 else if (strncmp (direct_str, "o", 1) == 0)
5609 direct = FILTER_OUT;
5610
5611 ret = peer_aslist_set (peer, afi, safi, direct, name_str);
5612
5613 return bgp_vty_return (vty, ret);
5614}
5615
94f2b392 5616static int
e52702f2 5617peer_aslist_unset_vty (struct vty *vty, const char *ip_str,
fd79ac91 5618 afi_t afi, safi_t safi,
5619 const char *direct_str)
718e3744 5620{
5621 int ret;
5622 struct peer *peer;
5623 int direct = FILTER_IN;
5624
5625 peer = peer_and_group_lookup_vty (vty, ip_str);
5626 if (! peer)
5627 return CMD_WARNING;
5628
5629 /* Check filter direction. */
5630 if (strncmp (direct_str, "i", 1) == 0)
5631 direct = FILTER_IN;
5632 else if (strncmp (direct_str, "o", 1) == 0)
5633 direct = FILTER_OUT;
5634
5635 ret = peer_aslist_unset (peer, afi, safi, direct);
5636
5637 return bgp_vty_return (vty, ret);
5638}
5639
5640DEFUN (neighbor_filter_list,
5641 neighbor_filter_list_cmd,
9ccf14f7 5642 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
718e3744 5643 NEIGHBOR_STR
5644 NEIGHBOR_ADDR_STR2
5645 "Establish BGP filters\n"
5646 "AS path access-list name\n"
5647 "Filter incoming routes\n"
5648 "Filter outgoing routes\n")
5649{
c500ae40
DW
5650 int idx_peer = 1;
5651 int idx_word = 3;
5652 int idx_in_out = 4;
5653 return peer_aslist_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5654 bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg);
718e3744 5655}
5656
596c17ba
DW
5657ALIAS_HIDDEN (neighbor_filter_list,
5658 neighbor_filter_list_hidden_cmd,
5659 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5660 NEIGHBOR_STR
5661 NEIGHBOR_ADDR_STR2
5662 "Establish BGP filters\n"
5663 "AS path access-list name\n"
5664 "Filter incoming routes\n"
5665 "Filter outgoing routes\n")
5666
718e3744 5667DEFUN (no_neighbor_filter_list,
5668 no_neighbor_filter_list_cmd,
9ccf14f7 5669 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
718e3744 5670 NO_STR
5671 NEIGHBOR_STR
5672 NEIGHBOR_ADDR_STR2
5673 "Establish BGP filters\n"
5674 "AS path access-list name\n"
5675 "Filter incoming routes\n"
5676 "Filter outgoing routes\n")
5677{
c500ae40
DW
5678 int idx_peer = 2;
5679 int idx_in_out = 5;
5680 return peer_aslist_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5681 bgp_node_safi (vty), argv[idx_in_out]->arg);
718e3744 5682}
6b0655a2 5683
596c17ba
DW
5684ALIAS_HIDDEN (no_neighbor_filter_list,
5685 no_neighbor_filter_list_hidden_cmd,
5686 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5687 NO_STR
5688 NEIGHBOR_STR
5689 NEIGHBOR_ADDR_STR2
5690 "Establish BGP filters\n"
5691 "AS path access-list name\n"
5692 "Filter incoming routes\n"
5693 "Filter outgoing routes\n")
5694
718e3744 5695/* Set route-map to the peer. */
94f2b392 5696static int
e52702f2 5697peer_route_map_set_vty (struct vty *vty, const char *ip_str,
fd79ac91 5698 afi_t afi, safi_t safi,
5699 const char *name_str, const char *direct_str)
718e3744 5700{
5701 int ret;
5702 struct peer *peer;
fee0f4c6 5703 int direct = RMAP_IN;
718e3744 5704
5705 peer = peer_and_group_lookup_vty (vty, ip_str);
5706 if (! peer)
5707 return CMD_WARNING;
5708
5709 /* Check filter direction. */
fee0f4c6 5710 if (strncmp (direct_str, "in", 2) == 0)
5711 direct = RMAP_IN;
718e3744 5712 else if (strncmp (direct_str, "o", 1) == 0)
fee0f4c6 5713 direct = RMAP_OUT;
718e3744 5714
5715 ret = peer_route_map_set (peer, afi, safi, direct, name_str);
5716
5717 return bgp_vty_return (vty, ret);
5718}
5719
94f2b392 5720static int
fd79ac91 5721peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
5722 safi_t safi, const char *direct_str)
718e3744 5723{
5724 int ret;
5725 struct peer *peer;
fee0f4c6 5726 int direct = RMAP_IN;
718e3744 5727
5728 peer = peer_and_group_lookup_vty (vty, ip_str);
5729 if (! peer)
5730 return CMD_WARNING;
5731
5732 /* Check filter direction. */
fee0f4c6 5733 if (strncmp (direct_str, "in", 2) == 0)
5734 direct = RMAP_IN;
718e3744 5735 else if (strncmp (direct_str, "o", 1) == 0)
fee0f4c6 5736 direct = RMAP_OUT;
718e3744 5737
5738 ret = peer_route_map_unset (peer, afi, safi, direct);
5739
5740 return bgp_vty_return (vty, ret);
5741}
5742
5743DEFUN (neighbor_route_map,
5744 neighbor_route_map_cmd,
9ccf14f7 5745 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
718e3744 5746 NEIGHBOR_STR
5747 NEIGHBOR_ADDR_STR2
5748 "Apply route map to neighbor\n"
5749 "Name of route map\n"
5750 "Apply map to incoming routes\n"
2a3d5731 5751 "Apply map to outbound routes\n")
718e3744 5752{
c500ae40
DW
5753 int idx_peer = 1;
5754 int idx_word = 3;
5755 int idx_in_out = 4;
5756 return peer_route_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5757 bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg);
718e3744 5758}
5759
596c17ba
DW
5760ALIAS_HIDDEN (neighbor_route_map,
5761 neighbor_route_map_hidden_cmd,
5762 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5763 NEIGHBOR_STR
5764 NEIGHBOR_ADDR_STR2
5765 "Apply route map to neighbor\n"
5766 "Name of route map\n"
5767 "Apply map to incoming routes\n"
5768 "Apply map to outbound routes\n")
5769
718e3744 5770DEFUN (no_neighbor_route_map,
5771 no_neighbor_route_map_cmd,
9ccf14f7 5772 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
718e3744 5773 NO_STR
5774 NEIGHBOR_STR
5775 NEIGHBOR_ADDR_STR2
5776 "Apply route map to neighbor\n"
5777 "Name of route map\n"
5778 "Apply map to incoming routes\n"
2a3d5731 5779 "Apply map to outbound routes\n")
718e3744 5780{
c500ae40
DW
5781 int idx_peer = 2;
5782 int idx_in_out = 5;
5783 return peer_route_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5784 bgp_node_safi (vty), argv[idx_in_out]->arg);
718e3744 5785}
6b0655a2 5786
596c17ba
DW
5787ALIAS_HIDDEN (no_neighbor_route_map,
5788 no_neighbor_route_map_hidden_cmd,
5789 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5790 NO_STR
5791 NEIGHBOR_STR
5792 NEIGHBOR_ADDR_STR2
5793 "Apply route map to neighbor\n"
5794 "Name of route map\n"
5795 "Apply map to incoming routes\n"
5796 "Apply map to outbound routes\n")
5797
718e3744 5798/* Set unsuppress-map to the peer. */
94f2b392 5799static int
fd79ac91 5800peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
5801 safi_t safi, const char *name_str)
718e3744 5802{
5803 int ret;
5804 struct peer *peer;
5805
5806 peer = peer_and_group_lookup_vty (vty, ip_str);
5807 if (! peer)
5808 return CMD_WARNING;
5809
5810 ret = peer_unsuppress_map_set (peer, afi, safi, name_str);
5811
5812 return bgp_vty_return (vty, ret);
5813}
5814
5815/* Unset route-map from the peer. */
94f2b392 5816static int
fd79ac91 5817peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
718e3744 5818 safi_t safi)
5819{
5820 int ret;
5821 struct peer *peer;
5822
5823 peer = peer_and_group_lookup_vty (vty, ip_str);
5824 if (! peer)
5825 return CMD_WARNING;
5826
5827 ret = peer_unsuppress_map_unset (peer, afi, safi);
5828
5829 return bgp_vty_return (vty, ret);
5830}
5831
5832DEFUN (neighbor_unsuppress_map,
5833 neighbor_unsuppress_map_cmd,
9ccf14f7 5834 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
718e3744 5835 NEIGHBOR_STR
5836 NEIGHBOR_ADDR_STR2
5837 "Route-map to selectively unsuppress suppressed routes\n"
5838 "Name of route map\n")
5839{
c500ae40
DW
5840 int idx_peer = 1;
5841 int idx_word = 3;
5842 return peer_unsuppress_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5843 bgp_node_safi (vty), argv[idx_word]->arg);
718e3744 5844}
5845
596c17ba
DW
5846ALIAS_HIDDEN (neighbor_unsuppress_map,
5847 neighbor_unsuppress_map_hidden_cmd,
5848 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5849 NEIGHBOR_STR
5850 NEIGHBOR_ADDR_STR2
5851 "Route-map to selectively unsuppress suppressed routes\n"
5852 "Name of route map\n")
5853
718e3744 5854DEFUN (no_neighbor_unsuppress_map,
5855 no_neighbor_unsuppress_map_cmd,
9ccf14f7 5856 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
718e3744 5857 NO_STR
5858 NEIGHBOR_STR
5859 NEIGHBOR_ADDR_STR2
5860 "Route-map to selectively unsuppress suppressed routes\n"
5861 "Name of route map\n")
5862{
c500ae40
DW
5863 int idx_peer = 2;
5864 return peer_unsuppress_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 5865 bgp_node_safi (vty));
5866}
6b0655a2 5867
596c17ba
DW
5868ALIAS_HIDDEN (no_neighbor_unsuppress_map,
5869 no_neighbor_unsuppress_map_hidden_cmd,
5870 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5871 NO_STR
5872 NEIGHBOR_STR
5873 NEIGHBOR_ADDR_STR2
5874 "Route-map to selectively unsuppress suppressed routes\n"
5875 "Name of route map\n")
5876
94f2b392 5877static int
fd79ac91 5878peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi,
e52702f2 5879 safi_t safi, const char *num_str,
0a486e5f 5880 const char *threshold_str, int warning,
5881 const char *restart_str)
718e3744 5882{
5883 int ret;
5884 struct peer *peer;
5885 u_int32_t max;
e0701b79 5886 u_char threshold;
0a486e5f 5887 u_int16_t restart;
718e3744 5888
5889 peer = peer_and_group_lookup_vty (vty, ip_str);
5890 if (! peer)
5891 return CMD_WARNING;
5892
e6ec1c36 5893 VTY_GET_INTEGER ("maximum number", max, num_str);
e0701b79 5894 if (threshold_str)
5895 threshold = atoi (threshold_str);
5896 else
5897 threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT;
718e3744 5898
0a486e5f 5899 if (restart_str)
5900 restart = atoi (restart_str);
5901 else
5902 restart = 0;
5903
5904 ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart);
718e3744 5905
5906 return bgp_vty_return (vty, ret);
5907}
5908
94f2b392 5909static int
fd79ac91 5910peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi,
718e3744 5911 safi_t safi)
5912{
5913 int ret;
5914 struct peer *peer;
5915
5916 peer = peer_and_group_lookup_vty (vty, ip_str);
5917 if (! peer)
5918 return CMD_WARNING;
5919
5920 ret = peer_maximum_prefix_unset (peer, afi, safi);
5921
5922 return bgp_vty_return (vty, ret);
5923}
5924
5925/* Maximum number of prefix configuration. prefix count is different
5926 for each peer configuration. So this configuration can be set for
5927 each peer configuration. */
5928DEFUN (neighbor_maximum_prefix,
5929 neighbor_maximum_prefix_cmd,
9ccf14f7 5930 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
718e3744 5931 NEIGHBOR_STR
5932 NEIGHBOR_ADDR_STR2
5933 "Maximum number of prefix accept from this peer\n"
5934 "maximum no. of prefix limit\n")
5935{
c500ae40
DW
5936 int idx_peer = 1;
5937 int idx_number = 3;
5938 return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5939 bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0,
0a486e5f 5940 NULL);
718e3744 5941}
5942
596c17ba
DW
5943ALIAS_HIDDEN (neighbor_maximum_prefix,
5944 neighbor_maximum_prefix_hidden_cmd,
5945 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5946 NEIGHBOR_STR
5947 NEIGHBOR_ADDR_STR2
5948 "Maximum number of prefix accept from this peer\n"
5949 "maximum no. of prefix limit\n")
5950
e0701b79 5951DEFUN (neighbor_maximum_prefix_threshold,
5952 neighbor_maximum_prefix_threshold_cmd,
9ccf14f7 5953 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
e0701b79 5954 NEIGHBOR_STR
5955 NEIGHBOR_ADDR_STR2
5956 "Maximum number of prefix accept from this peer\n"
5957 "maximum no. of prefix limit\n"
5958 "Threshold value (%) at which to generate a warning msg\n")
5959{
c500ae40
DW
5960 int idx_peer = 1;
5961 int idx_number = 3;
5962 int idx_number_2 = 4;
5963 return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5964 bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0,
0a486e5f 5965 NULL);
5966}
e0701b79 5967
596c17ba
DW
5968ALIAS_HIDDEN (neighbor_maximum_prefix_threshold,
5969 neighbor_maximum_prefix_threshold_hidden_cmd,
5970 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5971 NEIGHBOR_STR
5972 NEIGHBOR_ADDR_STR2
5973 "Maximum number of prefix accept from this peer\n"
5974 "maximum no. of prefix limit\n"
5975 "Threshold value (%) at which to generate a warning msg\n")
5976
718e3744 5977DEFUN (neighbor_maximum_prefix_warning,
5978 neighbor_maximum_prefix_warning_cmd,
9ccf14f7 5979 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
718e3744 5980 NEIGHBOR_STR
5981 NEIGHBOR_ADDR_STR2
5982 "Maximum number of prefix accept from this peer\n"
5983 "maximum no. of prefix limit\n"
5984 "Only give warning message when limit is exceeded\n")
5985{
c500ae40
DW
5986 int idx_peer = 1;
5987 int idx_number = 3;
5988 return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
5989 bgp_node_safi (vty), argv[idx_number]->arg, NULL, 1,
0a486e5f 5990 NULL);
718e3744 5991}
5992
596c17ba
DW
5993ALIAS_HIDDEN (neighbor_maximum_prefix_warning,
5994 neighbor_maximum_prefix_warning_hidden_cmd,
5995 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5996 NEIGHBOR_STR
5997 NEIGHBOR_ADDR_STR2
5998 "Maximum number of prefix accept from this peer\n"
5999 "maximum no. of prefix limit\n"
6000 "Only give warning message when limit is exceeded\n")
6001
e0701b79 6002DEFUN (neighbor_maximum_prefix_threshold_warning,
6003 neighbor_maximum_prefix_threshold_warning_cmd,
9ccf14f7 6004 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
e0701b79 6005 NEIGHBOR_STR
6006 NEIGHBOR_ADDR_STR2
6007 "Maximum number of prefix accept from this peer\n"
6008 "maximum no. of prefix limit\n"
6009 "Threshold value (%) at which to generate a warning msg\n"
6010 "Only give warning message when limit is exceeded\n")
6011{
c500ae40
DW
6012 int idx_peer = 1;
6013 int idx_number = 3;
6014 int idx_number_2 = 4;
6015 return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
6016 bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL);
0a486e5f 6017}
6018
596c17ba
DW
6019ALIAS_HIDDEN (neighbor_maximum_prefix_threshold_warning,
6020 neighbor_maximum_prefix_threshold_warning_hidden_cmd,
6021 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6022 NEIGHBOR_STR
6023 NEIGHBOR_ADDR_STR2
6024 "Maximum number of prefix accept from this peer\n"
6025 "maximum no. of prefix limit\n"
6026 "Threshold value (%) at which to generate a warning msg\n"
6027 "Only give warning message when limit is exceeded\n")
6028
0a486e5f 6029DEFUN (neighbor_maximum_prefix_restart,
6030 neighbor_maximum_prefix_restart_cmd,
9ccf14f7 6031 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
0a486e5f 6032 NEIGHBOR_STR
6033 NEIGHBOR_ADDR_STR2
6034 "Maximum number of prefix accept from this peer\n"
6035 "maximum no. of prefix limit\n"
6036 "Restart bgp connection after limit is exceeded\n"
6037 "Restart interval in minutes")
6038{
c500ae40
DW
6039 int idx_peer = 1;
6040 int idx_number = 3;
6041 int idx_number_2 = 5;
6042 return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
6043 bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg);
0a486e5f 6044}
6045
596c17ba
DW
6046ALIAS_HIDDEN (neighbor_maximum_prefix_restart,
6047 neighbor_maximum_prefix_restart_hidden_cmd,
6048 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6049 NEIGHBOR_STR
6050 NEIGHBOR_ADDR_STR2
6051 "Maximum number of prefix accept from this peer\n"
6052 "maximum no. of prefix limit\n"
6053 "Restart bgp connection after limit is exceeded\n"
6054 "Restart interval in minutes")
6055
0a486e5f 6056DEFUN (neighbor_maximum_prefix_threshold_restart,
6057 neighbor_maximum_prefix_threshold_restart_cmd,
9ccf14f7 6058 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
0a486e5f 6059 NEIGHBOR_STR
6060 NEIGHBOR_ADDR_STR2
16cedbb0 6061 "Maximum number of prefixes to accept from this peer\n"
0a486e5f 6062 "maximum no. of prefix limit\n"
6063 "Threshold value (%) at which to generate a warning msg\n"
6064 "Restart bgp connection after limit is exceeded\n"
16cedbb0 6065 "Restart interval in minutes\n")
0a486e5f 6066{
c500ae40
DW
6067 int idx_peer = 1;
6068 int idx_number = 3;
6069 int idx_number_2 = 4;
6070 int idx_number_3 = 6;
6071 return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
6072 bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, argv[idx_number_3]->arg);
0a486e5f 6073}
e0701b79 6074
596c17ba
DW
6075ALIAS_HIDDEN (neighbor_maximum_prefix_threshold_restart,
6076 neighbor_maximum_prefix_threshold_restart_hidden_cmd,
6077 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6078 NEIGHBOR_STR
6079 NEIGHBOR_ADDR_STR2
6080 "Maximum number of prefixes to accept from this peer\n"
6081 "maximum no. of prefix limit\n"
6082 "Threshold value (%) at which to generate a warning msg\n"
6083 "Restart bgp connection after limit is exceeded\n"
6084 "Restart interval in minutes\n")
6085
718e3744 6086DEFUN (no_neighbor_maximum_prefix,
6087 no_neighbor_maximum_prefix_cmd,
d04c479d 6088 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
718e3744 6089 NO_STR
6090 NEIGHBOR_STR
6091 NEIGHBOR_ADDR_STR2
16cedbb0 6092 "Maximum number of prefixes to accept from this peer\n"
31500417
DW
6093 "maximum no. of prefix limit\n"
6094 "Threshold value (%) at which to generate a warning msg\n"
6095 "Restart bgp connection after limit is exceeded\n"
16cedbb0 6096 "Restart interval in minutes\n"
31500417 6097 "Only give warning message when limit is exceeded\n")
718e3744 6098{
c500ae40
DW
6099 int idx_peer = 2;
6100 return peer_maximum_prefix_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
718e3744 6101 bgp_node_safi (vty));
6102}
e52702f2 6103
596c17ba
DW
6104ALIAS_HIDDEN (no_neighbor_maximum_prefix,
6105 no_neighbor_maximum_prefix_hidden_cmd,
6106 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6107 NO_STR
6108 NEIGHBOR_STR
6109 NEIGHBOR_ADDR_STR2
6110 "Maximum number of prefixes to accept from this peer\n"
6111 "maximum no. of prefix limit\n"
6112 "Threshold value (%) at which to generate a warning msg\n"
6113 "Restart bgp connection after limit is exceeded\n"
6114 "Restart interval in minutes\n"
6115 "Only give warning message when limit is exceeded\n")
6116
718e3744 6117
718e3744 6118/* "neighbor allowas-in" */
6119DEFUN (neighbor_allowas_in,
6120 neighbor_allowas_in_cmd,
fd8503f5 6121 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
718e3744 6122 NEIGHBOR_STR
6123 NEIGHBOR_ADDR_STR2
31500417 6124 "Accept as-path with my AS present in it\n"
fd8503f5
QY
6125 "Number of occurances of AS number\n"
6126 "Only accept my AS in the as-path if the route was originated in my AS\n")
718e3744 6127{
c500ae40 6128 int idx_peer = 1;
fd8503f5 6129 int idx_number_origin = 3;
718e3744 6130 int ret;
aac9ef6c 6131 int origin = 0;
718e3744 6132 struct peer *peer;
aac9ef6c 6133 int allow_num = 0;
718e3744 6134
c500ae40 6135 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 6136 if (! peer)
6137 return CMD_WARNING;
6138
fd8503f5 6139 if (argc <= idx_number_origin)
718e3744 6140 allow_num = 3;
6141 else
aac9ef6c 6142 {
fd8503f5 6143 if (argv[idx_number_origin]->type == WORD_TKN)
aac9ef6c
DW
6144 origin = 1;
6145 else
fd8503f5 6146 allow_num = atoi (argv[idx_number_origin]->arg);
aac9ef6c 6147 }
718e3744 6148
6149 ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty),
aac9ef6c 6150 allow_num, origin);
718e3744 6151
6152 return bgp_vty_return (vty, ret);
6153}
6154
596c17ba
DW
6155ALIAS_HIDDEN (neighbor_allowas_in,
6156 neighbor_allowas_in_hidden_cmd,
6157 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6158 NEIGHBOR_STR
6159 NEIGHBOR_ADDR_STR2
6160 "Accept as-path with my AS present in it\n"
6161 "Number of occurances of AS number\n"
6162 "Only accept my AS in the as-path if the route was originated in my AS\n")
6163
718e3744 6164DEFUN (no_neighbor_allowas_in,
6165 no_neighbor_allowas_in_cmd,
fd8503f5 6166 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
718e3744 6167 NO_STR
6168 NEIGHBOR_STR
6169 NEIGHBOR_ADDR_STR2
8334fd5a 6170 "allow local ASN appears in aspath attribute\n"
fd8503f5
QY
6171 "Number of occurances of AS number\n"
6172 "Only accept my AS in the as-path if the route was originated in my AS\n")
718e3744 6173{
c500ae40 6174 int idx_peer = 2;
718e3744 6175 int ret;
6176 struct peer *peer;
6177
c500ae40 6178 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
718e3744 6179 if (! peer)
6180 return CMD_WARNING;
6181
6182 ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty));
6183
6184 return bgp_vty_return (vty, ret);
6185}
6b0655a2 6186
596c17ba
DW
6187ALIAS_HIDDEN (no_neighbor_allowas_in,
6188 no_neighbor_allowas_in_hidden_cmd,
6189 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6190 NO_STR
6191 NEIGHBOR_STR
6192 NEIGHBOR_ADDR_STR2
6193 "allow local ASN appears in aspath attribute\n"
6194 "Number of occurances of AS number\n"
6195 "Only accept my AS in the as-path if the route was originated in my AS\n")
6196
fa411a21
NH
6197DEFUN (neighbor_ttl_security,
6198 neighbor_ttl_security_cmd,
9ccf14f7 6199 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
fa411a21
NH
6200 NEIGHBOR_STR
6201 NEIGHBOR_ADDR_STR2
16cedbb0 6202 "BGP ttl-security parameters\n"
d7fa34c1
QY
6203 "Specify the maximum number of hops to the BGP peer\n"
6204 "Number of hops to BGP peer\n")
fa411a21 6205{
c500ae40
DW
6206 int idx_peer = 1;
6207 int idx_number = 4;
fa411a21 6208 struct peer *peer;
89b6d1f8 6209 int gtsm_hops;
fa411a21 6210
c500ae40 6211 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
fa411a21
NH
6212 if (! peer)
6213 return CMD_WARNING;
e52702f2 6214
c500ae40 6215 VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[idx_number]->arg, 1, 254);
fa411a21 6216
8cdabf90
SK
6217 /*
6218 * If 'neighbor swpX', then this is for directly connected peers,
6219 * we should not accept a ttl-security hops value greater than 1.
6220 */
6221 if (peer->conf_if && (gtsm_hops > 1)) {
6222 vty_out (vty, "%s is directly connected peer, hops cannot exceed 1%s",
c500ae40 6223 argv[idx_peer]->arg, VTY_NEWLINE);
8cdabf90
SK
6224 return CMD_WARNING;
6225 }
6226
89b6d1f8 6227 return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops));
fa411a21
NH
6228}
6229
6230DEFUN (no_neighbor_ttl_security,
6231 no_neighbor_ttl_security_cmd,
9ccf14f7 6232 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
fa411a21
NH
6233 NO_STR
6234 NEIGHBOR_STR
6235 NEIGHBOR_ADDR_STR2
16cedbb0 6236 "BGP ttl-security parameters\n"
3a2d747c
QY
6237 "Specify the maximum number of hops to the BGP peer\n"
6238 "Number of hops to BGP peer\n")
fa411a21 6239{
c500ae40 6240 int idx_peer = 2;
fa411a21 6241 struct peer *peer;
fa411a21 6242
c500ae40 6243 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
fa411a21
NH
6244 if (! peer)
6245 return CMD_WARNING;
6246
89b6d1f8 6247 return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer));
fa411a21 6248}
6b0655a2 6249
adbac85e
DW
6250DEFUN (neighbor_addpath_tx_all_paths,
6251 neighbor_addpath_tx_all_paths_cmd,
9ccf14f7 6252 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
adbac85e
DW
6253 NEIGHBOR_STR
6254 NEIGHBOR_ADDR_STR2
6255 "Use addpath to advertise all paths to a neighbor\n")
6256{
c500ae40 6257 int idx_peer = 1;
adbac85e
DW
6258 struct peer *peer;
6259
c500ae40 6260 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
adbac85e
DW
6261 if (! peer)
6262 return CMD_WARNING;
6263
c500ae40 6264 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
adbac85e
DW
6265 bgp_node_safi (vty),
6266 PEER_FLAG_ADDPATH_TX_ALL_PATHS);
6267}
6268
596c17ba
DW
6269ALIAS_HIDDEN (neighbor_addpath_tx_all_paths,
6270 neighbor_addpath_tx_all_paths_hidden_cmd,
6271 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6272 NEIGHBOR_STR
6273 NEIGHBOR_ADDR_STR2
6274 "Use addpath to advertise all paths to a neighbor\n")
6275
adbac85e
DW
6276DEFUN (no_neighbor_addpath_tx_all_paths,
6277 no_neighbor_addpath_tx_all_paths_cmd,
9ccf14f7 6278 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
adbac85e
DW
6279 NO_STR
6280 NEIGHBOR_STR
6281 NEIGHBOR_ADDR_STR2
6282 "Use addpath to advertise all paths to a neighbor\n")
6283{
c500ae40
DW
6284 int idx_peer = 2;
6285 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
adbac85e
DW
6286 bgp_node_safi (vty),
6287 PEER_FLAG_ADDPATH_TX_ALL_PATHS);
6288}
6289
596c17ba
DW
6290ALIAS_HIDDEN (no_neighbor_addpath_tx_all_paths,
6291 no_neighbor_addpath_tx_all_paths_hidden_cmd,
6292 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6293 NO_STR
6294 NEIGHBOR_STR
6295 NEIGHBOR_ADDR_STR2
6296 "Use addpath to advertise all paths to a neighbor\n")
6297
06370dac
DW
6298DEFUN (neighbor_addpath_tx_bestpath_per_as,
6299 neighbor_addpath_tx_bestpath_per_as_cmd,
9ccf14f7 6300 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
06370dac
DW
6301 NEIGHBOR_STR
6302 NEIGHBOR_ADDR_STR2
6303 "Use addpath to advertise the bestpath per each neighboring AS\n")
6304{
c500ae40 6305 int idx_peer = 1;
06370dac
DW
6306 struct peer *peer;
6307
c500ae40 6308 peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
06370dac
DW
6309 if (! peer)
6310 return CMD_WARNING;
6311
c500ae40 6312 return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
06370dac
DW
6313 bgp_node_safi (vty),
6314 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS);
6315}
6316
596c17ba
DW
6317ALIAS_HIDDEN (neighbor_addpath_tx_bestpath_per_as,
6318 neighbor_addpath_tx_bestpath_per_as_hidden_cmd,
6319 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6320 NEIGHBOR_STR
6321 NEIGHBOR_ADDR_STR2
6322 "Use addpath to advertise the bestpath per each neighboring AS\n")
6323
06370dac
DW
6324DEFUN (no_neighbor_addpath_tx_bestpath_per_as,
6325 no_neighbor_addpath_tx_bestpath_per_as_cmd,
9ccf14f7 6326 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
06370dac
DW
6327 NO_STR
6328 NEIGHBOR_STR
6329 NEIGHBOR_ADDR_STR2
6330 "Use addpath to advertise the bestpath per each neighboring AS\n")
6331{
c500ae40
DW
6332 int idx_peer = 2;
6333 return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty),
06370dac
DW
6334 bgp_node_safi (vty),
6335 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS);
6336}
6337
596c17ba
DW
6338ALIAS_HIDDEN (no_neighbor_addpath_tx_bestpath_per_as,
6339 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd,
6340 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6341 NO_STR
6342 NEIGHBOR_STR
6343 NEIGHBOR_ADDR_STR2
6344 "Use addpath to advertise the bestpath per each neighboring AS\n")
6345
505e5056 6346DEFUN_NOSH (address_family_ipv4_safi,
718e3744 6347 address_family_ipv4_safi_cmd,
f51bae9c 6348 "address-family ipv4 [<unicast|multicast|vpn|encap|labeled-unicast>]",
718e3744 6349 "Enter Address Family command mode\n"
8c3deaae 6350 "Address Family\n"
46f296b4 6351 BGP_SAFI_HELP_STR)
718e3744 6352{
f51bae9c
DS
6353
6354 if (argc == 3)
ccbb332a 6355 {
f51bae9c
DS
6356 safi_t safi = bgp_vty_safi_from_arg(argv[2]->arg);
6357 vty->node = bgp_node_type(AFI_IP, safi);
ccbb332a 6358 }
c7f1274b
DS
6359 else
6360 vty->node = BGP_IPV4_NODE;
718e3744 6361
6362 return CMD_SUCCESS;
6363}
6364
505e5056 6365DEFUN_NOSH (address_family_ipv6_safi,
25ffbdc1 6366 address_family_ipv6_safi_cmd,
f51bae9c 6367 "address-family ipv6 [<unicast|multicast|vpn|encap|labeled-unicast>]",
718e3744 6368 "Enter Address Family command mode\n"
8c3deaae 6369 "Address Family\n"
46f296b4 6370 BGP_SAFI_HELP_STR)
25ffbdc1 6371{
f51bae9c 6372 if (argc == 3)
46f296b4 6373 {
f51bae9c
DS
6374 safi_t safi = bgp_vty_safi_from_arg(argv[2]->arg);
6375 vty->node = bgp_node_type(AFI_IP6, safi);
46f296b4 6376 }
c7f1274b
DS
6377 else
6378 vty->node = BGP_IPV6_NODE;
25ffbdc1 6379
6380 return CMD_SUCCESS;
6381}
718e3744 6382
d6902373 6383#ifdef KEEP_OLD_VPN_COMMANDS
505e5056 6384DEFUN_NOSH (address_family_vpnv4,
718e3744 6385 address_family_vpnv4_cmd,
8334fd5a 6386 "address-family vpnv4 [unicast]",
718e3744 6387 "Enter Address Family command mode\n"
8c3deaae 6388 "Address Family\n"
3a2d747c 6389 "Address Family modifier\n")
718e3744 6390{
6391 vty->node = BGP_VPNV4_NODE;
6392 return CMD_SUCCESS;
6393}
6394
505e5056 6395DEFUN_NOSH (address_family_vpnv6,
8ecd3266 6396 address_family_vpnv6_cmd,
8334fd5a 6397 "address-family vpnv6 [unicast]",
8ecd3266 6398 "Enter Address Family command mode\n"
8c3deaae 6399 "Address Family\n"
3a2d747c 6400 "Address Family modifier\n")
8ecd3266 6401{
6402 vty->node = BGP_VPNV6_NODE;
6403 return CMD_SUCCESS;
6404}
c016b6c7 6405#endif
d6902373 6406
505e5056 6407DEFUN_NOSH (address_family_encap,
8b1fb8be 6408 address_family_encap_cmd,
8334fd5a 6409 "address-family <encap|encapv4>",
8b1fb8be 6410 "Enter Address Family command mode\n"
8c3deaae
QY
6411 "Address Family\n"
6412 "Address Family\n")
8b1fb8be
LB
6413{
6414 vty->node = BGP_ENCAP_NODE;
6415 return CMD_SUCCESS;
6416}
6417
8b1fb8be 6418
505e5056 6419DEFUN_NOSH (address_family_encapv6,
8b1fb8be
LB
6420 address_family_encapv6_cmd,
6421 "address-family encapv6",
6422 "Enter Address Family command mode\n"
8c3deaae 6423 "Address Family\n")
8b1fb8be
LB
6424{
6425 vty->node = BGP_ENCAPV6_NODE;
6426 return CMD_SUCCESS;
6427}
6428
505e5056 6429DEFUN_NOSH (address_family_evpn,
4e0b7b6d 6430 address_family_evpn_cmd,
b194703e 6431 "address-family <l2vpn evpn>",
4e0b7b6d 6432 "Enter Address Family command mode\n"
61a51962
PG
6433 "EVPN Address family\n"
6434 "Layer2 VPN Address family\n"
6435 "Ethernet Virtual Private Network Subsequent Address Family\n")
4e0b7b6d 6436{
4e0b7b6d 6437 vty->node = BGP_EVPN_NODE;
4e0b7b6d
PG
6438 return CMD_SUCCESS;
6439}
6440
505e5056 6441DEFUN_NOSH (exit_address_family,
718e3744 6442 exit_address_family_cmd,
6443 "exit-address-family",
6444 "Exit from Address Family configuration mode\n")
6445{
a8a80d53 6446 if (vty->node == BGP_IPV4_NODE
6447 || vty->node == BGP_IPV4M_NODE
f51bae9c 6448 || vty->node == BGP_IPV4L_NODE
718e3744 6449 || vty->node == BGP_VPNV4_NODE
25ffbdc1 6450 || vty->node == BGP_IPV6_NODE
8ecd3266 6451 || vty->node == BGP_IPV6M_NODE
f51bae9c 6452 || vty->node == BGP_IPV6L_NODE
8b1fb8be
LB
6453 || vty->node == BGP_VPNV6_NODE
6454 || vty->node == BGP_ENCAP_NODE
4e0b7b6d
PG
6455 || vty->node == BGP_ENCAPV6_NODE
6456 || vty->node == BGP_EVPN_NODE)
718e3744 6457 vty->node = BGP_NODE;
6458 return CMD_SUCCESS;
6459}
6b0655a2 6460
8ad7271d
DS
6461/* Recalculate bestpath and re-advertise a prefix */
6462static int
01080f7c 6463bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str,
8ad7271d
DS
6464 afi_t afi, safi_t safi, struct prefix_rd *prd)
6465{
6466 int ret;
6467 struct prefix match;
6468 struct bgp_node *rn;
6469 struct bgp_node *rm;
8ad7271d
DS
6470 struct bgp *bgp;
6471 struct bgp_table *table;
6472 struct bgp_table *rib;
6473
6474 /* BGP structure lookup. */
6475 if (view_name)
6476 {
6477 bgp = bgp_lookup_by_name (view_name);
6478 if (bgp == NULL)
6479 {
6aeb9e78 6480 vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTY_NEWLINE);
8ad7271d
DS
6481 return CMD_WARNING;
6482 }
6483 }
6484 else
6485 {
6486 bgp = bgp_get_default ();
6487 if (bgp == NULL)
6488 {
6489 vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
6490 return CMD_WARNING;
6491 }
6492 }
6493
6494 /* Check IP address argument. */
6495 ret = str2prefix (ip_str, &match);
6496 if (! ret)
6497 {
6498 vty_out (vty, "%% address is malformed%s", VTY_NEWLINE);
6499 return CMD_WARNING;
6500 }
6501
6502 match.family = afi2family (afi);
6503 rib = bgp->rib[afi][safi];
6504
6505 if (safi == SAFI_MPLS_VPN)
6506 {
6507 for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn))
6508 {
6509 if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
6510 continue;
6511
6512 if ((table = rn->info) != NULL)
6513 {
6514 if ((rm = bgp_node_match (table, &match)) != NULL)
6515 {
6516 if (rm->p.prefixlen == match.prefixlen)
6517 {
6518 SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR);
6519 bgp_process (bgp, rm, afi, safi);
6520 }
6521 bgp_unlock_node (rm);
6522 }
6523 }
6524 }
6525 }
6526 else
6527 {
6528 if ((rn = bgp_node_match (rib, &match)) != NULL)
6529 {
6530 if (rn->p.prefixlen == match.prefixlen)
6531 {
6532 SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR);
6533 bgp_process (bgp, rn, afi, safi);
6534 }
6535 bgp_unlock_node (rn);
6536 }
6537 }
6538
6539 return CMD_SUCCESS;
6540}
6541
b09b5ae0 6542/* one clear bgp command to rule them all */
718e3744 6543DEFUN (clear_ip_bgp_all,
6544 clear_ip_bgp_all_cmd,
46f296b4 6545 "clear [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> [<soft [<in|out>]|in [prefix-filter]|out>]",
718e3744 6546 CLEAR_STR
6547 IP_STR
6548 BGP_STR
838758ac 6549 BGP_INSTANCE_HELP_STR
b09b5ae0
DW
6550 "Clear all peers\n"
6551 "BGP neighbor address to clear\n"
a80beece 6552 "BGP IPv6 neighbor to clear\n"
838758ac 6553 "BGP neighbor on interface to clear\n"
b09b5ae0
DW
6554 "Clear peers with the AS number\n"
6555 "Clear all external peers\n"
718e3744 6556 "Clear all members of peer-group\n"
b09b5ae0 6557 "BGP peer-group name\n"
46f296b4
LB
6558 BGP_AFI_HELP_STR
6559 BGP_SAFI_HELP_STR
b09b5ae0
DW
6560 BGP_SOFT_STR
6561 BGP_SOFT_IN_STR
b09b5ae0
DW
6562 BGP_SOFT_OUT_STR
6563 BGP_SOFT_IN_STR
6564 "Push out prefix-list ORF and do inbound soft reconfig\n"
b09b5ae0 6565 BGP_SOFT_OUT_STR)
718e3744 6566{
8334fd5a 6567 char *vrf = NULL;
630a298c 6568
ae19d7dd
QY
6569 afi_t afi = AFI_IP6;
6570 safi_t safi = SAFI_UNICAST;
5bf15956 6571 enum clear_sort clr_sort = clear_peer;
b09b5ae0
DW
6572 enum bgp_clear_type clr_type;
6573 char *clr_arg = NULL;
718e3744 6574
ae19d7dd 6575 int idx = 0;
01080f7c 6576
ae19d7dd
QY
6577 /* clear [ip] bgp */
6578 if (argv_find (argv, argc, "ip", &idx))
6579 afi = AFI_IP;
6580 /* [<view|vrf> WORD] */
6581 if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx))
838758ac 6582 {
ae19d7dd
QY
6583 vrf = argv[idx + 1]->arg;
6584 idx += 2;
838758ac 6585 }
ae19d7dd
QY
6586 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
6587 if (argv_find (argv, argc, "*", &idx))
b09b5ae0 6588 {
ae19d7dd 6589 clr_sort = clear_all;
b09b5ae0 6590 }
ae19d7dd 6591 else if (argv_find (argv, argc, "A.B.C.D", &idx))
b09b5ae0
DW
6592 {
6593 clr_sort = clear_peer;
ae19d7dd 6594 clr_arg = argv[idx]->arg;
b09b5ae0 6595 }
ae19d7dd 6596 else if (argv_find (argv, argc, "X:X::X:X", &idx))
b09b5ae0 6597 {
ae19d7dd
QY
6598 clr_sort = clear_peer;
6599 clr_arg = argv[idx]->arg;
838758ac 6600 }
ae19d7dd 6601 else if (argv_find (argv, argc, "peer-group", &idx))
b09b5ae0
DW
6602 {
6603 clr_sort = clear_group;
ae19d7dd
QY
6604 idx++;
6605 clr_arg = argv[idx]->arg;
b09b5ae0 6606 }
ae19d7dd 6607 else if (argv_find (argv, argc, "WORD", &idx))
b09b5ae0 6608 {
f0dac89f
RW
6609 clr_sort = clear_peer;
6610 clr_arg = argv[idx]->arg;
b09b5ae0 6611 }
ae19d7dd
QY
6612 else if (argv_find (argv, argc, "(1-4294967295)", &idx))
6613 {
6614 clr_sort = clear_as;
6615 clr_arg = argv[idx]->arg;
6616 }
6617 else if (argv_find (argv, argc, "external", &idx))
6618 {
6619 clr_sort = clear_external;
6620 }
46f296b4
LB
6621 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
6622 if (argv_find_and_parse_afi (argv, argc, &idx, &afi))
ae19d7dd 6623 {
46f296b4 6624 argv_find_and_parse_safi (argv, argc, &idx, &safi);
ae19d7dd
QY
6625 }
6626 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
6627 if (argv_find (argv, argc, "soft", &idx))
6628 {
6629 if (argv_find (argv, argc, "in", &idx) || argv_find (argv, argc, "out", &idx))
6630 clr_type = strmatch (argv[idx]->text, "in") ? BGP_CLEAR_SOFT_IN : BGP_CLEAR_SOFT_OUT;
6631 else
6632 clr_type = BGP_CLEAR_SOFT_BOTH;
6633 }
6634 else if (argv_find (argv, argc, "in", &idx))
6635 {
6636 clr_type = argv_find (argv, argc, "prefix-filter", &idx) ? BGP_CLEAR_SOFT_IN_ORF_PREFIX : BGP_CLEAR_SOFT_IN;
6637 }
6638 else if (argv_find (argv, argc, "out", &idx))
6639 {
5daa3e5e 6640 clr_type = BGP_CLEAR_SOFT_OUT;
ae19d7dd
QY
6641 }
6642 else
6643 clr_type = BGP_CLEAR_SOFT_NONE;
718e3744 6644
b09b5ae0 6645 return bgp_clear_vty (vty, vrf, afi, safi, clr_sort, clr_type, clr_arg);
838758ac 6646}
01080f7c 6647
8ad7271d
DS
6648DEFUN (clear_ip_bgp_prefix,
6649 clear_ip_bgp_prefix_cmd,
838758ac 6650 "clear [ip] bgp [<view|vrf> WORD] prefix A.B.C.D/M",
8ad7271d
DS
6651 CLEAR_STR
6652 IP_STR
6653 BGP_STR
838758ac 6654 BGP_INSTANCE_HELP_STR
8ad7271d 6655 "Clear bestpath and re-advertise\n"
0c7b1b01 6656 "IPv4 prefix\n")
8ad7271d 6657{
8334fd5a 6658 char *vrf = NULL;
630a298c 6659 char *prefix = NULL;
8ad7271d 6660
630a298c 6661 int idx = 0;
01080f7c 6662
630a298c
QY
6663 /* [<view|vrf> WORD] */
6664 if (argv_find (argv, argc, "WORD", &idx))
6665 vrf = argv[idx]->arg;
0c7b1b01 6666
630a298c 6667 prefix = argv[argc-1]->arg;
8ad7271d 6668
630a298c 6669 return bgp_clear_prefix (vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL);
838758ac 6670}
8ad7271d 6671
b09b5ae0
DW
6672DEFUN (clear_bgp_ipv6_safi_prefix,
6673 clear_bgp_ipv6_safi_prefix_cmd,
46f296b4 6674 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M",
718e3744 6675 CLEAR_STR
3a2d747c 6676 IP_STR
718e3744 6677 BGP_STR
8c3deaae 6678 "Address Family\n"
46f296b4 6679 BGP_SAFI_HELP_STR
b09b5ae0 6680 "Clear bestpath and re-advertise\n"
0c7b1b01 6681 "IPv6 prefix\n")
718e3744 6682{
b09b5ae0
DW
6683 int idx_safi = 3;
6684 int idx_ipv6_prefixlen = 5;
46f296b4
LB
6685 return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6,
6686 bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL);
838758ac 6687}
01080f7c 6688
b09b5ae0
DW
6689DEFUN (clear_bgp_instance_ipv6_safi_prefix,
6690 clear_bgp_instance_ipv6_safi_prefix_cmd,
46f296b4 6691 "clear [ip] bgp <view|vrf> WORD ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M",
718e3744 6692 CLEAR_STR
3a2d747c 6693 IP_STR
718e3744 6694 BGP_STR
838758ac 6695 BGP_INSTANCE_HELP_STR
8c3deaae 6696 "Address Family\n"
46f296b4 6697 BGP_SAFI_HELP_STR
b09b5ae0 6698 "Clear bestpath and re-advertise\n"
0c7b1b01 6699 "IPv6 prefix\n")
718e3744 6700{
b09b5ae0 6701 int idx_word = 3;
c500ae40 6702 int idx_safi = 5;
b09b5ae0 6703 int idx_ipv6_prefixlen = 7;
46f296b4
LB
6704 return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6,
6705 bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL);
718e3744 6706}
6707
b09b5ae0
DW
6708DEFUN (show_bgp_views,
6709 show_bgp_views_cmd,
d6e3c605 6710 "show [ip] bgp views",
b09b5ae0 6711 SHOW_STR
d6e3c605 6712 IP_STR
01080f7c 6713 BGP_STR
b09b5ae0 6714 "Show the defined BGP views\n")
01080f7c 6715{
b09b5ae0
DW
6716 struct list *inst = bm->bgp;
6717 struct listnode *node;
6718 struct bgp *bgp;
01080f7c 6719
b09b5ae0
DW
6720 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
6721 {
6722 vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE);
6723 return CMD_WARNING;
6724 }
e52702f2 6725
b09b5ae0
DW
6726 vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE);
6727 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
6728 {
6729 /* Skip VRFs. */
6730 if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF)
6731 continue;
6732 vty_out (vty, "\t%s (AS%u)%s",
6733 bgp->name ? bgp->name : "(null)",
6734 bgp->as, VTY_NEWLINE);
6735 }
e52702f2 6736
b09b5ae0 6737 return CMD_SUCCESS;
e0081f70
ML
6738}
6739
8386ac43 6740DEFUN (show_bgp_vrfs,
6741 show_bgp_vrfs_cmd,
d6e3c605 6742 "show [ip] bgp vrfs [json]",
8386ac43 6743 SHOW_STR
d6e3c605 6744 IP_STR
8386ac43 6745 BGP_STR
6746 "Show BGP VRFs\n"
9973d184 6747 JSON_STR)
8386ac43 6748{
6749 struct list *inst = bm->bgp;
6750 struct listnode *node;
6751 struct bgp *bgp;
6752 u_char uj = use_json(argc, argv);
6753 json_object *json = NULL;
6754 json_object *json_vrfs = NULL;
6755 int count = 0;
6756 static char header[] = "Type Id RouterId #PeersCfg #PeersEstb Name";
6757
6758 if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
6759 {
6760 vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE);
6761 return CMD_WARNING;
6762 }
6763
6764 if (uj)
6765 {
6766 json = json_object_new_object();
6767 json_vrfs = json_object_new_object();
6768 }
6769
6770 for (ALL_LIST_ELEMENTS_RO(inst, node, bgp))
6771 {
6772 const char *name, *type;
6773 struct peer *peer;
6774 struct listnode *node, *nnode;
6775 int peers_cfg, peers_estb;
6776 json_object *json_vrf = NULL;
5c81a5f3 6777 int vrf_id_ui;
8386ac43 6778
6779 /* Skip Views. */
6780 if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
6781 continue;
6782
6783 count++;
6784 if (!uj && count == 1)
6785 vty_out (vty, "%s%s", header, VTY_NEWLINE);
6786
6787 peers_cfg = peers_estb = 0;
6788 if (uj)
6789 json_vrf = json_object_new_object();
6790
6791
6792 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
6793 {
6794 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
6795 continue;
6796 peers_cfg++;
6797 if (peer->status == Established)
6798 peers_estb++;
6799 }
6800
6801 if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
6802 {
6803 name = "Default";
6804 type = "DFLT";
6805 }
6806 else
6807 {
6808 name = bgp->name;
6809 type = "VRF";
6810 }
6811
5c81a5f3 6812 vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id;
8386ac43 6813 if (uj)
6814 {
6815 json_object_string_add(json_vrf, "type", type);
5c81a5f3 6816 json_object_int_add(json_vrf, "vrfId", vrf_id_ui);
8386ac43 6817 json_object_string_add(json_vrf, "routerId", inet_ntoa (bgp->router_id));
6818 json_object_int_add(json_vrf, "numConfiguredPeers", peers_cfg);
6819 json_object_int_add(json_vrf, "numEstablishedPeers", peers_estb);
6820
6821 json_object_object_add(json_vrfs, name, json_vrf);
6822 }
6823 else
5c81a5f3 6824 vty_out (vty, "%4s %-5d %-16s %9u %10u %s%s",
6825 type, vrf_id_ui, inet_ntoa (bgp->router_id),
8386ac43 6826 peers_cfg, peers_estb, name,
6827 VTY_NEWLINE);
6828 }
6829
6830 if (uj)
6831 {
6832 json_object_object_add(json, "vrfs", json_vrfs);
6833
6834 json_object_int_add(json, "totalVrfs", count);
6835
2aac5767 6836 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
8386ac43 6837 json_object_free(json);
6838 }
6839 else
6840 {
6841 if (count)
6842 vty_out (vty, "%sTotal number of VRFs (including default): %d%s",
6843 VTY_NEWLINE, count, VTY_NEWLINE);
6844 }
6845
6846 return CMD_SUCCESS;
6847}
6848
f412b39a 6849DEFUN (show_bgp_memory,
4bf6a362 6850 show_bgp_memory_cmd,
7fa12b13 6851 "show [ip] bgp memory",
4bf6a362 6852 SHOW_STR
3a2d747c 6853 IP_STR
4bf6a362
PJ
6854 BGP_STR
6855 "Global BGP memory statistics\n")
6856{
6857 char memstrbuf[MTYPE_MEMSTR_LEN];
6858 unsigned long count;
e52702f2 6859
4bf6a362
PJ
6860 /* RIB related usage stats */
6861 count = mtype_stats_alloc (MTYPE_BGP_NODE);
6862 vty_out (vty, "%ld RIB nodes, using %s of memory%s", count,
6863 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6864 count * sizeof (struct bgp_node)),
6865 VTY_NEWLINE);
e52702f2 6866
4bf6a362
PJ
6867 count = mtype_stats_alloc (MTYPE_BGP_ROUTE);
6868 vty_out (vty, "%ld BGP routes, using %s of memory%s", count,
6869 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6870 count * sizeof (struct bgp_info)),
6871 VTY_NEWLINE);
fb982c25
PJ
6872 if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA)))
6873 vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count,
6874 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6875 count * sizeof (struct bgp_info_extra)),
6876 VTY_NEWLINE);
e52702f2 6877
4bf6a362
PJ
6878 if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC)))
6879 vty_out (vty, "%ld Static routes, using %s of memory%s", count,
6880 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6881 count * sizeof (struct bgp_static)),
6882 VTY_NEWLINE);
3f9c7369
DS
6883
6884 if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET)))
6885 vty_out (vty, "%ld Packets, using %s of memory%s", count,
6886 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6887 count * sizeof (struct bpacket)),
6888 VTY_NEWLINE);
e52702f2 6889
4bf6a362
PJ
6890 /* Adj-In/Out */
6891 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN)))
6892 vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count,
6893 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6894 count * sizeof (struct bgp_adj_in)),
6895 VTY_NEWLINE);
6896 if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT)))
6897 vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count,
6898 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6899 count * sizeof (struct bgp_adj_out)),
6900 VTY_NEWLINE);
e52702f2 6901
4bf6a362
PJ
6902 if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE)))
6903 vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count,
6904 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6905 count * sizeof (struct bgp_nexthop_cache)),
6906 VTY_NEWLINE);
6907
6908 if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO)))
6909 vty_out (vty, "%ld Dampening entries, using %s of memory%s", count,
6910 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6911 count * sizeof (struct bgp_damp_info)),
6912 VTY_NEWLINE);
6913
6914 /* Attributes */
6915 count = attr_count();
e52702f2
QY
6916 vty_out (vty, "%ld BGP attributes, using %s of memory%s", count,
6917 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6918 count * sizeof(struct attr)),
4bf6a362 6919 VTY_NEWLINE);
fb982c25 6920 if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA)))
e52702f2
QY
6921 vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count,
6922 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6923 count * sizeof(struct attr_extra)),
fb982c25 6924 VTY_NEWLINE);
e52702f2 6925
4bf6a362
PJ
6926 if ((count = attr_unknown_count()))
6927 vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE);
e52702f2 6928
4bf6a362
PJ
6929 /* AS_PATH attributes */
6930 count = aspath_count ();
6931 vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count,
6932 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6933 count * sizeof (struct aspath)),
6934 VTY_NEWLINE);
e52702f2 6935
4bf6a362
PJ
6936 count = mtype_stats_alloc (MTYPE_AS_SEG);
6937 vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count,
6938 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6939 count * sizeof (struct assegment)),
6940 VTY_NEWLINE);
e52702f2 6941
4bf6a362
PJ
6942 /* Other attributes */
6943 if ((count = community_count ()))
6944 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
6945 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6946 count * sizeof (struct community)),
6947 VTY_NEWLINE);
6948 if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY)))
6949 vty_out (vty, "%ld BGP community entries, using %s of memory%s", count,
6950 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6951 count * sizeof (struct ecommunity)),
6952 VTY_NEWLINE);
57d187bc
JS
6953 if ((count = mtype_stats_alloc (MTYPE_LCOMMUNITY)))
6954 vty_out (vty, "%ld BGP large-community entries, using %s of memory%s",
2acb4ac2 6955 count,
57d187bc
JS
6956 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6957 count * sizeof (struct lcommunity)),
6958 VTY_NEWLINE);
e52702f2 6959
4bf6a362
PJ
6960 if ((count = mtype_stats_alloc (MTYPE_CLUSTER)))
6961 vty_out (vty, "%ld Cluster lists, using %s of memory%s", count,
6962 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6963 count * sizeof (struct cluster_list)),
6964 VTY_NEWLINE);
e52702f2 6965
4bf6a362
PJ
6966 /* Peer related usage */
6967 count = mtype_stats_alloc (MTYPE_BGP_PEER);
6968 vty_out (vty, "%ld peers, using %s of memory%s", count,
6969 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6970 count * sizeof (struct peer)),
6971 VTY_NEWLINE);
e52702f2 6972
4a1ab8e4 6973 if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP)))
4bf6a362
PJ
6974 vty_out (vty, "%ld peer groups, using %s of memory%s", count,
6975 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6976 count * sizeof (struct peer_group)),
6977 VTY_NEWLINE);
e52702f2 6978
4bf6a362
PJ
6979 /* Other */
6980 if ((count = mtype_stats_alloc (MTYPE_HASH)))
6981 vty_out (vty, "%ld hash tables, using %s of memory%s", count,
6982 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6983 count * sizeof (struct hash)),
6984 VTY_NEWLINE);
6985 if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET)))
6986 vty_out (vty, "%ld hash buckets, using %s of memory%s", count,
6987 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6988 count * sizeof (struct hash_backet)),
6989 VTY_NEWLINE);
6990 if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP)))
6991 vty_out (vty, "%ld compiled regexes, using %s of memory%s", count,
6992 mtype_memstr (memstrbuf, sizeof (memstrbuf),
6993 count * sizeof (regex_t)),
6994 VTY_NEWLINE);
6995 return CMD_SUCCESS;
6996}
fee0f4c6 6997
718e3744 6998/* Show BGP peer's summary information. */
94f2b392 6999static int
b05a1c8b 7000bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi,
9f689658 7001 u_char use_json, json_object *json)
718e3744 7002{
7003 struct peer *peer;
1eb8ef25 7004 struct listnode *node, *nnode;
f14e6fdb
DS
7005 unsigned int count = 0, dn_count = 0;
7006 char timebuf[BGP_UPTIME_LEN], dn_flag[2];
f933309e
DW
7007 char neighbor_buf[VTY_BUFSIZ];
7008 int neighbor_col_default_width = 16;
718e3744 7009 int len;
f933309e 7010 int max_neighbor_width = 0;
ffd0c037
DS
7011 json_object *json_peer = NULL;
7012 json_object *json_peers = NULL;
718e3744 7013
b05a1c8b
DS
7014 if (use_json)
7015 {
9f689658
DD
7016 if (json == NULL)
7017 json = json_object_new_object();
7018
f1aa5d8a 7019 json_peers = json_object_new_object();
b05a1c8b 7020 }
f933309e
DW
7021 else
7022 {
7023 /* Loop over all neighbors that will be displayed to determine how many
7024 * characters are needed for the Neighbor column
7025 */
7026 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
7027 {
7028 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
7029 continue;
7030
7031 if (peer->afc[afi][safi])
7032 {
c9d5bd27
DS
7033 memset(dn_flag, '\0', sizeof(dn_flag));
7034 if (peer_dynamic_neighbor(peer))
7035 dn_flag[0] = '*';
7036
f933309e
DW
7037 if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME))
7038 sprintf(neighbor_buf, "%s%s(%s) ", dn_flag, peer->hostname, peer->host);
7039 else
7040 sprintf(neighbor_buf, "%s%s ", dn_flag, peer->host);
7041
7042 len = strlen(neighbor_buf);
7043
7044 if (len > max_neighbor_width)
7045 max_neighbor_width = len;
7046 }
7047 }
7048
7049 /* Originally we displayed the Neighbor column as 16
7050 * characters wide so make that the default
7051 */
7052 if (max_neighbor_width < neighbor_col_default_width)
7053 max_neighbor_width = neighbor_col_default_width;
7054 }
b05a1c8b 7055
1eb8ef25 7056 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
718e3744 7057 {
1ff9a340
DS
7058 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
7059 continue;
7060
718e3744 7061 if (peer->afc[afi][safi])
7062 {
b05a1c8b 7063 if (!count)
4bf6a362
PJ
7064 {
7065 unsigned long ents;
7066 char memstrbuf[MTYPE_MEMSTR_LEN];
5c81a5f3 7067 int vrf_id_ui;
7068
7069 vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id;
b05a1c8b 7070
4bf6a362 7071 /* Usage summary and header */
b05a1c8b
DS
7072 if (use_json)
7073 {
62d6dca0 7074 json_object_string_add(json, "routerId", inet_ntoa (bgp->router_id));
f1aa5d8a 7075 json_object_int_add(json, "as", bgp->as);
9f689658
DD
7076 json_object_int_add(json, "vrfId", vrf_id_ui);
7077 json_object_string_add(json, "vrfName",
7078 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
7079 ? "Default" : bgp->name);
b05a1c8b
DS
7080 }
7081 else
7082 {
7083 vty_out (vty,
5c81a5f3 7084 "BGP router identifier %s, local AS number %u vrf-id %d",
7085 inet_ntoa (bgp->router_id), bgp->as, vrf_id_ui);
6aeb9e78 7086 vty_out (vty, "%s", VTY_NEWLINE);
b05a1c8b
DS
7087 }
7088
f188f2c4
DS
7089 if (bgp_update_delay_configured(bgp))
7090 {
b05a1c8b 7091 if (use_json)
f188f2c4 7092 {
62d6dca0 7093 json_object_int_add(json, "updateDelayLimit", bgp->v_update_delay);
b05a1c8b
DS
7094
7095 if (bgp->v_update_delay != bgp->v_establish_wait)
62d6dca0 7096 json_object_int_add(json, "updateDelayEstablishWait", bgp->v_establish_wait);
b05a1c8b
DS
7097
7098 if (bgp_update_delay_active(bgp))
7099 {
62d6dca0
DS
7100 json_object_string_add(json, "updateDelayFirstNeighbor", bgp->update_delay_begin_time);
7101 json_object_boolean_true_add(json, "updateDelayInProgress");
b05a1c8b
DS
7102 }
7103 else
7104 {
7105 if (bgp->update_delay_over)
7106 {
62d6dca0 7107 json_object_string_add(json, "updateDelayFirstNeighbor",
f1aa5d8a 7108 bgp->update_delay_begin_time);
62d6dca0 7109 json_object_string_add(json, "updateDelayBestpathResumed",
f1aa5d8a 7110 bgp->update_delay_end_time);
62d6dca0 7111 json_object_string_add(json, "updateDelayZebraUpdateResume",
f1aa5d8a 7112 bgp->update_delay_zebra_resume_time);
62d6dca0 7113 json_object_string_add(json, "updateDelayPeerUpdateResume",
f1aa5d8a 7114 bgp->update_delay_peers_resume_time);
b05a1c8b
DS
7115 }
7116 }
f188f2c4
DS
7117 }
7118 else
7119 {
b05a1c8b
DS
7120 vty_out (vty, "Read-only mode update-delay limit: %d seconds%s",
7121 bgp->v_update_delay, VTY_NEWLINE);
7122 if (bgp->v_update_delay != bgp->v_establish_wait)
7123 vty_out (vty, " Establish wait: %d seconds%s",
7124 bgp->v_establish_wait, VTY_NEWLINE);
7125
7126 if (bgp_update_delay_active(bgp))
f188f2c4
DS
7127 {
7128 vty_out (vty, " First neighbor established: %s%s",
7129 bgp->update_delay_begin_time, VTY_NEWLINE);
b05a1c8b
DS
7130 vty_out (vty, " Delay in progress%s", VTY_NEWLINE);
7131 }
7132 else
7133 {
7134 if (bgp->update_delay_over)
7135 {
7136 vty_out (vty, " First neighbor established: %s%s",
7137 bgp->update_delay_begin_time, VTY_NEWLINE);
7138 vty_out (vty, " Best-paths resumed: %s%s",
7139 bgp->update_delay_end_time, VTY_NEWLINE);
7140 vty_out (vty, " zebra update resumed: %s%s",
7141 bgp->update_delay_zebra_resume_time, VTY_NEWLINE);
7142 vty_out (vty, " peers update resumed: %s%s",
7143 bgp->update_delay_peers_resume_time, VTY_NEWLINE);
7144 }
f188f2c4
DS
7145 }
7146 }
7147 }
4bf6a362 7148
b05a1c8b
DS
7149 if (use_json)
7150 {
7151 if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active)
62d6dca0 7152 json_object_boolean_true_add(json, "maxMedOnStartup");
b05a1c8b 7153 if (bgp->v_maxmed_admin)
62d6dca0 7154 json_object_boolean_true_add(json, "maxMedAdministrative");
b05a1c8b 7155
62d6dca0 7156 json_object_int_add(json, "tableVersion", bgp_table_version(bgp->rib[afi][safi]));
b05a1c8b
DS
7157
7158 ents = bgp_table_count (bgp->rib[afi][safi]);
62d6dca0
DS
7159 json_object_int_add(json, "ribCount", ents);
7160 json_object_int_add(json, "ribMemory", ents * sizeof (struct bgp_node));
b05a1c8b
DS
7161
7162 ents = listcount (bgp->peer);
62d6dca0
DS
7163 json_object_int_add(json, "peerCount", ents);
7164 json_object_int_add(json, "peerMemory", ents * sizeof (struct peer));
b05a1c8b 7165
b05a1c8b
DS
7166 if ((ents = listcount (bgp->group)))
7167 {
62d6dca0
DS
7168 json_object_int_add(json, "peerGroupCount", ents);
7169 json_object_int_add(json, "peerGroupMemory", ents * sizeof (struct peer_group));
b05a1c8b 7170 }
3f9c7369 7171
b05a1c8b 7172 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
62d6dca0 7173 json_object_boolean_true_add(json, "dampeningEnabled");
b05a1c8b
DS
7174 }
7175 else
7176 {
7177 if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active)
7178 vty_out (vty, "Max-med on-startup active%s", VTY_NEWLINE);
7179 if (bgp->v_maxmed_admin)
7180 vty_out (vty, "Max-med administrative active%s", VTY_NEWLINE);
7181
ffd0c037 7182 vty_out(vty, "BGP table version %" PRIu64 "%s",
b05a1c8b
DS
7183 bgp_table_version(bgp->rib[afi][safi]), VTY_NEWLINE);
7184
7185 ents = bgp_table_count (bgp->rib[afi][safi]);
7186 vty_out (vty, "RIB entries %ld, using %s of memory%s", ents,
7187 mtype_memstr (memstrbuf, sizeof (memstrbuf),
7188 ents * sizeof (struct bgp_node)),
7189 VTY_NEWLINE);
7190
7191 /* Peer related usage */
7192 ents = listcount (bgp->peer);
7193 vty_out (vty, "Peers %ld, using %s of memory%s",
7194 ents,
7195 mtype_memstr (memstrbuf, sizeof (memstrbuf),
7196 ents * sizeof (struct peer)),
7197 VTY_NEWLINE);
7198
b05a1c8b
DS
7199 if ((ents = listcount (bgp->group)))
7200 vty_out (vty, "Peer groups %ld, using %s of memory%s", ents,
7201 mtype_memstr (memstrbuf, sizeof (memstrbuf),
7202 ents * sizeof (struct peer_group)),
7203 VTY_NEWLINE);
7204
7205 if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
7206 vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE);
7207 vty_out (vty, "%s", VTY_NEWLINE);
f933309e
DW
7208
7209 /* Subtract 8 here because 'Neighbor' is 8 characters */
7210 vty_out (vty, "Neighbor");
7211 vty_out (vty, "%*s", max_neighbor_width - 8, " ");
7212 vty_out (vty, "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd%s", VTY_NEWLINE);
b05a1c8b 7213 }
4bf6a362 7214 }
e52702f2 7215
b05a1c8b 7216 count++;
718e3744 7217
b05a1c8b
DS
7218 if (use_json)
7219 {
7220 json_peer = json_object_new_object();
f14e6fdb 7221
b05a1c8b 7222 if (peer_dynamic_neighbor(peer))
62d6dca0 7223 json_object_boolean_true_add(json_peer, "dynamicPeer");
b05a1c8b 7224
04b6bdc0
DW
7225 if (peer->hostname)
7226 json_object_string_add(json_peer, "hostname", peer->hostname);
7227
7228 if (peer->domainname)
7229 json_object_string_add(json_peer, "domainname", peer->domainname);
7230
62d6dca0 7231 json_object_int_add(json_peer, "remoteAs", peer->as);
f1aa5d8a 7232 json_object_int_add(json_peer, "version", 4);
62d6dca0 7233 json_object_int_add(json_peer, "msgRcvd",
f1aa5d8a
DS
7234 peer->open_in + peer->update_in + peer->keepalive_in
7235 + peer->notify_in + peer->refresh_in
7236 + peer->dynamic_cap_in);
62d6dca0 7237 json_object_int_add(json_peer, "msgSent",
f1aa5d8a
DS
7238 peer->open_out + peer->update_out + peer->keepalive_out
7239 + peer->notify_out + peer->refresh_out
7240 + peer->dynamic_cap_out);
7241
62d6dca0 7242 json_object_int_add(json_peer, "tableVersion", peer->version[afi][safi]);
f1aa5d8a
DS
7243 json_object_int_add(json_peer, "outq", peer->obuf->count);
7244 json_object_int_add(json_peer, "inq", 0);
856ca177 7245 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer);
62d6dca0 7246 json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][safi]);
b05a1c8b
DS
7247
7248 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
f1aa5d8a 7249 json_object_string_add(json_peer, "state", "Idle (Admin)");
b05a1c8b 7250 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
f1aa5d8a 7251 json_object_string_add(json_peer, "state", "Idle (PfxCt)");
b05a1c8b 7252 else
f1aa5d8a 7253 json_object_string_add(json_peer, "state", LOOKUP(bgp_status_msg, peer->status));
b05a1c8b 7254
f1aa5d8a 7255 if (peer->conf_if)
62d6dca0 7256 json_object_string_add(json_peer, "idType", "interface");
f1aa5d8a 7257 else if (peer->su.sa.sa_family == AF_INET)
62d6dca0 7258 json_object_string_add(json_peer, "idType", "ipv4");
f1aa5d8a 7259 else if (peer->su.sa.sa_family == AF_INET6)
62d6dca0 7260 json_object_string_add(json_peer, "idType", "ipv6");
b05a1c8b 7261
f1aa5d8a 7262 json_object_object_add(json_peers, peer->host, json_peer);
b05a1c8b
DS
7263 }
7264 else
7265 {
7266 memset(dn_flag, '\0', sizeof(dn_flag));
7267 if (peer_dynamic_neighbor(peer))
7268 {
7269 dn_count++;
7270 dn_flag[0] = '*';
7271 }
7272
04b6bdc0
DW
7273 if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME))
7274 len = vty_out (vty, "%s%s(%s)", dn_flag, peer->hostname,
7275 peer->host);
7276 else
7277 len = vty_out (vty, "%s%s", dn_flag, peer->host);
b05a1c8b 7278
f933309e
DW
7279 /* pad the neighbor column with spaces */
7280 if (len < max_neighbor_width)
7281 vty_out (vty, "%*s", max_neighbor_width - len, " ");
b05a1c8b 7282
f933309e 7283 vty_out (vty, "4 %10u %7d %7d %8" PRIu64 " %4d %4zd %8s",
b05a1c8b
DS
7284 peer->as,
7285 peer->open_in + peer->update_in + peer->keepalive_in
7286 + peer->notify_in + peer->refresh_in
7287 + peer->dynamic_cap_in,
7288 peer->open_out + peer->update_out + peer->keepalive_out
7289 + peer->notify_out + peer->refresh_out
7290 + peer->dynamic_cap_out,
7291 peer->version[afi][safi],
7292 0,
f933309e 7293 peer->obuf->count,
856ca177 7294 peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL));
b05a1c8b
DS
7295
7296 if (peer->status == Established)
46f8c104 7297 vty_out (vty, " %12ld", peer->pcount[afi][safi]);
b05a1c8b
DS
7298 else
7299 {
7300 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
7301 vty_out (vty, " Idle (Admin)");
7302 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
7303 vty_out (vty, " Idle (PfxCt)");
7304 else
f933309e 7305 vty_out (vty, " %12s", LOOKUP(bgp_status_msg, peer->status));
b05a1c8b
DS
7306 }
7307 vty_out (vty, "%s", VTY_NEWLINE);
7308 }
718e3744 7309 }
7310 }
7311
b05a1c8b
DS
7312 if (use_json)
7313 {
7314 json_object_object_add(json, "peers", json_peers);
14151a32 7315
62d6dca0
DS
7316 json_object_int_add(json, "totalPeers", count);
7317 json_object_int_add(json, "dynamicPeers", dn_count);
14151a32 7318
2aac5767 7319 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
f1aa5d8a 7320 json_object_free(json);
b05a1c8b
DS
7321 }
7322 else
f14e6fdb 7323 {
b05a1c8b
DS
7324 if (count)
7325 vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE,
7326 count, VTY_NEWLINE);
7327 else
9f689658
DD
7328 {
7329 if (use_json)
7330 vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}%s",
46f296b4 7331 afi_safi_print(afi, safi), VTY_NEWLINE);
9f689658
DD
7332 else
7333 vty_out (vty, "No %s neighbor is configured%s",
46f296b4 7334 afi_safi_print(afi, safi), VTY_NEWLINE);
9f689658 7335 }
b05a1c8b 7336
9f689658 7337 if (dn_count && ! use_json)
b05a1c8b
DS
7338 {
7339 vty_out(vty, "* - dynamic neighbor%s", VTY_NEWLINE);
7340 vty_out(vty,
7341 "%d dynamic neighbor(s), limit %d%s",
7342 dn_count, bgp->dynamic_neighbors_limit, VTY_NEWLINE);
7343 }
f14e6fdb
DS
7344 }
7345
718e3744 7346 return CMD_SUCCESS;
7347}
7348
798c3572
DS
7349/*
7350 * Return if we have a peer configured to use this afi/safi
7351 */
7352static int
7353bgp_show_summary_afi_safi_peer_exists (struct bgp *bgp, int afi, int safi)
7354{
7355 struct listnode *node;
7356 struct peer *peer;
7357
7358 for (ALL_LIST_ELEMENTS_RO (bgp->peer, node, peer))
7359 {
7360 if (!CHECK_FLAG (peer->flags, PEER_FLAG_CONFIG_NODE))
7361 continue;
7362
7363 if (peer->afc[afi][safi])
7364 return 1;
7365 }
7366
7367 return 0;
7368}
7369
27162734
LB
7370static void
7371bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi,
7372 u_char use_json, json_object *json)
7373{
7374 int is_first = 1;
7375 int afi_wildcard = (afi == AFI_MAX);
7376 int safi_wildcard = (safi == SAFI_MAX);
7377 int is_wildcard = (afi_wildcard || safi_wildcard);
5ce77b2b 7378 bool json_output = false;
798c3572 7379
27162734
LB
7380 if (use_json && is_wildcard)
7381 vty_out (vty, "{%s", VTY_NEWLINE);
7382 if (afi_wildcard)
7383 afi = 1; /* AFI_IP */
7384 while (afi < AFI_MAX)
7385 {
7386 if (safi_wildcard)
7387 safi = 1; /* SAFI_UNICAST */
7388 while (safi < SAFI_MAX)
7389 {
798c3572 7390 if (bgp_show_summary_afi_safi_peer_exists (bgp, afi, safi))
27162734 7391 {
5ce77b2b 7392 json_output = true;
798c3572 7393 if (is_wildcard)
27162734 7394 {
798c3572
DS
7395 /*
7396 * So limit output to those afi/safi pairs that
7397 * actualy have something interesting in them
7398 */
7399 if (use_json)
7400 {
7401 json = json_object_new_object();
27162734 7402
798c3572
DS
7403 if (! is_first)
7404 vty_out (vty, ",%s", VTY_NEWLINE);
7405 else
7406 is_first = 0;
27162734 7407
798c3572
DS
7408 vty_out(vty, "\"%s\":", afi_safi_json(afi, safi));
7409 }
7410 else
7411 {
7412 vty_out (vty, "%s%s Summary:%s",
7413 VTY_NEWLINE, afi_safi_print(afi, safi), VTY_NEWLINE);
7414 }
27162734 7415 }
798c3572 7416 bgp_show_summary (vty, bgp, afi, safi, use_json, json);
27162734 7417 }
f62a5c33
LB
7418 safi++;
7419 if (safi == SAFI_RESERVED_4 ||
7420 safi == SAFI_RESERVED_5) /* handle special cases to match zebra.h */
7421 safi++;
27162734
LB
7422 if (! safi_wildcard)
7423 safi = SAFI_MAX;
7424 }
7425 afi++;
7426 if (! afi_wildcard ||
5ef6cd69 7427 afi == AFI_L2VPN) /* special case, not handled yet */
27162734
LB
7428 afi = AFI_MAX;
7429 }
7430
7431 if (use_json && is_wildcard)
7432 vty_out (vty, "}%s", VTY_NEWLINE);
5ce77b2b
DS
7433 else if (use_json && !json_output)
7434 vty_out (vty, "{}%s", VTY_NEWLINE);
27162734
LB
7435}
7436
f186de26 7437static void
7438bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi,
7439 u_char use_json)
7440{
7441 struct listnode *node, *nnode;
7442 struct bgp *bgp;
9f689658
DD
7443 json_object *json = NULL;
7444 int is_first = 1;
7445
7446 if (use_json)
7447 vty_out (vty, "{%s", VTY_NEWLINE);
f186de26 7448
7449 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
7450 {
9f689658
DD
7451 if (use_json)
7452 {
4fb25c53 7453 json = json_object_new_object();
9f689658
DD
7454
7455 if (! is_first)
7456 vty_out (vty, ",%s", VTY_NEWLINE);
7457 else
7458 is_first = 0;
7459
7460 vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
7461 ? "Default" : bgp->name);
7462 }
7463 else
7464 {
7465 vty_out (vty, "%sInstance %s:%s",
7466 VTY_NEWLINE,
7467 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
7468 ? "Default" : bgp->name, VTY_NEWLINE);
7469 }
27162734 7470 bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, json);
f186de26 7471 }
9f689658
DD
7472
7473 if (use_json)
7474 vty_out (vty, "}%s", VTY_NEWLINE);
7475
f186de26 7476}
7477
4fb25c53
DW
7478static int
7479bgp_show_summary_vty (struct vty *vty, const char *name,
7480 afi_t afi, safi_t safi, u_char use_json)
7481{
7482 struct bgp *bgp;
7483
7484 if (name)
7485 {
7486 if (strmatch(name, "all"))
7487 {
7488 bgp_show_all_instances_summary_vty (vty, afi, safi, use_json);
7489 return CMD_SUCCESS;
7490 }
7491 else
7492 {
7493 bgp = bgp_lookup_by_name (name);
7494
7495 if (! bgp)
7496 {
7497 if (use_json)
7498 vty_out (vty, "{}%s", VTY_NEWLINE);
7499 else
7500 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
7501 return CMD_WARNING;
7502 }
7503
27162734 7504 bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL);
4fb25c53
DW
7505 return CMD_SUCCESS;
7506 }
7507 }
7508
7509 bgp = bgp_get_default ();
7510
7511 if (bgp)
27162734 7512 bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL);
4fb25c53
DW
7513
7514 return CMD_SUCCESS;
7515}
7516
716b2d8a 7517/* `show [ip] bgp summary' commands. */
47fc97cc 7518DEFUN (show_ip_bgp_summary,
718e3744 7519 show_ip_bgp_summary_cmd,
46f296b4 7520 "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] summary [json]",
718e3744 7521 SHOW_STR
7522 IP_STR
7523 BGP_STR
8386ac43 7524 BGP_INSTANCE_HELP_STR
46f296b4
LB
7525 BGP_AFI_HELP_STR
7526 BGP_SAFI_HELP_STR
b05a1c8b 7527 "Summary of BGP neighbor status\n"
9973d184 7528 JSON_STR)
718e3744 7529{
74ca3d33 7530 char *vrf = NULL;
27162734
LB
7531 afi_t afi = AFI_MAX;
7532 safi_t safi = SAFI_MAX;
ae19d7dd
QY
7533
7534 int idx = 0;
7535
7536 /* show [ip] bgp */
7537 if (argv_find (argv, argc, "ip", &idx))
7538 afi = AFI_IP;
7539 /* [<view|vrf> WORD] */
7540 if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx))
7541 vrf = argv[++idx]->arg;
46f296b4
LB
7542 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7543 if (argv_find_and_parse_afi (argv, argc, &idx, &afi))
ae19d7dd 7544 {
46f296b4 7545 argv_find_and_parse_safi (argv, argc, &idx, &safi);
91d37724
QY
7546 }
7547
ae19d7dd 7548 int uj = use_json (argc, argv);
74ca3d33
DW
7549
7550 return bgp_show_summary_vty (vty, vrf, afi, safi, uj);
718e3744 7551}
7552
fd79ac91 7553const char *
538621f2 7554afi_safi_print (afi_t afi, safi_t safi)
7555{
7556 if (afi == AFI_IP && safi == SAFI_UNICAST)
7557 return "IPv4 Unicast";
7558 else if (afi == AFI_IP && safi == SAFI_MULTICAST)
7559 return "IPv4 Multicast";
b60f5275
DS
7560 else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST)
7561 return "IPv4 labeled-unicast";
538621f2 7562 else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
46f296b4 7563 return "IPv4 VPN";
8b1fb8be 7564 else if (afi == AFI_IP && safi == SAFI_ENCAP)
46f296b4 7565 return "IPv4 Encap";
538621f2 7566 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
7567 return "IPv6 Unicast";
7568 else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
7569 return "IPv6 Multicast";
b60f5275
DS
7570 else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST)
7571 return "IPv6 labeled-unicast";
945c8fe9 7572 else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN)
46f296b4 7573 return "IPv6 VPN";
8b1fb8be 7574 else if (afi == AFI_IP6 && safi == SAFI_ENCAP)
46f296b4 7575 return "IPv6 Encap";
3d6c0dfa
PG
7576 else if (afi == AFI_L2VPN && safi == SAFI_EVPN)
7577 return "L2VPN EVPN";
538621f2 7578 else
7579 return "Unknown";
7580}
7581
b9f77ec8
DS
7582/*
7583 * Please note that we have intentionally camelCased
7584 * the return strings here. So if you want
7585 * to use this function, please ensure you
7586 * are doing this within json output
7587 */
27162734
LB
7588const char *
7589afi_safi_json (afi_t afi, safi_t safi)
7590{
7591 if (afi == AFI_IP && safi == SAFI_UNICAST)
b9f77ec8 7592 return "ipv4Unicast";
27162734 7593 else if (afi == AFI_IP && safi == SAFI_MULTICAST)
b9f77ec8 7594 return "ipv4Multicast";
b60f5275 7595 else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST)
05ba625a 7596 return "ipv4LabeledUnicast";
27162734 7597 else if (afi == AFI_IP && safi == SAFI_MPLS_VPN)
b9f77ec8 7598 return "ipv4Vpn";
27162734 7599 else if (afi == AFI_IP && safi == SAFI_ENCAP)
b9f77ec8 7600 return "ipv4Encap";
27162734 7601 else if (afi == AFI_IP6 && safi == SAFI_UNICAST)
b9f77ec8 7602 return "ipv6Unicast";
27162734 7603 else if (afi == AFI_IP6 && safi == SAFI_MULTICAST)
b9f77ec8 7604 return "ipv6Multicast";
b60f5275 7605 else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST)
05ba625a 7606 return "ipv6LabeledUnicast";
27162734 7607 else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN)
b9f77ec8 7608 return "ipv6Vpn";
27162734 7609 else if (afi == AFI_IP6 && safi == SAFI_ENCAP)
b9f77ec8 7610 return "ipv6Encap";
3d6c0dfa 7611 else if (afi == AFI_L2VPN && safi == SAFI_EVPN)
b9f77ec8 7612 return "l2VpnEvpn";
27162734
LB
7613 else
7614 return "Unknown";
7615}
7616
718e3744 7617/* Show BGP peer's information. */
7618enum show_type
7619{
7620 show_all,
7621 show_peer
7622};
7623
94f2b392 7624static void
856ca177
MS
7625bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
7626 u_int16_t adv_smcap, u_int16_t adv_rmcap, u_int16_t rcv_smcap,
7627 u_int16_t rcv_rmcap, u_char use_json, json_object *json_pref)
718e3744 7628{
7629 /* Send-Mode */
7630 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)
7631 || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
7632 {
856ca177
MS
7633 if (use_json)
7634 {
7635 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
7636 json_object_string_add(json_pref, "sendMode", "advertisedAndReceived");
7637 else if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
7638 json_object_string_add(json_pref, "sendMode", "advertised");
7639 else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
7640 json_object_string_add(json_pref, "sendMode", "received");
7641 }
7642 else
7643 {
7644 vty_out (vty, " Send-mode: ");
7645 if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap))
7646 vty_out (vty, "advertised");
7647 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap))
7648 vty_out (vty, "%sreceived",
7649 CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ?
7650 ", " : "");
7651 vty_out (vty, "%s", VTY_NEWLINE);
7652 }
718e3744 7653 }
7654
7655 /* Receive-Mode */
7656 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)
7657 || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
7658 {
856ca177
MS
7659 if (use_json)
7660 {
7661 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
7662 json_object_string_add(json_pref, "recvMode", "advertisedAndReceived");
7663 else if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
7664 json_object_string_add(json_pref, "recvMode", "advertised");
7665 else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
7666 json_object_string_add(json_pref, "recvMode", "received");
7667 }
7668 else
7669 {
7670 vty_out (vty, " Receive-mode: ");
7671 if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap))
7672 vty_out (vty, "advertised");
7673 if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap))
7674 vty_out (vty, "%sreceived",
7675 CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ?
7676 ", " : "");
7677 vty_out (vty, "%s", VTY_NEWLINE);
7678 }
718e3744 7679 }
7680}
7681
94f2b392 7682static void
856ca177
MS
7683bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi,
7684 u_char use_json, json_object *json_neigh)
718e3744 7685{
7686 struct bgp_filter *filter;
3f9c7369 7687 struct peer_af *paf;
718e3744 7688 char orf_pfx_name[BUFSIZ];
7689 int orf_pfx_count;
856ca177
MS
7690 json_object *json_af = NULL;
7691 json_object *json_prefA = NULL;
7692 json_object *json_prefB = NULL;
7693 json_object *json_addr = NULL;
718e3744 7694
856ca177
MS
7695 if (use_json)
7696 {
7697 json_addr = json_object_new_object();
7698 json_af = json_object_new_object();
856ca177 7699 filter = &p->filter[afi][safi];
718e3744 7700
c8560b44 7701 if (peer_group_active(p))
856ca177 7702 json_object_string_add(json_addr, "peerGroupMember", p->group->name);
538621f2 7703
856ca177
MS
7704 paf = peer_af_find(p, afi, safi);
7705 if (paf && PAF_SUBGRP(paf))
7706 {
7707 json_object_int_add(json_addr, "updateGroupId", PAF_UPDGRP(paf)->id);
7708 json_object_int_add(json_addr, "subGroupId", PAF_SUBGRP(paf)->id);
7709 json_object_int_add(json_addr, "packetQueueLength", bpacket_queue_virtual_length(paf));
7710 }
7711
7712 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7713 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
7714 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7715 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
7716 {
7717 json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX);
b6df4090 7718 json_prefA = json_object_new_object();
856ca177
MS
7719 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
7720 PEER_CAP_ORF_PREFIX_SM_ADV,
7721 PEER_CAP_ORF_PREFIX_RM_ADV,
7722 PEER_CAP_ORF_PREFIX_SM_RCV,
7723 PEER_CAP_ORF_PREFIX_RM_RCV, use_json, json_prefA);
7724 json_object_object_add(json_af, "orfPrefixList", json_prefA);
7725 }
7726
7727 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7728 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
7729 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7730 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
7731 {
7732 json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD);
b6df4090 7733 json_prefB = json_object_new_object();
856ca177
MS
7734 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
7735 PEER_CAP_ORF_PREFIX_SM_ADV,
7736 PEER_CAP_ORF_PREFIX_RM_ADV,
7737 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
7738 PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, json_prefB);
7739 json_object_object_add(json_af, "orfOldPrefixList", json_prefB);
7740 }
7741
7742 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7743 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
7744 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
7745 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7746 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
7747 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
7748 json_object_object_add(json_addr, "afDependentCap", json_af);
b6df4090
DS
7749 else
7750 json_object_free(json_af);
856ca177
MS
7751
7752 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
7753 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json);
7754
7755 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
7756 || orf_pfx_count)
7757 {
7758 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
7759 json_object_boolean_true_add(json_neigh, "orfSent");
7760 if (orf_pfx_count)
7761 json_object_int_add(json_addr, "orfRecvCounter", orf_pfx_count);
7762 }
7763 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
7764 json_object_string_add(json_addr, "orfFirstUpdate", "deferredUntilORFOrRouteRefreshRecvd");
7765
7766 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
7767 json_object_boolean_true_add(json_addr, "routeReflectorClient");
7768 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
7769 json_object_boolean_true_add(json_addr, "routeServerClient");
7770 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
7771 json_object_boolean_true_add(json_addr, "inboundSoftConfigPermit");
7772
88b8ed8d
DW
7773 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE))
7774 json_object_boolean_true_add(json_addr, "privateAsNumsAllReplacedInUpdatesToNbr");
7775 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE))
856ca177 7776 json_object_boolean_true_add(json_addr, "privateAsNumsReplacedInUpdatesToNbr");
88b8ed8d
DW
7777 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL))
7778 json_object_boolean_true_add(json_addr, "privateAsNumsAllRemovedInUpdatesToNbr");
856ca177
MS
7779 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
7780 json_object_boolean_true_add(json_addr, "privateAsNumsRemovedInUpdatesToNbr");
7781
adbac85e
DW
7782 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS))
7783 json_object_boolean_true_add(json_addr, "addpathTxAllPaths");
7784
06370dac
DW
7785 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
7786 json_object_boolean_true_add(json_addr, "addpathTxBestpathPerAS");
7787
856ca177
MS
7788 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE))
7789 json_object_string_add(json_addr, "overrideASNsInOutboundUpdates", "ifAspathEqualRemoteAs");
7790
7791 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) ||
7792 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF))
7793 json_object_boolean_true_add(json_addr, "routerAlwaysNextHop");
7794 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
7795 json_object_boolean_true_add(json_addr, "unchangedAsPathPropogatedToNbr");
7796 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
7797 json_object_boolean_true_add(json_addr, "unchangedNextHopPropogatedToNbr");
7798 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
7799 json_object_boolean_true_add(json_addr, "unchangedMedPropogatedToNbr");
718e3744 7800 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
856ca177
MS
7801 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
7802 {
7803 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
7804 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
7805 json_object_string_add(json_addr, "commAttriSentToNbr", "extendedAndStandard");
7806 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
7807 json_object_string_add(json_addr, "commAttriSentToNbr", "extended");
7808 else
7809 json_object_string_add(json_addr, "commAttriSentToNbr", "standard");
7810 }
7811 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
7812 {
7813 if (p->default_rmap[afi][safi].name)
7814 json_object_string_add(json_addr, "defaultRouteMap", p->default_rmap[afi][safi].name);
7815
7816 if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE))
7817 json_object_boolean_true_add(json_addr, "defaultSent");
7818 else
7819 json_object_boolean_true_add(json_addr, "defaultNotSent");
7820 }
7821
7822 if (filter->plist[FILTER_IN].name
7823 || filter->dlist[FILTER_IN].name
7824 || filter->aslist[FILTER_IN].name
7825 || filter->map[RMAP_IN].name)
7826 json_object_boolean_true_add(json_addr, "inboundPathPolicyConfig");
7827 if (filter->plist[FILTER_OUT].name
7828 || filter->dlist[FILTER_OUT].name
7829 || filter->aslist[FILTER_OUT].name
7830 || filter->map[RMAP_OUT].name
7831 || filter->usmap.name)
7832 json_object_boolean_true_add(json_addr, "outboundPathPolicyConfig");
856ca177
MS
7833
7834 /* prefix-list */
7835 if (filter->plist[FILTER_IN].name)
7836 json_object_string_add(json_addr, "incomingUpdatePrefixFilterList", filter->plist[FILTER_IN].name);
7837 if (filter->plist[FILTER_OUT].name)
7838 json_object_string_add(json_addr, "outgoingUpdatePrefixFilterList", filter->plist[FILTER_OUT].name);
7839
7840 /* distribute-list */
7841 if (filter->dlist[FILTER_IN].name)
7842 json_object_string_add(json_addr, "incomingUpdateNetworkFilterList", filter->dlist[FILTER_IN].name);
7843 if (filter->dlist[FILTER_OUT].name)
7844 json_object_string_add(json_addr, "outgoingUpdateNetworkFilterList", filter->dlist[FILTER_OUT].name);
7845
7846 /* filter-list. */
7847 if (filter->aslist[FILTER_IN].name)
7848 json_object_string_add(json_addr, "incomingUpdateAsPathFilterList", filter->aslist[FILTER_IN].name);
7849 if (filter->aslist[FILTER_OUT].name)
7850 json_object_string_add(json_addr, "outgoingUpdateAsPathFilterList", filter->aslist[FILTER_OUT].name);
7851
7852 /* route-map. */
7853 if (filter->map[RMAP_IN].name)
7854 json_object_string_add(json_addr, "routeMapForIncomingAdvertisements", filter->map[RMAP_IN].name);
7855 if (filter->map[RMAP_OUT].name)
7856 json_object_string_add(json_addr, "routeMapForOutgoingAdvertisements", filter->map[RMAP_OUT].name);
856ca177
MS
7857
7858 /* unsuppress-map */
7859 if (filter->usmap.name)
7860 json_object_string_add(json_addr, "selectiveUnsuppressRouteMap", filter->usmap.name);
7861
7862 /* Receive prefix count */
7863 json_object_int_add(json_addr, "acceptedPrefixCounter", p->pcount[afi][safi]);
7864
7865 /* Maximum prefix */
7866 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
7867 {
7868 json_object_int_add(json_addr, "prefixAllowedMax", p->pmax[afi][safi]);
7869 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING))
7870 json_object_boolean_true_add(json_addr, "prefixAllowedMaxWarning");
7871 json_object_int_add(json_addr, "prefixAllowedWarningThresh", p->pmax_threshold[afi][safi]);
7872 if (p->pmax_restart[afi][safi])
7873 json_object_int_add(json_addr, "prefixAllowedRestartIntervalMsecs", p->pmax_restart[afi][safi] * 60000);
7874 }
7875 json_object_object_add(json_neigh, afi_safi_print (afi, safi), json_addr);
7876
7877 }
7878 else
7879 {
7880 filter = &p->filter[afi][safi];
7881
7882 vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi),
7883 VTY_NEWLINE);
7884
c8560b44 7885 if (peer_group_active(p))
856ca177
MS
7886 vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE);
7887
7888 paf = peer_af_find(p, afi, safi);
7889 if (paf && PAF_SUBGRP(paf))
7890 {
7891 vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "%s",
7892 PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTY_NEWLINE);
7893 vty_out (vty, " Packet Queue length %d%s",
7894 bpacket_queue_virtual_length(paf), VTY_NEWLINE);
7895 }
718e3744 7896 else
856ca177
MS
7897 {
7898 vty_out(vty, " Not part of any update group%s", VTY_NEWLINE);
7899 }
7900 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7901 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
7902 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
7903 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7904 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)
7905 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
7906 vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE);
7907
7908 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7909 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV)
7910 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7911 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV))
7912 {
7913 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
7914 ORF_TYPE_PREFIX, VTY_NEWLINE);
7915 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
7916 PEER_CAP_ORF_PREFIX_SM_ADV,
7917 PEER_CAP_ORF_PREFIX_RM_ADV,
7918 PEER_CAP_ORF_PREFIX_SM_RCV,
7919 PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL);
7920 }
7921 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV)
7922 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV)
7923 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV)
7924 || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV))
7925 {
7926 vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s",
7927 ORF_TYPE_PREFIX_OLD, VTY_NEWLINE);
7928 bgp_show_peer_afi_orf_cap (vty, p, afi, safi,
7929 PEER_CAP_ORF_PREFIX_SM_ADV,
7930 PEER_CAP_ORF_PREFIX_RM_ADV,
7931 PEER_CAP_ORF_PREFIX_SM_OLD_RCV,
7932 PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL);
7933 }
718e3744 7934
856ca177
MS
7935 sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi);
7936 orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json);
718e3744 7937
856ca177
MS
7938 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)
7939 || orf_pfx_count)
7940 {
7941 vty_out (vty, " Outbound Route Filter (ORF):");
7942 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND))
7943 vty_out (vty, " sent;");
7944 if (orf_pfx_count)
7945 vty_out (vty, " received (%d entries)", orf_pfx_count);
7946 vty_out (vty, "%s", VTY_NEWLINE);
7947 }
7948 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH))
7949 vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE);
7950
7951 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT))
7952 vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE);
7953 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
7954 vty_out (vty, " Route-Server Client%s", VTY_NEWLINE);
7955 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
7956 vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE);
7957
88b8ed8d
DW
7958 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE))
7959 vty_out (vty, " Private AS numbers (all) replaced in updates to this neighbor%s", VTY_NEWLINE);
7960 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE))
856ca177 7961 vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE);
88b8ed8d
DW
7962 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL))
7963 vty_out (vty, " Private AS numbers (all) removed in updates to this neighbor%s", VTY_NEWLINE);
856ca177
MS
7964 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
7965 vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTY_NEWLINE);
7966
adbac85e
DW
7967 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS))
7968 vty_out (vty, " Advertise all paths via addpath%s", VTY_NEWLINE);
7969
06370dac
DW
7970 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS))
7971 vty_out (vty, " Advertise bestpath per AS via addpath%s", VTY_NEWLINE);
7972
856ca177
MS
7973 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE))
7974 vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE);
7975
7976 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) ||
7977 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF))
7978 vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE);
7979 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
7980 vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7981 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED))
7982 vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7983 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED))
7984 vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE);
7985 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
57d187bc
JS
7986 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)
7987 || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY))
856ca177
MS
7988 {
7989 vty_out (vty, " Community attribute sent to this neighbor");
7990 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
57d187bc
JS
7991 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)
7992 && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY))
7993 vty_out (vty, "(all)%s", VTY_NEWLINE);
7994 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_LARGE_COMMUNITY))
7995 vty_out (vty, "(large)%s", VTY_NEWLINE);
856ca177
MS
7996 else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY))
7997 vty_out (vty, "(extended)%s", VTY_NEWLINE);
7998 else
7999 vty_out (vty, "(standard)%s", VTY_NEWLINE);
8000 }
8001 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE))
8002 {
8003 vty_out (vty, " Default information originate,");
8004
8005 if (p->default_rmap[afi][safi].name)
8006 vty_out (vty, " default route-map %s%s,",
8007 p->default_rmap[afi][safi].map ? "*" : "",
8008 p->default_rmap[afi][safi].name);
8009 if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE))
8010 vty_out (vty, " default sent%s", VTY_NEWLINE);
8011 else
8012 vty_out (vty, " default not sent%s", VTY_NEWLINE);
8013 }
718e3744 8014
856ca177
MS
8015 if (filter->plist[FILTER_IN].name
8016 || filter->dlist[FILTER_IN].name
8017 || filter->aslist[FILTER_IN].name
8018 || filter->map[RMAP_IN].name)
8019 vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE);
8020 if (filter->plist[FILTER_OUT].name
8021 || filter->dlist[FILTER_OUT].name
8022 || filter->aslist[FILTER_OUT].name
8023 || filter->map[RMAP_OUT].name
8024 || filter->usmap.name)
8025 vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE);
856ca177
MS
8026
8027 /* prefix-list */
8028 if (filter->plist[FILTER_IN].name)
8029 vty_out (vty, " Incoming update prefix filter list is %s%s%s",
8030 filter->plist[FILTER_IN].plist ? "*" : "",
8031 filter->plist[FILTER_IN].name,
8032 VTY_NEWLINE);
8033 if (filter->plist[FILTER_OUT].name)
8034 vty_out (vty, " Outgoing update prefix filter list is %s%s%s",
8035 filter->plist[FILTER_OUT].plist ? "*" : "",
8036 filter->plist[FILTER_OUT].name,
8037 VTY_NEWLINE);
8038
8039 /* distribute-list */
8040 if (filter->dlist[FILTER_IN].name)
8041 vty_out (vty, " Incoming update network filter list is %s%s%s",
8042 filter->dlist[FILTER_IN].alist ? "*" : "",
8043 filter->dlist[FILTER_IN].name,
8044 VTY_NEWLINE);
8045 if (filter->dlist[FILTER_OUT].name)
8046 vty_out (vty, " Outgoing update network filter list is %s%s%s",
8047 filter->dlist[FILTER_OUT].alist ? "*" : "",
8048 filter->dlist[FILTER_OUT].name,
8049 VTY_NEWLINE);
8050
8051 /* filter-list. */
8052 if (filter->aslist[FILTER_IN].name)
8053 vty_out (vty, " Incoming update AS path filter list is %s%s%s",
8054 filter->aslist[FILTER_IN].aslist ? "*" : "",
8055 filter->aslist[FILTER_IN].name,
8056 VTY_NEWLINE);
8057 if (filter->aslist[FILTER_OUT].name)
8058 vty_out (vty, " Outgoing update AS path filter list is %s%s%s",
8059 filter->aslist[FILTER_OUT].aslist ? "*" : "",
8060 filter->aslist[FILTER_OUT].name,
8061 VTY_NEWLINE);
8062
8063 /* route-map. */
8064 if (filter->map[RMAP_IN].name)
8065 vty_out (vty, " Route map for incoming advertisements is %s%s%s",
8066 filter->map[RMAP_IN].map ? "*" : "",
8067 filter->map[RMAP_IN].name,
8068 VTY_NEWLINE);
8069 if (filter->map[RMAP_OUT].name)
8070 vty_out (vty, " Route map for outgoing advertisements is %s%s%s",
8071 filter->map[RMAP_OUT].map ? "*" : "",
8072 filter->map[RMAP_OUT].name,
8073 VTY_NEWLINE);
856ca177
MS
8074
8075 /* unsuppress-map */
8076 if (filter->usmap.name)
8077 vty_out (vty, " Route map for selective unsuppress is %s%s%s",
8078 filter->usmap.map ? "*" : "",
8079 filter->usmap.name, VTY_NEWLINE);
8080
8081 /* Receive prefix count */
8082 vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE);
8083
8084 /* Maximum prefix */
8085 if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX))
8086 {
8087 vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi],
8088 CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)
8089 ? " (warning-only)" : "", VTY_NEWLINE);
8090 vty_out (vty, " Threshold for warning message %d%%",
8091 p->pmax_threshold[afi][safi]);
8092 if (p->pmax_restart[afi][safi])
8093 vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]);
8094 vty_out (vty, "%s", VTY_NEWLINE);
8095 }
718e3744 8096
0a486e5f 8097 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 8098 }
718e3744 8099}
8100
94f2b392 8101static void
e8f7da3a 8102bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *json)
718e3744 8103{
8104 struct bgp *bgp;
4690c7d7 8105 char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN];
718e3744 8106 char timebuf[BGP_UPTIME_LEN];
f14e6fdb 8107 char dn_flag[2];
3a8c7ba1
DW
8108 const char *subcode_str;
8109 const char *code_str;
538621f2 8110 afi_t afi;
8111 safi_t safi;
d6661008
DS
8112 u_int16_t i;
8113 u_char *msg;
e8f7da3a 8114 json_object *json_neigh = NULL;
46111f2f 8115 time_t epoch_tbuf;
718e3744 8116
8117 bgp = p->bgp;
8118
e8f7da3a
DW
8119 if (use_json)
8120 json_neigh = json_object_new_object();
8121
517cd68a
DS
8122 memset (dn_flag, '\0', sizeof (dn_flag));
8123 if (!p->conf_if && peer_dynamic_neighbor (p))
8124 dn_flag[0] = '*';
8125
856ca177 8126 if (!use_json)
f14e6fdb 8127 {
856ca177
MS
8128 if (p->conf_if) /* Configured interface name. */
8129 vty_out (vty, "BGP neighbor on %s: %s, ", p->conf_if,
8130 BGP_PEER_SU_UNSPEC(p) ? "None" :
8131 sockunion2str (&p->su, buf, SU_ADDRSTRLEN));
8132 else /* Configured IP address. */
74ef1672 8133 vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host);
f14e6fdb
DS
8134 }
8135
856ca177
MS
8136 if (use_json)
8137 {
8138 if (p->conf_if && BGP_PEER_SU_UNSPEC(p))
8139 json_object_string_add(json_neigh, "bgpNeighborAddr", "none");
8140 else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p))
8141 json_object_string_add(json_neigh, "bgpNeighborAddr", sockunion2str (&p->su, buf, SU_ADDRSTRLEN));
8142
8143 json_object_int_add(json_neigh, "remoteAs", p->as);
8144
8145 if (p->change_local_as)
8146 json_object_int_add(json_neigh, "localAs", p->change_local_as);
8147 else
8148 json_object_int_add(json_neigh, "localAs", p->local_as);
8149
8150 if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND))
8151 json_object_boolean_true_add(json_neigh, "localAsNoPrepend");
66b199b2 8152
856ca177
MS
8153 if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS))
8154 json_object_boolean_true_add(json_neigh, "localAsReplaceAs");
8155 }
8156 else
8157 {
f8cfafda
DS
8158 if ((p->as_type == AS_SPECIFIED) ||
8159 (p->as_type == AS_EXTERNAL) ||
8160 (p->as_type == AS_INTERNAL))
8161 vty_out (vty, "remote AS %u, ", p->as);
8162 else
8163 vty_out (vty, "remote AS Unspecified, ");
856ca177
MS
8164 vty_out (vty, "local AS %u%s%s, ",
8165 p->change_local_as ? p->change_local_as : p->local_as,
8166 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
8167 " no-prepend" : "",
8168 CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ?
8169 " replace-as" : "");
8170 }
66b199b2
DS
8171 /* peer type internal, external, confed-internal or confed-external */
8172 if (p->as == p->local_as)
8173 {
856ca177
MS
8174 if (use_json)
8175 {
8176 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
8177 json_object_boolean_true_add(json_neigh, "nbrConfedInternalLink");
8178 else
8179 json_object_boolean_true_add(json_neigh, "nbrInternalLink");
8180 }
66b199b2 8181 else
856ca177
MS
8182 {
8183 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
8184 vty_out (vty, "confed-internal link%s", VTY_NEWLINE);
8185 else
8186 vty_out (vty, "internal link%s", VTY_NEWLINE);
8187 }
66b199b2
DS
8188 }
8189 else
8190 {
856ca177
MS
8191 if (use_json)
8192 {
8193 if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION))
8194 json_object_boolean_true_add(json_neigh, "nbrConfedExternalLink");
8195 else
8196 json_object_boolean_true_add(json_neigh, "nbrExternalLink");
8197 }
66b199b2 8198 else
856ca177
MS
8199 {
8200 if (bgp_confederation_peers_check(bgp, p->as))
8201 vty_out (vty, "confed-external link%s", VTY_NEWLINE);
8202 else
8203 vty_out (vty, "external link%s", VTY_NEWLINE);
8204 }
66b199b2 8205 }
718e3744 8206
8207 /* Description. */
8208 if (p->desc)
856ca177
MS
8209 {
8210 if (use_json)
8211 json_object_string_add(json_neigh, "nbrDesc", p->desc);
8212 else
8213 vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE);
8214 }
6410e93a 8215
04b6bdc0
DW
8216 if (p->hostname)
8217 {
d1570739
DW
8218 if (use_json)
8219 {
8220 if (p->hostname)
8221 json_object_string_add(json_neigh, "hostname", p->hostname);
8222
8223 if (p->domainname)
8224 json_object_string_add(json_neigh, "domainname", p->domainname);
8225 }
04b6bdc0 8226 else
d1570739
DW
8227 {
8228 if (p->domainname && (p->domainname[0] != '\0'))
8229 vty_out(vty, "Hostname: %s.%s%s", p->hostname, p->domainname,
8230 VTY_NEWLINE);
8231 else
8232 vty_out(vty, "Hostname: %s%s", p->hostname, VTY_NEWLINE);
8233 }
8234
04b6bdc0
DW
8235 }
8236
c744aa9f 8237 /* Peer-group */
718e3744 8238 if (p->group)
f14e6fdb 8239 {
856ca177
MS
8240 if (use_json)
8241 {
8242 json_object_string_add(json_neigh, "peerGroup", p->group->name);
8243
8244 if (dn_flag[0])
8245 {
40ee54a7 8246 struct prefix prefix, *range = NULL;
f14e6fdb 8247
40ee54a7
TT
8248 sockunion2hostprefix(&(p->su), &prefix);
8249 range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix);
856ca177
MS
8250
8251 if (range)
8252 {
8253 prefix2str(range, buf1, sizeof(buf1));
8254 json_object_string_add(json_neigh, "peerSubnetRangeGroup", buf1);
8255 }
8256 }
8257 }
8258 else
f14e6fdb 8259 {
856ca177
MS
8260 vty_out (vty, " Member of peer-group %s for session parameters%s",
8261 p->group->name, VTY_NEWLINE);
f14e6fdb 8262
856ca177 8263 if (dn_flag[0])
f14e6fdb 8264 {
40ee54a7 8265 struct prefix prefix, *range = NULL;
856ca177 8266
40ee54a7
TT
8267 sockunion2hostprefix(&(p->su), &prefix);
8268 range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix);
856ca177
MS
8269
8270 if (range)
8271 {
8272 prefix2str(range, buf1, sizeof(buf1));
8273 vty_out (vty, " Belongs to the subnet range group: %s%s", buf1, VTY_NEWLINE);
8274 }
f14e6fdb
DS
8275 }
8276 }
8277 }
718e3744 8278
856ca177
MS
8279 if (use_json)
8280 {
8281 /* Administrative shutdown. */
8282 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
8283 json_object_boolean_true_add(json_neigh, "adminShutDown");
718e3744 8284
856ca177
MS
8285 /* BGP Version. */
8286 json_object_int_add(json_neigh, "bgpVersion", 4);
389e3fe0 8287 json_object_string_add(json_neigh, "remoteRouterId",
44b8cd53 8288 inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1)));
718e3744 8289
856ca177
MS
8290 /* Confederation */
8291 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as))
8292 json_object_boolean_true_add(json_neigh, "nbrCommonAdmin");
8293
8294 /* Status. */
8295 json_object_string_add(json_neigh, "bgpState", LOOKUP (bgp_status_msg, p->status));
8296
8297 if (p->status == Established)
8298 {
8299 time_t uptime;
8300 struct tm *tm;
8301
8302 uptime = bgp_clock();
8303 uptime -= p->uptime;
8304 tm = gmtime(&uptime);
46111f2f 8305 epoch_tbuf = time(NULL) - uptime;
856ca177
MS
8306
8307 json_object_int_add(json_neigh, "bgpTimerUp", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
46111f2f
DW
8308 json_object_string_add(json_neigh, "bgpTimerUpString", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL));
8309 json_object_int_add(json_neigh, "bgpTimerUpEstablishedEpoch", epoch_tbuf);
856ca177
MS
8310 }
8311
8312 else if (p->status == Active)
8313 {
8314 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
8315 json_object_string_add(json_neigh, "bgpStateIs", "passive");
8316 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
8317 json_object_string_add(json_neigh, "bgpStateIs", "passiveNSF");
8318 }
8319
8320 /* read timer */
8321 time_t uptime;
8322 struct tm *tm;
8323
8324 uptime = bgp_clock();
8325 uptime -= p->readtime;
8326 tm = gmtime(&uptime);
8327 json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
8328
8329 uptime = bgp_clock();
8330 uptime -= p->last_write;
8331 tm = gmtime(&uptime);
39e871e6
ST
8332 json_object_int_add(json_neigh, "bgpTimerLastWrite", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
8333
8334 uptime = bgp_clock();
8335 uptime -= p->update_time;
8336 tm = gmtime(&uptime);
8337 json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs",
8338 (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
856ca177
MS
8339
8340 /* Configured timer values. */
8341 json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", p->v_holdtime * 1000);
8342 json_object_int_add(json_neigh, "bgpTimerKeepAliveIntervalMsecs", p->v_keepalive * 1000);
8343
8344 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
8345 {
8346 json_object_int_add(json_neigh, "bgpTimerConfiguredHoldTimeMsecs", p->holdtime * 1000);
8347 json_object_int_add(json_neigh, "bgpTimerConfiguredKeepAliveIntervalMsecs", p->keepalive * 1000);
8348 }
93406d87 8349 }
856ca177
MS
8350 else
8351 {
8352 /* Administrative shutdown. */
8353 if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN))
8354 vty_out (vty, " Administratively shut down%s", VTY_NEWLINE);
8355
8356 /* BGP Version. */
8357 vty_out (vty, " BGP version 4");
389e3fe0 8358 vty_out (vty, ", remote router ID %s%s",
44b8cd53 8359 inet_ntop (AF_INET, &p->remote_id, buf1, sizeof(buf1)),
856ca177
MS
8360 VTY_NEWLINE);
8361
8362 /* Confederation */
8363 if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION)
8364 && bgp_confederation_peers_check (bgp, p->as))
8365 vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE);
e52702f2 8366
856ca177
MS
8367 /* Status. */
8368 vty_out (vty, " BGP state = %s", LOOKUP (bgp_status_msg, p->status));
718e3744 8369
856ca177
MS
8370 if (p->status == Established)
8371 vty_out (vty, ", up for %8s", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL));
8372
8373 else if (p->status == Active)
8374 {
8375 if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE))
8376 vty_out (vty, " (passive)");
8377 else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT))
8378 vty_out (vty, " (NSF passive)");
8379 }
8380 vty_out (vty, "%s", VTY_NEWLINE);
93406d87 8381
856ca177
MS
8382 /* read timer */
8383 vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN, 0, NULL));
8384 vty_out (vty, ", Last write %s%s",
8385 peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL), VTY_NEWLINE);
8386
8387 /* Configured timer values. */
8388 vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s",
8389 p->v_holdtime, p->v_keepalive, VTY_NEWLINE);
8390 if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER))
8391 {
8392 vty_out (vty, " Configured hold time is %d", p->holdtime);
8393 vty_out (vty, ", keepalive interval is %d seconds%s",
8394 p->keepalive, VTY_NEWLINE);
8395 }
8396 }
718e3744 8397 /* Capability. */
e52702f2 8398 if (p->status == Established)
718e3744 8399 {
538621f2 8400 if (p->cap
718e3744 8401 || p->afc_adv[AFI_IP][SAFI_UNICAST]
8402 || p->afc_recv[AFI_IP][SAFI_UNICAST]
8403 || p->afc_adv[AFI_IP][SAFI_MULTICAST]
8404 || p->afc_recv[AFI_IP][SAFI_MULTICAST]
718e3744 8405 || p->afc_adv[AFI_IP6][SAFI_UNICAST]
8406 || p->afc_recv[AFI_IP6][SAFI_UNICAST]
8407 || p->afc_adv[AFI_IP6][SAFI_MULTICAST]
8408 || p->afc_recv[AFI_IP6][SAFI_MULTICAST]
945c8fe9
LB
8409 || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN]
8410 || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN]
8b1fb8be
LB
8411 || p->afc_adv[AFI_IP6][SAFI_ENCAP]
8412 || p->afc_recv[AFI_IP6][SAFI_ENCAP]
8b1fb8be
LB
8413 || p->afc_adv[AFI_IP][SAFI_ENCAP]
8414 || p->afc_recv[AFI_IP][SAFI_ENCAP]
718e3744 8415 || p->afc_adv[AFI_IP][SAFI_MPLS_VPN]
8416 || p->afc_recv[AFI_IP][SAFI_MPLS_VPN])
8417 {
856ca177
MS
8418 if (use_json)
8419 {
8420 json_object *json_cap = NULL;
8421
8422 json_cap = json_object_new_object();
8423
8424 /* AS4 */
8425 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
8426 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
8427 {
8428 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) && CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
8429 json_object_string_add(json_cap, "4byteAs", "advertisedAndReceived");
8430 else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
8431 json_object_string_add(json_cap, "4byteAs", "advertised");
8432 else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
8433 json_object_string_add(json_cap, "4byteAs", "received");
8434 }
8435
8436 /* AddPath */
8437 if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV)
8438 || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV))
8439 {
8440 json_object *json_add = NULL;
8441 const char *print_store;
718e3744 8442
856ca177 8443 json_add = json_object_new_object();
a82478b9 8444
856ca177
MS
8445 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8446 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8447 {
8448 json_object *json_sub = NULL;
8449 json_sub = json_object_new_object();
8450 print_store = afi_safi_print (afi, safi);
8451
8452 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
8453 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
8454 {
8455 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) && CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
8456 json_object_boolean_true_add(json_sub, "txAdvertisedAndReceived");
8457 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV))
8458 json_object_boolean_true_add(json_sub, "txAdvertised");
8459 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
8460 json_object_boolean_true_add(json_sub, "txReceived");
8461 }
8462
8463 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
8464 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
8465 {
8466 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) && CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
8467 json_object_boolean_true_add(json_sub, "rxAdvertisedAndReceived");
8468 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV))
8469 json_object_boolean_true_add(json_sub, "rxAdvertised");
8470 else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
8471 json_object_boolean_true_add(json_sub, "rxReceived");
8472 }
8473
8474 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
8475 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV) ||
8476 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
8477 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
8478 json_object_object_add(json_add, print_store, json_sub);
b6df4090
DS
8479 else
8480 json_object_free(json_sub);
856ca177 8481 }
a82478b9 8482
856ca177
MS
8483 json_object_object_add(json_cap, "addPath", json_add);
8484 }
8485
8486 /* Dynamic */
8487 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
8488 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
8489 {
8490 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) && CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
8491 json_object_string_add(json_cap, "dynamic", "advertisedAndReceived");
8492 else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
8493 json_object_string_add(json_cap, "dynamic", "advertised");
8494 else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
8495 json_object_string_add(json_cap, "dynamic", "received");
8496 }
8497
8498 /* Extended nexthop */
8499 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)
8500 || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
8501 {
8502 json_object *json_nxt = NULL;
8503 const char *print_store;
8504
856ca177
MS
8505
8506 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
8507 json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived");
8508 else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
8509 json_object_string_add(json_cap, "extendedNexthop", "advertised");
8510 else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
8511 json_object_string_add(json_cap, "extendedNexthop", "received");
8512
8513 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
8514 {
b6df4090
DS
8515 json_nxt = json_object_new_object();
8516
856ca177
MS
8517 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8518 {
8519 if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV))
8520 {
8521 print_store = afi_safi_print (AFI_IP, safi);
8522 json_object_string_add(json_nxt, print_store, "recieved");
8523 }
8524 }
8525 json_object_object_add(json_cap, "extendedNexthopFamililesByPeer", json_nxt);
8526 }
8527 }
8528
8529 /* Route Refresh */
8530 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
8531 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
8532 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
8533 {
8534 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) && (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)))
8535 {
8536 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV))
8537 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOldNew");
8538 else
8539 {
8540 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
8541 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOld");
8542 else
8543 json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedNew");
8544 }
8545 }
8546 else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
8547 json_object_string_add(json_cap, "routeRefresh", "advertised");
8548 else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
8549 json_object_string_add(json_cap, "routeRefresh", "received");
8550 }
8551
8552 /* Multiprotocol Extensions */
8553 json_object *json_multi = NULL;
8554 json_multi = json_object_new_object();
8555
8556 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8557 {
8558 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8559 {
8560 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
8561 {
8562 json_object *json_exten = NULL;
8563 json_exten = json_object_new_object();
8564
8565 if (p->afc_adv[afi][safi] && p->afc_recv[afi][safi])
8566 json_object_boolean_true_add(json_exten, "advertisedAndReceived");
8567 else if (p->afc_adv[afi][safi])
8568 json_object_boolean_true_add(json_exten, "advertised");
8569 else if (p->afc_recv[afi][safi])
8570 json_object_boolean_true_add(json_exten, "received");
8571
8572 json_object_object_add(json_multi, afi_safi_print (afi, safi), json_exten);
8573 }
8574 }
8575 }
8576 json_object_object_add(json_cap, "multiprotocolExtensions", json_multi);
8577
8578 /* Gracefull Restart */
8579 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
8580 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
8581 {
8582 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) && CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
8583 json_object_string_add(json_cap, "gracefulRestart", "advertisedAndReceived");
8584 else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
8585 json_object_string_add(json_cap, "gracefulRestartCapability", "advertised");
8586 else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
8587 json_object_string_add(json_cap, "gracefulRestartCapability", "received");
8588
8589 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
8590 {
8591 int restart_af_count = 0;
8592 json_object *json_restart = NULL;
8593 json_restart = json_object_new_object();
8594
8595 json_object_int_add(json_cap, "gracefulRestartRemoteTimerMsecs", p->v_gr_restart * 1000);
8596
8597 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8598 {
8599 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8600 {
8601 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
8602 {
8603 json_object *json_sub = NULL;
8604 json_sub = json_object_new_object();
8605
8606 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV))
8607 json_object_boolean_true_add(json_sub, "preserved");
8608 restart_af_count++;
8609 json_object_object_add(json_restart, afi_safi_print (afi, safi), json_sub);
8610 }
8611 }
8612 }
8613 if (! restart_af_count)
b6df4090 8614 {
856ca177 8615 json_object_string_add(json_cap, "addressFamiliesByPeer", "none");
b6df4090
DS
8616 json_object_free(json_restart);
8617 }
856ca177
MS
8618 else
8619 json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart);
8620 }
8621 }
8622 json_object_object_add(json_neigh, "neighborCapabilities", json_cap);
8623 }
8624 else
8625 {
8626 vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE);
8627
8628 /* AS4 */
8629 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)
8630 || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
8631 {
8632 vty_out (vty, " 4 Byte AS:");
8633 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV))
8634 vty_out (vty, " advertised");
8635 if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV))
8636 vty_out (vty, " %sreceived",
8637 CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : "");
8638 vty_out (vty, "%s", VTY_NEWLINE);
8639 }
8640
8641 /* AddPath */
8642 if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV)
8643 || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV))
8644 {
8645 vty_out (vty, " AddPath:%s", VTY_NEWLINE);
a82478b9 8646
856ca177
MS
8647 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8648 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
a82478b9 8649 {
856ca177
MS
8650 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ||
8651 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
8652 {
8653 vty_out (vty, " %s: TX ", afi_safi_print (afi, safi));
a82478b9 8654
856ca177
MS
8655 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV))
8656 vty_out (vty, "advertised %s", afi_safi_print (afi, safi));
a82478b9 8657
856ca177
MS
8658 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV))
8659 vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" );
a82478b9 8660
856ca177
MS
8661 vty_out (vty, "%s", VTY_NEWLINE);
8662 }
a82478b9 8663
856ca177 8664 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ||
a82478b9 8665 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
856ca177
MS
8666 {
8667 vty_out (vty, " %s: RX ", afi_safi_print (afi, safi));
a82478b9 8668
856ca177
MS
8669 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV))
8670 vty_out (vty, "advertised %s", afi_safi_print (afi, safi));
a82478b9 8671
856ca177
MS
8672 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV))
8673 vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" );
a82478b9 8674
856ca177
MS
8675 vty_out (vty, "%s", VTY_NEWLINE);
8676 }
a82478b9 8677 }
856ca177 8678 }
a82478b9 8679
856ca177
MS
8680 /* Dynamic */
8681 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)
8682 || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
8683 {
8684 vty_out (vty, " Dynamic:");
8685 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV))
8686 vty_out (vty, " advertised");
8687 if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV))
8688 vty_out (vty, " %sreceived",
8689 CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : "");
8690 vty_out (vty, "%s", VTY_NEWLINE);
8691 }
8692
8693 /* Extended nexthop */
8694 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)
8695 || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
8696 {
8697 vty_out (vty, " Extended nexthop:");
8698 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV))
8699 vty_out (vty, " advertised");
8700 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
8701 vty_out (vty, " %sreceived",
8702 CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) ? "and " : "");
8703 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 8704
856ca177
MS
8705 if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV))
8706 {
8707 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
8708 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8709 if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV))
8710 vty_out (vty, " %s%s",
8711 afi_safi_print (AFI_IP, safi), VTY_NEWLINE);
8712 }
8713 }
8a92a8a0 8714
856ca177
MS
8715 /* Route Refresh */
8716 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)
8717 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
8718 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
8719 {
8720 vty_out (vty, " Route refresh:");
8721 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV))
8722 vty_out (vty, " advertised");
8723 if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)
8724 || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV))
8725 vty_out (vty, " %sreceived(%s)",
8726 CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "",
8727 (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)
8728 && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ?
8729 "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new");
8a92a8a0 8730
856ca177
MS
8731 vty_out (vty, "%s", VTY_NEWLINE);
8732 }
718e3744 8733
856ca177
MS
8734 /* Multiprotocol Extensions */
8735 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8736 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8737 if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi])
8738 {
8c3deaae 8739 vty_out (vty, " Address Family %s:", afi_safi_print (afi, safi));
856ca177
MS
8740 if (p->afc_adv[afi][safi])
8741 vty_out (vty, " advertised");
8742 if (p->afc_recv[afi][safi])
8743 vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : "");
8744 vty_out (vty, "%s", VTY_NEWLINE);
8745 }
538621f2 8746
04b6bdc0
DW
8747 /* Hostname capability */
8748 if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV) ||
8749 CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV))
8750 {
8751 vty_out (vty, " Hostname Capability:");
8752 if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV))
8753 vty_out (vty, " advertised");
8754 if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_RCV))
8755 vty_out (vty, " %sreceived",
8756 CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV) ? "and " : "");
8757 vty_out (vty, "%s", VTY_NEWLINE);
8758 }
8759
856ca177
MS
8760 /* Gracefull Restart */
8761 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
8762 || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
8763 {
8764 vty_out (vty, " Graceful Restart Capabilty:");
8765 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV))
538621f2 8766 vty_out (vty, " advertised");
856ca177
MS
8767 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
8768 vty_out (vty, " %sreceived",
8769 CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : "");
8770 vty_out (vty, "%s", VTY_NEWLINE);
538621f2 8771
856ca177
MS
8772 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV))
8773 {
8774 int restart_af_count = 0;
8775
8776 vty_out (vty, " Remote Restart timer is %d seconds%s",
8777 p->v_gr_restart, VTY_NEWLINE);
8778 vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE);
8779
8780 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8781 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8782 if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV))
8783 {
8784 vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "",
8785 afi_safi_print (afi, safi),
8786 CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ?
8787 "preserved" : "not preserved");
8788 restart_af_count++;
8789 }
8790 if (! restart_af_count)
8791 vty_out (vty, "none");
8792 vty_out (vty, "%s", VTY_NEWLINE);
8793 }
8794 }
8795 }
718e3744 8796 }
8797 }
8798
93406d87 8799 /* graceful restart information */
8800 if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)
8801 || p->t_gr_restart
8802 || p->t_gr_stale)
8803 {
856ca177
MS
8804 json_object *json_grace = NULL;
8805 json_object *json_grace_send = NULL;
8806 json_object *json_grace_recv = NULL;
93406d87 8807 int eor_send_af_count = 0;
8808 int eor_receive_af_count = 0;
8809
856ca177
MS
8810 if (use_json)
8811 {
8812 json_grace = json_object_new_object();
8813 json_grace_send = json_object_new_object();
8814 json_grace_recv = json_object_new_object();
8815
8816 if (p->status == Established)
8817 {
8818 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8819 {
8820 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8821 {
8822 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
8823 {
8824 json_object_boolean_true_add(json_grace_send, afi_safi_print (afi, safi));
8825 eor_send_af_count++;
8826 }
8827 }
8828 }
8829 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8830 {
8831 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8832 {
8833 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
8834 {
8835 json_object_boolean_true_add(json_grace_recv, afi_safi_print (afi, safi));
8836 eor_receive_af_count++;
8837 }
8838 }
8839 }
8840 }
8841
8842 json_object_object_add(json_grace, "endOfRibSend", json_grace_send);
8843 json_object_object_add(json_grace, "endOfRibRecv", json_grace_recv);
8844
8845 if (p->t_gr_restart)
8846 json_object_int_add(json_grace, "gracefulRestartTimerMsecs", thread_timer_remain_second (p->t_gr_restart) * 1000);
8847
8848 if (p->t_gr_stale)
8849 json_object_int_add(json_grace, "gracefulStalepathTimerMsecs", thread_timer_remain_second (p->t_gr_stale) * 1000);
8850
8851 json_object_object_add(json_neigh, "gracefulRestartInfo", json_grace);
8852 }
8853 else
8854 {
8855 vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE);
8856 if (p->status == Established)
8857 {
8858 vty_out (vty, " End-of-RIB send: ");
8859 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8860 {
8861 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8862 {
8863 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND))
8864 {
8865 vty_out (vty, "%s%s", eor_send_af_count ? ", " : "",
8866 afi_safi_print (afi, safi));
8867 eor_send_af_count++;
8868 }
8869 }
8870 }
8871 vty_out (vty, "%s", VTY_NEWLINE);
8872 vty_out (vty, " End-of-RIB received: ");
8873 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8874 {
8875 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8876 {
8877 if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED))
8878 {
8879 vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "",
8880 afi_safi_print (afi, safi));
8881 eor_receive_af_count++;
8882 }
8883 }
8884 }
8885 vty_out (vty, "%s", VTY_NEWLINE);
8886 }
93406d87 8887
856ca177
MS
8888 if (p->t_gr_restart)
8889 vty_out (vty, " The remaining time of restart timer is %ld%s",
8890 thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE);
e52702f2 8891
856ca177
MS
8892 if (p->t_gr_stale)
8893 vty_out (vty, " The remaining time of stalepath timer is %ld%s",
8894 thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE);
8895 }
8896 }
8897 if (use_json)
8898 {
8899 json_object *json_stat = NULL;
8900 json_stat = json_object_new_object();
8901 /* Packet counts. */
8902 json_object_int_add(json_stat, "depthInq", 0);
8903 json_object_int_add(json_stat, "depthOutq", (unsigned long) p->obuf->count);
8904 json_object_int_add(json_stat, "opensSent", p->open_out);
8905 json_object_int_add(json_stat, "opensRecv", p->open_in);
8906 json_object_int_add(json_stat, "notificationsSent", p->notify_out);
8907 json_object_int_add(json_stat, "notificationsRecv", p->notify_in);
8908 json_object_int_add(json_stat, "updatesSent", p->update_out);
8909 json_object_int_add(json_stat, "updatesRecv", p->update_in);
8910 json_object_int_add(json_stat, "keepalivesSent", p->keepalive_out);
8911 json_object_int_add(json_stat, "keepalivesRecv", p->keepalive_in);
8912 json_object_int_add(json_stat, "routeRefreshSent", p->refresh_out);
8913 json_object_int_add(json_stat, "routeRefreshRecv", p->refresh_in);
8914 json_object_int_add(json_stat, "capabilitySent", p->dynamic_cap_out);
8915 json_object_int_add(json_stat, "capabilityRecv", p->dynamic_cap_in);
8916 json_object_int_add(json_stat, "totalSent", p->open_out + p->notify_out + p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out);
8917 json_object_int_add(json_stat, "totalRecv", p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in + p->dynamic_cap_in);
8918 json_object_object_add(json_neigh, "messageStats", json_stat);
8919 }
8920 else
8921 {
8922 /* Packet counts. */
8923 vty_out (vty, " Message statistics:%s", VTY_NEWLINE);
8924 vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE);
8925 vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE);
8926 vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE);
8927 vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE);
8928 vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE);
8929 vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE);
8930 vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE);
8931 vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE);
8932 vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE);
8933 vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out +
8934 p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out,
8935 p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in +
8936 p->dynamic_cap_in, VTY_NEWLINE);
718e3744 8937 }
8938
856ca177
MS
8939 if (use_json)
8940 {
8941 /* advertisement-interval */
8942 json_object_int_add(json_neigh, "minBtwnAdvertisementRunsTimerMsecs", p->v_routeadv * 1000);
718e3744 8943
856ca177
MS
8944 /* Update-source. */
8945 if (p->update_if || p->update_source)
8946 {
8947 if (p->update_if)
8948 json_object_string_add(json_neigh, "updateSource", p->update_if);
8949 else if (p->update_source)
8950 json_object_string_add(json_neigh, "updateSource", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
8951 }
856ca177
MS
8952 }
8953 else
8954 {
8955 /* advertisement-interval */
8956 vty_out (vty, " Minimum time between advertisement runs is %d seconds%s",
8957 p->v_routeadv, VTY_NEWLINE);
8958
8959 /* Update-source. */
8960 if (p->update_if || p->update_source)
8961 {
8962 vty_out (vty, " Update source is ");
8963 if (p->update_if)
8964 vty_out (vty, "%s", p->update_if);
8965 else if (p->update_source)
8966 vty_out (vty, "%s", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN));
8967 vty_out (vty, "%s", VTY_NEWLINE);
8968 }
8969
856ca177
MS
8970 vty_out (vty, "%s", VTY_NEWLINE);
8971 }
718e3744 8972
8973 /* Address Family Information */
856ca177
MS
8974 json_object *json_hold = NULL;
8975
8976 if (use_json)
8977 json_hold = json_object_new_object();
8978
538621f2 8979 for (afi = AFI_IP ; afi < AFI_MAX ; afi++)
8980 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
8981 if (p->afc[afi][safi])
856ca177 8982 bgp_show_peer_afi (vty, p, afi, safi, use_json, json_hold);
718e3744 8983
856ca177
MS
8984 if (use_json)
8985 {
58433ae6 8986 json_object_object_add(json_neigh, "addressFamilyInfo", json_hold);
e08ac8b7
DW
8987 json_object_int_add(json_neigh, "connectionsEstablished", p->established);
8988 json_object_int_add(json_neigh, "connectionsDropped", p->dropped);
856ca177
MS
8989 }
8990 else
8991 vty_out (vty, " Connections established %d; dropped %d%s", p->established, p->dropped,
8992 VTY_NEWLINE);
718e3744 8993
d6661008 8994 if (! p->last_reset)
856ca177
MS
8995 {
8996 if (use_json)
e08ac8b7 8997 json_object_string_add(json_neigh, "lastReset", "never");
856ca177
MS
8998 else
8999 vty_out (vty, " Last reset never%s", VTY_NEWLINE);
9000 }
e0701b79 9001 else
d6661008 9002 {
856ca177
MS
9003 if (use_json)
9004 {
9005 time_t uptime;
9006 struct tm *tm;
9007
9008 uptime = bgp_clock();
9009 uptime -= p->resettime;
9010 tm = gmtime(&uptime);
e08ac8b7
DW
9011 json_object_int_add(json_neigh, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000));
9012 json_object_string_add(json_neigh, "lastResetDueTo", peer_down_str[(int) p->last_reset]);
cca1dda8
DD
9013 if (p->last_reset == PEER_DOWN_NOTIFY_SEND ||
9014 p->last_reset == PEER_DOWN_NOTIFY_RECEIVED)
856ca177 9015 {
39e871e6 9016 char errorcodesubcode_hexstr[5];
cca1dda8
DD
9017 char errorcodesubcode_str[256];
9018
9019 code_str = bgp_notify_code_str(p->notify.code);
9020 subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode);
9021
39e871e6 9022 sprintf(errorcodesubcode_hexstr, "%02X%02X", p->notify.code, p->notify.subcode);
e08ac8b7 9023 json_object_string_add(json_neigh, "lastErrorCodeSubcode", errorcodesubcode_hexstr);
cca1dda8
DD
9024 snprintf(errorcodesubcode_str, 255, "%s%s", code_str, subcode_str);
9025 json_object_string_add(json_neigh, "lastNotificationReason", errorcodesubcode_str);
652b9429
DS
9026 if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED
9027 && p->notify.code == BGP_NOTIFY_CEASE
9028 && (p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
9029 || p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_RESET)
9030 && p->notify.length)
9031 {
9032 char msgbuf[1024];
9033 const char *msg_str;
9034
9035 msg_str = bgp_notify_admin_message(msgbuf, sizeof(msgbuf),
9036 (u_char*)p->notify.data, p->notify.length);
9037 if (msg_str)
9038 json_object_string_add(json_neigh, "lastShutdownDescription", msg_str);
9039 }
856ca177
MS
9040 }
9041 }
9042 else
d6661008 9043 {
3a8c7ba1
DW
9044 vty_out (vty, " Last reset %s, ",
9045 peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN, 0, NULL));
9046
9047 if (p->last_reset == PEER_DOWN_NOTIFY_SEND ||
9048 p->last_reset == PEER_DOWN_NOTIFY_RECEIVED)
9049 {
9050 code_str = bgp_notify_code_str(p->notify.code);
9051 subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode);
9052 vty_out (vty, "due to NOTIFICATION %s (%s%s)%s",
9053 p->last_reset == PEER_DOWN_NOTIFY_SEND ? "sent" : "received",
9054 code_str, subcode_str, VTY_NEWLINE);
38de8d02
DL
9055 if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED
9056 && p->notify.code == BGP_NOTIFY_CEASE
9057 && (p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
9058 || p->notify.subcode == BGP_NOTIFY_CEASE_ADMIN_RESET)
9059 && p->notify.length)
9060 {
9061 char msgbuf[1024];
9062 const char *msg_str;
9063
9064 msg_str = bgp_notify_admin_message(msgbuf, sizeof(msgbuf),
9065 (u_char*)p->notify.data, p->notify.length);
9066 if (msg_str)
9067 vty_out (vty, " Message: \"%s\"%s", msg_str, VTY_NEWLINE);
9068 }
3a8c7ba1
DW
9069 }
9070 else
9071 {
9072 vty_out (vty, "due to %s%s",
9073 peer_down_str[(int) p->last_reset], VTY_NEWLINE);
9074 }
856ca177
MS
9075
9076 if (p->last_reset_cause_size)
d6661008 9077 {
856ca177
MS
9078 msg = p->last_reset_cause;
9079 vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE);
9080 for (i = 1; i <= p->last_reset_cause_size; i++)
9081 {
9082 vty_out(vty, "%02X", *msg++);
d6661008 9083
856ca177
MS
9084 if (i != p->last_reset_cause_size)
9085 {
9086 if (i % 16 == 0)
9087 {
9088 vty_out(vty, "%s ", VTY_NEWLINE);
9089 }
9090 else if (i % 4 == 0)
9091 {
9092 vty_out(vty, " ");
9093 }
9094 }
9095 }
9096 vty_out(vty, "%s", VTY_NEWLINE);
d6661008 9097 }
d6661008
DS
9098 }
9099 }
848973c7 9100
718e3744 9101 if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW))
9102 {
856ca177 9103 if (use_json)
e08ac8b7 9104 json_object_boolean_true_add(json_neigh, "prefixesConfigExceedMax");
856ca177
MS
9105 else
9106 vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE);
0a486e5f 9107
9108 if (p->t_pmax_restart)
856ca177
MS
9109 {
9110 if (use_json)
9111 {
e08ac8b7
DW
9112 json_object_boolean_true_add(json_neigh, "reducePrefixNumFrom");
9113 json_object_int_add(json_neigh, "restartInTimerMsec", thread_timer_remain_second (p->t_pmax_restart) * 1000);
856ca177
MS
9114 }
9115 else
9116 vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s",
9117 p->host, thread_timer_remain_second (p->t_pmax_restart),
9118 VTY_NEWLINE);
9119 }
0a486e5f 9120 else
856ca177
MS
9121 {
9122 if (use_json)
e08ac8b7 9123 json_object_boolean_true_add(json_neigh, "reducePrefixNumAndClearIpBgp");
856ca177
MS
9124 else
9125 vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s",
9126 p->host, VTY_NEWLINE);
9127 }
718e3744 9128 }
9129
f5a4827d 9130 /* EBGP Multihop and GTSM */
6d85b15b 9131 if (p->sort != BGP_PEER_IBGP)
f5a4827d 9132 {
856ca177
MS
9133 if (use_json)
9134 {
9135 if (p->gtsm_hops > 0)
9136 json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->gtsm_hops);
9137 else if (p->ttl > 1)
9138 json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->ttl);
9139 }
9140 else
9141 {
9142 if (p->gtsm_hops > 0)
9143 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
9144 p->gtsm_hops, VTY_NEWLINE);
9145 else if (p->ttl > 1)
9146 vty_out (vty, " External BGP neighbor may be up to %d hops away.%s",
9147 p->ttl, VTY_NEWLINE);
9148 }
f5a4827d 9149 }
5d804b43
PM
9150 else
9151 {
9152 if (p->gtsm_hops > 0)
856ca177
MS
9153 {
9154 if (use_json)
9155 json_object_int_add(json_neigh, "internalBgpNbrMaxHopsAway", p->gtsm_hops);
9156 else
9157 vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s",
9158 p->gtsm_hops, VTY_NEWLINE);
9159 }
5d804b43 9160 }
718e3744 9161
9162 /* Local address. */
9163 if (p->su_local)
9164 {
856ca177
MS
9165 if (use_json)
9166 {
9167 json_object_string_add(json_neigh, "hostLocal", sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN));
9168 json_object_int_add(json_neigh, "portLocal", ntohs (p->su_local->sin.sin_port));
9169 }
9170 else
9171 vty_out (vty, "Local host: %s, Local port: %d%s",
9172 sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN),
9173 ntohs (p->su_local->sin.sin_port),
9174 VTY_NEWLINE);
718e3744 9175 }
e52702f2 9176
718e3744 9177 /* Remote address. */
9178 if (p->su_remote)
9179 {
856ca177
MS
9180 if (use_json)
9181 {
9182 json_object_string_add(json_neigh, "hostForeign", sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN));
9183 json_object_int_add(json_neigh, "portForeign", ntohs (p->su_remote->sin.sin_port));
9184 }
9185 else
9186 vty_out (vty, "Foreign host: %s, Foreign port: %d%s",
718e3744 9187 sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN),
9188 ntohs (p->su_remote->sin.sin_port),
9189 VTY_NEWLINE);
9190 }
9191
9192 /* Nexthop display. */
9193 if (p->su_local)
9194 {
856ca177
MS
9195 if (use_json)
9196 {
389e3fe0 9197 json_object_string_add(json_neigh, "nexthop",
44b8cd53 9198 inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1)));
389e3fe0 9199 json_object_string_add(json_neigh, "nexthopGlobal",
44b8cd53 9200 inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1)));
389e3fe0 9201 json_object_string_add(json_neigh, "nexthopLocal",
44b8cd53 9202 inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1)));
856ca177
MS
9203 if (p->shared_network)
9204 json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork");
9205 else
9206 json_object_string_add(json_neigh, "bgpConnection", "nonSharedNetwork");
856ca177
MS
9207 }
9208 else
9209 {
9210 vty_out (vty, "Nexthop: %s%s",
44b8cd53
DL
9211 inet_ntop (AF_INET, &p->nexthop.v4, buf1, sizeof(buf1)),
9212 VTY_NEWLINE);
856ca177 9213 vty_out (vty, "Nexthop global: %s%s",
44b8cd53
DL
9214 inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, sizeof(buf1)),
9215 VTY_NEWLINE);
856ca177 9216 vty_out (vty, "Nexthop local: %s%s",
44b8cd53
DL
9217 inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, sizeof(buf1)),
9218 VTY_NEWLINE);
856ca177 9219 vty_out (vty, "BGP connection: %s%s",
44b8cd53
DL
9220 p->shared_network ? "shared network" : "non shared network",
9221 VTY_NEWLINE);
856ca177 9222 }
718e3744 9223 }
9224
9225 /* Timer information. */
856ca177
MS
9226 if (use_json)
9227 {
39e871e6 9228 json_object_int_add(json_neigh, "connectRetryTimer", p->v_connect);
dd9275d6
ST
9229 if (p->status == Established && p->rtt)
9230 json_object_int_add(json_neigh, "estimatedRttInMsecs", p->rtt);
856ca177
MS
9231 if (p->t_start)
9232 json_object_int_add(json_neigh, "nextStartTimerDueInMsecs", thread_timer_remain_second (p->t_start) * 1000);
9233 if (p->t_connect)
9234 json_object_int_add(json_neigh, "nextConnectTimerDueInMsecs", thread_timer_remain_second (p->t_connect) * 1000);
9235 if (p->t_routeadv)
9236 {
9237 json_object_int_add(json_neigh, "mraiInterval", p->v_routeadv);
9238 json_object_int_add(json_neigh, "mraiTimerExpireInMsecs", thread_timer_remain_second (p->t_routeadv) * 1000);
9239 }
047fc950
DS
9240 if (p->password)
9241 json_object_int_add(json_neigh, "authenticationEnabled", 1);
cb1faec9 9242
856ca177
MS
9243 if (p->t_read)
9244 json_object_string_add(json_neigh, "readThread", "on");
9245 else
9246 json_object_string_add(json_neigh, "readThread", "off");
9247 if (p->t_write)
9248 json_object_string_add(json_neigh, "writeThread", "on");
9249 else
9250 json_object_string_add(json_neigh, "writeThread", "off");
9251 }
9252 else
9253 {
39e871e6
ST
9254 vty_out (vty, "BGP Connect Retry Timer in Seconds: %d%s",
9255 p->v_connect, VTY_NEWLINE);
dd9275d6
ST
9256 if (p->status == Established && p->rtt)
9257 vty_out (vty, "Estimated round trip time: %d ms%s",
9258 p->rtt, VTY_NEWLINE);
856ca177
MS
9259 if (p->t_start)
9260 vty_out (vty, "Next start timer due in %ld seconds%s",
9261 thread_timer_remain_second (p->t_start), VTY_NEWLINE);
9262 if (p->t_connect)
9263 vty_out (vty, "Next connect timer due in %ld seconds%s",
9264 thread_timer_remain_second (p->t_connect), VTY_NEWLINE);
9265 if (p->t_routeadv)
9266 vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s",
9267 p->v_routeadv, thread_timer_remain_second (p->t_routeadv),
9268 VTY_NEWLINE);
047fc950
DS
9269 if (p->password)
9270 vty_out (vty, "Peer Authentication Enabled%s", VTY_NEWLINE);
856ca177
MS
9271
9272 vty_out (vty, "Read thread: %s Write thread: %s%s",
9273 p->t_read ? "on" : "off",
9274 p->t_write ? "on" : "off",
9275 VTY_NEWLINE);
9276 }
718e3744 9277
9278 if (p->notify.code == BGP_NOTIFY_OPEN_ERR
9279 && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL)
856ca177
MS
9280 bgp_capability_vty_out (vty, p, use_json, json_neigh);
9281
9282 if (!use_json)
9283 vty_out (vty, "%s", VTY_NEWLINE);
c43ed2e4
DS
9284
9285 /* BFD information. */
856ca177
MS
9286 bgp_bfd_show_info(vty, p, use_json, json_neigh);
9287
9288 if (use_json)
9289 {
9290 if (p->conf_if) /* Configured interface name. */
9291 json_object_object_add(json, p->conf_if, json_neigh);
9292 else /* Configured IP address. */
9293 json_object_object_add(json, p->host, json_neigh);
9294 }
718e3744 9295}
9296
94f2b392 9297static int
856ca177
MS
9298bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type,
9299 union sockunion *su, const char *conf_if, u_char use_json, json_object *json)
718e3744 9300{
1eb8ef25 9301 struct listnode *node, *nnode;
718e3744 9302 struct peer *peer;
9303 int find = 0;
9304
1eb8ef25 9305 for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
718e3744 9306 {
1ff9a340
DS
9307 if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE))
9308 continue;
9309
718e3744 9310 switch (type)
856ca177
MS
9311 {
9312 case show_all:
e8f7da3a 9313 bgp_show_peer (vty, peer, use_json, json);
856ca177
MS
9314 break;
9315 case show_peer:
9316 if (conf_if)
9317 {
4873b3b9
DW
9318 if ((peer->conf_if && !strcmp(peer->conf_if, conf_if)) ||
9319 (peer->hostname && !strcmp(peer->hostname, conf_if)))
856ca177
MS
9320 {
9321 find = 1;
e8f7da3a 9322 bgp_show_peer (vty, peer, use_json, json);
856ca177
MS
9323 }
9324 }
9325 else
9326 {
9327 if (sockunion_same (&peer->su, su))
9328 {
9329 find = 1;
e8f7da3a 9330 bgp_show_peer (vty, peer, use_json, json);
856ca177
MS
9331 }
9332 }
9333 break;
718e3744 9334 }
9335 }
9336
9337 if (type == show_peer && ! find)
856ca177
MS
9338 {
9339 if (use_json)
9340 json_object_boolean_true_add(json, "bgpNoSuchNeighbor");
9341 else
9342 vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE);
9343 }
9344
9345 if (use_json)
9346 {
2aac5767 9347 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
856ca177
MS
9348 json_object_free(json);
9349 }
9350 else
9351 {
9352 vty_out (vty, "%s", VTY_NEWLINE);
9353 }
9354
718e3744 9355 return CMD_SUCCESS;
9356}
9357
f186de26 9358static void
9359bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json)
9360{
9361 struct listnode *node, *nnode;
9362 struct bgp *bgp;
9363 json_object *json = NULL;
9f689658
DD
9364 int is_first = 1;
9365
9366 if (use_json)
9367 vty_out (vty, "{%s", VTY_NEWLINE);
f186de26 9368
9369 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
9370 {
f186de26 9371 if (use_json)
9f689658
DD
9372 {
9373 if (!(json = json_object_new_object()))
9374 {
9375 zlog_err("Unable to allocate memory for JSON object");
9376 vty_out (vty,
9377 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s",
9378 VTY_NEWLINE);
9379 return;
9380 }
9381
9382 json_object_int_add(json, "vrfId",
9383 (bgp->vrf_id == VRF_UNKNOWN)
9384 ? -1 : bgp->vrf_id);
9385 json_object_string_add(json, "vrfName",
9386 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
9387 ? "Default" : bgp->name);
9388
9389 if (! is_first)
9390 vty_out (vty, ",%s", VTY_NEWLINE);
9391 else
9392 is_first = 0;
9393
9394 vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
9395 ? "Default" : bgp->name);
9396 }
9397 else
9398 {
9399 vty_out (vty, "%sInstance %s:%s",
9400 VTY_NEWLINE,
9401 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
9402 ? "Default" : bgp->name,
9403 VTY_NEWLINE);
9404 }
f186de26 9405 bgp_show_neighbor (vty, bgp, show_all, NULL, NULL, use_json, json);
9406 }
9f689658
DD
9407
9408 if (use_json)
9409 vty_out (vty, "}%s", VTY_NEWLINE);
f186de26 9410}
9411
4fb25c53
DW
9412static int
9413bgp_show_neighbor_vty (struct vty *vty, const char *name,
9414 enum show_type type, const char *ip_str, u_char use_json)
9415{
9416 int ret;
9417 struct bgp *bgp;
9418 union sockunion su;
9419 json_object *json = NULL;
9420
9421 if (use_json)
9422 json = json_object_new_object();
9423
9424 if (name)
9425 {
9426 if (strmatch(name, "all"))
9427 {
9428 bgp_show_all_instances_neighbors_vty (vty, use_json);
9429 return CMD_SUCCESS;
9430 }
9431 else
9432 {
9433 bgp = bgp_lookup_by_name (name);
9434 if (! bgp)
9435 {
9436 if (use_json)
9437 {
9438 json_object_boolean_true_add(json, "bgpNoSuchInstance");
e52702f2 9439 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
4fb25c53
DW
9440 json_object_free(json);
9441 }
9442 else
9443 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
9444
9445 return CMD_WARNING;
9446 }
9447 }
9448 }
9449 else
9450 {
9451 bgp = bgp_get_default ();
9452 }
9453
9454 if (bgp)
9455 {
9456 if (ip_str)
9457 {
9458 ret = str2sockunion (ip_str, &su);
9459 if (ret < 0)
9460 bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json);
9461 else
9462 bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json);
9463 }
9464 else
9465 {
9466 bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json);
9467 }
9468 }
9469
9470 return CMD_SUCCESS;
9471}
9472
716b2d8a 9473/* "show [ip] bgp neighbors" commands. */
718e3744 9474DEFUN (show_ip_bgp_neighbors,
9475 show_ip_bgp_neighbors_cmd,
91d37724 9476 "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6|vpnv4 <all|rd ASN:nn_or_IP-address:nn>>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
718e3744 9477 SHOW_STR
9478 IP_STR
9479 BGP_STR
f2a8972b 9480 BGP_INSTANCE_HELP_STR
8c3deaae
QY
9481 "Address Family\n"
9482 "Address Family\n"
91d37724
QY
9483 "Address Family\n"
9484 "Display information about all VPNv4 NLRIs\n"
9485 "Display information for a route distinguisher\n"
9486 "VPN Route Distinguisher\n"
718e3744 9487 "Detailed information on TCP and BGP neighbor connections\n"
9488 "Neighbor to display information about\n"
a80beece 9489 "Neighbor to display information about\n"
91d37724 9490 "Neighbor on BGP configured interface\n"
9973d184 9491 JSON_STR)
718e3744 9492{
5bf15956
DW
9493 char *vrf = NULL;
9494 char *sh_arg = NULL;
9495 enum show_type sh_type;
718e3744 9496
5bf15956 9497 u_char uj = use_json(argc, argv);
718e3744 9498
630a298c 9499 int idx = 0;
718e3744 9500
46854ac0
DS
9501 if (argv_find (argv, argc, "view", &idx) ||
9502 argv_find (argv, argc, "vrf", &idx))
9503 vrf = argv[idx+1]->arg;
718e3744 9504
46854ac0 9505 idx++;
91d37724
QY
9506 if (argv_find (argv, argc, "A.B.C.D", &idx) ||
9507 argv_find (argv, argc, "X:X::X:X", &idx) ||
630a298c
QY
9508 argv_find (argv, argc, "WORD", &idx))
9509 {
9510 sh_type = show_peer;
9511 sh_arg = argv[idx]->arg;
9512 }
5bf15956 9513 else
630a298c 9514 sh_type = show_all;
856ca177 9515
5bf15956 9516 return bgp_show_neighbor_vty (vty, vrf, sh_type, sh_arg, uj);
718e3744 9517}
9518
716b2d8a 9519/* Show BGP's AS paths internal data. There are both `show [ip] bgp
718e3744 9520 paths' and `show ip mbgp paths'. Those functions results are the
9521 same.*/
f412b39a 9522DEFUN (show_ip_bgp_paths,
718e3744 9523 show_ip_bgp_paths_cmd,
46f296b4 9524 "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths",
718e3744 9525 SHOW_STR
9526 IP_STR
9527 BGP_STR
46f296b4 9528 BGP_SAFI_HELP_STR
718e3744 9529 "Path information\n")
9530{
9531 vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE);
9532 aspath_print_all_vty (vty);
9533 return CMD_SUCCESS;
9534}
9535
718e3744 9536#include "hash.h"
9537
94f2b392 9538static void
718e3744 9539community_show_all_iterator (struct hash_backet *backet, struct vty *vty)
9540{
9541 struct community *com;
9542
9543 com = (struct community *) backet->data;
6c4f4e6e 9544 vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, com->refcnt,
718e3744 9545 community_str (com), VTY_NEWLINE);
9546}
9547
9548/* Show BGP's community internal data. */
f412b39a 9549DEFUN (show_ip_bgp_community_info,
718e3744 9550 show_ip_bgp_community_info_cmd,
bec37ba5 9551 "show [ip] bgp community-info",
718e3744 9552 SHOW_STR
9553 IP_STR
9554 BGP_STR
9555 "List all bgp community information\n")
9556{
9557 vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE);
9558
e52702f2 9559 hash_iterate (community_hash (),
718e3744 9560 (void (*) (struct hash_backet *, void *))
9561 community_show_all_iterator,
9562 vty);
9563
9564 return CMD_SUCCESS;
9565}
9566
57d187bc
JS
9567static void
9568lcommunity_show_all_iterator (struct hash_backet *backet, struct vty *vty)
9569{
9570 struct lcommunity *lcom;
9571
9572 lcom = (struct lcommunity *) backet->data;
9573 vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, lcom->refcnt,
2acb4ac2 9574 lcommunity_str (lcom), VTY_NEWLINE);
57d187bc
JS
9575}
9576
9577/* Show BGP's community internal data. */
9578DEFUN (show_ip_bgp_lcommunity_info,
9579 show_ip_bgp_lcommunity_info_cmd,
9580 "show ip bgp large-community-info",
9581 SHOW_STR
9582 IP_STR
9583 BGP_STR
9584 "List all bgp large-community information\n")
9585{
9586 vty_out (vty, "Address Refcnt Large-community%s", VTY_NEWLINE);
9587
9588 hash_iterate (lcommunity_hash (),
2acb4ac2
DL
9589 (void (*) (struct hash_backet *, void *))
9590 lcommunity_show_all_iterator,
9591 vty);
57d187bc
JS
9592
9593 return CMD_SUCCESS;
9594}
9595
9596
f412b39a 9597DEFUN (show_ip_bgp_attr_info,
718e3744 9598 show_ip_bgp_attr_info_cmd,
bec37ba5 9599 "show [ip] bgp attribute-info",
718e3744 9600 SHOW_STR
9601 IP_STR
9602 BGP_STR
9603 "List all bgp attribute information\n")
9604{
9605 attr_show_all (vty);
9606 return CMD_SUCCESS;
9607}
6b0655a2 9608
f186de26 9609static void
9610bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi)
9611{
9612 struct listnode *node, *nnode;
9613 struct bgp *bgp;
9614
9615 for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
9616 {
9617 vty_out (vty, "%sInstance %s:%s",
9618 VTY_NEWLINE,
9619 (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name,
9620 VTY_NEWLINE);
9621 update_group_show(bgp, afi, safi, vty, 0);
9622 }
9623}
9624
4fb25c53
DW
9625static int
9626bgp_show_update_groups(struct vty *vty, const char *name,
9627 int afi, int safi,
9628 uint64_t subgrp_id)
9629{
9630 struct bgp *bgp;
9631
9632 if (name)
9633 {
9634 if (strmatch (name, "all"))
9635 {
9636 bgp_show_all_instances_updgrps_vty (vty, afi, safi);
9637 return CMD_SUCCESS;
9638 }
9639 else
9640 {
9641 bgp = bgp_lookup_by_name (name);
9642 }
9643 }
9644 else
9645 {
9646 bgp = bgp_get_default ();
9647 }
9648
9649 if (bgp)
9650 update_group_show(bgp, afi, safi, vty, subgrp_id);
9651 return CMD_SUCCESS;
9652}
9653
8fe8a7f6
DS
9654DEFUN (show_ip_bgp_updgrps,
9655 show_ip_bgp_updgrps_cmd,
c9e571b4 9656 "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] update-groups [SUBGROUP-ID]",
8386ac43 9657 SHOW_STR
9658 IP_STR
9659 BGP_STR
9660 BGP_INSTANCE_HELP_STR
c9e571b4 9661 BGP_AFI_HELP_STR
46f296b4 9662 BGP_SAFI_HELP_STR
5bf15956
DW
9663 "Detailed info about dynamic update groups\n"
9664 "Specific subgroup to display detailed info for\n")
8386ac43 9665{
5bf15956 9666 char *vrf = NULL;
ae19d7dd
QY
9667 afi_t afi = AFI_IP6;
9668 safi_t safi = SAFI_UNICAST;
5bf15956
DW
9669 uint64_t subgrp_id = 0;
9670
ae19d7dd
QY
9671 int idx = 0;
9672
9673 /* show [ip] bgp */
9674 if (argv_find (argv, argc, "ip", &idx))
9675 afi = AFI_IP;
9676 /* [<view|vrf> WORD] */
9677 if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx))
9678 vrf = argv[++idx]->arg;
c9e571b4
LB
9679 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9680 if (argv_find_and_parse_afi (argv, argc, &idx, &afi))
9681 {
9682 argv_find_and_parse_safi (argv, argc, &idx, &safi);
9683 }
5bf15956 9684
ae19d7dd
QY
9685 /* get subgroup id, if provided */
9686 idx = argc - 1;
9687 if (argv[idx]->type == VARIABLE_TKN)
9688 VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx]->arg);
5bf15956
DW
9689
9690 return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id));
8fe8a7f6
DS
9691}
9692
f186de26 9693DEFUN (show_bgp_instance_all_ipv6_updgrps,
9694 show_bgp_instance_all_ipv6_updgrps_cmd,
716b2d8a 9695 "show [ip] bgp <view|vrf> all update-groups",
f186de26 9696 SHOW_STR
716b2d8a 9697 IP_STR
f186de26 9698 BGP_STR
9699 BGP_INSTANCE_ALL_HELP_STR
0c7b1b01 9700 "Detailed info about dynamic update groups\n")
f186de26 9701{
9702 bgp_show_all_instances_updgrps_vty (vty, AFI_IP6, SAFI_UNICAST);
9703 return CMD_SUCCESS;
9704}
9705
5bf15956
DW
9706DEFUN (show_bgp_updgrps_stats,
9707 show_bgp_updgrps_stats_cmd,
716b2d8a 9708 "show [ip] bgp update-groups statistics",
3f9c7369 9709 SHOW_STR
716b2d8a 9710 IP_STR
3f9c7369 9711 BGP_STR
0c7b1b01 9712 "Detailed info about dynamic update groups\n"
3f9c7369
DS
9713 "Statistics\n")
9714{
9715 struct bgp *bgp;
9716
9717 bgp = bgp_get_default();
9718 if (bgp)
9719 update_group_show_stats(bgp, vty);
9720
9721 return CMD_SUCCESS;
9722}
9723
8386ac43 9724DEFUN (show_bgp_instance_updgrps_stats,
9725 show_bgp_instance_updgrps_stats_cmd,
716b2d8a 9726 "show [ip] bgp <view|vrf> WORD update-groups statistics",
8386ac43 9727 SHOW_STR
716b2d8a 9728 IP_STR
8386ac43 9729 BGP_STR
9730 BGP_INSTANCE_HELP_STR
0c7b1b01 9731 "Detailed info about dynamic update groups\n"
8386ac43 9732 "Statistics\n")
9733{
c500ae40 9734 int idx_word = 3;
8386ac43 9735 struct bgp *bgp;
9736
c500ae40 9737 bgp = bgp_lookup_by_name (argv[idx_word]->arg);
8386ac43 9738 if (bgp)
9739 update_group_show_stats(bgp, vty);
9740
9741 return CMD_SUCCESS;
9742}
9743
3f9c7369 9744static void
8386ac43 9745show_bgp_updgrps_adj_info_aux (struct vty *vty, const char *name,
9746 afi_t afi, safi_t safi,
f43e655e 9747 const char *what, uint64_t subgrp_id)
3f9c7369
DS
9748{
9749 struct bgp *bgp;
8386ac43 9750
9751 if (name)
9752 bgp = bgp_lookup_by_name (name);
9753 else
9754 bgp = bgp_get_default ();
9755
3f9c7369
DS
9756 if (bgp)
9757 {
9758 if (!strcmp(what, "advertise-queue"))
9759 update_group_show_adj_queue(bgp, afi, safi, vty, subgrp_id);
9760 else if (!strcmp(what, "advertised-routes"))
9761 update_group_show_advertised(bgp, afi, safi, vty, subgrp_id);
9762 else if (!strcmp(what, "packet-queue"))
9763 update_group_show_packet_queue(bgp, afi, safi, vty, subgrp_id);
9764 }
9765}
9766
9767DEFUN (show_ip_bgp_updgrps_adj,
9768 show_ip_bgp_updgrps_adj_cmd,
716b2d8a 9769 "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>",
3f9c7369
DS
9770 SHOW_STR
9771 IP_STR
9772 BGP_STR
0c7b1b01 9773 "Detailed info about dynamic update groups\n"
3f9c7369
DS
9774 "Advertisement queue\n"
9775 "Announced routes\n"
9776 "Packet queue\n")
8fe8a7f6 9777
3f9c7369 9778{
c500ae40
DW
9779 int idx_type = 4;
9780 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0);
8386ac43 9781 return CMD_SUCCESS;
9782}
9783
9784DEFUN (show_ip_bgp_instance_updgrps_adj,
9785 show_ip_bgp_instance_updgrps_adj_cmd,
716b2d8a 9786 "show [ip] bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>",
8386ac43 9787 SHOW_STR
9788 IP_STR
9789 BGP_STR
9790 BGP_INSTANCE_HELP_STR
0c7b1b01 9791 "Detailed info about dynamic update groups\n"
8386ac43 9792 "Advertisement queue\n"
9793 "Announced routes\n"
9794 "Packet queue\n")
9795
9796{
c500ae40
DW
9797 int idx_word = 4;
9798 int idx_type = 6;
9799 show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0);
3f9c7369
DS
9800 return CMD_SUCCESS;
9801}
9802
9803DEFUN (show_bgp_updgrps_afi_adj,
9804 show_bgp_updgrps_afi_adj_cmd,
46f296b4 9805 "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups <advertise-queue|advertised-routes|packet-queue>",
3f9c7369 9806 SHOW_STR
716b2d8a 9807 IP_STR
3f9c7369 9808 BGP_STR
46f296b4 9809 BGP_AFI_SAFI_HELP_STR
0c7b1b01 9810 "Detailed info about dynamic update groups\n"
3f9c7369
DS
9811 "Advertisement queue\n"
9812 "Announced routes\n"
8fe8a7f6
DS
9813 "Packet queue\n"
9814 "Specific subgroup info wanted for\n")
3f9c7369 9815{
c500ae40
DW
9816 int idx_afi = 2;
9817 int idx_safi = 3;
9818 int idx_type = 5;
46f296b4
LB
9819 show_bgp_updgrps_adj_info_aux(vty, NULL,
9820 bgp_vty_afi_from_arg(argv[idx_afi]->arg),
9821 bgp_vty_safi_from_arg(argv[idx_safi]->arg),
9822 argv[idx_type]->arg, 0);
8fe8a7f6 9823 return CMD_SUCCESS;
3f9c7369
DS
9824}
9825
9826DEFUN (show_bgp_updgrps_adj,
9827 show_bgp_updgrps_adj_cmd,
716b2d8a 9828 "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>",
3f9c7369 9829 SHOW_STR
716b2d8a 9830 IP_STR
3f9c7369 9831 BGP_STR
0c7b1b01 9832 "Detailed info about dynamic update groups\n"
3f9c7369
DS
9833 "Advertisement queue\n"
9834 "Announced routes\n"
9835 "Packet queue\n")
9836{
c500ae40
DW
9837 int idx_type = 3;
9838 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0);
8386ac43 9839 return CMD_SUCCESS;
9840}
9841
9842DEFUN (show_bgp_instance_updgrps_adj,
9843 show_bgp_instance_updgrps_adj_cmd,
716b2d8a 9844 "show [ip] bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>",
8386ac43 9845 SHOW_STR
716b2d8a 9846 IP_STR
8386ac43 9847 BGP_STR
9848 BGP_INSTANCE_HELP_STR
0c7b1b01 9849 "Detailed info about dynamic update groups\n"
8386ac43 9850 "Advertisement queue\n"
9851 "Announced routes\n"
9852 "Packet queue\n")
9853{
c500ae40
DW
9854 int idx_word = 3;
9855 int idx_type = 5;
9856 show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0);
3f9c7369
DS
9857 return CMD_SUCCESS;
9858}
9859
9860DEFUN (show_ip_bgp_updgrps_adj_s,
8fe8a7f6 9861 show_ip_bgp_updgrps_adj_s_cmd,
716b2d8a 9862 "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
3f9c7369
DS
9863 SHOW_STR
9864 IP_STR
9865 BGP_STR
0c7b1b01 9866 "Detailed info about dynamic update groups\n"
8fe8a7f6 9867 "Specific subgroup to display info for\n"
3f9c7369
DS
9868 "Advertisement queue\n"
9869 "Announced routes\n"
9870 "Packet queue\n")
3f9c7369 9871
3f9c7369 9872{
5bf15956 9873 int idx_subgroup_id = 4;
c500ae40 9874 int idx_type = 5;
f43e655e 9875 uint64_t subgrp_id;
8fe8a7f6 9876
5bf15956 9877 VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg);
8fe8a7f6 9878
5bf15956 9879 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id);
8386ac43 9880 return CMD_SUCCESS;
9881}
9882
9883DEFUN (show_ip_bgp_instance_updgrps_adj_s,
9884 show_ip_bgp_instance_updgrps_adj_s_cmd,
716b2d8a 9885 "show [ip] bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
8386ac43 9886 SHOW_STR
9887 IP_STR
9888 BGP_STR
9889 BGP_INSTANCE_HELP_STR
0c7b1b01 9890 "Detailed info about dynamic update groups\n"
8386ac43 9891 "Specific subgroup to display info for\n"
9892 "Advertisement queue\n"
9893 "Announced routes\n"
9894 "Packet queue\n")
9895
9896{
5bf15956
DW
9897 int idx_vrf = 4;
9898 int idx_subgroup_id = 6;
c500ae40 9899 int idx_type = 7;
f43e655e 9900 uint64_t subgrp_id;
8386ac43 9901
5bf15956 9902 VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg);
8386ac43 9903
5bf15956 9904 show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id);
3f9c7369
DS
9905 return CMD_SUCCESS;
9906}
9907
8fe8a7f6
DS
9908DEFUN (show_bgp_updgrps_afi_adj_s,
9909 show_bgp_updgrps_afi_adj_s_cmd,
46f296b4 9910 "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
3f9c7369 9911 SHOW_STR
716b2d8a 9912 IP_STR
3f9c7369 9913 BGP_STR
46f296b4 9914 BGP_AFI_SAFI_HELP_STR
0c7b1b01 9915 "Detailed info about dynamic update groups\n"
8fe8a7f6 9916 "Specific subgroup to display info for\n"
3f9c7369
DS
9917 "Advertisement queue\n"
9918 "Announced routes\n"
8fe8a7f6
DS
9919 "Packet queue\n"
9920 "Specific subgroup info wanted for\n")
3f9c7369 9921{
c500ae40
DW
9922 int idx_afi = 2;
9923 int idx_safi = 3;
5bf15956 9924 int idx_subgroup_id = 5;
c500ae40 9925 int idx_type = 6;
f43e655e 9926 uint64_t subgrp_id;
3f9c7369 9927
5bf15956 9928 VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg);
8fe8a7f6 9929
46f296b4
LB
9930 show_bgp_updgrps_adj_info_aux(vty, NULL,
9931 bgp_vty_afi_from_arg(argv[idx_afi]->arg),
9932 bgp_vty_safi_from_arg(argv[idx_safi]->arg),
9933 argv[idx_type]->arg, subgrp_id);
8fe8a7f6 9934 return CMD_SUCCESS;
3f9c7369
DS
9935}
9936
8fe8a7f6
DS
9937DEFUN (show_bgp_updgrps_adj_s,
9938 show_bgp_updgrps_adj_s_cmd,
716b2d8a 9939 "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
8fe8a7f6 9940 SHOW_STR
716b2d8a 9941 IP_STR
8fe8a7f6 9942 BGP_STR
0c7b1b01 9943 "Detailed info about dynamic update groups\n"
8fe8a7f6
DS
9944 "Specific subgroup to display info for\n"
9945 "Advertisement queue\n"
9946 "Announced routes\n"
9947 "Packet queue\n")
9948{
5bf15956 9949 int idx_subgroup_id = 3;
c500ae40 9950 int idx_type = 4;
f43e655e 9951 uint64_t subgrp_id;
8fe8a7f6 9952
5bf15956 9953 VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg);
8fe8a7f6 9954
5bf15956 9955 show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id);
8fe8a7f6
DS
9956 return CMD_SUCCESS;
9957}
9958
8386ac43 9959DEFUN (show_bgp_instance_updgrps_adj_s,
9960 show_bgp_instance_updgrps_adj_s_cmd,
716b2d8a 9961 "show [ip] bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>",
8386ac43 9962 SHOW_STR
716b2d8a 9963 IP_STR
8386ac43 9964 BGP_STR
9965 BGP_INSTANCE_HELP_STR
0c7b1b01 9966 "Detailed info about dynamic update groups\n"
8386ac43 9967 "Specific subgroup to display info for\n"
9968 "Advertisement queue\n"
9969 "Announced routes\n"
9970 "Packet queue\n")
9971{
5bf15956
DW
9972 int idx_vrf = 3;
9973 int idx_subgroup_id = 5;
c500ae40 9974 int idx_type = 6;
f43e655e 9975 uint64_t subgrp_id;
8386ac43 9976
5bf15956 9977 VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg);
8386ac43 9978
5bf15956 9979 show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id);
8386ac43 9980 return CMD_SUCCESS;
9981}
9982
9983
8fe8a7f6 9984
f14e6fdb
DS
9985static int
9986bgp_show_one_peer_group (struct vty *vty, struct peer_group *group)
9987{
9988 struct listnode *node, *nnode;
9989 struct prefix *range;
9990 struct peer *conf;
9991 struct peer *peer;
4690c7d7 9992 char buf[PREFIX2STR_BUFFER];
f14e6fdb
DS
9993 afi_t afi;
9994 safi_t safi;
ffd0c037
DS
9995 const char *peer_status;
9996 const char *af_str;
f14e6fdb
DS
9997 int lr_count;
9998 int dynamic;
9999 int af_cfgd;
10000
10001 conf = group->conf;
10002
0299c004
DS
10003 if (conf->as_type == AS_SPECIFIED ||
10004 conf->as_type == AS_EXTERNAL) {
66b199b2 10005 vty_out (vty, "%sBGP peer-group %s, remote AS %d%s",
f14e6fdb 10006 VTY_NEWLINE, group->name, conf->as, VTY_NEWLINE);
0299c004 10007 } else if (conf->as_type == AS_INTERNAL) {
66b199b2 10008 vty_out (vty, "%sBGP peer-group %s, remote AS %d%s",
0299c004 10009 VTY_NEWLINE, group->name, group->bgp->as, VTY_NEWLINE);
66b199b2
DS
10010 } else {
10011 vty_out (vty, "%sBGP peer-group %s%s",
10012 VTY_NEWLINE, group->name, VTY_NEWLINE);
0299c004 10013 }
f14e6fdb 10014
0299c004 10015 if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL))
f14e6fdb
DS
10016 vty_out (vty, " Peer-group type is internal%s", VTY_NEWLINE);
10017 else
10018 vty_out (vty, " Peer-group type is external%s", VTY_NEWLINE);
10019
10020 /* Display AFs configured. */
10021 vty_out (vty, " Configured address-families:");
10022 for (afi = AFI_IP; afi < AFI_MAX; afi++)
10023 for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++)
10024 {
10025 if (conf->afc[afi][safi])
10026 {
10027 af_cfgd = 1;
10028 vty_out (vty, " %s;", afi_safi_print(afi, safi));
10029 }
10030 }
10031 if (!af_cfgd)
10032 vty_out (vty, " none%s", VTY_NEWLINE);
10033 else
10034 vty_out (vty, "%s", VTY_NEWLINE);
10035
10036 /* Display listen ranges (for dynamic neighbors), if any */
10037 for (afi = AFI_IP; afi < AFI_MAX; afi++)
10038 {
10039 if (afi == AFI_IP)
10040 af_str = "IPv4";
10041 else if (afi == AFI_IP6)
10042 af_str = "IPv6";
45ef4300
DL
10043 else
10044 af_str = "???";
f14e6fdb
DS
10045 lr_count = listcount(group->listen_range[afi]);
10046 if (lr_count)
10047 {
10048 vty_out(vty,
10049 " %d %s listen range(s)%s",
10050 lr_count, af_str, VTY_NEWLINE);
10051
10052
10053 for (ALL_LIST_ELEMENTS (group->listen_range[afi], node,
10054 nnode, range))
10055 {
10056 prefix2str(range, buf, sizeof(buf));
10057 vty_out(vty, " %s%s", buf, VTY_NEWLINE);
10058 }
10059 }
10060 }
10061
10062 /* Display group members and their status */
10063 if (listcount(group->peer))
10064 {
10065 vty_out (vty, " Peer-group members:%s", VTY_NEWLINE);
10066 for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
10067 {
10068 if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN))
10069 peer_status = "Idle (Admin)";
10070 else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
10071 peer_status = "Idle (PfxCt)";
10072 else
10073 peer_status = LOOKUP(bgp_status_msg, peer->status);
10074
10075 dynamic = peer_dynamic_neighbor(peer);
10076 vty_out (vty, " %s %s %s %s",
10077 peer->host, dynamic ? "(dynamic)" : "",
10078 peer_status, VTY_NEWLINE);
10079 }
10080 }
10081
10082 return CMD_SUCCESS;
10083}
10084
10085/* Show BGP peer group's information. */
10086enum show_group_type
10087{
10088 show_all_groups,
10089 show_peer_group
10090};
10091
10092static int
10093bgp_show_peer_group (struct vty *vty, struct bgp *bgp,
10094 enum show_group_type type, const char *group_name)
10095{
10096 struct listnode *node, *nnode;
10097 struct peer_group *group;
10098 int find = 0;
10099
10100 for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
10101 {
10102 switch (type)
10103 {
10104 case show_all_groups:
10105 bgp_show_one_peer_group (vty, group);
10106 break;
10107 case show_peer_group:
10108 if (group_name && (strcmp(group->name, group_name) == 0))
10109 {
10110 find = 1;
10111 bgp_show_one_peer_group (vty, group);
10112 }
10113 break;
10114 }
10115 }
10116
10117 if (type == show_peer_group && ! find)
6d9e66dc 10118 vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE);
f14e6fdb
DS
10119
10120 return CMD_SUCCESS;
10121}
10122
10123static int
10124bgp_show_peer_group_vty (struct vty *vty, const char *name,
10125 enum show_group_type type, const char *group_name)
10126{
10127 struct bgp *bgp;
10128 int ret = CMD_SUCCESS;
10129
10130 if (name)
8386ac43 10131 bgp = bgp_lookup_by_name (name);
10132 else
10133 bgp = bgp_get_default ();
f14e6fdb 10134
8386ac43 10135 if (! bgp)
10136 {
10137 vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE);
10138 return CMD_WARNING;
f14e6fdb
DS
10139 }
10140
8386ac43 10141 ret = bgp_show_peer_group (vty, bgp, type, group_name);
f14e6fdb
DS
10142
10143 return ret;
10144}
10145
10146DEFUN (show_ip_bgp_peer_groups,
10147 show_ip_bgp_peer_groups_cmd,
f2a8972b 10148 "show [ip] bgp [<view|vrf> WORD] peer-group [PGNAME]",
f14e6fdb
DS
10149 SHOW_STR
10150 IP_STR
10151 BGP_STR
8386ac43 10152 BGP_INSTANCE_HELP_STR
d6e3c605
QY
10153 "Detailed information on BGP peer groups\n"
10154 "Peer group name\n")
f14e6fdb 10155{
d6e3c605
QY
10156 char *vrf, *pg;
10157 vrf = pg = NULL;
10158 int idx = 0;
f14e6fdb 10159
f2a8972b 10160 vrf = argv_find (argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL;
d6e3c605 10161 pg = argv_find (argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL;
f14e6fdb 10162
d6e3c605 10163 return bgp_show_peer_group_vty (vty, vrf, show_all_groups, pg);
f14e6fdb 10164}
3f9c7369 10165
d6e3c605 10166
718e3744 10167/* Redistribute VTY commands. */
10168
718e3744 10169DEFUN (bgp_redistribute_ipv4,
10170 bgp_redistribute_ipv4_cmd,
40d1cbfb 10171 "redistribute " FRR_IP_REDIST_STR_BGPD,
718e3744 10172 "Redistribute information from another routing protocol\n"
ab0181ee 10173 FRR_IP_REDIST_HELP_STR_BGPD)
718e3744 10174{
cdc2d765 10175 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40 10176 int idx_protocol = 1;
718e3744 10177 int type;
10178
6d681bd8
QY
10179 type = proto_redistnum (AFI_IP, argv[idx_protocol]->text);
10180 if (type < 0)
718e3744 10181 {
10182 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10183 return CMD_WARNING;
10184 }
cdc2d765
DL
10185 bgp_redist_add(bgp, AFI_IP, type, 0);
10186 return bgp_redistribute_set (bgp, AFI_IP, type, 0);
718e3744 10187}
10188
596c17ba
DW
10189ALIAS_HIDDEN (bgp_redistribute_ipv4,
10190 bgp_redistribute_ipv4_hidden_cmd,
10191 "redistribute " FRR_IP_REDIST_STR_BGPD,
10192 "Redistribute information from another routing protocol\n"
10193 FRR_IP_REDIST_HELP_STR_BGPD)
10194
718e3744 10195DEFUN (bgp_redistribute_ipv4_rmap,
10196 bgp_redistribute_ipv4_rmap_cmd,
40d1cbfb 10197 "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD",
718e3744 10198 "Redistribute information from another routing protocol\n"
ab0181ee 10199 FRR_IP_REDIST_HELP_STR_BGPD
718e3744 10200 "Route map reference\n"
10201 "Pointer to route-map entries\n")
10202{
cdc2d765 10203 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40
DW
10204 int idx_protocol = 1;
10205 int idx_word = 3;
718e3744 10206 int type;
7c8ff89e 10207 struct bgp_redist *red;
718e3744 10208
6d681bd8
QY
10209 type = proto_redistnum (AFI_IP, argv[idx_protocol]->text);
10210 if (type < 0)
718e3744 10211 {
10212 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10213 return CMD_WARNING;
10214 }
10215
cdc2d765 10216 red = bgp_redist_add(bgp, AFI_IP, type, 0);
c500ae40 10217 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
cdc2d765 10218 return bgp_redistribute_set (bgp, AFI_IP, type, 0);
718e3744 10219}
10220
596c17ba
DW
10221ALIAS_HIDDEN (bgp_redistribute_ipv4_rmap,
10222 bgp_redistribute_ipv4_rmap_hidden_cmd,
10223 "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD",
10224 "Redistribute information from another routing protocol\n"
10225 FRR_IP_REDIST_HELP_STR_BGPD
10226 "Route map reference\n"
10227 "Pointer to route-map entries\n")
10228
718e3744 10229DEFUN (bgp_redistribute_ipv4_metric,
10230 bgp_redistribute_ipv4_metric_cmd,
40d1cbfb 10231 "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)",
718e3744 10232 "Redistribute information from another routing protocol\n"
ab0181ee 10233 FRR_IP_REDIST_HELP_STR_BGPD
718e3744 10234 "Metric for redistributed routes\n"
10235 "Default metric\n")
10236{
cdc2d765 10237 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40
DW
10238 int idx_protocol = 1;
10239 int idx_number = 3;
718e3744 10240 int type;
10241 u_int32_t metric;
7c8ff89e 10242 struct bgp_redist *red;
718e3744 10243
6d681bd8
QY
10244 type = proto_redistnum (AFI_IP, argv[idx_protocol]->text);
10245 if (type < 0)
718e3744 10246 {
10247 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10248 return CMD_WARNING;
10249 }
c500ae40 10250 VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
718e3744 10251
cdc2d765
DL
10252 red = bgp_redist_add(bgp, AFI_IP, type, 0);
10253 bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric);
10254 return bgp_redistribute_set (bgp, AFI_IP, type, 0);
718e3744 10255}
10256
596c17ba
DW
10257ALIAS_HIDDEN (bgp_redistribute_ipv4_metric,
10258 bgp_redistribute_ipv4_metric_hidden_cmd,
10259 "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)",
10260 "Redistribute information from another routing protocol\n"
10261 FRR_IP_REDIST_HELP_STR_BGPD
10262 "Metric for redistributed routes\n"
10263 "Default metric\n")
10264
718e3744 10265DEFUN (bgp_redistribute_ipv4_rmap_metric,
10266 bgp_redistribute_ipv4_rmap_metric_cmd,
40d1cbfb 10267 "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)",
718e3744 10268 "Redistribute information from another routing protocol\n"
ab0181ee 10269 FRR_IP_REDIST_HELP_STR_BGPD
718e3744 10270 "Route map reference\n"
10271 "Pointer to route-map entries\n"
10272 "Metric for redistributed routes\n"
10273 "Default metric\n")
10274{
cdc2d765 10275 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40
DW
10276 int idx_protocol = 1;
10277 int idx_word = 3;
10278 int idx_number = 5;
718e3744 10279 int type;
10280 u_int32_t metric;
7c8ff89e 10281 struct bgp_redist *red;
718e3744 10282
6d681bd8
QY
10283 type = proto_redistnum (AFI_IP, argv[idx_protocol]->text);
10284 if (type < 0)
718e3744 10285 {
10286 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10287 return CMD_WARNING;
10288 }
c500ae40 10289 VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
718e3744 10290
cdc2d765 10291 red = bgp_redist_add(bgp, AFI_IP, type, 0);
c500ae40 10292 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
cdc2d765
DL
10293 bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric);
10294 return bgp_redistribute_set (bgp, AFI_IP, type, 0);
718e3744 10295}
10296
596c17ba
DW
10297ALIAS_HIDDEN (bgp_redistribute_ipv4_rmap_metric,
10298 bgp_redistribute_ipv4_rmap_metric_hidden_cmd,
10299 "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)",
10300 "Redistribute information from another routing protocol\n"
10301 FRR_IP_REDIST_HELP_STR_BGPD
10302 "Route map reference\n"
10303 "Pointer to route-map entries\n"
10304 "Metric for redistributed routes\n"
10305 "Default metric\n")
10306
718e3744 10307DEFUN (bgp_redistribute_ipv4_metric_rmap,
10308 bgp_redistribute_ipv4_metric_rmap_cmd,
40d1cbfb 10309 "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD",
718e3744 10310 "Redistribute information from another routing protocol\n"
ab0181ee 10311 FRR_IP_REDIST_HELP_STR_BGPD
718e3744 10312 "Metric for redistributed routes\n"
10313 "Default metric\n"
10314 "Route map reference\n"
10315 "Pointer to route-map entries\n")
10316{
cdc2d765 10317 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40
DW
10318 int idx_protocol = 1;
10319 int idx_number = 3;
10320 int idx_word = 5;
718e3744 10321 int type;
10322 u_int32_t metric;
7c8ff89e 10323 struct bgp_redist *red;
718e3744 10324
6d681bd8
QY
10325 type = proto_redistnum (AFI_IP, argv[idx_protocol]->text);
10326 if (type < 0)
718e3744 10327 {
10328 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10329 return CMD_WARNING;
10330 }
c500ae40 10331 VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
718e3744 10332
cdc2d765
DL
10333 red = bgp_redist_add(bgp, AFI_IP, type, 0);
10334 bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric);
c500ae40 10335 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
cdc2d765 10336 return bgp_redistribute_set (bgp, AFI_IP, type, 0);
718e3744 10337}
10338
596c17ba
DW
10339ALIAS_HIDDEN (bgp_redistribute_ipv4_metric_rmap,
10340 bgp_redistribute_ipv4_metric_rmap_hidden_cmd,
10341 "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD",
10342 "Redistribute information from another routing protocol\n"
10343 FRR_IP_REDIST_HELP_STR_BGPD
10344 "Metric for redistributed routes\n"
10345 "Default metric\n"
10346 "Route map reference\n"
10347 "Pointer to route-map entries\n")
10348
7c8ff89e
DS
10349DEFUN (bgp_redistribute_ipv4_ospf,
10350 bgp_redistribute_ipv4_ospf_cmd,
6147e2c6 10351 "redistribute <ospf|table> (1-65535)",
7c8ff89e
DS
10352 "Redistribute information from another routing protocol\n"
10353 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
10354 "Non-main Kernel Routing Table\n"
10355 "Instance ID/Table ID\n")
7c8ff89e 10356{
cdc2d765 10357 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40
DW
10358 int idx_ospf_table = 1;
10359 int idx_number = 2;
7c8ff89e 10360 u_short instance;
7a4bb9c5 10361 u_short protocol;
7c8ff89e 10362
c500ae40 10363 VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
7a4bb9c5 10364
c500ae40 10365 if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
7a4bb9c5
DS
10366 protocol = ZEBRA_ROUTE_OSPF;
10367 else
10368 protocol = ZEBRA_ROUTE_TABLE;
10369
cdc2d765
DL
10370 bgp_redist_add(bgp, AFI_IP, protocol, instance);
10371 return bgp_redistribute_set (bgp, AFI_IP, protocol, instance);
7c8ff89e
DS
10372}
10373
596c17ba
DW
10374ALIAS_HIDDEN (bgp_redistribute_ipv4_ospf,
10375 bgp_redistribute_ipv4_ospf_hidden_cmd,
10376 "redistribute <ospf|table> (1-65535)",
10377 "Redistribute information from another routing protocol\n"
10378 "Open Shortest Path First (OSPFv2)\n"
10379 "Non-main Kernel Routing Table\n"
10380 "Instance ID/Table ID\n")
10381
7c8ff89e
DS
10382DEFUN (bgp_redistribute_ipv4_ospf_rmap,
10383 bgp_redistribute_ipv4_ospf_rmap_cmd,
6147e2c6 10384 "redistribute <ospf|table> (1-65535) route-map WORD",
7c8ff89e
DS
10385 "Redistribute information from another routing protocol\n"
10386 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
10387 "Non-main Kernel Routing Table\n"
10388 "Instance ID/Table ID\n"
7c8ff89e
DS
10389 "Route map reference\n"
10390 "Pointer to route-map entries\n")
10391{
cdc2d765 10392 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40
DW
10393 int idx_ospf_table = 1;
10394 int idx_number = 2;
10395 int idx_word = 4;
7c8ff89e
DS
10396 struct bgp_redist *red;
10397 u_short instance;
7a4bb9c5 10398 int protocol;
7c8ff89e 10399
c500ae40 10400 if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
7a4bb9c5
DS
10401 protocol = ZEBRA_ROUTE_OSPF;
10402 else
10403 protocol = ZEBRA_ROUTE_TABLE;
10404
c500ae40 10405 VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
cdc2d765 10406 red = bgp_redist_add(bgp, AFI_IP, protocol, instance);
c500ae40 10407 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
cdc2d765 10408 return bgp_redistribute_set (bgp, AFI_IP, protocol, instance);
7c8ff89e
DS
10409}
10410
596c17ba
DW
10411ALIAS_HIDDEN (bgp_redistribute_ipv4_ospf_rmap,
10412 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd,
10413 "redistribute <ospf|table> (1-65535) route-map WORD",
10414 "Redistribute information from another routing protocol\n"
10415 "Open Shortest Path First (OSPFv2)\n"
10416 "Non-main Kernel Routing Table\n"
10417 "Instance ID/Table ID\n"
10418 "Route map reference\n"
10419 "Pointer to route-map entries\n")
10420
7c8ff89e
DS
10421DEFUN (bgp_redistribute_ipv4_ospf_metric,
10422 bgp_redistribute_ipv4_ospf_metric_cmd,
6147e2c6 10423 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
7c8ff89e
DS
10424 "Redistribute information from another routing protocol\n"
10425 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
10426 "Non-main Kernel Routing Table\n"
10427 "Instance ID/Table ID\n"
7c8ff89e
DS
10428 "Metric for redistributed routes\n"
10429 "Default metric\n")
10430{
cdc2d765 10431 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40
DW
10432 int idx_ospf_table = 1;
10433 int idx_number = 2;
10434 int idx_number_2 = 4;
7c8ff89e
DS
10435 u_int32_t metric;
10436 struct bgp_redist *red;
10437 u_short instance;
7a4bb9c5 10438 int protocol;
7c8ff89e 10439
c500ae40 10440 if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
7a4bb9c5
DS
10441 protocol = ZEBRA_ROUTE_OSPF;
10442 else
10443 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 10444
c500ae40
DW
10445 VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
10446 VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg);
7a4bb9c5 10447
cdc2d765
DL
10448 red = bgp_redist_add(bgp, AFI_IP, protocol, instance);
10449 bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric);
10450 return bgp_redistribute_set (bgp, AFI_IP, protocol, instance);
7c8ff89e
DS
10451}
10452
596c17ba
DW
10453ALIAS_HIDDEN (bgp_redistribute_ipv4_ospf_metric,
10454 bgp_redistribute_ipv4_ospf_metric_hidden_cmd,
10455 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
10456 "Redistribute information from another routing protocol\n"
10457 "Open Shortest Path First (OSPFv2)\n"
10458 "Non-main Kernel Routing Table\n"
10459 "Instance ID/Table ID\n"
10460 "Metric for redistributed routes\n"
10461 "Default metric\n")
10462
7c8ff89e
DS
10463DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric,
10464 bgp_redistribute_ipv4_ospf_rmap_metric_cmd,
6147e2c6 10465 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
7c8ff89e
DS
10466 "Redistribute information from another routing protocol\n"
10467 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
10468 "Non-main Kernel Routing Table\n"
10469 "Instance ID/Table ID\n"
7c8ff89e
DS
10470 "Route map reference\n"
10471 "Pointer to route-map entries\n"
10472 "Metric for redistributed routes\n"
10473 "Default metric\n")
10474{
cdc2d765 10475 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40
DW
10476 int idx_ospf_table = 1;
10477 int idx_number = 2;
10478 int idx_word = 4;
10479 int idx_number_2 = 6;
7c8ff89e
DS
10480 u_int32_t metric;
10481 struct bgp_redist *red;
10482 u_short instance;
7a4bb9c5 10483 int protocol;
7c8ff89e 10484
c500ae40 10485 if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
7a4bb9c5
DS
10486 protocol = ZEBRA_ROUTE_OSPF;
10487 else
10488 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 10489
c500ae40
DW
10490 VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
10491 VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg);
7a4bb9c5 10492
cdc2d765 10493 red = bgp_redist_add(bgp, AFI_IP, protocol, instance);
c500ae40 10494 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
cdc2d765
DL
10495 bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric);
10496 return bgp_redistribute_set (bgp, AFI_IP, protocol, instance);
7c8ff89e
DS
10497}
10498
596c17ba
DW
10499ALIAS_HIDDEN (bgp_redistribute_ipv4_ospf_rmap_metric,
10500 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd,
10501 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
10502 "Redistribute information from another routing protocol\n"
10503 "Open Shortest Path First (OSPFv2)\n"
10504 "Non-main Kernel Routing Table\n"
10505 "Instance ID/Table ID\n"
10506 "Route map reference\n"
10507 "Pointer to route-map entries\n"
10508 "Metric for redistributed routes\n"
10509 "Default metric\n")
10510
7c8ff89e
DS
10511DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap,
10512 bgp_redistribute_ipv4_ospf_metric_rmap_cmd,
6147e2c6 10513 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
7c8ff89e
DS
10514 "Redistribute information from another routing protocol\n"
10515 "Open Shortest Path First (OSPFv2)\n"
2d627ff5
DS
10516 "Non-main Kernel Routing Table\n"
10517 "Instance ID/Table ID\n"
7c8ff89e
DS
10518 "Metric for redistributed routes\n"
10519 "Default metric\n"
10520 "Route map reference\n"
10521 "Pointer to route-map entries\n")
10522{
cdc2d765 10523 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40
DW
10524 int idx_ospf_table = 1;
10525 int idx_number = 2;
10526 int idx_number_2 = 4;
10527 int idx_word = 6;
7c8ff89e
DS
10528 u_int32_t metric;
10529 struct bgp_redist *red;
10530 u_short instance;
7a4bb9c5 10531 int protocol;
7c8ff89e 10532
c500ae40 10533 if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
7a4bb9c5
DS
10534 protocol = ZEBRA_ROUTE_OSPF;
10535 else
10536 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 10537
c500ae40
DW
10538 VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
10539 VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg);
7a4bb9c5 10540
cdc2d765
DL
10541 red = bgp_redist_add(bgp, AFI_IP, protocol, instance);
10542 bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric);
c500ae40 10543 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
cdc2d765 10544 return bgp_redistribute_set (bgp, AFI_IP, protocol, instance);
7c8ff89e
DS
10545}
10546
596c17ba
DW
10547ALIAS_HIDDEN (bgp_redistribute_ipv4_ospf_metric_rmap,
10548 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd,
10549 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
10550 "Redistribute information from another routing protocol\n"
10551 "Open Shortest Path First (OSPFv2)\n"
10552 "Non-main Kernel Routing Table\n"
10553 "Instance ID/Table ID\n"
10554 "Metric for redistributed routes\n"
10555 "Default metric\n"
10556 "Route map reference\n"
10557 "Pointer to route-map entries\n")
10558
7c8ff89e
DS
10559DEFUN (no_bgp_redistribute_ipv4_ospf,
10560 no_bgp_redistribute_ipv4_ospf_cmd,
d04c479d 10561 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
7c8ff89e
DS
10562 NO_STR
10563 "Redistribute information from another routing protocol\n"
10564 "Open Shortest Path First (OSPFv2)\n"
2d627ff5 10565 "Non-main Kernel Routing Table\n"
31500417
DW
10566 "Instance ID/Table ID\n"
10567 "Metric for redistributed routes\n"
10568 "Default metric\n"
10569 "Route map reference\n"
10570 "Pointer to route-map entries\n")
7c8ff89e 10571{
cdc2d765 10572 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40
DW
10573 int idx_ospf_table = 2;
10574 int idx_number = 3;
7c8ff89e 10575 u_short instance;
7a4bb9c5
DS
10576 int protocol;
10577
c500ae40 10578 if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0)
7a4bb9c5
DS
10579 protocol = ZEBRA_ROUTE_OSPF;
10580 else
10581 protocol = ZEBRA_ROUTE_TABLE;
7c8ff89e 10582
c500ae40 10583 VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg);
cdc2d765 10584 return bgp_redistribute_unset (bgp, AFI_IP, protocol, instance);
7c8ff89e
DS
10585}
10586
596c17ba
DW
10587ALIAS_HIDDEN (no_bgp_redistribute_ipv4_ospf,
10588 no_bgp_redistribute_ipv4_ospf_hidden_cmd,
10589 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
10590 NO_STR
10591 "Redistribute information from another routing protocol\n"
10592 "Open Shortest Path First (OSPFv2)\n"
10593 "Non-main Kernel Routing Table\n"
10594 "Instance ID/Table ID\n"
10595 "Metric for redistributed routes\n"
10596 "Default metric\n"
10597 "Route map reference\n"
10598 "Pointer to route-map entries\n")
10599
718e3744 10600DEFUN (no_bgp_redistribute_ipv4,
10601 no_bgp_redistribute_ipv4_cmd,
40d1cbfb 10602 "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]",
718e3744 10603 NO_STR
10604 "Redistribute information from another routing protocol\n"
3b14d86e 10605 FRR_IP_REDIST_HELP_STR_BGPD
31500417
DW
10606 "Metric for redistributed routes\n"
10607 "Default metric\n"
10608 "Route map reference\n"
10609 "Pointer to route-map entries\n")
718e3744 10610{
cdc2d765 10611 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40 10612 int idx_protocol = 2;
718e3744 10613 int type;
10614
6d681bd8
QY
10615 type = proto_redistnum (AFI_IP, argv[idx_protocol]->text);
10616 if (type < 0)
718e3744 10617 {
10618 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10619 return CMD_WARNING;
10620 }
cdc2d765 10621 return bgp_redistribute_unset (bgp, AFI_IP, type, 0);
718e3744 10622}
10623
596c17ba
DW
10624ALIAS_HIDDEN (no_bgp_redistribute_ipv4,
10625 no_bgp_redistribute_ipv4_hidden_cmd,
10626 "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]",
10627 NO_STR
10628 "Redistribute information from another routing protocol\n"
10629 FRR_IP_REDIST_HELP_STR_BGPD
10630 "Metric for redistributed routes\n"
10631 "Default metric\n"
10632 "Route map reference\n"
10633 "Pointer to route-map entries\n")
10634
718e3744 10635DEFUN (bgp_redistribute_ipv6,
10636 bgp_redistribute_ipv6_cmd,
40d1cbfb 10637 "redistribute " FRR_IP6_REDIST_STR_BGPD,
718e3744 10638 "Redistribute information from another routing protocol\n"
ab0181ee 10639 FRR_IP6_REDIST_HELP_STR_BGPD)
718e3744 10640{
cdc2d765 10641 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40 10642 int idx_protocol = 1;
718e3744 10643 int type;
10644
6d681bd8
QY
10645 type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text);
10646 if (type < 0)
718e3744 10647 {
10648 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10649 return CMD_WARNING;
10650 }
10651
cdc2d765
DL
10652 bgp_redist_add(bgp, AFI_IP6, type, 0);
10653 return bgp_redistribute_set (bgp, AFI_IP6, type, 0);
718e3744 10654}
10655
10656DEFUN (bgp_redistribute_ipv6_rmap,
10657 bgp_redistribute_ipv6_rmap_cmd,
40d1cbfb 10658 "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD",
718e3744 10659 "Redistribute information from another routing protocol\n"
ab0181ee 10660 FRR_IP6_REDIST_HELP_STR_BGPD
718e3744 10661 "Route map reference\n"
10662 "Pointer to route-map entries\n")
10663{
cdc2d765 10664 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40
DW
10665 int idx_protocol = 1;
10666 int idx_word = 3;
718e3744 10667 int type;
7c8ff89e 10668 struct bgp_redist *red;
718e3744 10669
6d681bd8
QY
10670 type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text);
10671 if (type < 0)
718e3744 10672 {
10673 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10674 return CMD_WARNING;
10675 }
10676
cdc2d765 10677 red = bgp_redist_add(bgp, AFI_IP6, type, 0);
c500ae40 10678 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
cdc2d765 10679 return bgp_redistribute_set (bgp, AFI_IP6, type, 0);
718e3744 10680}
10681
10682DEFUN (bgp_redistribute_ipv6_metric,
10683 bgp_redistribute_ipv6_metric_cmd,
40d1cbfb 10684 "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)",
718e3744 10685 "Redistribute information from another routing protocol\n"
ab0181ee 10686 FRR_IP6_REDIST_HELP_STR_BGPD
718e3744 10687 "Metric for redistributed routes\n"
10688 "Default metric\n")
10689{
cdc2d765 10690 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40
DW
10691 int idx_protocol = 1;
10692 int idx_number = 3;
718e3744 10693 int type;
10694 u_int32_t metric;
7c8ff89e 10695 struct bgp_redist *red;
718e3744 10696
6d681bd8
QY
10697 type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text);
10698 if (type < 0)
718e3744 10699 {
10700 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10701 return CMD_WARNING;
10702 }
c500ae40 10703 VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
718e3744 10704
cdc2d765
DL
10705 red = bgp_redist_add(bgp, AFI_IP6, type, 0);
10706 bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric);
10707 return bgp_redistribute_set (bgp, AFI_IP6, type, 0);
718e3744 10708}
10709
10710DEFUN (bgp_redistribute_ipv6_rmap_metric,
10711 bgp_redistribute_ipv6_rmap_metric_cmd,
40d1cbfb 10712 "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)",
718e3744 10713 "Redistribute information from another routing protocol\n"
ab0181ee 10714 FRR_IP6_REDIST_HELP_STR_BGPD
718e3744 10715 "Route map reference\n"
10716 "Pointer to route-map entries\n"
10717 "Metric for redistributed routes\n"
10718 "Default metric\n")
10719{
cdc2d765 10720 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40
DW
10721 int idx_protocol = 1;
10722 int idx_word = 3;
10723 int idx_number = 5;
718e3744 10724 int type;
10725 u_int32_t metric;
7c8ff89e 10726 struct bgp_redist *red;
718e3744 10727
6d681bd8
QY
10728 type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text);
10729 if (type < 0)
718e3744 10730 {
10731 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10732 return CMD_WARNING;
10733 }
c500ae40 10734 VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
718e3744 10735
cdc2d765 10736 red = bgp_redist_add(bgp, AFI_IP6, type, 0);
c500ae40 10737 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
cdc2d765
DL
10738 bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric);
10739 return bgp_redistribute_set (bgp, AFI_IP6, type, 0);
718e3744 10740}
10741
10742DEFUN (bgp_redistribute_ipv6_metric_rmap,
10743 bgp_redistribute_ipv6_metric_rmap_cmd,
40d1cbfb 10744 "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD",
718e3744 10745 "Redistribute information from another routing protocol\n"
ab0181ee 10746 FRR_IP6_REDIST_HELP_STR_BGPD
718e3744 10747 "Metric for redistributed routes\n"
10748 "Default metric\n"
10749 "Route map reference\n"
10750 "Pointer to route-map entries\n")
10751{
cdc2d765 10752 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40
DW
10753 int idx_protocol = 1;
10754 int idx_number = 3;
10755 int idx_word = 5;
718e3744 10756 int type;
10757 u_int32_t metric;
7c8ff89e 10758 struct bgp_redist *red;
718e3744 10759
6d681bd8
QY
10760 type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text);
10761 if (type < 0)
718e3744 10762 {
10763 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10764 return CMD_WARNING;
10765 }
c500ae40 10766 VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg);
718e3744 10767
cdc2d765
DL
10768 red = bgp_redist_add(bgp, AFI_IP6, type, 0);
10769 bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric);
c500ae40 10770 bgp_redistribute_rmap_set (red, argv[idx_word]->arg);
cdc2d765 10771 return bgp_redistribute_set (bgp, AFI_IP6, type, 0);
718e3744 10772}
10773
10774DEFUN (no_bgp_redistribute_ipv6,
10775 no_bgp_redistribute_ipv6_cmd,
40d1cbfb 10776 "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]",
718e3744 10777 NO_STR
10778 "Redistribute information from another routing protocol\n"
3b14d86e 10779 FRR_IP6_REDIST_HELP_STR_BGPD
31500417
DW
10780 "Metric for redistributed routes\n"
10781 "Default metric\n"
10782 "Route map reference\n"
10783 "Pointer to route-map entries\n")
718e3744 10784{
cdc2d765 10785 VTY_DECLVAR_CONTEXT(bgp, bgp);
c500ae40 10786 int idx_protocol = 2;
718e3744 10787 int type;
10788
6d681bd8
QY
10789 type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text);
10790 if (type < 0)
718e3744 10791 {
10792 vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
10793 return CMD_WARNING;
10794 }
10795
cdc2d765 10796 return bgp_redistribute_unset (bgp, AFI_IP6, type, 0);
718e3744 10797}
6b0655a2 10798
718e3744 10799int
10800bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
10801 safi_t safi, int *write)
10802{
10803 int i;
718e3744 10804
10805 /* Unicast redistribution only. */
10806 if (safi != SAFI_UNICAST)
10807 return 0;
10808
10809 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
10810 {
10811 /* Redistribute BGP does not make sense. */
7c8ff89e 10812 if (i != ZEBRA_ROUTE_BGP)
718e3744 10813 {
7c8ff89e
DS
10814 struct list *red_list;
10815 struct listnode *node;
10816 struct bgp_redist *red;
718e3744 10817
7c8ff89e
DS
10818 red_list = bgp->redist[afi][i];
10819 if (!red_list)
10820 continue;
718e3744 10821
7c8ff89e
DS
10822 for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
10823 {
10824 /* Display "address-family" when it is not yet diplayed. */
10825 bgp_config_write_family_header (vty, afi, safi, write);
10826
10827 /* "redistribute" configuration. */
0b960b4d 10828 vty_out (vty, " redistribute %s", zebra_route_string(i));
7c8ff89e
DS
10829 if (red->instance)
10830 vty_out (vty, " %d", red->instance);
10831 if (red->redist_metric_flag)
10832 vty_out (vty, " metric %u", red->redist_metric);
10833 if (red->rmap.name)
10834 vty_out (vty, " route-map %s", red->rmap.name);
10835 vty_out (vty, "%s", VTY_NEWLINE);
10836 }
718e3744 10837 }
10838 }
10839 return *write;
10840}
6b0655a2 10841
718e3744 10842/* BGP node structure. */
7fc626de 10843static struct cmd_node bgp_node =
718e3744 10844{
10845 BGP_NODE,
10846 "%s(config-router)# ",
10847 1,
10848};
10849
7fc626de 10850static struct cmd_node bgp_ipv4_unicast_node =
718e3744 10851{
10852 BGP_IPV4_NODE,
10853 "%s(config-router-af)# ",
10854 1,
10855};
10856
7fc626de 10857static struct cmd_node bgp_ipv4_multicast_node =
718e3744 10858{
10859 BGP_IPV4M_NODE,
10860 "%s(config-router-af)# ",
10861 1,
10862};
10863
f51bae9c
DS
10864static struct cmd_node bgp_ipv4_labeled_unicast_node =
10865{
10866 BGP_IPV4L_NODE,
10867 "%s(config-router-af)# ",
10868 1,
10869};
10870
7fc626de 10871static struct cmd_node bgp_ipv6_unicast_node =
718e3744 10872{
10873 BGP_IPV6_NODE,
10874 "%s(config-router-af)# ",
10875 1,
10876};
10877
7fc626de 10878static struct cmd_node bgp_ipv6_multicast_node =
25ffbdc1 10879{
10880 BGP_IPV6M_NODE,
10881 "%s(config-router-af)# ",
10882 1,
10883};
10884
f51bae9c
DS
10885static struct cmd_node bgp_ipv6_labeled_unicast_node =
10886{
10887 BGP_IPV6L_NODE,
10888 "%s(config-router-af)# ",
10889 1,
10890};
10891
7fc626de 10892static struct cmd_node bgp_vpnv4_node =
718e3744 10893{
10894 BGP_VPNV4_NODE,
10895 "%s(config-router-af)# ",
10896 1
10897};
6b0655a2 10898
8ecd3266 10899static struct cmd_node bgp_vpnv6_node =
10900{
10901 BGP_VPNV6_NODE,
10902 "%s(config-router-af-vpnv6)# ",
10903 1
10904};
10905
8b1fb8be
LB
10906static struct cmd_node bgp_encap_node =
10907{
10908 BGP_ENCAP_NODE,
10909 "%s(config-router-af-encap)# ",
10910 1
10911};
10912
10913static struct cmd_node bgp_encapv6_node =
10914{
10915 BGP_ENCAPV6_NODE,
10916 "%s(config-router-af-encapv6)# ",
10917 1
10918};
10919
4e0b7b6d
PG
10920static struct cmd_node bgp_evpn_node =
10921{
10922 BGP_EVPN_NODE,
10923 "%s(config-router-evpn)# ",
10924 1
10925};
10926
1f8ae70b 10927static void community_list_vty (void);
10928
b8a815e5
DL
10929static void
10930bgp_ac_neighbor (vector comps, struct cmd_token *token)
10931{
10932 struct bgp *bgp;
10933 struct peer *peer;
d48ed3e0 10934 struct peer_group *group;
b8a815e5
DL
10935 struct listnode *lnbgp, *lnpeer;
10936
b8a815e5 10937 for (ALL_LIST_ELEMENTS_RO (bm->bgp, lnbgp, bgp))
d48ed3e0
DL
10938 {
10939 for (ALL_LIST_ELEMENTS_RO (bgp->peer, lnpeer, peer))
b8a815e5 10940 {
d48ed3e0
DL
10941 /* only provide suggestions on the appropriate input token type,
10942 * they'll otherwise show up multiple times */
10943 enum cmd_token_type match_type;
10944 char *name = peer->host;
10945
10946 if (peer->conf_if)
10947 {
10948 match_type = VARIABLE_TKN;
10949 name = peer->conf_if;
10950 }
10951 else if (strchr(peer->host, ':'))
10952 match_type = IPV6_TKN;
10953 else
10954 match_type = IPV4_TKN;
10955
10956 if (token->type != match_type)
b8a815e5 10957 continue;
d48ed3e0
DL
10958
10959 vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name));
b8a815e5 10960 }
d48ed3e0
DL
10961
10962 if (token->type == VARIABLE_TKN)
10963 for (ALL_LIST_ELEMENTS_RO (bgp->group, lnpeer, group))
10964 vector_set(comps, XSTRDUP(MTYPE_COMPLETION, group->name));
10965 }
b8a815e5
DL
10966}
10967
10968static const struct cmd_variable_handler bgp_var_neighbor[] = {
10969 {
10970 .varname = "neighbor",
10971 .completions = bgp_ac_neighbor
10972 }, {
10973 .varname = "neighbors",
10974 .completions = bgp_ac_neighbor
10975 }, {
10976 .completions = NULL
10977 }
10978};
10979
718e3744 10980void
94f2b392 10981bgp_vty_init (void)
718e3744 10982{
b8a815e5
DL
10983 cmd_variable_handler_register(bgp_var_neighbor);
10984
718e3744 10985 /* Install bgp top node. */
10986 install_node (&bgp_node, bgp_config_write);
10987 install_node (&bgp_ipv4_unicast_node, NULL);
10988 install_node (&bgp_ipv4_multicast_node, NULL);
f51bae9c 10989 install_node (&bgp_ipv4_labeled_unicast_node, NULL);
718e3744 10990 install_node (&bgp_ipv6_unicast_node, NULL);
25ffbdc1 10991 install_node (&bgp_ipv6_multicast_node, NULL);
f51bae9c 10992 install_node (&bgp_ipv6_labeled_unicast_node, NULL);
718e3744 10993 install_node (&bgp_vpnv4_node, NULL);
8ecd3266 10994 install_node (&bgp_vpnv6_node, NULL);
8b1fb8be
LB
10995 install_node (&bgp_encap_node, NULL);
10996 install_node (&bgp_encapv6_node, NULL);
4e0b7b6d 10997 install_node (&bgp_evpn_node, NULL);
718e3744 10998
10999 /* Install default VTY commands to new nodes. */
11000 install_default (BGP_NODE);
11001 install_default (BGP_IPV4_NODE);
11002 install_default (BGP_IPV4M_NODE);
f51bae9c 11003 install_default (BGP_IPV4L_NODE);
718e3744 11004 install_default (BGP_IPV6_NODE);
25ffbdc1 11005 install_default (BGP_IPV6M_NODE);
f51bae9c 11006 install_default (BGP_IPV6L_NODE);
718e3744 11007 install_default (BGP_VPNV4_NODE);
8ecd3266 11008 install_default (BGP_VPNV6_NODE);
8b1fb8be
LB
11009 install_default (BGP_ENCAP_NODE);
11010 install_default (BGP_ENCAPV6_NODE);
4e0b7b6d 11011 install_default (BGP_EVPN_NODE);
e52702f2 11012
718e3744 11013 /* "bgp multiple-instance" commands. */
11014 install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
11015 install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd);
11016
11017 /* "bgp config-type" commands. */
11018 install_element (CONFIG_NODE, &bgp_config_type_cmd);
8c3deaae 11019 install_element (CONFIG_NODE, &no_bgp_config_type_cmd);
718e3744 11020
5fe9f963 11021 /* bgp route-map delay-timer commands. */
11022 install_element (CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd);
11023 install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd);
5fe9f963 11024
718e3744 11025 /* Dummy commands (Currently not supported) */
11026 install_element (BGP_NODE, &no_synchronization_cmd);
11027 install_element (BGP_NODE, &no_auto_summary_cmd);
11028
11029 /* "router bgp" commands. */
11030 install_element (CONFIG_NODE, &router_bgp_cmd);
718e3744 11031
11032 /* "no router bgp" commands. */
11033 install_element (CONFIG_NODE, &no_router_bgp_cmd);
718e3744 11034
11035 /* "bgp router-id" commands. */
11036 install_element (BGP_NODE, &bgp_router_id_cmd);
11037 install_element (BGP_NODE, &no_bgp_router_id_cmd);
718e3744 11038
11039 /* "bgp cluster-id" commands. */
11040 install_element (BGP_NODE, &bgp_cluster_id_cmd);
718e3744 11041 install_element (BGP_NODE, &no_bgp_cluster_id_cmd);
718e3744 11042
11043 /* "bgp confederation" commands. */
11044 install_element (BGP_NODE, &bgp_confederation_identifier_cmd);
11045 install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd);
718e3744 11046
11047 /* "bgp confederation peers" commands. */
11048 install_element (BGP_NODE, &bgp_confederation_peers_cmd);
11049 install_element (BGP_NODE, &no_bgp_confederation_peers_cmd);
11050
abc920f8
DS
11051 /* bgp max-med command */
11052 install_element (BGP_NODE, &bgp_maxmed_admin_cmd);
11053 install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd);
11054 install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd);
abc920f8
DS
11055 install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd);
11056 install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd);
abc920f8 11057 install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd);
abc920f8 11058
907f92c8
DS
11059 /* bgp disable-ebgp-connected-nh-check */
11060 install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd);
11061 install_element (BGP_NODE, &no_bgp_disable_connected_route_check_cmd);
11062
f188f2c4
DS
11063 /* bgp update-delay command */
11064 install_element (BGP_NODE, &bgp_update_delay_cmd);
11065 install_element (BGP_NODE, &no_bgp_update_delay_cmd);
11066 install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd);
f188f2c4 11067
cb1faec9
DS
11068 install_element (BGP_NODE, &bgp_wpkt_quanta_cmd);
11069 install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd);
11070
3f9c7369
DS
11071 install_element (BGP_NODE, &bgp_coalesce_time_cmd);
11072 install_element (BGP_NODE, &no_bgp_coalesce_time_cmd);
11073
165b5fff 11074 /* "maximum-paths" commands. */
596c17ba
DW
11075 install_element (BGP_NODE, &bgp_maxpaths_hidden_cmd);
11076 install_element (BGP_NODE, &no_bgp_maxpaths_hidden_cmd);
165b5fff
JB
11077 install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd);
11078 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd);
431aa9f9
DS
11079 install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd);
11080 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd);
596c17ba
DW
11081 install_element (BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd);
11082 install_element (BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd);
11083 install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd);
165b5fff 11084 install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd);
f51bae9c 11085 install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
165b5fff 11086 install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd);
431aa9f9 11087 install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd);
f51bae9c 11088 install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
431aa9f9 11089 install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd);
165b5fff 11090
f51bae9c
DS
11091 install_element (BGP_IPV4L_NODE, &bgp_maxpaths_cmd);
11092 install_element (BGP_IPV4L_NODE, &no_bgp_maxpaths_cmd);
11093 install_element (BGP_IPV6L_NODE, &bgp_maxpaths_cmd);
11094 install_element (BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd);
11095
11096 install_element (BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cmd);
11097 install_element (BGP_IPV4L_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
11098 install_element (BGP_IPV4L_NODE, &no_bgp_maxpaths_ibgp_cmd);
11099 install_element (BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd);
11100 install_element (BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd);
11101 install_element (BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd);
11102
718e3744 11103 /* "timers bgp" commands. */
11104 install_element (BGP_NODE, &bgp_timers_cmd);
11105 install_element (BGP_NODE, &no_bgp_timers_cmd);
718e3744 11106
5fe9f963 11107 /* route-map delay-timer commands - per instance for backwards compat. */
518f0eb1
DS
11108 install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd);
11109 install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd);
11110
718e3744 11111 /* "bgp client-to-client reflection" commands */
11112 install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd);
11113 install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd);
11114
11115 /* "bgp always-compare-med" commands */
11116 install_element (BGP_NODE, &bgp_always_compare_med_cmd);
11117 install_element (BGP_NODE, &no_bgp_always_compare_med_cmd);
e52702f2 11118
718e3744 11119 /* "bgp deterministic-med" commands */
11120 install_element (BGP_NODE, &bgp_deterministic_med_cmd);
11121 install_element (BGP_NODE, &no_bgp_deterministic_med_cmd);
538621f2 11122
538621f2 11123 /* "bgp graceful-restart" commands */
11124 install_element (BGP_NODE, &bgp_graceful_restart_cmd);
11125 install_element (BGP_NODE, &no_bgp_graceful_restart_cmd);
93406d87 11126 install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd);
11127 install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd);
eb6f1b41
PG
11128 install_element (BGP_NODE, &bgp_graceful_restart_restart_time_cmd);
11129 install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd);
e52702f2 11130
43fc21b3
JC
11131 install_element (BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd);
11132 install_element (BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd);
11133
718e3744 11134 /* "bgp fast-external-failover" commands */
11135 install_element (BGP_NODE, &bgp_fast_external_failover_cmd);
11136 install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd);
11137
11138 /* "bgp enforce-first-as" commands */
11139 install_element (BGP_NODE, &bgp_enforce_first_as_cmd);
11140 install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd);
11141
11142 /* "bgp bestpath compare-routerid" commands */
11143 install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd);
11144 install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd);
11145
11146 /* "bgp bestpath as-path ignore" commands */
11147 install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd);
11148 install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd);
11149
6811845b 11150 /* "bgp bestpath as-path confed" commands */
11151 install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd);
11152 install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd);
11153
2fdd455c
PM
11154 /* "bgp bestpath as-path multipath-relax" commands */
11155 install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd);
11156 install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd);
11157
848973c7 11158 /* "bgp log-neighbor-changes" commands */
11159 install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd);
11160 install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd);
11161
718e3744 11162 /* "bgp bestpath med" commands */
11163 install_element (BGP_NODE, &bgp_bestpath_med_cmd);
718e3744 11164 install_element (BGP_NODE, &no_bgp_bestpath_med_cmd);
718e3744 11165
11166 /* "no bgp default ipv4-unicast" commands. */
11167 install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd);
11168 install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd);
e52702f2 11169
718e3744 11170 /* "bgp network import-check" commands. */
11171 install_element (BGP_NODE, &bgp_network_import_check_cmd);
8233ef81 11172 install_element (BGP_NODE, &bgp_network_import_check_exact_cmd);
718e3744 11173 install_element (BGP_NODE, &no_bgp_network_import_check_cmd);
11174
11175 /* "bgp default local-preference" commands. */
11176 install_element (BGP_NODE, &bgp_default_local_preference_cmd);
11177 install_element (BGP_NODE, &no_bgp_default_local_preference_cmd);
718e3744 11178
04b6bdc0
DW
11179 /* bgp default show-hostname */
11180 install_element (BGP_NODE, &bgp_default_show_hostname_cmd);
11181 install_element (BGP_NODE, &no_bgp_default_show_hostname_cmd);
11182
3f9c7369
DS
11183 /* "bgp default subgroup-pkt-queue-max" commands. */
11184 install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd);
11185 install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd);
11186
8bd9d948
DS
11187 /* bgp ibgp-allow-policy-mods command */
11188 install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd);
11189 install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd);
11190
f14e6fdb
DS
11191 /* "bgp listen limit" commands. */
11192 install_element (BGP_NODE, &bgp_listen_limit_cmd);
11193 install_element (BGP_NODE, &no_bgp_listen_limit_cmd);
11194
11195 /* "bgp listen range" commands. */
11196 install_element (BGP_NODE, &bgp_listen_range_cmd);
11197 install_element (BGP_NODE, &no_bgp_listen_range_cmd);
11198
718e3744 11199 /* "neighbor remote-as" commands. */
11200 install_element (BGP_NODE, &neighbor_remote_as_cmd);
a80beece 11201 install_element (BGP_NODE, &neighbor_interface_config_cmd);
4c48cf63 11202 install_element (BGP_NODE, &neighbor_interface_config_v6only_cmd);
b3a39dc5
DD
11203 install_element (BGP_NODE, &neighbor_interface_config_remote_as_cmd);
11204 install_element (BGP_NODE, &neighbor_interface_v6only_config_remote_as_cmd);
718e3744 11205 install_element (BGP_NODE, &no_neighbor_cmd);
a80beece 11206 install_element (BGP_NODE, &no_neighbor_interface_config_cmd);
718e3744 11207
11208 /* "neighbor peer-group" commands. */
11209 install_element (BGP_NODE, &neighbor_peer_group_cmd);
11210 install_element (BGP_NODE, &no_neighbor_peer_group_cmd);
a80beece 11211 install_element (BGP_NODE, &no_neighbor_interface_peer_group_remote_as_cmd);
718e3744 11212
11213 /* "neighbor local-as" commands. */
11214 install_element (BGP_NODE, &neighbor_local_as_cmd);
11215 install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd);
9d3f9705 11216 install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd);
718e3744 11217 install_element (BGP_NODE, &no_neighbor_local_as_cmd);
718e3744 11218
3f9c7369
DS
11219 /* "neighbor solo" commands. */
11220 install_element (BGP_NODE, &neighbor_solo_cmd);
11221 install_element (BGP_NODE, &no_neighbor_solo_cmd);
11222
0df7c91f
PJ
11223 /* "neighbor password" commands. */
11224 install_element (BGP_NODE, &neighbor_password_cmd);
11225 install_element (BGP_NODE, &no_neighbor_password_cmd);
11226
718e3744 11227 /* "neighbor activate" commands. */
596c17ba 11228 install_element (BGP_NODE, &neighbor_activate_hidden_cmd);
718e3744 11229 install_element (BGP_IPV4_NODE, &neighbor_activate_cmd);
11230 install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd);
f51bae9c 11231 install_element (BGP_IPV4L_NODE, &neighbor_activate_cmd);
718e3744 11232 install_element (BGP_IPV6_NODE, &neighbor_activate_cmd);
25ffbdc1 11233 install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd);
f51bae9c 11234 install_element (BGP_IPV6L_NODE, &neighbor_activate_cmd);
718e3744 11235 install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd);
8ecd3266 11236 install_element (BGP_VPNV6_NODE, &neighbor_activate_cmd);
8b1fb8be
LB
11237 install_element (BGP_ENCAP_NODE, &neighbor_activate_cmd);
11238 install_element (BGP_ENCAPV6_NODE, &neighbor_activate_cmd);
4e0b7b6d 11239 install_element (BGP_EVPN_NODE, &neighbor_activate_cmd);
718e3744 11240
11241 /* "no neighbor activate" commands. */
596c17ba 11242 install_element (BGP_NODE, &no_neighbor_activate_hidden_cmd);
718e3744 11243 install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd);
11244 install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd);
f51bae9c 11245 install_element (BGP_IPV4L_NODE, &no_neighbor_activate_cmd);
718e3744 11246 install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd);
25ffbdc1 11247 install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd);
f51bae9c 11248 install_element (BGP_IPV6L_NODE, &no_neighbor_activate_cmd);
718e3744 11249 install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd);
8ecd3266 11250 install_element (BGP_VPNV6_NODE, &no_neighbor_activate_cmd);
8b1fb8be
LB
11251 install_element (BGP_ENCAP_NODE, &no_neighbor_activate_cmd);
11252 install_element (BGP_ENCAPV6_NODE, &no_neighbor_activate_cmd);
4e0b7b6d 11253 install_element (BGP_EVPN_NODE, &no_neighbor_activate_cmd);
718e3744 11254
596c17ba 11255 /* "neighbor peer-group" set commands. */
718e3744 11256 install_element (BGP_NODE, &neighbor_set_peer_group_cmd);
596c17ba
DW
11257 install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd);
11258 install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd);
11259 install_element (BGP_IPV4L_NODE, &neighbor_set_peer_group_hidden_cmd);
11260 install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd);
11261 install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd);
11262 install_element (BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd);
11263 install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd);
11264 install_element (BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd);
11265 install_element (BGP_ENCAP_NODE, &neighbor_set_peer_group_hidden_cmd);
11266 install_element (BGP_ENCAPV6_NODE, &neighbor_set_peer_group_hidden_cmd);
c8560b44 11267
718e3744 11268 /* "no neighbor peer-group unset" commands. */
11269 install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd);
596c17ba
DW
11270 install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd);
11271 install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd);
11272 install_element (BGP_IPV4L_NODE, &no_neighbor_set_peer_group_hidden_cmd);
11273 install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd);
11274 install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd);
11275 install_element (BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd);
11276 install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd);
11277 install_element (BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd);
11278 install_element (BGP_ENCAP_NODE, &no_neighbor_set_peer_group_hidden_cmd);
11279 install_element (BGP_ENCAPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd);
e52702f2 11280
718e3744 11281 /* "neighbor softreconfiguration inbound" commands.*/
596c17ba
DW
11282 install_element (BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd);
11283 install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd);
718e3744 11284 install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd);
11285 install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
f51bae9c
DS
11286 install_element (BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd);
11287 install_element (BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd);
718e3744 11288 install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd);
11289 install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd);
11290 install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd);
11291 install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
25ffbdc1 11292 install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd);
11293 install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd);
f51bae9c
DS
11294 install_element (BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd);
11295 install_element (BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd);
a58545bb 11296 install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd);
11297 install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd);
8ecd3266 11298 install_element (BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd);
11299 install_element (BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
8b1fb8be
LB
11300 install_element (BGP_ENCAP_NODE, &neighbor_soft_reconfiguration_cmd);
11301 install_element (BGP_ENCAP_NODE, &no_neighbor_soft_reconfiguration_cmd);
11302 install_element (BGP_ENCAPV6_NODE, &neighbor_soft_reconfiguration_cmd);
11303 install_element (BGP_ENCAPV6_NODE, &no_neighbor_soft_reconfiguration_cmd);
718e3744 11304
11305 /* "neighbor attribute-unchanged" commands. */
596c17ba
DW
11306 install_element (BGP_NODE, &neighbor_attr_unchanged_hidden_cmd);
11307 install_element (BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd);
718e3744 11308 install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd);
718e3744 11309 install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd);
718e3744 11310 install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd);
718e3744 11311 install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd);
f51bae9c
DS
11312 install_element (BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd);
11313 install_element (BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd);
718e3744 11314 install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd);
718e3744 11315 install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd);
25ffbdc1 11316 install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd);
25ffbdc1 11317 install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd);
f51bae9c
DS
11318 install_element (BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd);
11319 install_element (BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd);
718e3744 11320 install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd);
718e3744 11321 install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd);
8ecd3266 11322 install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd);
8ecd3266 11323 install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd);
8ecd3266 11324
8b1fb8be 11325 install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged_cmd);
8b1fb8be 11326 install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged_cmd);
8b1fb8be
LB
11327
11328 install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged_cmd);
8b1fb8be 11329 install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged_cmd);
718e3744 11330
4e0b7b6d
PG
11331 install_element (BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd);
11332 install_element (BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd);
11333
fee0f4c6 11334 /* "nexthop-local unchanged" commands */
11335 install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd);
11336 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd);
11337
718e3744 11338 /* "neighbor next-hop-self" commands. */
596c17ba
DW
11339 install_element (BGP_NODE, &neighbor_nexthop_self_hidden_cmd);
11340 install_element (BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd);
718e3744 11341 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd);
11342 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd);
11343 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd);
11344 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd);
f51bae9c
DS
11345 install_element (BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd);
11346 install_element (BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd);
718e3744 11347 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd);
11348 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd);
25ffbdc1 11349 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd);
11350 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd);
f51bae9c
DS
11351 install_element (BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd);
11352 install_element (BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd);
718e3744 11353 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd);
11354 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd);
8ecd3266 11355 install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd);
11356 install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd);
8b1fb8be
LB
11357 install_element (BGP_ENCAP_NODE, &neighbor_nexthop_self_cmd);
11358 install_element (BGP_ENCAP_NODE, &no_neighbor_nexthop_self_cmd);
11359 install_element (BGP_ENCAPV6_NODE, &neighbor_nexthop_self_cmd);
11360 install_element (BGP_ENCAPV6_NODE, &no_neighbor_nexthop_self_cmd);
718e3744 11361
a538debe 11362 /* "neighbor next-hop-self force" commands. */
596c17ba
DW
11363 install_element (BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd);
11364 install_element (BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd);
a538debe
DS
11365 install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd);
11366 install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd);
11367 install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd);
11368 install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd);
f51bae9c
DS
11369 install_element (BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd);
11370 install_element (BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd);
a538debe
DS
11371 install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd);
11372 install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd);
11373 install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd);
11374 install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd);
f51bae9c
DS
11375 install_element (BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd);
11376 install_element (BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd);
a538debe
DS
11377 install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd);
11378 install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd);
8ecd3266 11379 install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd);
11380 install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd);
a538debe 11381
c7122e14 11382 /* "neighbor as-override" commands. */
596c17ba
DW
11383 install_element (BGP_NODE, &neighbor_as_override_hidden_cmd);
11384 install_element (BGP_NODE, &no_neighbor_as_override_hidden_cmd);
c7122e14
DS
11385 install_element (BGP_IPV4_NODE, &neighbor_as_override_cmd);
11386 install_element (BGP_IPV4_NODE, &no_neighbor_as_override_cmd);
11387 install_element (BGP_IPV4M_NODE, &neighbor_as_override_cmd);
11388 install_element (BGP_IPV4M_NODE, &no_neighbor_as_override_cmd);
f51bae9c
DS
11389 install_element (BGP_IPV4L_NODE, &neighbor_as_override_cmd);
11390 install_element (BGP_IPV4L_NODE, &no_neighbor_as_override_cmd);
c7122e14
DS
11391 install_element (BGP_IPV6_NODE, &neighbor_as_override_cmd);
11392 install_element (BGP_IPV6_NODE, &no_neighbor_as_override_cmd);
11393 install_element (BGP_IPV6M_NODE, &neighbor_as_override_cmd);
11394 install_element (BGP_IPV6M_NODE, &no_neighbor_as_override_cmd);
f51bae9c
DS
11395 install_element (BGP_IPV6L_NODE, &neighbor_as_override_cmd);
11396 install_element (BGP_IPV6L_NODE, &no_neighbor_as_override_cmd);
c7122e14
DS
11397 install_element (BGP_VPNV4_NODE, &neighbor_as_override_cmd);
11398 install_element (BGP_VPNV4_NODE, &no_neighbor_as_override_cmd);
8ecd3266 11399 install_element (BGP_VPNV6_NODE, &neighbor_as_override_cmd);
11400 install_element (BGP_VPNV6_NODE, &no_neighbor_as_override_cmd);
c7122e14 11401
718e3744 11402 /* "neighbor remove-private-AS" commands. */
596c17ba
DW
11403 install_element (BGP_NODE, &neighbor_remove_private_as_hidden_cmd);
11404 install_element (BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd);
11405 install_element (BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd);
11406 install_element (BGP_NODE, &no_neighbor_remove_private_as_all_hidden_cmd);
11407 install_element (BGP_NODE, &neighbor_remove_private_as_replace_as_hidden_cmd);
11408 install_element (BGP_NODE, &no_neighbor_remove_private_as_replace_as_hidden_cmd);
11409 install_element (BGP_NODE, &neighbor_remove_private_as_all_replace_as_hidden_cmd);
11410 install_element (BGP_NODE, &no_neighbor_remove_private_as_all_replace_as_hidden_cmd);
718e3744 11411 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd);
11412 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
11413 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd);
11414 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd);
11415 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_replace_as_cmd);
11416 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11417 install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11418 install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 11419 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd);
11420 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
11421 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd);
11422 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd);
11423 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_replace_as_cmd);
11424 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11425 install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11426 install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
f51bae9c
DS
11427 install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd);
11428 install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd);
11429 install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd);
11430 install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd);
11431 install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_replace_as_cmd);
11432 install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11433 install_element (BGP_IPV4L_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11434 install_element (BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 11435 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd);
11436 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
11437 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd);
11438 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd);
11439 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_replace_as_cmd);
11440 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11441 install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11442 install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
25ffbdc1 11443 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd);
11444 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
11445 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd);
11446 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd);
11447 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_replace_as_cmd);
11448 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11449 install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11450 install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
f51bae9c
DS
11451 install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd);
11452 install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd);
11453 install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd);
11454 install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd);
11455 install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_replace_as_cmd);
11456 install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11457 install_element (BGP_IPV6L_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11458 install_element (BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
718e3744 11459 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd);
11460 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd);
5000f21c
DS
11461 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd);
11462 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd);
11463 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_replace_as_cmd);
11464 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11465 install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11466 install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
8ecd3266 11467 install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd);
11468 install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd);
11469 install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd);
11470 install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd);
11471 install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_replace_as_cmd);
11472 install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd);
11473 install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd);
11474 install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd);
8b1fb8be
LB
11475 install_element (BGP_ENCAP_NODE, &neighbor_remove_private_as_cmd);
11476 install_element (BGP_ENCAP_NODE, &no_neighbor_remove_private_as_cmd);
11477 install_element (BGP_ENCAPV6_NODE, &neighbor_remove_private_as_cmd);
11478 install_element (BGP_ENCAPV6_NODE, &no_neighbor_remove_private_as_cmd);
718e3744 11479
11480 /* "neighbor send-community" commands.*/
596c17ba
DW
11481 install_element (BGP_NODE, &neighbor_send_community_hidden_cmd);
11482 install_element (BGP_NODE, &neighbor_send_community_type_hidden_cmd);
11483 install_element (BGP_NODE, &no_neighbor_send_community_hidden_cmd);
11484 install_element (BGP_NODE, &no_neighbor_send_community_type_hidden_cmd);
718e3744 11485 install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd);
11486 install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd);
11487 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd);
11488 install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd);
11489 install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd);
11490 install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd);
11491 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd);
11492 install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd);
f51bae9c
DS
11493 install_element (BGP_IPV4L_NODE, &neighbor_send_community_cmd);
11494 install_element (BGP_IPV4L_NODE, &neighbor_send_community_type_cmd);
11495 install_element (BGP_IPV4L_NODE, &no_neighbor_send_community_cmd);
11496 install_element (BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd);
718e3744 11497 install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd);
11498 install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd);
11499 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd);
11500 install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd);
25ffbdc1 11501 install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd);
11502 install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd);
11503 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd);
11504 install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd);
f51bae9c
DS
11505 install_element (BGP_IPV6L_NODE, &neighbor_send_community_cmd);
11506 install_element (BGP_IPV6L_NODE, &neighbor_send_community_type_cmd);
11507 install_element (BGP_IPV6L_NODE, &no_neighbor_send_community_cmd);
11508 install_element (BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd);
718e3744 11509 install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd);
11510 install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd);
11511 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd);
11512 install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd);
8ecd3266 11513 install_element (BGP_VPNV6_NODE, &neighbor_send_community_cmd);
11514 install_element (BGP_VPNV6_NODE, &neighbor_send_community_type_cmd);
11515 install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_cmd);
11516 install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd);
8b1fb8be
LB
11517 install_element (BGP_ENCAP_NODE, &neighbor_send_community_cmd);
11518 install_element (BGP_ENCAP_NODE, &neighbor_send_community_type_cmd);
11519 install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_cmd);
11520 install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_type_cmd);
11521 install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_cmd);
11522 install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_type_cmd);
11523 install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_cmd);
11524 install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_type_cmd);
718e3744 11525
11526 /* "neighbor route-reflector" commands.*/
596c17ba
DW
11527 install_element (BGP_NODE, &neighbor_route_reflector_client_hidden_cmd);
11528 install_element (BGP_NODE, &no_neighbor_route_reflector_client_hidden_cmd);
718e3744 11529 install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd);
11530 install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd);
11531 install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd);
11532 install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd);
f51bae9c
DS
11533 install_element (BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd);
11534 install_element (BGP_IPV4L_NODE, &no_neighbor_route_reflector_client_cmd);
718e3744 11535 install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd);
11536 install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd);
25ffbdc1 11537 install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd);
11538 install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd);
f51bae9c
DS
11539 install_element (BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd);
11540 install_element (BGP_IPV6L_NODE, &no_neighbor_route_reflector_client_cmd);
718e3744 11541 install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd);
11542 install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd);
8ecd3266 11543 install_element (BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd);
11544 install_element (BGP_VPNV6_NODE, &no_neighbor_route_reflector_client_cmd);
8b1fb8be
LB
11545 install_element (BGP_ENCAP_NODE, &neighbor_route_reflector_client_cmd);
11546 install_element (BGP_ENCAP_NODE, &no_neighbor_route_reflector_client_cmd);
11547 install_element (BGP_ENCAPV6_NODE, &neighbor_route_reflector_client_cmd);
11548 install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_reflector_client_cmd);
718e3744 11549
11550 /* "neighbor route-server" commands.*/
596c17ba
DW
11551 install_element (BGP_NODE, &neighbor_route_server_client_hidden_cmd);
11552 install_element (BGP_NODE, &no_neighbor_route_server_client_hidden_cmd);
718e3744 11553 install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd);
11554 install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd);
11555 install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd);
11556 install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd);
f51bae9c
DS
11557 install_element (BGP_IPV4L_NODE, &neighbor_route_server_client_cmd);
11558 install_element (BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd);
718e3744 11559 install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd);
11560 install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd);
25ffbdc1 11561 install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd);
11562 install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd);
f51bae9c
DS
11563 install_element (BGP_IPV6L_NODE, &neighbor_route_server_client_cmd);
11564 install_element (BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd);
718e3744 11565 install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd);
11566 install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd);
8ecd3266 11567 install_element (BGP_VPNV6_NODE, &neighbor_route_server_client_cmd);
11568 install_element (BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd);
8b1fb8be
LB
11569 install_element (BGP_ENCAP_NODE, &neighbor_route_server_client_cmd);
11570 install_element (BGP_ENCAP_NODE, &no_neighbor_route_server_client_cmd);
11571 install_element (BGP_ENCAPV6_NODE, &neighbor_route_server_client_cmd);
11572 install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_server_client_cmd);
718e3744 11573
adbac85e 11574 /* "neighbor addpath-tx-all-paths" commands.*/
596c17ba
DW
11575 install_element (BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd);
11576 install_element (BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd);
adbac85e
DW
11577 install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd);
11578 install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
11579 install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd);
11580 install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
f51bae9c
DS
11581 install_element (BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd);
11582 install_element (BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
adbac85e
DW
11583 install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd);
11584 install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
11585 install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd);
11586 install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
f51bae9c
DS
11587 install_element (BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd);
11588 install_element (BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
adbac85e
DW
11589 install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd);
11590 install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
8ecd3266 11591 install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd);
11592 install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd);
adbac85e 11593
06370dac 11594 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
596c17ba
DW
11595 install_element (BGP_NODE, &neighbor_addpath_tx_bestpath_per_as_hidden_cmd);
11596 install_element (BGP_NODE, &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd);
06370dac
DW
11597 install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
11598 install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
11599 install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
11600 install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
f51bae9c
DS
11601 install_element (BGP_IPV4L_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
11602 install_element (BGP_IPV4L_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
06370dac
DW
11603 install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
11604 install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
11605 install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
11606 install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
f51bae9c
DS
11607 install_element (BGP_IPV6L_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
11608 install_element (BGP_IPV6L_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
06370dac
DW
11609 install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
11610 install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
8ecd3266 11611 install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd);
11612 install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd);
06370dac 11613
718e3744 11614 /* "neighbor passive" commands. */
11615 install_element (BGP_NODE, &neighbor_passive_cmd);
11616 install_element (BGP_NODE, &no_neighbor_passive_cmd);
11617
d5a5c8f0 11618
718e3744 11619 /* "neighbor shutdown" commands. */
11620 install_element (BGP_NODE, &neighbor_shutdown_cmd);
11621 install_element (BGP_NODE, &no_neighbor_shutdown_cmd);
73d70fa6
DL
11622 install_element (BGP_NODE, &neighbor_shutdown_msg_cmd);
11623 install_element (BGP_NODE, &no_neighbor_shutdown_msg_cmd);
718e3744 11624
8a92a8a0
DS
11625 /* "neighbor capability extended-nexthop" commands.*/
11626 install_element (BGP_NODE, &neighbor_capability_enhe_cmd);
11627 install_element (BGP_NODE, &no_neighbor_capability_enhe_cmd);
11628
718e3744 11629 /* "neighbor capability orf prefix-list" commands.*/
596c17ba
DW
11630 install_element (BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd);
11631 install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_hidden_cmd);
718e3744 11632 install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd);
11633 install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd);
11634 install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd);
11635 install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd);
f51bae9c
DS
11636 install_element (BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd);
11637 install_element (BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd);
718e3744 11638 install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd);
11639 install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd);
25ffbdc1 11640 install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd);
11641 install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd);
f51bae9c
DS
11642 install_element (BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd);
11643 install_element (BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd);
718e3744 11644
11645 /* "neighbor capability dynamic" commands.*/
11646 install_element (BGP_NODE, &neighbor_capability_dynamic_cmd);
11647 install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd);
11648
11649 /* "neighbor dont-capability-negotiate" commands. */
11650 install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd);
11651 install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd);
11652
11653 /* "neighbor ebgp-multihop" commands. */
11654 install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd);
11655 install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd);
11656 install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd);
718e3744 11657
6ffd2079 11658 /* "neighbor disable-connected-check" commands. */
11659 install_element (BGP_NODE, &neighbor_disable_connected_check_cmd);
11660 install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd);
718e3744 11661
11662 /* "neighbor description" commands. */
11663 install_element (BGP_NODE, &neighbor_description_cmd);
11664 install_element (BGP_NODE, &no_neighbor_description_cmd);
718e3744 11665
11666 /* "neighbor update-source" commands. "*/
11667 install_element (BGP_NODE, &neighbor_update_source_cmd);
11668 install_element (BGP_NODE, &no_neighbor_update_source_cmd);
11669
11670 /* "neighbor default-originate" commands. */
596c17ba
DW
11671 install_element (BGP_NODE, &neighbor_default_originate_hidden_cmd);
11672 install_element (BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd);
11673 install_element (BGP_NODE, &no_neighbor_default_originate_hidden_cmd);
718e3744 11674 install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd);
11675 install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd);
11676 install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd);
718e3744 11677 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd);
11678 install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd);
11679 install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd);
f51bae9c
DS
11680 install_element (BGP_IPV4L_NODE, &neighbor_default_originate_cmd);
11681 install_element (BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd);
11682 install_element (BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd);
718e3744 11683 install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd);
11684 install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd);
11685 install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd);
25ffbdc1 11686 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd);
11687 install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd);
11688 install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd);
f51bae9c
DS
11689 install_element (BGP_IPV6L_NODE, &neighbor_default_originate_cmd);
11690 install_element (BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd);
11691 install_element (BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd);
718e3744 11692
11693 /* "neighbor port" commands. */
11694 install_element (BGP_NODE, &neighbor_port_cmd);
11695 install_element (BGP_NODE, &no_neighbor_port_cmd);
718e3744 11696
11697 /* "neighbor weight" commands. */
596c17ba
DW
11698 install_element (BGP_NODE, &neighbor_weight_hidden_cmd);
11699 install_element (BGP_NODE, &no_neighbor_weight_hidden_cmd);
718e3744 11700
d93f7ffc
DW
11701 install_element (BGP_IPV4_NODE, &neighbor_weight_cmd);
11702 install_element (BGP_IPV4_NODE, &no_neighbor_weight_cmd);
d93f7ffc
DW
11703 install_element (BGP_IPV4M_NODE, &neighbor_weight_cmd);
11704 install_element (BGP_IPV4M_NODE, &no_neighbor_weight_cmd);
f51bae9c
DS
11705 install_element (BGP_IPV4L_NODE, &neighbor_weight_cmd);
11706 install_element (BGP_IPV4L_NODE, &no_neighbor_weight_cmd);
d93f7ffc
DW
11707 install_element (BGP_IPV6_NODE, &neighbor_weight_cmd);
11708 install_element (BGP_IPV6_NODE, &no_neighbor_weight_cmd);
d93f7ffc
DW
11709 install_element (BGP_IPV6M_NODE, &neighbor_weight_cmd);
11710 install_element (BGP_IPV6M_NODE, &no_neighbor_weight_cmd);
f51bae9c
DS
11711 install_element (BGP_IPV6L_NODE, &neighbor_weight_cmd);
11712 install_element (BGP_IPV6L_NODE, &no_neighbor_weight_cmd);
d93f7ffc
DW
11713 install_element (BGP_VPNV4_NODE, &neighbor_weight_cmd);
11714 install_element (BGP_VPNV4_NODE, &no_neighbor_weight_cmd);
d93f7ffc
DW
11715 install_element (BGP_VPNV6_NODE, &neighbor_weight_cmd);
11716 install_element (BGP_VPNV6_NODE, &no_neighbor_weight_cmd);
d93f7ffc
DW
11717 install_element (BGP_ENCAP_NODE, &neighbor_weight_cmd);
11718 install_element (BGP_ENCAP_NODE, &no_neighbor_weight_cmd);
d93f7ffc
DW
11719 install_element (BGP_ENCAPV6_NODE, &neighbor_weight_cmd);
11720 install_element (BGP_ENCAPV6_NODE, &no_neighbor_weight_cmd);
718e3744 11721
11722 /* "neighbor override-capability" commands. */
11723 install_element (BGP_NODE, &neighbor_override_capability_cmd);
11724 install_element (BGP_NODE, &no_neighbor_override_capability_cmd);
11725
11726 /* "neighbor strict-capability-match" commands. */
11727 install_element (BGP_NODE, &neighbor_strict_capability_cmd);
11728 install_element (BGP_NODE, &no_neighbor_strict_capability_cmd);
11729
11730 /* "neighbor timers" commands. */
11731 install_element (BGP_NODE, &neighbor_timers_cmd);
11732 install_element (BGP_NODE, &no_neighbor_timers_cmd);
11733
11734 /* "neighbor timers connect" commands. */
11735 install_element (BGP_NODE, &neighbor_timers_connect_cmd);
11736 install_element (BGP_NODE, &no_neighbor_timers_connect_cmd);
718e3744 11737
11738 /* "neighbor advertisement-interval" commands. */
11739 install_element (BGP_NODE, &neighbor_advertise_interval_cmd);
11740 install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd);
718e3744 11741
718e3744 11742 /* "neighbor interface" commands. */
11743 install_element (BGP_NODE, &neighbor_interface_cmd);
11744 install_element (BGP_NODE, &no_neighbor_interface_cmd);
11745
11746 /* "neighbor distribute" commands. */
596c17ba
DW
11747 install_element (BGP_NODE, &neighbor_distribute_list_hidden_cmd);
11748 install_element (BGP_NODE, &no_neighbor_distribute_list_hidden_cmd);
718e3744 11749 install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd);
11750 install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd);
11751 install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd);
11752 install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd);
f51bae9c
DS
11753 install_element (BGP_IPV4L_NODE, &neighbor_distribute_list_cmd);
11754 install_element (BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd);
718e3744 11755 install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd);
11756 install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd);
25ffbdc1 11757 install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd);
11758 install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd);
f51bae9c
DS
11759 install_element (BGP_IPV6L_NODE, &neighbor_distribute_list_cmd);
11760 install_element (BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd);
718e3744 11761 install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd);
11762 install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd);
8ecd3266 11763 install_element (BGP_VPNV6_NODE, &neighbor_distribute_list_cmd);
11764 install_element (BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd);
8b1fb8be
LB
11765 install_element (BGP_ENCAP_NODE, &neighbor_distribute_list_cmd);
11766 install_element (BGP_ENCAP_NODE, &no_neighbor_distribute_list_cmd);
11767 install_element (BGP_ENCAPV6_NODE, &neighbor_distribute_list_cmd);
11768 install_element (BGP_ENCAPV6_NODE, &no_neighbor_distribute_list_cmd);
718e3744 11769
11770 /* "neighbor prefix-list" commands. */
596c17ba
DW
11771 install_element (BGP_NODE, &neighbor_prefix_list_hidden_cmd);
11772 install_element (BGP_NODE, &no_neighbor_prefix_list_hidden_cmd);
718e3744 11773 install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd);
11774 install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd);
11775 install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd);
11776 install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd);
f51bae9c
DS
11777 install_element (BGP_IPV4L_NODE, &neighbor_prefix_list_cmd);
11778 install_element (BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd);
718e3744 11779 install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd);
11780 install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd);
25ffbdc1 11781 install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd);
11782 install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd);
f51bae9c
DS
11783 install_element (BGP_IPV6L_NODE, &neighbor_prefix_list_cmd);
11784 install_element (BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd);
718e3744 11785 install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd);
11786 install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd);
8ecd3266 11787 install_element (BGP_VPNV6_NODE, &neighbor_prefix_list_cmd);
11788 install_element (BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd);
8b1fb8be
LB
11789 install_element (BGP_ENCAP_NODE, &neighbor_prefix_list_cmd);
11790 install_element (BGP_ENCAP_NODE, &no_neighbor_prefix_list_cmd);
11791 install_element (BGP_ENCAPV6_NODE, &neighbor_prefix_list_cmd);
11792 install_element (BGP_ENCAPV6_NODE, &no_neighbor_prefix_list_cmd);
718e3744 11793
11794 /* "neighbor filter-list" commands. */
596c17ba
DW
11795 install_element (BGP_NODE, &neighbor_filter_list_hidden_cmd);
11796 install_element (BGP_NODE, &no_neighbor_filter_list_hidden_cmd);
718e3744 11797 install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd);
11798 install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd);
11799 install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd);
11800 install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd);
f51bae9c
DS
11801 install_element (BGP_IPV4L_NODE, &neighbor_filter_list_cmd);
11802 install_element (BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd);
718e3744 11803 install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd);
11804 install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd);
25ffbdc1 11805 install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd);
11806 install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd);
f51bae9c
DS
11807 install_element (BGP_IPV6L_NODE, &neighbor_filter_list_cmd);
11808 install_element (BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd);
718e3744 11809 install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd);
11810 install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd);
8ecd3266 11811 install_element (BGP_VPNV6_NODE, &neighbor_filter_list_cmd);
11812 install_element (BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd);
8b1fb8be
LB
11813 install_element (BGP_ENCAP_NODE, &neighbor_filter_list_cmd);
11814 install_element (BGP_ENCAP_NODE, &no_neighbor_filter_list_cmd);
11815 install_element (BGP_ENCAPV6_NODE, &neighbor_filter_list_cmd);
11816 install_element (BGP_ENCAPV6_NODE, &no_neighbor_filter_list_cmd);
718e3744 11817
11818 /* "neighbor route-map" commands. */
596c17ba
DW
11819 install_element (BGP_NODE, &neighbor_route_map_hidden_cmd);
11820 install_element (BGP_NODE, &no_neighbor_route_map_hidden_cmd);
718e3744 11821 install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd);
11822 install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd);
11823 install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd);
11824 install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd);
f51bae9c
DS
11825 install_element (BGP_IPV4L_NODE, &neighbor_route_map_cmd);
11826 install_element (BGP_IPV4L_NODE, &no_neighbor_route_map_cmd);
718e3744 11827 install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd);
11828 install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd);
25ffbdc1 11829 install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd);
11830 install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd);
f51bae9c
DS
11831 install_element (BGP_IPV6L_NODE, &neighbor_route_map_cmd);
11832 install_element (BGP_IPV6L_NODE, &no_neighbor_route_map_cmd);
718e3744 11833 install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd);
11834 install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd);
8ecd3266 11835 install_element (BGP_VPNV6_NODE, &neighbor_route_map_cmd);
11836 install_element (BGP_VPNV6_NODE, &no_neighbor_route_map_cmd);
8b1fb8be
LB
11837 install_element (BGP_ENCAP_NODE, &neighbor_route_map_cmd);
11838 install_element (BGP_ENCAP_NODE, &no_neighbor_route_map_cmd);
11839 install_element (BGP_ENCAPV6_NODE, &neighbor_route_map_cmd);
11840 install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_map_cmd);
718e3744 11841
11842 /* "neighbor unsuppress-map" commands. */
596c17ba
DW
11843 install_element (BGP_NODE, &neighbor_unsuppress_map_hidden_cmd);
11844 install_element (BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd);
718e3744 11845 install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd);
11846 install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd);
11847 install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd);
11848 install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd);
f51bae9c
DS
11849 install_element (BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd);
11850 install_element (BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd);
718e3744 11851 install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd);
11852 install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd);
25ffbdc1 11853 install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd);
11854 install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd);
f51bae9c
DS
11855 install_element (BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd);
11856 install_element (BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd);
a58545bb 11857 install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd);
bb86c601 11858 install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd);
8ecd3266 11859 install_element (BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd);
bb86c601 11860 install_element (BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd);
8b1fb8be
LB
11861 install_element (BGP_ENCAP_NODE, &neighbor_unsuppress_map_cmd);
11862 install_element (BGP_ENCAP_NODE, &no_neighbor_unsuppress_map_cmd);
11863 install_element (BGP_ENCAPV6_NODE, &neighbor_unsuppress_map_cmd);
11864 install_element (BGP_ENCAPV6_NODE, &no_neighbor_unsuppress_map_cmd);
718e3744 11865
11866 /* "neighbor maximum-prefix" commands. */
596c17ba
DW
11867 install_element (BGP_NODE, &neighbor_maximum_prefix_hidden_cmd);
11868 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_hidden_cmd);
11869 install_element (BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd);
11870 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_hidden_cmd);
11871 install_element (BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd);
11872 install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_hidden_cmd);
11873 install_element (BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd);
718e3744 11874 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 11875 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 11876 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 11877 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 11878 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd);
11879 install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 11880 install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd);
718e3744 11881 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 11882 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 11883 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 11884 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 11885 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd);
11886 install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 11887 install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd);
f51bae9c
DS
11888 install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd);
11889 install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd);
11890 install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd);
11891 install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
11892 install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd);
11893 install_element (BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
11894 install_element (BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd);
718e3744 11895 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 11896 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 11897 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 11898 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 11899 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
11900 install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 11901 install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd);
25ffbdc1 11902 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd);
11903 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd);
11904 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd);
11905 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
11906 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd);
11907 install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
11908 install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd);
f51bae9c
DS
11909 install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd);
11910 install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd);
11911 install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd);
11912 install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
11913 install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd);
11914 install_element (BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
11915 install_element (BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd);
718e3744 11916 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd);
e0701b79 11917 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd);
718e3744 11918 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd);
e0701b79 11919 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
0a486e5f 11920 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd);
11921 install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
718e3744 11922 install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd);
8ecd3266 11923 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd);
11924 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
11925 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd);
11926 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
11927 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd);
11928 install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
11929 install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd);
718e3744 11930
8b1fb8be
LB
11931 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_cmd);
11932 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_cmd);
11933 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_warning_cmd);
11934 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
11935 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_restart_cmd);
11936 install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
11937 install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_cmd);
8b1fb8be
LB
11938
11939 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_cmd);
11940 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_cmd);
11941 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_warning_cmd);
11942 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd);
11943 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_restart_cmd);
11944 install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd);
11945 install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_cmd);
8b1fb8be 11946
718e3744 11947 /* "neighbor allowas-in" */
596c17ba
DW
11948 install_element (BGP_NODE, &neighbor_allowas_in_hidden_cmd);
11949 install_element (BGP_NODE, &no_neighbor_allowas_in_hidden_cmd);
718e3744 11950 install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd);
718e3744 11951 install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd);
11952 install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd);
718e3744 11953 install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd);
f51bae9c
DS
11954 install_element (BGP_IPV4L_NODE, &neighbor_allowas_in_cmd);
11955 install_element (BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd);
718e3744 11956 install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd);
718e3744 11957 install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd);
25ffbdc1 11958 install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd);
25ffbdc1 11959 install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd);
f51bae9c
DS
11960 install_element (BGP_IPV6L_NODE, &neighbor_allowas_in_cmd);
11961 install_element (BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd);
718e3744 11962 install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd);
718e3744 11963 install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd);
8ecd3266 11964 install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_cmd);
8ecd3266 11965 install_element (BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd);
8b1fb8be 11966 install_element (BGP_ENCAP_NODE, &neighbor_allowas_in_cmd);
8b1fb8be
LB
11967 install_element (BGP_ENCAP_NODE, &no_neighbor_allowas_in_cmd);
11968 install_element (BGP_ENCAPV6_NODE, &neighbor_allowas_in_cmd);
8b1fb8be 11969 install_element (BGP_ENCAPV6_NODE, &no_neighbor_allowas_in_cmd);
718e3744 11970
11971 /* address-family commands. */
718e3744 11972 install_element (BGP_NODE, &address_family_ipv4_safi_cmd);
25ffbdc1 11973 install_element (BGP_NODE, &address_family_ipv6_safi_cmd);
d6902373 11974#ifdef KEEP_OLD_VPN_COMMANDS
718e3744 11975 install_element (BGP_NODE, &address_family_vpnv4_cmd);
8b1fb8be 11976 install_element (BGP_NODE, &address_family_vpnv6_cmd);
d6902373 11977#endif /* KEEP_OLD_VPN_COMMANDS */
8b1fb8be
LB
11978
11979 install_element (BGP_NODE, &address_family_encap_cmd);
8b1fb8be 11980 install_element (BGP_NODE, &address_family_encapv6_cmd);
8b1fb8be 11981
4e0b7b6d
PG
11982 install_element (BGP_NODE, &address_family_evpn_cmd);
11983
718e3744 11984 /* "exit-address-family" command. */
11985 install_element (BGP_IPV4_NODE, &exit_address_family_cmd);
11986 install_element (BGP_IPV4M_NODE, &exit_address_family_cmd);
f51bae9c 11987 install_element (BGP_IPV4L_NODE, &exit_address_family_cmd);
718e3744 11988 install_element (BGP_IPV6_NODE, &exit_address_family_cmd);
25ffbdc1 11989 install_element (BGP_IPV6M_NODE, &exit_address_family_cmd);
f51bae9c 11990 install_element (BGP_IPV6L_NODE, &exit_address_family_cmd);
718e3744 11991 install_element (BGP_VPNV4_NODE, &exit_address_family_cmd);
8ecd3266 11992 install_element (BGP_VPNV6_NODE, &exit_address_family_cmd);
8b1fb8be
LB
11993 install_element (BGP_ENCAP_NODE, &exit_address_family_cmd);
11994 install_element (BGP_ENCAPV6_NODE, &exit_address_family_cmd);
4e0b7b6d 11995 install_element (BGP_EVPN_NODE, &exit_address_family_cmd);
718e3744 11996
11997 /* "clear ip bgp commands" */
11998 install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd);
718e3744 11999
8ad7271d
DS
12000 /* clear ip bgp prefix */
12001 install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd);
12002 install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd);
01080f7c 12003 install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd);
8ad7271d 12004
716b2d8a 12005 /* "show [ip] bgp summary" commands. */
f186de26 12006 install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd);
8386ac43 12007 install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd);
8386ac43 12008 install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd);
271ad8d5 12009 install_element (VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd);
e52702f2 12010 install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd);
e52702f2 12011 install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd);
271ad8d5 12012 install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd);
e52702f2 12013 install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd);
8c3deaae 12014 install_element (VIEW_NODE, &show_bgp_updgrps_stats_cmd);
271ad8d5
QY
12015 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd);
12016 install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd);
12017 install_element (VIEW_NODE, &show_ip_bgp_summary_cmd);
12018 install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd);
12019 install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd);
12020 install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd);
e3e29b32 12021
716b2d8a 12022 /* "show [ip] bgp neighbors" commands. */
718e3744 12023 install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd);
718e3744 12024
716b2d8a 12025 /* "show [ip] bgp peer-group" commands. */
f14e6fdb 12026 install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd);
f14e6fdb 12027
716b2d8a 12028 /* "show [ip] bgp paths" commands. */
718e3744 12029 install_element (VIEW_NODE, &show_ip_bgp_paths_cmd);
718e3744 12030
716b2d8a 12031 /* "show [ip] bgp community" commands. */
718e3744 12032 install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd);
718e3744 12033
57d187bc
JS
12034 /* "show ip bgp large-community" commands. */
12035 install_element (VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd);
716b2d8a 12036 /* "show [ip] bgp attribute-info" commands. */
718e3744 12037 install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd);
718e3744 12038
12039 /* "redistribute" commands. */
596c17ba
DW
12040 install_element (BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd);
12041 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd);
12042 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd);
12043 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd);
12044 install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_hidden_cmd);
12045 install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_hidden_cmd);
12046 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd);
12047 install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd);
12048 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd);
12049 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_hidden_cmd);
12050 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd);
12051 install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd);
919e0666
DW
12052 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd);
12053 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd);
12054 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd);
919e0666 12055 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd);
919e0666
DW
12056 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd);
12057 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd);
919e0666
DW
12058 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd);
12059 install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd);
12060 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd);
919e0666 12061 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd);
919e0666 12062 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd);
919e0666 12063 install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd);
718e3744 12064 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd);
12065 install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd);
12066 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd);
718e3744 12067 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd);
718e3744 12068 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd);
12069 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd);
718e3744 12070
fa411a21
NH
12071 /* ttl_security commands */
12072 install_element (BGP_NODE, &neighbor_ttl_security_cmd);
12073 install_element (BGP_NODE, &no_neighbor_ttl_security_cmd);
12074
716b2d8a 12075 /* "show [ip] bgp memory" commands. */
4bf6a362 12076 install_element (VIEW_NODE, &show_bgp_memory_cmd);
e52702f2 12077
716b2d8a 12078 /* "show [ip] bgp views" commands. */
e0081f70 12079 install_element (VIEW_NODE, &show_bgp_views_cmd);
e52702f2 12080
716b2d8a 12081 /* "show [ip] bgp vrfs" commands. */
8386ac43 12082 install_element (VIEW_NODE, &show_bgp_vrfs_cmd);
e52702f2 12083
718e3744 12084 /* Community-list. */
12085 community_list_vty ();
12086}
6b0655a2 12087
718e3744 12088#include "memory.h"
12089#include "bgp_regex.h"
12090#include "bgp_clist.h"
12091#include "bgp_ecommunity.h"
12092
12093/* VTY functions. */
12094
12095/* Direction value to string conversion. */
94f2b392 12096static const char *
718e3744 12097community_direct_str (int direct)
12098{
12099 switch (direct)
12100 {
12101 case COMMUNITY_DENY:
12102 return "deny";
718e3744 12103 case COMMUNITY_PERMIT:
12104 return "permit";
718e3744 12105 default:
12106 return "unknown";
718e3744 12107 }
12108}
12109
12110/* Display error string. */
94f2b392 12111static void
718e3744 12112community_list_perror (struct vty *vty, int ret)
12113{
12114 switch (ret)
12115 {
12116 case COMMUNITY_LIST_ERR_CANT_FIND_LIST:
b729294c 12117 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
718e3744 12118 break;
12119 case COMMUNITY_LIST_ERR_MALFORMED_VAL:
12120 vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE);
12121 break;
12122 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT:
12123 vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE);
12124 break;
12125 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT:
12126 vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE);
12127 break;
12128 }
12129}
12130
5bf15956
DW
12131/* "community-list" keyword help string. */
12132#define COMMUNITY_LIST_STR "Add a community list entry\n"
12133
718e3744 12134
5bf15956 12135/* ip community-list standard */
718e3744 12136DEFUN (ip_community_list_standard,
12137 ip_community_list_standard_cmd,
e961923c 12138 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
718e3744 12139 IP_STR
12140 COMMUNITY_LIST_STR
12141 "Community list number (standard)\n"
5bf15956 12142 "Add an standard community-list entry\n"
718e3744 12143 "Community list name\n"
12144 "Specify community to reject\n"
12145 "Specify community to accept\n"
12146 COMMUNITY_VAL_STR)
12147{
42f914d4
QY
12148 char *cl_name_or_number = NULL;
12149 int direct = 0;
12150 int style = COMMUNITY_LIST_STANDARD;
12151
12152 int idx = 0;
12153 argv_find (argv, argc, "(1-99)", &idx);
12154 argv_find (argv, argc, "WORD", &idx);
12155 cl_name_or_number = argv[idx]->arg;
12156 direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY;
12157 argv_find (argv, argc, "AA:NN", &idx);
12158 char *str = argv_concat (argv, argc, idx);
12159
12160 int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style);
12161
12162 XFREE (MTYPE_TMP, str);
12163
12164 if (ret < 0)
12165 {
12166 /* Display error string. */
12167 community_list_perror (vty, ret);
12168 return CMD_WARNING;
12169 }
12170
12171 return CMD_SUCCESS;
718e3744 12172}
12173
fee6e4e4 12174DEFUN (no_ip_community_list_standard_all,
12175 no_ip_community_list_standard_all_cmd,
e961923c 12176 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
718e3744 12177 NO_STR
12178 IP_STR
12179 COMMUNITY_LIST_STR
12180 "Community list number (standard)\n"
5bf15956
DW
12181 "Add an standard community-list entry\n"
12182 "Community list name\n"
718e3744 12183 "Specify community to reject\n"
12184 "Specify community to accept\n"
12185 COMMUNITY_VAL_STR)
12186{
42f914d4
QY
12187 int delete_all = 0;
12188
12189 char *cl_name_or_number = NULL;
12190 int direct = 0;
12191 int style = COMMUNITY_LIST_STANDARD;
12192
12193 int idx = 0;
12194 argv_find (argv, argc, "(1-99)", &idx);
12195 argv_find (argv, argc, "WORD", &idx);
12196 cl_name_or_number = argv[idx]->arg;
12197 direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY;
12198 argv_find (argv, argc, "AA:NN", &idx);
12199 char *str = argv_concat (argv, argc, idx);
12200
12201 int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all);
12202
daf9ddbb
DS
12203 XFREE (MTYPE_TMP, str);
12204
42f914d4
QY
12205 if (ret < 0)
12206 {
12207 community_list_perror (vty, ret);
12208 return CMD_WARNING;
12209 }
12210
12211 return CMD_SUCCESS;
718e3744 12212}
12213
5bf15956
DW
12214/* ip community-list expanded */
12215DEFUN (ip_community_list_expanded_all,
12216 ip_community_list_expanded_all_cmd,
42f914d4 12217 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
718e3744 12218 IP_STR
12219 COMMUNITY_LIST_STR
12220 "Community list number (expanded)\n"
5bf15956 12221 "Add an expanded community-list entry\n"
718e3744 12222 "Community list name\n"
12223 "Specify community to reject\n"
12224 "Specify community to accept\n"
12225 COMMUNITY_VAL_STR)
12226{
42f914d4
QY
12227 char *cl_name_or_number = NULL;
12228 int direct = 0;
12229 int style = COMMUNITY_LIST_EXPANDED;
12230
12231 int idx = 0;
12232 argv_find (argv, argc, "(100-500)", &idx);
12233 argv_find (argv, argc, "WORD", &idx);
12234 cl_name_or_number = argv[idx]->arg;
12235 direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY;
12236 argv_find (argv, argc, "AA:NN", &idx);
12237 char *str = argv_concat (argv, argc, idx);
12238
12239 int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style);
12240
12241 XFREE (MTYPE_TMP, str);
12242
12243 if (ret < 0)
12244 {
12245 /* Display error string. */
12246 community_list_perror (vty, ret);
12247 return CMD_WARNING;
12248 }
12249
12250 return CMD_SUCCESS;
718e3744 12251}
12252
5bf15956
DW
12253DEFUN (no_ip_community_list_expanded_all,
12254 no_ip_community_list_expanded_all_cmd,
42f914d4 12255 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
718e3744 12256 NO_STR
12257 IP_STR
12258 COMMUNITY_LIST_STR
5bf15956
DW
12259 "Community list number (expanded)\n"
12260 "Add an expanded community-list entry\n"
718e3744 12261 "Community list name\n"
12262 "Specify community to reject\n"
12263 "Specify community to accept\n"
5bf15956 12264 COMMUNITY_VAL_STR)
718e3744 12265{
42f914d4
QY
12266 int delete_all = 0;
12267
12268 char *cl_name_or_number = NULL;
12269 int direct = 0;
12270 int style = COMMUNITY_LIST_EXPANDED;
12271
12272 int idx = 0;
12273 argv_find (argv, argc, "(100-500)", &idx);
12274 argv_find (argv, argc, "WORD", &idx);
12275 cl_name_or_number = argv[idx]->arg;
12276 direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY;
12277 argv_find (argv, argc, "AA:NN", &idx);
12278 char *str = argv_concat (argv, argc, idx);
12279
12280 int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all);
12281
daf9ddbb
DS
12282 XFREE (MTYPE_TMP, str);
12283
42f914d4
QY
12284 if (ret < 0)
12285 {
12286 community_list_perror (vty, ret);
12287 return CMD_WARNING;
12288 }
12289
12290 return CMD_SUCCESS;
718e3744 12291}
12292
94f2b392 12293static void
718e3744 12294community_list_show (struct vty *vty, struct community_list *list)
12295{
12296 struct community_entry *entry;
12297
12298 for (entry = list->head; entry; entry = entry->next)
12299 {
12300 if (entry == list->head)
12301 {
12302 if (all_digit (list->name))
12303 vty_out (vty, "Community %s list %s%s",
12304 entry->style == COMMUNITY_LIST_STANDARD ?
12305 "standard" : "(expanded) access",
12306 list->name, VTY_NEWLINE);
12307 else
12308 vty_out (vty, "Named Community %s list %s%s",
12309 entry->style == COMMUNITY_LIST_STANDARD ?
12310 "standard" : "expanded",
12311 list->name, VTY_NEWLINE);
12312 }
12313 if (entry->any)
12314 vty_out (vty, " %s%s",
12315 community_direct_str (entry->direct), VTY_NEWLINE);
12316 else
12317 vty_out (vty, " %s %s%s",
12318 community_direct_str (entry->direct),
12319 entry->style == COMMUNITY_LIST_STANDARD
12320 ? community_str (entry->u.com) : entry->config,
12321 VTY_NEWLINE);
12322 }
12323}
12324
12325DEFUN (show_ip_community_list,
12326 show_ip_community_list_cmd,
12327 "show ip community-list",
12328 SHOW_STR
12329 IP_STR
12330 "List community-list\n")
12331{
12332 struct community_list *list;
12333 struct community_list_master *cm;
12334
fee6e4e4 12335 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
718e3744 12336 if (! cm)
12337 return CMD_SUCCESS;
12338
12339 for (list = cm->num.head; list; list = list->next)
12340 community_list_show (vty, list);
12341
12342 for (list = cm->str.head; list; list = list->next)
12343 community_list_show (vty, list);
12344
12345 return CMD_SUCCESS;
12346}
12347
12348DEFUN (show_ip_community_list_arg,
12349 show_ip_community_list_arg_cmd,
6147e2c6 12350 "show ip community-list <(1-500)|WORD>",
718e3744 12351 SHOW_STR
12352 IP_STR
12353 "List community-list\n"
12354 "Community-list number\n"
12355 "Community-list name\n")
12356{
c500ae40 12357 int idx_comm_list = 3;
718e3744 12358 struct community_list *list;
12359
c500ae40 12360 list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, COMMUNITY_LIST_MASTER);
718e3744 12361 if (! list)
12362 {
b729294c 12363 vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE);
718e3744 12364 return CMD_WARNING;
12365 }
12366
12367 community_list_show (vty, list);
12368
12369 return CMD_SUCCESS;
12370}
6b0655a2 12371
57d187bc
JS
12372/*
12373 * Large Community code.
12374 */
12375static int
12376lcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv,
2acb4ac2 12377 int style, int reject_all_digit_name)
57d187bc
JS
12378{
12379 int ret;
12380 int direct;
12381 char *str;
12382 int idx = 0;
12383 char *cl_name;
12384
12385 direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY;
12386
12387 /* All digit name check. */
12388 idx = 0;
12389 argv_find (argv, argc, "WORD", &idx);
12390 argv_find (argv, argc, "(1-99)", &idx);
12391 argv_find (argv, argc, "(100-500)", &idx);
12392 cl_name = argv[idx]->arg;
12393 if (reject_all_digit_name && all_digit (cl_name))
12394 {
12395 vty_out (vty, "%% Community name cannot have all digits%s", VTY_NEWLINE);
12396 return CMD_WARNING;
12397 }
12398
12399 argv_find (argv, argc, "AA:BB:CC", &idx);
12400 argv_find (argv, argc, "LINE", &idx);
12401 /* Concat community string argument. */
12402 if (idx)
12403 str = argv_concat (argv, argc, idx);
12404 else
12405 str = NULL;
12406
12407 ret = lcommunity_list_set (bgp_clist, cl_name, str, direct, style);
12408
12409 /* Free temporary community list string allocated by
12410 argv_concat(). */
12411 if (str)
12412 XFREE (MTYPE_TMP, str);
12413
12414 if (ret < 0)
12415 {
12416 community_list_perror (vty, ret);
12417 return CMD_WARNING;
12418 }
12419 return CMD_SUCCESS;
12420}
12421
12422static int
12423lcommunity_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv,
2acb4ac2 12424 int style)
57d187bc
JS
12425{
12426 int ret;
12427 int direct = 0;
12428 char *str = NULL;
12429 int idx = 0;
12430
12431 argv_find (argv, argc, "permit", &idx);
12432 argv_find (argv, argc, "deny", &idx);
12433
12434 if (idx)
12435 {
12436 /* Check the list direct. */
12437 if (strncmp (argv[idx]->arg, "p", 1) == 0)
2acb4ac2 12438 direct = COMMUNITY_PERMIT;
57d187bc 12439 else
2acb4ac2 12440 direct = COMMUNITY_DENY;
57d187bc
JS
12441
12442 idx = 0;
12443 argv_find (argv, argc, "LINE", &idx);
12444 argv_find (argv, argc, "AA:AA:NN", &idx);
12445 /* Concat community string argument. */
12446 str = argv_concat (argv, argc, idx);
12447 }
12448
12449 idx = 0;
12450 argv_find (argv, argc, "(1-99)", &idx);
12451 argv_find (argv, argc, "(100-500)", &idx);
12452 argv_find (argv, argc, "WORD", &idx);
12453
12454 /* Unset community list. */
12455 ret = lcommunity_list_unset (bgp_clist, argv[idx]->arg, str, direct, style);
12456
12457 /* Free temporary community list string allocated by
12458 argv_concat(). */
12459 if (str)
12460 XFREE (MTYPE_TMP, str);
12461
12462 if (ret < 0)
12463 {
12464 community_list_perror (vty, ret);
12465 return CMD_WARNING;
12466 }
12467
12468 return CMD_SUCCESS;
12469}
12470
12471/* "large-community-list" keyword help string. */
12472#define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
12473#define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
12474
12475DEFUN (ip_lcommunity_list_standard,
12476 ip_lcommunity_list_standard_cmd,
52951b63
DS
12477 "ip large-community-list (1-99) <deny|permit>",
12478 IP_STR
12479 LCOMMUNITY_LIST_STR
12480 "Large Community list number (standard)\n"
12481 "Specify large community to reject\n"
12482 "Specify large community to accept\n"
12483 LCOMMUNITY_VAL_STR)
12484{
12485 return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 0);
12486}
12487
12488DEFUN (ip_lcommunity_list_standard1,
12489 ip_lcommunity_list_standard1_cmd,
12490 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
57d187bc
JS
12491 IP_STR
12492 LCOMMUNITY_LIST_STR
12493 "Large Community list number (standard)\n"
12494 "Specify large community to reject\n"
12495 "Specify large community to accept\n"
12496 LCOMMUNITY_VAL_STR)
12497{
12498 return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 0);
12499}
12500
12501DEFUN (ip_lcommunity_list_expanded,
12502 ip_lcommunity_list_expanded_cmd,
12503 "ip large-community-list (100-500) <deny|permit> LINE...",
12504 IP_STR
12505 LCOMMUNITY_LIST_STR
12506 "Large Community list number (expanded)\n"
12507 "Specify large community to reject\n"
12508 "Specify large community to accept\n"
12509 "An ordered list as a regular-expression\n")
12510{
12511 return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED, 0);
12512}
12513
12514DEFUN (ip_lcommunity_list_name_standard,
12515 ip_lcommunity_list_name_standard_cmd,
52951b63
DS
12516 "ip large-community-list standard WORD <deny|permit>",
12517 IP_STR
12518 LCOMMUNITY_LIST_STR
12519 "Specify standard large-community-list\n"
12520 "Large Community list name\n"
12521 "Specify large community to reject\n"
12522 "Specify large community to accept\n")
12523{
12524 return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 1);
12525}
12526
12527DEFUN (ip_lcommunity_list_name_standard1,
12528 ip_lcommunity_list_name_standard1_cmd,
12529 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
57d187bc
JS
12530 IP_STR
12531 LCOMMUNITY_LIST_STR
12532 "Specify standard large-community-list\n"
12533 "Large Community list name\n"
12534 "Specify large community to reject\n"
12535 "Specify large community to accept\n"
12536 LCOMMUNITY_VAL_STR)
12537{
12538 return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD, 1);
12539}
12540
12541DEFUN (ip_lcommunity_list_name_expanded,
12542 ip_lcommunity_list_name_expanded_cmd,
12543 "ip large-community-list expanded WORD <deny|permit> LINE...",
12544 IP_STR
12545 LCOMMUNITY_LIST_STR
12546 "Specify expanded large-community-list\n"
12547 "Large Community list name\n"
12548 "Specify large community to reject\n"
12549 "Specify large community to accept\n"
12550 "An ordered list as a regular-expression\n")
12551{
12552 return lcommunity_list_set_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED, 1);
12553}
12554
12555DEFUN (no_ip_lcommunity_list_standard_all,
12556 no_ip_lcommunity_list_standard_all_cmd,
12557 "no ip large-community-list <(1-99)|(100-500)|WORD>",
12558 NO_STR
12559 IP_STR
12560 LCOMMUNITY_LIST_STR
12561 "Large Community list number (standard)\n"
12562 "Large Community list number (expanded)\n"
12563 "Large Community list name\n")
12564{
12565 return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD);
12566}
12567
12568DEFUN (no_ip_lcommunity_list_name_expanded_all,
12569 no_ip_lcommunity_list_name_expanded_all_cmd,
12570 "no ip large-community-list expanded WORD",
12571 NO_STR
12572 IP_STR
12573 LCOMMUNITY_LIST_STR
12574 "Specify expanded large-community-list\n"
12575 "Large Community list name\n")
12576{
12577 return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED);
12578}
12579
12580DEFUN (no_ip_lcommunity_list_standard,
12581 no_ip_lcommunity_list_standard_cmd,
12582 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
12583 NO_STR
12584 IP_STR
12585 LCOMMUNITY_LIST_STR
12586 "Large Community list number (standard)\n"
12587 "Specify large community to reject\n"
12588 "Specify large community to accept\n"
12589 LCOMMUNITY_VAL_STR)
12590{
12591 return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD);
12592}
12593
12594DEFUN (no_ip_lcommunity_list_expanded,
12595 no_ip_lcommunity_list_expanded_cmd,
12596 "no ip large-community-list (100-500) <deny|permit> LINE...",
12597 NO_STR
12598 IP_STR
12599 LCOMMUNITY_LIST_STR
12600 "Large Community list number (expanded)\n"
12601 "Specify large community to reject\n"
12602 "Specify large community to accept\n"
12603 "An ordered list as a regular-expression\n")
12604{
12605 return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED);
12606}
12607
12608DEFUN (no_ip_lcommunity_list_name_standard,
12609 no_ip_lcommunity_list_name_standard_cmd,
12610 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
12611 NO_STR
12612 IP_STR
12613 LCOMMUNITY_LIST_STR
12614 "Specify standard large-community-list\n"
12615 "Large Community list name\n"
12616 "Specify large community to reject\n"
12617 "Specify large community to accept\n"
12618 LCOMMUNITY_VAL_STR)
12619{
12620 return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_STANDARD);
12621}
12622
12623DEFUN (no_ip_lcommunity_list_name_expanded,
12624 no_ip_lcommunity_list_name_expanded_cmd,
12625 "no ip large-community-list expanded WORD <deny|permit> LINE...",
12626 NO_STR
12627 IP_STR
12628 LCOMMUNITY_LIST_STR
12629 "Specify expanded large-community-list\n"
12630 "Large community list name\n"
12631 "Specify large community to reject\n"
12632 "Specify large community to accept\n"
12633 "An ordered list as a regular-expression\n")
12634{
12635 return lcommunity_list_unset_vty (vty, argc, argv, LARGE_COMMUNITY_LIST_EXPANDED);
12636}
12637
12638static void
12639lcommunity_list_show (struct vty *vty, struct community_list *list)
12640{
12641 struct community_entry *entry;
12642
12643 for (entry = list->head; entry; entry = entry->next)
12644 {
12645 if (entry == list->head)
2acb4ac2
DL
12646 {
12647 if (all_digit (list->name))
12648 vty_out (vty, "Large community %s list %s%s",
12649 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
12650 "standard" : "(expanded) access",
12651 list->name, VTY_NEWLINE);
12652 else
12653 vty_out (vty, "Named large community %s list %s%s",
12654 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
12655 "standard" : "expanded",
12656 list->name, VTY_NEWLINE);
12657 }
57d187bc 12658 if (entry->any)
2acb4ac2
DL
12659 vty_out (vty, " %s%s",
12660 community_direct_str (entry->direct), VTY_NEWLINE);
57d187bc 12661 else
2acb4ac2
DL
12662 vty_out (vty, " %s %s%s",
12663 community_direct_str (entry->direct),
12664 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
12665 entry->u.ecom->str : entry->config,
12666 VTY_NEWLINE);
57d187bc
JS
12667 }
12668}
12669
12670DEFUN (show_ip_lcommunity_list,
12671 show_ip_lcommunity_list_cmd,
12672 "show ip large-community-list",
12673 SHOW_STR
12674 IP_STR
12675 "List large-community list\n")
12676{
12677 struct community_list *list;
12678 struct community_list_master *cm;
12679
12680 cm = community_list_master_lookup (bgp_clist, LARGE_COMMUNITY_LIST_MASTER);
12681 if (! cm)
12682 return CMD_SUCCESS;
12683
12684 for (list = cm->num.head; list; list = list->next)
12685 lcommunity_list_show (vty, list);
12686
12687 for (list = cm->str.head; list; list = list->next)
12688 lcommunity_list_show (vty, list);
12689
12690 return CMD_SUCCESS;
12691}
12692
12693DEFUN (show_ip_lcommunity_list_arg,
12694 show_ip_lcommunity_list_arg_cmd,
12695 "show ip large-community-list <(1-500)|WORD>",
12696 SHOW_STR
12697 IP_STR
12698 "List large-community list\n"
12699 "large-community-list number\n"
12700 "large-community-list name\n")
12701{
12702 struct community_list *list;
12703
12704 list = community_list_lookup (bgp_clist, argv[3]->arg, LARGE_COMMUNITY_LIST_MASTER);
12705 if (! list)
12706 {
12707 vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE);
12708 return CMD_WARNING;
12709 }
12710
12711 lcommunity_list_show (vty, list);
12712
12713 return CMD_SUCCESS;
12714}
12715
718e3744 12716/* "extcommunity-list" keyword help string. */
12717#define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
12718#define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
12719
12720DEFUN (ip_extcommunity_list_standard,
12721 ip_extcommunity_list_standard_cmd,
e961923c 12722 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
718e3744 12723 IP_STR
12724 EXTCOMMUNITY_LIST_STR
12725 "Extended Community list number (standard)\n"
718e3744 12726 "Specify standard extcommunity-list\n"
5bf15956 12727 "Community list name\n"
718e3744 12728 "Specify community to reject\n"
12729 "Specify community to accept\n"
12730 EXTCOMMUNITY_VAL_STR)
12731{
42f914d4
QY
12732 int style = EXTCOMMUNITY_LIST_STANDARD;
12733 int direct = 0;
12734 char *cl_number_or_name = NULL;
12735
12736 int idx = 0;
12737 argv_find (argv, argc, "(1-99)", &idx);
12738 argv_find (argv, argc, "WORD", &idx);
12739 cl_number_or_name = argv[idx]->arg;
12740 direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY;
12741 argv_find (argv, argc, "AA:NN", &idx);
12742 char *str = argv_concat (argv, argc, idx);
12743
12744 int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style);
12745
12746 XFREE (MTYPE_TMP, str);
12747
12748 if (ret < 0)
12749 {
12750 community_list_perror (vty, ret);
12751 return CMD_WARNING;
12752 }
12753
12754 return CMD_SUCCESS;
718e3744 12755}
12756
718e3744 12757DEFUN (ip_extcommunity_list_name_expanded,
12758 ip_extcommunity_list_name_expanded_cmd,
e961923c 12759 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
718e3744 12760 IP_STR
12761 EXTCOMMUNITY_LIST_STR
5bf15956 12762 "Extended Community list number (expanded)\n"
718e3744 12763 "Specify expanded extcommunity-list\n"
12764 "Extended Community list name\n"
12765 "Specify community to reject\n"
12766 "Specify community to accept\n"
12767 "An ordered list as a regular-expression\n")
12768{
42f914d4
QY
12769 int style = EXTCOMMUNITY_LIST_EXPANDED;
12770 int direct = 0;
12771 char *cl_number_or_name = NULL;
12772
12773 int idx = 0;
12774 argv_find (argv, argc, "(100-500)", &idx);
12775 argv_find (argv, argc, "WORD", &idx);
12776 cl_number_or_name = argv[idx]->arg;
12777 direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY;
12778 argv_find (argv, argc, "LINE", &idx);
12779 char *str = argv_concat (argv, argc, idx);
12780
12781 int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style);
12782
12783 XFREE (MTYPE_TMP, str);
12784
12785 if (ret < 0)
12786 {
12787 community_list_perror (vty, ret);
12788 return CMD_WARNING;
12789 }
12790
12791 return CMD_SUCCESS;
718e3744 12792}
12793
fee6e4e4 12794DEFUN (no_ip_extcommunity_list_standard_all,
12795 no_ip_extcommunity_list_standard_all_cmd,
e961923c 12796 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
813d4307
DW
12797 NO_STR
12798 IP_STR
12799 EXTCOMMUNITY_LIST_STR
12800 "Extended Community list number (standard)\n"
718e3744 12801 "Specify standard extcommunity-list\n"
5bf15956 12802 "Community list name\n"
718e3744 12803 "Specify community to reject\n"
12804 "Specify community to accept\n"
12805 EXTCOMMUNITY_VAL_STR)
12806{
42f914d4
QY
12807 int deleteall = 0;
12808
12809 int style = EXTCOMMUNITY_LIST_STANDARD;
12810 int direct = 0;
12811 char *cl_number_or_name = NULL;
12812
12813 int idx = 0;
12814 argv_find (argv, argc, "(1-99)", &idx);
12815 argv_find (argv, argc, "WORD", &idx);
12816 cl_number_or_name = argv[idx]->arg;
12817 direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY;
12818 argv_find (argv, argc, "AA:NN", &idx);
12819 char *str = argv_concat (argv, argc, idx);
12820
12821 int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall);
12822
12823 XFREE (MTYPE_TMP, str);
12824
12825 if (ret < 0)
12826 {
12827 community_list_perror (vty, ret);
12828 return CMD_WARNING;
12829 }
12830
12831 return CMD_SUCCESS;
718e3744 12832}
12833
5bf15956
DW
12834DEFUN (no_ip_extcommunity_list_expanded_all,
12835 no_ip_extcommunity_list_expanded_all_cmd,
e961923c 12836 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
718e3744 12837 NO_STR
12838 IP_STR
12839 EXTCOMMUNITY_LIST_STR
12840 "Extended Community list number (expanded)\n"
718e3744 12841 "Specify expanded extcommunity-list\n"
5bf15956 12842 "Extended Community list name\n"
718e3744 12843 "Specify community to reject\n"
12844 "Specify community to accept\n"
12845 "An ordered list as a regular-expression\n")
12846{
42f914d4
QY
12847 int deleteall = 0;
12848
12849 int style = EXTCOMMUNITY_LIST_EXPANDED;
12850 int direct = 0;
12851 char *cl_number_or_name = NULL;
12852
12853 int idx = 0;
12854 argv_find (argv, argc, "(100-500)", &idx);
12855 argv_find (argv, argc, "WORD", &idx);
12856 cl_number_or_name = argv[idx]->arg;
12857 direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY;
12858 argv_find (argv, argc, "LINE", &idx);
12859 char *str = argv_concat (argv, argc, idx);
12860
12861 int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall);
12862
12863 XFREE (MTYPE_TMP, str);
12864
12865 if (ret < 0)
12866 {
12867 community_list_perror (vty, ret);
12868 return CMD_WARNING;
12869 }
12870
12871 return CMD_SUCCESS;
718e3744 12872}
12873
94f2b392 12874static void
718e3744 12875extcommunity_list_show (struct vty *vty, struct community_list *list)
12876{
12877 struct community_entry *entry;
12878
12879 for (entry = list->head; entry; entry = entry->next)
12880 {
12881 if (entry == list->head)
12882 {
12883 if (all_digit (list->name))
12884 vty_out (vty, "Extended community %s list %s%s",
12885 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
12886 "standard" : "(expanded) access",
12887 list->name, VTY_NEWLINE);
12888 else
12889 vty_out (vty, "Named extended community %s list %s%s",
12890 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
12891 "standard" : "expanded",
12892 list->name, VTY_NEWLINE);
12893 }
12894 if (entry->any)
12895 vty_out (vty, " %s%s",
12896 community_direct_str (entry->direct), VTY_NEWLINE);
12897 else
12898 vty_out (vty, " %s %s%s",
12899 community_direct_str (entry->direct),
12900 entry->style == EXTCOMMUNITY_LIST_STANDARD ?
12901 entry->u.ecom->str : entry->config,
12902 VTY_NEWLINE);
12903 }
12904}
12905
12906DEFUN (show_ip_extcommunity_list,
12907 show_ip_extcommunity_list_cmd,
12908 "show ip extcommunity-list",
12909 SHOW_STR
12910 IP_STR
12911 "List extended-community list\n")
12912{
12913 struct community_list *list;
12914 struct community_list_master *cm;
12915
fee6e4e4 12916 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
718e3744 12917 if (! cm)
12918 return CMD_SUCCESS;
12919
12920 for (list = cm->num.head; list; list = list->next)
12921 extcommunity_list_show (vty, list);
12922
12923 for (list = cm->str.head; list; list = list->next)
12924 extcommunity_list_show (vty, list);
12925
12926 return CMD_SUCCESS;
12927}
12928
12929DEFUN (show_ip_extcommunity_list_arg,
12930 show_ip_extcommunity_list_arg_cmd,
6147e2c6 12931 "show ip extcommunity-list <(1-500)|WORD>",
718e3744 12932 SHOW_STR
12933 IP_STR
12934 "List extended-community list\n"
12935 "Extcommunity-list number\n"
12936 "Extcommunity-list name\n")
12937{
c500ae40 12938 int idx_comm_list = 3;
718e3744 12939 struct community_list *list;
12940
c500ae40 12941 list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, EXTCOMMUNITY_LIST_MASTER);
718e3744 12942 if (! list)
12943 {
b729294c 12944 vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE);
718e3744 12945 return CMD_WARNING;
12946 }
12947
12948 extcommunity_list_show (vty, list);
12949
12950 return CMD_SUCCESS;
12951}
6b0655a2 12952
718e3744 12953/* Return configuration string of community-list entry. */
fd79ac91 12954static const char *
718e3744 12955community_list_config_str (struct community_entry *entry)
12956{
fd79ac91 12957 const char *str;
718e3744 12958
12959 if (entry->any)
12960 str = "";
12961 else
12962 {
12963 if (entry->style == COMMUNITY_LIST_STANDARD)
12964 str = community_str (entry->u.com);
12965 else
12966 str = entry->config;
12967 }
12968 return str;
12969}
12970
12971/* Display community-list and extcommunity-list configuration. */
94f2b392 12972static int
718e3744 12973community_list_config_write (struct vty *vty)
12974{
12975 struct community_list *list;
12976 struct community_entry *entry;
12977 struct community_list_master *cm;
12978 int write = 0;
12979
12980 /* Community-list. */
fee6e4e4 12981 cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER);
718e3744 12982
12983 for (list = cm->num.head; list; list = list->next)
12984 for (entry = list->head; entry; entry = entry->next)
12985 {
fee6e4e4 12986 vty_out (vty, "ip community-list %s %s %s%s",
12987 list->name, community_direct_str (entry->direct),
12988 community_list_config_str (entry),
12989 VTY_NEWLINE);
718e3744 12990 write++;
12991 }
12992 for (list = cm->str.head; list; list = list->next)
12993 for (entry = list->head; entry; entry = entry->next)
12994 {
12995 vty_out (vty, "ip community-list %s %s %s %s%s",
12996 entry->style == COMMUNITY_LIST_STANDARD
12997 ? "standard" : "expanded",
12998 list->name, community_direct_str (entry->direct),
12999 community_list_config_str (entry),
13000 VTY_NEWLINE);
13001 write++;
13002 }
13003
13004 /* Extcommunity-list. */
fee6e4e4 13005 cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER);
718e3744 13006
13007 for (list = cm->num.head; list; list = list->next)
13008 for (entry = list->head; entry; entry = entry->next)
13009 {
fee6e4e4 13010 vty_out (vty, "ip extcommunity-list %s %s %s%s",
13011 list->name, community_direct_str (entry->direct),
13012 community_list_config_str (entry), VTY_NEWLINE);
718e3744 13013 write++;
13014 }
13015 for (list = cm->str.head; list; list = list->next)
13016 for (entry = list->head; entry; entry = entry->next)
13017 {
13018 vty_out (vty, "ip extcommunity-list %s %s %s %s%s",
13019 entry->style == EXTCOMMUNITY_LIST_STANDARD
13020 ? "standard" : "expanded",
13021 list->name, community_direct_str (entry->direct),
13022 community_list_config_str (entry), VTY_NEWLINE);
13023 write++;
13024 }
57d187bc
JS
13025
13026
13027 /* lcommunity-list. */
13028 cm = community_list_master_lookup (bgp_clist, LARGE_COMMUNITY_LIST_MASTER);
13029
13030 for (list = cm->num.head; list; list = list->next)
13031 for (entry = list->head; entry; entry = entry->next)
13032 {
2acb4ac2
DL
13033 vty_out (vty, "ip large-community-list %s %s %s%s",
13034 list->name, community_direct_str (entry->direct),
13035 community_list_config_str (entry), VTY_NEWLINE);
13036 write++;
57d187bc
JS
13037 }
13038 for (list = cm->str.head; list; list = list->next)
13039 for (entry = list->head; entry; entry = entry->next)
13040 {
2acb4ac2
DL
13041 vty_out (vty, "ip large-community-list %s %s %s %s%s",
13042 entry->style == LARGE_COMMUNITY_LIST_STANDARD
13043 ? "standard" : "expanded",
13044 list->name, community_direct_str (entry->direct),
13045 community_list_config_str (entry), VTY_NEWLINE);
13046 write++;
57d187bc
JS
13047 }
13048
718e3744 13049 return write;
13050}
13051
7fc626de 13052static struct cmd_node community_list_node =
718e3744 13053{
13054 COMMUNITY_LIST_NODE,
13055 "",
13056 1 /* Export to vtysh. */
13057};
13058
94f2b392 13059static void
13060community_list_vty (void)
718e3744 13061{
13062 install_node (&community_list_node, community_list_config_write);
13063
13064 /* Community-list. */
718e3744 13065 install_element (CONFIG_NODE, &ip_community_list_standard_cmd);
d7d73ffc 13066 install_element (CONFIG_NODE, &ip_community_list_expanded_all_cmd);
fee6e4e4 13067 install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd);
13068 install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd);
718e3744 13069 install_element (VIEW_NODE, &show_ip_community_list_cmd);
13070 install_element (VIEW_NODE, &show_ip_community_list_arg_cmd);
718e3744 13071
13072 /* Extcommunity-list. */
13073 install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd);
718e3744 13074 install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd);
fee6e4e4 13075 install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd);
13076 install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd);
718e3744 13077 install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd);
13078 install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd);
57d187bc
JS
13079
13080 /* Large Community List */
13081 install_element (CONFIG_NODE, &ip_lcommunity_list_standard_cmd);
52951b63 13082 install_element (CONFIG_NODE, &ip_lcommunity_list_standard1_cmd);
57d187bc
JS
13083 install_element (CONFIG_NODE, &ip_lcommunity_list_expanded_cmd);
13084 install_element (CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd);
52951b63 13085 install_element (CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd);
57d187bc
JS
13086 install_element (CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd);
13087 install_element (CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd);
13088 install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_all_cmd);
13089 install_element (CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd);
13090 install_element (CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd);
13091 install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd);
13092 install_element (CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd);
13093 install_element (VIEW_NODE, &show_ip_lcommunity_list_cmd);
13094 install_element (VIEW_NODE, &show_ip_lcommunity_list_arg_cmd);
5bf15956 13095}