]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP VTY interface. |
2 | Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro | |
3 | ||
4 | This file is part of GNU Zebra. | |
5 | ||
6 | GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | under the terms of the GNU General Public License as published by the | |
8 | Free Software Foundation; either version 2, or (at your option) any | |
9 | later version. | |
10 | ||
11 | GNU Zebra is distributed in the hope that it will be useful, but | |
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GNU Zebra; see the file COPYING. If not, write to the Free | |
18 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
19 | 02111-1307, USA. */ | |
20 | ||
21 | #include <zebra.h> | |
22 | ||
23 | #include "command.h" | |
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 PJ |
43 | #include "bgpd/bgp_ecommunity.h" |
44 | #include "bgpd/bgp_damp.h" | |
718e3744 | 45 | #include "bgpd/bgp_debug.h" |
e0701b79 | 46 | #include "bgpd/bgp_fsm.h" |
718e3744 | 47 | #include "bgpd/bgp_mplsvpn.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" |
52 | #include "bgpd/bgp_zebra.h" | |
fee0f4c6 | 53 | #include "bgpd/bgp_table.h" |
94f2b392 | 54 | #include "bgpd/bgp_vty.h" |
165b5fff | 55 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 56 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 57 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 58 | #include "bgpd/bgp_bfd.h" |
718e3744 | 59 | |
20eb8864 | 60 | static struct peer_group * |
61 | listen_range_exists (struct bgp *bgp, struct prefix *range, int exact); | |
62 | ||
718e3744 | 63 | /* Utility function to get address family from current node. */ |
64 | afi_t | |
65 | bgp_node_afi (struct vty *vty) | |
66 | { | |
4e851f1f LB |
67 | afi_t afi; |
68 | switch (vty->node) | |
69 | { | |
70 | case BGP_IPV6_NODE: | |
71 | case BGP_IPV6M_NODE: | |
72 | case BGP_VPNV6_NODE: | |
73 | case BGP_ENCAPV6_NODE: | |
74 | afi = AFI_IP6; | |
75 | break; | |
76 | default: | |
77 | afi = AFI_IP; | |
78 | break; | |
79 | } | |
80 | return afi; | |
718e3744 | 81 | } |
82 | ||
83 | /* Utility function to get subsequent address family from current | |
84 | node. */ | |
85 | safi_t | |
86 | bgp_node_safi (struct vty *vty) | |
87 | { | |
4e851f1f LB |
88 | safi_t safi; |
89 | switch (vty->node) | |
90 | { | |
91 | case BGP_ENCAP_NODE: | |
92 | case BGP_ENCAPV6_NODE: | |
93 | safi = SAFI_ENCAP; | |
94 | break; | |
95 | case BGP_VPNV4_NODE: | |
96 | case BGP_VPNV6_NODE: | |
97 | safi = SAFI_MPLS_VPN; | |
98 | break; | |
99 | case BGP_IPV4M_NODE: | |
100 | case BGP_IPV6M_NODE: | |
101 | safi = SAFI_MULTICAST; | |
102 | break; | |
103 | default: | |
104 | safi = SAFI_UNICAST; | |
105 | break; | |
106 | } | |
107 | return safi; | |
718e3744 | 108 | } |
109 | ||
46f296b4 LB |
110 | /* supports <ipv4|ipv6> */ |
111 | afi_t | |
112 | bgp_vty_afi_from_arg(const char *afi_str) | |
8b1fb8be | 113 | { |
46f296b4 LB |
114 | afi_t afi = AFI_MAX; /* unknown */ |
115 | if (!strcmp(afi_str, "ipv4")) { | |
116 | afi = AFI_IP; | |
8b1fb8be LB |
117 | } |
118 | #ifdef HAVE_IPV6 | |
46f296b4 LB |
119 | else if (!strcmp(afi_str, "ipv6")) { |
120 | afi = AFI_IP6; | |
121 | } | |
8b1fb8be | 122 | #endif /* HAVE_IPV6 */ |
46f296b4 LB |
123 | return afi; |
124 | } | |
125 | ||
126 | int | |
127 | bgp_parse_afi(const char *str, afi_t *afi) | |
128 | { | |
129 | *afi = bgp_vty_afi_from_arg(str); | |
130 | if (*afi != AFI_MAX) | |
131 | return 0; | |
132 | else | |
8b1fb8be LB |
133 | return -1; |
134 | } | |
135 | ||
46f296b4 LB |
136 | int |
137 | argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, afi_t *afi) | |
138 | { | |
139 | int ret = 0; | |
140 | if (argv_find (argv, argc, "ipv4", index)) | |
141 | { | |
142 | ret = 1; | |
143 | if (afi) | |
144 | *afi = AFI_IP; | |
145 | } | |
146 | else if (argv_find (argv, argc, "ipv6", index)) | |
147 | { | |
148 | ret = 1; | |
149 | if (afi) | |
150 | *afi = AFI_IP6; | |
151 | } | |
152 | return ret; | |
153 | } | |
154 | ||
155 | /* supports <unicast|multicast|vpn|encap> */ | |
ccbb332a | 156 | safi_t |
3b14d86e | 157 | bgp_vty_safi_from_arg(const char *safi_str) |
ccbb332a LB |
158 | { |
159 | safi_t safi = SAFI_MAX; /* unknown */ | |
160 | if (strncmp (safi_str, "m", 1) == 0) | |
161 | safi = SAFI_MULTICAST; | |
162 | else if (strncmp (safi_str, "u", 1) == 0) | |
163 | safi = SAFI_UNICAST; | |
164 | else if (strncmp (safi_str, "e", 1) == 0) | |
165 | safi = SAFI_ENCAP; | |
166 | else if (strncmp (safi_str, "v", 1) == 0) | |
46f296b4 | 167 | safi = SAFI_MPLS_VPN; |
ccbb332a LB |
168 | return safi; |
169 | } | |
170 | ||
8b1fb8be LB |
171 | int |
172 | bgp_parse_safi(const char *str, safi_t *safi) | |
173 | { | |
ccbb332a LB |
174 | *safi = bgp_vty_safi_from_arg(str); |
175 | if (*safi != SAFI_MAX) | |
176 | return 0; | |
3b14d86e | 177 | else |
8b1fb8be LB |
178 | return -1; |
179 | } | |
180 | ||
46f296b4 LB |
181 | int |
182 | argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, safi_t *safi) | |
183 | { | |
184 | int ret = 0; | |
185 | if (argv_find (argv, argc, "unicast", index)) | |
186 | { | |
187 | ret = 1; | |
188 | if (safi) | |
189 | *safi = SAFI_UNICAST; | |
190 | } | |
191 | else if (argv_find (argv, argc, "multicast", index)) | |
192 | { | |
193 | ret = 1; | |
194 | if (safi) | |
195 | *safi = SAFI_MULTICAST; | |
196 | } | |
197 | else if (argv_find (argv, argc, "vpn", index)) | |
198 | { | |
199 | ret = 1; | |
200 | if (safi) | |
201 | *safi = SAFI_MPLS_VPN; | |
202 | } | |
203 | else if (argv_find (argv, argc, "encap", index)) | |
204 | { | |
205 | ret = 1; | |
206 | if (safi) | |
207 | *safi = SAFI_ENCAP; | |
208 | } | |
209 | return ret; | |
210 | } | |
211 | ||
94f2b392 | 212 | static int |
6aeb9e78 | 213 | peer_address_self_check (struct bgp *bgp, union sockunion *su) |
718e3744 | 214 | { |
215 | struct interface *ifp = NULL; | |
216 | ||
217 | if (su->sa.sa_family == AF_INET) | |
6aeb9e78 | 218 | ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr, bgp->vrf_id); |
718e3744 | 219 | #ifdef HAVE_IPV6 |
220 | else if (su->sa.sa_family == AF_INET6) | |
f2345335 | 221 | ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr, |
6aeb9e78 | 222 | su->sin6.sin6_scope_id, bgp->vrf_id); |
718e3744 | 223 | #endif /* HAVE IPV6 */ |
224 | ||
225 | if (ifp) | |
226 | return 1; | |
227 | ||
228 | return 0; | |
229 | } | |
230 | ||
231 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
232 | /* This is used only for configuration, so disallow if attempted on |
233 | * a dynamic neighbor. | |
234 | */ | |
94f2b392 | 235 | static struct peer * |
fd79ac91 | 236 | peer_lookup_vty (struct vty *vty, const char *ip_str) |
718e3744 | 237 | { |
cdc2d765 | 238 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
718e3744 | 239 | int ret; |
718e3744 | 240 | union sockunion su; |
241 | struct peer *peer; | |
242 | ||
cdc2d765 DL |
243 | if (!bgp) { |
244 | return NULL; | |
245 | } | |
718e3744 | 246 | |
247 | ret = str2sockunion (ip_str, &su); | |
248 | if (ret < 0) | |
249 | { | |
a80beece DS |
250 | peer = peer_lookup_by_conf_if (bgp, ip_str); |
251 | if (!peer) | |
252 | { | |
04b6bdc0 DW |
253 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) == NULL) |
254 | { | |
255 | vty_out (vty, "%% Malformed address or name: %s%s", ip_str, VTY_NEWLINE); | |
256 | return NULL; | |
257 | } | |
a80beece | 258 | } |
718e3744 | 259 | } |
a80beece | 260 | else |
718e3744 | 261 | { |
a80beece DS |
262 | peer = peer_lookup (bgp, &su); |
263 | if (! peer) | |
264 | { | |
265 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", | |
266 | VTY_NEWLINE); | |
267 | return NULL; | |
268 | } | |
f14e6fdb DS |
269 | if (peer_dynamic_neighbor (peer)) |
270 | { | |
271 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
272 | VTY_NEWLINE); | |
273 | return NULL; | |
274 | } | |
275 | ||
718e3744 | 276 | } |
277 | return peer; | |
278 | } | |
279 | ||
280 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
281 | /* This is used only for configuration, so disallow if attempted on |
282 | * a dynamic neighbor. | |
283 | */ | |
c43ed2e4 | 284 | struct peer * |
fd79ac91 | 285 | peer_and_group_lookup_vty (struct vty *vty, const char *peer_str) |
718e3744 | 286 | { |
cdc2d765 | 287 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); |
718e3744 | 288 | int ret; |
718e3744 | 289 | union sockunion su; |
f14e6fdb DS |
290 | struct peer *peer = NULL; |
291 | struct peer_group *group = NULL; | |
718e3744 | 292 | |
cdc2d765 DL |
293 | if (!bgp) { |
294 | return NULL; | |
295 | } | |
718e3744 | 296 | |
297 | ret = str2sockunion (peer_str, &su); | |
298 | if (ret == 0) | |
299 | { | |
f14e6fdb | 300 | /* IP address, locate peer. */ |
718e3744 | 301 | peer = peer_lookup (bgp, &su); |
718e3744 | 302 | } |
303 | else | |
304 | { | |
f14e6fdb | 305 | /* Not IP, could match either peer configured on interface or a group. */ |
a80beece | 306 | peer = peer_lookup_by_conf_if (bgp, peer_str); |
f14e6fdb DS |
307 | if (!peer) |
308 | group = peer_group_lookup (bgp, peer_str); | |
309 | } | |
a80beece | 310 | |
f14e6fdb DS |
311 | if (peer) |
312 | { | |
313 | if (peer_dynamic_neighbor (peer)) | |
314 | { | |
315 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
316 | VTY_NEWLINE); | |
317 | return NULL; | |
318 | } | |
319 | ||
320 | return peer; | |
718e3744 | 321 | } |
322 | ||
f14e6fdb DS |
323 | if (group) |
324 | return group->conf; | |
325 | ||
718e3744 | 326 | vty_out (vty, "%% Specify remote-as or peer-group commands first%s", |
327 | VTY_NEWLINE); | |
328 | ||
329 | return NULL; | |
330 | } | |
331 | ||
c43ed2e4 | 332 | int |
718e3744 | 333 | bgp_vty_return (struct vty *vty, int ret) |
334 | { | |
fd79ac91 | 335 | const char *str = NULL; |
718e3744 | 336 | |
337 | switch (ret) | |
338 | { | |
339 | case BGP_ERR_INVALID_VALUE: | |
340 | str = "Invalid value"; | |
341 | break; | |
342 | case BGP_ERR_INVALID_FLAG: | |
343 | str = "Invalid flag"; | |
344 | break; | |
718e3744 | 345 | case BGP_ERR_PEER_GROUP_SHUTDOWN: |
346 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
347 | break; | |
718e3744 | 348 | case BGP_ERR_PEER_FLAG_CONFLICT: |
349 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
350 | break; | |
718e3744 | 351 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: |
352 | str = "Specify remote-as or peer-group remote AS first"; | |
353 | break; | |
354 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
355 | str = "Cannot change the peer-group. Deconfigure first"; | |
356 | break; | |
357 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
4c48cf63 | 358 | str = "Peer is not a member of this peer-group"; |
718e3744 | 359 | break; |
360 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
361 | str = "Prefix/distribute list can not co-exist"; | |
362 | break; | |
363 | case BGP_ERR_NOT_INTERNAL_PEER: | |
364 | str = "Invalid command. Not an internal neighbor"; | |
365 | break; | |
366 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
5000f21c | 367 | str = "remove-private-AS cannot be configured for IBGP peers"; |
718e3744 | 368 | break; |
369 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
370 | str = "Local-AS allowed only for EBGP peers"; | |
371 | break; | |
372 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
373 | str = "Cannot have local-as same as BGP AS number"; | |
374 | break; | |
0df7c91f PJ |
375 | case BGP_ERR_TCPSIG_FAILED: |
376 | str = "Error while applying TCP-Sig to session(s)"; | |
377 | break; | |
fa411a21 NH |
378 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: |
379 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
380 | break; | |
f5a4827d SH |
381 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: |
382 | str = "ttl-security only allowed for EBGP peers"; | |
383 | break; | |
c7122e14 DS |
384 | case BGP_ERR_AS_OVERRIDE: |
385 | str = "as-override cannot be configured for IBGP peers"; | |
386 | break; | |
f14e6fdb DS |
387 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: |
388 | str = "Invalid limit for number of dynamic neighbors"; | |
389 | break; | |
390 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
391 | str = "Dynamic neighbor listen range already exists"; | |
392 | break; | |
393 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
394 | str = "Operation not allowed on a dynamic neighbor"; | |
395 | break; | |
63fa10b5 QY |
396 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: |
397 | str = "Operation not allowed on a directly connected neighbor"; | |
398 | break; | |
718e3744 | 399 | } |
400 | if (str) | |
401 | { | |
402 | vty_out (vty, "%% %s%s", str, VTY_NEWLINE); | |
403 | return CMD_WARNING; | |
404 | } | |
405 | return CMD_SUCCESS; | |
406 | } | |
407 | ||
7aafcaca DS |
408 | /* BGP clear sort. */ |
409 | enum clear_sort | |
410 | { | |
411 | clear_all, | |
412 | clear_peer, | |
413 | clear_group, | |
414 | clear_external, | |
415 | clear_as | |
416 | }; | |
417 | ||
7aafcaca DS |
418 | static void |
419 | bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi, | |
420 | safi_t safi, int error) | |
421 | { | |
422 | switch (error) | |
423 | { | |
424 | case BGP_ERR_AF_UNCONFIGURED: | |
425 | vty_out (vty, | |
46f296b4 LB |
426 | "%%BGP: Enable %s address family for the neighbor %s%s", |
427 | afi_safi_print(afi, safi), peer->host, VTY_NEWLINE); | |
7aafcaca DS |
428 | break; |
429 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
430 | 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); | |
431 | break; | |
432 | default: | |
433 | break; | |
434 | } | |
435 | } | |
436 | ||
437 | /* `clear ip bgp' functions. */ | |
438 | static int | |
439 | bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, | |
440 | enum clear_sort sort,enum bgp_clear_type stype, const char *arg) | |
441 | { | |
442 | int ret; | |
443 | struct peer *peer; | |
444 | struct listnode *node, *nnode; | |
445 | ||
446 | /* Clear all neighbors. */ | |
447 | /* | |
448 | * Pass along pointer to next node to peer_clear() when walking all nodes | |
449 | * on the BGP instance as that may get freed if it is a doppelganger | |
450 | */ | |
451 | if (sort == clear_all) | |
452 | { | |
453 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
454 | { | |
455 | if (stype == BGP_CLEAR_SOFT_NONE) | |
456 | ret = peer_clear (peer, &nnode); | |
457 | else if (peer->afc[afi][safi]) | |
458 | ret = peer_clear_soft (peer, afi, safi, stype); | |
459 | else | |
460 | ret = 0; | |
461 | ||
462 | if (ret < 0) | |
463 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
464 | } | |
465 | ||
466 | /* This is to apply read-only mode on this clear. */ | |
467 | if (stype == BGP_CLEAR_SOFT_NONE) | |
468 | bgp->update_delay_over = 0; | |
469 | ||
470 | return CMD_SUCCESS; | |
471 | } | |
472 | ||
473 | /* Clear specified neighbors. */ | |
474 | if (sort == clear_peer) | |
475 | { | |
476 | union sockunion su; | |
477 | int ret; | |
478 | ||
479 | /* Make sockunion for lookup. */ | |
480 | ret = str2sockunion (arg, &su); | |
481 | if (ret < 0) | |
482 | { | |
483 | peer = peer_lookup_by_conf_if (bgp, arg); | |
484 | if (!peer) | |
485 | { | |
04b6bdc0 DW |
486 | peer = peer_lookup_by_hostname(bgp, arg); |
487 | if (!peer) | |
488 | { | |
489 | vty_out (vty, "Malformed address or name: %s%s", arg, VTY_NEWLINE); | |
490 | return CMD_WARNING; | |
491 | } | |
7aafcaca DS |
492 | } |
493 | } | |
494 | else | |
495 | { | |
496 | peer = peer_lookup (bgp, &su); | |
497 | if (! peer) | |
498 | { | |
499 | vty_out (vty, "%%BGP: Unknown neighbor - \"%s\"%s", arg, VTY_NEWLINE); | |
500 | return CMD_WARNING; | |
501 | } | |
502 | } | |
503 | ||
504 | if (stype == BGP_CLEAR_SOFT_NONE) | |
505 | ret = peer_clear (peer, NULL); | |
506 | else | |
507 | ret = peer_clear_soft (peer, afi, safi, stype); | |
508 | ||
509 | if (ret < 0) | |
510 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
511 | ||
512 | return CMD_SUCCESS; | |
513 | } | |
514 | ||
515 | /* Clear all peer-group members. */ | |
516 | if (sort == clear_group) | |
517 | { | |
518 | struct peer_group *group; | |
519 | ||
520 | group = peer_group_lookup (bgp, arg); | |
521 | if (! group) | |
522 | { | |
523 | vty_out (vty, "%%BGP: No such peer-group %s%s", arg, VTY_NEWLINE); | |
524 | return CMD_WARNING; | |
525 | } | |
526 | ||
527 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
528 | { | |
529 | if (stype == BGP_CLEAR_SOFT_NONE) | |
530 | { | |
18f1dc06 | 531 | peer_clear (peer, NULL); |
7aafcaca DS |
532 | continue; |
533 | } | |
534 | ||
c8560b44 | 535 | if (! peer->afc[afi][safi]) |
7aafcaca DS |
536 | continue; |
537 | ||
538 | ret = peer_clear_soft (peer, afi, safi, stype); | |
539 | ||
540 | if (ret < 0) | |
541 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
542 | } | |
543 | return CMD_SUCCESS; | |
544 | } | |
545 | ||
546 | if (sort == clear_external) | |
547 | { | |
548 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
549 | { | |
550 | if (peer->sort == BGP_PEER_IBGP) | |
551 | continue; | |
552 | ||
553 | if (stype == BGP_CLEAR_SOFT_NONE) | |
554 | ret = peer_clear (peer, &nnode); | |
555 | else | |
556 | ret = peer_clear_soft (peer, afi, safi, stype); | |
557 | ||
558 | if (ret < 0) | |
559 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
560 | } | |
561 | return CMD_SUCCESS; | |
562 | } | |
563 | ||
564 | if (sort == clear_as) | |
565 | { | |
566 | as_t as; | |
567 | int find = 0; | |
568 | ||
569 | VTY_GET_INTEGER_RANGE ("AS", as, arg, 1, BGP_AS4_MAX); | |
570 | ||
571 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
572 | { | |
573 | if (peer->as != as) | |
574 | continue; | |
575 | ||
576 | find = 1; | |
577 | if (stype == BGP_CLEAR_SOFT_NONE) | |
578 | ret = peer_clear (peer, &nnode); | |
579 | else | |
580 | ret = peer_clear_soft (peer, afi, safi, stype); | |
581 | ||
582 | if (ret < 0) | |
583 | bgp_clear_vty_error (vty, peer, afi, safi, ret); | |
584 | } | |
585 | if (! find) | |
586 | vty_out (vty, "%%BGP: No peer is configured with AS %s%s", arg, | |
587 | VTY_NEWLINE); | |
588 | return CMD_SUCCESS; | |
589 | } | |
590 | ||
591 | return CMD_SUCCESS; | |
592 | } | |
593 | ||
594 | static int | |
595 | bgp_clear_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi, | |
596 | enum clear_sort sort, enum bgp_clear_type stype, | |
597 | const char *arg) | |
598 | { | |
599 | struct bgp *bgp; | |
600 | ||
601 | /* BGP structure lookup. */ | |
602 | if (name) | |
603 | { | |
604 | bgp = bgp_lookup_by_name (name); | |
605 | if (bgp == NULL) | |
606 | { | |
6aeb9e78 | 607 | vty_out (vty, "Can't find BGP instance %s%s", name, VTY_NEWLINE); |
7aafcaca DS |
608 | return CMD_WARNING; |
609 | } | |
610 | } | |
611 | else | |
612 | { | |
f31fa004 | 613 | bgp = bgp_get_default (); |
7aafcaca DS |
614 | if (bgp == NULL) |
615 | { | |
616 | vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE); | |
617 | return CMD_WARNING; | |
618 | } | |
619 | } | |
620 | ||
621 | return bgp_clear (vty, bgp, afi, safi, sort, stype, arg); | |
622 | } | |
623 | ||
624 | /* clear soft inbound */ | |
625 | static void | |
f31fa004 | 626 | bgp_clear_star_soft_in (struct vty *vty, const char *name) |
7aafcaca | 627 | { |
b09b5ae0 | 628 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 629 | BGP_CLEAR_SOFT_IN, NULL); |
f31fa004 | 630 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 631 | BGP_CLEAR_SOFT_IN, NULL); |
7aafcaca DS |
632 | } |
633 | ||
634 | /* clear soft outbound */ | |
635 | static void | |
f31fa004 | 636 | bgp_clear_star_soft_out (struct vty *vty, const char *name) |
7aafcaca | 637 | { |
f31fa004 | 638 | bgp_clear_vty (vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
7aafcaca | 639 | BGP_CLEAR_SOFT_OUT, NULL); |
f31fa004 | 640 | bgp_clear_vty (vty, name, AFI_IP6, SAFI_UNICAST, clear_all, |
7aafcaca | 641 | BGP_CLEAR_SOFT_OUT, NULL); |
7aafcaca DS |
642 | } |
643 | ||
644 | ||
718e3744 | 645 | /* BGP global configuration. */ |
646 | ||
647 | DEFUN (bgp_multiple_instance_func, | |
648 | bgp_multiple_instance_cmd, | |
649 | "bgp multiple-instance", | |
650 | BGP_STR | |
651 | "Enable bgp multiple instance\n") | |
652 | { | |
653 | bgp_option_set (BGP_OPT_MULTIPLE_INSTANCE); | |
654 | return CMD_SUCCESS; | |
655 | } | |
656 | ||
657 | DEFUN (no_bgp_multiple_instance, | |
658 | no_bgp_multiple_instance_cmd, | |
659 | "no bgp multiple-instance", | |
660 | NO_STR | |
661 | BGP_STR | |
662 | "BGP multiple instance\n") | |
663 | { | |
664 | int ret; | |
665 | ||
666 | ret = bgp_option_unset (BGP_OPT_MULTIPLE_INSTANCE); | |
667 | if (ret < 0) | |
668 | { | |
669 | vty_out (vty, "%% There are more than two BGP instances%s", VTY_NEWLINE); | |
670 | return CMD_WARNING; | |
671 | } | |
672 | return CMD_SUCCESS; | |
673 | } | |
674 | ||
675 | DEFUN (bgp_config_type, | |
676 | bgp_config_type_cmd, | |
6147e2c6 | 677 | "bgp config-type <cisco|zebra>", |
718e3744 | 678 | BGP_STR |
679 | "Configuration type\n" | |
680 | "cisco\n" | |
681 | "zebra\n") | |
682 | { | |
c500ae40 DW |
683 | int idx_vendor = 2; |
684 | if (strncmp (argv[idx_vendor]->arg, "c", 1) == 0) | |
718e3744 | 685 | bgp_option_set (BGP_OPT_CONFIG_CISCO); |
686 | else | |
687 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
688 | ||
689 | return CMD_SUCCESS; | |
690 | } | |
691 | ||
692 | DEFUN (no_bgp_config_type, | |
693 | no_bgp_config_type_cmd, | |
c7178fe7 | 694 | "no bgp config-type [<cisco|zebra>]", |
718e3744 | 695 | NO_STR |
696 | BGP_STR | |
838758ac DW |
697 | "Display configuration type\n" |
698 | "cisco\n" | |
699 | "zebra\n") | |
718e3744 | 700 | { |
701 | bgp_option_unset (BGP_OPT_CONFIG_CISCO); | |
702 | return CMD_SUCCESS; | |
703 | } | |
704 | ||
813d4307 | 705 | |
718e3744 | 706 | DEFUN (no_synchronization, |
707 | no_synchronization_cmd, | |
708 | "no synchronization", | |
709 | NO_STR | |
710 | "Perform IGP synchronization\n") | |
711 | { | |
712 | return CMD_SUCCESS; | |
713 | } | |
714 | ||
715 | DEFUN (no_auto_summary, | |
716 | no_auto_summary_cmd, | |
717 | "no auto-summary", | |
718 | NO_STR | |
719 | "Enable automatic network number summarization\n") | |
720 | { | |
721 | return CMD_SUCCESS; | |
722 | } | |
3d515fd9 | 723 | |
718e3744 | 724 | /* "router bgp" commands. */ |
f412b39a DW |
725 | DEFUN (router_bgp, |
726 | router_bgp_cmd, | |
31500417 | 727 | "router bgp [(1-4294967295) [<view|vrf> WORD]]", |
718e3744 | 728 | ROUTER_STR |
729 | BGP_STR | |
31500417 DW |
730 | AS_STR |
731 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 732 | { |
31500417 DW |
733 | int idx_asn = 2; |
734 | int idx_view_vrf = 3; | |
735 | int idx_vrf = 4; | |
718e3744 | 736 | int ret; |
737 | as_t as; | |
738 | struct bgp *bgp; | |
fd79ac91 | 739 | const char *name = NULL; |
ad4cbda1 | 740 | enum bgp_instance_type inst_type; |
718e3744 | 741 | |
2385a876 | 742 | // "router bgp" without an ASN |
31500417 | 743 | if (argc == 2) |
2385a876 | 744 | { |
6aeb9e78 | 745 | //Pending: Make VRF option available for ASN less config |
2385a876 | 746 | bgp = bgp_get_default(); |
718e3744 | 747 | |
2385a876 DW |
748 | if (bgp == NULL) |
749 | { | |
750 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
751 | return CMD_WARNING; | |
752 | } | |
718e3744 | 753 | |
2385a876 DW |
754 | if (listcount(bm->bgp) > 1) |
755 | { | |
756 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
757 | return CMD_WARNING; | |
758 | } | |
759 | } | |
760 | ||
761 | // "router bgp X" | |
762 | else | |
718e3744 | 763 | { |
31500417 | 764 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
2385a876 | 765 | |
ad4cbda1 | 766 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; |
31500417 | 767 | if (argc > 3) |
ad4cbda1 | 768 | { |
31500417 DW |
769 | name = argv[idx_vrf]->arg; |
770 | ||
e52702f2 | 771 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) |
ad4cbda1 | 772 | inst_type = BGP_INSTANCE_TYPE_VRF; |
e52702f2 | 773 | else if (!strcmp(argv[idx_view_vrf]->text, "view")) |
ad4cbda1 | 774 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
775 | } | |
2385a876 | 776 | |
ad4cbda1 | 777 | ret = bgp_get (&bgp, &as, name, inst_type); |
2385a876 DW |
778 | switch (ret) |
779 | { | |
780 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
781 | vty_out (vty, "Please specify 'bgp multiple-instance' first%s", | |
782 | VTY_NEWLINE); | |
783 | return CMD_WARNING; | |
784 | case BGP_ERR_AS_MISMATCH: | |
785 | vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE); | |
786 | return CMD_WARNING; | |
787 | case BGP_ERR_INSTANCE_MISMATCH: | |
6aeb9e78 | 788 | vty_out (vty, "BGP instance name and AS number mismatch%s", VTY_NEWLINE); |
2385a876 DW |
789 | vty_out (vty, "BGP instance is already running; AS is %u%s", |
790 | as, VTY_NEWLINE); | |
791 | return CMD_WARNING; | |
792 | } | |
6aeb9e78 DS |
793 | |
794 | /* Pending: handle when user tries to change a view to vrf n vv. */ | |
718e3744 | 795 | } |
796 | ||
cdc2d765 | 797 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
718e3744 | 798 | |
799 | return CMD_SUCCESS; | |
800 | } | |
801 | ||
718e3744 | 802 | /* "no router bgp" commands. */ |
803 | DEFUN (no_router_bgp, | |
804 | no_router_bgp_cmd, | |
31500417 | 805 | "no router bgp [(1-4294967295) [<view|vrf> WORD]]", |
718e3744 | 806 | NO_STR |
807 | ROUTER_STR | |
808 | BGP_STR | |
31500417 DW |
809 | AS_STR |
810 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 811 | { |
31500417 | 812 | int idx_asn = 3; |
31500417 | 813 | int idx_vrf = 5; |
718e3744 | 814 | as_t as; |
815 | struct bgp *bgp; | |
fd79ac91 | 816 | const char *name = NULL; |
718e3744 | 817 | |
7fb21a9f | 818 | // "no router bgp" without an ASN |
31500417 | 819 | if (argc == 3) |
7fb21a9f QY |
820 | { |
821 | //Pending: Make VRF option available for ASN less config | |
822 | bgp = bgp_get_default(); | |
718e3744 | 823 | |
7fb21a9f QY |
824 | if (bgp == NULL) |
825 | { | |
826 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
827 | return CMD_WARNING; | |
828 | } | |
829 | ||
830 | if (listcount(bm->bgp) > 1) | |
831 | { | |
832 | vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); | |
833 | return CMD_WARNING; | |
834 | } | |
835 | } | |
836 | else | |
718e3744 | 837 | { |
31500417 | 838 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_asn]->arg, 1, BGP_AS4_MAX); |
7fb21a9f | 839 | |
31500417 DW |
840 | if (argc > 4) |
841 | name = argv[idx_vrf]->arg; | |
7fb21a9f QY |
842 | |
843 | /* Lookup bgp structure. */ | |
844 | bgp = bgp_lookup (as, name); | |
845 | if (! bgp) | |
846 | { | |
847 | vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE); | |
848 | return CMD_WARNING; | |
849 | } | |
718e3744 | 850 | } |
851 | ||
852 | bgp_delete (bgp); | |
853 | ||
854 | return CMD_SUCCESS; | |
855 | } | |
856 | ||
6b0655a2 | 857 | |
7fb21a9f | 858 | |
718e3744 | 859 | /* BGP router-id. */ |
860 | ||
861 | DEFUN (bgp_router_id, | |
862 | bgp_router_id_cmd, | |
863 | "bgp router-id A.B.C.D", | |
864 | BGP_STR | |
865 | "Override configured router identifier\n" | |
866 | "Manually configured router identifier\n") | |
867 | { | |
cdc2d765 | 868 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 869 | int idx_ipv4 = 2; |
718e3744 | 870 | int ret; |
871 | struct in_addr id; | |
718e3744 | 872 | |
c500ae40 | 873 | ret = inet_aton (argv[idx_ipv4]->arg, &id); |
718e3744 | 874 | if (! ret) |
875 | { | |
876 | vty_out (vty, "%% Malformed bgp router identifier%s", VTY_NEWLINE); | |
877 | return CMD_WARNING; | |
878 | } | |
879 | ||
0e6cb743 | 880 | bgp_router_id_static_set (bgp, id); |
718e3744 | 881 | |
882 | return CMD_SUCCESS; | |
883 | } | |
884 | ||
885 | DEFUN (no_bgp_router_id, | |
886 | no_bgp_router_id_cmd, | |
31500417 | 887 | "no bgp router-id [A.B.C.D]", |
718e3744 | 888 | NO_STR |
889 | BGP_STR | |
31500417 DW |
890 | "Override configured router identifier\n" |
891 | "Manually configured router identifier\n") | |
718e3744 | 892 | { |
cdc2d765 | 893 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
31500417 | 894 | int idx_router_id = 3; |
718e3744 | 895 | int ret; |
896 | struct in_addr id; | |
718e3744 | 897 | |
31500417 | 898 | if (argc > idx_router_id) |
718e3744 | 899 | { |
31500417 | 900 | ret = inet_aton (argv[idx_router_id]->arg, &id); |
718e3744 | 901 | if (! ret) |
e018c7cc SK |
902 | { |
903 | vty_out (vty, "%% Malformed BGP router identifier%s", VTY_NEWLINE); | |
904 | return CMD_WARNING; | |
905 | } | |
718e3744 | 906 | |
18a6dce6 | 907 | if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id)) |
e018c7cc SK |
908 | { |
909 | vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE); | |
910 | return CMD_WARNING; | |
911 | } | |
718e3744 | 912 | } |
913 | ||
0e6cb743 DL |
914 | id.s_addr = 0; |
915 | bgp_router_id_static_set (bgp, id); | |
718e3744 | 916 | |
917 | return CMD_SUCCESS; | |
918 | } | |
919 | ||
6b0655a2 | 920 | |
718e3744 | 921 | /* BGP Cluster ID. */ |
718e3744 | 922 | DEFUN (bgp_cluster_id, |
923 | bgp_cluster_id_cmd, | |
838758ac | 924 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 925 | BGP_STR |
926 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
927 | "Route-Reflector Cluster-id in IP address format\n" |
928 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 929 | { |
cdc2d765 | 930 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 931 | int idx_ipv4 = 2; |
718e3744 | 932 | int ret; |
718e3744 | 933 | struct in_addr cluster; |
934 | ||
c500ae40 | 935 | ret = inet_aton (argv[idx_ipv4]->arg, &cluster); |
718e3744 | 936 | if (! ret) |
937 | { | |
938 | vty_out (vty, "%% Malformed bgp cluster identifier%s", VTY_NEWLINE); | |
939 | return CMD_WARNING; | |
940 | } | |
941 | ||
942 | bgp_cluster_id_set (bgp, &cluster); | |
f31fa004 | 943 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 944 | |
945 | return CMD_SUCCESS; | |
946 | } | |
947 | ||
718e3744 | 948 | DEFUN (no_bgp_cluster_id, |
949 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 950 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 951 | NO_STR |
952 | BGP_STR | |
838758ac DW |
953 | "Configure Route-Reflector Cluster-id\n" |
954 | "Route-Reflector Cluster-id in IP address format\n" | |
955 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 956 | { |
cdc2d765 | 957 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 958 | bgp_cluster_id_unset (bgp); |
f31fa004 | 959 | bgp_clear_star_soft_out (vty, bgp->name); |
718e3744 | 960 | |
961 | return CMD_SUCCESS; | |
962 | } | |
963 | ||
718e3744 | 964 | DEFUN (bgp_confederation_identifier, |
965 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 966 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 967 | "BGP specific commands\n" |
968 | "AS confederation parameters\n" | |
969 | "AS number\n" | |
970 | "Set routing domain confederation AS\n") | |
971 | { | |
cdc2d765 | 972 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 973 | int idx_number = 3; |
718e3744 | 974 | as_t as; |
975 | ||
c500ae40 | 976 | VTY_GET_INTEGER_RANGE ("AS", as, argv[idx_number]->arg, 1, BGP_AS4_MAX); |
718e3744 | 977 | |
978 | bgp_confederation_id_set (bgp, as); | |
979 | ||
980 | return CMD_SUCCESS; | |
981 | } | |
982 | ||
983 | DEFUN (no_bgp_confederation_identifier, | |
984 | no_bgp_confederation_identifier_cmd, | |
838758ac | 985 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 986 | NO_STR |
987 | "BGP specific commands\n" | |
988 | "AS confederation parameters\n" | |
3a2d747c QY |
989 | "AS number\n" |
990 | "Set routing domain confederation AS\n") | |
718e3744 | 991 | { |
cdc2d765 | 992 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 993 | bgp_confederation_id_unset (bgp); |
994 | ||
995 | return CMD_SUCCESS; | |
996 | } | |
997 | ||
718e3744 | 998 | DEFUN (bgp_confederation_peers, |
999 | bgp_confederation_peers_cmd, | |
12dcf78e | 1000 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1001 | "BGP specific commands\n" |
1002 | "AS confederation parameters\n" | |
1003 | "Peer ASs in BGP confederation\n" | |
1004 | AS_STR) | |
1005 | { | |
cdc2d765 | 1006 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
58749582 | 1007 | int idx_asn = 3; |
718e3744 | 1008 | as_t as; |
1009 | int i; | |
1010 | ||
58749582 | 1011 | for (i = idx_asn; i < argc; i++) |
718e3744 | 1012 | { |
afec25d9 | 1013 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
718e3744 | 1014 | |
1015 | if (bgp->as == as) | |
1016 | { | |
1017 | vty_out (vty, "%% Local member-AS not allowed in confed peer list%s", | |
1018 | VTY_NEWLINE); | |
1019 | continue; | |
1020 | } | |
1021 | ||
1022 | bgp_confederation_peers_add (bgp, as); | |
1023 | } | |
1024 | return CMD_SUCCESS; | |
1025 | } | |
1026 | ||
1027 | DEFUN (no_bgp_confederation_peers, | |
1028 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1029 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1030 | NO_STR |
1031 | "BGP specific commands\n" | |
1032 | "AS confederation parameters\n" | |
1033 | "Peer ASs in BGP confederation\n" | |
1034 | AS_STR) | |
1035 | { | |
cdc2d765 | 1036 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
58749582 | 1037 | int idx_asn = 4; |
718e3744 | 1038 | as_t as; |
1039 | int i; | |
1040 | ||
58749582 | 1041 | for (i = idx_asn; i < argc; i++) |
718e3744 | 1042 | { |
afec25d9 | 1043 | VTY_GET_INTEGER_RANGE ("AS", as, argv[i]->arg, 1, BGP_AS4_MAX); |
0b2aa3a0 | 1044 | |
718e3744 | 1045 | bgp_confederation_peers_remove (bgp, as); |
1046 | } | |
1047 | return CMD_SUCCESS; | |
1048 | } | |
6b0655a2 | 1049 | |
5e242b0d DS |
1050 | /** |
1051 | * Central routine for maximum-paths configuration. | |
1052 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1053 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1054 | */ | |
ffd0c037 DS |
1055 | static int |
1056 | bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths, | |
5e242b0d | 1057 | u_int16_t options, int set) |
165b5fff | 1058 | { |
cdc2d765 | 1059 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4c9dee98 | 1060 | u_int16_t maxpaths = 0; |
165b5fff | 1061 | int ret; |
5e242b0d DS |
1062 | afi_t afi; |
1063 | safi_t safi; | |
165b5fff | 1064 | |
5e242b0d DS |
1065 | afi = bgp_node_afi (vty); |
1066 | safi = bgp_node_safi (vty); | |
165b5fff | 1067 | |
5e242b0d | 1068 | if (set) |
4c9dee98 | 1069 | { |
c59f2066 | 1070 | maxpaths = strtol(mpaths, NULL, 10); |
dff6764a | 1071 | ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths, options); |
4c9dee98 | 1072 | } |
5e242b0d DS |
1073 | else |
1074 | ret = bgp_maximum_paths_unset (bgp, afi, safi, peer_type); | |
165b5fff | 1075 | |
165b5fff JB |
1076 | if (ret < 0) |
1077 | { | |
1078 | vty_out (vty, | |
5e242b0d DS |
1079 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u%s", |
1080 | (set == 1) ? "" : "un", | |
1081 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1082 | maxpaths, afi, safi, VTY_NEWLINE); | |
165b5fff JB |
1083 | return CMD_WARNING; |
1084 | } | |
1085 | ||
7aafcaca DS |
1086 | bgp_recalculate_all_bestpaths (bgp); |
1087 | ||
165b5fff JB |
1088 | return CMD_SUCCESS; |
1089 | } | |
1090 | ||
abc920f8 DS |
1091 | DEFUN (bgp_maxmed_admin, |
1092 | bgp_maxmed_admin_cmd, | |
1093 | "bgp max-med administrative ", | |
1094 | BGP_STR | |
1095 | "Advertise routes with max-med\n" | |
1096 | "Administratively applied, for an indefinite period\n") | |
1097 | { | |
cdc2d765 | 1098 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1099 | |
1100 | bgp->v_maxmed_admin = 1; | |
1101 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1102 | ||
1103 | bgp_maxmed_update(bgp); | |
1104 | ||
1105 | return CMD_SUCCESS; | |
1106 | } | |
1107 | ||
1108 | DEFUN (bgp_maxmed_admin_medv, | |
1109 | bgp_maxmed_admin_medv_cmd, | |
6147e2c6 | 1110 | "bgp max-med administrative (0-4294967294)", |
abc920f8 DS |
1111 | BGP_STR |
1112 | "Advertise routes with max-med\n" | |
1113 | "Administratively applied, for an indefinite period\n" | |
1114 | "Max MED value to be used\n") | |
1115 | { | |
cdc2d765 | 1116 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1117 | int idx_number = 3; |
abc920f8 DS |
1118 | |
1119 | bgp->v_maxmed_admin = 1; | |
c500ae40 | 1120 | VTY_GET_INTEGER ("max-med admin med-value", bgp->maxmed_admin_value, argv[idx_number]->arg); |
abc920f8 DS |
1121 | |
1122 | bgp_maxmed_update(bgp); | |
1123 | ||
1124 | return CMD_SUCCESS; | |
1125 | } | |
1126 | ||
1127 | DEFUN (no_bgp_maxmed_admin, | |
1128 | no_bgp_maxmed_admin_cmd, | |
8334fd5a | 1129 | "no bgp max-med administrative [(0-4294967294)]", |
abc920f8 DS |
1130 | NO_STR |
1131 | BGP_STR | |
1132 | "Advertise routes with max-med\n" | |
838758ac DW |
1133 | "Administratively applied, for an indefinite period\n" |
1134 | "Max MED value to be used\n") | |
abc920f8 | 1135 | { |
cdc2d765 | 1136 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1137 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; |
1138 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 DS |
1139 | bgp_maxmed_update(bgp); |
1140 | ||
1141 | return CMD_SUCCESS; | |
1142 | } | |
1143 | ||
abc920f8 DS |
1144 | DEFUN (bgp_maxmed_onstartup, |
1145 | bgp_maxmed_onstartup_cmd, | |
6147e2c6 | 1146 | "bgp max-med on-startup (5-86400)", |
abc920f8 DS |
1147 | BGP_STR |
1148 | "Advertise routes with max-med\n" | |
1149 | "Effective on a startup\n" | |
1150 | "Time (seconds) period for max-med\n") | |
1151 | { | |
cdc2d765 | 1152 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1153 | int idx_number = 3; |
c500ae40 | 1154 | VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); |
abc920f8 | 1155 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; |
abc920f8 DS |
1156 | bgp_maxmed_update(bgp); |
1157 | ||
1158 | return CMD_SUCCESS; | |
1159 | } | |
1160 | ||
1161 | DEFUN (bgp_maxmed_onstartup_medv, | |
1162 | bgp_maxmed_onstartup_medv_cmd, | |
6147e2c6 | 1163 | "bgp max-med on-startup (5-86400) (0-4294967294)", |
abc920f8 DS |
1164 | BGP_STR |
1165 | "Advertise routes with max-med\n" | |
1166 | "Effective on a startup\n" | |
1167 | "Time (seconds) period for max-med\n" | |
1168 | "Max MED value to be used\n") | |
1169 | { | |
cdc2d765 | 1170 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
1171 | int idx_number = 3; |
1172 | int idx_number_2 = 4; | |
c500ae40 DW |
1173 | VTY_GET_INTEGER ("max-med on-startup period", bgp->v_maxmed_onstartup, argv[idx_number]->arg); |
1174 | VTY_GET_INTEGER ("max-med on-startup med-value", bgp->maxmed_onstartup_value, argv[idx_number_2]->arg); | |
abc920f8 DS |
1175 | bgp_maxmed_update(bgp); |
1176 | ||
1177 | return CMD_SUCCESS; | |
1178 | } | |
1179 | ||
1180 | DEFUN (no_bgp_maxmed_onstartup, | |
1181 | no_bgp_maxmed_onstartup_cmd, | |
8334fd5a | 1182 | "no bgp max-med on-startup [(5-86400) [(0-4294967294)]]", |
abc920f8 DS |
1183 | NO_STR |
1184 | BGP_STR | |
1185 | "Advertise routes with max-med\n" | |
838758ac DW |
1186 | "Effective on a startup\n" |
1187 | "Time (seconds) period for max-med\n" | |
1188 | "Max MED value to be used\n") | |
abc920f8 | 1189 | { |
cdc2d765 | 1190 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 DS |
1191 | |
1192 | /* Cancel max-med onstartup if its on */ | |
1193 | if (bgp->t_maxmed_onstartup) | |
1194 | { | |
1195 | THREAD_TIMER_OFF (bgp->t_maxmed_onstartup); | |
1196 | bgp->maxmed_onstartup_over = 1; | |
1197 | } | |
1198 | ||
1199 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; | |
1200 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
1201 | ||
1202 | bgp_maxmed_update(bgp); | |
1203 | ||
1204 | return CMD_SUCCESS; | |
1205 | } | |
1206 | ||
f188f2c4 DS |
1207 | static int |
1208 | bgp_update_delay_config_vty (struct vty *vty, const char *delay, | |
1209 | const char *wait) | |
1210 | { | |
cdc2d765 | 1211 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 DS |
1212 | u_int16_t update_delay; |
1213 | u_int16_t establish_wait; | |
1214 | ||
f188f2c4 DS |
1215 | VTY_GET_INTEGER_RANGE ("update-delay", update_delay, delay, |
1216 | BGP_UPDATE_DELAY_MIN, BGP_UPDATE_DELAY_MAX); | |
1217 | ||
1218 | if (!wait) /* update-delay <delay> */ | |
1219 | { | |
1220 | bgp->v_update_delay = update_delay; | |
1221 | bgp->v_establish_wait = bgp->v_update_delay; | |
1222 | return CMD_SUCCESS; | |
1223 | } | |
1224 | ||
1225 | /* update-delay <delay> <establish-wait> */ | |
1226 | establish_wait = atoi (wait); | |
1227 | if (update_delay < establish_wait) | |
1228 | { | |
1229 | vty_out (vty, "%%Failed: update-delay less than the establish-wait!%s", | |
1230 | VTY_NEWLINE); | |
1231 | return CMD_WARNING; | |
1232 | } | |
1233 | ||
1234 | bgp->v_update_delay = update_delay; | |
1235 | bgp->v_establish_wait = establish_wait; | |
1236 | ||
1237 | return CMD_SUCCESS; | |
1238 | } | |
1239 | ||
1240 | static int | |
1241 | bgp_update_delay_deconfig_vty (struct vty *vty) | |
1242 | { | |
cdc2d765 | 1243 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 DS |
1244 | |
1245 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; | |
1246 | bgp->v_establish_wait = bgp->v_update_delay; | |
1247 | ||
1248 | return CMD_SUCCESS; | |
1249 | } | |
1250 | ||
1251 | int | |
1252 | bgp_config_write_update_delay (struct vty *vty, struct bgp *bgp) | |
1253 | { | |
1254 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) | |
1255 | { | |
1256 | vty_out (vty, " update-delay %d", bgp->v_update_delay); | |
1257 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1258 | vty_out (vty, " %d", bgp->v_establish_wait); | |
1259 | vty_out (vty, "%s", VTY_NEWLINE); | |
1260 | } | |
1261 | ||
1262 | return 0; | |
1263 | } | |
1264 | ||
1265 | ||
1266 | /* Update-delay configuration */ | |
1267 | DEFUN (bgp_update_delay, | |
1268 | bgp_update_delay_cmd, | |
6147e2c6 | 1269 | "update-delay (0-3600)", |
f188f2c4 DS |
1270 | "Force initial delay for best-path and updates\n" |
1271 | "Seconds\n") | |
1272 | { | |
c500ae40 DW |
1273 | int idx_number = 1; |
1274 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1275 | } |
1276 | ||
1277 | DEFUN (bgp_update_delay_establish_wait, | |
1278 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1279 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1280 | "Force initial delay for best-path and updates\n" |
1281 | "Seconds\n" | |
1282 | "Wait for peers to be established\n" | |
1283 | "Seconds\n") | |
1284 | { | |
c500ae40 DW |
1285 | int idx_number = 1; |
1286 | int idx_number_2 = 2; | |
1287 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
f188f2c4 DS |
1288 | } |
1289 | ||
1290 | /* Update-delay deconfiguration */ | |
1291 | DEFUN (no_bgp_update_delay, | |
1292 | no_bgp_update_delay_cmd, | |
838758ac DW |
1293 | "no update-delay [(0-3600) [(1-3600)]]", |
1294 | NO_STR | |
f188f2c4 | 1295 | "Force initial delay for best-path and updates\n" |
838758ac DW |
1296 | "Seconds\n" |
1297 | "Wait for peers to be established\n") | |
f188f2c4 DS |
1298 | { |
1299 | return bgp_update_delay_deconfig_vty(vty); | |
1300 | } | |
1301 | ||
5e242b0d | 1302 | |
ffd0c037 DS |
1303 | static int |
1304 | bgp_wpkt_quanta_config_vty (struct vty *vty, const char *num, char set) | |
cb1faec9 | 1305 | { |
cdc2d765 | 1306 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 DS |
1307 | |
1308 | if (set) | |
1309 | VTY_GET_INTEGER_RANGE ("write-quanta", bgp->wpkt_quanta, num, | |
4543bbb4 | 1310 | 1, 10000); |
cb1faec9 DS |
1311 | else |
1312 | bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX; | |
1313 | ||
1314 | return CMD_SUCCESS; | |
1315 | } | |
1316 | ||
1317 | int | |
1318 | bgp_config_write_wpkt_quanta (struct vty *vty, struct bgp *bgp) | |
1319 | { | |
1320 | if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX) | |
1321 | vty_out (vty, " write-quanta %d%s", | |
1322 | bgp->wpkt_quanta, VTY_NEWLINE); | |
1323 | ||
1324 | return 0; | |
1325 | } | |
1326 | ||
1327 | ||
1328 | /* Update-delay configuration */ | |
1329 | DEFUN (bgp_wpkt_quanta, | |
1330 | bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1331 | "write-quanta (1-10000)", |
cb1faec9 DS |
1332 | "How many packets to write to peer socket per run\n" |
1333 | "Number of packets\n") | |
1334 | { | |
c500ae40 DW |
1335 | int idx_number = 1; |
1336 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1337 | } |
1338 | ||
1339 | /* Update-delay deconfiguration */ | |
1340 | DEFUN (no_bgp_wpkt_quanta, | |
1341 | no_bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1342 | "no write-quanta (1-10000)", |
d7fa34c1 | 1343 | NO_STR |
cb1faec9 DS |
1344 | "How many packets to write to peer socket per run\n" |
1345 | "Number of packets\n") | |
1346 | { | |
c500ae40 DW |
1347 | int idx_number = 2; |
1348 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1349 | } |
1350 | ||
ffd0c037 | 1351 | static int |
3f9c7369 DS |
1352 | bgp_coalesce_config_vty (struct vty *vty, const char *num, char set) |
1353 | { | |
cdc2d765 | 1354 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3f9c7369 DS |
1355 | |
1356 | if (set) | |
1357 | VTY_GET_INTEGER_RANGE ("coalesce-time", bgp->coalesce_time, num, | |
1358 | 0, 4294967295); | |
1359 | else | |
1360 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; | |
1361 | ||
1362 | return CMD_SUCCESS; | |
1363 | } | |
1364 | ||
1365 | int | |
1366 | bgp_config_write_coalesce_time (struct vty *vty, struct bgp *bgp) | |
1367 | { | |
1368 | if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME) | |
1369 | vty_out (vty, " coalesce-time %d%s", | |
1370 | bgp->coalesce_time, VTY_NEWLINE); | |
1371 | ||
1372 | return 0; | |
1373 | } | |
1374 | ||
1375 | ||
1376 | DEFUN (bgp_coalesce_time, | |
1377 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1378 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1379 | "Subgroup coalesce timer\n" |
1380 | "Subgroup coalesce timer value (in ms)\n") | |
1381 | { | |
c500ae40 DW |
1382 | int idx_number = 1; |
1383 | return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 1); | |
3f9c7369 DS |
1384 | } |
1385 | ||
1386 | DEFUN (no_bgp_coalesce_time, | |
1387 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1388 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1389 | NO_STR |
3f9c7369 DS |
1390 | "Subgroup coalesce timer\n" |
1391 | "Subgroup coalesce timer value (in ms)\n") | |
1392 | { | |
c500ae40 DW |
1393 | int idx_number = 2; |
1394 | return bgp_coalesce_config_vty(vty, argv[idx_number]->arg, 0); | |
3f9c7369 DS |
1395 | } |
1396 | ||
5e242b0d DS |
1397 | /* Maximum-paths configuration */ |
1398 | DEFUN (bgp_maxpaths, | |
1399 | bgp_maxpaths_cmd, | |
9ccf14f7 | 1400 | "maximum-paths (1-255)", |
5e242b0d DS |
1401 | "Forward packets over multiple paths\n" |
1402 | "Number of paths\n") | |
1403 | { | |
c500ae40 DW |
1404 | int idx_number = 1; |
1405 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1406 | } |
1407 | ||
165b5fff JB |
1408 | DEFUN (bgp_maxpaths_ibgp, |
1409 | bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1410 | "maximum-paths ibgp (1-255)", |
165b5fff JB |
1411 | "Forward packets over multiple paths\n" |
1412 | "iBGP-multipath\n" | |
1413 | "Number of paths\n") | |
1414 | { | |
c500ae40 DW |
1415 | int idx_number = 2; |
1416 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1417 | } |
165b5fff | 1418 | |
5e242b0d DS |
1419 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1420 | bgp_maxpaths_ibgp_cluster_cmd, | |
9ccf14f7 | 1421 | "maximum-paths ibgp (1-255) equal-cluster-length", |
5e242b0d DS |
1422 | "Forward packets over multiple paths\n" |
1423 | "iBGP-multipath\n" | |
1424 | "Number of paths\n" | |
1425 | "Match the cluster length\n") | |
1426 | { | |
c500ae40 DW |
1427 | int idx_number = 2; |
1428 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
5e242b0d | 1429 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); |
165b5fff JB |
1430 | } |
1431 | ||
1432 | DEFUN (no_bgp_maxpaths, | |
1433 | no_bgp_maxpaths_cmd, | |
9ccf14f7 | 1434 | "no maximum-paths [(1-255)]", |
165b5fff JB |
1435 | NO_STR |
1436 | "Forward packets over multiple paths\n" | |
1437 | "Number of paths\n") | |
1438 | { | |
5e242b0d | 1439 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1440 | } |
1441 | ||
165b5fff JB |
1442 | DEFUN (no_bgp_maxpaths_ibgp, |
1443 | no_bgp_maxpaths_ibgp_cmd, | |
9ccf14f7 | 1444 | "no maximum-paths ibgp [(1-255) [equal-cluster-length]]", |
165b5fff JB |
1445 | NO_STR |
1446 | "Forward packets over multiple paths\n" | |
1447 | "iBGP-multipath\n" | |
838758ac DW |
1448 | "Number of paths\n" |
1449 | "Match the cluster length\n") | |
165b5fff | 1450 | { |
5e242b0d | 1451 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1452 | } |
1453 | ||
165b5fff JB |
1454 | int |
1455 | bgp_config_write_maxpaths (struct vty *vty, struct bgp *bgp, afi_t afi, | |
1456 | safi_t safi, int *write) | |
1457 | { | |
d5b77cc2 | 1458 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) |
165b5fff JB |
1459 | { |
1460 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1461 | vty_out (vty, " maximum-paths %d%s", |
165b5fff JB |
1462 | bgp->maxpaths[afi][safi].maxpaths_ebgp, VTY_NEWLINE); |
1463 | } | |
1464 | ||
d5b77cc2 | 1465 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) |
165b5fff JB |
1466 | { |
1467 | bgp_config_write_family_header (vty, afi, safi, write); | |
0b960b4d | 1468 | vty_out (vty, " maximum-paths ibgp %d", |
5e242b0d DS |
1469 | bgp->maxpaths[afi][safi].maxpaths_ibgp); |
1470 | if (CHECK_FLAG (bgp->maxpaths[afi][safi].ibgp_flags, | |
1471 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1472 | vty_out (vty, " equal-cluster-length"); | |
1473 | vty_out (vty, "%s", VTY_NEWLINE); | |
165b5fff JB |
1474 | } |
1475 | ||
1476 | return 0; | |
1477 | } | |
6b0655a2 | 1478 | |
718e3744 | 1479 | /* BGP timers. */ |
1480 | ||
1481 | DEFUN (bgp_timers, | |
1482 | bgp_timers_cmd, | |
6147e2c6 | 1483 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1484 | "Adjust routing timers\n" |
1485 | "BGP timers\n" | |
1486 | "Keepalive interval\n" | |
1487 | "Holdtime\n") | |
1488 | { | |
cdc2d765 | 1489 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
1490 | int idx_number = 2; |
1491 | int idx_number_2 = 3; | |
718e3744 | 1492 | unsigned long keepalive = 0; |
1493 | unsigned long holdtime = 0; | |
1494 | ||
c500ae40 DW |
1495 | VTY_GET_INTEGER ("keepalive", keepalive, argv[idx_number]->arg); |
1496 | VTY_GET_INTEGER ("holdtime", holdtime, argv[idx_number_2]->arg); | |
718e3744 | 1497 | |
1498 | /* Holdtime value check. */ | |
1499 | if (holdtime < 3 && holdtime != 0) | |
1500 | { | |
1501 | vty_out (vty, "%% hold time value must be either 0 or greater than 3%s", | |
1502 | VTY_NEWLINE); | |
1503 | return CMD_WARNING; | |
1504 | } | |
1505 | ||
1506 | bgp_timers_set (bgp, keepalive, holdtime); | |
1507 | ||
1508 | return CMD_SUCCESS; | |
1509 | } | |
1510 | ||
1511 | DEFUN (no_bgp_timers, | |
1512 | no_bgp_timers_cmd, | |
838758ac | 1513 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1514 | NO_STR |
1515 | "Adjust routing timers\n" | |
838758ac DW |
1516 | "BGP timers\n" |
1517 | "Keepalive interval\n" | |
1518 | "Holdtime\n") | |
718e3744 | 1519 | { |
cdc2d765 | 1520 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1521 | bgp_timers_unset (bgp); |
1522 | ||
1523 | return CMD_SUCCESS; | |
1524 | } | |
1525 | ||
6b0655a2 | 1526 | |
718e3744 | 1527 | DEFUN (bgp_client_to_client_reflection, |
1528 | bgp_client_to_client_reflection_cmd, | |
1529 | "bgp client-to-client reflection", | |
1530 | "BGP specific commands\n" | |
1531 | "Configure client to client route reflection\n" | |
1532 | "reflection of routes allowed\n") | |
1533 | { | |
cdc2d765 | 1534 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1535 | bgp_flag_unset (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
f31fa004 | 1536 | bgp_clear_star_soft_out (vty, bgp->name); |
7aafcaca | 1537 | |
718e3744 | 1538 | return CMD_SUCCESS; |
1539 | } | |
1540 | ||
1541 | DEFUN (no_bgp_client_to_client_reflection, | |
1542 | no_bgp_client_to_client_reflection_cmd, | |
1543 | "no bgp client-to-client reflection", | |
1544 | NO_STR | |
1545 | "BGP specific commands\n" | |
1546 | "Configure client to client route reflection\n" | |
1547 | "reflection of routes allowed\n") | |
1548 | { | |
cdc2d765 | 1549 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1550 | bgp_flag_set (bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); |
f31fa004 | 1551 | bgp_clear_star_soft_out (vty, bgp->name); |
7aafcaca | 1552 | |
718e3744 | 1553 | return CMD_SUCCESS; |
1554 | } | |
1555 | ||
1556 | /* "bgp always-compare-med" configuration. */ | |
1557 | DEFUN (bgp_always_compare_med, | |
1558 | bgp_always_compare_med_cmd, | |
1559 | "bgp always-compare-med", | |
1560 | "BGP specific commands\n" | |
1561 | "Allow comparing MED from different neighbors\n") | |
1562 | { | |
cdc2d765 | 1563 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1564 | bgp_flag_set (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); |
7aafcaca DS |
1565 | bgp_recalculate_all_bestpaths (bgp); |
1566 | ||
718e3744 | 1567 | return CMD_SUCCESS; |
1568 | } | |
1569 | ||
1570 | DEFUN (no_bgp_always_compare_med, | |
1571 | no_bgp_always_compare_med_cmd, | |
1572 | "no bgp always-compare-med", | |
1573 | NO_STR | |
1574 | "BGP specific commands\n" | |
1575 | "Allow comparing MED from different neighbors\n") | |
1576 | { | |
cdc2d765 | 1577 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1578 | bgp_flag_unset (bgp, BGP_FLAG_ALWAYS_COMPARE_MED); |
7aafcaca DS |
1579 | bgp_recalculate_all_bestpaths (bgp); |
1580 | ||
718e3744 | 1581 | return CMD_SUCCESS; |
1582 | } | |
6b0655a2 | 1583 | |
718e3744 | 1584 | /* "bgp deterministic-med" configuration. */ |
1585 | DEFUN (bgp_deterministic_med, | |
1586 | bgp_deterministic_med_cmd, | |
1587 | "bgp deterministic-med", | |
1588 | "BGP specific commands\n" | |
1589 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1590 | { | |
cdc2d765 | 1591 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 DW |
1592 | |
1593 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) | |
1594 | { | |
1595 | bgp_flag_set (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1596 | bgp_recalculate_all_bestpaths (bgp); | |
1597 | } | |
7aafcaca | 1598 | |
718e3744 | 1599 | return CMD_SUCCESS; |
1600 | } | |
1601 | ||
1602 | DEFUN (no_bgp_deterministic_med, | |
1603 | no_bgp_deterministic_med_cmd, | |
1604 | "no bgp deterministic-med", | |
1605 | NO_STR | |
1606 | "BGP specific commands\n" | |
1607 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1608 | { | |
cdc2d765 | 1609 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
06370dac DW |
1610 | int bestpath_per_as_used; |
1611 | afi_t afi; | |
1612 | safi_t safi; | |
1613 | struct peer *peer; | |
1614 | struct listnode *node, *nnode; | |
718e3744 | 1615 | |
1475ac87 DW |
1616 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) |
1617 | { | |
06370dac DW |
1618 | bestpath_per_as_used = 0; |
1619 | ||
1620 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
1621 | { | |
1622 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
1623 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
1624 | if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
1625 | { | |
1626 | bestpath_per_as_used = 1; | |
1627 | break; | |
1628 | } | |
1629 | ||
1630 | if (bestpath_per_as_used) | |
1631 | break; | |
1632 | } | |
1633 | ||
1634 | if (bestpath_per_as_used) | |
1635 | { | |
1636 | vty_out (vty, "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use%s", | |
1637 | VTY_NEWLINE); | |
1638 | return CMD_WARNING; | |
1639 | } | |
1640 | else | |
1641 | { | |
1642 | bgp_flag_unset (bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1643 | bgp_recalculate_all_bestpaths (bgp); | |
1644 | } | |
1475ac87 | 1645 | } |
7aafcaca | 1646 | |
718e3744 | 1647 | return CMD_SUCCESS; |
1648 | } | |
538621f2 | 1649 | |
1650 | /* "bgp graceful-restart" configuration. */ | |
1651 | DEFUN (bgp_graceful_restart, | |
1652 | bgp_graceful_restart_cmd, | |
1653 | "bgp graceful-restart", | |
1654 | "BGP specific commands\n" | |
1655 | "Graceful restart capability parameters\n") | |
1656 | { | |
cdc2d765 | 1657 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
538621f2 | 1658 | bgp_flag_set (bgp, BGP_FLAG_GRACEFUL_RESTART); |
1659 | return CMD_SUCCESS; | |
1660 | } | |
1661 | ||
1662 | DEFUN (no_bgp_graceful_restart, | |
1663 | no_bgp_graceful_restart_cmd, | |
1664 | "no bgp graceful-restart", | |
1665 | NO_STR | |
1666 | "BGP specific commands\n" | |
1667 | "Graceful restart capability parameters\n") | |
1668 | { | |
cdc2d765 | 1669 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
538621f2 | 1670 | bgp_flag_unset (bgp, BGP_FLAG_GRACEFUL_RESTART); |
1671 | return CMD_SUCCESS; | |
1672 | } | |
1673 | ||
93406d87 | 1674 | DEFUN (bgp_graceful_restart_stalepath_time, |
1675 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1676 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1677 | "BGP specific commands\n" |
1678 | "Graceful restart capability parameters\n" | |
1679 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1680 | "Delay value (seconds)\n") | |
1681 | { | |
cdc2d765 | 1682 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1683 | int idx_number = 3; |
93406d87 | 1684 | u_int32_t stalepath; |
1685 | ||
c500ae40 | 1686 | VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[idx_number]->arg, 1, 3600); |
93406d87 | 1687 | bgp->stalepath_time = stalepath; |
1688 | return CMD_SUCCESS; | |
1689 | } | |
1690 | ||
eb6f1b41 PG |
1691 | DEFUN (bgp_graceful_restart_restart_time, |
1692 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1693 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1694 | "BGP specific commands\n" |
1695 | "Graceful restart capability parameters\n" | |
1696 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1697 | "Delay value (seconds)\n") | |
1698 | { | |
cdc2d765 | 1699 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 1700 | int idx_number = 3; |
eb6f1b41 PG |
1701 | u_int32_t restart; |
1702 | ||
c500ae40 | 1703 | VTY_GET_INTEGER_RANGE ("restart-time", restart, argv[idx_number]->arg, 1, 3600); |
eb6f1b41 PG |
1704 | bgp->restart_time = restart; |
1705 | return CMD_SUCCESS; | |
1706 | } | |
1707 | ||
93406d87 | 1708 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1709 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1710 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1711 | NO_STR |
1712 | "BGP specific commands\n" | |
1713 | "Graceful restart capability parameters\n" | |
838758ac DW |
1714 | "Set the max time to hold onto restarting peer's stale paths\n" |
1715 | "Delay value (seconds)\n") | |
93406d87 | 1716 | { |
cdc2d765 | 1717 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1718 | |
1719 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; | |
1720 | return CMD_SUCCESS; | |
1721 | } | |
1722 | ||
eb6f1b41 PG |
1723 | DEFUN (no_bgp_graceful_restart_restart_time, |
1724 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1725 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1726 | NO_STR |
1727 | "BGP specific commands\n" | |
1728 | "Graceful restart capability parameters\n" | |
838758ac DW |
1729 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1730 | "Delay value (seconds)\n") | |
eb6f1b41 | 1731 | { |
cdc2d765 | 1732 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 PG |
1733 | |
1734 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; | |
1735 | return CMD_SUCCESS; | |
1736 | } | |
1737 | ||
43fc21b3 JC |
1738 | DEFUN (bgp_graceful_restart_preserve_fw, |
1739 | bgp_graceful_restart_preserve_fw_cmd, | |
1740 | "bgp graceful-restart preserve-fw-state", | |
1741 | "BGP specific commands\n" | |
1742 | "Graceful restart capability parameters\n" | |
1743 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1744 | { | |
1745 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1746 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1747 | return CMD_SUCCESS; | |
1748 | } | |
1749 | ||
1750 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
1751 | no_bgp_graceful_restart_preserve_fw_cmd, | |
1752 | "no bgp graceful-restart preserve-fw-state", | |
1753 | NO_STR | |
1754 | "BGP specific commands\n" | |
1755 | "Graceful restart capability parameters\n" | |
1756 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1757 | { | |
1758 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1759 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1760 | return CMD_SUCCESS; | |
1761 | } | |
1762 | ||
718e3744 | 1763 | /* "bgp fast-external-failover" configuration. */ |
1764 | DEFUN (bgp_fast_external_failover, | |
1765 | bgp_fast_external_failover_cmd, | |
1766 | "bgp fast-external-failover", | |
1767 | BGP_STR | |
1768 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1769 | { | |
cdc2d765 | 1770 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1771 | bgp_flag_unset (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
1772 | return CMD_SUCCESS; | |
1773 | } | |
1774 | ||
1775 | DEFUN (no_bgp_fast_external_failover, | |
1776 | no_bgp_fast_external_failover_cmd, | |
1777 | "no bgp fast-external-failover", | |
1778 | NO_STR | |
1779 | BGP_STR | |
1780 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1781 | { | |
cdc2d765 | 1782 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1783 | bgp_flag_set (bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); |
1784 | return CMD_SUCCESS; | |
1785 | } | |
6b0655a2 | 1786 | |
718e3744 | 1787 | /* "bgp enforce-first-as" configuration. */ |
1788 | DEFUN (bgp_enforce_first_as, | |
1789 | bgp_enforce_first_as_cmd, | |
1790 | "bgp enforce-first-as", | |
1791 | BGP_STR | |
1792 | "Enforce the first AS for EBGP routes\n") | |
1793 | { | |
cdc2d765 | 1794 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1795 | bgp_flag_set (bgp, BGP_FLAG_ENFORCE_FIRST_AS); |
f31fa004 | 1796 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 1797 | |
718e3744 | 1798 | return CMD_SUCCESS; |
1799 | } | |
1800 | ||
1801 | DEFUN (no_bgp_enforce_first_as, | |
1802 | no_bgp_enforce_first_as_cmd, | |
1803 | "no bgp enforce-first-as", | |
1804 | NO_STR | |
1805 | BGP_STR | |
1806 | "Enforce the first AS for EBGP routes\n") | |
1807 | { | |
cdc2d765 | 1808 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1809 | bgp_flag_unset (bgp, BGP_FLAG_ENFORCE_FIRST_AS); |
f31fa004 | 1810 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 1811 | |
718e3744 | 1812 | return CMD_SUCCESS; |
1813 | } | |
6b0655a2 | 1814 | |
718e3744 | 1815 | /* "bgp bestpath compare-routerid" configuration. */ |
1816 | DEFUN (bgp_bestpath_compare_router_id, | |
1817 | bgp_bestpath_compare_router_id_cmd, | |
1818 | "bgp bestpath compare-routerid", | |
1819 | "BGP specific commands\n" | |
1820 | "Change the default bestpath selection\n" | |
1821 | "Compare router-id for identical EBGP paths\n") | |
1822 | { | |
cdc2d765 | 1823 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1824 | bgp_flag_set (bgp, BGP_FLAG_COMPARE_ROUTER_ID); |
7aafcaca DS |
1825 | bgp_recalculate_all_bestpaths (bgp); |
1826 | ||
718e3744 | 1827 | return CMD_SUCCESS; |
1828 | } | |
1829 | ||
1830 | DEFUN (no_bgp_bestpath_compare_router_id, | |
1831 | no_bgp_bestpath_compare_router_id_cmd, | |
1832 | "no bgp bestpath compare-routerid", | |
1833 | NO_STR | |
1834 | "BGP specific commands\n" | |
1835 | "Change the default bestpath selection\n" | |
1836 | "Compare router-id for identical EBGP paths\n") | |
1837 | { | |
cdc2d765 | 1838 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1839 | bgp_flag_unset (bgp, BGP_FLAG_COMPARE_ROUTER_ID); |
7aafcaca DS |
1840 | bgp_recalculate_all_bestpaths (bgp); |
1841 | ||
718e3744 | 1842 | return CMD_SUCCESS; |
1843 | } | |
6b0655a2 | 1844 | |
718e3744 | 1845 | /* "bgp bestpath as-path ignore" configuration. */ |
1846 | DEFUN (bgp_bestpath_aspath_ignore, | |
1847 | bgp_bestpath_aspath_ignore_cmd, | |
1848 | "bgp bestpath as-path ignore", | |
1849 | "BGP specific commands\n" | |
1850 | "Change the default bestpath selection\n" | |
1851 | "AS-path attribute\n" | |
1852 | "Ignore as-path length in selecting a route\n") | |
1853 | { | |
cdc2d765 | 1854 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1855 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_IGNORE); |
7aafcaca DS |
1856 | bgp_recalculate_all_bestpaths (bgp); |
1857 | ||
718e3744 | 1858 | return CMD_SUCCESS; |
1859 | } | |
1860 | ||
1861 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
1862 | no_bgp_bestpath_aspath_ignore_cmd, | |
1863 | "no bgp bestpath as-path ignore", | |
1864 | NO_STR | |
1865 | "BGP specific commands\n" | |
1866 | "Change the default bestpath selection\n" | |
1867 | "AS-path attribute\n" | |
1868 | "Ignore as-path length in selecting a route\n") | |
1869 | { | |
cdc2d765 | 1870 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1871 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_IGNORE); |
7aafcaca DS |
1872 | bgp_recalculate_all_bestpaths (bgp); |
1873 | ||
718e3744 | 1874 | return CMD_SUCCESS; |
1875 | } | |
6b0655a2 | 1876 | |
6811845b | 1877 | /* "bgp bestpath as-path confed" configuration. */ |
1878 | DEFUN (bgp_bestpath_aspath_confed, | |
1879 | bgp_bestpath_aspath_confed_cmd, | |
1880 | "bgp bestpath as-path confed", | |
1881 | "BGP specific commands\n" | |
1882 | "Change the default bestpath selection\n" | |
1883 | "AS-path attribute\n" | |
1884 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
1885 | { | |
cdc2d765 | 1886 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6811845b | 1887 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_CONFED); |
7aafcaca DS |
1888 | bgp_recalculate_all_bestpaths (bgp); |
1889 | ||
6811845b | 1890 | return CMD_SUCCESS; |
1891 | } | |
1892 | ||
1893 | DEFUN (no_bgp_bestpath_aspath_confed, | |
1894 | no_bgp_bestpath_aspath_confed_cmd, | |
1895 | "no bgp bestpath as-path confed", | |
1896 | NO_STR | |
1897 | "BGP specific commands\n" | |
1898 | "Change the default bestpath selection\n" | |
1899 | "AS-path attribute\n" | |
1900 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
1901 | { | |
cdc2d765 | 1902 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6811845b | 1903 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_CONFED); |
7aafcaca DS |
1904 | bgp_recalculate_all_bestpaths (bgp); |
1905 | ||
6811845b | 1906 | return CMD_SUCCESS; |
1907 | } | |
6b0655a2 | 1908 | |
2fdd455c PM |
1909 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
1910 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
1911 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 1912 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
1913 | "BGP specific commands\n" |
1914 | "Change the default bestpath selection\n" | |
1915 | "AS-path attribute\n" | |
1916 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 1917 | "Generate an AS_SET\n" |
16fc1eec DS |
1918 | "Do not generate an AS_SET\n") |
1919 | { | |
cdc2d765 | 1920 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4c4ff4c1 | 1921 | int idx = 0; |
16fc1eec | 1922 | bgp_flag_set (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 DW |
1923 | |
1924 | /* no-as-set is now the default behavior so we can silently | |
1925 | * ignore it */ | |
4c4ff4c1 | 1926 | if (argv_find (argv, argc, "as-set", &idx)) |
219178b6 DW |
1927 | bgp_flag_set (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
1928 | else | |
1929 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET) ; | |
1930 | ||
7aafcaca DS |
1931 | bgp_recalculate_all_bestpaths (bgp); |
1932 | ||
16fc1eec DS |
1933 | return CMD_SUCCESS; |
1934 | } | |
1935 | ||
219178b6 DW |
1936 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
1937 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 1938 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
1939 | NO_STR |
1940 | "BGP specific commands\n" | |
1941 | "Change the default bestpath selection\n" | |
1942 | "AS-path attribute\n" | |
1943 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 1944 | "Generate an AS_SET\n" |
16fc1eec DS |
1945 | "Do not generate an AS_SET\n") |
1946 | { | |
cdc2d765 | 1947 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
16fc1eec | 1948 | bgp_flag_unset (bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); |
219178b6 | 1949 | bgp_flag_unset (bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); |
7aafcaca DS |
1950 | bgp_recalculate_all_bestpaths (bgp); |
1951 | ||
2fdd455c PM |
1952 | return CMD_SUCCESS; |
1953 | } | |
6b0655a2 | 1954 | |
848973c7 | 1955 | /* "bgp log-neighbor-changes" configuration. */ |
1956 | DEFUN (bgp_log_neighbor_changes, | |
1957 | bgp_log_neighbor_changes_cmd, | |
1958 | "bgp log-neighbor-changes", | |
1959 | "BGP specific commands\n" | |
1960 | "Log neighbor up/down and reset reason\n") | |
1961 | { | |
cdc2d765 | 1962 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
848973c7 | 1963 | bgp_flag_set (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
1964 | return CMD_SUCCESS; | |
1965 | } | |
1966 | ||
1967 | DEFUN (no_bgp_log_neighbor_changes, | |
1968 | no_bgp_log_neighbor_changes_cmd, | |
1969 | "no bgp log-neighbor-changes", | |
1970 | NO_STR | |
1971 | "BGP specific commands\n" | |
1972 | "Log neighbor up/down and reset reason\n") | |
1973 | { | |
cdc2d765 | 1974 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
848973c7 | 1975 | bgp_flag_unset (bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); |
1976 | return CMD_SUCCESS; | |
1977 | } | |
6b0655a2 | 1978 | |
718e3744 | 1979 | /* "bgp bestpath med" configuration. */ |
1980 | DEFUN (bgp_bestpath_med, | |
1981 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 1982 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 1983 | "BGP specific commands\n" |
1984 | "Change the default bestpath selection\n" | |
1985 | "MED attribute\n" | |
1986 | "Compare MED among confederation paths\n" | |
838758ac DW |
1987 | "Treat missing MED as the least preferred one\n" |
1988 | "Treat missing MED as the least preferred one\n" | |
1989 | "Compare MED among confederation paths\n") | |
718e3744 | 1990 | { |
cdc2d765 | 1991 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 QY |
1992 | |
1993 | int idx = 0; | |
1994 | if (argv_find (argv, argc, "confed", &idx)) | |
1995 | bgp_flag_set (bgp, BGP_FLAG_MED_CONFED); | |
1996 | idx = 0; | |
1997 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
1998 | bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 1999 | |
7aafcaca DS |
2000 | bgp_recalculate_all_bestpaths (bgp); |
2001 | ||
718e3744 | 2002 | return CMD_SUCCESS; |
2003 | } | |
2004 | ||
718e3744 | 2005 | DEFUN (no_bgp_bestpath_med, |
2006 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2007 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2008 | NO_STR |
2009 | "BGP specific commands\n" | |
2010 | "Change the default bestpath selection\n" | |
2011 | "MED attribute\n" | |
2012 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2013 | "Treat missing MED as the least preferred one\n" |
2014 | "Treat missing MED as the least preferred one\n" | |
2015 | "Compare MED among confederation paths\n") | |
718e3744 | 2016 | { |
cdc2d765 | 2017 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2018 | |
6cbd1915 QY |
2019 | int idx = 0; |
2020 | if (argv_find (argv, argc, "confed", &idx)) | |
718e3744 | 2021 | bgp_flag_unset (bgp, BGP_FLAG_MED_CONFED); |
6cbd1915 QY |
2022 | idx = 0; |
2023 | if (argv_find (argv, argc, "missing-as-worst", &idx)) | |
718e3744 | 2024 | bgp_flag_unset (bgp, BGP_FLAG_MED_MISSING_AS_WORST); |
2025 | ||
7aafcaca DS |
2026 | bgp_recalculate_all_bestpaths (bgp); |
2027 | ||
718e3744 | 2028 | return CMD_SUCCESS; |
2029 | } | |
2030 | ||
718e3744 | 2031 | /* "no bgp default ipv4-unicast". */ |
2032 | DEFUN (no_bgp_default_ipv4_unicast, | |
2033 | no_bgp_default_ipv4_unicast_cmd, | |
2034 | "no bgp default ipv4-unicast", | |
2035 | NO_STR | |
2036 | "BGP specific commands\n" | |
2037 | "Configure BGP defaults\n" | |
2038 | "Activate ipv4-unicast for a peer by default\n") | |
2039 | { | |
cdc2d765 | 2040 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2041 | bgp_flag_set (bgp, BGP_FLAG_NO_DEFAULT_IPV4); |
2042 | return CMD_SUCCESS; | |
2043 | } | |
2044 | ||
2045 | DEFUN (bgp_default_ipv4_unicast, | |
2046 | bgp_default_ipv4_unicast_cmd, | |
2047 | "bgp default ipv4-unicast", | |
2048 | "BGP specific commands\n" | |
2049 | "Configure BGP defaults\n" | |
2050 | "Activate ipv4-unicast for a peer by default\n") | |
2051 | { | |
cdc2d765 | 2052 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2053 | bgp_flag_unset (bgp, BGP_FLAG_NO_DEFAULT_IPV4); |
2054 | return CMD_SUCCESS; | |
2055 | } | |
6b0655a2 | 2056 | |
04b6bdc0 DW |
2057 | /* Display hostname in certain command outputs */ |
2058 | DEFUN (bgp_default_show_hostname, | |
2059 | bgp_default_show_hostname_cmd, | |
2060 | "bgp default show-hostname", | |
2061 | "BGP specific commands\n" | |
2062 | "Configure BGP defaults\n" | |
2063 | "Show hostname in certain command ouputs\n") | |
2064 | { | |
cdc2d765 | 2065 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
04b6bdc0 DW |
2066 | bgp_flag_set (bgp, BGP_FLAG_SHOW_HOSTNAME); |
2067 | return CMD_SUCCESS; | |
2068 | } | |
2069 | ||
2070 | DEFUN (no_bgp_default_show_hostname, | |
2071 | no_bgp_default_show_hostname_cmd, | |
2072 | "no bgp default show-hostname", | |
2073 | NO_STR | |
2074 | "BGP specific commands\n" | |
2075 | "Configure BGP defaults\n" | |
2076 | "Show hostname in certain command ouputs\n") | |
2077 | { | |
cdc2d765 | 2078 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
04b6bdc0 DW |
2079 | bgp_flag_unset (bgp, BGP_FLAG_SHOW_HOSTNAME); |
2080 | return CMD_SUCCESS; | |
2081 | } | |
2082 | ||
8233ef81 | 2083 | /* "bgp network import-check" configuration. */ |
718e3744 | 2084 | DEFUN (bgp_network_import_check, |
2085 | bgp_network_import_check_cmd, | |
5623e905 | 2086 | "bgp network import-check", |
718e3744 | 2087 | "BGP specific commands\n" |
2088 | "BGP network command\n" | |
5623e905 | 2089 | "Check BGP network route exists in IGP\n") |
718e3744 | 2090 | { |
cdc2d765 | 2091 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
078430f6 DS |
2092 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2093 | { | |
2094 | bgp_flag_set (bgp, BGP_FLAG_IMPORT_CHECK); | |
5623e905 | 2095 | bgp_static_redo_import_check(bgp); |
078430f6 DS |
2096 | } |
2097 | ||
718e3744 | 2098 | return CMD_SUCCESS; |
2099 | } | |
2100 | ||
8233ef81 DW |
2101 | ALIAS_HIDDEN (bgp_network_import_check, |
2102 | bgp_network_import_check_exact_cmd, | |
2103 | "bgp network import-check exact", | |
2104 | "BGP specific commands\n" | |
2105 | "BGP network command\n" | |
2106 | "Check BGP network route exists in IGP\n" | |
2107 | "Match route precisely\n") | |
2108 | ||
718e3744 | 2109 | DEFUN (no_bgp_network_import_check, |
2110 | no_bgp_network_import_check_cmd, | |
5623e905 | 2111 | "no bgp network import-check", |
718e3744 | 2112 | NO_STR |
2113 | "BGP specific commands\n" | |
2114 | "BGP network command\n" | |
2115 | "Check BGP network route exists in IGP\n") | |
2116 | { | |
cdc2d765 | 2117 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
078430f6 DS |
2118 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) |
2119 | { | |
2120 | bgp_flag_unset (bgp, BGP_FLAG_IMPORT_CHECK); | |
078430f6 DS |
2121 | bgp_static_redo_import_check(bgp); |
2122 | } | |
5623e905 | 2123 | |
718e3744 | 2124 | return CMD_SUCCESS; |
2125 | } | |
6b0655a2 | 2126 | |
718e3744 | 2127 | DEFUN (bgp_default_local_preference, |
2128 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2129 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2130 | "BGP specific commands\n" |
2131 | "Configure BGP defaults\n" | |
2132 | "local preference (higher=more preferred)\n" | |
2133 | "Configure default local preference value\n") | |
2134 | { | |
cdc2d765 | 2135 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2136 | int idx_number = 3; |
718e3744 | 2137 | u_int32_t local_pref; |
2138 | ||
c500ae40 | 2139 | VTY_GET_INTEGER ("local preference", local_pref, argv[idx_number]->arg); |
718e3744 | 2140 | |
2141 | bgp_default_local_preference_set (bgp, local_pref); | |
f31fa004 | 2142 | bgp_clear_star_soft_in (vty, bgp->name); |
718e3744 | 2143 | |
2144 | return CMD_SUCCESS; | |
2145 | } | |
2146 | ||
2147 | DEFUN (no_bgp_default_local_preference, | |
2148 | no_bgp_default_local_preference_cmd, | |
838758ac | 2149 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2150 | NO_STR |
2151 | "BGP specific commands\n" | |
2152 | "Configure BGP defaults\n" | |
838758ac DW |
2153 | "local preference (higher=more preferred)\n" |
2154 | "Configure default local preference value\n") | |
718e3744 | 2155 | { |
cdc2d765 | 2156 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2157 | bgp_default_local_preference_unset (bgp); |
f31fa004 | 2158 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2159 | |
718e3744 | 2160 | return CMD_SUCCESS; |
2161 | } | |
2162 | ||
6b0655a2 | 2163 | |
3f9c7369 DS |
2164 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2165 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2166 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2167 | "BGP specific commands\n" |
2168 | "Configure BGP defaults\n" | |
2169 | "subgroup-pkt-queue-max\n" | |
2170 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2171 | { |
cdc2d765 | 2172 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2173 | int idx_number = 3; |
3f9c7369 | 2174 | u_int32_t max_size; |
8bd9d948 | 2175 | |
c500ae40 | 2176 | VTY_GET_INTEGER ("subgroup packet queue max", max_size, argv[idx_number]->arg); |
3f9c7369 DS |
2177 | |
2178 | bgp_default_subgroup_pkt_queue_max_set (bgp, max_size); | |
2179 | ||
2180 | return CMD_SUCCESS; | |
2181 | } | |
2182 | ||
2183 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2184 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2185 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2186 | NO_STR |
2187 | "BGP specific commands\n" | |
2188 | "Configure BGP defaults\n" | |
838758ac DW |
2189 | "subgroup-pkt-queue-max\n" |
2190 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2191 | { |
cdc2d765 | 2192 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3f9c7369 DS |
2193 | bgp_default_subgroup_pkt_queue_max_unset (bgp); |
2194 | return CMD_SUCCESS; | |
8bd9d948 DS |
2195 | } |
2196 | ||
813d4307 | 2197 | |
8bd9d948 DS |
2198 | DEFUN (bgp_rr_allow_outbound_policy, |
2199 | bgp_rr_allow_outbound_policy_cmd, | |
2200 | "bgp route-reflector allow-outbound-policy", | |
2201 | "BGP specific commands\n" | |
2202 | "Allow modifications made by out route-map\n" | |
2203 | "on ibgp neighbors\n") | |
2204 | { | |
cdc2d765 | 2205 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 DS |
2206 | |
2207 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2208 | { | |
2209 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2210 | update_group_announce_rrclients(bgp); |
f31fa004 | 2211 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2212 | } |
2213 | ||
2214 | return CMD_SUCCESS; | |
2215 | } | |
2216 | ||
2217 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2218 | no_bgp_rr_allow_outbound_policy_cmd, | |
2219 | "no bgp route-reflector allow-outbound-policy", | |
2220 | NO_STR | |
2221 | "BGP specific commands\n" | |
2222 | "Allow modifications made by out route-map\n" | |
2223 | "on ibgp neighbors\n") | |
2224 | { | |
cdc2d765 | 2225 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 DS |
2226 | |
2227 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) | |
2228 | { | |
2229 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
3f9c7369 | 2230 | update_group_announce_rrclients(bgp); |
f31fa004 | 2231 | bgp_clear_star_soft_out (vty, bgp->name); |
8bd9d948 DS |
2232 | } |
2233 | ||
2234 | return CMD_SUCCESS; | |
2235 | } | |
2236 | ||
f14e6fdb DS |
2237 | DEFUN (bgp_listen_limit, |
2238 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2239 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2240 | "BGP specific commands\n" |
2241 | "Configure BGP defaults\n" | |
2242 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2243 | "Configure Dynamic Neighbors listen limit value\n") | |
2244 | { | |
cdc2d765 | 2245 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2246 | int idx_number = 3; |
f14e6fdb DS |
2247 | int listen_limit; |
2248 | ||
c500ae40 | 2249 | VTY_GET_INTEGER_RANGE ("listen limit", listen_limit, argv[idx_number]->arg, |
f14e6fdb DS |
2250 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN, |
2251 | BGP_DYNAMIC_NEIGHBORS_LIMIT_MAX); | |
2252 | ||
2253 | bgp_listen_limit_set (bgp, listen_limit); | |
2254 | ||
2255 | return CMD_SUCCESS; | |
2256 | } | |
2257 | ||
2258 | DEFUN (no_bgp_listen_limit, | |
2259 | no_bgp_listen_limit_cmd, | |
838758ac | 2260 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2261 | "BGP specific commands\n" |
2262 | "Configure BGP defaults\n" | |
2263 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2264 | "Configure Dynamic Neighbors listen limit value to default\n" |
2265 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2266 | { |
cdc2d765 | 2267 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb DS |
2268 | bgp_listen_limit_unset (bgp); |
2269 | return CMD_SUCCESS; | |
2270 | } | |
2271 | ||
2272 | ||
20eb8864 | 2273 | /* |
2274 | * Check if this listen range is already configured. Check for exact | |
2275 | * match or overlap based on input. | |
2276 | */ | |
2277 | static struct peer_group * | |
2278 | listen_range_exists (struct bgp *bgp, struct prefix *range, int exact) | |
2279 | { | |
2280 | struct listnode *node, *nnode; | |
2281 | struct listnode *node1, *nnode1; | |
2282 | struct peer_group *group; | |
2283 | struct prefix *lr; | |
2284 | afi_t afi; | |
2285 | int match; | |
2286 | ||
2287 | afi = family2afi(range->family); | |
2288 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2289 | { | |
2290 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node1, | |
2291 | nnode1, lr)) | |
2292 | { | |
2293 | if (exact) | |
2294 | match = prefix_same (range, lr); | |
2295 | else | |
2296 | match = (prefix_match (range, lr) || prefix_match (lr, range)); | |
2297 | if (match) | |
2298 | return group; | |
2299 | } | |
2300 | } | |
2301 | ||
2302 | return NULL; | |
2303 | } | |
2304 | ||
f14e6fdb DS |
2305 | DEFUN (bgp_listen_range, |
2306 | bgp_listen_range_cmd, | |
9ccf14f7 | 2307 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2308 | "BGP specific commands\n" |
d7fa34c1 QY |
2309 | "Configure BGP dynamic neighbors listen range\n" |
2310 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2311 | NEIGHBOR_ADDR_STR |
2312 | "Member of the peer-group\n" | |
2313 | "Peer-group name\n") | |
f14e6fdb | 2314 | { |
cdc2d765 | 2315 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb | 2316 | struct prefix range; |
20eb8864 | 2317 | struct peer_group *group, *existing_group; |
f14e6fdb DS |
2318 | afi_t afi; |
2319 | int ret; | |
d7fa34c1 | 2320 | int idx = 0; |
f14e6fdb | 2321 | |
d7fa34c1 QY |
2322 | argv_find (argv, argc, "A.B.C.D/M", &idx); |
2323 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2324 | char *prefix = argv[idx]->arg; | |
2325 | argv_find (argv, argc, "WORD", &idx); | |
2326 | char *peergroup = argv[idx]->arg; | |
f14e6fdb | 2327 | |
f14e6fdb | 2328 | /* Convert IP prefix string to struct prefix. */ |
d7fa34c1 | 2329 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2330 | if (! ret) |
2331 | { | |
2332 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2333 | return CMD_WARNING; | |
2334 | } | |
2335 | ||
2336 | afi = family2afi(range.family); | |
2337 | ||
f14e6fdb DS |
2338 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2339 | { | |
2340 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2341 | VTY_NEWLINE); | |
2342 | return CMD_WARNING; | |
2343 | } | |
f14e6fdb DS |
2344 | |
2345 | apply_mask (&range); | |
2346 | ||
20eb8864 | 2347 | /* Check if same listen range is already configured. */ |
2348 | existing_group = listen_range_exists (bgp, &range, 1); | |
2349 | if (existing_group) | |
2350 | { | |
d7fa34c1 | 2351 | if (strcmp (existing_group->name, peergroup) == 0) |
20eb8864 | 2352 | return CMD_SUCCESS; |
2353 | else | |
2354 | { | |
2355 | vty_out (vty, "%% Same listen range is attached to peer-group %s%s", | |
2356 | existing_group->name, VTY_NEWLINE); | |
2357 | return CMD_WARNING; | |
2358 | } | |
2359 | } | |
2360 | ||
2361 | /* Check if an overlapping listen range exists. */ | |
2362 | if (listen_range_exists (bgp, &range, 0)) | |
2363 | { | |
2364 | vty_out (vty, "%% Listen range overlaps with existing listen range%s", | |
2365 | VTY_NEWLINE); | |
2366 | return CMD_WARNING; | |
2367 | } | |
f14e6fdb | 2368 | |
d7fa34c1 | 2369 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2370 | if (! group) |
2371 | { | |
2372 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2373 | return CMD_WARNING; | |
2374 | } | |
2375 | ||
2376 | ret = peer_group_listen_range_add(group, &range); | |
2377 | return bgp_vty_return (vty, ret); | |
2378 | } | |
2379 | ||
2380 | DEFUN (no_bgp_listen_range, | |
2381 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2382 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2383 | NO_STR | |
f14e6fdb | 2384 | "BGP specific commands\n" |
d7fa34c1 QY |
2385 | "Unconfigure BGP dynamic neighbors listen range\n" |
2386 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2387 | NEIGHBOR_ADDR_STR | |
2388 | "Member of the peer-group\n" | |
2389 | "Peer-group name\n") | |
f14e6fdb | 2390 | { |
cdc2d765 | 2391 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f14e6fdb DS |
2392 | struct prefix range; |
2393 | struct peer_group *group; | |
2394 | afi_t afi; | |
2395 | int ret; | |
d7fa34c1 QY |
2396 | int idx = 0; |
2397 | ||
2398 | argv_find (argv, argc, "A.B.C.D/M", &idx); | |
2399 | argv_find (argv, argc, "X:X::X:X/M", &idx); | |
2400 | char *prefix = argv[idx]->arg; | |
2401 | argv_find (argv, argc, "WORD", &idx); | |
2402 | char *peergroup = argv[idx]->arg; | |
f14e6fdb | 2403 | |
c500ae40 | 2404 | // VTY_GET_IPV4_PREFIX ("listen range", range, argv[idx_ipv4_prefixlen]->arg); |
f14e6fdb DS |
2405 | |
2406 | /* Convert IP prefix string to struct prefix. */ | |
d7fa34c1 | 2407 | ret = str2prefix (prefix, &range); |
f14e6fdb DS |
2408 | if (! ret) |
2409 | { | |
2410 | vty_out (vty, "%% Malformed listen range%s", VTY_NEWLINE); | |
2411 | return CMD_WARNING; | |
2412 | } | |
2413 | ||
2414 | afi = family2afi(range.family); | |
2415 | ||
f14e6fdb DS |
2416 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&range.u.prefix6)) |
2417 | { | |
2418 | vty_out (vty, "%% Malformed listen range (link-local address)%s", | |
2419 | VTY_NEWLINE); | |
2420 | return CMD_WARNING; | |
2421 | } | |
f14e6fdb DS |
2422 | |
2423 | apply_mask (&range); | |
2424 | ||
d7fa34c1 | 2425 | group = peer_group_lookup (bgp, peergroup); |
f14e6fdb DS |
2426 | if (! group) |
2427 | { | |
2428 | vty_out (vty, "%% Peer-group does not exist%s", VTY_NEWLINE); | |
2429 | return CMD_WARNING; | |
2430 | } | |
2431 | ||
2432 | ret = peer_group_listen_range_del(group, &range); | |
2433 | return bgp_vty_return (vty, ret); | |
2434 | } | |
2435 | ||
2436 | int | |
2437 | bgp_config_write_listen (struct vty *vty, struct bgp *bgp) | |
2438 | { | |
2439 | struct peer_group *group; | |
2440 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2441 | struct prefix *range; | |
2442 | afi_t afi; | |
4690c7d7 | 2443 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
2444 | |
2445 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2446 | vty_out (vty, " bgp listen limit %d%s", | |
2447 | bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
2448 | ||
2449 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
2450 | { | |
2451 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
2452 | { | |
2453 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], rnode, nrnode, range)) | |
2454 | { | |
2455 | prefix2str(range, buf, sizeof(buf)); | |
2456 | vty_out(vty, " bgp listen range %s peer-group %s%s", | |
2457 | buf, group->name, VTY_NEWLINE); | |
2458 | } | |
2459 | } | |
2460 | } | |
2461 | ||
2462 | return 0; | |
2463 | } | |
2464 | ||
2465 | ||
907f92c8 DS |
2466 | DEFUN (bgp_disable_connected_route_check, |
2467 | bgp_disable_connected_route_check_cmd, | |
2468 | "bgp disable-ebgp-connected-route-check", | |
2469 | "BGP specific commands\n" | |
2470 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2471 | { | |
cdc2d765 | 2472 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
907f92c8 | 2473 | bgp_flag_set (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
f31fa004 | 2474 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2475 | |
907f92c8 DS |
2476 | return CMD_SUCCESS; |
2477 | } | |
2478 | ||
2479 | DEFUN (no_bgp_disable_connected_route_check, | |
2480 | no_bgp_disable_connected_route_check_cmd, | |
2481 | "no bgp disable-ebgp-connected-route-check", | |
2482 | NO_STR | |
2483 | "BGP specific commands\n" | |
2484 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2485 | { | |
cdc2d765 | 2486 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
907f92c8 | 2487 | bgp_flag_unset (bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); |
f31fa004 | 2488 | bgp_clear_star_soft_in (vty, bgp->name); |
7aafcaca | 2489 | |
907f92c8 DS |
2490 | return CMD_SUCCESS; |
2491 | } | |
2492 | ||
2493 | ||
718e3744 | 2494 | static int |
e52702f2 | 2495 | peer_remote_as_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 2496 | const char *as_str, afi_t afi, safi_t safi) |
718e3744 | 2497 | { |
cdc2d765 | 2498 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2499 | int ret; |
718e3744 | 2500 | as_t as; |
0299c004 | 2501 | int as_type = AS_SPECIFIED; |
718e3744 | 2502 | union sockunion su; |
2503 | ||
7ae5fc81 | 2504 | if (as_str[0] == 'i') |
0299c004 DS |
2505 | { |
2506 | as = 0; | |
2507 | as_type = AS_INTERNAL; | |
2508 | } | |
7ae5fc81 | 2509 | else if (as_str[0] == 'e') |
0299c004 DS |
2510 | { |
2511 | as = 0; | |
2512 | as_type = AS_EXTERNAL; | |
2513 | } | |
2514 | else | |
2515 | { | |
2516 | /* Get AS number. */ | |
2517 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2518 | } | |
718e3744 | 2519 | |
2520 | /* If peer is peer group, call proper function. */ | |
2521 | ret = str2sockunion (peer_str, &su); | |
2522 | if (ret < 0) | |
2523 | { | |
a80beece | 2524 | /* Check for peer by interface */ |
0299c004 | 2525 | ret = peer_remote_as (bgp, NULL, peer_str, &as, as_type, afi, safi); |
718e3744 | 2526 | if (ret < 0) |
a80beece | 2527 | { |
0299c004 | 2528 | ret = peer_group_remote_as (bgp, peer_str, &as, as_type); |
a80beece DS |
2529 | if (ret < 0) |
2530 | { | |
2531 | vty_out (vty, "%% Create the peer-group or interface first%s", | |
2532 | VTY_NEWLINE); | |
2533 | return CMD_WARNING; | |
2534 | } | |
2535 | return CMD_SUCCESS; | |
2536 | } | |
718e3744 | 2537 | } |
a80beece | 2538 | else |
718e3744 | 2539 | { |
6aeb9e78 | 2540 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
2541 | { |
2542 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
2543 | VTY_NEWLINE); | |
2544 | return CMD_WARNING; | |
2545 | } | |
0299c004 | 2546 | ret = peer_remote_as (bgp, &su, NULL, &as, as_type, afi, safi); |
718e3744 | 2547 | } |
2548 | ||
718e3744 | 2549 | /* This peer belongs to peer group. */ |
2550 | switch (ret) | |
2551 | { | |
2552 | case BGP_ERR_PEER_GROUP_MEMBER: | |
aea339f7 | 2553 | vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", as, VTY_NEWLINE); |
718e3744 | 2554 | return CMD_WARNING; |
718e3744 | 2555 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: |
aea339f7 | 2556 | 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 | 2557 | return CMD_WARNING; |
718e3744 | 2558 | } |
2559 | return bgp_vty_return (vty, ret); | |
2560 | } | |
2561 | ||
2562 | DEFUN (neighbor_remote_as, | |
2563 | neighbor_remote_as_cmd, | |
3a2d747c | 2564 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2565 | NEIGHBOR_STR |
2566 | NEIGHBOR_ADDR_STR2 | |
2567 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2568 | AS_STR |
3a2d747c QY |
2569 | "Internal BGP peer\n" |
2570 | "External BGP peer\n") | |
718e3744 | 2571 | { |
c500ae40 DW |
2572 | int idx_peer = 1; |
2573 | int idx_remote_as = 3; | |
2574 | return peer_remote_as_vty (vty, argv[idx_peer]->arg, argv[idx_remote_as]->arg, AFI_IP, SAFI_UNICAST); | |
718e3744 | 2575 | } |
6b0655a2 | 2576 | |
4c48cf63 DW |
2577 | static int |
2578 | peer_conf_interface_get (struct vty *vty, const char *conf_if, afi_t afi, | |
b3a39dc5 DD |
2579 | safi_t safi, int v6only, const char *peer_group_name, |
2580 | const char *as_str) | |
a80beece | 2581 | { |
cdc2d765 | 2582 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
b3a39dc5 DD |
2583 | as_t as = 0; |
2584 | int as_type = AS_UNSPECIFIED; | |
a80beece DS |
2585 | struct peer *peer; |
2586 | struct peer_group *group; | |
4c48cf63 DW |
2587 | int ret = 0; |
2588 | union sockunion su; | |
a80beece | 2589 | |
4c48cf63 DW |
2590 | group = peer_group_lookup (bgp, conf_if); |
2591 | ||
a80beece DS |
2592 | if (group) |
2593 | { | |
2594 | vty_out (vty, "%% Name conflict with peer-group %s", VTY_NEWLINE); | |
2595 | return CMD_WARNING; | |
2596 | } | |
2597 | ||
b3a39dc5 DD |
2598 | if (as_str) |
2599 | { | |
7ae5fc81 | 2600 | if (as_str[0] == 'i') |
b3a39dc5 DD |
2601 | { |
2602 | as_type = AS_INTERNAL; | |
2603 | } | |
7ae5fc81 | 2604 | else if (as_str[0] == 'e') |
b3a39dc5 DD |
2605 | { |
2606 | as_type = AS_EXTERNAL; | |
2607 | } | |
2608 | else | |
2609 | { | |
2610 | /* Get AS number. */ | |
2611 | VTY_GET_INTEGER_RANGE ("AS", as, as_str, 1, BGP_AS4_MAX); | |
2612 | as_type = AS_SPECIFIED; | |
2613 | } | |
2614 | } | |
2615 | ||
4c48cf63 DW |
2616 | peer = peer_lookup_by_conf_if (bgp, conf_if); |
2617 | if (!peer) | |
2618 | { | |
2619 | if (bgp_flag_check (bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2620 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
b3a39dc5 DD |
2621 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, 0, 0, |
2622 | NULL); | |
4c48cf63 | 2623 | else |
b3a39dc5 DD |
2624 | peer = peer_create (NULL, conf_if, bgp, bgp->as, as, as_type, afi, safi, |
2625 | NULL); | |
4c48cf63 DW |
2626 | |
2627 | if (peer && v6only) | |
2628 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
4a04e5f7 | 2629 | |
2630 | /* Request zebra to initiate IPv6 RAs on this interface. We do this | |
2631 | * any unnumbered peer in order to not worry about run-time transitions | |
2632 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 address | |
2633 | * gets deleted later etc.) | |
2634 | */ | |
2635 | if (peer->ifp) | |
b3a39dc5 DD |
2636 | { |
2637 | bgp_zebra_initiate_radv (bgp, peer); | |
2638 | } | |
2639 | peer_flag_set (peer, PEER_FLAG_CAPABILITY_ENHE); | |
4c48cf63 DW |
2640 | } |
2641 | else if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) || | |
2642 | (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) | |
2643 | { | |
2644 | if (v6only) | |
2645 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2646 | else | |
2647 | UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2648 | ||
2649 | /* v6only flag changed. Reset bgp seesion */ | |
2650 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) | |
2651 | { | |
2652 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2653 | bgp_notify_send (peer, BGP_NOTIFY_CEASE, | |
2654 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2655 | } | |
2656 | else | |
2657 | bgp_session_reset(peer); | |
2658 | } | |
2659 | ||
a80beece DS |
2660 | if (!peer) |
2661 | return CMD_WARNING; | |
2662 | ||
4c48cf63 DW |
2663 | if (peer_group_name) |
2664 | { | |
2665 | group = peer_group_lookup (bgp, peer_group_name); | |
2666 | if (! group) | |
2667 | { | |
2668 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
2669 | return CMD_WARNING; | |
2670 | } | |
2671 | ||
2672 | ret = peer_group_bind (bgp, &su, peer, group, &as); | |
2673 | } | |
2674 | ||
2675 | return bgp_vty_return (vty, ret); | |
a80beece DS |
2676 | } |
2677 | ||
4c48cf63 DW |
2678 | DEFUN (neighbor_interface_config, |
2679 | neighbor_interface_config_cmd, | |
31500417 | 2680 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2681 | NEIGHBOR_STR |
2682 | "Interface name or neighbor tag\n" | |
31500417 DW |
2683 | "Enable BGP on interface\n" |
2684 | "Member of the peer-group\n" | |
16cedbb0 | 2685 | "Peer-group name\n") |
4c48cf63 | 2686 | { |
c500ae40 | 2687 | int idx_word = 1; |
31500417 DW |
2688 | int idx_peer_group_word = 4; |
2689 | ||
2690 | if (argc > idx_peer_group_word) | |
c500ae40 | 2691 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
31500417 | 2692 | argv[idx_peer_group_word]->arg, NULL); |
4c48cf63 | 2693 | else |
c500ae40 | 2694 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, |
b3a39dc5 | 2695 | NULL, NULL); |
4c48cf63 DW |
2696 | } |
2697 | ||
4c48cf63 DW |
2698 | DEFUN (neighbor_interface_config_v6only, |
2699 | neighbor_interface_config_v6only_cmd, | |
31500417 | 2700 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
2701 | NEIGHBOR_STR |
2702 | "Interface name or neighbor tag\n" | |
2703 | "Enable BGP on interface\n" | |
31500417 DW |
2704 | "Enable BGP with v6 link-local only\n" |
2705 | "Member of the peer-group\n" | |
16cedbb0 | 2706 | "Peer-group name\n") |
4c48cf63 | 2707 | { |
c500ae40 | 2708 | int idx_word = 1; |
31500417 DW |
2709 | int idx_peer_group_word = 5; |
2710 | ||
2711 | if (argc > idx_peer_group_word) | |
2712 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2713 | argv[idx_peer_group_word]->arg, NULL); | |
2714 | ||
c500ae40 | 2715 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, |
31500417 | 2716 | NULL, NULL); |
4c48cf63 DW |
2717 | } |
2718 | ||
a80beece | 2719 | |
b3a39dc5 DD |
2720 | DEFUN (neighbor_interface_config_remote_as, |
2721 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2722 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2723 | NEIGHBOR_STR |
2724 | "Interface name or neighbor tag\n" | |
2725 | "Enable BGP on interface\n" | |
3a2d747c | 2726 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2727 | AS_STR |
3a2d747c QY |
2728 | "Internal BGP peer\n" |
2729 | "External BGP peer\n") | |
b3a39dc5 | 2730 | { |
c500ae40 DW |
2731 | int idx_word = 1; |
2732 | int idx_remote_as = 4; | |
2733 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2734 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2735 | } |
2736 | ||
2737 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
2738 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 2739 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2740 | NEIGHBOR_STR |
2741 | "Interface name or neighbor tag\n" | |
3a2d747c | 2742 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 2743 | "Enable BGP on interface\n" |
3a2d747c | 2744 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2745 | AS_STR |
3a2d747c QY |
2746 | "Internal BGP peer\n" |
2747 | "External BGP peer\n") | |
b3a39dc5 | 2748 | { |
c500ae40 DW |
2749 | int idx_word = 1; |
2750 | int idx_remote_as = 5; | |
2751 | return peer_conf_interface_get (vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2752 | NULL, argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2753 | } |
2754 | ||
718e3744 | 2755 | DEFUN (neighbor_peer_group, |
2756 | neighbor_peer_group_cmd, | |
2757 | "neighbor WORD peer-group", | |
2758 | NEIGHBOR_STR | |
a80beece | 2759 | "Interface name or neighbor tag\n" |
718e3744 | 2760 | "Configure peer-group\n") |
2761 | { | |
cdc2d765 | 2762 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2763 | int idx_word = 1; |
a80beece | 2764 | struct peer *peer; |
718e3744 | 2765 | struct peer_group *group; |
2766 | ||
c500ae40 | 2767 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
2768 | if (peer) |
2769 | { | |
2770 | vty_out (vty, "%% Name conflict with interface: %s", VTY_NEWLINE); | |
2771 | return CMD_WARNING; | |
2772 | } | |
718e3744 | 2773 | |
c500ae40 | 2774 | group = peer_group_get (bgp, argv[idx_word]->arg); |
718e3744 | 2775 | if (! group) |
2776 | return CMD_WARNING; | |
2777 | ||
2778 | return CMD_SUCCESS; | |
2779 | } | |
2780 | ||
2781 | DEFUN (no_neighbor, | |
2782 | no_neighbor_cmd, | |
a636c635 | 2783 | "no neighbor <A.B.C.D|X:X::X:X|WORD> [remote-as <(1-4294967295)|internal|external>]", |
718e3744 | 2784 | NO_STR |
2785 | NEIGHBOR_STR | |
3a2d747c QY |
2786 | NEIGHBOR_ADDR_STR2 |
2787 | "Specify a BGP neighbor\n" | |
2788 | AS_STR | |
2789 | "Internal BGP peer\n" | |
2790 | "External BGP peer\n") | |
718e3744 | 2791 | { |
cdc2d765 | 2792 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2793 | int idx_peer = 2; |
718e3744 | 2794 | int ret; |
2795 | union sockunion su; | |
2796 | struct peer_group *group; | |
2797 | struct peer *peer; | |
1ff9a340 | 2798 | struct peer *other; |
718e3744 | 2799 | |
c500ae40 | 2800 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 2801 | if (ret < 0) |
2802 | { | |
a80beece | 2803 | /* look up for neighbor by interface name config. */ |
cdc2d765 | 2804 | peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); |
a80beece DS |
2805 | if (peer) |
2806 | { | |
4a04e5f7 | 2807 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
2808 | if (peer->ifp) | |
2809 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
2810 | peer_delete (peer); |
2811 | return CMD_SUCCESS; | |
2812 | } | |
2813 | ||
cdc2d765 | 2814 | group = peer_group_lookup (bgp, argv[idx_peer]->arg); |
718e3744 | 2815 | if (group) |
2816 | peer_group_delete (group); | |
2817 | else | |
2818 | { | |
2819 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
2820 | return CMD_WARNING; | |
2821 | } | |
2822 | } | |
2823 | else | |
2824 | { | |
cdc2d765 | 2825 | peer = peer_lookup (bgp, &su); |
718e3744 | 2826 | if (peer) |
1ff9a340 | 2827 | { |
f14e6fdb DS |
2828 | if (peer_dynamic_neighbor (peer)) |
2829 | { | |
2830 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
2831 | VTY_NEWLINE); | |
2832 | return CMD_WARNING; | |
2833 | } | |
2834 | ||
1ff9a340 DS |
2835 | other = peer->doppelganger; |
2836 | peer_delete (peer); | |
2837 | if (other && other->status != Deleted) | |
2838 | peer_delete(other); | |
2839 | } | |
718e3744 | 2840 | } |
2841 | ||
2842 | return CMD_SUCCESS; | |
2843 | } | |
2844 | ||
a80beece DS |
2845 | DEFUN (no_neighbor_interface_config, |
2846 | no_neighbor_interface_config_cmd, | |
31500417 | 2847 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
2848 | NO_STR |
2849 | NEIGHBOR_STR | |
2850 | "Interface name\n" | |
31500417 DW |
2851 | "Configure BGP on interface\n" |
2852 | "Enable BGP with v6 link-local only\n" | |
2853 | "Member of the peer-group\n" | |
16cedbb0 | 2854 | "Peer-group name\n" |
3a2d747c QY |
2855 | "Specify a BGP neighbor\n" |
2856 | AS_STR | |
2857 | "Internal BGP peer\n" | |
2858 | "External BGP peer\n") | |
a80beece | 2859 | { |
cdc2d765 | 2860 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2861 | int idx_word = 2; |
a80beece DS |
2862 | struct peer *peer; |
2863 | ||
2864 | /* look up for neighbor by interface name config. */ | |
cdc2d765 | 2865 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
2866 | if (peer) |
2867 | { | |
4a04e5f7 | 2868 | /* Request zebra to terminate IPv6 RAs on this interface. */ |
2869 | if (peer->ifp) | |
2870 | bgp_zebra_terminate_radv (peer->bgp, peer); | |
a80beece DS |
2871 | peer_delete (peer); |
2872 | } | |
2873 | else | |
2874 | { | |
2875 | vty_out (vty, "%% Create the bgp interface first%s", VTY_NEWLINE); | |
2876 | return CMD_WARNING; | |
2877 | } | |
2878 | return CMD_SUCCESS; | |
2879 | } | |
2880 | ||
718e3744 | 2881 | DEFUN (no_neighbor_peer_group, |
2882 | no_neighbor_peer_group_cmd, | |
2883 | "no neighbor WORD peer-group", | |
2884 | NO_STR | |
2885 | NEIGHBOR_STR | |
2886 | "Neighbor tag\n" | |
2887 | "Configure peer-group\n") | |
2888 | { | |
cdc2d765 | 2889 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2890 | int idx_word = 2; |
718e3744 | 2891 | struct peer_group *group; |
2892 | ||
cdc2d765 | 2893 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 2894 | if (group) |
2895 | peer_group_delete (group); | |
2896 | else | |
2897 | { | |
2898 | vty_out (vty, "%% Create the peer-group first%s", VTY_NEWLINE); | |
2899 | return CMD_WARNING; | |
2900 | } | |
2901 | return CMD_SUCCESS; | |
2902 | } | |
2903 | ||
a80beece DS |
2904 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
2905 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 2906 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2907 | NO_STR |
2908 | NEIGHBOR_STR | |
a80beece | 2909 | "Interface name or neighbor tag\n" |
718e3744 | 2910 | "Specify a BGP neighbor\n" |
3a2d747c QY |
2911 | AS_STR |
2912 | "Internal BGP peer\n" | |
2913 | "External BGP peer\n") | |
718e3744 | 2914 | { |
cdc2d765 | 2915 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 2916 | int idx_word = 2; |
718e3744 | 2917 | struct peer_group *group; |
a80beece DS |
2918 | struct peer *peer; |
2919 | ||
2920 | /* look up for neighbor by interface name config. */ | |
cdc2d765 | 2921 | peer = peer_lookup_by_conf_if (bgp, argv[idx_word]->arg); |
a80beece DS |
2922 | if (peer) |
2923 | { | |
0299c004 | 2924 | peer_as_change (peer, 0, AS_SPECIFIED); |
a80beece DS |
2925 | return CMD_SUCCESS; |
2926 | } | |
718e3744 | 2927 | |
cdc2d765 | 2928 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 2929 | if (group) |
2930 | peer_group_remote_as_delete (group); | |
2931 | else | |
2932 | { | |
a80beece | 2933 | vty_out (vty, "%% Create the peer-group or interface first%s", VTY_NEWLINE); |
718e3744 | 2934 | return CMD_WARNING; |
2935 | } | |
2936 | return CMD_SUCCESS; | |
2937 | } | |
6b0655a2 | 2938 | |
718e3744 | 2939 | DEFUN (neighbor_local_as, |
2940 | neighbor_local_as_cmd, | |
9ccf14f7 | 2941 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 2942 | NEIGHBOR_STR |
2943 | NEIGHBOR_ADDR_STR2 | |
2944 | "Specify a local-as number\n" | |
2945 | "AS number used as local AS\n") | |
2946 | { | |
c500ae40 DW |
2947 | int idx_peer = 1; |
2948 | int idx_number = 3; | |
718e3744 | 2949 | struct peer *peer; |
2950 | int ret; | |
2951 | ||
c500ae40 | 2952 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 2953 | if (! peer) |
2954 | return CMD_WARNING; | |
2955 | ||
c500ae40 | 2956 | ret = peer_local_as_set (peer, atoi (argv[idx_number]->arg), 0, 0); |
718e3744 | 2957 | return bgp_vty_return (vty, ret); |
2958 | } | |
2959 | ||
2960 | DEFUN (neighbor_local_as_no_prepend, | |
2961 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 2962 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 2963 | NEIGHBOR_STR |
2964 | NEIGHBOR_ADDR_STR2 | |
2965 | "Specify a local-as number\n" | |
2966 | "AS number used as local AS\n" | |
2967 | "Do not prepend local-as to updates from ebgp peers\n") | |
2968 | { | |
c500ae40 DW |
2969 | int idx_peer = 1; |
2970 | int idx_number = 3; | |
718e3744 | 2971 | struct peer *peer; |
2972 | int ret; | |
2973 | ||
c500ae40 | 2974 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 2975 | if (! peer) |
2976 | return CMD_WARNING; | |
2977 | ||
c500ae40 | 2978 | ret = peer_local_as_set (peer, atoi (argv[idx_number]->arg), 1, 0); |
718e3744 | 2979 | return bgp_vty_return (vty, ret); |
2980 | } | |
2981 | ||
9d3f9705 AC |
2982 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
2983 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 2984 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
2985 | NEIGHBOR_STR |
2986 | NEIGHBOR_ADDR_STR2 | |
2987 | "Specify a local-as number\n" | |
2988 | "AS number used as local AS\n" | |
2989 | "Do not prepend local-as to updates from ebgp peers\n" | |
2990 | "Do not prepend local-as to updates from ibgp peers\n") | |
2991 | { | |
c500ae40 DW |
2992 | int idx_peer = 1; |
2993 | int idx_number = 3; | |
9d3f9705 AC |
2994 | struct peer *peer; |
2995 | int ret; | |
2996 | ||
c500ae40 | 2997 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
9d3f9705 AC |
2998 | if (! peer) |
2999 | return CMD_WARNING; | |
3000 | ||
c500ae40 | 3001 | ret = peer_local_as_set (peer, atoi (argv[idx_number]->arg), 1, 1); |
9d3f9705 AC |
3002 | return bgp_vty_return (vty, ret); |
3003 | } | |
3004 | ||
718e3744 | 3005 | DEFUN (no_neighbor_local_as, |
3006 | no_neighbor_local_as_cmd, | |
a636c635 | 3007 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3008 | NO_STR |
3009 | NEIGHBOR_STR | |
3010 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3011 | "Specify a local-as number\n" |
3012 | "AS number used as local AS\n" | |
3013 | "Do not prepend local-as to updates from ebgp peers\n" | |
3014 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3015 | { |
c500ae40 | 3016 | int idx_peer = 2; |
718e3744 | 3017 | struct peer *peer; |
3018 | int ret; | |
3019 | ||
c500ae40 | 3020 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3021 | if (! peer) |
3022 | return CMD_WARNING; | |
3023 | ||
3024 | ret = peer_local_as_unset (peer); | |
3025 | return bgp_vty_return (vty, ret); | |
3026 | } | |
3027 | ||
718e3744 | 3028 | |
9d3f9705 | 3029 | |
6b0655a2 | 3030 | |
3f9c7369 DS |
3031 | DEFUN (neighbor_solo, |
3032 | neighbor_solo_cmd, | |
9ccf14f7 | 3033 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3034 | NEIGHBOR_STR |
3035 | NEIGHBOR_ADDR_STR2 | |
3036 | "Solo peer - part of its own update group\n") | |
3037 | { | |
c500ae40 | 3038 | int idx_peer = 1; |
3f9c7369 DS |
3039 | struct peer *peer; |
3040 | int ret; | |
3041 | ||
c500ae40 | 3042 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3043 | if (! peer) |
3044 | return CMD_WARNING; | |
3045 | ||
3046 | ret = update_group_adjust_soloness(peer, 1); | |
3047 | return bgp_vty_return (vty, ret); | |
3048 | } | |
3049 | ||
3050 | DEFUN (no_neighbor_solo, | |
3051 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3052 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3053 | NO_STR |
3054 | NEIGHBOR_STR | |
3055 | NEIGHBOR_ADDR_STR2 | |
3056 | "Solo peer - part of its own update group\n") | |
3057 | { | |
c500ae40 | 3058 | int idx_peer = 2; |
3f9c7369 DS |
3059 | struct peer *peer; |
3060 | int ret; | |
3061 | ||
c500ae40 | 3062 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
3f9c7369 DS |
3063 | if (! peer) |
3064 | return CMD_WARNING; | |
3065 | ||
3066 | ret = update_group_adjust_soloness(peer, 0); | |
3067 | return bgp_vty_return (vty, ret); | |
3068 | } | |
3069 | ||
0df7c91f PJ |
3070 | DEFUN (neighbor_password, |
3071 | neighbor_password_cmd, | |
9ccf14f7 | 3072 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3073 | NEIGHBOR_STR |
3074 | NEIGHBOR_ADDR_STR2 | |
3075 | "Set a password\n" | |
3076 | "The password\n") | |
3077 | { | |
c500ae40 DW |
3078 | int idx_peer = 1; |
3079 | int idx_line = 3; | |
0df7c91f PJ |
3080 | struct peer *peer; |
3081 | int ret; | |
3082 | ||
c500ae40 | 3083 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3084 | if (! peer) |
3085 | return CMD_WARNING; | |
3086 | ||
c500ae40 | 3087 | ret = peer_password_set (peer, argv[idx_line]->arg); |
0df7c91f PJ |
3088 | return bgp_vty_return (vty, ret); |
3089 | } | |
3090 | ||
3091 | DEFUN (no_neighbor_password, | |
3092 | no_neighbor_password_cmd, | |
a636c635 | 3093 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3094 | NO_STR |
3095 | NEIGHBOR_STR | |
3096 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3097 | "Set a password\n" |
3098 | "The password\n") | |
0df7c91f | 3099 | { |
c500ae40 | 3100 | int idx_peer = 2; |
0df7c91f PJ |
3101 | struct peer *peer; |
3102 | int ret; | |
3103 | ||
c500ae40 | 3104 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
0df7c91f PJ |
3105 | if (! peer) |
3106 | return CMD_WARNING; | |
3107 | ||
3108 | ret = peer_password_unset (peer); | |
3109 | return bgp_vty_return (vty, ret); | |
3110 | } | |
6b0655a2 | 3111 | |
813d4307 | 3112 | |
718e3744 | 3113 | DEFUN (neighbor_activate, |
3114 | neighbor_activate_cmd, | |
9ccf14f7 | 3115 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3116 | NEIGHBOR_STR |
3117 | NEIGHBOR_ADDR_STR2 | |
3118 | "Enable the Address Family for this Neighbor\n") | |
3119 | { | |
c500ae40 | 3120 | int idx_peer = 1; |
c8560b44 | 3121 | int ret; |
718e3744 | 3122 | struct peer *peer; |
3123 | ||
c500ae40 | 3124 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3125 | if (! peer) |
3126 | return CMD_WARNING; | |
3127 | ||
c8560b44 | 3128 | ret = peer_activate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 3129 | |
c8560b44 DW |
3130 | if (ret) |
3131 | return CMD_WARNING; | |
718e3744 | 3132 | return CMD_SUCCESS; |
3133 | } | |
3134 | ||
3135 | DEFUN (no_neighbor_activate, | |
3136 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3137 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3138 | NO_STR |
3139 | NEIGHBOR_STR | |
3140 | NEIGHBOR_ADDR_STR2 | |
3141 | "Enable the Address Family for this Neighbor\n") | |
3142 | { | |
c500ae40 | 3143 | int idx_peer = 2; |
718e3744 | 3144 | int ret; |
3145 | struct peer *peer; | |
3146 | ||
3147 | /* Lookup peer. */ | |
c500ae40 | 3148 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3149 | if (! peer) |
3150 | return CMD_WARNING; | |
3151 | ||
3152 | ret = peer_deactivate (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
3153 | ||
c8560b44 DW |
3154 | if (ret) |
3155 | return CMD_WARNING; | |
3156 | return CMD_SUCCESS; | |
718e3744 | 3157 | } |
6b0655a2 | 3158 | |
718e3744 | 3159 | DEFUN (neighbor_set_peer_group, |
3160 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3161 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3162 | NEIGHBOR_STR |
a80beece | 3163 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3164 | "Member of the peer-group\n" |
16cedbb0 | 3165 | "Peer-group name\n") |
718e3744 | 3166 | { |
cdc2d765 | 3167 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
3168 | int idx_peer = 1; |
3169 | int idx_word = 3; | |
718e3744 | 3170 | int ret; |
3171 | as_t as; | |
3172 | union sockunion su; | |
a80beece | 3173 | struct peer *peer; |
718e3744 | 3174 | struct peer_group *group; |
3175 | ||
a80beece | 3176 | peer = NULL; |
718e3744 | 3177 | |
c500ae40 | 3178 | ret = str2sockunion (argv[idx_peer]->arg, &su); |
718e3744 | 3179 | if (ret < 0) |
3180 | { | |
c500ae40 | 3181 | peer = peer_lookup_by_conf_if (bgp, argv[idx_peer]->arg); |
a80beece DS |
3182 | if (!peer) |
3183 | { | |
c500ae40 | 3184 | vty_out (vty, "%% Malformed address or name: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); |
a80beece DS |
3185 | return CMD_WARNING; |
3186 | } | |
3187 | } | |
3188 | else | |
3189 | { | |
6aeb9e78 | 3190 | if (peer_address_self_check (bgp, &su)) |
a80beece DS |
3191 | { |
3192 | vty_out (vty, "%% Can not configure the local system as neighbor%s", | |
3193 | VTY_NEWLINE); | |
3194 | return CMD_WARNING; | |
3195 | } | |
f14e6fdb DS |
3196 | |
3197 | /* Disallow for dynamic neighbor. */ | |
3198 | peer = peer_lookup (bgp, &su); | |
3199 | if (peer && peer_dynamic_neighbor (peer)) | |
3200 | { | |
3201 | vty_out (vty, "%% Operation not allowed on a dynamic neighbor%s", | |
3202 | VTY_NEWLINE); | |
3203 | return CMD_WARNING; | |
3204 | } | |
718e3744 | 3205 | } |
3206 | ||
c500ae40 | 3207 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3208 | if (! group) |
3209 | { | |
3210 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3211 | return CMD_WARNING; | |
3212 | } | |
3213 | ||
c8560b44 | 3214 | ret = peer_group_bind (bgp, &su, peer, group, &as); |
718e3744 | 3215 | |
3216 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) | |
3217 | { | |
aea339f7 | 3218 | 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 | 3219 | return CMD_WARNING; |
3220 | } | |
3221 | ||
3222 | return bgp_vty_return (vty, ret); | |
3223 | } | |
3224 | ||
3225 | DEFUN (no_neighbor_set_peer_group, | |
3226 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3227 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3228 | NO_STR |
3229 | NEIGHBOR_STR | |
a80beece | 3230 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3231 | "Member of the peer-group\n" |
16cedbb0 | 3232 | "Peer-group name\n") |
718e3744 | 3233 | { |
cdc2d765 | 3234 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
3235 | int idx_peer = 2; |
3236 | int idx_word = 4; | |
718e3744 | 3237 | int ret; |
718e3744 | 3238 | struct peer *peer; |
3239 | struct peer_group *group; | |
3240 | ||
c500ae40 | 3241 | peer = peer_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3242 | if (! peer) |
3243 | return CMD_WARNING; | |
3244 | ||
c500ae40 | 3245 | group = peer_group_lookup (bgp, argv[idx_word]->arg); |
718e3744 | 3246 | if (! group) |
3247 | { | |
3248 | vty_out (vty, "%% Configure the peer-group first%s", VTY_NEWLINE); | |
3249 | return CMD_WARNING; | |
3250 | } | |
3251 | ||
c8560b44 | 3252 | ret = peer_group_unbind (bgp, peer, group); |
718e3744 | 3253 | |
3254 | return bgp_vty_return (vty, ret); | |
3255 | } | |
6b0655a2 | 3256 | |
94f2b392 | 3257 | static int |
e52702f2 | 3258 | peer_flag_modify_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 3259 | u_int16_t flag, int set) |
718e3744 | 3260 | { |
3261 | int ret; | |
3262 | struct peer *peer; | |
3263 | ||
3264 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
3265 | if (! peer) | |
3266 | return CMD_WARNING; | |
3267 | ||
8cdabf90 SK |
3268 | /* |
3269 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3270 | * we should not accept disable-connected-check. | |
3271 | */ | |
3272 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3273 | vty_out (vty, "%s is directly connected peer, cannot accept disable-" | |
3274 | "connected-check%s", ip_str, VTY_NEWLINE); | |
3275 | return CMD_WARNING; | |
3276 | } | |
3277 | ||
718e3744 | 3278 | if (set) |
3279 | ret = peer_flag_set (peer, flag); | |
3280 | else | |
3281 | ret = peer_flag_unset (peer, flag); | |
3282 | ||
3283 | return bgp_vty_return (vty, ret); | |
3284 | } | |
3285 | ||
94f2b392 | 3286 | static int |
fd79ac91 | 3287 | peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3288 | { |
3289 | return peer_flag_modify_vty (vty, ip_str, flag, 1); | |
3290 | } | |
3291 | ||
94f2b392 | 3292 | static int |
fd79ac91 | 3293 | peer_flag_unset_vty (struct vty *vty, const char *ip_str, u_int16_t flag) |
718e3744 | 3294 | { |
3295 | return peer_flag_modify_vty (vty, ip_str, flag, 0); | |
3296 | } | |
3297 | ||
3298 | /* neighbor passive. */ | |
3299 | DEFUN (neighbor_passive, | |
3300 | neighbor_passive_cmd, | |
9ccf14f7 | 3301 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3302 | NEIGHBOR_STR |
3303 | NEIGHBOR_ADDR_STR2 | |
3304 | "Don't send open messages to this neighbor\n") | |
3305 | { | |
c500ae40 DW |
3306 | int idx_peer = 1; |
3307 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3308 | } |
3309 | ||
3310 | DEFUN (no_neighbor_passive, | |
3311 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3312 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3313 | NO_STR |
3314 | NEIGHBOR_STR | |
3315 | NEIGHBOR_ADDR_STR2 | |
3316 | "Don't send open messages to this neighbor\n") | |
3317 | { | |
c500ae40 DW |
3318 | int idx_peer = 2; |
3319 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3320 | } |
6b0655a2 | 3321 | |
718e3744 | 3322 | /* neighbor shutdown. */ |
3323 | DEFUN (neighbor_shutdown, | |
3324 | neighbor_shutdown_cmd, | |
9ccf14f7 | 3325 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
718e3744 | 3326 | NEIGHBOR_STR |
3327 | NEIGHBOR_ADDR_STR2 | |
3328 | "Administratively shut down this neighbor\n") | |
3329 | { | |
c500ae40 DW |
3330 | int idx_peer = 1; |
3331 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); | |
718e3744 | 3332 | } |
3333 | ||
3334 | DEFUN (no_neighbor_shutdown, | |
3335 | no_neighbor_shutdown_cmd, | |
9ccf14f7 | 3336 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", |
718e3744 | 3337 | NO_STR |
3338 | NEIGHBOR_STR | |
3339 | NEIGHBOR_ADDR_STR2 | |
3340 | "Administratively shut down this neighbor\n") | |
3341 | { | |
c500ae40 DW |
3342 | int idx_peer = 2; |
3343 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); | |
718e3744 | 3344 | } |
6b0655a2 | 3345 | |
718e3744 | 3346 | /* neighbor capability dynamic. */ |
3347 | DEFUN (neighbor_capability_dynamic, | |
3348 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3349 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3350 | NEIGHBOR_STR |
3351 | NEIGHBOR_ADDR_STR2 | |
3352 | "Advertise capability to the peer\n" | |
3353 | "Advertise dynamic capability to this neighbor\n") | |
3354 | { | |
c500ae40 DW |
3355 | int idx_peer = 1; |
3356 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3357 | } |
3358 | ||
3359 | DEFUN (no_neighbor_capability_dynamic, | |
3360 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3361 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3362 | NO_STR |
3363 | NEIGHBOR_STR | |
3364 | NEIGHBOR_ADDR_STR2 | |
3365 | "Advertise capability to the peer\n" | |
3366 | "Advertise dynamic capability to this neighbor\n") | |
3367 | { | |
c500ae40 DW |
3368 | int idx_peer = 2; |
3369 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3370 | } |
6b0655a2 | 3371 | |
718e3744 | 3372 | /* neighbor dont-capability-negotiate */ |
3373 | DEFUN (neighbor_dont_capability_negotiate, | |
3374 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3375 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3376 | NEIGHBOR_STR |
3377 | NEIGHBOR_ADDR_STR2 | |
3378 | "Do not perform capability negotiation\n") | |
3379 | { | |
c500ae40 DW |
3380 | int idx_peer = 1; |
3381 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3382 | } |
3383 | ||
3384 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3385 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3386 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3387 | NO_STR |
3388 | NEIGHBOR_STR | |
3389 | NEIGHBOR_ADDR_STR2 | |
3390 | "Do not perform capability negotiation\n") | |
3391 | { | |
c500ae40 DW |
3392 | int idx_peer = 2; |
3393 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3394 | } |
6b0655a2 | 3395 | |
8a92a8a0 DS |
3396 | /* neighbor capability extended next hop encoding */ |
3397 | DEFUN (neighbor_capability_enhe, | |
3398 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3399 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3400 | NEIGHBOR_STR |
3401 | NEIGHBOR_ADDR_STR2 | |
3402 | "Advertise capability to the peer\n" | |
3403 | "Advertise extended next-hop capability to the peer\n") | |
3404 | { | |
c500ae40 DW |
3405 | int idx_peer = 1; |
3406 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3407 | } |
3408 | ||
3409 | DEFUN (no_neighbor_capability_enhe, | |
3410 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3411 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3412 | NO_STR |
3413 | NEIGHBOR_STR | |
3414 | NEIGHBOR_ADDR_STR2 | |
3415 | "Advertise capability to the peer\n" | |
3416 | "Advertise extended next-hop capability to the peer\n") | |
3417 | { | |
c500ae40 DW |
3418 | int idx_peer = 2; |
3419 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3420 | } |
3421 | ||
94f2b392 | 3422 | static int |
fd79ac91 | 3423 | peer_af_flag_modify_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3424 | safi_t safi, u_int32_t flag, int set) |
718e3744 | 3425 | { |
3426 | int ret; | |
3427 | struct peer *peer; | |
3428 | ||
3429 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
3430 | if (! peer) | |
3431 | return CMD_WARNING; | |
3432 | ||
3433 | if (set) | |
3434 | ret = peer_af_flag_set (peer, afi, safi, flag); | |
3435 | else | |
3436 | ret = peer_af_flag_unset (peer, afi, safi, flag); | |
3437 | ||
3438 | return bgp_vty_return (vty, ret); | |
3439 | } | |
3440 | ||
94f2b392 | 3441 | static int |
fd79ac91 | 3442 | peer_af_flag_set_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3443 | safi_t safi, u_int32_t flag) |
718e3744 | 3444 | { |
3445 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 1); | |
3446 | } | |
3447 | ||
94f2b392 | 3448 | static int |
fd79ac91 | 3449 | peer_af_flag_unset_vty (struct vty *vty, const char *peer_str, afi_t afi, |
fee0f4c6 | 3450 | safi_t safi, u_int32_t flag) |
718e3744 | 3451 | { |
3452 | return peer_af_flag_modify_vty (vty, peer_str, afi, safi, flag, 0); | |
3453 | } | |
6b0655a2 | 3454 | |
718e3744 | 3455 | /* neighbor capability orf prefix-list. */ |
3456 | DEFUN (neighbor_capability_orf_prefix, | |
3457 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3458 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3459 | NEIGHBOR_STR |
3460 | NEIGHBOR_ADDR_STR2 | |
3461 | "Advertise capability to the peer\n" | |
3462 | "Advertise ORF capability to the peer\n" | |
3463 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3464 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3465 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3466 | "Capability to SEND the ORF to this neighbor\n") | |
3467 | { | |
c500ae40 DW |
3468 | int idx_peer = 1; |
3469 | int idx_send_recv = 5; | |
718e3744 | 3470 | u_int16_t flag = 0; |
3471 | ||
c500ae40 | 3472 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3473 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3474 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3475 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3476 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3477 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3478 | else | |
3479 | return CMD_WARNING; | |
3480 | ||
c500ae40 | 3481 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3482 | bgp_node_safi (vty), flag); |
3483 | } | |
3484 | ||
3485 | DEFUN (no_neighbor_capability_orf_prefix, | |
3486 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3487 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3488 | NO_STR |
3489 | NEIGHBOR_STR | |
3490 | NEIGHBOR_ADDR_STR2 | |
3491 | "Advertise capability to the peer\n" | |
3492 | "Advertise ORF capability to the peer\n" | |
3493 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3494 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3495 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3496 | "Capability to SEND the ORF to this neighbor\n") | |
3497 | { | |
c500ae40 DW |
3498 | int idx_peer = 2; |
3499 | int idx_send_recv = 6; | |
718e3744 | 3500 | u_int16_t flag = 0; |
3501 | ||
c500ae40 | 3502 | if (strncmp (argv[idx_send_recv]->arg, "s", 1) == 0) |
718e3744 | 3503 | flag = PEER_FLAG_ORF_PREFIX_SM; |
c500ae40 | 3504 | else if (strncmp (argv[idx_send_recv]->arg, "r", 1) == 0) |
718e3744 | 3505 | flag = PEER_FLAG_ORF_PREFIX_RM; |
c500ae40 | 3506 | else if (strncmp (argv[idx_send_recv]->arg, "b", 1) == 0) |
718e3744 | 3507 | flag = PEER_FLAG_ORF_PREFIX_SM|PEER_FLAG_ORF_PREFIX_RM; |
3508 | else | |
3509 | return CMD_WARNING; | |
3510 | ||
c500ae40 | 3511 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3512 | bgp_node_safi (vty), flag); |
3513 | } | |
6b0655a2 | 3514 | |
718e3744 | 3515 | /* neighbor next-hop-self. */ |
3516 | DEFUN (neighbor_nexthop_self, | |
3517 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3518 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3519 | NEIGHBOR_STR |
3520 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3521 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3522 | { |
c500ae40 DW |
3523 | int idx_peer = 1; |
3524 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
a538debe DS |
3525 | bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF); |
3526 | } | |
9e7a53c1 | 3527 | |
a538debe DS |
3528 | /* neighbor next-hop-self. */ |
3529 | DEFUN (neighbor_nexthop_self_force, | |
3530 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3531 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3532 | NEIGHBOR_STR |
3533 | NEIGHBOR_ADDR_STR2 | |
3534 | "Disable the next hop calculation for this neighbor\n" | |
3535 | "Set the next hop to self for reflected routes\n") | |
3536 | { | |
c500ae40 DW |
3537 | int idx_peer = 1; |
3538 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
a538debe | 3539 | bgp_node_safi (vty), |
88b8ed8d | 3540 | PEER_FLAG_FORCE_NEXTHOP_SELF); |
718e3744 | 3541 | } |
3542 | ||
3543 | DEFUN (no_neighbor_nexthop_self, | |
3544 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3545 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3546 | NO_STR |
3547 | NEIGHBOR_STR | |
3548 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3549 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3550 | { |
c500ae40 DW |
3551 | int idx_peer = 2; |
3552 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
9e7a53c1 | 3553 | bgp_node_safi (vty), |
88b8ed8d | 3554 | PEER_FLAG_NEXTHOP_SELF); |
718e3744 | 3555 | } |
6b0655a2 | 3556 | |
88b8ed8d | 3557 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3558 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3559 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3560 | NO_STR |
3561 | NEIGHBOR_STR | |
3562 | NEIGHBOR_ADDR_STR2 | |
3563 | "Disable the next hop calculation for this neighbor\n" | |
3564 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3565 | { |
c500ae40 DW |
3566 | int idx_peer = 2; |
3567 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3568 | bgp_node_safi (vty), |
3569 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
3570 | } | |
a538debe | 3571 | |
c7122e14 DS |
3572 | /* neighbor as-override */ |
3573 | DEFUN (neighbor_as_override, | |
3574 | neighbor_as_override_cmd, | |
9ccf14f7 | 3575 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3576 | NEIGHBOR_STR |
3577 | NEIGHBOR_ADDR_STR2 | |
3578 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3579 | { | |
c500ae40 DW |
3580 | int idx_peer = 1; |
3581 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3582 | bgp_node_safi (vty), |
3583 | PEER_FLAG_AS_OVERRIDE); | |
3584 | } | |
3585 | ||
3586 | DEFUN (no_neighbor_as_override, | |
3587 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3588 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3589 | NO_STR |
3590 | NEIGHBOR_STR | |
3591 | NEIGHBOR_ADDR_STR2 | |
3592 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3593 | { | |
c500ae40 DW |
3594 | int idx_peer = 2; |
3595 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
c7122e14 DS |
3596 | bgp_node_safi (vty), |
3597 | PEER_FLAG_AS_OVERRIDE); | |
3598 | } | |
3599 | ||
718e3744 | 3600 | /* neighbor remove-private-AS. */ |
3601 | DEFUN (neighbor_remove_private_as, | |
3602 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3603 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3604 | NEIGHBOR_STR |
3605 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3606 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3607 | { |
c500ae40 DW |
3608 | int idx_peer = 1; |
3609 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3610 | bgp_node_safi (vty), |
3611 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
3612 | } | |
3613 | ||
5000f21c DS |
3614 | DEFUN (neighbor_remove_private_as_all, |
3615 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 3616 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3617 | NEIGHBOR_STR |
3618 | NEIGHBOR_ADDR_STR2 | |
3619 | "Remove private ASNs in outbound updates\n" | |
3620 | "Apply to all AS numbers") | |
3621 | { | |
c500ae40 DW |
3622 | int idx_peer = 1; |
3623 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3624 | bgp_node_safi (vty), |
5000f21c DS |
3625 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); |
3626 | } | |
3627 | ||
3628 | DEFUN (neighbor_remove_private_as_replace_as, | |
3629 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 3630 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3631 | NEIGHBOR_STR |
3632 | NEIGHBOR_ADDR_STR2 | |
3633 | "Remove private ASNs in outbound updates\n" | |
3634 | "Replace private ASNs with our ASN in outbound updates\n") | |
3635 | { | |
c500ae40 DW |
3636 | int idx_peer = 1; |
3637 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3638 | bgp_node_safi (vty), |
5000f21c DS |
3639 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); |
3640 | } | |
3641 | ||
3642 | DEFUN (neighbor_remove_private_as_all_replace_as, | |
3643 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 3644 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3645 | NEIGHBOR_STR |
3646 | NEIGHBOR_ADDR_STR2 | |
3647 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3648 | "Apply to all AS numbers\n" |
5000f21c DS |
3649 | "Replace private ASNs with our ASN in outbound updates\n") |
3650 | { | |
c500ae40 DW |
3651 | int idx_peer = 1; |
3652 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5000f21c | 3653 | bgp_node_safi (vty), |
88b8ed8d | 3654 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); |
5000f21c DS |
3655 | } |
3656 | ||
718e3744 | 3657 | DEFUN (no_neighbor_remove_private_as, |
3658 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3659 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3660 | NO_STR |
3661 | NEIGHBOR_STR | |
3662 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3663 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3664 | { |
c500ae40 DW |
3665 | int idx_peer = 2; |
3666 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3667 | bgp_node_safi (vty), |
88b8ed8d | 3668 | PEER_FLAG_REMOVE_PRIVATE_AS); |
718e3744 | 3669 | } |
6b0655a2 | 3670 | |
88b8ed8d | 3671 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 3672 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 3673 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3674 | NO_STR |
3675 | NEIGHBOR_STR | |
3676 | NEIGHBOR_ADDR_STR2 | |
3677 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3678 | "Apply to all AS numbers\n") |
88b8ed8d | 3679 | { |
c500ae40 DW |
3680 | int idx_peer = 2; |
3681 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3682 | bgp_node_safi (vty), |
3683 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
3684 | } | |
5000f21c | 3685 | |
88b8ed8d | 3686 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 3687 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 3688 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3689 | NO_STR |
3690 | NEIGHBOR_STR | |
3691 | NEIGHBOR_ADDR_STR2 | |
3692 | "Remove private ASNs in outbound updates\n" | |
3693 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 3694 | { |
c500ae40 DW |
3695 | int idx_peer = 2; |
3696 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3697 | bgp_node_safi (vty), |
3698 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
3699 | } | |
5000f21c | 3700 | |
88b8ed8d | 3701 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 3702 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 3703 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3704 | NO_STR |
3705 | NEIGHBOR_STR | |
3706 | NEIGHBOR_ADDR_STR2 | |
3707 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3708 | "Apply to all AS numbers\n" |
5000f21c | 3709 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 3710 | { |
c500ae40 DW |
3711 | int idx_peer = 2; |
3712 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
88b8ed8d DW |
3713 | bgp_node_safi (vty), |
3714 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
3715 | } | |
5000f21c DS |
3716 | |
3717 | ||
718e3744 | 3718 | /* neighbor send-community. */ |
3719 | DEFUN (neighbor_send_community, | |
3720 | neighbor_send_community_cmd, | |
9ccf14f7 | 3721 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3722 | NEIGHBOR_STR |
3723 | NEIGHBOR_ADDR_STR2 | |
3724 | "Send Community attribute to this neighbor\n") | |
3725 | { | |
c500ae40 DW |
3726 | int idx_peer = 1; |
3727 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3728 | bgp_node_safi (vty), |
3729 | PEER_FLAG_SEND_COMMUNITY); | |
3730 | } | |
3731 | ||
3732 | DEFUN (no_neighbor_send_community, | |
3733 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 3734 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3735 | NO_STR |
3736 | NEIGHBOR_STR | |
3737 | NEIGHBOR_ADDR_STR2 | |
3738 | "Send Community attribute to this neighbor\n") | |
3739 | { | |
c500ae40 DW |
3740 | int idx_peer = 2; |
3741 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3742 | bgp_node_safi (vty), |
3743 | PEER_FLAG_SEND_COMMUNITY); | |
3744 | } | |
6b0655a2 | 3745 | |
718e3744 | 3746 | /* neighbor send-community extended. */ |
3747 | DEFUN (neighbor_send_community_type, | |
3748 | neighbor_send_community_type_cmd, | |
9ccf14f7 | 3749 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|extended|standard>", |
718e3744 | 3750 | NEIGHBOR_STR |
3751 | NEIGHBOR_ADDR_STR2 | |
3752 | "Send Community attribute to this neighbor\n" | |
3753 | "Send Standard and Extended Community attributes\n" | |
3754 | "Send Extended Community attributes\n" | |
3755 | "Send Standard Community attributes\n") | |
3756 | { | |
4c4ff4c1 QY |
3757 | int idx = 0; |
3758 | u_int32_t flag = 0; | |
718e3744 | 3759 | |
4c4ff4c1 QY |
3760 | char *peer = argv[1]->arg; |
3761 | ||
3762 | if (argv_find (argv, argc, "standard", &idx)) | |
3763 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3764 | else if (argv_find (argv, argc, "extended", &idx)) | |
3765 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3766 | else | |
3767 | { | |
3768 | SET_FLAG (flag, PEER_FLAG_SEND_COMMUNITY); | |
3769 | SET_FLAG (flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3770 | } | |
3771 | ||
3772 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flag); | |
718e3744 | 3773 | } |
3774 | ||
3775 | DEFUN (no_neighbor_send_community_type, | |
3776 | no_neighbor_send_community_type_cmd, | |
9ccf14f7 | 3777 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|extended|standard>", |
718e3744 | 3778 | NO_STR |
3779 | NEIGHBOR_STR | |
3780 | NEIGHBOR_ADDR_STR2 | |
3781 | "Send Community attribute to this neighbor\n" | |
3782 | "Send Standard and Extended Community attributes\n" | |
3783 | "Send Extended Community attributes\n" | |
3784 | "Send Standard Community attributes\n") | |
3785 | { | |
c500ae40 DW |
3786 | int idx_peer = 2; |
3787 | int idx_type = 4; | |
3788 | if (strncmp (argv[idx_type]->arg, "s", 1) == 0) | |
3789 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3790 | bgp_node_safi (vty), |
3791 | PEER_FLAG_SEND_COMMUNITY); | |
c500ae40 DW |
3792 | if (strncmp (argv[idx_type]->arg, "e", 1) == 0) |
3793 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3794 | bgp_node_safi (vty), |
3795 | PEER_FLAG_SEND_EXT_COMMUNITY); | |
3796 | ||
c500ae40 | 3797 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3798 | bgp_node_safi (vty), |
3799 | (PEER_FLAG_SEND_COMMUNITY | | |
3800 | PEER_FLAG_SEND_EXT_COMMUNITY)); | |
3801 | } | |
6b0655a2 | 3802 | |
718e3744 | 3803 | /* neighbor soft-reconfig. */ |
3804 | DEFUN (neighbor_soft_reconfiguration, | |
3805 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 3806 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 3807 | NEIGHBOR_STR |
3808 | NEIGHBOR_ADDR_STR2 | |
3809 | "Per neighbor soft reconfiguration\n" | |
3810 | "Allow inbound soft reconfiguration for this neighbor\n") | |
3811 | { | |
c500ae40 DW |
3812 | int idx_peer = 1; |
3813 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 3814 | bgp_node_afi (vty), bgp_node_safi (vty), |
3815 | PEER_FLAG_SOFT_RECONFIG); | |
3816 | } | |
3817 | ||
3818 | DEFUN (no_neighbor_soft_reconfiguration, | |
3819 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 3820 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 3821 | NO_STR |
3822 | NEIGHBOR_STR | |
3823 | NEIGHBOR_ADDR_STR2 | |
3824 | "Per neighbor soft reconfiguration\n" | |
3825 | "Allow inbound soft reconfiguration for this neighbor\n") | |
3826 | { | |
c500ae40 DW |
3827 | int idx_peer = 2; |
3828 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, | |
718e3744 | 3829 | bgp_node_afi (vty), bgp_node_safi (vty), |
3830 | PEER_FLAG_SOFT_RECONFIG); | |
3831 | } | |
6b0655a2 | 3832 | |
718e3744 | 3833 | DEFUN (neighbor_route_reflector_client, |
3834 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 3835 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 3836 | NEIGHBOR_STR |
3837 | NEIGHBOR_ADDR_STR2 | |
3838 | "Configure a neighbor as Route Reflector client\n") | |
3839 | { | |
c500ae40 | 3840 | int idx_peer = 1; |
718e3744 | 3841 | struct peer *peer; |
3842 | ||
3843 | ||
c500ae40 | 3844 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 3845 | if (! peer) |
3846 | return CMD_WARNING; | |
3847 | ||
c500ae40 | 3848 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
718e3744 | 3849 | bgp_node_safi (vty), |
3850 | PEER_FLAG_REFLECTOR_CLIENT); | |
3851 | } | |
3852 | ||
3853 | DEFUN (no_neighbor_route_reflector_client, | |
3854 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 3855 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 3856 | NO_STR |
3857 | NEIGHBOR_STR | |
3858 | NEIGHBOR_ADDR_STR2 | |
3859 | "Configure a neighbor as Route Reflector client\n") | |
3860 | { | |
c500ae40 DW |
3861 | int idx_peer = 2; |
3862 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3863 | bgp_node_safi (vty), |
3864 | PEER_FLAG_REFLECTOR_CLIENT); | |
3865 | } | |
6b0655a2 | 3866 | |
718e3744 | 3867 | /* neighbor route-server-client. */ |
3868 | DEFUN (neighbor_route_server_client, | |
3869 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 3870 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 3871 | NEIGHBOR_STR |
3872 | NEIGHBOR_ADDR_STR2 | |
3873 | "Configure a neighbor as Route Server client\n") | |
3874 | { | |
c500ae40 | 3875 | int idx_peer = 1; |
2a3d5731 DW |
3876 | struct peer *peer; |
3877 | ||
c500ae40 | 3878 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
2a3d5731 DW |
3879 | if (! peer) |
3880 | return CMD_WARNING; | |
c500ae40 | 3881 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
2a3d5731 DW |
3882 | bgp_node_safi (vty), |
3883 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 3884 | } |
3885 | ||
3886 | DEFUN (no_neighbor_route_server_client, | |
3887 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 3888 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 3889 | NO_STR |
3890 | NEIGHBOR_STR | |
3891 | NEIGHBOR_ADDR_STR2 | |
3892 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 3893 | { |
c500ae40 DW |
3894 | int idx_peer = 2; |
3895 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
2a3d5731 DW |
3896 | bgp_node_safi (vty), |
3897 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 3898 | } |
6b0655a2 | 3899 | |
fee0f4c6 | 3900 | DEFUN (neighbor_nexthop_local_unchanged, |
3901 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 3902 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 3903 | NEIGHBOR_STR |
3904 | NEIGHBOR_ADDR_STR2 | |
3905 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
3906 | "Leave link-local nexthop unchanged for this peer\n") | |
3907 | { | |
c500ae40 DW |
3908 | int idx_peer = 1; |
3909 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
fee0f4c6 | 3910 | bgp_node_safi (vty), |
3911 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); | |
3912 | } | |
6b0655a2 | 3913 | |
fee0f4c6 | 3914 | DEFUN (no_neighbor_nexthop_local_unchanged, |
3915 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 3916 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 3917 | NO_STR |
3918 | NEIGHBOR_STR | |
3919 | NEIGHBOR_ADDR_STR2 | |
3920 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
3921 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 3922 | { |
c500ae40 DW |
3923 | int idx_peer = 2; |
3924 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 3925 | bgp_node_safi (vty), |
fee0f4c6 | 3926 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED ); |
718e3744 | 3927 | } |
6b0655a2 | 3928 | |
718e3744 | 3929 | DEFUN (neighbor_attr_unchanged, |
3930 | neighbor_attr_unchanged_cmd, | |
1084263f QY |
3931 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
3932 | [<\ | |
ddbaf941 QY |
3933 | as-path [<next-hop [med]|med [next-hop]>]|\ |
3934 | next-hop [<as-path [med]|med [as-path]>]|\ | |
3935 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 3936 | >]", |
718e3744 | 3937 | NEIGHBOR_STR |
3938 | NEIGHBOR_ADDR_STR2 | |
3939 | "BGP attribute is propagated unchanged to this neighbor\n" | |
3940 | "As-path attribute\n" | |
3941 | "Nexthop attribute\n" | |
40e718b5 | 3942 | "Med attribute\n" |
1084263f QY |
3943 | "Med attribute\n" |
3944 | "Nexthop attribute\n" | |
3945 | "Nexthop attribute\n" | |
3946 | "As-path attribute\n" | |
3947 | "Med attribute\n" | |
40e718b5 | 3948 | "Med attribute\n" |
718e3744 | 3949 | "As-path attribute\n" |
1084263f QY |
3950 | "Med attribute\n" |
3951 | "As-path attribute\n" | |
3952 | "Nexthop attribute\n" | |
40e718b5 | 3953 | "Nexthop attribute\n" |
1084263f | 3954 | "As-path attribute\n") |
718e3744 | 3955 | { |
40e718b5 QY |
3956 | int idx = 0; |
3957 | char *peer = argv[1]->arg; | |
3958 | u_int16_t flags = 0; | |
718e3744 | 3959 | |
40e718b5 | 3960 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 3961 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
3962 | idx = 0; |
3963 | if (argv_find (argv, argc, "next-hop", &idx)) | |
3964 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
3965 | idx = 0; | |
3966 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 3967 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
3968 | ||
40e718b5 QY |
3969 | if (!flags) // no flags means all of them! |
3970 | { | |
718e3744 | 3971 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 3972 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
3973 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
3974 | } | |
718e3744 | 3975 | |
40e718b5 | 3976 | return peer_af_flag_set_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 3977 | } |
3978 | ||
718e3744 | 3979 | DEFUN (no_neighbor_attr_unchanged, |
3980 | no_neighbor_attr_unchanged_cmd, | |
1084263f QY |
3981 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged\ |
3982 | [<\ | |
ddbaf941 QY |
3983 | as-path [<next-hop [med]|med [next-hop]>]|\ |
3984 | next-hop [<as-path [med]|med [as-path]>]|\ | |
3985 | med [<as-path [next-hop]|next-hop [as-path]>]\ | |
1084263f | 3986 | >]", |
e52702f2 | 3987 | NO_STR |
718e3744 | 3988 | NEIGHBOR_STR |
3989 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
3990 | "BGP attribute is propagated unchanged to this neighbor\n" |
3991 | "As-path attribute\n" | |
40e718b5 | 3992 | "Nexthop attribute\n" |
31500417 | 3993 | "Med attribute\n" |
1084263f QY |
3994 | "Med attribute\n" |
3995 | "Nexthop attribute\n" | |
3996 | "Nexthop attribute\n" | |
3997 | "As-path attribute\n" | |
3998 | "Med attribute\n" | |
40e718b5 | 3999 | "Med attribute\n" |
718e3744 | 4000 | "As-path attribute\n" |
1084263f QY |
4001 | "Med attribute\n" |
4002 | "As-path attribute\n" | |
4003 | "Nexthop attribute\n" | |
718e3744 | 4004 | "Nexthop attribute\n" |
1084263f | 4005 | "As-path attribute\n") |
718e3744 | 4006 | { |
40e718b5 QY |
4007 | int idx = 0; |
4008 | char *peer = argv[2]->arg; | |
4009 | u_int16_t flags = 0; | |
718e3744 | 4010 | |
40e718b5 | 4011 | if (argv_find (argv, argc, "as-path", &idx)) |
718e3744 | 4012 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
40e718b5 QY |
4013 | idx = 0; |
4014 | if (argv_find (argv, argc, "next-hop", &idx)) | |
4015 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4016 | idx = 0; | |
4017 | if (argv_find (argv, argc, "med", &idx)) | |
718e3744 | 4018 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4019 | ||
40e718b5 QY |
4020 | if (!flags) // no flags means all of them! |
4021 | { | |
718e3744 | 4022 | SET_FLAG (flags, PEER_FLAG_AS_PATH_UNCHANGED); |
718e3744 | 4023 | SET_FLAG (flags, PEER_FLAG_NEXTHOP_UNCHANGED); |
40e718b5 QY |
4024 | SET_FLAG (flags, PEER_FLAG_MED_UNCHANGED); |
4025 | } | |
718e3744 | 4026 | |
40e718b5 | 4027 | return peer_af_flag_unset_vty (vty, peer, bgp_node_afi (vty), bgp_node_safi (vty), flags); |
718e3744 | 4028 | } |
4029 | ||
718e3744 | 4030 | |
718e3744 | 4031 | /* EBGP multihop configuration. */ |
94f2b392 | 4032 | static int |
e52702f2 | 4033 | peer_ebgp_multihop_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4034 | const char *ttl_str) |
718e3744 | 4035 | { |
4036 | struct peer *peer; | |
fd79ac91 | 4037 | unsigned int ttl; |
718e3744 | 4038 | |
4039 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4040 | if (! peer) | |
4041 | return CMD_WARNING; | |
4042 | ||
63fa10b5 QY |
4043 | if (peer->conf_if) |
4044 | return bgp_vty_return (vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
4045 | ||
718e3744 | 4046 | if (! ttl_str) |
9b1be336 | 4047 | ttl = MAXTTL; |
718e3744 | 4048 | else |
9b1be336 | 4049 | VTY_GET_INTEGER_RANGE ("TTL", ttl, ttl_str, 1, MAXTTL); |
718e3744 | 4050 | |
89b6d1f8 | 4051 | return bgp_vty_return (vty, peer_ebgp_multihop_set (peer, ttl)); |
718e3744 | 4052 | } |
4053 | ||
94f2b392 | 4054 | static int |
e52702f2 | 4055 | peer_ebgp_multihop_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4056 | { |
4057 | struct peer *peer; | |
4058 | ||
4059 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4060 | if (! peer) | |
4061 | return CMD_WARNING; | |
4062 | ||
89b6d1f8 | 4063 | return bgp_vty_return (vty, peer_ebgp_multihop_unset (peer)); |
718e3744 | 4064 | } |
4065 | ||
4066 | /* neighbor ebgp-multihop. */ | |
4067 | DEFUN (neighbor_ebgp_multihop, | |
4068 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4069 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4070 | NEIGHBOR_STR |
4071 | NEIGHBOR_ADDR_STR2 | |
4072 | "Allow EBGP neighbors not on directly connected networks\n") | |
4073 | { | |
c500ae40 DW |
4074 | int idx_peer = 1; |
4075 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4076 | } |
4077 | ||
4078 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4079 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4080 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4081 | NEIGHBOR_STR |
4082 | NEIGHBOR_ADDR_STR2 | |
4083 | "Allow EBGP neighbors not on directly connected networks\n" | |
4084 | "maximum hop count\n") | |
4085 | { | |
c500ae40 DW |
4086 | int idx_peer = 1; |
4087 | int idx_number = 3; | |
4088 | return peer_ebgp_multihop_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 4089 | } |
4090 | ||
4091 | DEFUN (no_neighbor_ebgp_multihop, | |
4092 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4093 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4094 | NO_STR |
4095 | NEIGHBOR_STR | |
4096 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4097 | "Allow EBGP neighbors not on directly connected networks\n" |
4098 | "maximum hop count\n") | |
718e3744 | 4099 | { |
c500ae40 DW |
4100 | int idx_peer = 2; |
4101 | return peer_ebgp_multihop_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4102 | } |
4103 | ||
6b0655a2 | 4104 | |
6ffd2079 | 4105 | /* disable-connected-check */ |
4106 | DEFUN (neighbor_disable_connected_check, | |
4107 | neighbor_disable_connected_check_cmd, | |
a636c635 | 4108 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4109 | NEIGHBOR_STR |
4110 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4111 | "one-hop away EBGP peer using loopback address\n" |
4112 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4113 | { |
c500ae40 DW |
4114 | int idx_peer = 1; |
4115 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4116 | } |
4117 | ||
4118 | DEFUN (no_neighbor_disable_connected_check, | |
4119 | no_neighbor_disable_connected_check_cmd, | |
a636c635 | 4120 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4121 | NO_STR |
4122 | NEIGHBOR_STR | |
4123 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4124 | "one-hop away EBGP peer using loopback address\n" |
4125 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4126 | { |
c500ae40 DW |
4127 | int idx_peer = 2; |
4128 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4129 | } |
4130 | ||
718e3744 | 4131 | DEFUN (neighbor_description, |
4132 | neighbor_description_cmd, | |
e961923c | 4133 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4134 | NEIGHBOR_STR |
4135 | NEIGHBOR_ADDR_STR2 | |
4136 | "Neighbor specific description\n" | |
4137 | "Up to 80 characters describing this neighbor\n") | |
4138 | { | |
c500ae40 | 4139 | int idx_peer = 1; |
58749582 | 4140 | int idx_line = 3; |
718e3744 | 4141 | struct peer *peer; |
718e3744 | 4142 | char *str; |
718e3744 | 4143 | |
c500ae40 | 4144 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4145 | if (! peer) |
4146 | return CMD_WARNING; | |
4147 | ||
58749582 | 4148 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4149 | |
4150 | peer_description_set (peer, str); | |
4151 | ||
3b8b1855 | 4152 | XFREE (MTYPE_TMP, str); |
718e3744 | 4153 | |
4154 | return CMD_SUCCESS; | |
4155 | } | |
4156 | ||
4157 | DEFUN (no_neighbor_description, | |
4158 | no_neighbor_description_cmd, | |
a636c635 | 4159 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]", |
718e3744 | 4160 | NO_STR |
4161 | NEIGHBOR_STR | |
4162 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4163 | "Neighbor specific description\n" |
4164 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 4165 | { |
c500ae40 | 4166 | int idx_peer = 2; |
718e3744 | 4167 | struct peer *peer; |
4168 | ||
c500ae40 | 4169 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 4170 | if (! peer) |
4171 | return CMD_WARNING; | |
4172 | ||
4173 | peer_description_unset (peer); | |
4174 | ||
4175 | return CMD_SUCCESS; | |
4176 | } | |
4177 | ||
6b0655a2 | 4178 | |
718e3744 | 4179 | /* Neighbor update-source. */ |
94f2b392 | 4180 | static int |
e52702f2 | 4181 | peer_update_source_vty (struct vty *vty, const char *peer_str, |
fd79ac91 | 4182 | const char *source_str) |
718e3744 | 4183 | { |
4184 | struct peer *peer; | |
718e3744 | 4185 | |
4186 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4187 | if (! peer) | |
4188 | return CMD_WARNING; | |
4189 | ||
a80beece DS |
4190 | if (peer->conf_if) |
4191 | return CMD_WARNING; | |
4192 | ||
718e3744 | 4193 | if (source_str) |
4194 | { | |
c63b83fe JBD |
4195 | union sockunion su; |
4196 | int ret = str2sockunion (source_str, &su); | |
4197 | ||
4198 | if (ret == 0) | |
4199 | peer_update_source_addr_set (peer, &su); | |
718e3744 | 4200 | else |
4201 | peer_update_source_if_set (peer, source_str); | |
4202 | } | |
4203 | else | |
4204 | peer_update_source_unset (peer); | |
4205 | ||
4206 | return CMD_SUCCESS; | |
4207 | } | |
4208 | ||
369688c0 PJ |
4209 | #define BGP_UPDATE_SOURCE_HELP_STR \ |
4210 | "IPv4 address\n" \ | |
9a1a331d PJ |
4211 | "IPv6 address\n" \ |
4212 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4213 | |
718e3744 | 4214 | DEFUN (neighbor_update_source, |
4215 | neighbor_update_source_cmd, | |
9ccf14f7 | 4216 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4217 | NEIGHBOR_STR |
4218 | NEIGHBOR_ADDR_STR2 | |
4219 | "Source of routing updates\n" | |
369688c0 | 4220 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4221 | { |
c500ae40 DW |
4222 | int idx_peer = 1; |
4223 | int idx_peer_2 = 3; | |
4224 | return peer_update_source_vty (vty, argv[idx_peer]->arg, argv[idx_peer_2]->arg); | |
718e3744 | 4225 | } |
4226 | ||
4227 | DEFUN (no_neighbor_update_source, | |
4228 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4229 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4230 | NO_STR |
4231 | NEIGHBOR_STR | |
4232 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4233 | "Source of routing updates\n" |
4234 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4235 | { |
c500ae40 DW |
4236 | int idx_peer = 2; |
4237 | return peer_update_source_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4238 | } |
6b0655a2 | 4239 | |
94f2b392 | 4240 | static int |
e52702f2 QY |
4241 | peer_default_originate_set_vty (struct vty *vty, const char *peer_str, |
4242 | afi_t afi, safi_t safi, | |
fd79ac91 | 4243 | const char *rmap, int set) |
718e3744 | 4244 | { |
4245 | int ret; | |
4246 | struct peer *peer; | |
4247 | ||
4248 | peer = peer_and_group_lookup_vty (vty, peer_str); | |
4249 | if (! peer) | |
4250 | return CMD_WARNING; | |
4251 | ||
4252 | if (set) | |
4253 | ret = peer_default_originate_set (peer, afi, safi, rmap); | |
4254 | else | |
4255 | ret = peer_default_originate_unset (peer, afi, safi); | |
4256 | ||
4257 | return bgp_vty_return (vty, ret); | |
4258 | } | |
4259 | ||
4260 | /* neighbor default-originate. */ | |
4261 | DEFUN (neighbor_default_originate, | |
4262 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4263 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4264 | NEIGHBOR_STR |
4265 | NEIGHBOR_ADDR_STR2 | |
4266 | "Originate default route to this neighbor\n") | |
4267 | { | |
c500ae40 DW |
4268 | int idx_peer = 1; |
4269 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4270 | bgp_node_safi (vty), NULL, 1); |
4271 | } | |
4272 | ||
4273 | DEFUN (neighbor_default_originate_rmap, | |
4274 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4275 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4276 | NEIGHBOR_STR |
4277 | NEIGHBOR_ADDR_STR2 | |
4278 | "Originate default route to this neighbor\n" | |
4279 | "Route-map to specify criteria to originate default\n" | |
4280 | "route-map name\n") | |
4281 | { | |
c500ae40 DW |
4282 | int idx_peer = 1; |
4283 | int idx_word = 4; | |
4284 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4285 | bgp_node_safi (vty), argv[idx_word]->arg, 1); | |
718e3744 | 4286 | } |
4287 | ||
4288 | DEFUN (no_neighbor_default_originate, | |
4289 | no_neighbor_default_originate_cmd, | |
a636c635 | 4290 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4291 | NO_STR |
4292 | NEIGHBOR_STR | |
4293 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4294 | "Originate default route to this neighbor\n" |
4295 | "Route-map to specify criteria to originate default\n" | |
4296 | "route-map name\n") | |
718e3744 | 4297 | { |
c500ae40 DW |
4298 | int idx_peer = 2; |
4299 | return peer_default_originate_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 4300 | bgp_node_safi (vty), NULL, 0); |
4301 | } | |
4302 | ||
6b0655a2 | 4303 | |
718e3744 | 4304 | /* Set neighbor's BGP port. */ |
94f2b392 | 4305 | static int |
e52702f2 | 4306 | peer_port_vty (struct vty *vty, const char *ip_str, int afi, |
fd79ac91 | 4307 | const char *port_str) |
718e3744 | 4308 | { |
4309 | struct peer *peer; | |
4310 | u_int16_t port; | |
4311 | struct servent *sp; | |
4312 | ||
4313 | peer = peer_lookup_vty (vty, ip_str); | |
4314 | if (! peer) | |
4315 | return CMD_WARNING; | |
4316 | ||
4317 | if (! port_str) | |
e52702f2 | 4318 | { |
718e3744 | 4319 | sp = getservbyname ("bgp", "tcp"); |
4320 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs (sp->s_port); | |
4321 | } | |
4322 | else | |
4323 | { | |
4324 | VTY_GET_INTEGER("port", port, port_str); | |
4325 | } | |
4326 | ||
4327 | peer_port_set (peer, port); | |
4328 | ||
4329 | return CMD_SUCCESS; | |
4330 | } | |
4331 | ||
f418446b | 4332 | /* Set specified peer's BGP port. */ |
718e3744 | 4333 | DEFUN (neighbor_port, |
4334 | neighbor_port_cmd, | |
9ccf14f7 | 4335 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4336 | NEIGHBOR_STR |
4337 | NEIGHBOR_ADDR_STR | |
4338 | "Neighbor's BGP port\n" | |
4339 | "TCP port number\n") | |
4340 | { | |
c500ae40 DW |
4341 | int idx_ip = 1; |
4342 | int idx_number = 3; | |
4343 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, argv[idx_number]->arg); | |
718e3744 | 4344 | } |
4345 | ||
4346 | DEFUN (no_neighbor_port, | |
4347 | no_neighbor_port_cmd, | |
9ccf14f7 | 4348 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4349 | NO_STR |
4350 | NEIGHBOR_STR | |
4351 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4352 | "Neighbor's BGP port\n" |
4353 | "TCP port number\n") | |
718e3744 | 4354 | { |
c500ae40 DW |
4355 | int idx_ip = 2; |
4356 | return peer_port_vty (vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4357 | } |
4358 | ||
6b0655a2 | 4359 | |
718e3744 | 4360 | /* neighbor weight. */ |
94f2b392 | 4361 | static int |
e52702f2 | 4362 | peer_weight_set_vty (struct vty *vty, const char *ip_str, |
d93f7ffc | 4363 | afi_t afi, safi_t safi, |
fd79ac91 | 4364 | const char *weight_str) |
718e3744 | 4365 | { |
1f9a9fff | 4366 | int ret; |
718e3744 | 4367 | struct peer *peer; |
4368 | unsigned long weight; | |
4369 | ||
4370 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4371 | if (! peer) | |
4372 | return CMD_WARNING; | |
4373 | ||
4374 | VTY_GET_INTEGER_RANGE("weight", weight, weight_str, 0, 65535); | |
4375 | ||
d93f7ffc | 4376 | ret = peer_weight_set (peer, afi, safi, weight); |
1f9a9fff | 4377 | return bgp_vty_return (vty, ret); |
718e3744 | 4378 | } |
4379 | ||
94f2b392 | 4380 | static int |
d93f7ffc DW |
4381 | peer_weight_unset_vty (struct vty *vty, const char *ip_str, |
4382 | afi_t afi, safi_t safi) | |
718e3744 | 4383 | { |
1f9a9fff | 4384 | int ret; |
718e3744 | 4385 | struct peer *peer; |
4386 | ||
4387 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4388 | if (! peer) | |
4389 | return CMD_WARNING; | |
4390 | ||
d93f7ffc | 4391 | ret = peer_weight_unset (peer, afi, safi); |
1f9a9fff | 4392 | return bgp_vty_return (vty, ret); |
718e3744 | 4393 | } |
4394 | ||
4395 | DEFUN (neighbor_weight, | |
4396 | neighbor_weight_cmd, | |
9ccf14f7 | 4397 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 4398 | NEIGHBOR_STR |
4399 | NEIGHBOR_ADDR_STR2 | |
4400 | "Set default weight for routes from this neighbor\n" | |
4401 | "default weight\n") | |
4402 | { | |
c500ae40 DW |
4403 | int idx_peer = 1; |
4404 | int idx_number = 3; | |
e52702f2 QY |
4405 | return peer_weight_set_vty (vty, |
4406 | argv[idx_peer]->arg, | |
4407 | bgp_node_afi (vty), | |
4408 | bgp_node_safi (vty), | |
4409 | argv[idx_number]->arg); | |
718e3744 | 4410 | } |
4411 | ||
4412 | DEFUN (no_neighbor_weight, | |
4413 | no_neighbor_weight_cmd, | |
9ccf14f7 | 4414 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 4415 | NO_STR |
4416 | NEIGHBOR_STR | |
4417 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4418 | "Set default weight for routes from this neighbor\n" |
4419 | "default weight\n") | |
718e3744 | 4420 | { |
c500ae40 | 4421 | int idx_peer = 2; |
e52702f2 | 4422 | return peer_weight_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), bgp_node_safi (vty)); |
718e3744 | 4423 | } |
4424 | ||
6b0655a2 | 4425 | |
718e3744 | 4426 | /* Override capability negotiation. */ |
4427 | DEFUN (neighbor_override_capability, | |
4428 | neighbor_override_capability_cmd, | |
9ccf14f7 | 4429 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4430 | NEIGHBOR_STR |
4431 | NEIGHBOR_ADDR_STR2 | |
4432 | "Override capability negotiation result\n") | |
4433 | { | |
c500ae40 DW |
4434 | int idx_peer = 1; |
4435 | return peer_flag_set_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4436 | } |
4437 | ||
4438 | DEFUN (no_neighbor_override_capability, | |
4439 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 4440 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4441 | NO_STR |
4442 | NEIGHBOR_STR | |
4443 | NEIGHBOR_ADDR_STR2 | |
4444 | "Override capability negotiation result\n") | |
4445 | { | |
c500ae40 DW |
4446 | int idx_peer = 2; |
4447 | return peer_flag_unset_vty (vty, argv[idx_peer]->arg, PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4448 | } |
6b0655a2 | 4449 | |
718e3744 | 4450 | DEFUN (neighbor_strict_capability, |
4451 | neighbor_strict_capability_cmd, | |
9ccf14f7 | 4452 | "neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4453 | NEIGHBOR_STR |
4454 | NEIGHBOR_ADDR_STR | |
4455 | "Strict capability negotiation match\n") | |
4456 | { | |
c500ae40 DW |
4457 | int idx_ip = 1; |
4458 | return peer_flag_set_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4459 | } |
4460 | ||
4461 | DEFUN (no_neighbor_strict_capability, | |
4462 | no_neighbor_strict_capability_cmd, | |
9ccf14f7 | 4463 | "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4464 | NO_STR |
4465 | NEIGHBOR_STR | |
4466 | NEIGHBOR_ADDR_STR | |
4467 | "Strict capability negotiation match\n") | |
4468 | { | |
c500ae40 DW |
4469 | int idx_ip = 2; |
4470 | return peer_flag_unset_vty (vty, argv[idx_ip]->arg, PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4471 | } |
6b0655a2 | 4472 | |
94f2b392 | 4473 | static int |
e52702f2 | 4474 | peer_timers_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4475 | const char *keep_str, const char *hold_str) |
718e3744 | 4476 | { |
4477 | int ret; | |
4478 | struct peer *peer; | |
4479 | u_int32_t keepalive; | |
4480 | u_int32_t holdtime; | |
4481 | ||
4482 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4483 | if (! peer) | |
4484 | return CMD_WARNING; | |
4485 | ||
4486 | VTY_GET_INTEGER_RANGE ("Keepalive", keepalive, keep_str, 0, 65535); | |
4487 | VTY_GET_INTEGER_RANGE ("Holdtime", holdtime, hold_str, 0, 65535); | |
4488 | ||
4489 | ret = peer_timers_set (peer, keepalive, holdtime); | |
4490 | ||
4491 | return bgp_vty_return (vty, ret); | |
4492 | } | |
6b0655a2 | 4493 | |
94f2b392 | 4494 | static int |
fd79ac91 | 4495 | peer_timers_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4496 | { |
4497 | int ret; | |
4498 | struct peer *peer; | |
4499 | ||
0c412461 | 4500 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4501 | if (! peer) |
4502 | return CMD_WARNING; | |
4503 | ||
4504 | ret = peer_timers_unset (peer); | |
4505 | ||
4506 | return bgp_vty_return (vty, ret); | |
4507 | } | |
4508 | ||
4509 | DEFUN (neighbor_timers, | |
4510 | neighbor_timers_cmd, | |
9ccf14f7 | 4511 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 4512 | NEIGHBOR_STR |
4513 | NEIGHBOR_ADDR_STR2 | |
4514 | "BGP per neighbor timers\n" | |
4515 | "Keepalive interval\n" | |
4516 | "Holdtime\n") | |
4517 | { | |
c500ae40 DW |
4518 | int idx_peer = 1; |
4519 | int idx_number = 3; | |
4520 | int idx_number_2 = 4; | |
4521 | return peer_timers_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, argv[idx_number_2]->arg); | |
718e3744 | 4522 | } |
4523 | ||
4524 | DEFUN (no_neighbor_timers, | |
4525 | no_neighbor_timers_cmd, | |
9ccf14f7 | 4526 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 4527 | NO_STR |
4528 | NEIGHBOR_STR | |
4529 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4530 | "BGP per neighbor timers\n" |
4531 | "Keepalive interval\n" | |
4532 | "Holdtime\n") | |
718e3744 | 4533 | { |
c500ae40 DW |
4534 | int idx_peer = 2; |
4535 | return peer_timers_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4536 | } |
6b0655a2 | 4537 | |
813d4307 | 4538 | |
94f2b392 | 4539 | static int |
e52702f2 | 4540 | peer_timers_connect_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4541 | const char *time_str) |
718e3744 | 4542 | { |
4543 | int ret; | |
4544 | struct peer *peer; | |
4545 | u_int32_t connect; | |
4546 | ||
966f821c | 4547 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4548 | if (! peer) |
4549 | return CMD_WARNING; | |
4550 | ||
4551 | VTY_GET_INTEGER_RANGE ("Connect time", connect, time_str, 0, 65535); | |
4552 | ||
4553 | ret = peer_timers_connect_set (peer, connect); | |
4554 | ||
966f821c | 4555 | return bgp_vty_return (vty, ret); |
718e3744 | 4556 | } |
4557 | ||
94f2b392 | 4558 | static int |
fd79ac91 | 4559 | peer_timers_connect_unset_vty (struct vty *vty, const char *ip_str) |
718e3744 | 4560 | { |
4561 | int ret; | |
4562 | struct peer *peer; | |
4563 | ||
4564 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4565 | if (! peer) | |
4566 | return CMD_WARNING; | |
4567 | ||
4568 | ret = peer_timers_connect_unset (peer); | |
4569 | ||
966f821c | 4570 | return bgp_vty_return (vty, ret); |
718e3744 | 4571 | } |
4572 | ||
4573 | DEFUN (neighbor_timers_connect, | |
4574 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 4575 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 4576 | NEIGHBOR_STR |
966f821c | 4577 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4578 | "BGP per neighbor timers\n" |
4579 | "BGP connect timer\n" | |
4580 | "Connect timer\n") | |
4581 | { | |
c500ae40 DW |
4582 | int idx_peer = 1; |
4583 | int idx_number = 4; | |
4584 | return peer_timers_connect_set_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg); | |
718e3744 | 4585 | } |
4586 | ||
4587 | DEFUN (no_neighbor_timers_connect, | |
4588 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 4589 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 4590 | NO_STR |
4591 | NEIGHBOR_STR | |
966f821c | 4592 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4593 | "BGP per neighbor timers\n" |
8334fd5a DW |
4594 | "BGP connect timer\n" |
4595 | "Connect timer\n") | |
718e3744 | 4596 | { |
c500ae40 DW |
4597 | int idx_peer = 2; |
4598 | return peer_timers_connect_unset_vty (vty, argv[idx_peer]->arg); | |
718e3744 | 4599 | } |
4600 | ||
6b0655a2 | 4601 | |
94f2b392 | 4602 | static int |
e52702f2 QY |
4603 | peer_advertise_interval_vty (struct vty *vty, const char *ip_str, |
4604 | const char *time_str, int set) | |
718e3744 | 4605 | { |
4606 | int ret; | |
4607 | struct peer *peer; | |
4608 | u_int32_t routeadv = 0; | |
4609 | ||
966f821c | 4610 | peer = peer_and_group_lookup_vty (vty, ip_str); |
718e3744 | 4611 | if (! peer) |
4612 | return CMD_WARNING; | |
4613 | ||
4614 | if (time_str) | |
4615 | VTY_GET_INTEGER_RANGE ("advertise interval", routeadv, time_str, 0, 600); | |
4616 | ||
4617 | if (set) | |
4618 | ret = peer_advertise_interval_set (peer, routeadv); | |
4619 | else | |
4620 | ret = peer_advertise_interval_unset (peer); | |
4621 | ||
966f821c | 4622 | return bgp_vty_return (vty, ret); |
718e3744 | 4623 | } |
4624 | ||
4625 | DEFUN (neighbor_advertise_interval, | |
4626 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4627 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 4628 | NEIGHBOR_STR |
966f821c | 4629 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4630 | "Minimum interval between sending BGP routing updates\n" |
4631 | "time in seconds\n") | |
4632 | { | |
c500ae40 DW |
4633 | int idx_peer = 1; |
4634 | int idx_number = 3; | |
4635 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, argv[idx_number]->arg, 1); | |
718e3744 | 4636 | } |
4637 | ||
4638 | DEFUN (no_neighbor_advertise_interval, | |
4639 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4640 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 4641 | NO_STR |
4642 | NEIGHBOR_STR | |
966f821c | 4643 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
4644 | "Minimum interval between sending BGP routing updates\n" |
4645 | "time in seconds\n") | |
718e3744 | 4646 | { |
c500ae40 DW |
4647 | int idx_peer = 2; |
4648 | return peer_advertise_interval_vty (vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 4649 | } |
4650 | ||
6b0655a2 | 4651 | |
518f0eb1 DS |
4652 | /* Time to wait before processing route-map updates */ |
4653 | DEFUN (bgp_set_route_map_delay_timer, | |
4654 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 4655 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
4656 | SET_STR |
4657 | "BGP route-map delay timer\n" | |
4658 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 4659 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 4660 | { |
c500ae40 | 4661 | int idx_number = 3; |
518f0eb1 | 4662 | u_int32_t rmap_delay_timer; |
518f0eb1 | 4663 | |
c500ae40 | 4664 | if (argv[idx_number]->arg) |
518f0eb1 | 4665 | { |
c500ae40 | 4666 | VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[idx_number]->arg, 0, 600); |
5fe9f963 | 4667 | bm->rmap_update_timer = rmap_delay_timer; |
518f0eb1 DS |
4668 | |
4669 | /* if the dynamic update handling is being disabled, and a timer is | |
4670 | * running, stop the timer and act as if the timer has already fired. | |
4671 | */ | |
5fe9f963 | 4672 | if (!rmap_delay_timer && bm->t_rmap_update ) |
518f0eb1 | 4673 | { |
5fe9f963 | 4674 | BGP_TIMER_OFF(bm->t_rmap_update); |
4675 | thread_execute (bm->master, bgp_route_map_update_timer, NULL, 0); | |
518f0eb1 DS |
4676 | } |
4677 | return CMD_SUCCESS; | |
4678 | } | |
4679 | else | |
ffd0c037 | 4680 | return CMD_WARNING; |
518f0eb1 DS |
4681 | } |
4682 | ||
4683 | DEFUN (no_bgp_set_route_map_delay_timer, | |
4684 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 4685 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 4686 | NO_STR |
3a2d747c | 4687 | BGP_STR |
518f0eb1 | 4688 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
4689 | "Reset to default time to wait for processing route-map changes\n" |
4690 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 4691 | { |
518f0eb1 | 4692 | |
5fe9f963 | 4693 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 DS |
4694 | |
4695 | return CMD_SUCCESS; | |
4696 | } | |
4697 | ||
f414725f | 4698 | |
718e3744 | 4699 | /* neighbor interface */ |
94f2b392 | 4700 | static int |
fd79ac91 | 4701 | peer_interface_vty (struct vty *vty, const char *ip_str, const char *str) |
718e3744 | 4702 | { |
718e3744 | 4703 | struct peer *peer; |
4704 | ||
4705 | peer = peer_lookup_vty (vty, ip_str); | |
a80beece | 4706 | if (! peer || peer->conf_if) |
718e3744 | 4707 | return CMD_WARNING; |
4708 | ||
4709 | if (str) | |
ffd0c037 | 4710 | peer_interface_set (peer, str); |
718e3744 | 4711 | else |
ffd0c037 | 4712 | peer_interface_unset (peer); |
718e3744 | 4713 | |
4714 | return CMD_SUCCESS; | |
4715 | } | |
4716 | ||
4717 | DEFUN (neighbor_interface, | |
4718 | neighbor_interface_cmd, | |
9ccf14f7 | 4719 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 4720 | NEIGHBOR_STR |
4721 | NEIGHBOR_ADDR_STR | |
4722 | "Interface\n" | |
4723 | "Interface name\n") | |
4724 | { | |
c500ae40 DW |
4725 | int idx_ip = 1; |
4726 | int idx_word = 3; | |
00d7d2d3 | 4727 | return peer_interface_vty (vty, argv[idx_ip]->arg, argv[idx_word]->arg); |
718e3744 | 4728 | } |
4729 | ||
4730 | DEFUN (no_neighbor_interface, | |
4731 | no_neighbor_interface_cmd, | |
9ccf14f7 | 4732 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 4733 | NO_STR |
4734 | NEIGHBOR_STR | |
16cedbb0 | 4735 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4736 | "Interface\n" |
4737 | "Interface name\n") | |
4738 | { | |
c500ae40 DW |
4739 | int idx_peer = 2; |
4740 | return peer_interface_vty (vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4741 | } |
6b0655a2 | 4742 | |
718e3744 | 4743 | /* Set distribute list to the peer. */ |
94f2b392 | 4744 | static int |
e52702f2 | 4745 | peer_distribute_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4746 | afi_t afi, safi_t safi, |
4747 | const char *name_str, const char *direct_str) | |
718e3744 | 4748 | { |
4749 | int ret; | |
4750 | struct peer *peer; | |
4751 | int direct = FILTER_IN; | |
4752 | ||
4753 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4754 | if (! peer) | |
4755 | return CMD_WARNING; | |
4756 | ||
4757 | /* Check filter direction. */ | |
4758 | if (strncmp (direct_str, "i", 1) == 0) | |
4759 | direct = FILTER_IN; | |
4760 | else if (strncmp (direct_str, "o", 1) == 0) | |
4761 | direct = FILTER_OUT; | |
4762 | ||
4763 | ret = peer_distribute_set (peer, afi, safi, direct, name_str); | |
4764 | ||
4765 | return bgp_vty_return (vty, ret); | |
4766 | } | |
4767 | ||
94f2b392 | 4768 | static int |
fd79ac91 | 4769 | peer_distribute_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
4770 | safi_t safi, const char *direct_str) | |
718e3744 | 4771 | { |
4772 | int ret; | |
4773 | struct peer *peer; | |
4774 | int direct = FILTER_IN; | |
4775 | ||
4776 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4777 | if (! peer) | |
4778 | return CMD_WARNING; | |
4779 | ||
4780 | /* Check filter direction. */ | |
4781 | if (strncmp (direct_str, "i", 1) == 0) | |
4782 | direct = FILTER_IN; | |
4783 | else if (strncmp (direct_str, "o", 1) == 0) | |
4784 | direct = FILTER_OUT; | |
4785 | ||
4786 | ret = peer_distribute_unset (peer, afi, safi, direct); | |
4787 | ||
4788 | return bgp_vty_return (vty, ret); | |
4789 | } | |
4790 | ||
4791 | DEFUN (neighbor_distribute_list, | |
4792 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 4793 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 4794 | NEIGHBOR_STR |
4795 | NEIGHBOR_ADDR_STR2 | |
4796 | "Filter updates to/from this neighbor\n" | |
4797 | "IP access-list number\n" | |
4798 | "IP access-list number (expanded range)\n" | |
4799 | "IP Access-list name\n" | |
4800 | "Filter incoming updates\n" | |
4801 | "Filter outgoing updates\n") | |
4802 | { | |
c500ae40 DW |
4803 | int idx_peer = 1; |
4804 | int idx_acl = 3; | |
4805 | int idx_in_out = 4; | |
4806 | return peer_distribute_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4807 | bgp_node_safi (vty), argv[idx_acl]->arg, argv[idx_in_out]->arg); | |
718e3744 | 4808 | } |
4809 | ||
4810 | DEFUN (no_neighbor_distribute_list, | |
4811 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 4812 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 4813 | NO_STR |
4814 | NEIGHBOR_STR | |
4815 | NEIGHBOR_ADDR_STR2 | |
4816 | "Filter updates to/from this neighbor\n" | |
4817 | "IP access-list number\n" | |
4818 | "IP access-list number (expanded range)\n" | |
4819 | "IP Access-list name\n" | |
4820 | "Filter incoming updates\n" | |
4821 | "Filter outgoing updates\n") | |
4822 | { | |
c500ae40 DW |
4823 | int idx_peer = 2; |
4824 | int idx_in_out = 5; | |
4825 | return peer_distribute_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4826 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 4827 | } |
6b0655a2 | 4828 | |
718e3744 | 4829 | /* Set prefix list to the peer. */ |
94f2b392 | 4830 | static int |
fd79ac91 | 4831 | peer_prefix_list_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 4832 | safi_t safi, const char *name_str, |
fd79ac91 | 4833 | const char *direct_str) |
718e3744 | 4834 | { |
4835 | int ret; | |
4836 | struct peer *peer; | |
4837 | int direct = FILTER_IN; | |
4838 | ||
4839 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4840 | if (! peer) | |
4841 | return CMD_WARNING; | |
4842 | ||
4843 | /* Check filter direction. */ | |
4844 | if (strncmp (direct_str, "i", 1) == 0) | |
4845 | direct = FILTER_IN; | |
4846 | else if (strncmp (direct_str, "o", 1) == 0) | |
4847 | direct = FILTER_OUT; | |
4848 | ||
4849 | ret = peer_prefix_list_set (peer, afi, safi, direct, name_str); | |
4850 | ||
4851 | return bgp_vty_return (vty, ret); | |
4852 | } | |
4853 | ||
94f2b392 | 4854 | static int |
fd79ac91 | 4855 | peer_prefix_list_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
4856 | safi_t safi, const char *direct_str) | |
718e3744 | 4857 | { |
4858 | int ret; | |
4859 | struct peer *peer; | |
4860 | int direct = FILTER_IN; | |
4861 | ||
4862 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4863 | if (! peer) | |
4864 | return CMD_WARNING; | |
e52702f2 | 4865 | |
718e3744 | 4866 | /* Check filter direction. */ |
4867 | if (strncmp (direct_str, "i", 1) == 0) | |
4868 | direct = FILTER_IN; | |
4869 | else if (strncmp (direct_str, "o", 1) == 0) | |
4870 | direct = FILTER_OUT; | |
4871 | ||
4872 | ret = peer_prefix_list_unset (peer, afi, safi, direct); | |
4873 | ||
4874 | return bgp_vty_return (vty, ret); | |
4875 | } | |
4876 | ||
4877 | DEFUN (neighbor_prefix_list, | |
4878 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 4879 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 4880 | NEIGHBOR_STR |
4881 | NEIGHBOR_ADDR_STR2 | |
4882 | "Filter updates to/from this neighbor\n" | |
4883 | "Name of a prefix list\n" | |
4884 | "Filter incoming updates\n" | |
4885 | "Filter outgoing updates\n") | |
4886 | { | |
c500ae40 DW |
4887 | int idx_peer = 1; |
4888 | int idx_word = 3; | |
4889 | int idx_in_out = 4; | |
4890 | return peer_prefix_list_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4891 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 4892 | } |
4893 | ||
4894 | DEFUN (no_neighbor_prefix_list, | |
4895 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 4896 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 4897 | NO_STR |
4898 | NEIGHBOR_STR | |
4899 | NEIGHBOR_ADDR_STR2 | |
4900 | "Filter updates to/from this neighbor\n" | |
4901 | "Name of a prefix list\n" | |
4902 | "Filter incoming updates\n" | |
4903 | "Filter outgoing updates\n") | |
4904 | { | |
c500ae40 DW |
4905 | int idx_peer = 2; |
4906 | int idx_in_out = 5; | |
4907 | return peer_prefix_list_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4908 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 4909 | } |
6b0655a2 | 4910 | |
94f2b392 | 4911 | static int |
e52702f2 | 4912 | peer_aslist_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4913 | afi_t afi, safi_t safi, |
4914 | const char *name_str, const char *direct_str) | |
718e3744 | 4915 | { |
4916 | int ret; | |
4917 | struct peer *peer; | |
4918 | int direct = FILTER_IN; | |
4919 | ||
4920 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4921 | if (! peer) | |
4922 | return CMD_WARNING; | |
4923 | ||
4924 | /* Check filter direction. */ | |
4925 | if (strncmp (direct_str, "i", 1) == 0) | |
4926 | direct = FILTER_IN; | |
4927 | else if (strncmp (direct_str, "o", 1) == 0) | |
4928 | direct = FILTER_OUT; | |
4929 | ||
4930 | ret = peer_aslist_set (peer, afi, safi, direct, name_str); | |
4931 | ||
4932 | return bgp_vty_return (vty, ret); | |
4933 | } | |
4934 | ||
94f2b392 | 4935 | static int |
e52702f2 | 4936 | peer_aslist_unset_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4937 | afi_t afi, safi_t safi, |
4938 | const char *direct_str) | |
718e3744 | 4939 | { |
4940 | int ret; | |
4941 | struct peer *peer; | |
4942 | int direct = FILTER_IN; | |
4943 | ||
4944 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
4945 | if (! peer) | |
4946 | return CMD_WARNING; | |
4947 | ||
4948 | /* Check filter direction. */ | |
4949 | if (strncmp (direct_str, "i", 1) == 0) | |
4950 | direct = FILTER_IN; | |
4951 | else if (strncmp (direct_str, "o", 1) == 0) | |
4952 | direct = FILTER_OUT; | |
4953 | ||
4954 | ret = peer_aslist_unset (peer, afi, safi, direct); | |
4955 | ||
4956 | return bgp_vty_return (vty, ret); | |
4957 | } | |
4958 | ||
4959 | DEFUN (neighbor_filter_list, | |
4960 | neighbor_filter_list_cmd, | |
9ccf14f7 | 4961 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 4962 | NEIGHBOR_STR |
4963 | NEIGHBOR_ADDR_STR2 | |
4964 | "Establish BGP filters\n" | |
4965 | "AS path access-list name\n" | |
4966 | "Filter incoming routes\n" | |
4967 | "Filter outgoing routes\n") | |
4968 | { | |
c500ae40 DW |
4969 | int idx_peer = 1; |
4970 | int idx_word = 3; | |
4971 | int idx_in_out = 4; | |
4972 | return peer_aslist_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4973 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 4974 | } |
4975 | ||
4976 | DEFUN (no_neighbor_filter_list, | |
4977 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 4978 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 4979 | NO_STR |
4980 | NEIGHBOR_STR | |
4981 | NEIGHBOR_ADDR_STR2 | |
4982 | "Establish BGP filters\n" | |
4983 | "AS path access-list name\n" | |
4984 | "Filter incoming routes\n" | |
4985 | "Filter outgoing routes\n") | |
4986 | { | |
c500ae40 DW |
4987 | int idx_peer = 2; |
4988 | int idx_in_out = 5; | |
4989 | return peer_aslist_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
4990 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 4991 | } |
6b0655a2 | 4992 | |
718e3744 | 4993 | /* Set route-map to the peer. */ |
94f2b392 | 4994 | static int |
e52702f2 | 4995 | peer_route_map_set_vty (struct vty *vty, const char *ip_str, |
fd79ac91 | 4996 | afi_t afi, safi_t safi, |
4997 | const char *name_str, const char *direct_str) | |
718e3744 | 4998 | { |
4999 | int ret; | |
5000 | struct peer *peer; | |
fee0f4c6 | 5001 | int direct = RMAP_IN; |
718e3744 | 5002 | |
5003 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5004 | if (! peer) | |
5005 | return CMD_WARNING; | |
5006 | ||
5007 | /* Check filter direction. */ | |
fee0f4c6 | 5008 | if (strncmp (direct_str, "in", 2) == 0) |
5009 | direct = RMAP_IN; | |
718e3744 | 5010 | else if (strncmp (direct_str, "o", 1) == 0) |
fee0f4c6 | 5011 | direct = RMAP_OUT; |
718e3744 | 5012 | |
5013 | ret = peer_route_map_set (peer, afi, safi, direct, name_str); | |
5014 | ||
5015 | return bgp_vty_return (vty, ret); | |
5016 | } | |
5017 | ||
94f2b392 | 5018 | static int |
fd79ac91 | 5019 | peer_route_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5020 | safi_t safi, const char *direct_str) | |
718e3744 | 5021 | { |
5022 | int ret; | |
5023 | struct peer *peer; | |
fee0f4c6 | 5024 | int direct = RMAP_IN; |
718e3744 | 5025 | |
5026 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5027 | if (! peer) | |
5028 | return CMD_WARNING; | |
5029 | ||
5030 | /* Check filter direction. */ | |
fee0f4c6 | 5031 | if (strncmp (direct_str, "in", 2) == 0) |
5032 | direct = RMAP_IN; | |
718e3744 | 5033 | else if (strncmp (direct_str, "o", 1) == 0) |
fee0f4c6 | 5034 | direct = RMAP_OUT; |
718e3744 | 5035 | |
5036 | ret = peer_route_map_unset (peer, afi, safi, direct); | |
5037 | ||
5038 | return bgp_vty_return (vty, ret); | |
5039 | } | |
5040 | ||
5041 | DEFUN (neighbor_route_map, | |
5042 | neighbor_route_map_cmd, | |
9ccf14f7 | 5043 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5044 | NEIGHBOR_STR |
5045 | NEIGHBOR_ADDR_STR2 | |
5046 | "Apply route map to neighbor\n" | |
5047 | "Name of route map\n" | |
5048 | "Apply map to incoming routes\n" | |
2a3d5731 | 5049 | "Apply map to outbound routes\n") |
718e3744 | 5050 | { |
c500ae40 DW |
5051 | int idx_peer = 1; |
5052 | int idx_word = 3; | |
5053 | int idx_in_out = 4; | |
5054 | return peer_route_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5055 | bgp_node_safi (vty), argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5056 | } |
5057 | ||
5058 | DEFUN (no_neighbor_route_map, | |
5059 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5060 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5061 | NO_STR |
5062 | NEIGHBOR_STR | |
5063 | NEIGHBOR_ADDR_STR2 | |
5064 | "Apply route map to neighbor\n" | |
5065 | "Name of route map\n" | |
5066 | "Apply map to incoming routes\n" | |
2a3d5731 | 5067 | "Apply map to outbound routes\n") |
718e3744 | 5068 | { |
c500ae40 DW |
5069 | int idx_peer = 2; |
5070 | int idx_in_out = 5; | |
5071 | return peer_route_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5072 | bgp_node_safi (vty), argv[idx_in_out]->arg); | |
718e3744 | 5073 | } |
6b0655a2 | 5074 | |
718e3744 | 5075 | /* Set unsuppress-map to the peer. */ |
94f2b392 | 5076 | static int |
fd79ac91 | 5077 | peer_unsuppress_map_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
5078 | safi_t safi, const char *name_str) | |
718e3744 | 5079 | { |
5080 | int ret; | |
5081 | struct peer *peer; | |
5082 | ||
5083 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5084 | if (! peer) | |
5085 | return CMD_WARNING; | |
5086 | ||
5087 | ret = peer_unsuppress_map_set (peer, afi, safi, name_str); | |
5088 | ||
5089 | return bgp_vty_return (vty, ret); | |
5090 | } | |
5091 | ||
5092 | /* Unset route-map from the peer. */ | |
94f2b392 | 5093 | static int |
fd79ac91 | 5094 | peer_unsuppress_map_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5095 | safi_t safi) |
5096 | { | |
5097 | int ret; | |
5098 | struct peer *peer; | |
5099 | ||
5100 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5101 | if (! peer) | |
5102 | return CMD_WARNING; | |
5103 | ||
5104 | ret = peer_unsuppress_map_unset (peer, afi, safi); | |
5105 | ||
5106 | return bgp_vty_return (vty, ret); | |
5107 | } | |
5108 | ||
5109 | DEFUN (neighbor_unsuppress_map, | |
5110 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5111 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5112 | NEIGHBOR_STR |
5113 | NEIGHBOR_ADDR_STR2 | |
5114 | "Route-map to selectively unsuppress suppressed routes\n" | |
5115 | "Name of route map\n") | |
5116 | { | |
c500ae40 DW |
5117 | int idx_peer = 1; |
5118 | int idx_word = 3; | |
5119 | return peer_unsuppress_map_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5120 | bgp_node_safi (vty), argv[idx_word]->arg); | |
718e3744 | 5121 | } |
5122 | ||
5123 | DEFUN (no_neighbor_unsuppress_map, | |
5124 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5125 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5126 | NO_STR |
5127 | NEIGHBOR_STR | |
5128 | NEIGHBOR_ADDR_STR2 | |
5129 | "Route-map to selectively unsuppress suppressed routes\n" | |
5130 | "Name of route map\n") | |
5131 | { | |
c500ae40 DW |
5132 | int idx_peer = 2; |
5133 | return peer_unsuppress_map_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 5134 | bgp_node_safi (vty)); |
5135 | } | |
6b0655a2 | 5136 | |
94f2b392 | 5137 | static int |
fd79ac91 | 5138 | peer_maximum_prefix_set_vty (struct vty *vty, const char *ip_str, afi_t afi, |
e52702f2 | 5139 | safi_t safi, const char *num_str, |
0a486e5f | 5140 | const char *threshold_str, int warning, |
5141 | const char *restart_str) | |
718e3744 | 5142 | { |
5143 | int ret; | |
5144 | struct peer *peer; | |
5145 | u_int32_t max; | |
e0701b79 | 5146 | u_char threshold; |
0a486e5f | 5147 | u_int16_t restart; |
718e3744 | 5148 | |
5149 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5150 | if (! peer) | |
5151 | return CMD_WARNING; | |
5152 | ||
e6ec1c36 | 5153 | VTY_GET_INTEGER ("maximum number", max, num_str); |
e0701b79 | 5154 | if (threshold_str) |
5155 | threshold = atoi (threshold_str); | |
5156 | else | |
5157 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5158 | |
0a486e5f | 5159 | if (restart_str) |
5160 | restart = atoi (restart_str); | |
5161 | else | |
5162 | restart = 0; | |
5163 | ||
5164 | ret = peer_maximum_prefix_set (peer, afi, safi, max, threshold, warning, restart); | |
718e3744 | 5165 | |
5166 | return bgp_vty_return (vty, ret); | |
5167 | } | |
5168 | ||
94f2b392 | 5169 | static int |
fd79ac91 | 5170 | peer_maximum_prefix_unset_vty (struct vty *vty, const char *ip_str, afi_t afi, |
718e3744 | 5171 | safi_t safi) |
5172 | { | |
5173 | int ret; | |
5174 | struct peer *peer; | |
5175 | ||
5176 | peer = peer_and_group_lookup_vty (vty, ip_str); | |
5177 | if (! peer) | |
5178 | return CMD_WARNING; | |
5179 | ||
5180 | ret = peer_maximum_prefix_unset (peer, afi, safi); | |
5181 | ||
5182 | return bgp_vty_return (vty, ret); | |
5183 | } | |
5184 | ||
5185 | /* Maximum number of prefix configuration. prefix count is different | |
5186 | for each peer configuration. So this configuration can be set for | |
5187 | each peer configuration. */ | |
5188 | DEFUN (neighbor_maximum_prefix, | |
5189 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5190 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5191 | NEIGHBOR_STR |
5192 | NEIGHBOR_ADDR_STR2 | |
5193 | "Maximum number of prefix accept from this peer\n" | |
5194 | "maximum no. of prefix limit\n") | |
5195 | { | |
c500ae40 DW |
5196 | int idx_peer = 1; |
5197 | int idx_number = 3; | |
5198 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5199 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, | |
0a486e5f | 5200 | NULL); |
718e3744 | 5201 | } |
5202 | ||
e0701b79 | 5203 | DEFUN (neighbor_maximum_prefix_threshold, |
5204 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5205 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5206 | NEIGHBOR_STR |
5207 | NEIGHBOR_ADDR_STR2 | |
5208 | "Maximum number of prefix accept from this peer\n" | |
5209 | "maximum no. of prefix limit\n" | |
5210 | "Threshold value (%) at which to generate a warning msg\n") | |
5211 | { | |
c500ae40 DW |
5212 | int idx_peer = 1; |
5213 | int idx_number = 3; | |
5214 | int idx_number_2 = 4; | |
5215 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5216 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
0a486e5f | 5217 | NULL); |
5218 | } | |
e0701b79 | 5219 | |
718e3744 | 5220 | DEFUN (neighbor_maximum_prefix_warning, |
5221 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5222 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5223 | NEIGHBOR_STR |
5224 | NEIGHBOR_ADDR_STR2 | |
5225 | "Maximum number of prefix accept from this peer\n" | |
5226 | "maximum no. of prefix limit\n" | |
5227 | "Only give warning message when limit is exceeded\n") | |
5228 | { | |
c500ae40 DW |
5229 | int idx_peer = 1; |
5230 | int idx_number = 3; | |
5231 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5232 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 1, | |
0a486e5f | 5233 | NULL); |
718e3744 | 5234 | } |
5235 | ||
e0701b79 | 5236 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5237 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5238 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5239 | NEIGHBOR_STR |
5240 | NEIGHBOR_ADDR_STR2 | |
5241 | "Maximum number of prefix accept from this peer\n" | |
5242 | "maximum no. of prefix limit\n" | |
5243 | "Threshold value (%) at which to generate a warning msg\n" | |
5244 | "Only give warning message when limit is exceeded\n") | |
5245 | { | |
c500ae40 DW |
5246 | int idx_peer = 1; |
5247 | int idx_number = 3; | |
5248 | int idx_number_2 = 4; | |
5249 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5250 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5251 | } |
5252 | ||
5253 | DEFUN (neighbor_maximum_prefix_restart, | |
5254 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5255 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 5256 | NEIGHBOR_STR |
5257 | NEIGHBOR_ADDR_STR2 | |
5258 | "Maximum number of prefix accept from this peer\n" | |
5259 | "maximum no. of prefix limit\n" | |
5260 | "Restart bgp connection after limit is exceeded\n" | |
5261 | "Restart interval in minutes") | |
5262 | { | |
c500ae40 DW |
5263 | int idx_peer = 1; |
5264 | int idx_number = 3; | |
5265 | int idx_number_2 = 5; | |
5266 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5267 | bgp_node_safi (vty), argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 5268 | } |
5269 | ||
5270 | DEFUN (neighbor_maximum_prefix_threshold_restart, | |
5271 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 5272 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 5273 | NEIGHBOR_STR |
5274 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5275 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 5276 | "maximum no. of prefix limit\n" |
5277 | "Threshold value (%) at which to generate a warning msg\n" | |
5278 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5279 | "Restart interval in minutes\n") |
0a486e5f | 5280 | { |
c500ae40 DW |
5281 | int idx_peer = 1; |
5282 | int idx_number = 3; | |
5283 | int idx_number_2 = 4; | |
5284 | int idx_number_3 = 6; | |
5285 | return peer_maximum_prefix_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
5286 | bgp_node_safi (vty), argv[idx_number]->arg, argv[idx_number_2]->arg, 0, argv[idx_number_3]->arg); | |
0a486e5f | 5287 | } |
e0701b79 | 5288 | |
718e3744 | 5289 | DEFUN (no_neighbor_maximum_prefix, |
5290 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 5291 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 5292 | NO_STR |
5293 | NEIGHBOR_STR | |
5294 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5295 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
5296 | "maximum no. of prefix limit\n" |
5297 | "Threshold value (%) at which to generate a warning msg\n" | |
5298 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5299 | "Restart interval in minutes\n" |
31500417 | 5300 | "Only give warning message when limit is exceeded\n") |
718e3744 | 5301 | { |
c500ae40 DW |
5302 | int idx_peer = 2; |
5303 | return peer_maximum_prefix_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
718e3744 | 5304 | bgp_node_safi (vty)); |
5305 | } | |
e52702f2 | 5306 | |
718e3744 | 5307 | |
718e3744 | 5308 | /* "neighbor allowas-in" */ |
5309 | DEFUN (neighbor_allowas_in, | |
5310 | neighbor_allowas_in_cmd, | |
fd8503f5 | 5311 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5312 | NEIGHBOR_STR |
5313 | NEIGHBOR_ADDR_STR2 | |
31500417 | 5314 | "Accept as-path with my AS present in it\n" |
fd8503f5 QY |
5315 | "Number of occurances of AS number\n" |
5316 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5317 | { |
c500ae40 | 5318 | int idx_peer = 1; |
fd8503f5 | 5319 | int idx_number_origin = 3; |
718e3744 | 5320 | int ret; |
aac9ef6c | 5321 | int origin = 0; |
718e3744 | 5322 | struct peer *peer; |
aac9ef6c | 5323 | int allow_num = 0; |
718e3744 | 5324 | |
c500ae40 | 5325 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 5326 | if (! peer) |
5327 | return CMD_WARNING; | |
5328 | ||
fd8503f5 | 5329 | if (argc <= idx_number_origin) |
718e3744 | 5330 | allow_num = 3; |
5331 | else | |
aac9ef6c | 5332 | { |
fd8503f5 | 5333 | if (argv[idx_number_origin]->type == WORD_TKN) |
aac9ef6c DW |
5334 | origin = 1; |
5335 | else | |
fd8503f5 | 5336 | allow_num = atoi (argv[idx_number_origin]->arg); |
aac9ef6c | 5337 | } |
718e3744 | 5338 | |
5339 | ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty), | |
aac9ef6c | 5340 | allow_num, origin); |
718e3744 | 5341 | |
5342 | return bgp_vty_return (vty, ret); | |
5343 | } | |
5344 | ||
718e3744 | 5345 | DEFUN (no_neighbor_allowas_in, |
5346 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 5347 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5348 | NO_STR |
5349 | NEIGHBOR_STR | |
5350 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 5351 | "allow local ASN appears in aspath attribute\n" |
fd8503f5 QY |
5352 | "Number of occurances of AS number\n" |
5353 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5354 | { |
c500ae40 | 5355 | int idx_peer = 2; |
718e3744 | 5356 | int ret; |
5357 | struct peer *peer; | |
5358 | ||
c500ae40 | 5359 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
718e3744 | 5360 | if (! peer) |
5361 | return CMD_WARNING; | |
5362 | ||
5363 | ret = peer_allowas_in_unset (peer, bgp_node_afi (vty), bgp_node_safi (vty)); | |
5364 | ||
5365 | return bgp_vty_return (vty, ret); | |
5366 | } | |
6b0655a2 | 5367 | |
fa411a21 NH |
5368 | DEFUN (neighbor_ttl_security, |
5369 | neighbor_ttl_security_cmd, | |
9ccf14f7 | 5370 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5371 | NEIGHBOR_STR |
5372 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5373 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
5374 | "Specify the maximum number of hops to the BGP peer\n" |
5375 | "Number of hops to BGP peer\n") | |
fa411a21 | 5376 | { |
c500ae40 DW |
5377 | int idx_peer = 1; |
5378 | int idx_number = 4; | |
fa411a21 | 5379 | struct peer *peer; |
89b6d1f8 | 5380 | int gtsm_hops; |
fa411a21 | 5381 | |
c500ae40 | 5382 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
5383 | if (! peer) |
5384 | return CMD_WARNING; | |
e52702f2 | 5385 | |
c500ae40 | 5386 | VTY_GET_INTEGER_RANGE ("", gtsm_hops, argv[idx_number]->arg, 1, 254); |
fa411a21 | 5387 | |
8cdabf90 SK |
5388 | /* |
5389 | * If 'neighbor swpX', then this is for directly connected peers, | |
5390 | * we should not accept a ttl-security hops value greater than 1. | |
5391 | */ | |
5392 | if (peer->conf_if && (gtsm_hops > 1)) { | |
5393 | vty_out (vty, "%s is directly connected peer, hops cannot exceed 1%s", | |
c500ae40 | 5394 | argv[idx_peer]->arg, VTY_NEWLINE); |
8cdabf90 SK |
5395 | return CMD_WARNING; |
5396 | } | |
5397 | ||
89b6d1f8 | 5398 | return bgp_vty_return (vty, peer_ttl_security_hops_set (peer, gtsm_hops)); |
fa411a21 NH |
5399 | } |
5400 | ||
5401 | DEFUN (no_neighbor_ttl_security, | |
5402 | no_neighbor_ttl_security_cmd, | |
9ccf14f7 | 5403 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5404 | NO_STR |
5405 | NEIGHBOR_STR | |
5406 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5407 | "BGP ttl-security parameters\n" |
3a2d747c QY |
5408 | "Specify the maximum number of hops to the BGP peer\n" |
5409 | "Number of hops to BGP peer\n") | |
fa411a21 | 5410 | { |
c500ae40 | 5411 | int idx_peer = 2; |
fa411a21 | 5412 | struct peer *peer; |
fa411a21 | 5413 | |
c500ae40 | 5414 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
fa411a21 NH |
5415 | if (! peer) |
5416 | return CMD_WARNING; | |
5417 | ||
89b6d1f8 | 5418 | return bgp_vty_return (vty, peer_ttl_security_hops_unset (peer)); |
fa411a21 | 5419 | } |
6b0655a2 | 5420 | |
adbac85e DW |
5421 | DEFUN (neighbor_addpath_tx_all_paths, |
5422 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5423 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5424 | NEIGHBOR_STR |
5425 | NEIGHBOR_ADDR_STR2 | |
5426 | "Use addpath to advertise all paths to a neighbor\n") | |
5427 | { | |
c500ae40 | 5428 | int idx_peer = 1; |
adbac85e DW |
5429 | struct peer *peer; |
5430 | ||
c500ae40 | 5431 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
adbac85e DW |
5432 | if (! peer) |
5433 | return CMD_WARNING; | |
5434 | ||
c500ae40 | 5435 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
adbac85e DW |
5436 | bgp_node_safi (vty), |
5437 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
5438 | } | |
5439 | ||
5440 | DEFUN (no_neighbor_addpath_tx_all_paths, | |
5441 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5442 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5443 | NO_STR |
5444 | NEIGHBOR_STR | |
5445 | NEIGHBOR_ADDR_STR2 | |
5446 | "Use addpath to advertise all paths to a neighbor\n") | |
5447 | { | |
c500ae40 DW |
5448 | int idx_peer = 2; |
5449 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
adbac85e DW |
5450 | bgp_node_safi (vty), |
5451 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
5452 | } | |
5453 | ||
06370dac DW |
5454 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
5455 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5456 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5457 | NEIGHBOR_STR |
5458 | NEIGHBOR_ADDR_STR2 | |
5459 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5460 | { | |
c500ae40 | 5461 | int idx_peer = 1; |
06370dac DW |
5462 | struct peer *peer; |
5463 | ||
c500ae40 | 5464 | peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg); |
06370dac DW |
5465 | if (! peer) |
5466 | return CMD_WARNING; | |
5467 | ||
c500ae40 | 5468 | return peer_af_flag_set_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), |
06370dac DW |
5469 | bgp_node_safi (vty), |
5470 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
5471 | } | |
5472 | ||
5473 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, | |
5474 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5475 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5476 | NO_STR |
5477 | NEIGHBOR_STR | |
5478 | NEIGHBOR_ADDR_STR2 | |
5479 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5480 | { | |
c500ae40 DW |
5481 | int idx_peer = 2; |
5482 | return peer_af_flag_unset_vty (vty, argv[idx_peer]->arg, bgp_node_afi (vty), | |
06370dac DW |
5483 | bgp_node_safi (vty), |
5484 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
5485 | } | |
5486 | ||
5487 | ||
8c3deaae | 5488 | /* Address Family configuration. */ |
718e3744 | 5489 | DEFUN (address_family_ipv4, |
5490 | address_family_ipv4_cmd, | |
5491 | "address-family ipv4", | |
5492 | "Enter Address Family command mode\n" | |
8c3deaae | 5493 | "Address Family\n") |
718e3744 | 5494 | { |
5495 | vty->node = BGP_IPV4_NODE; | |
5496 | return CMD_SUCCESS; | |
5497 | } | |
5498 | ||
5499 | DEFUN (address_family_ipv4_safi, | |
5500 | address_family_ipv4_safi_cmd, | |
46f296b4 | 5501 | "address-family ipv4 "BGP_SAFI_CMD_STR, |
718e3744 | 5502 | "Enter Address Family command mode\n" |
8c3deaae | 5503 | "Address Family\n" |
46f296b4 | 5504 | BGP_SAFI_HELP_STR) |
718e3744 | 5505 | { |
c500ae40 | 5506 | int idx_safi = 2; |
3b14d86e | 5507 | switch (bgp_vty_safi_from_arg(argv[idx_safi]->arg)) |
ccbb332a LB |
5508 | { |
5509 | case SAFI_MULTICAST: | |
5510 | vty->node = BGP_IPV4M_NODE; | |
5511 | break; | |
5512 | case SAFI_ENCAP: | |
5513 | vty->node = BGP_ENCAP_NODE; | |
5514 | break; | |
5515 | case SAFI_MPLS_VPN: | |
5516 | vty->node = BGP_VPNV4_NODE; | |
5517 | break; | |
5518 | case SAFI_UNICAST: | |
5519 | default: | |
5520 | vty->node = BGP_IPV4_NODE; | |
5521 | break; | |
5522 | } | |
718e3744 | 5523 | |
5524 | return CMD_SUCCESS; | |
5525 | } | |
5526 | ||
25ffbdc1 | 5527 | DEFUN (address_family_ipv6, |
5528 | address_family_ipv6_cmd, | |
5529 | "address-family ipv6", | |
718e3744 | 5530 | "Enter Address Family command mode\n" |
8c3deaae | 5531 | "Address Family\n") |
718e3744 | 5532 | { |
5533 | vty->node = BGP_IPV6_NODE; | |
5534 | return CMD_SUCCESS; | |
5535 | } | |
5536 | ||
25ffbdc1 | 5537 | DEFUN (address_family_ipv6_safi, |
5538 | address_family_ipv6_safi_cmd, | |
46f296b4 | 5539 | "address-family ipv6 "BGP_SAFI_CMD_STR, |
718e3744 | 5540 | "Enter Address Family command mode\n" |
8c3deaae | 5541 | "Address Family\n" |
46f296b4 | 5542 | BGP_SAFI_HELP_STR) |
25ffbdc1 | 5543 | { |
c500ae40 | 5544 | int idx_safi = 2; |
46f296b4 LB |
5545 | switch (bgp_vty_safi_from_arg(argv[idx_safi]->arg)) |
5546 | { | |
5547 | case SAFI_MULTICAST: | |
5548 | vty->node = BGP_IPV6M_NODE; | |
5549 | break; | |
5550 | case SAFI_ENCAP: | |
5551 | vty->node = BGP_ENCAPV6_NODE; | |
5552 | break; | |
5553 | case SAFI_MPLS_VPN: | |
5554 | vty->node = BGP_VPNV6_NODE; | |
5555 | break; | |
5556 | case SAFI_UNICAST: | |
5557 | default: | |
5558 | vty->node = BGP_IPV6_NODE; | |
5559 | break; | |
5560 | } | |
25ffbdc1 | 5561 | |
5562 | return CMD_SUCCESS; | |
5563 | } | |
718e3744 | 5564 | |
5565 | DEFUN (address_family_vpnv4, | |
5566 | address_family_vpnv4_cmd, | |
8334fd5a | 5567 | "address-family vpnv4 [unicast]", |
718e3744 | 5568 | "Enter Address Family command mode\n" |
8c3deaae | 5569 | "Address Family\n" |
3a2d747c | 5570 | "Address Family modifier\n") |
718e3744 | 5571 | { |
5572 | vty->node = BGP_VPNV4_NODE; | |
5573 | return CMD_SUCCESS; | |
5574 | } | |
5575 | ||
8ecd3266 | 5576 | DEFUN (address_family_vpnv6, |
5577 | address_family_vpnv6_cmd, | |
8334fd5a | 5578 | "address-family vpnv6 [unicast]", |
8ecd3266 | 5579 | "Enter Address Family command mode\n" |
8c3deaae | 5580 | "Address Family\n" |
3a2d747c | 5581 | "Address Family modifier\n") |
8ecd3266 | 5582 | { |
5583 | vty->node = BGP_VPNV6_NODE; | |
5584 | return CMD_SUCCESS; | |
5585 | } | |
5586 | ||
8b1fb8be LB |
5587 | DEFUN (address_family_encap, |
5588 | address_family_encap_cmd, | |
8334fd5a | 5589 | "address-family <encap|encapv4>", |
8b1fb8be | 5590 | "Enter Address Family command mode\n" |
8c3deaae QY |
5591 | "Address Family\n" |
5592 | "Address Family\n") | |
8b1fb8be LB |
5593 | { |
5594 | vty->node = BGP_ENCAP_NODE; | |
5595 | return CMD_SUCCESS; | |
5596 | } | |
5597 | ||
8b1fb8be LB |
5598 | |
5599 | DEFUN (address_family_encapv6, | |
5600 | address_family_encapv6_cmd, | |
5601 | "address-family encapv6", | |
5602 | "Enter Address Family command mode\n" | |
8c3deaae | 5603 | "Address Family\n") |
8b1fb8be LB |
5604 | { |
5605 | vty->node = BGP_ENCAPV6_NODE; | |
5606 | return CMD_SUCCESS; | |
5607 | } | |
5608 | ||
718e3744 | 5609 | DEFUN (exit_address_family, |
5610 | exit_address_family_cmd, | |
5611 | "exit-address-family", | |
5612 | "Exit from Address Family configuration mode\n") | |
5613 | { | |
a8a80d53 | 5614 | if (vty->node == BGP_IPV4_NODE |
5615 | || vty->node == BGP_IPV4M_NODE | |
718e3744 | 5616 | || vty->node == BGP_VPNV4_NODE |
25ffbdc1 | 5617 | || vty->node == BGP_IPV6_NODE |
8ecd3266 | 5618 | || vty->node == BGP_IPV6M_NODE |
8b1fb8be LB |
5619 | || vty->node == BGP_VPNV6_NODE |
5620 | || vty->node == BGP_ENCAP_NODE | |
5621 | || vty->node == BGP_ENCAPV6_NODE) | |
718e3744 | 5622 | vty->node = BGP_NODE; |
5623 | return CMD_SUCCESS; | |
5624 | } | |
6b0655a2 | 5625 | |
8ad7271d DS |
5626 | /* Recalculate bestpath and re-advertise a prefix */ |
5627 | static int | |
01080f7c | 5628 | bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str, |
8ad7271d DS |
5629 | afi_t afi, safi_t safi, struct prefix_rd *prd) |
5630 | { | |
5631 | int ret; | |
5632 | struct prefix match; | |
5633 | struct bgp_node *rn; | |
5634 | struct bgp_node *rm; | |
8ad7271d DS |
5635 | struct bgp *bgp; |
5636 | struct bgp_table *table; | |
5637 | struct bgp_table *rib; | |
5638 | ||
5639 | /* BGP structure lookup. */ | |
5640 | if (view_name) | |
5641 | { | |
5642 | bgp = bgp_lookup_by_name (view_name); | |
5643 | if (bgp == NULL) | |
5644 | { | |
6aeb9e78 | 5645 | vty_out (vty, "%% Can't find BGP instance %s%s", view_name, VTY_NEWLINE); |
8ad7271d DS |
5646 | return CMD_WARNING; |
5647 | } | |
5648 | } | |
5649 | else | |
5650 | { | |
5651 | bgp = bgp_get_default (); | |
5652 | if (bgp == NULL) | |
5653 | { | |
5654 | vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); | |
5655 | return CMD_WARNING; | |
5656 | } | |
5657 | } | |
5658 | ||
5659 | /* Check IP address argument. */ | |
5660 | ret = str2prefix (ip_str, &match); | |
5661 | if (! ret) | |
5662 | { | |
5663 | vty_out (vty, "%% address is malformed%s", VTY_NEWLINE); | |
5664 | return CMD_WARNING; | |
5665 | } | |
5666 | ||
5667 | match.family = afi2family (afi); | |
5668 | rib = bgp->rib[afi][safi]; | |
5669 | ||
5670 | if (safi == SAFI_MPLS_VPN) | |
5671 | { | |
5672 | for (rn = bgp_table_top (rib); rn; rn = bgp_route_next (rn)) | |
5673 | { | |
5674 | if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) | |
5675 | continue; | |
5676 | ||
5677 | if ((table = rn->info) != NULL) | |
5678 | { | |
5679 | if ((rm = bgp_node_match (table, &match)) != NULL) | |
5680 | { | |
5681 | if (rm->p.prefixlen == match.prefixlen) | |
5682 | { | |
5683 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
5684 | bgp_process (bgp, rm, afi, safi); | |
5685 | } | |
5686 | bgp_unlock_node (rm); | |
5687 | } | |
5688 | } | |
5689 | } | |
5690 | } | |
5691 | else | |
5692 | { | |
5693 | if ((rn = bgp_node_match (rib, &match)) != NULL) | |
5694 | { | |
5695 | if (rn->p.prefixlen == match.prefixlen) | |
5696 | { | |
5697 | SET_FLAG (rn->flags, BGP_NODE_USER_CLEAR); | |
5698 | bgp_process (bgp, rn, afi, safi); | |
5699 | } | |
5700 | bgp_unlock_node (rn); | |
5701 | } | |
5702 | } | |
5703 | ||
5704 | return CMD_SUCCESS; | |
5705 | } | |
5706 | ||
b09b5ae0 | 5707 | /* one clear bgp command to rule them all */ |
718e3744 | 5708 | DEFUN (clear_ip_bgp_all, |
5709 | clear_ip_bgp_all_cmd, | |
46f296b4 | 5710 | "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 | 5711 | CLEAR_STR |
5712 | IP_STR | |
5713 | BGP_STR | |
838758ac | 5714 | BGP_INSTANCE_HELP_STR |
b09b5ae0 DW |
5715 | "Clear all peers\n" |
5716 | "BGP neighbor address to clear\n" | |
a80beece | 5717 | "BGP IPv6 neighbor to clear\n" |
838758ac | 5718 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
5719 | "Clear peers with the AS number\n" |
5720 | "Clear all external peers\n" | |
718e3744 | 5721 | "Clear all members of peer-group\n" |
b09b5ae0 | 5722 | "BGP peer-group name\n" |
46f296b4 LB |
5723 | BGP_AFI_HELP_STR |
5724 | BGP_SAFI_HELP_STR | |
b09b5ae0 DW |
5725 | BGP_SOFT_STR |
5726 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
5727 | BGP_SOFT_OUT_STR |
5728 | BGP_SOFT_IN_STR | |
5729 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 5730 | BGP_SOFT_OUT_STR) |
718e3744 | 5731 | { |
cdc2d765 | 5732 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8334fd5a | 5733 | char *vrf = NULL; |
630a298c | 5734 | |
ae19d7dd QY |
5735 | afi_t afi = AFI_IP6; |
5736 | safi_t safi = SAFI_UNICAST; | |
5bf15956 | 5737 | enum clear_sort clr_sort = clear_peer; |
b09b5ae0 DW |
5738 | enum bgp_clear_type clr_type; |
5739 | char *clr_arg = NULL; | |
718e3744 | 5740 | |
ae19d7dd | 5741 | int idx = 0; |
01080f7c | 5742 | |
ae19d7dd QY |
5743 | /* clear [ip] bgp */ |
5744 | if (argv_find (argv, argc, "ip", &idx)) | |
5745 | afi = AFI_IP; | |
5746 | /* [<view|vrf> WORD] */ | |
5747 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
838758ac | 5748 | { |
ae19d7dd QY |
5749 | vrf = argv[idx + 1]->arg; |
5750 | idx += 2; | |
838758ac | 5751 | } |
ae19d7dd QY |
5752 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ |
5753 | if (argv_find (argv, argc, "*", &idx)) | |
b09b5ae0 | 5754 | { |
ae19d7dd | 5755 | clr_sort = clear_all; |
b09b5ae0 | 5756 | } |
ae19d7dd | 5757 | else if (argv_find (argv, argc, "A.B.C.D", &idx)) |
b09b5ae0 DW |
5758 | { |
5759 | clr_sort = clear_peer; | |
ae19d7dd | 5760 | clr_arg = argv[idx]->arg; |
b09b5ae0 | 5761 | } |
ae19d7dd | 5762 | else if (argv_find (argv, argc, "X:X::X:X", &idx)) |
b09b5ae0 | 5763 | { |
ae19d7dd QY |
5764 | clr_sort = clear_peer; |
5765 | clr_arg = argv[idx]->arg; | |
838758ac | 5766 | } |
ae19d7dd | 5767 | else if (argv_find (argv, argc, "peer-group", &idx)) |
b09b5ae0 DW |
5768 | { |
5769 | clr_sort = clear_group; | |
ae19d7dd QY |
5770 | idx++; |
5771 | clr_arg = argv[idx]->arg; | |
718e3744 | 5772 | |
cdc2d765 | 5773 | if (! peer_group_lookup (bgp, clr_arg)) |
b09b5ae0 DW |
5774 | { |
5775 | vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE); | |
ae19d7dd | 5776 | return CMD_WARNING; |
b09b5ae0 DW |
5777 | } |
5778 | } | |
ae19d7dd | 5779 | else if (argv_find (argv, argc, "WORD", &idx)) |
b09b5ae0 | 5780 | { |
cdc2d765 | 5781 | if (peer_lookup_by_conf_if (bgp, argv[idx]->arg)) |
b09b5ae0 DW |
5782 | { |
5783 | clr_sort = clear_peer; | |
ae19d7dd | 5784 | clr_arg = argv[idx]->arg; |
b09b5ae0 DW |
5785 | } |
5786 | else | |
5787 | { | |
5788 | vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE); | |
5789 | return CMD_WARNING; | |
5790 | } | |
5791 | } | |
ae19d7dd QY |
5792 | else if (argv_find (argv, argc, "(1-4294967295)", &idx)) |
5793 | { | |
5794 | clr_sort = clear_as; | |
5795 | clr_arg = argv[idx]->arg; | |
5796 | } | |
5797 | else if (argv_find (argv, argc, "external", &idx)) | |
5798 | { | |
5799 | clr_sort = clear_external; | |
5800 | } | |
46f296b4 LB |
5801 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
5802 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
ae19d7dd | 5803 | { |
46f296b4 | 5804 | argv_find_and_parse_safi (argv, argc, &idx, &safi); |
ae19d7dd QY |
5805 | } |
5806 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
5807 | if (argv_find (argv, argc, "soft", &idx)) | |
5808 | { | |
5809 | if (argv_find (argv, argc, "in", &idx) || argv_find (argv, argc, "out", &idx)) | |
5810 | clr_type = strmatch (argv[idx]->text, "in") ? BGP_CLEAR_SOFT_IN : BGP_CLEAR_SOFT_OUT; | |
5811 | else | |
5812 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
5813 | } | |
5814 | else if (argv_find (argv, argc, "in", &idx)) | |
5815 | { | |
5816 | clr_type = argv_find (argv, argc, "prefix-filter", &idx) ? BGP_CLEAR_SOFT_IN_ORF_PREFIX : BGP_CLEAR_SOFT_IN; | |
5817 | } | |
5818 | else if (argv_find (argv, argc, "out", &idx)) | |
5819 | { | |
5daa3e5e | 5820 | clr_type = BGP_CLEAR_SOFT_OUT; |
ae19d7dd QY |
5821 | } |
5822 | else | |
5823 | clr_type = BGP_CLEAR_SOFT_NONE; | |
718e3744 | 5824 | |
b09b5ae0 | 5825 | return bgp_clear_vty (vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); |
838758ac | 5826 | } |
01080f7c | 5827 | |
8ad7271d DS |
5828 | DEFUN (clear_ip_bgp_prefix, |
5829 | clear_ip_bgp_prefix_cmd, | |
838758ac | 5830 | "clear [ip] bgp [<view|vrf> WORD] prefix A.B.C.D/M", |
8ad7271d DS |
5831 | CLEAR_STR |
5832 | IP_STR | |
5833 | BGP_STR | |
838758ac | 5834 | BGP_INSTANCE_HELP_STR |
8ad7271d | 5835 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 5836 | "IPv4 prefix\n") |
8ad7271d | 5837 | { |
8334fd5a | 5838 | char *vrf = NULL; |
630a298c | 5839 | char *prefix = NULL; |
8ad7271d | 5840 | |
630a298c | 5841 | int idx = 0; |
01080f7c | 5842 | |
630a298c QY |
5843 | /* [<view|vrf> WORD] */ |
5844 | if (argv_find (argv, argc, "WORD", &idx)) | |
5845 | vrf = argv[idx]->arg; | |
0c7b1b01 | 5846 | |
630a298c | 5847 | prefix = argv[argc-1]->arg; |
8ad7271d | 5848 | |
630a298c | 5849 | return bgp_clear_prefix (vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 5850 | } |
8ad7271d | 5851 | |
b09b5ae0 DW |
5852 | DEFUN (clear_bgp_ipv6_safi_prefix, |
5853 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 5854 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 5855 | CLEAR_STR |
3a2d747c | 5856 | IP_STR |
718e3744 | 5857 | BGP_STR |
8c3deaae | 5858 | "Address Family\n" |
46f296b4 | 5859 | BGP_SAFI_HELP_STR |
b09b5ae0 | 5860 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 5861 | "IPv6 prefix\n") |
718e3744 | 5862 | { |
b09b5ae0 DW |
5863 | int idx_safi = 3; |
5864 | int idx_ipv6_prefixlen = 5; | |
46f296b4 LB |
5865 | return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, |
5866 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); | |
838758ac | 5867 | } |
01080f7c | 5868 | |
b09b5ae0 DW |
5869 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
5870 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
46f296b4 | 5871 | "clear [ip] bgp <view|vrf> WORD ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 5872 | CLEAR_STR |
3a2d747c | 5873 | IP_STR |
718e3744 | 5874 | BGP_STR |
838758ac | 5875 | BGP_INSTANCE_HELP_STR |
8c3deaae | 5876 | "Address Family\n" |
46f296b4 | 5877 | BGP_SAFI_HELP_STR |
b09b5ae0 | 5878 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 5879 | "IPv6 prefix\n") |
718e3744 | 5880 | { |
b09b5ae0 | 5881 | int idx_word = 3; |
c500ae40 | 5882 | int idx_safi = 5; |
b09b5ae0 | 5883 | int idx_ipv6_prefixlen = 7; |
46f296b4 LB |
5884 | return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, |
5885 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); | |
718e3744 | 5886 | } |
5887 | ||
b09b5ae0 DW |
5888 | DEFUN (show_bgp_views, |
5889 | show_bgp_views_cmd, | |
d6e3c605 | 5890 | "show [ip] bgp views", |
b09b5ae0 | 5891 | SHOW_STR |
d6e3c605 | 5892 | IP_STR |
01080f7c | 5893 | BGP_STR |
b09b5ae0 | 5894 | "Show the defined BGP views\n") |
01080f7c | 5895 | { |
b09b5ae0 DW |
5896 | struct list *inst = bm->bgp; |
5897 | struct listnode *node; | |
5898 | struct bgp *bgp; | |
01080f7c | 5899 | |
b09b5ae0 DW |
5900 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) |
5901 | { | |
5902 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
5903 | return CMD_WARNING; | |
5904 | } | |
e52702f2 | 5905 | |
b09b5ae0 DW |
5906 | vty_out (vty, "Defined BGP views:%s", VTY_NEWLINE); |
5907 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
5908 | { | |
5909 | /* Skip VRFs. */ | |
5910 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
5911 | continue; | |
5912 | vty_out (vty, "\t%s (AS%u)%s", | |
5913 | bgp->name ? bgp->name : "(null)", | |
5914 | bgp->as, VTY_NEWLINE); | |
5915 | } | |
e52702f2 | 5916 | |
b09b5ae0 | 5917 | return CMD_SUCCESS; |
e0081f70 ML |
5918 | } |
5919 | ||
8386ac43 | 5920 | DEFUN (show_bgp_vrfs, |
5921 | show_bgp_vrfs_cmd, | |
d6e3c605 | 5922 | "show [ip] bgp vrfs [json]", |
8386ac43 | 5923 | SHOW_STR |
d6e3c605 | 5924 | IP_STR |
8386ac43 | 5925 | BGP_STR |
5926 | "Show BGP VRFs\n" | |
9973d184 | 5927 | JSON_STR) |
8386ac43 | 5928 | { |
5929 | struct list *inst = bm->bgp; | |
5930 | struct listnode *node; | |
5931 | struct bgp *bgp; | |
5932 | u_char uj = use_json(argc, argv); | |
5933 | json_object *json = NULL; | |
5934 | json_object *json_vrfs = NULL; | |
5935 | int count = 0; | |
5936 | static char header[] = "Type Id RouterId #PeersCfg #PeersEstb Name"; | |
5937 | ||
5938 | if (!bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE)) | |
5939 | { | |
5940 | vty_out (vty, "BGP Multiple Instance is not enabled%s", VTY_NEWLINE); | |
5941 | return CMD_WARNING; | |
5942 | } | |
5943 | ||
5944 | if (uj) | |
5945 | { | |
5946 | json = json_object_new_object(); | |
5947 | json_vrfs = json_object_new_object(); | |
5948 | } | |
5949 | ||
5950 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) | |
5951 | { | |
5952 | const char *name, *type; | |
5953 | struct peer *peer; | |
5954 | struct listnode *node, *nnode; | |
5955 | int peers_cfg, peers_estb; | |
5956 | json_object *json_vrf = NULL; | |
5c81a5f3 | 5957 | int vrf_id_ui; |
8386ac43 | 5958 | |
5959 | /* Skip Views. */ | |
5960 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
5961 | continue; | |
5962 | ||
5963 | count++; | |
5964 | if (!uj && count == 1) | |
5965 | vty_out (vty, "%s%s", header, VTY_NEWLINE); | |
5966 | ||
5967 | peers_cfg = peers_estb = 0; | |
5968 | if (uj) | |
5969 | json_vrf = json_object_new_object(); | |
5970 | ||
5971 | ||
5972 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
5973 | { | |
5974 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
5975 | continue; | |
5976 | peers_cfg++; | |
5977 | if (peer->status == Established) | |
5978 | peers_estb++; | |
5979 | } | |
5980 | ||
5981 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5982 | { | |
5983 | name = "Default"; | |
5984 | type = "DFLT"; | |
5985 | } | |
5986 | else | |
5987 | { | |
5988 | name = bgp->name; | |
5989 | type = "VRF"; | |
5990 | } | |
5991 | ||
5c81a5f3 | 5992 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; |
8386ac43 | 5993 | if (uj) |
5994 | { | |
5995 | json_object_string_add(json_vrf, "type", type); | |
5c81a5f3 | 5996 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); |
8386ac43 | 5997 | json_object_string_add(json_vrf, "routerId", inet_ntoa (bgp->router_id)); |
5998 | json_object_int_add(json_vrf, "numConfiguredPeers", peers_cfg); | |
5999 | json_object_int_add(json_vrf, "numEstablishedPeers", peers_estb); | |
6000 | ||
6001 | json_object_object_add(json_vrfs, name, json_vrf); | |
6002 | } | |
6003 | else | |
5c81a5f3 | 6004 | vty_out (vty, "%4s %-5d %-16s %9u %10u %s%s", |
6005 | type, vrf_id_ui, inet_ntoa (bgp->router_id), | |
8386ac43 | 6006 | peers_cfg, peers_estb, name, |
6007 | VTY_NEWLINE); | |
6008 | } | |
6009 | ||
6010 | if (uj) | |
6011 | { | |
6012 | json_object_object_add(json, "vrfs", json_vrfs); | |
6013 | ||
6014 | json_object_int_add(json, "totalVrfs", count); | |
6015 | ||
2aac5767 | 6016 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
8386ac43 | 6017 | json_object_free(json); |
6018 | } | |
6019 | else | |
6020 | { | |
6021 | if (count) | |
6022 | vty_out (vty, "%sTotal number of VRFs (including default): %d%s", | |
6023 | VTY_NEWLINE, count, VTY_NEWLINE); | |
6024 | } | |
6025 | ||
6026 | return CMD_SUCCESS; | |
6027 | } | |
6028 | ||
f412b39a | 6029 | DEFUN (show_bgp_memory, |
4bf6a362 | 6030 | show_bgp_memory_cmd, |
7fa12b13 | 6031 | "show [ip] bgp memory", |
4bf6a362 | 6032 | SHOW_STR |
3a2d747c | 6033 | IP_STR |
4bf6a362 PJ |
6034 | BGP_STR |
6035 | "Global BGP memory statistics\n") | |
6036 | { | |
6037 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
6038 | unsigned long count; | |
e52702f2 | 6039 | |
4bf6a362 PJ |
6040 | /* RIB related usage stats */ |
6041 | count = mtype_stats_alloc (MTYPE_BGP_NODE); | |
6042 | vty_out (vty, "%ld RIB nodes, using %s of memory%s", count, | |
6043 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6044 | count * sizeof (struct bgp_node)), | |
6045 | VTY_NEWLINE); | |
e52702f2 | 6046 | |
4bf6a362 PJ |
6047 | count = mtype_stats_alloc (MTYPE_BGP_ROUTE); |
6048 | vty_out (vty, "%ld BGP routes, using %s of memory%s", count, | |
6049 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6050 | count * sizeof (struct bgp_info)), | |
6051 | VTY_NEWLINE); | |
fb982c25 PJ |
6052 | if ((count = mtype_stats_alloc (MTYPE_BGP_ROUTE_EXTRA))) |
6053 | vty_out (vty, "%ld BGP route ancillaries, using %s of memory%s", count, | |
6054 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6055 | count * sizeof (struct bgp_info_extra)), | |
6056 | VTY_NEWLINE); | |
e52702f2 | 6057 | |
4bf6a362 PJ |
6058 | if ((count = mtype_stats_alloc (MTYPE_BGP_STATIC))) |
6059 | vty_out (vty, "%ld Static routes, using %s of memory%s", count, | |
6060 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6061 | count * sizeof (struct bgp_static)), | |
6062 | VTY_NEWLINE); | |
3f9c7369 DS |
6063 | |
6064 | if ((count = mtype_stats_alloc (MTYPE_BGP_PACKET))) | |
6065 | vty_out (vty, "%ld Packets, using %s of memory%s", count, | |
6066 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6067 | count * sizeof (struct bpacket)), | |
6068 | VTY_NEWLINE); | |
e52702f2 | 6069 | |
4bf6a362 PJ |
6070 | /* Adj-In/Out */ |
6071 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_IN))) | |
6072 | vty_out (vty, "%ld Adj-In entries, using %s of memory%s", count, | |
6073 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6074 | count * sizeof (struct bgp_adj_in)), | |
6075 | VTY_NEWLINE); | |
6076 | if ((count = mtype_stats_alloc (MTYPE_BGP_ADJ_OUT))) | |
6077 | vty_out (vty, "%ld Adj-Out entries, using %s of memory%s", count, | |
6078 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6079 | count * sizeof (struct bgp_adj_out)), | |
6080 | VTY_NEWLINE); | |
e52702f2 | 6081 | |
4bf6a362 PJ |
6082 | if ((count = mtype_stats_alloc (MTYPE_BGP_NEXTHOP_CACHE))) |
6083 | vty_out (vty, "%ld Nexthop cache entries, using %s of memory%s", count, | |
6084 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6085 | count * sizeof (struct bgp_nexthop_cache)), | |
6086 | VTY_NEWLINE); | |
6087 | ||
6088 | if ((count = mtype_stats_alloc (MTYPE_BGP_DAMP_INFO))) | |
6089 | vty_out (vty, "%ld Dampening entries, using %s of memory%s", count, | |
6090 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6091 | count * sizeof (struct bgp_damp_info)), | |
6092 | VTY_NEWLINE); | |
6093 | ||
6094 | /* Attributes */ | |
6095 | count = attr_count(); | |
e52702f2 QY |
6096 | vty_out (vty, "%ld BGP attributes, using %s of memory%s", count, |
6097 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6098 | count * sizeof(struct attr)), | |
4bf6a362 | 6099 | VTY_NEWLINE); |
fb982c25 | 6100 | if ((count = mtype_stats_alloc (MTYPE_ATTR_EXTRA))) |
e52702f2 QY |
6101 | vty_out (vty, "%ld BGP extra attributes, using %s of memory%s", count, |
6102 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6103 | count * sizeof(struct attr_extra)), | |
fb982c25 | 6104 | VTY_NEWLINE); |
e52702f2 | 6105 | |
4bf6a362 PJ |
6106 | if ((count = attr_unknown_count())) |
6107 | vty_out (vty, "%ld unknown attributes%s", count, VTY_NEWLINE); | |
e52702f2 | 6108 | |
4bf6a362 PJ |
6109 | /* AS_PATH attributes */ |
6110 | count = aspath_count (); | |
6111 | vty_out (vty, "%ld BGP AS-PATH entries, using %s of memory%s", count, | |
6112 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6113 | count * sizeof (struct aspath)), | |
6114 | VTY_NEWLINE); | |
e52702f2 | 6115 | |
4bf6a362 PJ |
6116 | count = mtype_stats_alloc (MTYPE_AS_SEG); |
6117 | vty_out (vty, "%ld BGP AS-PATH segments, using %s of memory%s", count, | |
6118 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6119 | count * sizeof (struct assegment)), | |
6120 | VTY_NEWLINE); | |
e52702f2 | 6121 | |
4bf6a362 PJ |
6122 | /* Other attributes */ |
6123 | if ((count = community_count ())) | |
6124 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6125 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6126 | count * sizeof (struct community)), | |
6127 | VTY_NEWLINE); | |
6128 | if ((count = mtype_stats_alloc (MTYPE_ECOMMUNITY))) | |
6129 | vty_out (vty, "%ld BGP community entries, using %s of memory%s", count, | |
6130 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6131 | count * sizeof (struct ecommunity)), | |
6132 | VTY_NEWLINE); | |
e52702f2 | 6133 | |
4bf6a362 PJ |
6134 | if ((count = mtype_stats_alloc (MTYPE_CLUSTER))) |
6135 | vty_out (vty, "%ld Cluster lists, using %s of memory%s", count, | |
6136 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6137 | count * sizeof (struct cluster_list)), | |
6138 | VTY_NEWLINE); | |
e52702f2 | 6139 | |
4bf6a362 PJ |
6140 | /* Peer related usage */ |
6141 | count = mtype_stats_alloc (MTYPE_BGP_PEER); | |
6142 | vty_out (vty, "%ld peers, using %s of memory%s", count, | |
6143 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6144 | count * sizeof (struct peer)), | |
6145 | VTY_NEWLINE); | |
e52702f2 | 6146 | |
4a1ab8e4 | 6147 | if ((count = mtype_stats_alloc (MTYPE_PEER_GROUP))) |
4bf6a362 PJ |
6148 | vty_out (vty, "%ld peer groups, using %s of memory%s", count, |
6149 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6150 | count * sizeof (struct peer_group)), | |
6151 | VTY_NEWLINE); | |
e52702f2 | 6152 | |
4bf6a362 PJ |
6153 | /* Other */ |
6154 | if ((count = mtype_stats_alloc (MTYPE_HASH))) | |
6155 | vty_out (vty, "%ld hash tables, using %s of memory%s", count, | |
6156 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6157 | count * sizeof (struct hash)), | |
6158 | VTY_NEWLINE); | |
6159 | if ((count = mtype_stats_alloc (MTYPE_HASH_BACKET))) | |
6160 | vty_out (vty, "%ld hash buckets, using %s of memory%s", count, | |
6161 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6162 | count * sizeof (struct hash_backet)), | |
6163 | VTY_NEWLINE); | |
6164 | if ((count = mtype_stats_alloc (MTYPE_BGP_REGEXP))) | |
6165 | vty_out (vty, "%ld compiled regexes, using %s of memory%s", count, | |
6166 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6167 | count * sizeof (regex_t)), | |
6168 | VTY_NEWLINE); | |
6169 | return CMD_SUCCESS; | |
6170 | } | |
fee0f4c6 | 6171 | |
718e3744 | 6172 | /* Show BGP peer's summary information. */ |
94f2b392 | 6173 | static int |
b05a1c8b | 6174 | bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, |
9f689658 | 6175 | u_char use_json, json_object *json) |
718e3744 | 6176 | { |
6177 | struct peer *peer; | |
1eb8ef25 | 6178 | struct listnode *node, *nnode; |
f14e6fdb DS |
6179 | unsigned int count = 0, dn_count = 0; |
6180 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
f933309e DW |
6181 | char neighbor_buf[VTY_BUFSIZ]; |
6182 | int neighbor_col_default_width = 16; | |
718e3744 | 6183 | int len; |
f933309e | 6184 | int max_neighbor_width = 0; |
ffd0c037 DS |
6185 | json_object *json_peer = NULL; |
6186 | json_object *json_peers = NULL; | |
718e3744 | 6187 | |
b05a1c8b DS |
6188 | if (use_json) |
6189 | { | |
9f689658 DD |
6190 | if (json == NULL) |
6191 | json = json_object_new_object(); | |
6192 | ||
f1aa5d8a | 6193 | json_peers = json_object_new_object(); |
b05a1c8b | 6194 | } |
f933309e DW |
6195 | else |
6196 | { | |
6197 | /* Loop over all neighbors that will be displayed to determine how many | |
6198 | * characters are needed for the Neighbor column | |
6199 | */ | |
6200 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) | |
6201 | { | |
6202 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6203 | continue; | |
6204 | ||
6205 | if (peer->afc[afi][safi]) | |
6206 | { | |
c9d5bd27 DS |
6207 | memset(dn_flag, '\0', sizeof(dn_flag)); |
6208 | if (peer_dynamic_neighbor(peer)) | |
6209 | dn_flag[0] = '*'; | |
6210 | ||
f933309e DW |
6211 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
6212 | sprintf(neighbor_buf, "%s%s(%s) ", dn_flag, peer->hostname, peer->host); | |
6213 | else | |
6214 | sprintf(neighbor_buf, "%s%s ", dn_flag, peer->host); | |
6215 | ||
6216 | len = strlen(neighbor_buf); | |
6217 | ||
6218 | if (len > max_neighbor_width) | |
6219 | max_neighbor_width = len; | |
6220 | } | |
6221 | } | |
6222 | ||
6223 | /* Originally we displayed the Neighbor column as 16 | |
6224 | * characters wide so make that the default | |
6225 | */ | |
6226 | if (max_neighbor_width < neighbor_col_default_width) | |
6227 | max_neighbor_width = neighbor_col_default_width; | |
6228 | } | |
b05a1c8b | 6229 | |
1eb8ef25 | 6230 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 6231 | { |
1ff9a340 DS |
6232 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
6233 | continue; | |
6234 | ||
718e3744 | 6235 | if (peer->afc[afi][safi]) |
6236 | { | |
b05a1c8b | 6237 | if (!count) |
4bf6a362 PJ |
6238 | { |
6239 | unsigned long ents; | |
6240 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
5c81a5f3 | 6241 | int vrf_id_ui; |
6242 | ||
6243 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; | |
b05a1c8b | 6244 | |
4bf6a362 | 6245 | /* Usage summary and header */ |
b05a1c8b DS |
6246 | if (use_json) |
6247 | { | |
62d6dca0 | 6248 | json_object_string_add(json, "routerId", inet_ntoa (bgp->router_id)); |
f1aa5d8a | 6249 | json_object_int_add(json, "as", bgp->as); |
9f689658 DD |
6250 | json_object_int_add(json, "vrfId", vrf_id_ui); |
6251 | json_object_string_add(json, "vrfName", | |
6252 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6253 | ? "Default" : bgp->name); | |
b05a1c8b DS |
6254 | } |
6255 | else | |
6256 | { | |
6257 | vty_out (vty, | |
5c81a5f3 | 6258 | "BGP router identifier %s, local AS number %u vrf-id %d", |
6259 | inet_ntoa (bgp->router_id), bgp->as, vrf_id_ui); | |
6aeb9e78 | 6260 | vty_out (vty, "%s", VTY_NEWLINE); |
b05a1c8b DS |
6261 | } |
6262 | ||
f188f2c4 DS |
6263 | if (bgp_update_delay_configured(bgp)) |
6264 | { | |
b05a1c8b | 6265 | if (use_json) |
f188f2c4 | 6266 | { |
62d6dca0 | 6267 | json_object_int_add(json, "updateDelayLimit", bgp->v_update_delay); |
b05a1c8b DS |
6268 | |
6269 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
62d6dca0 | 6270 | json_object_int_add(json, "updateDelayEstablishWait", bgp->v_establish_wait); |
b05a1c8b DS |
6271 | |
6272 | if (bgp_update_delay_active(bgp)) | |
6273 | { | |
62d6dca0 DS |
6274 | json_object_string_add(json, "updateDelayFirstNeighbor", bgp->update_delay_begin_time); |
6275 | json_object_boolean_true_add(json, "updateDelayInProgress"); | |
b05a1c8b DS |
6276 | } |
6277 | else | |
6278 | { | |
6279 | if (bgp->update_delay_over) | |
6280 | { | |
62d6dca0 | 6281 | json_object_string_add(json, "updateDelayFirstNeighbor", |
f1aa5d8a | 6282 | bgp->update_delay_begin_time); |
62d6dca0 | 6283 | json_object_string_add(json, "updateDelayBestpathResumed", |
f1aa5d8a | 6284 | bgp->update_delay_end_time); |
62d6dca0 | 6285 | json_object_string_add(json, "updateDelayZebraUpdateResume", |
f1aa5d8a | 6286 | bgp->update_delay_zebra_resume_time); |
62d6dca0 | 6287 | json_object_string_add(json, "updateDelayPeerUpdateResume", |
f1aa5d8a | 6288 | bgp->update_delay_peers_resume_time); |
b05a1c8b DS |
6289 | } |
6290 | } | |
f188f2c4 DS |
6291 | } |
6292 | else | |
6293 | { | |
b05a1c8b DS |
6294 | vty_out (vty, "Read-only mode update-delay limit: %d seconds%s", |
6295 | bgp->v_update_delay, VTY_NEWLINE); | |
6296 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
6297 | vty_out (vty, " Establish wait: %d seconds%s", | |
6298 | bgp->v_establish_wait, VTY_NEWLINE); | |
6299 | ||
6300 | if (bgp_update_delay_active(bgp)) | |
f188f2c4 DS |
6301 | { |
6302 | vty_out (vty, " First neighbor established: %s%s", | |
6303 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
b05a1c8b DS |
6304 | vty_out (vty, " Delay in progress%s", VTY_NEWLINE); |
6305 | } | |
6306 | else | |
6307 | { | |
6308 | if (bgp->update_delay_over) | |
6309 | { | |
6310 | vty_out (vty, " First neighbor established: %s%s", | |
6311 | bgp->update_delay_begin_time, VTY_NEWLINE); | |
6312 | vty_out (vty, " Best-paths resumed: %s%s", | |
6313 | bgp->update_delay_end_time, VTY_NEWLINE); | |
6314 | vty_out (vty, " zebra update resumed: %s%s", | |
6315 | bgp->update_delay_zebra_resume_time, VTY_NEWLINE); | |
6316 | vty_out (vty, " peers update resumed: %s%s", | |
6317 | bgp->update_delay_peers_resume_time, VTY_NEWLINE); | |
6318 | } | |
f188f2c4 DS |
6319 | } |
6320 | } | |
6321 | } | |
4bf6a362 | 6322 | |
b05a1c8b DS |
6323 | if (use_json) |
6324 | { | |
6325 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
62d6dca0 | 6326 | json_object_boolean_true_add(json, "maxMedOnStartup"); |
b05a1c8b | 6327 | if (bgp->v_maxmed_admin) |
62d6dca0 | 6328 | json_object_boolean_true_add(json, "maxMedAdministrative"); |
b05a1c8b | 6329 | |
62d6dca0 | 6330 | json_object_int_add(json, "tableVersion", bgp_table_version(bgp->rib[afi][safi])); |
b05a1c8b DS |
6331 | |
6332 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
62d6dca0 DS |
6333 | json_object_int_add(json, "ribCount", ents); |
6334 | json_object_int_add(json, "ribMemory", ents * sizeof (struct bgp_node)); | |
b05a1c8b DS |
6335 | |
6336 | ents = listcount (bgp->peer); | |
62d6dca0 DS |
6337 | json_object_int_add(json, "peerCount", ents); |
6338 | json_object_int_add(json, "peerMemory", ents * sizeof (struct peer)); | |
b05a1c8b | 6339 | |
b05a1c8b DS |
6340 | if ((ents = listcount (bgp->group))) |
6341 | { | |
62d6dca0 DS |
6342 | json_object_int_add(json, "peerGroupCount", ents); |
6343 | json_object_int_add(json, "peerGroupMemory", ents * sizeof (struct peer_group)); | |
b05a1c8b | 6344 | } |
3f9c7369 | 6345 | |
b05a1c8b | 6346 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) |
62d6dca0 | 6347 | json_object_boolean_true_add(json, "dampeningEnabled"); |
b05a1c8b DS |
6348 | } |
6349 | else | |
6350 | { | |
6351 | if (bgp_maxmed_onstartup_configured(bgp) && bgp->maxmed_active) | |
6352 | vty_out (vty, "Max-med on-startup active%s", VTY_NEWLINE); | |
6353 | if (bgp->v_maxmed_admin) | |
6354 | vty_out (vty, "Max-med administrative active%s", VTY_NEWLINE); | |
6355 | ||
ffd0c037 | 6356 | vty_out(vty, "BGP table version %" PRIu64 "%s", |
b05a1c8b DS |
6357 | bgp_table_version(bgp->rib[afi][safi]), VTY_NEWLINE); |
6358 | ||
6359 | ents = bgp_table_count (bgp->rib[afi][safi]); | |
6360 | vty_out (vty, "RIB entries %ld, using %s of memory%s", ents, | |
6361 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6362 | ents * sizeof (struct bgp_node)), | |
6363 | VTY_NEWLINE); | |
6364 | ||
6365 | /* Peer related usage */ | |
6366 | ents = listcount (bgp->peer); | |
6367 | vty_out (vty, "Peers %ld, using %s of memory%s", | |
6368 | ents, | |
6369 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6370 | ents * sizeof (struct peer)), | |
6371 | VTY_NEWLINE); | |
6372 | ||
b05a1c8b DS |
6373 | if ((ents = listcount (bgp->group))) |
6374 | vty_out (vty, "Peer groups %ld, using %s of memory%s", ents, | |
6375 | mtype_memstr (memstrbuf, sizeof (memstrbuf), | |
6376 | ents * sizeof (struct peer_group)), | |
6377 | VTY_NEWLINE); | |
6378 | ||
6379 | if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) | |
6380 | vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE); | |
6381 | vty_out (vty, "%s", VTY_NEWLINE); | |
f933309e DW |
6382 | |
6383 | /* Subtract 8 here because 'Neighbor' is 8 characters */ | |
6384 | vty_out (vty, "Neighbor"); | |
6385 | vty_out (vty, "%*s", max_neighbor_width - 8, " "); | |
6386 | vty_out (vty, "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd%s", VTY_NEWLINE); | |
b05a1c8b | 6387 | } |
4bf6a362 | 6388 | } |
e52702f2 | 6389 | |
b05a1c8b | 6390 | count++; |
718e3744 | 6391 | |
b05a1c8b DS |
6392 | if (use_json) |
6393 | { | |
6394 | json_peer = json_object_new_object(); | |
f14e6fdb | 6395 | |
b05a1c8b | 6396 | if (peer_dynamic_neighbor(peer)) |
62d6dca0 | 6397 | json_object_boolean_true_add(json_peer, "dynamicPeer"); |
b05a1c8b | 6398 | |
04b6bdc0 DW |
6399 | if (peer->hostname) |
6400 | json_object_string_add(json_peer, "hostname", peer->hostname); | |
6401 | ||
6402 | if (peer->domainname) | |
6403 | json_object_string_add(json_peer, "domainname", peer->domainname); | |
6404 | ||
62d6dca0 | 6405 | json_object_int_add(json_peer, "remoteAs", peer->as); |
f1aa5d8a | 6406 | json_object_int_add(json_peer, "version", 4); |
62d6dca0 | 6407 | json_object_int_add(json_peer, "msgRcvd", |
f1aa5d8a DS |
6408 | peer->open_in + peer->update_in + peer->keepalive_in |
6409 | + peer->notify_in + peer->refresh_in | |
6410 | + peer->dynamic_cap_in); | |
62d6dca0 | 6411 | json_object_int_add(json_peer, "msgSent", |
f1aa5d8a DS |
6412 | peer->open_out + peer->update_out + peer->keepalive_out |
6413 | + peer->notify_out + peer->refresh_out | |
6414 | + peer->dynamic_cap_out); | |
6415 | ||
62d6dca0 | 6416 | json_object_int_add(json_peer, "tableVersion", peer->version[afi][safi]); |
f1aa5d8a DS |
6417 | json_object_int_add(json_peer, "outq", peer->obuf->count); |
6418 | json_object_int_add(json_peer, "inq", 0); | |
856ca177 | 6419 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer); |
62d6dca0 | 6420 | json_object_int_add(json_peer, "prefixReceivedCount", peer->pcount[afi][safi]); |
b05a1c8b DS |
6421 | |
6422 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
f1aa5d8a | 6423 | json_object_string_add(json_peer, "state", "Idle (Admin)"); |
b05a1c8b | 6424 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
f1aa5d8a | 6425 | json_object_string_add(json_peer, "state", "Idle (PfxCt)"); |
b05a1c8b | 6426 | else |
f1aa5d8a | 6427 | json_object_string_add(json_peer, "state", LOOKUP(bgp_status_msg, peer->status)); |
b05a1c8b | 6428 | |
f1aa5d8a | 6429 | if (peer->conf_if) |
62d6dca0 | 6430 | json_object_string_add(json_peer, "idType", "interface"); |
f1aa5d8a | 6431 | else if (peer->su.sa.sa_family == AF_INET) |
62d6dca0 | 6432 | json_object_string_add(json_peer, "idType", "ipv4"); |
f1aa5d8a | 6433 | else if (peer->su.sa.sa_family == AF_INET6) |
62d6dca0 | 6434 | json_object_string_add(json_peer, "idType", "ipv6"); |
b05a1c8b | 6435 | |
f1aa5d8a | 6436 | json_object_object_add(json_peers, peer->host, json_peer); |
b05a1c8b DS |
6437 | } |
6438 | else | |
6439 | { | |
6440 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
6441 | if (peer_dynamic_neighbor(peer)) | |
6442 | { | |
6443 | dn_count++; | |
6444 | dn_flag[0] = '*'; | |
6445 | } | |
6446 | ||
04b6bdc0 DW |
6447 | if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
6448 | len = vty_out (vty, "%s%s(%s)", dn_flag, peer->hostname, | |
6449 | peer->host); | |
6450 | else | |
6451 | len = vty_out (vty, "%s%s", dn_flag, peer->host); | |
b05a1c8b | 6452 | |
f933309e DW |
6453 | /* pad the neighbor column with spaces */ |
6454 | if (len < max_neighbor_width) | |
6455 | vty_out (vty, "%*s", max_neighbor_width - len, " "); | |
b05a1c8b | 6456 | |
f933309e | 6457 | vty_out (vty, "4 %10u %7d %7d %8" PRIu64 " %4d %4zd %8s", |
b05a1c8b DS |
6458 | peer->as, |
6459 | peer->open_in + peer->update_in + peer->keepalive_in | |
6460 | + peer->notify_in + peer->refresh_in | |
6461 | + peer->dynamic_cap_in, | |
6462 | peer->open_out + peer->update_out + peer->keepalive_out | |
6463 | + peer->notify_out + peer->refresh_out | |
6464 | + peer->dynamic_cap_out, | |
6465 | peer->version[afi][safi], | |
6466 | 0, | |
f933309e | 6467 | peer->obuf->count, |
856ca177 | 6468 | peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); |
b05a1c8b DS |
6469 | |
6470 | if (peer->status == Established) | |
46f8c104 | 6471 | vty_out (vty, " %12ld", peer->pcount[afi][safi]); |
b05a1c8b DS |
6472 | else |
6473 | { | |
6474 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
6475 | vty_out (vty, " Idle (Admin)"); | |
6476 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
6477 | vty_out (vty, " Idle (PfxCt)"); | |
6478 | else | |
f933309e | 6479 | vty_out (vty, " %12s", LOOKUP(bgp_status_msg, peer->status)); |
b05a1c8b DS |
6480 | } |
6481 | vty_out (vty, "%s", VTY_NEWLINE); | |
6482 | } | |
718e3744 | 6483 | } |
6484 | } | |
6485 | ||
b05a1c8b DS |
6486 | if (use_json) |
6487 | { | |
6488 | json_object_object_add(json, "peers", json_peers); | |
14151a32 | 6489 | |
62d6dca0 DS |
6490 | json_object_int_add(json, "totalPeers", count); |
6491 | json_object_int_add(json, "dynamicPeers", dn_count); | |
14151a32 | 6492 | |
2aac5767 | 6493 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
f1aa5d8a | 6494 | json_object_free(json); |
b05a1c8b DS |
6495 | } |
6496 | else | |
f14e6fdb | 6497 | { |
b05a1c8b DS |
6498 | if (count) |
6499 | vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE, | |
6500 | count, VTY_NEWLINE); | |
6501 | else | |
9f689658 DD |
6502 | { |
6503 | if (use_json) | |
6504 | vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}%s", | |
46f296b4 | 6505 | afi_safi_print(afi, safi), VTY_NEWLINE); |
9f689658 DD |
6506 | else |
6507 | vty_out (vty, "No %s neighbor is configured%s", | |
46f296b4 | 6508 | afi_safi_print(afi, safi), VTY_NEWLINE); |
9f689658 | 6509 | } |
b05a1c8b | 6510 | |
9f689658 | 6511 | if (dn_count && ! use_json) |
b05a1c8b DS |
6512 | { |
6513 | vty_out(vty, "* - dynamic neighbor%s", VTY_NEWLINE); | |
6514 | vty_out(vty, | |
6515 | "%d dynamic neighbor(s), limit %d%s", | |
6516 | dn_count, bgp->dynamic_neighbors_limit, VTY_NEWLINE); | |
6517 | } | |
f14e6fdb DS |
6518 | } |
6519 | ||
718e3744 | 6520 | return CMD_SUCCESS; |
6521 | } | |
6522 | ||
f186de26 | 6523 | static void |
6524 | bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, | |
6525 | u_char use_json) | |
6526 | { | |
6527 | struct listnode *node, *nnode; | |
6528 | struct bgp *bgp; | |
9f689658 DD |
6529 | json_object *json = NULL; |
6530 | int is_first = 1; | |
6531 | ||
6532 | if (use_json) | |
6533 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 6534 | |
6535 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
6536 | { | |
9f689658 DD |
6537 | if (use_json) |
6538 | { | |
4fb25c53 | 6539 | json = json_object_new_object(); |
9f689658 DD |
6540 | |
6541 | if (! is_first) | |
6542 | vty_out (vty, ",%s", VTY_NEWLINE); | |
6543 | else | |
6544 | is_first = 0; | |
6545 | ||
6546 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6547 | ? "Default" : bgp->name); | |
6548 | } | |
6549 | else | |
6550 | { | |
6551 | vty_out (vty, "%sInstance %s:%s", | |
6552 | VTY_NEWLINE, | |
6553 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
6554 | ? "Default" : bgp->name, VTY_NEWLINE); | |
6555 | } | |
6556 | bgp_show_summary (vty, bgp, afi, safi, use_json, json); | |
f186de26 | 6557 | } |
9f689658 DD |
6558 | |
6559 | if (use_json) | |
6560 | vty_out (vty, "}%s", VTY_NEWLINE); | |
6561 | ||
f186de26 | 6562 | } |
6563 | ||
4fb25c53 DW |
6564 | static int |
6565 | bgp_show_summary_vty (struct vty *vty, const char *name, | |
6566 | afi_t afi, safi_t safi, u_char use_json) | |
6567 | { | |
6568 | struct bgp *bgp; | |
6569 | ||
6570 | if (name) | |
6571 | { | |
6572 | if (strmatch(name, "all")) | |
6573 | { | |
6574 | bgp_show_all_instances_summary_vty (vty, afi, safi, use_json); | |
6575 | return CMD_SUCCESS; | |
6576 | } | |
6577 | else | |
6578 | { | |
6579 | bgp = bgp_lookup_by_name (name); | |
6580 | ||
6581 | if (! bgp) | |
6582 | { | |
6583 | if (use_json) | |
6584 | vty_out (vty, "{}%s", VTY_NEWLINE); | |
6585 | else | |
6586 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
6587 | return CMD_WARNING; | |
6588 | } | |
6589 | ||
6590 | bgp_show_summary (vty, bgp, afi, safi, use_json, NULL); | |
6591 | return CMD_SUCCESS; | |
6592 | } | |
6593 | } | |
6594 | ||
6595 | bgp = bgp_get_default (); | |
6596 | ||
6597 | if (bgp) | |
6598 | bgp_show_summary (vty, bgp, afi, safi, use_json, NULL); | |
6599 | ||
6600 | return CMD_SUCCESS; | |
6601 | } | |
6602 | ||
716b2d8a | 6603 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 6604 | DEFUN (show_ip_bgp_summary, |
718e3744 | 6605 | show_ip_bgp_summary_cmd, |
46f296b4 | 6606 | "show [ip] bgp [<view|vrf> WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] summary [json]", |
718e3744 | 6607 | SHOW_STR |
6608 | IP_STR | |
6609 | BGP_STR | |
8386ac43 | 6610 | BGP_INSTANCE_HELP_STR |
46f296b4 LB |
6611 | BGP_AFI_HELP_STR |
6612 | BGP_SAFI_HELP_STR | |
b05a1c8b | 6613 | "Summary of BGP neighbor status\n" |
9973d184 | 6614 | JSON_STR) |
718e3744 | 6615 | { |
74ca3d33 | 6616 | char *vrf = NULL; |
46f296b4 | 6617 | afi_t afi = AFI_IP6; /* why default to v6? */ |
ae19d7dd QY |
6618 | safi_t safi = SAFI_UNICAST; |
6619 | ||
6620 | int idx = 0; | |
6621 | ||
6622 | /* show [ip] bgp */ | |
6623 | if (argv_find (argv, argc, "ip", &idx)) | |
6624 | afi = AFI_IP; | |
6625 | /* [<view|vrf> WORD] */ | |
6626 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
6627 | vrf = argv[++idx]->arg; | |
46f296b4 LB |
6628 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
6629 | if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) | |
ae19d7dd | 6630 | { |
46f296b4 | 6631 | argv_find_and_parse_safi (argv, argc, &idx, &safi); |
91d37724 QY |
6632 | } |
6633 | ||
ae19d7dd | 6634 | int uj = use_json (argc, argv); |
74ca3d33 DW |
6635 | |
6636 | return bgp_show_summary_vty (vty, vrf, afi, safi, uj); | |
718e3744 | 6637 | } |
6638 | ||
fd79ac91 | 6639 | const char * |
538621f2 | 6640 | afi_safi_print (afi_t afi, safi_t safi) |
6641 | { | |
6642 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
6643 | return "IPv4 Unicast"; | |
6644 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
6645 | return "IPv4 Multicast"; | |
6646 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
46f296b4 | 6647 | return "IPv4 VPN"; |
8b1fb8be | 6648 | else if (afi == AFI_IP && safi == SAFI_ENCAP) |
46f296b4 | 6649 | return "IPv4 Encap"; |
538621f2 | 6650 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
6651 | return "IPv6 Unicast"; | |
6652 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
6653 | return "IPv6 Multicast"; | |
945c8fe9 | 6654 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) |
46f296b4 | 6655 | return "IPv6 VPN"; |
8b1fb8be | 6656 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) |
46f296b4 | 6657 | return "IPv6 Encap"; |
538621f2 | 6658 | else |
6659 | return "Unknown"; | |
6660 | } | |
6661 | ||
718e3744 | 6662 | /* Show BGP peer's information. */ |
6663 | enum show_type | |
6664 | { | |
6665 | show_all, | |
6666 | show_peer | |
6667 | }; | |
6668 | ||
94f2b392 | 6669 | static void |
856ca177 MS |
6670 | bgp_show_peer_afi_orf_cap (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
6671 | u_int16_t adv_smcap, u_int16_t adv_rmcap, u_int16_t rcv_smcap, | |
6672 | u_int16_t rcv_rmcap, u_char use_json, json_object *json_pref) | |
718e3744 | 6673 | { |
6674 | /* Send-Mode */ | |
6675 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) | |
6676 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6677 | { | |
856ca177 MS |
6678 | if (use_json) |
6679 | { | |
6680 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6681 | json_object_string_add(json_pref, "sendMode", "advertisedAndReceived"); | |
6682 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
6683 | json_object_string_add(json_pref, "sendMode", "advertised"); | |
6684 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6685 | json_object_string_add(json_pref, "sendMode", "received"); | |
6686 | } | |
6687 | else | |
6688 | { | |
6689 | vty_out (vty, " Send-mode: "); | |
6690 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_smcap)) | |
6691 | vty_out (vty, "advertised"); | |
6692 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_smcap)) | |
6693 | vty_out (vty, "%sreceived", | |
6694 | CHECK_FLAG (p->af_cap[afi][safi], adv_smcap) ? | |
6695 | ", " : ""); | |
6696 | vty_out (vty, "%s", VTY_NEWLINE); | |
6697 | } | |
718e3744 | 6698 | } |
6699 | ||
6700 | /* Receive-Mode */ | |
6701 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) | |
6702 | || CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6703 | { | |
856ca177 MS |
6704 | if (use_json) |
6705 | { | |
6706 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) && CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6707 | json_object_string_add(json_pref, "recvMode", "advertisedAndReceived"); | |
6708 | else if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
6709 | json_object_string_add(json_pref, "recvMode", "advertised"); | |
6710 | else if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6711 | json_object_string_add(json_pref, "recvMode", "received"); | |
6712 | } | |
6713 | else | |
6714 | { | |
6715 | vty_out (vty, " Receive-mode: "); | |
6716 | if (CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap)) | |
6717 | vty_out (vty, "advertised"); | |
6718 | if (CHECK_FLAG (p->af_cap[afi][safi], rcv_rmcap)) | |
6719 | vty_out (vty, "%sreceived", | |
6720 | CHECK_FLAG (p->af_cap[afi][safi], adv_rmcap) ? | |
6721 | ", " : ""); | |
6722 | vty_out (vty, "%s", VTY_NEWLINE); | |
6723 | } | |
718e3744 | 6724 | } |
6725 | } | |
6726 | ||
94f2b392 | 6727 | static void |
856ca177 MS |
6728 | bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi, |
6729 | u_char use_json, json_object *json_neigh) | |
718e3744 | 6730 | { |
6731 | struct bgp_filter *filter; | |
3f9c7369 | 6732 | struct peer_af *paf; |
718e3744 | 6733 | char orf_pfx_name[BUFSIZ]; |
6734 | int orf_pfx_count; | |
856ca177 MS |
6735 | json_object *json_af = NULL; |
6736 | json_object *json_prefA = NULL; | |
6737 | json_object *json_prefB = NULL; | |
6738 | json_object *json_addr = NULL; | |
718e3744 | 6739 | |
856ca177 MS |
6740 | if (use_json) |
6741 | { | |
6742 | json_addr = json_object_new_object(); | |
6743 | json_af = json_object_new_object(); | |
856ca177 | 6744 | filter = &p->filter[afi][safi]; |
718e3744 | 6745 | |
c8560b44 | 6746 | if (peer_group_active(p)) |
856ca177 | 6747 | json_object_string_add(json_addr, "peerGroupMember", p->group->name); |
538621f2 | 6748 | |
856ca177 MS |
6749 | paf = peer_af_find(p, afi, safi); |
6750 | if (paf && PAF_SUBGRP(paf)) | |
6751 | { | |
6752 | json_object_int_add(json_addr, "updateGroupId", PAF_UPDGRP(paf)->id); | |
6753 | json_object_int_add(json_addr, "subGroupId", PAF_SUBGRP(paf)->id); | |
6754 | json_object_int_add(json_addr, "packetQueueLength", bpacket_queue_virtual_length(paf)); | |
6755 | } | |
6756 | ||
6757 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
6758 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
6759 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
6760 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
6761 | { | |
6762 | json_object_int_add(json_af, "orfType", ORF_TYPE_PREFIX); | |
b6df4090 | 6763 | json_prefA = json_object_new_object(); |
856ca177 MS |
6764 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
6765 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
6766 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
6767 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
6768 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, json_prefA); | |
6769 | json_object_object_add(json_af, "orfPrefixList", json_prefA); | |
6770 | } | |
6771 | ||
6772 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
6773 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
6774 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
6775 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
6776 | { | |
6777 | json_object_int_add(json_af, "orfOldType", ORF_TYPE_PREFIX_OLD); | |
b6df4090 | 6778 | json_prefB = json_object_new_object(); |
856ca177 MS |
6779 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, |
6780 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
6781 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
6782 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
6783 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, json_prefB); | |
6784 | json_object_object_add(json_af, "orfOldPrefixList", json_prefB); | |
6785 | } | |
6786 | ||
6787 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
6788 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
6789 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
6790 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
6791 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
6792 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
6793 | json_object_object_add(json_addr, "afDependentCap", json_af); | |
b6df4090 DS |
6794 | else |
6795 | json_object_free(json_af); | |
856ca177 MS |
6796 | |
6797 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
6798 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
6799 | ||
6800 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) | |
6801 | || orf_pfx_count) | |
6802 | { | |
6803 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
6804 | json_object_boolean_true_add(json_neigh, "orfSent"); | |
6805 | if (orf_pfx_count) | |
6806 | json_object_int_add(json_addr, "orfRecvCounter", orf_pfx_count); | |
6807 | } | |
6808 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
6809 | json_object_string_add(json_addr, "orfFirstUpdate", "deferredUntilORFOrRouteRefreshRecvd"); | |
6810 | ||
6811 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
6812 | json_object_boolean_true_add(json_addr, "routeReflectorClient"); | |
6813 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
6814 | json_object_boolean_true_add(json_addr, "routeServerClient"); | |
6815 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
6816 | json_object_boolean_true_add(json_addr, "inboundSoftConfigPermit"); | |
6817 | ||
88b8ed8d DW |
6818 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
6819 | json_object_boolean_true_add(json_addr, "privateAsNumsAllReplacedInUpdatesToNbr"); | |
6820 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 6821 | json_object_boolean_true_add(json_addr, "privateAsNumsReplacedInUpdatesToNbr"); |
88b8ed8d DW |
6822 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
6823 | json_object_boolean_true_add(json_addr, "privateAsNumsAllRemovedInUpdatesToNbr"); | |
856ca177 MS |
6824 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
6825 | json_object_boolean_true_add(json_addr, "privateAsNumsRemovedInUpdatesToNbr"); | |
6826 | ||
adbac85e DW |
6827 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
6828 | json_object_boolean_true_add(json_addr, "addpathTxAllPaths"); | |
6829 | ||
06370dac DW |
6830 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
6831 | json_object_boolean_true_add(json_addr, "addpathTxBestpathPerAS"); | |
6832 | ||
856ca177 MS |
6833 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
6834 | json_object_string_add(json_addr, "overrideASNsInOutboundUpdates", "ifAspathEqualRemoteAs"); | |
6835 | ||
6836 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
6837 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
6838 | json_object_boolean_true_add(json_addr, "routerAlwaysNextHop"); | |
6839 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
6840 | json_object_boolean_true_add(json_addr, "unchangedAsPathPropogatedToNbr"); | |
6841 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
6842 | json_object_boolean_true_add(json_addr, "unchangedNextHopPropogatedToNbr"); | |
6843 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
6844 | json_object_boolean_true_add(json_addr, "unchangedMedPropogatedToNbr"); | |
718e3744 | 6845 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) |
856ca177 MS |
6846 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) |
6847 | { | |
6848 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
6849 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
6850 | json_object_string_add(json_addr, "commAttriSentToNbr", "extendedAndStandard"); | |
6851 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
6852 | json_object_string_add(json_addr, "commAttriSentToNbr", "extended"); | |
6853 | else | |
6854 | json_object_string_add(json_addr, "commAttriSentToNbr", "standard"); | |
6855 | } | |
6856 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
6857 | { | |
6858 | if (p->default_rmap[afi][safi].name) | |
6859 | json_object_string_add(json_addr, "defaultRouteMap", p->default_rmap[afi][safi].name); | |
6860 | ||
6861 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
6862 | json_object_boolean_true_add(json_addr, "defaultSent"); | |
6863 | else | |
6864 | json_object_boolean_true_add(json_addr, "defaultNotSent"); | |
6865 | } | |
6866 | ||
6867 | if (filter->plist[FILTER_IN].name | |
6868 | || filter->dlist[FILTER_IN].name | |
6869 | || filter->aslist[FILTER_IN].name | |
6870 | || filter->map[RMAP_IN].name) | |
6871 | json_object_boolean_true_add(json_addr, "inboundPathPolicyConfig"); | |
6872 | if (filter->plist[FILTER_OUT].name | |
6873 | || filter->dlist[FILTER_OUT].name | |
6874 | || filter->aslist[FILTER_OUT].name | |
6875 | || filter->map[RMAP_OUT].name | |
6876 | || filter->usmap.name) | |
6877 | json_object_boolean_true_add(json_addr, "outboundPathPolicyConfig"); | |
856ca177 MS |
6878 | |
6879 | /* prefix-list */ | |
6880 | if (filter->plist[FILTER_IN].name) | |
6881 | json_object_string_add(json_addr, "incomingUpdatePrefixFilterList", filter->plist[FILTER_IN].name); | |
6882 | if (filter->plist[FILTER_OUT].name) | |
6883 | json_object_string_add(json_addr, "outgoingUpdatePrefixFilterList", filter->plist[FILTER_OUT].name); | |
6884 | ||
6885 | /* distribute-list */ | |
6886 | if (filter->dlist[FILTER_IN].name) | |
6887 | json_object_string_add(json_addr, "incomingUpdateNetworkFilterList", filter->dlist[FILTER_IN].name); | |
6888 | if (filter->dlist[FILTER_OUT].name) | |
6889 | json_object_string_add(json_addr, "outgoingUpdateNetworkFilterList", filter->dlist[FILTER_OUT].name); | |
6890 | ||
6891 | /* filter-list. */ | |
6892 | if (filter->aslist[FILTER_IN].name) | |
6893 | json_object_string_add(json_addr, "incomingUpdateAsPathFilterList", filter->aslist[FILTER_IN].name); | |
6894 | if (filter->aslist[FILTER_OUT].name) | |
6895 | json_object_string_add(json_addr, "outgoingUpdateAsPathFilterList", filter->aslist[FILTER_OUT].name); | |
6896 | ||
6897 | /* route-map. */ | |
6898 | if (filter->map[RMAP_IN].name) | |
6899 | json_object_string_add(json_addr, "routeMapForIncomingAdvertisements", filter->map[RMAP_IN].name); | |
6900 | if (filter->map[RMAP_OUT].name) | |
6901 | json_object_string_add(json_addr, "routeMapForOutgoingAdvertisements", filter->map[RMAP_OUT].name); | |
856ca177 MS |
6902 | |
6903 | /* unsuppress-map */ | |
6904 | if (filter->usmap.name) | |
6905 | json_object_string_add(json_addr, "selectiveUnsuppressRouteMap", filter->usmap.name); | |
6906 | ||
6907 | /* Receive prefix count */ | |
6908 | json_object_int_add(json_addr, "acceptedPrefixCounter", p->pcount[afi][safi]); | |
6909 | ||
6910 | /* Maximum prefix */ | |
6911 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
6912 | { | |
6913 | json_object_int_add(json_addr, "prefixAllowedMax", p->pmax[afi][safi]); | |
6914 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) | |
6915 | json_object_boolean_true_add(json_addr, "prefixAllowedMaxWarning"); | |
6916 | json_object_int_add(json_addr, "prefixAllowedWarningThresh", p->pmax_threshold[afi][safi]); | |
6917 | if (p->pmax_restart[afi][safi]) | |
6918 | json_object_int_add(json_addr, "prefixAllowedRestartIntervalMsecs", p->pmax_restart[afi][safi] * 60000); | |
6919 | } | |
6920 | json_object_object_add(json_neigh, afi_safi_print (afi, safi), json_addr); | |
6921 | ||
6922 | } | |
6923 | else | |
6924 | { | |
6925 | filter = &p->filter[afi][safi]; | |
6926 | ||
6927 | vty_out (vty, " For address family: %s%s", afi_safi_print (afi, safi), | |
6928 | VTY_NEWLINE); | |
6929 | ||
c8560b44 | 6930 | if (peer_group_active(p)) |
856ca177 MS |
6931 | vty_out (vty, " %s peer-group member%s", p->group->name, VTY_NEWLINE); |
6932 | ||
6933 | paf = peer_af_find(p, afi, safi); | |
6934 | if (paf && PAF_SUBGRP(paf)) | |
6935 | { | |
6936 | vty_out (vty, " Update group %" PRIu64 ", subgroup %" PRIu64 "%s", | |
6937 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id, VTY_NEWLINE); | |
6938 | vty_out (vty, " Packet Queue length %d%s", | |
6939 | bpacket_queue_virtual_length(paf), VTY_NEWLINE); | |
6940 | } | |
718e3744 | 6941 | else |
856ca177 MS |
6942 | { |
6943 | vty_out(vty, " Not part of any update group%s", VTY_NEWLINE); | |
6944 | } | |
6945 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
6946 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
6947 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
6948 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
6949 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV) | |
6950 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
6951 | vty_out (vty, " AF-dependant capabilities:%s", VTY_NEWLINE); | |
6952 | ||
6953 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
6954 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_RCV) | |
6955 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
6956 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_RCV)) | |
6957 | { | |
6958 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
6959 | ORF_TYPE_PREFIX, VTY_NEWLINE); | |
6960 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
6961 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
6962 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
6963 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
6964 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
6965 | } | |
6966 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
6967 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
6968 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_ADV) | |
6969 | || CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
6970 | { | |
6971 | vty_out (vty, " Outbound Route Filter (ORF) type (%d) Prefix-list:%s", | |
6972 | ORF_TYPE_PREFIX_OLD, VTY_NEWLINE); | |
6973 | bgp_show_peer_afi_orf_cap (vty, p, afi, safi, | |
6974 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
6975 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
6976 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
6977 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
6978 | } | |
718e3744 | 6979 | |
856ca177 MS |
6980 | sprintf (orf_pfx_name, "%s.%d.%d", p->host, afi, safi); |
6981 | orf_pfx_count = prefix_bgp_show_prefix_list (NULL, afi, orf_pfx_name, use_json); | |
718e3744 | 6982 | |
856ca177 MS |
6983 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND) |
6984 | || orf_pfx_count) | |
6985 | { | |
6986 | vty_out (vty, " Outbound Route Filter (ORF):"); | |
6987 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_PREFIX_SEND)) | |
6988 | vty_out (vty, " sent;"); | |
6989 | if (orf_pfx_count) | |
6990 | vty_out (vty, " received (%d entries)", orf_pfx_count); | |
6991 | vty_out (vty, "%s", VTY_NEWLINE); | |
6992 | } | |
6993 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_ORF_WAIT_REFRESH)) | |
6994 | vty_out (vty, " First update is deferred until ORF or ROUTE-REFRESH is received%s", VTY_NEWLINE); | |
6995 | ||
6996 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) | |
6997 | vty_out (vty, " Route-Reflector Client%s", VTY_NEWLINE); | |
6998 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) | |
6999 | vty_out (vty, " Route-Server Client%s", VTY_NEWLINE); | |
7000 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7001 | vty_out (vty, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE); | |
7002 | ||
88b8ed8d DW |
7003 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) |
7004 | vty_out (vty, " Private AS numbers (all) replaced in updates to this neighbor%s", VTY_NEWLINE); | |
7005 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
856ca177 | 7006 | vty_out (vty, " Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE); |
88b8ed8d DW |
7007 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) |
7008 | vty_out (vty, " Private AS numbers (all) removed in updates to this neighbor%s", VTY_NEWLINE); | |
856ca177 MS |
7009 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS)) |
7010 | vty_out (vty, " Private AS numbers removed in updates to this neighbor%s", VTY_NEWLINE); | |
7011 | ||
adbac85e DW |
7012 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_ALL_PATHS)) |
7013 | vty_out (vty, " Advertise all paths via addpath%s", VTY_NEWLINE); | |
7014 | ||
06370dac DW |
7015 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) |
7016 | vty_out (vty, " Advertise bestpath per AS via addpath%s", VTY_NEWLINE); | |
7017 | ||
856ca177 MS |
7018 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) |
7019 | vty_out (vty, " Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE); | |
7020 | ||
7021 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) || | |
7022 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7023 | vty_out (vty, " NEXT_HOP is always this router%s", VTY_NEWLINE); | |
7024 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED)) | |
7025 | vty_out (vty, " AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7026 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7027 | vty_out (vty, " NEXT_HOP is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7028 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7029 | vty_out (vty, " MED is propagated unchanged to this neighbor%s", VTY_NEWLINE); | |
7030 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7031 | || CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7032 | { | |
7033 | vty_out (vty, " Community attribute sent to this neighbor"); | |
7034 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7035 | && CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7036 | vty_out (vty, "(both)%s", VTY_NEWLINE); | |
7037 | else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7038 | vty_out (vty, "(extended)%s", VTY_NEWLINE); | |
7039 | else | |
7040 | vty_out (vty, "(standard)%s", VTY_NEWLINE); | |
7041 | } | |
7042 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE)) | |
7043 | { | |
7044 | vty_out (vty, " Default information originate,"); | |
7045 | ||
7046 | if (p->default_rmap[afi][safi].name) | |
7047 | vty_out (vty, " default route-map %s%s,", | |
7048 | p->default_rmap[afi][safi].map ? "*" : "", | |
7049 | p->default_rmap[afi][safi].name); | |
7050 | if (paf && PAF_SUBGRP(paf) && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7051 | vty_out (vty, " default sent%s", VTY_NEWLINE); | |
7052 | else | |
7053 | vty_out (vty, " default not sent%s", VTY_NEWLINE); | |
7054 | } | |
718e3744 | 7055 | |
856ca177 MS |
7056 | if (filter->plist[FILTER_IN].name |
7057 | || filter->dlist[FILTER_IN].name | |
7058 | || filter->aslist[FILTER_IN].name | |
7059 | || filter->map[RMAP_IN].name) | |
7060 | vty_out (vty, " Inbound path policy configured%s", VTY_NEWLINE); | |
7061 | if (filter->plist[FILTER_OUT].name | |
7062 | || filter->dlist[FILTER_OUT].name | |
7063 | || filter->aslist[FILTER_OUT].name | |
7064 | || filter->map[RMAP_OUT].name | |
7065 | || filter->usmap.name) | |
7066 | vty_out (vty, " Outbound path policy configured%s", VTY_NEWLINE); | |
856ca177 MS |
7067 | |
7068 | /* prefix-list */ | |
7069 | if (filter->plist[FILTER_IN].name) | |
7070 | vty_out (vty, " Incoming update prefix filter list is %s%s%s", | |
7071 | filter->plist[FILTER_IN].plist ? "*" : "", | |
7072 | filter->plist[FILTER_IN].name, | |
7073 | VTY_NEWLINE); | |
7074 | if (filter->plist[FILTER_OUT].name) | |
7075 | vty_out (vty, " Outgoing update prefix filter list is %s%s%s", | |
7076 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
7077 | filter->plist[FILTER_OUT].name, | |
7078 | VTY_NEWLINE); | |
7079 | ||
7080 | /* distribute-list */ | |
7081 | if (filter->dlist[FILTER_IN].name) | |
7082 | vty_out (vty, " Incoming update network filter list is %s%s%s", | |
7083 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
7084 | filter->dlist[FILTER_IN].name, | |
7085 | VTY_NEWLINE); | |
7086 | if (filter->dlist[FILTER_OUT].name) | |
7087 | vty_out (vty, " Outgoing update network filter list is %s%s%s", | |
7088 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
7089 | filter->dlist[FILTER_OUT].name, | |
7090 | VTY_NEWLINE); | |
7091 | ||
7092 | /* filter-list. */ | |
7093 | if (filter->aslist[FILTER_IN].name) | |
7094 | vty_out (vty, " Incoming update AS path filter list is %s%s%s", | |
7095 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
7096 | filter->aslist[FILTER_IN].name, | |
7097 | VTY_NEWLINE); | |
7098 | if (filter->aslist[FILTER_OUT].name) | |
7099 | vty_out (vty, " Outgoing update AS path filter list is %s%s%s", | |
7100 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
7101 | filter->aslist[FILTER_OUT].name, | |
7102 | VTY_NEWLINE); | |
7103 | ||
7104 | /* route-map. */ | |
7105 | if (filter->map[RMAP_IN].name) | |
7106 | vty_out (vty, " Route map for incoming advertisements is %s%s%s", | |
7107 | filter->map[RMAP_IN].map ? "*" : "", | |
7108 | filter->map[RMAP_IN].name, | |
7109 | VTY_NEWLINE); | |
7110 | if (filter->map[RMAP_OUT].name) | |
7111 | vty_out (vty, " Route map for outgoing advertisements is %s%s%s", | |
7112 | filter->map[RMAP_OUT].map ? "*" : "", | |
7113 | filter->map[RMAP_OUT].name, | |
7114 | VTY_NEWLINE); | |
856ca177 MS |
7115 | |
7116 | /* unsuppress-map */ | |
7117 | if (filter->usmap.name) | |
7118 | vty_out (vty, " Route map for selective unsuppress is %s%s%s", | |
7119 | filter->usmap.map ? "*" : "", | |
7120 | filter->usmap.name, VTY_NEWLINE); | |
7121 | ||
7122 | /* Receive prefix count */ | |
7123 | vty_out (vty, " %ld accepted prefixes%s", p->pcount[afi][safi], VTY_NEWLINE); | |
7124 | ||
7125 | /* Maximum prefix */ | |
7126 | if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) | |
7127 | { | |
7128 | vty_out (vty, " Maximum prefixes allowed %ld%s%s", p->pmax[afi][safi], | |
7129 | CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING) | |
7130 | ? " (warning-only)" : "", VTY_NEWLINE); | |
7131 | vty_out (vty, " Threshold for warning message %d%%", | |
7132 | p->pmax_threshold[afi][safi]); | |
7133 | if (p->pmax_restart[afi][safi]) | |
7134 | vty_out (vty, ", restart interval %d min", p->pmax_restart[afi][safi]); | |
7135 | vty_out (vty, "%s", VTY_NEWLINE); | |
7136 | } | |
718e3744 | 7137 | |
0a486e5f | 7138 | vty_out (vty, "%s", VTY_NEWLINE); |
718e3744 | 7139 | } |
718e3744 | 7140 | } |
7141 | ||
94f2b392 | 7142 | static void |
e8f7da3a | 7143 | bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *json) |
718e3744 | 7144 | { |
7145 | struct bgp *bgp; | |
4690c7d7 | 7146 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; |
718e3744 | 7147 | char timebuf[BGP_UPTIME_LEN]; |
f14e6fdb | 7148 | char dn_flag[2]; |
3a8c7ba1 DW |
7149 | const char *subcode_str; |
7150 | const char *code_str; | |
538621f2 | 7151 | afi_t afi; |
7152 | safi_t safi; | |
d6661008 DS |
7153 | u_int16_t i; |
7154 | u_char *msg; | |
e8f7da3a | 7155 | json_object *json_neigh = NULL; |
718e3744 | 7156 | |
7157 | bgp = p->bgp; | |
7158 | ||
e8f7da3a DW |
7159 | if (use_json) |
7160 | json_neigh = json_object_new_object(); | |
7161 | ||
856ca177 | 7162 | if (!use_json) |
f14e6fdb | 7163 | { |
856ca177 MS |
7164 | if (p->conf_if) /* Configured interface name. */ |
7165 | vty_out (vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
7166 | BGP_PEER_SU_UNSPEC(p) ? "None" : | |
7167 | sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
7168 | else /* Configured IP address. */ | |
7169 | { | |
7170 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7171 | if (peer_dynamic_neighbor(p)) | |
7172 | dn_flag[0] = '*'; | |
f14e6fdb | 7173 | |
856ca177 MS |
7174 | vty_out (vty, "BGP neighbor is %s%s, ", dn_flag, p->host); |
7175 | } | |
f14e6fdb DS |
7176 | } |
7177 | ||
856ca177 MS |
7178 | if (use_json) |
7179 | { | |
7180 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
7181 | json_object_string_add(json_neigh, "bgpNeighborAddr", "none"); | |
7182 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
7183 | json_object_string_add(json_neigh, "bgpNeighborAddr", sockunion2str (&p->su, buf, SU_ADDRSTRLEN)); | |
7184 | ||
7185 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
7186 | ||
7187 | if (p->change_local_as) | |
7188 | json_object_int_add(json_neigh, "localAs", p->change_local_as); | |
7189 | else | |
7190 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
7191 | ||
7192 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
7193 | json_object_boolean_true_add(json_neigh, "localAsNoPrepend"); | |
66b199b2 | 7194 | |
856ca177 MS |
7195 | if (CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) |
7196 | json_object_boolean_true_add(json_neigh, "localAsReplaceAs"); | |
7197 | } | |
7198 | else | |
7199 | { | |
f8cfafda DS |
7200 | if ((p->as_type == AS_SPECIFIED) || |
7201 | (p->as_type == AS_EXTERNAL) || | |
7202 | (p->as_type == AS_INTERNAL)) | |
7203 | vty_out (vty, "remote AS %u, ", p->as); | |
7204 | else | |
7205 | vty_out (vty, "remote AS Unspecified, "); | |
856ca177 MS |
7206 | vty_out (vty, "local AS %u%s%s, ", |
7207 | p->change_local_as ? p->change_local_as : p->local_as, | |
7208 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ? | |
7209 | " no-prepend" : "", | |
7210 | CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) ? | |
7211 | " replace-as" : ""); | |
7212 | } | |
66b199b2 DS |
7213 | /* peer type internal, external, confed-internal or confed-external */ |
7214 | if (p->as == p->local_as) | |
7215 | { | |
856ca177 MS |
7216 | if (use_json) |
7217 | { | |
7218 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7219 | json_object_boolean_true_add(json_neigh, "nbrConfedInternalLink"); | |
7220 | else | |
7221 | json_object_boolean_true_add(json_neigh, "nbrInternalLink"); | |
7222 | } | |
66b199b2 | 7223 | else |
856ca177 MS |
7224 | { |
7225 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7226 | vty_out (vty, "confed-internal link%s", VTY_NEWLINE); | |
7227 | else | |
7228 | vty_out (vty, "internal link%s", VTY_NEWLINE); | |
7229 | } | |
66b199b2 DS |
7230 | } |
7231 | else | |
7232 | { | |
856ca177 MS |
7233 | if (use_json) |
7234 | { | |
7235 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7236 | json_object_boolean_true_add(json_neigh, "nbrConfedExternalLink"); | |
7237 | else | |
7238 | json_object_boolean_true_add(json_neigh, "nbrExternalLink"); | |
7239 | } | |
66b199b2 | 7240 | else |
856ca177 MS |
7241 | { |
7242 | if (bgp_confederation_peers_check(bgp, p->as)) | |
7243 | vty_out (vty, "confed-external link%s", VTY_NEWLINE); | |
7244 | else | |
7245 | vty_out (vty, "external link%s", VTY_NEWLINE); | |
7246 | } | |
66b199b2 | 7247 | } |
718e3744 | 7248 | |
7249 | /* Description. */ | |
7250 | if (p->desc) | |
856ca177 MS |
7251 | { |
7252 | if (use_json) | |
7253 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
7254 | else | |
7255 | vty_out (vty, " Description: %s%s", p->desc, VTY_NEWLINE); | |
7256 | } | |
6410e93a | 7257 | |
04b6bdc0 DW |
7258 | if (p->hostname) |
7259 | { | |
d1570739 DW |
7260 | if (use_json) |
7261 | { | |
7262 | if (p->hostname) | |
7263 | json_object_string_add(json_neigh, "hostname", p->hostname); | |
7264 | ||
7265 | if (p->domainname) | |
7266 | json_object_string_add(json_neigh, "domainname", p->domainname); | |
7267 | } | |
04b6bdc0 | 7268 | else |
d1570739 DW |
7269 | { |
7270 | if (p->domainname && (p->domainname[0] != '\0')) | |
7271 | vty_out(vty, "Hostname: %s.%s%s", p->hostname, p->domainname, | |
7272 | VTY_NEWLINE); | |
7273 | else | |
7274 | vty_out(vty, "Hostname: %s%s", p->hostname, VTY_NEWLINE); | |
7275 | } | |
7276 | ||
04b6bdc0 DW |
7277 | } |
7278 | ||
c744aa9f | 7279 | /* Peer-group */ |
718e3744 | 7280 | if (p->group) |
f14e6fdb | 7281 | { |
856ca177 MS |
7282 | if (use_json) |
7283 | { | |
7284 | json_object_string_add(json_neigh, "peerGroup", p->group->name); | |
7285 | ||
7286 | if (dn_flag[0]) | |
7287 | { | |
40ee54a7 | 7288 | struct prefix prefix, *range = NULL; |
f14e6fdb | 7289 | |
40ee54a7 TT |
7290 | sockunion2hostprefix(&(p->su), &prefix); |
7291 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
7292 | |
7293 | if (range) | |
7294 | { | |
7295 | prefix2str(range, buf1, sizeof(buf1)); | |
7296 | json_object_string_add(json_neigh, "peerSubnetRangeGroup", buf1); | |
7297 | } | |
7298 | } | |
7299 | } | |
7300 | else | |
f14e6fdb | 7301 | { |
856ca177 MS |
7302 | vty_out (vty, " Member of peer-group %s for session parameters%s", |
7303 | p->group->name, VTY_NEWLINE); | |
f14e6fdb | 7304 | |
856ca177 | 7305 | if (dn_flag[0]) |
f14e6fdb | 7306 | { |
40ee54a7 | 7307 | struct prefix prefix, *range = NULL; |
856ca177 | 7308 | |
40ee54a7 TT |
7309 | sockunion2hostprefix(&(p->su), &prefix); |
7310 | range = peer_group_lookup_dynamic_neighbor_range (p->group, &prefix); | |
856ca177 MS |
7311 | |
7312 | if (range) | |
7313 | { | |
7314 | prefix2str(range, buf1, sizeof(buf1)); | |
7315 | vty_out (vty, " Belongs to the subnet range group: %s%s", buf1, VTY_NEWLINE); | |
7316 | } | |
f14e6fdb DS |
7317 | } |
7318 | } | |
7319 | } | |
718e3744 | 7320 | |
856ca177 MS |
7321 | if (use_json) |
7322 | { | |
7323 | /* Administrative shutdown. */ | |
7324 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
7325 | json_object_boolean_true_add(json_neigh, "adminShutDown"); | |
718e3744 | 7326 | |
856ca177 MS |
7327 | /* BGP Version. */ |
7328 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
7329 | json_object_string_add(json_neigh, "remoteRouterId", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ)); | |
718e3744 | 7330 | |
856ca177 MS |
7331 | /* Confederation */ |
7332 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) && bgp_confederation_peers_check (bgp, p->as)) | |
7333 | json_object_boolean_true_add(json_neigh, "nbrCommonAdmin"); | |
7334 | ||
7335 | /* Status. */ | |
7336 | json_object_string_add(json_neigh, "bgpState", LOOKUP (bgp_status_msg, p->status)); | |
7337 | ||
7338 | if (p->status == Established) | |
7339 | { | |
7340 | time_t uptime; | |
7341 | struct tm *tm; | |
7342 | ||
7343 | uptime = bgp_clock(); | |
7344 | uptime -= p->uptime; | |
7345 | tm = gmtime(&uptime); | |
7346 | ||
7347 | json_object_int_add(json_neigh, "bgpTimerUp", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
7348 | } | |
7349 | ||
7350 | else if (p->status == Active) | |
7351 | { | |
7352 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
7353 | json_object_string_add(json_neigh, "bgpStateIs", "passive"); | |
7354 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
7355 | json_object_string_add(json_neigh, "bgpStateIs", "passiveNSF"); | |
7356 | } | |
7357 | ||
7358 | /* read timer */ | |
7359 | time_t uptime; | |
7360 | struct tm *tm; | |
7361 | ||
7362 | uptime = bgp_clock(); | |
7363 | uptime -= p->readtime; | |
7364 | tm = gmtime(&uptime); | |
7365 | json_object_int_add(json_neigh, "bgpTimerLastRead", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
7366 | ||
7367 | uptime = bgp_clock(); | |
7368 | uptime -= p->last_write; | |
7369 | tm = gmtime(&uptime); | |
39e871e6 ST |
7370 | json_object_int_add(json_neigh, "bgpTimerLastWrite", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
7371 | ||
7372 | uptime = bgp_clock(); | |
7373 | uptime -= p->update_time; | |
7374 | tm = gmtime(&uptime); | |
7375 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
7376 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); | |
856ca177 MS |
7377 | |
7378 | /* Configured timer values. */ | |
7379 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", p->v_holdtime * 1000); | |
7380 | json_object_int_add(json_neigh, "bgpTimerKeepAliveIntervalMsecs", p->v_keepalive * 1000); | |
7381 | ||
7382 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
7383 | { | |
7384 | json_object_int_add(json_neigh, "bgpTimerConfiguredHoldTimeMsecs", p->holdtime * 1000); | |
7385 | json_object_int_add(json_neigh, "bgpTimerConfiguredKeepAliveIntervalMsecs", p->keepalive * 1000); | |
7386 | } | |
93406d87 | 7387 | } |
856ca177 MS |
7388 | else |
7389 | { | |
7390 | /* Administrative shutdown. */ | |
7391 | if (CHECK_FLAG (p->flags, PEER_FLAG_SHUTDOWN)) | |
7392 | vty_out (vty, " Administratively shut down%s", VTY_NEWLINE); | |
7393 | ||
7394 | /* BGP Version. */ | |
7395 | vty_out (vty, " BGP version 4"); | |
7396 | vty_out (vty, ", remote router ID %s%s", inet_ntop (AF_INET, &p->remote_id, buf1, BUFSIZ), | |
7397 | VTY_NEWLINE); | |
7398 | ||
7399 | /* Confederation */ | |
7400 | if (CHECK_FLAG (bgp->config, BGP_CONFIG_CONFEDERATION) | |
7401 | && bgp_confederation_peers_check (bgp, p->as)) | |
7402 | vty_out (vty, " Neighbor under common administration%s", VTY_NEWLINE); | |
e52702f2 | 7403 | |
856ca177 MS |
7404 | /* Status. */ |
7405 | vty_out (vty, " BGP state = %s", LOOKUP (bgp_status_msg, p->status)); | |
718e3744 | 7406 | |
856ca177 MS |
7407 | if (p->status == Established) |
7408 | vty_out (vty, ", up for %8s", peer_uptime (p->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
7409 | ||
7410 | else if (p->status == Active) | |
7411 | { | |
7412 | if (CHECK_FLAG (p->flags, PEER_FLAG_PASSIVE)) | |
7413 | vty_out (vty, " (passive)"); | |
7414 | else if (CHECK_FLAG (p->sflags, PEER_STATUS_NSF_WAIT)) | |
7415 | vty_out (vty, " (NSF passive)"); | |
7416 | } | |
7417 | vty_out (vty, "%s", VTY_NEWLINE); | |
93406d87 | 7418 | |
856ca177 MS |
7419 | /* read timer */ |
7420 | vty_out (vty, " Last read %s", peer_uptime (p->readtime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
7421 | vty_out (vty, ", Last write %s%s", | |
7422 | peer_uptime (p->last_write, timebuf, BGP_UPTIME_LEN, 0, NULL), VTY_NEWLINE); | |
7423 | ||
7424 | /* Configured timer values. */ | |
7425 | vty_out (vty, " Hold time is %d, keepalive interval is %d seconds%s", | |
7426 | p->v_holdtime, p->v_keepalive, VTY_NEWLINE); | |
7427 | if (CHECK_FLAG (p->config, PEER_CONFIG_TIMER)) | |
7428 | { | |
7429 | vty_out (vty, " Configured hold time is %d", p->holdtime); | |
7430 | vty_out (vty, ", keepalive interval is %d seconds%s", | |
7431 | p->keepalive, VTY_NEWLINE); | |
7432 | } | |
7433 | } | |
718e3744 | 7434 | /* Capability. */ |
e52702f2 | 7435 | if (p->status == Established) |
718e3744 | 7436 | { |
538621f2 | 7437 | if (p->cap |
718e3744 | 7438 | || p->afc_adv[AFI_IP][SAFI_UNICAST] |
7439 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
7440 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
7441 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
7442 | #ifdef HAVE_IPV6 | |
7443 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
7444 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
7445 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
7446 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
945c8fe9 LB |
7447 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] |
7448 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
8b1fb8be LB |
7449 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] |
7450 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
718e3744 | 7451 | #endif /* HAVE_IPV6 */ |
8b1fb8be LB |
7452 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
7453 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
718e3744 | 7454 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
7455 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) | |
7456 | { | |
856ca177 MS |
7457 | if (use_json) |
7458 | { | |
7459 | json_object *json_cap = NULL; | |
7460 | ||
7461 | json_cap = json_object_new_object(); | |
7462 | ||
7463 | /* AS4 */ | |
7464 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
7465 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7466 | { | |
7467 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) && CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7468 | json_object_string_add(json_cap, "4byteAs", "advertisedAndReceived"); | |
7469 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7470 | json_object_string_add(json_cap, "4byteAs", "advertised"); | |
7471 | else if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7472 | json_object_string_add(json_cap, "4byteAs", "received"); | |
7473 | } | |
7474 | ||
7475 | /* AddPath */ | |
7476 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
7477 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
7478 | { | |
7479 | json_object *json_add = NULL; | |
7480 | const char *print_store; | |
718e3744 | 7481 | |
856ca177 | 7482 | json_add = json_object_new_object(); |
a82478b9 | 7483 | |
856ca177 MS |
7484 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
7485 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7486 | { | |
7487 | json_object *json_sub = NULL; | |
7488 | json_sub = json_object_new_object(); | |
7489 | print_store = afi_safi_print (afi, safi); | |
7490 | ||
7491 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
7492 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7493 | { | |
7494 | 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)) | |
7495 | json_object_boolean_true_add(json_sub, "txAdvertisedAndReceived"); | |
7496 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) | |
7497 | json_object_boolean_true_add(json_sub, "txAdvertised"); | |
7498 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7499 | json_object_boolean_true_add(json_sub, "txReceived"); | |
7500 | } | |
7501 | ||
7502 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
7503 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7504 | { | |
7505 | 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)) | |
7506 | json_object_boolean_true_add(json_sub, "rxAdvertisedAndReceived"); | |
7507 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) | |
7508 | json_object_boolean_true_add(json_sub, "rxAdvertised"); | |
7509 | else if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7510 | json_object_boolean_true_add(json_sub, "rxReceived"); | |
7511 | } | |
7512 | ||
7513 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || | |
7514 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV) || | |
7515 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || | |
7516 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) | |
7517 | json_object_object_add(json_add, print_store, json_sub); | |
b6df4090 DS |
7518 | else |
7519 | json_object_free(json_sub); | |
856ca177 | 7520 | } |
a82478b9 | 7521 | |
856ca177 MS |
7522 | json_object_object_add(json_cap, "addPath", json_add); |
7523 | } | |
7524 | ||
7525 | /* Dynamic */ | |
7526 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
7527 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7528 | { | |
7529 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) && CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7530 | json_object_string_add(json_cap, "dynamic", "advertisedAndReceived"); | |
7531 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7532 | json_object_string_add(json_cap, "dynamic", "advertised"); | |
7533 | else if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7534 | json_object_string_add(json_cap, "dynamic", "received"); | |
7535 | } | |
7536 | ||
7537 | /* Extended nexthop */ | |
7538 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
7539 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7540 | { | |
7541 | json_object *json_nxt = NULL; | |
7542 | const char *print_store; | |
7543 | ||
856ca177 MS |
7544 | |
7545 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) && CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7546 | json_object_string_add(json_cap, "extendedNexthop", "advertisedAndReceived"); | |
7547 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7548 | json_object_string_add(json_cap, "extendedNexthop", "advertised"); | |
7549 | else if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7550 | json_object_string_add(json_cap, "extendedNexthop", "received"); | |
7551 | ||
7552 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7553 | { | |
b6df4090 DS |
7554 | json_nxt = json_object_new_object(); |
7555 | ||
856ca177 MS |
7556 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) |
7557 | { | |
7558 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
7559 | { | |
7560 | print_store = afi_safi_print (AFI_IP, safi); | |
7561 | json_object_string_add(json_nxt, print_store, "recieved"); | |
7562 | } | |
7563 | } | |
7564 | json_object_object_add(json_cap, "extendedNexthopFamililesByPeer", json_nxt); | |
7565 | } | |
7566 | } | |
7567 | ||
7568 | /* Route Refresh */ | |
7569 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
7570 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
7571 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7572 | { | |
7573 | 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))) | |
7574 | { | |
7575 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) | |
7576 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOldNew"); | |
7577 | else | |
7578 | { | |
7579 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7580 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedOld"); | |
7581 | else | |
7582 | json_object_string_add(json_cap, "routeRefresh", "advertisedAndReceivedNew"); | |
7583 | } | |
7584 | } | |
7585 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
7586 | json_object_string_add(json_cap, "routeRefresh", "advertised"); | |
7587 | else if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7588 | json_object_string_add(json_cap, "routeRefresh", "received"); | |
7589 | } | |
7590 | ||
7591 | /* Multiprotocol Extensions */ | |
7592 | json_object *json_multi = NULL; | |
7593 | json_multi = json_object_new_object(); | |
7594 | ||
7595 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7596 | { | |
7597 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7598 | { | |
7599 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
7600 | { | |
7601 | json_object *json_exten = NULL; | |
7602 | json_exten = json_object_new_object(); | |
7603 | ||
7604 | if (p->afc_adv[afi][safi] && p->afc_recv[afi][safi]) | |
7605 | json_object_boolean_true_add(json_exten, "advertisedAndReceived"); | |
7606 | else if (p->afc_adv[afi][safi]) | |
7607 | json_object_boolean_true_add(json_exten, "advertised"); | |
7608 | else if (p->afc_recv[afi][safi]) | |
7609 | json_object_boolean_true_add(json_exten, "received"); | |
7610 | ||
7611 | json_object_object_add(json_multi, afi_safi_print (afi, safi), json_exten); | |
7612 | } | |
7613 | } | |
7614 | } | |
7615 | json_object_object_add(json_cap, "multiprotocolExtensions", json_multi); | |
7616 | ||
7617 | /* Gracefull Restart */ | |
7618 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
7619 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7620 | { | |
7621 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) && CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7622 | json_object_string_add(json_cap, "gracefulRestart", "advertisedAndReceived"); | |
7623 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7624 | json_object_string_add(json_cap, "gracefulRestartCapability", "advertised"); | |
7625 | else if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7626 | json_object_string_add(json_cap, "gracefulRestartCapability", "received"); | |
7627 | ||
7628 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) | |
7629 | { | |
7630 | int restart_af_count = 0; | |
7631 | json_object *json_restart = NULL; | |
7632 | json_restart = json_object_new_object(); | |
7633 | ||
7634 | json_object_int_add(json_cap, "gracefulRestartRemoteTimerMsecs", p->v_gr_restart * 1000); | |
7635 | ||
7636 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7637 | { | |
7638 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7639 | { | |
7640 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
7641 | { | |
7642 | json_object *json_sub = NULL; | |
7643 | json_sub = json_object_new_object(); | |
7644 | ||
7645 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV)) | |
7646 | json_object_boolean_true_add(json_sub, "preserved"); | |
7647 | restart_af_count++; | |
7648 | json_object_object_add(json_restart, afi_safi_print (afi, safi), json_sub); | |
7649 | } | |
7650 | } | |
7651 | } | |
7652 | if (! restart_af_count) | |
b6df4090 | 7653 | { |
856ca177 | 7654 | json_object_string_add(json_cap, "addressFamiliesByPeer", "none"); |
b6df4090 DS |
7655 | json_object_free(json_restart); |
7656 | } | |
856ca177 MS |
7657 | else |
7658 | json_object_object_add(json_cap, "addressFamiliesByPeer", json_restart); | |
7659 | } | |
7660 | } | |
7661 | json_object_object_add(json_neigh, "neighborCapabilities", json_cap); | |
7662 | } | |
7663 | else | |
7664 | { | |
7665 | vty_out (vty, " Neighbor capabilities:%s", VTY_NEWLINE); | |
7666 | ||
7667 | /* AS4 */ | |
7668 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV) | |
7669 | || CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7670 | { | |
7671 | vty_out (vty, " 4 Byte AS:"); | |
7672 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV)) | |
7673 | vty_out (vty, " advertised"); | |
7674 | if (CHECK_FLAG (p->cap, PEER_CAP_AS4_RCV)) | |
7675 | vty_out (vty, " %sreceived", | |
7676 | CHECK_FLAG (p->cap, PEER_CAP_AS4_ADV) ? "and " : ""); | |
7677 | vty_out (vty, "%s", VTY_NEWLINE); | |
7678 | } | |
7679 | ||
7680 | /* AddPath */ | |
7681 | if (CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_RCV) | |
7682 | || CHECK_FLAG (p->cap, PEER_CAP_ADDPATH_ADV)) | |
7683 | { | |
7684 | vty_out (vty, " AddPath:%s", VTY_NEWLINE); | |
a82478b9 | 7685 | |
856ca177 MS |
7686 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
7687 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
a82478b9 | 7688 | { |
856ca177 MS |
7689 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) || |
7690 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) | |
7691 | { | |
7692 | vty_out (vty, " %s: TX ", afi_safi_print (afi, safi)); | |
a82478b9 | 7693 | |
856ca177 MS |
7694 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV)) |
7695 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 7696 | |
856ca177 MS |
7697 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_RCV)) |
7698 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_TX_ADV) ? " and " : "" ); | |
a82478b9 | 7699 | |
856ca177 MS |
7700 | vty_out (vty, "%s", VTY_NEWLINE); |
7701 | } | |
a82478b9 | 7702 | |
856ca177 | 7703 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) || |
a82478b9 | 7704 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
856ca177 MS |
7705 | { |
7706 | vty_out (vty, " %s: RX ", afi_safi_print (afi, safi)); | |
a82478b9 | 7707 | |
856ca177 MS |
7708 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV)) |
7709 | vty_out (vty, "advertised %s", afi_safi_print (afi, safi)); | |
a82478b9 | 7710 | |
856ca177 MS |
7711 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_RCV)) |
7712 | vty_out (vty, "%sreceived", CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_ADDPATH_AF_RX_ADV) ? " and " : "" ); | |
a82478b9 | 7713 | |
856ca177 MS |
7714 | vty_out (vty, "%s", VTY_NEWLINE); |
7715 | } | |
a82478b9 | 7716 | } |
856ca177 | 7717 | } |
a82478b9 | 7718 | |
856ca177 MS |
7719 | /* Dynamic */ |
7720 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV) | |
7721 | || CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7722 | { | |
7723 | vty_out (vty, " Dynamic:"); | |
7724 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV)) | |
7725 | vty_out (vty, " advertised"); | |
7726 | if (CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_RCV)) | |
7727 | vty_out (vty, " %sreceived", | |
7728 | CHECK_FLAG (p->cap, PEER_CAP_DYNAMIC_ADV) ? "and " : ""); | |
7729 | vty_out (vty, "%s", VTY_NEWLINE); | |
7730 | } | |
7731 | ||
7732 | /* Extended nexthop */ | |
7733 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV) | |
7734 | || CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7735 | { | |
7736 | vty_out (vty, " Extended nexthop:"); | |
7737 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV)) | |
7738 | vty_out (vty, " advertised"); | |
7739 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) | |
7740 | vty_out (vty, " %sreceived", | |
7741 | CHECK_FLAG (p->cap, PEER_CAP_ENHE_ADV) ? "and " : ""); | |
7742 | vty_out (vty, "%s", VTY_NEWLINE); | |
718e3744 | 7743 | |
856ca177 MS |
7744 | if (CHECK_FLAG (p->cap, PEER_CAP_ENHE_RCV)) |
7745 | { | |
7746 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
7747 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7748 | if (CHECK_FLAG (p->af_cap[AFI_IP][safi], PEER_CAP_ENHE_AF_RCV)) | |
7749 | vty_out (vty, " %s%s", | |
7750 | afi_safi_print (AFI_IP, safi), VTY_NEWLINE); | |
7751 | } | |
7752 | } | |
8a92a8a0 | 7753 | |
856ca177 MS |
7754 | /* Route Refresh */ |
7755 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) | |
7756 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
7757 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7758 | { | |
7759 | vty_out (vty, " Route refresh:"); | |
7760 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV)) | |
7761 | vty_out (vty, " advertised"); | |
7762 | if (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV) | |
7763 | || CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV)) | |
7764 | vty_out (vty, " %sreceived(%s)", | |
7765 | CHECK_FLAG (p->cap, PEER_CAP_REFRESH_ADV) ? "and " : "", | |
7766 | (CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) | |
7767 | && CHECK_FLAG (p->cap, PEER_CAP_REFRESH_NEW_RCV)) ? | |
7768 | "old & new" : CHECK_FLAG (p->cap, PEER_CAP_REFRESH_OLD_RCV) ? "old" : "new"); | |
8a92a8a0 | 7769 | |
856ca177 MS |
7770 | vty_out (vty, "%s", VTY_NEWLINE); |
7771 | } | |
718e3744 | 7772 | |
856ca177 MS |
7773 | /* Multiprotocol Extensions */ |
7774 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7775 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7776 | if (p->afc_adv[afi][safi] || p->afc_recv[afi][safi]) | |
7777 | { | |
8c3deaae | 7778 | vty_out (vty, " Address Family %s:", afi_safi_print (afi, safi)); |
856ca177 MS |
7779 | if (p->afc_adv[afi][safi]) |
7780 | vty_out (vty, " advertised"); | |
7781 | if (p->afc_recv[afi][safi]) | |
7782 | vty_out (vty, " %sreceived", p->afc_adv[afi][safi] ? "and " : ""); | |
7783 | vty_out (vty, "%s", VTY_NEWLINE); | |
7784 | } | |
538621f2 | 7785 | |
04b6bdc0 DW |
7786 | /* Hostname capability */ |
7787 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV) || | |
7788 | CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) | |
7789 | { | |
7790 | vty_out (vty, " Hostname Capability:"); | |
7791 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV)) | |
7792 | vty_out (vty, " advertised"); | |
7793 | if (CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_RCV)) | |
7794 | vty_out (vty, " %sreceived", | |
7795 | CHECK_FLAG (p->cap, PEER_CAP_HOSTNAME_ADV) ? "and " : ""); | |
7796 | vty_out (vty, "%s", VTY_NEWLINE); | |
7797 | } | |
7798 | ||
856ca177 MS |
7799 | /* Gracefull Restart */ |
7800 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
7801 | || CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
7802 | { | |
7803 | vty_out (vty, " Graceful Restart Capabilty:"); | |
7804 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV)) | |
538621f2 | 7805 | vty_out (vty, " advertised"); |
856ca177 MS |
7806 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
7807 | vty_out (vty, " %sreceived", | |
7808 | CHECK_FLAG (p->cap, PEER_CAP_RESTART_ADV) ? "and " : ""); | |
7809 | vty_out (vty, "%s", VTY_NEWLINE); | |
538621f2 | 7810 | |
856ca177 MS |
7811 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV)) |
7812 | { | |
7813 | int restart_af_count = 0; | |
7814 | ||
7815 | vty_out (vty, " Remote Restart timer is %d seconds%s", | |
7816 | p->v_gr_restart, VTY_NEWLINE); | |
7817 | vty_out (vty, " Address families by peer:%s ", VTY_NEWLINE); | |
7818 | ||
7819 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7820 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7821 | if (CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_RCV)) | |
7822 | { | |
7823 | vty_out (vty, "%s%s(%s)", restart_af_count ? ", " : "", | |
7824 | afi_safi_print (afi, safi), | |
7825 | CHECK_FLAG (p->af_cap[afi][safi], PEER_CAP_RESTART_AF_PRESERVE_RCV) ? | |
7826 | "preserved" : "not preserved"); | |
7827 | restart_af_count++; | |
7828 | } | |
7829 | if (! restart_af_count) | |
7830 | vty_out (vty, "none"); | |
7831 | vty_out (vty, "%s", VTY_NEWLINE); | |
7832 | } | |
7833 | } | |
7834 | } | |
718e3744 | 7835 | } |
7836 | } | |
7837 | ||
93406d87 | 7838 | /* graceful restart information */ |
7839 | if (CHECK_FLAG (p->cap, PEER_CAP_RESTART_RCV) | |
7840 | || p->t_gr_restart | |
7841 | || p->t_gr_stale) | |
7842 | { | |
856ca177 MS |
7843 | json_object *json_grace = NULL; |
7844 | json_object *json_grace_send = NULL; | |
7845 | json_object *json_grace_recv = NULL; | |
93406d87 | 7846 | int eor_send_af_count = 0; |
7847 | int eor_receive_af_count = 0; | |
7848 | ||
856ca177 MS |
7849 | if (use_json) |
7850 | { | |
7851 | json_grace = json_object_new_object(); | |
7852 | json_grace_send = json_object_new_object(); | |
7853 | json_grace_recv = json_object_new_object(); | |
7854 | ||
7855 | if (p->status == Established) | |
7856 | { | |
7857 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7858 | { | |
7859 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7860 | { | |
7861 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
7862 | { | |
7863 | json_object_boolean_true_add(json_grace_send, afi_safi_print (afi, safi)); | |
7864 | eor_send_af_count++; | |
7865 | } | |
7866 | } | |
7867 | } | |
7868 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7869 | { | |
7870 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7871 | { | |
7872 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
7873 | { | |
7874 | json_object_boolean_true_add(json_grace_recv, afi_safi_print (afi, safi)); | |
7875 | eor_receive_af_count++; | |
7876 | } | |
7877 | } | |
7878 | } | |
7879 | } | |
7880 | ||
7881 | json_object_object_add(json_grace, "endOfRibSend", json_grace_send); | |
7882 | json_object_object_add(json_grace, "endOfRibRecv", json_grace_recv); | |
7883 | ||
7884 | if (p->t_gr_restart) | |
7885 | json_object_int_add(json_grace, "gracefulRestartTimerMsecs", thread_timer_remain_second (p->t_gr_restart) * 1000); | |
7886 | ||
7887 | if (p->t_gr_stale) | |
7888 | json_object_int_add(json_grace, "gracefulStalepathTimerMsecs", thread_timer_remain_second (p->t_gr_stale) * 1000); | |
7889 | ||
7890 | json_object_object_add(json_neigh, "gracefulRestartInfo", json_grace); | |
7891 | } | |
7892 | else | |
7893 | { | |
7894 | vty_out (vty, " Graceful restart informations:%s", VTY_NEWLINE); | |
7895 | if (p->status == Established) | |
7896 | { | |
7897 | vty_out (vty, " End-of-RIB send: "); | |
7898 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7899 | { | |
7900 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7901 | { | |
7902 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_SEND)) | |
7903 | { | |
7904 | vty_out (vty, "%s%s", eor_send_af_count ? ", " : "", | |
7905 | afi_safi_print (afi, safi)); | |
7906 | eor_send_af_count++; | |
7907 | } | |
7908 | } | |
7909 | } | |
7910 | vty_out (vty, "%s", VTY_NEWLINE); | |
7911 | vty_out (vty, " End-of-RIB received: "); | |
7912 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) | |
7913 | { | |
7914 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
7915 | { | |
7916 | if (CHECK_FLAG (p->af_sflags[afi][safi], PEER_STATUS_EOR_RECEIVED)) | |
7917 | { | |
7918 | vty_out (vty, "%s%s", eor_receive_af_count ? ", " : "", | |
7919 | afi_safi_print (afi, safi)); | |
7920 | eor_receive_af_count++; | |
7921 | } | |
7922 | } | |
7923 | } | |
7924 | vty_out (vty, "%s", VTY_NEWLINE); | |
7925 | } | |
93406d87 | 7926 | |
856ca177 MS |
7927 | if (p->t_gr_restart) |
7928 | vty_out (vty, " The remaining time of restart timer is %ld%s", | |
7929 | thread_timer_remain_second (p->t_gr_restart), VTY_NEWLINE); | |
e52702f2 | 7930 | |
856ca177 MS |
7931 | if (p->t_gr_stale) |
7932 | vty_out (vty, " The remaining time of stalepath timer is %ld%s", | |
7933 | thread_timer_remain_second (p->t_gr_stale), VTY_NEWLINE); | |
7934 | } | |
7935 | } | |
7936 | if (use_json) | |
7937 | { | |
7938 | json_object *json_stat = NULL; | |
7939 | json_stat = json_object_new_object(); | |
7940 | /* Packet counts. */ | |
7941 | json_object_int_add(json_stat, "depthInq", 0); | |
7942 | json_object_int_add(json_stat, "depthOutq", (unsigned long) p->obuf->count); | |
7943 | json_object_int_add(json_stat, "opensSent", p->open_out); | |
7944 | json_object_int_add(json_stat, "opensRecv", p->open_in); | |
7945 | json_object_int_add(json_stat, "notificationsSent", p->notify_out); | |
7946 | json_object_int_add(json_stat, "notificationsRecv", p->notify_in); | |
7947 | json_object_int_add(json_stat, "updatesSent", p->update_out); | |
7948 | json_object_int_add(json_stat, "updatesRecv", p->update_in); | |
7949 | json_object_int_add(json_stat, "keepalivesSent", p->keepalive_out); | |
7950 | json_object_int_add(json_stat, "keepalivesRecv", p->keepalive_in); | |
7951 | json_object_int_add(json_stat, "routeRefreshSent", p->refresh_out); | |
7952 | json_object_int_add(json_stat, "routeRefreshRecv", p->refresh_in); | |
7953 | json_object_int_add(json_stat, "capabilitySent", p->dynamic_cap_out); | |
7954 | json_object_int_add(json_stat, "capabilityRecv", p->dynamic_cap_in); | |
7955 | 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); | |
7956 | 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); | |
7957 | json_object_object_add(json_neigh, "messageStats", json_stat); | |
7958 | } | |
7959 | else | |
7960 | { | |
7961 | /* Packet counts. */ | |
7962 | vty_out (vty, " Message statistics:%s", VTY_NEWLINE); | |
7963 | vty_out (vty, " Inq depth is 0%s", VTY_NEWLINE); | |
7964 | vty_out (vty, " Outq depth is %lu%s", (unsigned long) p->obuf->count, VTY_NEWLINE); | |
7965 | vty_out (vty, " Sent Rcvd%s", VTY_NEWLINE); | |
7966 | vty_out (vty, " Opens: %10d %10d%s", p->open_out, p->open_in, VTY_NEWLINE); | |
7967 | vty_out (vty, " Notifications: %10d %10d%s", p->notify_out, p->notify_in, VTY_NEWLINE); | |
7968 | vty_out (vty, " Updates: %10d %10d%s", p->update_out, p->update_in, VTY_NEWLINE); | |
7969 | vty_out (vty, " Keepalives: %10d %10d%s", p->keepalive_out, p->keepalive_in, VTY_NEWLINE); | |
7970 | vty_out (vty, " Route Refresh: %10d %10d%s", p->refresh_out, p->refresh_in, VTY_NEWLINE); | |
7971 | vty_out (vty, " Capability: %10d %10d%s", p->dynamic_cap_out, p->dynamic_cap_in, VTY_NEWLINE); | |
7972 | vty_out (vty, " Total: %10d %10d%s", p->open_out + p->notify_out + | |
7973 | p->update_out + p->keepalive_out + p->refresh_out + p->dynamic_cap_out, | |
7974 | p->open_in + p->notify_in + p->update_in + p->keepalive_in + p->refresh_in + | |
7975 | p->dynamic_cap_in, VTY_NEWLINE); | |
718e3744 | 7976 | } |
7977 | ||
856ca177 MS |
7978 | if (use_json) |
7979 | { | |
7980 | /* advertisement-interval */ | |
7981 | json_object_int_add(json_neigh, "minBtwnAdvertisementRunsTimerMsecs", p->v_routeadv * 1000); | |
718e3744 | 7982 | |
856ca177 MS |
7983 | /* Update-source. */ |
7984 | if (p->update_if || p->update_source) | |
7985 | { | |
7986 | if (p->update_if) | |
7987 | json_object_string_add(json_neigh, "updateSource", p->update_if); | |
7988 | else if (p->update_source) | |
7989 | json_object_string_add(json_neigh, "updateSource", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
7990 | } | |
856ca177 MS |
7991 | } |
7992 | else | |
7993 | { | |
7994 | /* advertisement-interval */ | |
7995 | vty_out (vty, " Minimum time between advertisement runs is %d seconds%s", | |
7996 | p->v_routeadv, VTY_NEWLINE); | |
7997 | ||
7998 | /* Update-source. */ | |
7999 | if (p->update_if || p->update_source) | |
8000 | { | |
8001 | vty_out (vty, " Update source is "); | |
8002 | if (p->update_if) | |
8003 | vty_out (vty, "%s", p->update_if); | |
8004 | else if (p->update_source) | |
8005 | vty_out (vty, "%s", sockunion2str (p->update_source, buf1, SU_ADDRSTRLEN)); | |
8006 | vty_out (vty, "%s", VTY_NEWLINE); | |
8007 | } | |
8008 | ||
856ca177 MS |
8009 | vty_out (vty, "%s", VTY_NEWLINE); |
8010 | } | |
718e3744 | 8011 | |
8012 | /* Address Family Information */ | |
856ca177 MS |
8013 | json_object *json_hold = NULL; |
8014 | ||
8015 | if (use_json) | |
8016 | json_hold = json_object_new_object(); | |
8017 | ||
538621f2 | 8018 | for (afi = AFI_IP ; afi < AFI_MAX ; afi++) |
8019 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
8020 | if (p->afc[afi][safi]) | |
856ca177 | 8021 | bgp_show_peer_afi (vty, p, afi, safi, use_json, json_hold); |
718e3744 | 8022 | |
856ca177 MS |
8023 | if (use_json) |
8024 | { | |
58433ae6 | 8025 | json_object_object_add(json_neigh, "addressFamilyInfo", json_hold); |
e08ac8b7 DW |
8026 | json_object_int_add(json_neigh, "connectionsEstablished", p->established); |
8027 | json_object_int_add(json_neigh, "connectionsDropped", p->dropped); | |
856ca177 MS |
8028 | } |
8029 | else | |
8030 | vty_out (vty, " Connections established %d; dropped %d%s", p->established, p->dropped, | |
8031 | VTY_NEWLINE); | |
718e3744 | 8032 | |
d6661008 | 8033 | if (! p->last_reset) |
856ca177 MS |
8034 | { |
8035 | if (use_json) | |
e08ac8b7 | 8036 | json_object_string_add(json_neigh, "lastReset", "never"); |
856ca177 MS |
8037 | else |
8038 | vty_out (vty, " Last reset never%s", VTY_NEWLINE); | |
8039 | } | |
e0701b79 | 8040 | else |
d6661008 | 8041 | { |
856ca177 MS |
8042 | if (use_json) |
8043 | { | |
8044 | time_t uptime; | |
8045 | struct tm *tm; | |
8046 | ||
8047 | uptime = bgp_clock(); | |
8048 | uptime -= p->resettime; | |
8049 | tm = gmtime(&uptime); | |
e08ac8b7 DW |
8050 | json_object_int_add(json_neigh, "lastResetTimerMsecs", (tm->tm_sec * 1000) + (tm->tm_min * 60000) + (tm->tm_hour * 3600000)); |
8051 | json_object_string_add(json_neigh, "lastResetDueTo", peer_down_str[(int) p->last_reset]); | |
856ca177 MS |
8052 | if (p->last_reset_cause_size) |
8053 | { | |
39e871e6 ST |
8054 | char errorcodesubcode_hexstr[5]; |
8055 | sprintf(errorcodesubcode_hexstr, "%02X%02X", p->notify.code, p->notify.subcode); | |
e08ac8b7 | 8056 | json_object_string_add(json_neigh, "lastErrorCodeSubcode", errorcodesubcode_hexstr); |
856ca177 MS |
8057 | } |
8058 | } | |
8059 | else | |
d6661008 | 8060 | { |
3a8c7ba1 DW |
8061 | vty_out (vty, " Last reset %s, ", |
8062 | peer_uptime (p->resettime, timebuf, BGP_UPTIME_LEN, 0, NULL)); | |
8063 | ||
8064 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND || | |
8065 | p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) | |
8066 | { | |
8067 | code_str = bgp_notify_code_str(p->notify.code); | |
8068 | subcode_str = bgp_notify_subcode_str(p->notify.code, p->notify.subcode); | |
8069 | vty_out (vty, "due to NOTIFICATION %s (%s%s)%s", | |
8070 | p->last_reset == PEER_DOWN_NOTIFY_SEND ? "sent" : "received", | |
8071 | code_str, subcode_str, VTY_NEWLINE); | |
8072 | } | |
8073 | else | |
8074 | { | |
8075 | vty_out (vty, "due to %s%s", | |
8076 | peer_down_str[(int) p->last_reset], VTY_NEWLINE); | |
8077 | } | |
856ca177 MS |
8078 | |
8079 | if (p->last_reset_cause_size) | |
d6661008 | 8080 | { |
856ca177 MS |
8081 | msg = p->last_reset_cause; |
8082 | vty_out(vty, " Message received that caused BGP to send a NOTIFICATION:%s ", VTY_NEWLINE); | |
8083 | for (i = 1; i <= p->last_reset_cause_size; i++) | |
8084 | { | |
8085 | vty_out(vty, "%02X", *msg++); | |
d6661008 | 8086 | |
856ca177 MS |
8087 | if (i != p->last_reset_cause_size) |
8088 | { | |
8089 | if (i % 16 == 0) | |
8090 | { | |
8091 | vty_out(vty, "%s ", VTY_NEWLINE); | |
8092 | } | |
8093 | else if (i % 4 == 0) | |
8094 | { | |
8095 | vty_out(vty, " "); | |
8096 | } | |
8097 | } | |
8098 | } | |
8099 | vty_out(vty, "%s", VTY_NEWLINE); | |
d6661008 | 8100 | } |
d6661008 DS |
8101 | } |
8102 | } | |
848973c7 | 8103 | |
718e3744 | 8104 | if (CHECK_FLAG (p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) |
8105 | { | |
856ca177 | 8106 | if (use_json) |
e08ac8b7 | 8107 | json_object_boolean_true_add(json_neigh, "prefixesConfigExceedMax"); |
856ca177 MS |
8108 | else |
8109 | vty_out (vty, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE); | |
0a486e5f | 8110 | |
8111 | if (p->t_pmax_restart) | |
856ca177 MS |
8112 | { |
8113 | if (use_json) | |
8114 | { | |
e08ac8b7 DW |
8115 | json_object_boolean_true_add(json_neigh, "reducePrefixNumFrom"); |
8116 | json_object_int_add(json_neigh, "restartInTimerMsec", thread_timer_remain_second (p->t_pmax_restart) * 1000); | |
856ca177 MS |
8117 | } |
8118 | else | |
8119 | vty_out (vty, " Reduce the no. of prefix from %s, will restart in %ld seconds%s", | |
8120 | p->host, thread_timer_remain_second (p->t_pmax_restart), | |
8121 | VTY_NEWLINE); | |
8122 | } | |
0a486e5f | 8123 | else |
856ca177 MS |
8124 | { |
8125 | if (use_json) | |
e08ac8b7 | 8126 | json_object_boolean_true_add(json_neigh, "reducePrefixNumAndClearIpBgp"); |
856ca177 MS |
8127 | else |
8128 | vty_out (vty, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s", | |
8129 | p->host, VTY_NEWLINE); | |
8130 | } | |
718e3744 | 8131 | } |
8132 | ||
f5a4827d | 8133 | /* EBGP Multihop and GTSM */ |
6d85b15b | 8134 | if (p->sort != BGP_PEER_IBGP) |
f5a4827d | 8135 | { |
856ca177 MS |
8136 | if (use_json) |
8137 | { | |
8138 | if (p->gtsm_hops > 0) | |
8139 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->gtsm_hops); | |
8140 | else if (p->ttl > 1) | |
8141 | json_object_int_add(json_neigh, "externalBgpNbrMaxHopsAway", p->ttl); | |
8142 | } | |
8143 | else | |
8144 | { | |
8145 | if (p->gtsm_hops > 0) | |
8146 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
8147 | p->gtsm_hops, VTY_NEWLINE); | |
8148 | else if (p->ttl > 1) | |
8149 | vty_out (vty, " External BGP neighbor may be up to %d hops away.%s", | |
8150 | p->ttl, VTY_NEWLINE); | |
8151 | } | |
f5a4827d | 8152 | } |
5d804b43 PM |
8153 | else |
8154 | { | |
8155 | if (p->gtsm_hops > 0) | |
856ca177 MS |
8156 | { |
8157 | if (use_json) | |
8158 | json_object_int_add(json_neigh, "internalBgpNbrMaxHopsAway", p->gtsm_hops); | |
8159 | else | |
8160 | vty_out (vty, " Internal BGP neighbor may be up to %d hops away.%s", | |
8161 | p->gtsm_hops, VTY_NEWLINE); | |
8162 | } | |
5d804b43 | 8163 | } |
718e3744 | 8164 | |
8165 | /* Local address. */ | |
8166 | if (p->su_local) | |
8167 | { | |
856ca177 MS |
8168 | if (use_json) |
8169 | { | |
8170 | json_object_string_add(json_neigh, "hostLocal", sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN)); | |
8171 | json_object_int_add(json_neigh, "portLocal", ntohs (p->su_local->sin.sin_port)); | |
8172 | } | |
8173 | else | |
8174 | vty_out (vty, "Local host: %s, Local port: %d%s", | |
8175 | sockunion2str (p->su_local, buf1, SU_ADDRSTRLEN), | |
8176 | ntohs (p->su_local->sin.sin_port), | |
8177 | VTY_NEWLINE); | |
718e3744 | 8178 | } |
e52702f2 | 8179 | |
718e3744 | 8180 | /* Remote address. */ |
8181 | if (p->su_remote) | |
8182 | { | |
856ca177 MS |
8183 | if (use_json) |
8184 | { | |
8185 | json_object_string_add(json_neigh, "hostForeign", sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN)); | |
8186 | json_object_int_add(json_neigh, "portForeign", ntohs (p->su_remote->sin.sin_port)); | |
8187 | } | |
8188 | else | |
8189 | vty_out (vty, "Foreign host: %s, Foreign port: %d%s", | |
718e3744 | 8190 | sockunion2str (p->su_remote, buf1, SU_ADDRSTRLEN), |
8191 | ntohs (p->su_remote->sin.sin_port), | |
8192 | VTY_NEWLINE); | |
8193 | } | |
8194 | ||
8195 | /* Nexthop display. */ | |
8196 | if (p->su_local) | |
8197 | { | |
856ca177 MS |
8198 | if (use_json) |
8199 | { | |
8200 | json_object_string_add(json_neigh, "nexthop", inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ)); | |
718e3744 | 8201 | #ifdef HAVE_IPV6 |
856ca177 MS |
8202 | json_object_string_add(json_neigh, "nexthopGlobal", inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ)); |
8203 | json_object_string_add(json_neigh, "nexthopLocal", inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ)); | |
8204 | if (p->shared_network) | |
8205 | json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork"); | |
8206 | else | |
8207 | json_object_string_add(json_neigh, "bgpConnection", "nonSharedNetwork"); | |
8208 | #endif /* HAVE_IPV6 */ | |
8209 | } | |
8210 | else | |
8211 | { | |
8212 | vty_out (vty, "Nexthop: %s%s", | |
8213 | inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ), | |
8214 | VTY_NEWLINE); | |
8215 | #ifdef HAVE_IPV6 | |
8216 | vty_out (vty, "Nexthop global: %s%s", | |
8217 | inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ), | |
8218 | VTY_NEWLINE); | |
8219 | vty_out (vty, "Nexthop local: %s%s", | |
8220 | inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ), | |
8221 | VTY_NEWLINE); | |
8222 | vty_out (vty, "BGP connection: %s%s", | |
8223 | p->shared_network ? "shared network" : "non shared network", | |
8224 | VTY_NEWLINE); | |
718e3744 | 8225 | #endif /* HAVE_IPV6 */ |
856ca177 | 8226 | } |
718e3744 | 8227 | } |
8228 | ||
8229 | /* Timer information. */ | |
856ca177 MS |
8230 | if (use_json) |
8231 | { | |
39e871e6 | 8232 | json_object_int_add(json_neigh, "connectRetryTimer", p->v_connect); |
dd9275d6 ST |
8233 | if (p->status == Established && p->rtt) |
8234 | json_object_int_add(json_neigh, "estimatedRttInMsecs", p->rtt); | |
856ca177 MS |
8235 | if (p->t_start) |
8236 | json_object_int_add(json_neigh, "nextStartTimerDueInMsecs", thread_timer_remain_second (p->t_start) * 1000); | |
8237 | if (p->t_connect) | |
8238 | json_object_int_add(json_neigh, "nextConnectTimerDueInMsecs", thread_timer_remain_second (p->t_connect) * 1000); | |
8239 | if (p->t_routeadv) | |
8240 | { | |
8241 | json_object_int_add(json_neigh, "mraiInterval", p->v_routeadv); | |
8242 | json_object_int_add(json_neigh, "mraiTimerExpireInMsecs", thread_timer_remain_second (p->t_routeadv) * 1000); | |
8243 | } | |
cb1faec9 | 8244 | |
856ca177 MS |
8245 | if (p->t_read) |
8246 | json_object_string_add(json_neigh, "readThread", "on"); | |
8247 | else | |
8248 | json_object_string_add(json_neigh, "readThread", "off"); | |
8249 | if (p->t_write) | |
8250 | json_object_string_add(json_neigh, "writeThread", "on"); | |
8251 | else | |
8252 | json_object_string_add(json_neigh, "writeThread", "off"); | |
8253 | } | |
8254 | else | |
8255 | { | |
39e871e6 ST |
8256 | vty_out (vty, "BGP Connect Retry Timer in Seconds: %d%s", |
8257 | p->v_connect, VTY_NEWLINE); | |
dd9275d6 ST |
8258 | if (p->status == Established && p->rtt) |
8259 | vty_out (vty, "Estimated round trip time: %d ms%s", | |
8260 | p->rtt, VTY_NEWLINE); | |
856ca177 MS |
8261 | if (p->t_start) |
8262 | vty_out (vty, "Next start timer due in %ld seconds%s", | |
8263 | thread_timer_remain_second (p->t_start), VTY_NEWLINE); | |
8264 | if (p->t_connect) | |
8265 | vty_out (vty, "Next connect timer due in %ld seconds%s", | |
8266 | thread_timer_remain_second (p->t_connect), VTY_NEWLINE); | |
8267 | if (p->t_routeadv) | |
8268 | vty_out (vty, "MRAI (interval %u) timer expires in %ld seconds%s", | |
8269 | p->v_routeadv, thread_timer_remain_second (p->t_routeadv), | |
8270 | VTY_NEWLINE); | |
8271 | ||
8272 | vty_out (vty, "Read thread: %s Write thread: %s%s", | |
8273 | p->t_read ? "on" : "off", | |
8274 | p->t_write ? "on" : "off", | |
8275 | VTY_NEWLINE); | |
8276 | } | |
718e3744 | 8277 | |
8278 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
8279 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
856ca177 MS |
8280 | bgp_capability_vty_out (vty, p, use_json, json_neigh); |
8281 | ||
8282 | if (!use_json) | |
8283 | vty_out (vty, "%s", VTY_NEWLINE); | |
c43ed2e4 DS |
8284 | |
8285 | /* BFD information. */ | |
856ca177 MS |
8286 | bgp_bfd_show_info(vty, p, use_json, json_neigh); |
8287 | ||
8288 | if (use_json) | |
8289 | { | |
8290 | if (p->conf_if) /* Configured interface name. */ | |
8291 | json_object_object_add(json, p->conf_if, json_neigh); | |
8292 | else /* Configured IP address. */ | |
8293 | json_object_object_add(json, p->host, json_neigh); | |
8294 | } | |
718e3744 | 8295 | } |
8296 | ||
94f2b392 | 8297 | static int |
856ca177 MS |
8298 | bgp_show_neighbor (struct vty *vty, struct bgp *bgp, enum show_type type, |
8299 | union sockunion *su, const char *conf_if, u_char use_json, json_object *json) | |
718e3744 | 8300 | { |
1eb8ef25 | 8301 | struct listnode *node, *nnode; |
718e3744 | 8302 | struct peer *peer; |
8303 | int find = 0; | |
8304 | ||
1eb8ef25 | 8305 | for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) |
718e3744 | 8306 | { |
1ff9a340 DS |
8307 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
8308 | continue; | |
8309 | ||
718e3744 | 8310 | switch (type) |
856ca177 MS |
8311 | { |
8312 | case show_all: | |
e8f7da3a | 8313 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8314 | break; |
8315 | case show_peer: | |
8316 | if (conf_if) | |
8317 | { | |
4873b3b9 DW |
8318 | if ((peer->conf_if && !strcmp(peer->conf_if, conf_if)) || |
8319 | (peer->hostname && !strcmp(peer->hostname, conf_if))) | |
856ca177 MS |
8320 | { |
8321 | find = 1; | |
e8f7da3a | 8322 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8323 | } |
8324 | } | |
8325 | else | |
8326 | { | |
8327 | if (sockunion_same (&peer->su, su)) | |
8328 | { | |
8329 | find = 1; | |
e8f7da3a | 8330 | bgp_show_peer (vty, peer, use_json, json); |
856ca177 MS |
8331 | } |
8332 | } | |
8333 | break; | |
718e3744 | 8334 | } |
8335 | } | |
8336 | ||
8337 | if (type == show_peer && ! find) | |
856ca177 MS |
8338 | { |
8339 | if (use_json) | |
8340 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
8341 | else | |
8342 | vty_out (vty, "%% No such neighbor%s", VTY_NEWLINE); | |
8343 | } | |
8344 | ||
8345 | if (use_json) | |
8346 | { | |
2aac5767 | 8347 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
856ca177 MS |
8348 | json_object_free(json); |
8349 | } | |
8350 | else | |
8351 | { | |
8352 | vty_out (vty, "%s", VTY_NEWLINE); | |
8353 | } | |
8354 | ||
718e3744 | 8355 | return CMD_SUCCESS; |
8356 | } | |
8357 | ||
f186de26 | 8358 | static void |
8359 | bgp_show_all_instances_neighbors_vty (struct vty *vty, u_char use_json) | |
8360 | { | |
8361 | struct listnode *node, *nnode; | |
8362 | struct bgp *bgp; | |
8363 | json_object *json = NULL; | |
9f689658 DD |
8364 | int is_first = 1; |
8365 | ||
8366 | if (use_json) | |
8367 | vty_out (vty, "{%s", VTY_NEWLINE); | |
f186de26 | 8368 | |
8369 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
8370 | { | |
f186de26 | 8371 | if (use_json) |
9f689658 DD |
8372 | { |
8373 | if (!(json = json_object_new_object())) | |
8374 | { | |
8375 | zlog_err("Unable to allocate memory for JSON object"); | |
8376 | vty_out (vty, | |
8377 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}%s", | |
8378 | VTY_NEWLINE); | |
8379 | return; | |
8380 | } | |
8381 | ||
8382 | json_object_int_add(json, "vrfId", | |
8383 | (bgp->vrf_id == VRF_UNKNOWN) | |
8384 | ? -1 : bgp->vrf_id); | |
8385 | json_object_string_add(json, "vrfName", | |
8386 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8387 | ? "Default" : bgp->name); | |
8388 | ||
8389 | if (! is_first) | |
8390 | vty_out (vty, ",%s", VTY_NEWLINE); | |
8391 | else | |
8392 | is_first = 0; | |
8393 | ||
8394 | vty_out(vty, "\"%s\":", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8395 | ? "Default" : bgp->name); | |
8396 | } | |
8397 | else | |
8398 | { | |
8399 | vty_out (vty, "%sInstance %s:%s", | |
8400 | VTY_NEWLINE, | |
8401 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8402 | ? "Default" : bgp->name, | |
8403 | VTY_NEWLINE); | |
8404 | } | |
f186de26 | 8405 | bgp_show_neighbor (vty, bgp, show_all, NULL, NULL, use_json, json); |
8406 | } | |
9f689658 DD |
8407 | |
8408 | if (use_json) | |
8409 | vty_out (vty, "}%s", VTY_NEWLINE); | |
f186de26 | 8410 | } |
8411 | ||
4fb25c53 DW |
8412 | static int |
8413 | bgp_show_neighbor_vty (struct vty *vty, const char *name, | |
8414 | enum show_type type, const char *ip_str, u_char use_json) | |
8415 | { | |
8416 | int ret; | |
8417 | struct bgp *bgp; | |
8418 | union sockunion su; | |
8419 | json_object *json = NULL; | |
8420 | ||
8421 | if (use_json) | |
8422 | json = json_object_new_object(); | |
8423 | ||
8424 | if (name) | |
8425 | { | |
8426 | if (strmatch(name, "all")) | |
8427 | { | |
8428 | bgp_show_all_instances_neighbors_vty (vty, use_json); | |
8429 | return CMD_SUCCESS; | |
8430 | } | |
8431 | else | |
8432 | { | |
8433 | bgp = bgp_lookup_by_name (name); | |
8434 | if (! bgp) | |
8435 | { | |
8436 | if (use_json) | |
8437 | { | |
8438 | json_object_boolean_true_add(json, "bgpNoSuchInstance"); | |
e52702f2 | 8439 | vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); |
4fb25c53 DW |
8440 | json_object_free(json); |
8441 | } | |
8442 | else | |
8443 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
8444 | ||
8445 | return CMD_WARNING; | |
8446 | } | |
8447 | } | |
8448 | } | |
8449 | else | |
8450 | { | |
8451 | bgp = bgp_get_default (); | |
8452 | } | |
8453 | ||
8454 | if (bgp) | |
8455 | { | |
8456 | if (ip_str) | |
8457 | { | |
8458 | ret = str2sockunion (ip_str, &su); | |
8459 | if (ret < 0) | |
8460 | bgp_show_neighbor (vty, bgp, type, NULL, ip_str, use_json, json); | |
8461 | else | |
8462 | bgp_show_neighbor (vty, bgp, type, &su, NULL, use_json, json); | |
8463 | } | |
8464 | else | |
8465 | { | |
8466 | bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json); | |
8467 | } | |
8468 | } | |
8469 | ||
8470 | return CMD_SUCCESS; | |
8471 | } | |
8472 | ||
716b2d8a | 8473 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 8474 | DEFUN (show_ip_bgp_neighbors, |
8475 | show_ip_bgp_neighbors_cmd, | |
91d37724 | 8476 | "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 | 8477 | SHOW_STR |
8478 | IP_STR | |
8479 | BGP_STR | |
5bf15956 | 8480 | BGP_INSTANCE_ALL_HELP_STR |
8c3deaae QY |
8481 | "Address Family\n" |
8482 | "Address Family\n" | |
91d37724 QY |
8483 | "Address Family\n" |
8484 | "Display information about all VPNv4 NLRIs\n" | |
8485 | "Display information for a route distinguisher\n" | |
8486 | "VPN Route Distinguisher\n" | |
718e3744 | 8487 | "Detailed information on TCP and BGP neighbor connections\n" |
8488 | "Neighbor to display information about\n" | |
a80beece | 8489 | "Neighbor to display information about\n" |
91d37724 | 8490 | "Neighbor on BGP configured interface\n" |
9973d184 | 8491 | JSON_STR) |
718e3744 | 8492 | { |
5bf15956 DW |
8493 | char *vrf = NULL; |
8494 | char *sh_arg = NULL; | |
8495 | enum show_type sh_type; | |
718e3744 | 8496 | |
5bf15956 | 8497 | u_char uj = use_json(argc, argv); |
718e3744 | 8498 | |
630a298c | 8499 | int idx = 0; |
718e3744 | 8500 | |
630a298c QY |
8501 | if (argv_find (argv, argc, "WORD", &idx)) |
8502 | vrf = argv[idx]->arg; | |
718e3744 | 8503 | |
91d37724 QY |
8504 | if (argv_find (argv, argc, "A.B.C.D", &idx) || |
8505 | argv_find (argv, argc, "X:X::X:X", &idx) || | |
630a298c QY |
8506 | argv_find (argv, argc, "WORD", &idx)) |
8507 | { | |
8508 | sh_type = show_peer; | |
8509 | sh_arg = argv[idx]->arg; | |
8510 | } | |
5bf15956 | 8511 | else |
630a298c | 8512 | sh_type = show_all; |
856ca177 | 8513 | |
5bf15956 | 8514 | return bgp_show_neighbor_vty (vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 8515 | } |
8516 | ||
716b2d8a | 8517 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 8518 | paths' and `show ip mbgp paths'. Those functions results are the |
8519 | same.*/ | |
f412b39a | 8520 | DEFUN (show_ip_bgp_paths, |
718e3744 | 8521 | show_ip_bgp_paths_cmd, |
46f296b4 | 8522 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 8523 | SHOW_STR |
8524 | IP_STR | |
8525 | BGP_STR | |
46f296b4 | 8526 | BGP_SAFI_HELP_STR |
718e3744 | 8527 | "Path information\n") |
8528 | { | |
8529 | vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE); | |
8530 | aspath_print_all_vty (vty); | |
8531 | return CMD_SUCCESS; | |
8532 | } | |
8533 | ||
718e3744 | 8534 | #include "hash.h" |
8535 | ||
94f2b392 | 8536 | static void |
718e3744 | 8537 | community_show_all_iterator (struct hash_backet *backet, struct vty *vty) |
8538 | { | |
8539 | struct community *com; | |
8540 | ||
8541 | com = (struct community *) backet->data; | |
6c4f4e6e | 8542 | vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, com->refcnt, |
718e3744 | 8543 | community_str (com), VTY_NEWLINE); |
8544 | } | |
8545 | ||
8546 | /* Show BGP's community internal data. */ | |
f412b39a | 8547 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 8548 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 8549 | "show [ip] bgp community-info", |
718e3744 | 8550 | SHOW_STR |
8551 | IP_STR | |
8552 | BGP_STR | |
8553 | "List all bgp community information\n") | |
8554 | { | |
8555 | vty_out (vty, "Address Refcnt Community%s", VTY_NEWLINE); | |
8556 | ||
e52702f2 | 8557 | hash_iterate (community_hash (), |
718e3744 | 8558 | (void (*) (struct hash_backet *, void *)) |
8559 | community_show_all_iterator, | |
8560 | vty); | |
8561 | ||
8562 | return CMD_SUCCESS; | |
8563 | } | |
8564 | ||
f412b39a | 8565 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 8566 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 8567 | "show [ip] bgp attribute-info", |
718e3744 | 8568 | SHOW_STR |
8569 | IP_STR | |
8570 | BGP_STR | |
8571 | "List all bgp attribute information\n") | |
8572 | { | |
8573 | attr_show_all (vty); | |
8574 | return CMD_SUCCESS; | |
8575 | } | |
6b0655a2 | 8576 | |
f186de26 | 8577 | static void |
8578 | bgp_show_all_instances_updgrps_vty (struct vty *vty, afi_t afi, safi_t safi) | |
8579 | { | |
8580 | struct listnode *node, *nnode; | |
8581 | struct bgp *bgp; | |
8582 | ||
8583 | for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp)) | |
8584 | { | |
8585 | vty_out (vty, "%sInstance %s:%s", | |
8586 | VTY_NEWLINE, | |
8587 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name, | |
8588 | VTY_NEWLINE); | |
8589 | update_group_show(bgp, afi, safi, vty, 0); | |
8590 | } | |
8591 | } | |
8592 | ||
4fb25c53 DW |
8593 | static int |
8594 | bgp_show_update_groups(struct vty *vty, const char *name, | |
8595 | int afi, int safi, | |
8596 | uint64_t subgrp_id) | |
8597 | { | |
8598 | struct bgp *bgp; | |
8599 | ||
8600 | if (name) | |
8601 | { | |
8602 | if (strmatch (name, "all")) | |
8603 | { | |
8604 | bgp_show_all_instances_updgrps_vty (vty, afi, safi); | |
8605 | return CMD_SUCCESS; | |
8606 | } | |
8607 | else | |
8608 | { | |
8609 | bgp = bgp_lookup_by_name (name); | |
8610 | } | |
8611 | } | |
8612 | else | |
8613 | { | |
8614 | bgp = bgp_get_default (); | |
8615 | } | |
8616 | ||
8617 | if (bgp) | |
8618 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
8619 | return CMD_SUCCESS; | |
8620 | } | |
8621 | ||
8fe8a7f6 DS |
8622 | DEFUN (show_ip_bgp_updgrps, |
8623 | show_ip_bgp_updgrps_cmd, | |
46f296b4 | 8624 | "show [ip] bgp [<view|vrf> WORD] [<ipv4 ["BGP_SAFI_CMD_STR"]|ipv6 ["BGP_SAFI_CMD_STR"]|encap [unicast]|vpnv4 [unicast]>] update-groups [SUBGROUP-ID]", |
8386ac43 | 8625 | SHOW_STR |
8626 | IP_STR | |
8627 | BGP_STR | |
8628 | BGP_INSTANCE_HELP_STR | |
8c3deaae | 8629 | "Address Family\n" |
46f296b4 LB |
8630 | BGP_SAFI_HELP_STR |
8631 | "Address Family\n" | |
8632 | BGP_SAFI_HELP_STR | |
8c3deaae | 8633 | "Address Family\n" |
5bf15956 | 8634 | "Address Family modifier\n" |
3b14d86e DS |
8635 | "Address Family modifier\n" |
8636 | "Address Family modifier\n" | |
8637 | "Address Family modifier\n" | |
8c3deaae | 8638 | "Address Family\n" |
5bf15956 DW |
8639 | "Address Family modifier\n" |
8640 | "Detailed info about dynamic update groups\n" | |
8641 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 8642 | { |
5bf15956 | 8643 | char *vrf = NULL; |
ae19d7dd QY |
8644 | afi_t afi = AFI_IP6; |
8645 | safi_t safi = SAFI_UNICAST; | |
5bf15956 DW |
8646 | uint64_t subgrp_id = 0; |
8647 | ||
ae19d7dd QY |
8648 | int idx = 0; |
8649 | ||
8650 | /* show [ip] bgp */ | |
8651 | if (argv_find (argv, argc, "ip", &idx)) | |
8652 | afi = AFI_IP; | |
8653 | /* [<view|vrf> WORD] */ | |
8654 | if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) | |
8655 | vrf = argv[++idx]->arg; | |
46f296b4 | 8656 | /* [<ipv4 ["BGP_SAFI_CMD_STR"]|ipv6 ["BGP_SAFI_CMD_STR"]|encap [unicast]|vpnv4 [unicast]>] */ |
ae19d7dd QY |
8657 | if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) |
8658 | { | |
8659 | afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; | |
8660 | if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) | |
3b14d86e | 8661 | safi = bgp_vty_safi_from_arg (argv[idx]->text); |
ae19d7dd QY |
8662 | } |
8663 | else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) | |
8664 | { | |
8665 | afi = AFI_IP; | |
3b14d86e | 8666 | safi = bgp_vty_safi_from_arg (argv[idx]->text); |
ae19d7dd QY |
8667 | // advance idx if necessary |
8668 | argv_find (argv, argc, "unicast", &idx); | |
8669 | } | |
5bf15956 | 8670 | |
ae19d7dd QY |
8671 | /* get subgroup id, if provided */ |
8672 | idx = argc - 1; | |
8673 | if (argv[idx]->type == VARIABLE_TKN) | |
8674 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx]->arg); | |
5bf15956 DW |
8675 | |
8676 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); | |
8fe8a7f6 DS |
8677 | } |
8678 | ||
f186de26 | 8679 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
8680 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 8681 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 8682 | SHOW_STR |
716b2d8a | 8683 | IP_STR |
f186de26 | 8684 | BGP_STR |
8685 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 8686 | "Detailed info about dynamic update groups\n") |
f186de26 | 8687 | { |
8688 | bgp_show_all_instances_updgrps_vty (vty, AFI_IP6, SAFI_UNICAST); | |
8689 | return CMD_SUCCESS; | |
8690 | } | |
8691 | ||
5bf15956 DW |
8692 | DEFUN (show_bgp_updgrps_stats, |
8693 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 8694 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 8695 | SHOW_STR |
716b2d8a | 8696 | IP_STR |
3f9c7369 | 8697 | BGP_STR |
0c7b1b01 | 8698 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
8699 | "Statistics\n") |
8700 | { | |
8701 | struct bgp *bgp; | |
8702 | ||
8703 | bgp = bgp_get_default(); | |
8704 | if (bgp) | |
8705 | update_group_show_stats(bgp, vty); | |
8706 | ||
8707 | return CMD_SUCCESS; | |
8708 | } | |
8709 | ||
8386ac43 | 8710 | DEFUN (show_bgp_instance_updgrps_stats, |
8711 | show_bgp_instance_updgrps_stats_cmd, | |
716b2d8a | 8712 | "show [ip] bgp <view|vrf> WORD update-groups statistics", |
8386ac43 | 8713 | SHOW_STR |
716b2d8a | 8714 | IP_STR |
8386ac43 | 8715 | BGP_STR |
8716 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 8717 | "Detailed info about dynamic update groups\n" |
8386ac43 | 8718 | "Statistics\n") |
8719 | { | |
c500ae40 | 8720 | int idx_word = 3; |
8386ac43 | 8721 | struct bgp *bgp; |
8722 | ||
c500ae40 | 8723 | bgp = bgp_lookup_by_name (argv[idx_word]->arg); |
8386ac43 | 8724 | if (bgp) |
8725 | update_group_show_stats(bgp, vty); | |
8726 | ||
8727 | return CMD_SUCCESS; | |
8728 | } | |
8729 | ||
3f9c7369 | 8730 | static void |
8386ac43 | 8731 | show_bgp_updgrps_adj_info_aux (struct vty *vty, const char *name, |
8732 | afi_t afi, safi_t safi, | |
f43e655e | 8733 | const char *what, uint64_t subgrp_id) |
3f9c7369 DS |
8734 | { |
8735 | struct bgp *bgp; | |
8386ac43 | 8736 | |
8737 | if (name) | |
8738 | bgp = bgp_lookup_by_name (name); | |
8739 | else | |
8740 | bgp = bgp_get_default (); | |
8741 | ||
3f9c7369 DS |
8742 | if (bgp) |
8743 | { | |
8744 | if (!strcmp(what, "advertise-queue")) | |
8745 | update_group_show_adj_queue(bgp, afi, safi, vty, subgrp_id); | |
8746 | else if (!strcmp(what, "advertised-routes")) | |
8747 | update_group_show_advertised(bgp, afi, safi, vty, subgrp_id); | |
8748 | else if (!strcmp(what, "packet-queue")) | |
8749 | update_group_show_packet_queue(bgp, afi, safi, vty, subgrp_id); | |
8750 | } | |
8751 | } | |
8752 | ||
8753 | DEFUN (show_ip_bgp_updgrps_adj, | |
8754 | show_ip_bgp_updgrps_adj_cmd, | |
716b2d8a | 8755 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
8756 | SHOW_STR |
8757 | IP_STR | |
8758 | BGP_STR | |
0c7b1b01 | 8759 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
8760 | "Advertisement queue\n" |
8761 | "Announced routes\n" | |
8762 | "Packet queue\n") | |
8fe8a7f6 | 8763 | |
3f9c7369 | 8764 | { |
c500ae40 DW |
8765 | int idx_type = 4; |
8766 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 8767 | return CMD_SUCCESS; |
8768 | } | |
8769 | ||
8770 | DEFUN (show_ip_bgp_instance_updgrps_adj, | |
8771 | show_ip_bgp_instance_updgrps_adj_cmd, | |
716b2d8a | 8772 | "show [ip] bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 8773 | SHOW_STR |
8774 | IP_STR | |
8775 | BGP_STR | |
8776 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 8777 | "Detailed info about dynamic update groups\n" |
8386ac43 | 8778 | "Advertisement queue\n" |
8779 | "Announced routes\n" | |
8780 | "Packet queue\n") | |
8781 | ||
8782 | { | |
c500ae40 DW |
8783 | int idx_word = 4; |
8784 | int idx_type = 6; | |
8785 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
8786 | return CMD_SUCCESS; |
8787 | } | |
8788 | ||
8789 | DEFUN (show_bgp_updgrps_afi_adj, | |
8790 | show_bgp_updgrps_afi_adj_cmd, | |
46f296b4 | 8791 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 8792 | SHOW_STR |
716b2d8a | 8793 | IP_STR |
3f9c7369 | 8794 | BGP_STR |
46f296b4 | 8795 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 8796 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
8797 | "Advertisement queue\n" |
8798 | "Announced routes\n" | |
8fe8a7f6 DS |
8799 | "Packet queue\n" |
8800 | "Specific subgroup info wanted for\n") | |
3f9c7369 | 8801 | { |
c500ae40 DW |
8802 | int idx_afi = 2; |
8803 | int idx_safi = 3; | |
8804 | int idx_type = 5; | |
46f296b4 LB |
8805 | show_bgp_updgrps_adj_info_aux(vty, NULL, |
8806 | bgp_vty_afi_from_arg(argv[idx_afi]->arg), | |
8807 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), | |
8808 | argv[idx_type]->arg, 0); | |
8fe8a7f6 | 8809 | return CMD_SUCCESS; |
3f9c7369 DS |
8810 | } |
8811 | ||
8812 | DEFUN (show_bgp_updgrps_adj, | |
8813 | show_bgp_updgrps_adj_cmd, | |
716b2d8a | 8814 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 8815 | SHOW_STR |
716b2d8a | 8816 | IP_STR |
3f9c7369 | 8817 | BGP_STR |
0c7b1b01 | 8818 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
8819 | "Advertisement queue\n" |
8820 | "Announced routes\n" | |
8821 | "Packet queue\n") | |
8822 | { | |
c500ae40 DW |
8823 | int idx_type = 3; |
8824 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
8386ac43 | 8825 | return CMD_SUCCESS; |
8826 | } | |
8827 | ||
8828 | DEFUN (show_bgp_instance_updgrps_adj, | |
8829 | show_bgp_instance_updgrps_adj_cmd, | |
716b2d8a | 8830 | "show [ip] bgp <view|vrf> WORD update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 8831 | SHOW_STR |
716b2d8a | 8832 | IP_STR |
8386ac43 | 8833 | BGP_STR |
8834 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 8835 | "Detailed info about dynamic update groups\n" |
8386ac43 | 8836 | "Advertisement queue\n" |
8837 | "Announced routes\n" | |
8838 | "Packet queue\n") | |
8839 | { | |
c500ae40 DW |
8840 | int idx_word = 3; |
8841 | int idx_type = 5; | |
8842 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, 0); | |
3f9c7369 DS |
8843 | return CMD_SUCCESS; |
8844 | } | |
8845 | ||
8846 | DEFUN (show_ip_bgp_updgrps_adj_s, | |
8fe8a7f6 | 8847 | show_ip_bgp_updgrps_adj_s_cmd, |
716b2d8a | 8848 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
8849 | SHOW_STR |
8850 | IP_STR | |
8851 | BGP_STR | |
0c7b1b01 | 8852 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 8853 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
8854 | "Advertisement queue\n" |
8855 | "Announced routes\n" | |
8856 | "Packet queue\n") | |
3f9c7369 | 8857 | |
3f9c7369 | 8858 | { |
5bf15956 | 8859 | int idx_subgroup_id = 4; |
c500ae40 | 8860 | int idx_type = 5; |
f43e655e | 8861 | uint64_t subgrp_id; |
8fe8a7f6 | 8862 | |
5bf15956 | 8863 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 8864 | |
5bf15956 | 8865 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 8866 | return CMD_SUCCESS; |
8867 | } | |
8868 | ||
8869 | DEFUN (show_ip_bgp_instance_updgrps_adj_s, | |
8870 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
716b2d8a | 8871 | "show [ip] bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 8872 | SHOW_STR |
8873 | IP_STR | |
8874 | BGP_STR | |
8875 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 8876 | "Detailed info about dynamic update groups\n" |
8386ac43 | 8877 | "Specific subgroup to display info for\n" |
8878 | "Advertisement queue\n" | |
8879 | "Announced routes\n" | |
8880 | "Packet queue\n") | |
8881 | ||
8882 | { | |
5bf15956 DW |
8883 | int idx_vrf = 4; |
8884 | int idx_subgroup_id = 6; | |
c500ae40 | 8885 | int idx_type = 7; |
f43e655e | 8886 | uint64_t subgrp_id; |
8386ac43 | 8887 | |
5bf15956 | 8888 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 8889 | |
5bf15956 | 8890 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
3f9c7369 DS |
8891 | return CMD_SUCCESS; |
8892 | } | |
8893 | ||
8fe8a7f6 DS |
8894 | DEFUN (show_bgp_updgrps_afi_adj_s, |
8895 | show_bgp_updgrps_afi_adj_s_cmd, | |
46f296b4 | 8896 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 8897 | SHOW_STR |
716b2d8a | 8898 | IP_STR |
3f9c7369 | 8899 | BGP_STR |
46f296b4 | 8900 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 8901 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 8902 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
8903 | "Advertisement queue\n" |
8904 | "Announced routes\n" | |
8fe8a7f6 DS |
8905 | "Packet queue\n" |
8906 | "Specific subgroup info wanted for\n") | |
3f9c7369 | 8907 | { |
c500ae40 DW |
8908 | int idx_afi = 2; |
8909 | int idx_safi = 3; | |
5bf15956 | 8910 | int idx_subgroup_id = 5; |
c500ae40 | 8911 | int idx_type = 6; |
f43e655e | 8912 | uint64_t subgrp_id; |
3f9c7369 | 8913 | |
5bf15956 | 8914 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 8915 | |
46f296b4 LB |
8916 | show_bgp_updgrps_adj_info_aux(vty, NULL, |
8917 | bgp_vty_afi_from_arg(argv[idx_afi]->arg), | |
8918 | bgp_vty_safi_from_arg(argv[idx_safi]->arg), | |
8919 | argv[idx_type]->arg, subgrp_id); | |
8fe8a7f6 | 8920 | return CMD_SUCCESS; |
3f9c7369 DS |
8921 | } |
8922 | ||
8fe8a7f6 DS |
8923 | DEFUN (show_bgp_updgrps_adj_s, |
8924 | show_bgp_updgrps_adj_s_cmd, | |
716b2d8a | 8925 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8fe8a7f6 | 8926 | SHOW_STR |
716b2d8a | 8927 | IP_STR |
8fe8a7f6 | 8928 | BGP_STR |
0c7b1b01 | 8929 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 DS |
8930 | "Specific subgroup to display info for\n" |
8931 | "Advertisement queue\n" | |
8932 | "Announced routes\n" | |
8933 | "Packet queue\n") | |
8934 | { | |
5bf15956 | 8935 | int idx_subgroup_id = 3; |
c500ae40 | 8936 | int idx_type = 4; |
f43e655e | 8937 | uint64_t subgrp_id; |
8fe8a7f6 | 8938 | |
5bf15956 | 8939 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8fe8a7f6 | 8940 | |
5bf15956 | 8941 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8fe8a7f6 DS |
8942 | return CMD_SUCCESS; |
8943 | } | |
8944 | ||
8386ac43 | 8945 | DEFUN (show_bgp_instance_updgrps_adj_s, |
8946 | show_bgp_instance_updgrps_adj_s_cmd, | |
716b2d8a | 8947 | "show [ip] bgp <view|vrf> WORD update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 8948 | SHOW_STR |
716b2d8a | 8949 | IP_STR |
8386ac43 | 8950 | BGP_STR |
8951 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 8952 | "Detailed info about dynamic update groups\n" |
8386ac43 | 8953 | "Specific subgroup to display info for\n" |
8954 | "Advertisement queue\n" | |
8955 | "Announced routes\n" | |
8956 | "Packet queue\n") | |
8957 | { | |
5bf15956 DW |
8958 | int idx_vrf = 3; |
8959 | int idx_subgroup_id = 5; | |
c500ae40 | 8960 | int idx_type = 6; |
f43e655e | 8961 | uint64_t subgrp_id; |
8386ac43 | 8962 | |
5bf15956 | 8963 | VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); |
8386ac43 | 8964 | |
5bf15956 | 8965 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP6, SAFI_UNICAST, argv[idx_type]->arg, subgrp_id); |
8386ac43 | 8966 | return CMD_SUCCESS; |
8967 | } | |
8968 | ||
8969 | ||
8fe8a7f6 | 8970 | |
f14e6fdb DS |
8971 | static int |
8972 | bgp_show_one_peer_group (struct vty *vty, struct peer_group *group) | |
8973 | { | |
8974 | struct listnode *node, *nnode; | |
8975 | struct prefix *range; | |
8976 | struct peer *conf; | |
8977 | struct peer *peer; | |
4690c7d7 | 8978 | char buf[PREFIX2STR_BUFFER]; |
f14e6fdb DS |
8979 | afi_t afi; |
8980 | safi_t safi; | |
ffd0c037 DS |
8981 | const char *peer_status; |
8982 | const char *af_str; | |
f14e6fdb DS |
8983 | int lr_count; |
8984 | int dynamic; | |
8985 | int af_cfgd; | |
8986 | ||
8987 | conf = group->conf; | |
8988 | ||
0299c004 DS |
8989 | if (conf->as_type == AS_SPECIFIED || |
8990 | conf->as_type == AS_EXTERNAL) { | |
66b199b2 | 8991 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
f14e6fdb | 8992 | VTY_NEWLINE, group->name, conf->as, VTY_NEWLINE); |
0299c004 | 8993 | } else if (conf->as_type == AS_INTERNAL) { |
66b199b2 | 8994 | vty_out (vty, "%sBGP peer-group %s, remote AS %d%s", |
0299c004 | 8995 | VTY_NEWLINE, group->name, group->bgp->as, VTY_NEWLINE); |
66b199b2 DS |
8996 | } else { |
8997 | vty_out (vty, "%sBGP peer-group %s%s", | |
8998 | VTY_NEWLINE, group->name, VTY_NEWLINE); | |
0299c004 | 8999 | } |
f14e6fdb | 9000 | |
0299c004 | 9001 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
f14e6fdb DS |
9002 | vty_out (vty, " Peer-group type is internal%s", VTY_NEWLINE); |
9003 | else | |
9004 | vty_out (vty, " Peer-group type is external%s", VTY_NEWLINE); | |
9005 | ||
9006 | /* Display AFs configured. */ | |
9007 | vty_out (vty, " Configured address-families:"); | |
9008 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9009 | for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) | |
9010 | { | |
9011 | if (conf->afc[afi][safi]) | |
9012 | { | |
9013 | af_cfgd = 1; | |
9014 | vty_out (vty, " %s;", afi_safi_print(afi, safi)); | |
9015 | } | |
9016 | } | |
9017 | if (!af_cfgd) | |
9018 | vty_out (vty, " none%s", VTY_NEWLINE); | |
9019 | else | |
9020 | vty_out (vty, "%s", VTY_NEWLINE); | |
9021 | ||
9022 | /* Display listen ranges (for dynamic neighbors), if any */ | |
9023 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9024 | { | |
9025 | if (afi == AFI_IP) | |
9026 | af_str = "IPv4"; | |
9027 | else if (afi == AFI_IP6) | |
9028 | af_str = "IPv6"; | |
45ef4300 DL |
9029 | else |
9030 | af_str = "???"; | |
f14e6fdb DS |
9031 | lr_count = listcount(group->listen_range[afi]); |
9032 | if (lr_count) | |
9033 | { | |
9034 | vty_out(vty, | |
9035 | " %d %s listen range(s)%s", | |
9036 | lr_count, af_str, VTY_NEWLINE); | |
9037 | ||
9038 | ||
9039 | for (ALL_LIST_ELEMENTS (group->listen_range[afi], node, | |
9040 | nnode, range)) | |
9041 | { | |
9042 | prefix2str(range, buf, sizeof(buf)); | |
9043 | vty_out(vty, " %s%s", buf, VTY_NEWLINE); | |
9044 | } | |
9045 | } | |
9046 | } | |
9047 | ||
9048 | /* Display group members and their status */ | |
9049 | if (listcount(group->peer)) | |
9050 | { | |
9051 | vty_out (vty, " Peer-group members:%s", VTY_NEWLINE); | |
9052 | for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer)) | |
9053 | { | |
9054 | if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) | |
9055 | peer_status = "Idle (Admin)"; | |
9056 | else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) | |
9057 | peer_status = "Idle (PfxCt)"; | |
9058 | else | |
9059 | peer_status = LOOKUP(bgp_status_msg, peer->status); | |
9060 | ||
9061 | dynamic = peer_dynamic_neighbor(peer); | |
9062 | vty_out (vty, " %s %s %s %s", | |
9063 | peer->host, dynamic ? "(dynamic)" : "", | |
9064 | peer_status, VTY_NEWLINE); | |
9065 | } | |
9066 | } | |
9067 | ||
9068 | return CMD_SUCCESS; | |
9069 | } | |
9070 | ||
9071 | /* Show BGP peer group's information. */ | |
9072 | enum show_group_type | |
9073 | { | |
9074 | show_all_groups, | |
9075 | show_peer_group | |
9076 | }; | |
9077 | ||
9078 | static int | |
9079 | bgp_show_peer_group (struct vty *vty, struct bgp *bgp, | |
9080 | enum show_group_type type, const char *group_name) | |
9081 | { | |
9082 | struct listnode *node, *nnode; | |
9083 | struct peer_group *group; | |
9084 | int find = 0; | |
9085 | ||
9086 | for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group)) | |
9087 | { | |
9088 | switch (type) | |
9089 | { | |
9090 | case show_all_groups: | |
9091 | bgp_show_one_peer_group (vty, group); | |
9092 | break; | |
9093 | case show_peer_group: | |
9094 | if (group_name && (strcmp(group->name, group_name) == 0)) | |
9095 | { | |
9096 | find = 1; | |
9097 | bgp_show_one_peer_group (vty, group); | |
9098 | } | |
9099 | break; | |
9100 | } | |
9101 | } | |
9102 | ||
9103 | if (type == show_peer_group && ! find) | |
6d9e66dc | 9104 | vty_out (vty, "%% No such peer-group%s", VTY_NEWLINE); |
f14e6fdb DS |
9105 | |
9106 | return CMD_SUCCESS; | |
9107 | } | |
9108 | ||
9109 | static int | |
9110 | bgp_show_peer_group_vty (struct vty *vty, const char *name, | |
9111 | enum show_group_type type, const char *group_name) | |
9112 | { | |
9113 | struct bgp *bgp; | |
9114 | int ret = CMD_SUCCESS; | |
9115 | ||
9116 | if (name) | |
8386ac43 | 9117 | bgp = bgp_lookup_by_name (name); |
9118 | else | |
9119 | bgp = bgp_get_default (); | |
f14e6fdb | 9120 | |
8386ac43 | 9121 | if (! bgp) |
9122 | { | |
9123 | vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); | |
9124 | return CMD_WARNING; | |
f14e6fdb DS |
9125 | } |
9126 | ||
8386ac43 | 9127 | ret = bgp_show_peer_group (vty, bgp, type, group_name); |
f14e6fdb DS |
9128 | |
9129 | return ret; | |
9130 | } | |
9131 | ||
9132 | DEFUN (show_ip_bgp_peer_groups, | |
9133 | show_ip_bgp_peer_groups_cmd, | |
d6e3c605 | 9134 | "show [ip] bgp [<view|vrf> VRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
9135 | SHOW_STR |
9136 | IP_STR | |
9137 | BGP_STR | |
8386ac43 | 9138 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
9139 | "Detailed information on BGP peer groups\n" |
9140 | "Peer group name\n") | |
f14e6fdb | 9141 | { |
d6e3c605 QY |
9142 | char *vrf, *pg; |
9143 | vrf = pg = NULL; | |
9144 | int idx = 0; | |
f14e6fdb | 9145 | |
d6e3c605 QY |
9146 | vrf = argv_find (argv, argc, "VRFNAME", &idx) ? argv[idx]->arg : NULL; |
9147 | pg = argv_find (argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; | |
f14e6fdb | 9148 | |
d6e3c605 | 9149 | return bgp_show_peer_group_vty (vty, vrf, show_all_groups, pg); |
f14e6fdb | 9150 | } |
3f9c7369 | 9151 | |
d6e3c605 | 9152 | |
718e3744 | 9153 | /* Redistribute VTY commands. */ |
9154 | ||
718e3744 | 9155 | DEFUN (bgp_redistribute_ipv4, |
9156 | bgp_redistribute_ipv4_cmd, | |
9ccf14f7 | 9157 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table>", |
718e3744 | 9158 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9159 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 9160 | { |
cdc2d765 | 9161 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9162 | int idx_protocol = 1; |
718e3744 | 9163 | int type; |
9164 | ||
6d681bd8 QY |
9165 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9166 | if (type < 0) | |
718e3744 | 9167 | { |
9168 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9169 | return CMD_WARNING; | |
9170 | } | |
cdc2d765 DL |
9171 | bgp_redist_add(bgp, AFI_IP, type, 0); |
9172 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9173 | } |
9174 | ||
9175 | DEFUN (bgp_redistribute_ipv4_rmap, | |
9176 | bgp_redistribute_ipv4_rmap_cmd, | |
9ccf14f7 | 9177 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> route-map WORD", |
718e3744 | 9178 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9179 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9180 | "Route map reference\n" |
9181 | "Pointer to route-map entries\n") | |
9182 | { | |
cdc2d765 | 9183 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9184 | int idx_protocol = 1; |
9185 | int idx_word = 3; | |
718e3744 | 9186 | int type; |
7c8ff89e | 9187 | struct bgp_redist *red; |
718e3744 | 9188 | |
6d681bd8 QY |
9189 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9190 | if (type < 0) | |
718e3744 | 9191 | { |
9192 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9193 | return CMD_WARNING; | |
9194 | } | |
9195 | ||
cdc2d765 | 9196 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
c500ae40 | 9197 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9198 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); |
718e3744 | 9199 | } |
9200 | ||
9201 | DEFUN (bgp_redistribute_ipv4_metric, | |
9202 | bgp_redistribute_ipv4_metric_cmd, | |
9ccf14f7 | 9203 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> metric (0-4294967295)", |
718e3744 | 9204 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9205 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9206 | "Metric for redistributed routes\n" |
9207 | "Default metric\n") | |
9208 | { | |
cdc2d765 | 9209 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9210 | int idx_protocol = 1; |
9211 | int idx_number = 3; | |
718e3744 | 9212 | int type; |
9213 | u_int32_t metric; | |
7c8ff89e | 9214 | struct bgp_redist *red; |
718e3744 | 9215 | |
6d681bd8 QY |
9216 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9217 | if (type < 0) | |
718e3744 | 9218 | { |
9219 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9220 | return CMD_WARNING; | |
9221 | } | |
c500ae40 | 9222 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9223 | |
cdc2d765 DL |
9224 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
9225 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
9226 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9227 | } |
9228 | ||
9229 | DEFUN (bgp_redistribute_ipv4_rmap_metric, | |
9230 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
9ccf14f7 | 9231 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> route-map WORD metric (0-4294967295)", |
718e3744 | 9232 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9233 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9234 | "Route map reference\n" |
9235 | "Pointer to route-map entries\n" | |
9236 | "Metric for redistributed routes\n" | |
9237 | "Default metric\n") | |
9238 | { | |
cdc2d765 | 9239 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9240 | int idx_protocol = 1; |
9241 | int idx_word = 3; | |
9242 | int idx_number = 5; | |
718e3744 | 9243 | int type; |
9244 | u_int32_t metric; | |
7c8ff89e | 9245 | struct bgp_redist *red; |
718e3744 | 9246 | |
6d681bd8 QY |
9247 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9248 | if (type < 0) | |
718e3744 | 9249 | { |
9250 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9251 | return CMD_WARNING; | |
9252 | } | |
c500ae40 | 9253 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9254 | |
cdc2d765 | 9255 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
c500ae40 | 9256 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9257 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
9258 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); | |
718e3744 | 9259 | } |
9260 | ||
9261 | DEFUN (bgp_redistribute_ipv4_metric_rmap, | |
9262 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
9ccf14f7 | 9263 | "redistribute <kernel|connected|static|rip|ospf|isis|pim|table> metric (0-4294967295) route-map WORD", |
718e3744 | 9264 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9265 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 9266 | "Metric for redistributed routes\n" |
9267 | "Default metric\n" | |
9268 | "Route map reference\n" | |
9269 | "Pointer to route-map entries\n") | |
9270 | { | |
cdc2d765 | 9271 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9272 | int idx_protocol = 1; |
9273 | int idx_number = 3; | |
9274 | int idx_word = 5; | |
718e3744 | 9275 | int type; |
9276 | u_int32_t metric; | |
7c8ff89e | 9277 | struct bgp_redist *red; |
718e3744 | 9278 | |
6d681bd8 QY |
9279 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9280 | if (type < 0) | |
718e3744 | 9281 | { |
9282 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9283 | return CMD_WARNING; | |
9284 | } | |
c500ae40 | 9285 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9286 | |
cdc2d765 DL |
9287 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
9288 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
c500ae40 | 9289 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9290 | return bgp_redistribute_set (bgp, AFI_IP, type, 0); |
718e3744 | 9291 | } |
9292 | ||
7c8ff89e DS |
9293 | DEFUN (bgp_redistribute_ipv4_ospf, |
9294 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 9295 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
9296 | "Redistribute information from another routing protocol\n" |
9297 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9298 | "Non-main Kernel Routing Table\n" |
9299 | "Instance ID/Table ID\n") | |
7c8ff89e | 9300 | { |
cdc2d765 | 9301 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9302 | int idx_ospf_table = 1; |
9303 | int idx_number = 2; | |
7c8ff89e | 9304 | u_short instance; |
7a4bb9c5 | 9305 | u_short protocol; |
7c8ff89e | 9306 | |
c500ae40 | 9307 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
7a4bb9c5 | 9308 | |
c500ae40 | 9309 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9310 | protocol = ZEBRA_ROUTE_OSPF; |
9311 | else | |
9312 | protocol = ZEBRA_ROUTE_TABLE; | |
9313 | ||
cdc2d765 DL |
9314 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9315 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9316 | } |
9317 | ||
9318 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, | |
9319 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 9320 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
9321 | "Redistribute information from another routing protocol\n" |
9322 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9323 | "Non-main Kernel Routing Table\n" |
9324 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9325 | "Route map reference\n" |
9326 | "Pointer to route-map entries\n") | |
9327 | { | |
cdc2d765 | 9328 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9329 | int idx_ospf_table = 1; |
9330 | int idx_number = 2; | |
9331 | int idx_word = 4; | |
7c8ff89e DS |
9332 | struct bgp_redist *red; |
9333 | u_short instance; | |
7a4bb9c5 | 9334 | int protocol; |
7c8ff89e | 9335 | |
c500ae40 | 9336 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9337 | protocol = ZEBRA_ROUTE_OSPF; |
9338 | else | |
9339 | protocol = ZEBRA_ROUTE_TABLE; | |
9340 | ||
c500ae40 | 9341 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
cdc2d765 | 9342 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
c500ae40 | 9343 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9344 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9345 | } |
9346 | ||
9347 | DEFUN (bgp_redistribute_ipv4_ospf_metric, | |
9348 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 9349 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
9350 | "Redistribute information from another routing protocol\n" |
9351 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9352 | "Non-main Kernel Routing Table\n" |
9353 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9354 | "Metric for redistributed routes\n" |
9355 | "Default metric\n") | |
9356 | { | |
cdc2d765 | 9357 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9358 | int idx_ospf_table = 1; |
9359 | int idx_number = 2; | |
9360 | int idx_number_2 = 4; | |
7c8ff89e DS |
9361 | u_int32_t metric; |
9362 | struct bgp_redist *red; | |
9363 | u_short instance; | |
7a4bb9c5 | 9364 | int protocol; |
7c8ff89e | 9365 | |
c500ae40 | 9366 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9367 | protocol = ZEBRA_ROUTE_OSPF; |
9368 | else | |
9369 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9370 | |
c500ae40 DW |
9371 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9372 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9373 | |
cdc2d765 DL |
9374 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9375 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
9376 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9377 | } |
9378 | ||
9379 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, | |
9380 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 9381 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
9382 | "Redistribute information from another routing protocol\n" |
9383 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9384 | "Non-main Kernel Routing Table\n" |
9385 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9386 | "Route map reference\n" |
9387 | "Pointer to route-map entries\n" | |
9388 | "Metric for redistributed routes\n" | |
9389 | "Default metric\n") | |
9390 | { | |
cdc2d765 | 9391 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9392 | int idx_ospf_table = 1; |
9393 | int idx_number = 2; | |
9394 | int idx_word = 4; | |
9395 | int idx_number_2 = 6; | |
7c8ff89e DS |
9396 | u_int32_t metric; |
9397 | struct bgp_redist *red; | |
9398 | u_short instance; | |
7a4bb9c5 | 9399 | int protocol; |
7c8ff89e | 9400 | |
c500ae40 | 9401 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9402 | protocol = ZEBRA_ROUTE_OSPF; |
9403 | else | |
9404 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9405 | |
c500ae40 DW |
9406 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9407 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9408 | |
cdc2d765 | 9409 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
c500ae40 | 9410 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9411 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); |
9412 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
9413 | } |
9414 | ||
9415 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, | |
9416 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 9417 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
9418 | "Redistribute information from another routing protocol\n" |
9419 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
9420 | "Non-main Kernel Routing Table\n" |
9421 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
9422 | "Metric for redistributed routes\n" |
9423 | "Default metric\n" | |
9424 | "Route map reference\n" | |
9425 | "Pointer to route-map entries\n") | |
9426 | { | |
cdc2d765 | 9427 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9428 | int idx_ospf_table = 1; |
9429 | int idx_number = 2; | |
9430 | int idx_number_2 = 4; | |
9431 | int idx_word = 6; | |
7c8ff89e DS |
9432 | u_int32_t metric; |
9433 | struct bgp_redist *red; | |
9434 | u_short instance; | |
7a4bb9c5 | 9435 | int protocol; |
7c8ff89e | 9436 | |
c500ae40 | 9437 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9438 | protocol = ZEBRA_ROUTE_OSPF; |
9439 | else | |
9440 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9441 | |
c500ae40 DW |
9442 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
9443 | VTY_GET_INTEGER ("metric", metric, argv[idx_number_2]->arg); | |
7a4bb9c5 | 9444 | |
cdc2d765 DL |
9445 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); |
9446 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
c500ae40 | 9447 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9448 | return bgp_redistribute_set (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9449 | } |
9450 | ||
9451 | DEFUN (no_bgp_redistribute_ipv4_ospf, | |
9452 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 9453 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
9454 | NO_STR |
9455 | "Redistribute information from another routing protocol\n" | |
9456 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 9457 | "Non-main Kernel Routing Table\n" |
31500417 DW |
9458 | "Instance ID/Table ID\n" |
9459 | "Metric for redistributed routes\n" | |
9460 | "Default metric\n" | |
9461 | "Route map reference\n" | |
9462 | "Pointer to route-map entries\n") | |
7c8ff89e | 9463 | { |
cdc2d765 | 9464 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9465 | int idx_ospf_table = 2; |
9466 | int idx_number = 3; | |
7c8ff89e | 9467 | u_short instance; |
7a4bb9c5 DS |
9468 | int protocol; |
9469 | ||
c500ae40 | 9470 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
7a4bb9c5 DS |
9471 | protocol = ZEBRA_ROUTE_OSPF; |
9472 | else | |
9473 | protocol = ZEBRA_ROUTE_TABLE; | |
7c8ff89e | 9474 | |
c500ae40 | 9475 | VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); |
cdc2d765 | 9476 | return bgp_redistribute_unset (bgp, AFI_IP, protocol, instance); |
7c8ff89e DS |
9477 | } |
9478 | ||
718e3744 | 9479 | DEFUN (no_bgp_redistribute_ipv4, |
9480 | no_bgp_redistribute_ipv4_cmd, | |
d04c479d | 9481 | "no redistribute <kernel|connected|static|rip|ospf|isis|pim|table> [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 9482 | NO_STR |
9483 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 9484 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
9485 | "Metric for redistributed routes\n" |
9486 | "Default metric\n" | |
9487 | "Route map reference\n" | |
9488 | "Pointer to route-map entries\n") | |
718e3744 | 9489 | { |
cdc2d765 | 9490 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9491 | int idx_protocol = 2; |
718e3744 | 9492 | int type; |
9493 | ||
6d681bd8 QY |
9494 | type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); |
9495 | if (type < 0) | |
718e3744 | 9496 | { |
9497 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9498 | return CMD_WARNING; | |
9499 | } | |
cdc2d765 | 9500 | return bgp_redistribute_unset (bgp, AFI_IP, type, 0); |
718e3744 | 9501 | } |
9502 | ||
718e3744 | 9503 | #ifdef HAVE_IPV6 |
9504 | DEFUN (bgp_redistribute_ipv6, | |
9505 | bgp_redistribute_ipv6_cmd, | |
9ccf14f7 | 9506 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table>", |
718e3744 | 9507 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9508 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 9509 | { |
cdc2d765 | 9510 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9511 | int idx_protocol = 1; |
718e3744 | 9512 | int type; |
9513 | ||
6d681bd8 QY |
9514 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9515 | if (type < 0) | |
718e3744 | 9516 | { |
9517 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9518 | return CMD_WARNING; | |
9519 | } | |
9520 | ||
cdc2d765 DL |
9521 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
9522 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9523 | } |
9524 | ||
9525 | DEFUN (bgp_redistribute_ipv6_rmap, | |
9526 | bgp_redistribute_ipv6_rmap_cmd, | |
9ccf14f7 | 9527 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table> route-map WORD", |
718e3744 | 9528 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9529 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9530 | "Route map reference\n" |
9531 | "Pointer to route-map entries\n") | |
9532 | { | |
cdc2d765 | 9533 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9534 | int idx_protocol = 1; |
9535 | int idx_word = 3; | |
718e3744 | 9536 | int type; |
7c8ff89e | 9537 | struct bgp_redist *red; |
718e3744 | 9538 | |
6d681bd8 QY |
9539 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9540 | if (type < 0) | |
718e3744 | 9541 | { |
9542 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9543 | return CMD_WARNING; | |
9544 | } | |
9545 | ||
cdc2d765 | 9546 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
c500ae40 | 9547 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9548 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); |
718e3744 | 9549 | } |
9550 | ||
9551 | DEFUN (bgp_redistribute_ipv6_metric, | |
9552 | bgp_redistribute_ipv6_metric_cmd, | |
9ccf14f7 | 9553 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table> metric (0-4294967295)", |
718e3744 | 9554 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9555 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9556 | "Metric for redistributed routes\n" |
9557 | "Default metric\n") | |
9558 | { | |
cdc2d765 | 9559 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9560 | int idx_protocol = 1; |
9561 | int idx_number = 3; | |
718e3744 | 9562 | int type; |
9563 | u_int32_t metric; | |
7c8ff89e | 9564 | struct bgp_redist *red; |
718e3744 | 9565 | |
6d681bd8 QY |
9566 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9567 | if (type < 0) | |
718e3744 | 9568 | { |
9569 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9570 | return CMD_WARNING; | |
9571 | } | |
c500ae40 | 9572 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9573 | |
cdc2d765 DL |
9574 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
9575 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
9576 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9577 | } |
9578 | ||
9579 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
9580 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
9ccf14f7 | 9581 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table> route-map WORD metric (0-4294967295)", |
718e3744 | 9582 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9583 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9584 | "Route map reference\n" |
9585 | "Pointer to route-map entries\n" | |
9586 | "Metric for redistributed routes\n" | |
9587 | "Default metric\n") | |
9588 | { | |
cdc2d765 | 9589 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9590 | int idx_protocol = 1; |
9591 | int idx_word = 3; | |
9592 | int idx_number = 5; | |
718e3744 | 9593 | int type; |
9594 | u_int32_t metric; | |
7c8ff89e | 9595 | struct bgp_redist *red; |
718e3744 | 9596 | |
6d681bd8 QY |
9597 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9598 | if (type < 0) | |
718e3744 | 9599 | { |
9600 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9601 | return CMD_WARNING; | |
9602 | } | |
c500ae40 | 9603 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9604 | |
cdc2d765 | 9605 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
c500ae40 | 9606 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 DL |
9607 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
9608 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); | |
718e3744 | 9609 | } |
9610 | ||
9611 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
9612 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
9ccf14f7 | 9613 | "redistribute <kernel|connected|static|ripng|ospf6|isis|table> metric (0-4294967295) route-map WORD", |
718e3744 | 9614 | "Redistribute information from another routing protocol\n" |
ab0181ee | 9615 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 9616 | "Metric for redistributed routes\n" |
9617 | "Default metric\n" | |
9618 | "Route map reference\n" | |
9619 | "Pointer to route-map entries\n") | |
9620 | { | |
cdc2d765 | 9621 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 DW |
9622 | int idx_protocol = 1; |
9623 | int idx_number = 3; | |
9624 | int idx_word = 5; | |
718e3744 | 9625 | int type; |
9626 | u_int32_t metric; | |
7c8ff89e | 9627 | struct bgp_redist *red; |
718e3744 | 9628 | |
6d681bd8 QY |
9629 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9630 | if (type < 0) | |
718e3744 | 9631 | { |
9632 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9633 | return CMD_WARNING; | |
9634 | } | |
c500ae40 | 9635 | VTY_GET_INTEGER ("metric", metric, argv[idx_number]->arg); |
718e3744 | 9636 | |
cdc2d765 DL |
9637 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
9638 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric); | |
c500ae40 | 9639 | bgp_redistribute_rmap_set (red, argv[idx_word]->arg); |
cdc2d765 | 9640 | return bgp_redistribute_set (bgp, AFI_IP6, type, 0); |
718e3744 | 9641 | } |
9642 | ||
9643 | DEFUN (no_bgp_redistribute_ipv6, | |
9644 | no_bgp_redistribute_ipv6_cmd, | |
d04c479d | 9645 | "no redistribute <kernel|connected|static|ripng|ospf6|isis|table> [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 9646 | NO_STR |
9647 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 9648 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
9649 | "Metric for redistributed routes\n" |
9650 | "Default metric\n" | |
9651 | "Route map reference\n" | |
9652 | "Pointer to route-map entries\n") | |
718e3744 | 9653 | { |
cdc2d765 | 9654 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
c500ae40 | 9655 | int idx_protocol = 2; |
718e3744 | 9656 | int type; |
9657 | ||
6d681bd8 QY |
9658 | type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); |
9659 | if (type < 0) | |
718e3744 | 9660 | { |
9661 | vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); | |
9662 | return CMD_WARNING; | |
9663 | } | |
9664 | ||
cdc2d765 | 9665 | return bgp_redistribute_unset (bgp, AFI_IP6, type, 0); |
718e3744 | 9666 | } |
718e3744 | 9667 | #endif /* HAVE_IPV6 */ |
6b0655a2 | 9668 | |
718e3744 | 9669 | int |
9670 | bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi, | |
9671 | safi_t safi, int *write) | |
9672 | { | |
9673 | int i; | |
718e3744 | 9674 | |
9675 | /* Unicast redistribution only. */ | |
9676 | if (safi != SAFI_UNICAST) | |
9677 | return 0; | |
9678 | ||
9679 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) | |
9680 | { | |
9681 | /* Redistribute BGP does not make sense. */ | |
7c8ff89e | 9682 | if (i != ZEBRA_ROUTE_BGP) |
718e3744 | 9683 | { |
7c8ff89e DS |
9684 | struct list *red_list; |
9685 | struct listnode *node; | |
9686 | struct bgp_redist *red; | |
718e3744 | 9687 | |
7c8ff89e DS |
9688 | red_list = bgp->redist[afi][i]; |
9689 | if (!red_list) | |
9690 | continue; | |
718e3744 | 9691 | |
7c8ff89e DS |
9692 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) |
9693 | { | |
9694 | /* Display "address-family" when it is not yet diplayed. */ | |
9695 | bgp_config_write_family_header (vty, afi, safi, write); | |
9696 | ||
9697 | /* "redistribute" configuration. */ | |
0b960b4d | 9698 | vty_out (vty, " redistribute %s", zebra_route_string(i)); |
7c8ff89e DS |
9699 | if (red->instance) |
9700 | vty_out (vty, " %d", red->instance); | |
9701 | if (red->redist_metric_flag) | |
9702 | vty_out (vty, " metric %u", red->redist_metric); | |
9703 | if (red->rmap.name) | |
9704 | vty_out (vty, " route-map %s", red->rmap.name); | |
9705 | vty_out (vty, "%s", VTY_NEWLINE); | |
9706 | } | |
718e3744 | 9707 | } |
9708 | } | |
9709 | return *write; | |
9710 | } | |
6b0655a2 | 9711 | |
718e3744 | 9712 | /* BGP node structure. */ |
7fc626de | 9713 | static struct cmd_node bgp_node = |
718e3744 | 9714 | { |
9715 | BGP_NODE, | |
9716 | "%s(config-router)# ", | |
9717 | 1, | |
9718 | }; | |
9719 | ||
7fc626de | 9720 | static struct cmd_node bgp_ipv4_unicast_node = |
718e3744 | 9721 | { |
9722 | BGP_IPV4_NODE, | |
9723 | "%s(config-router-af)# ", | |
9724 | 1, | |
9725 | }; | |
9726 | ||
7fc626de | 9727 | static struct cmd_node bgp_ipv4_multicast_node = |
718e3744 | 9728 | { |
9729 | BGP_IPV4M_NODE, | |
9730 | "%s(config-router-af)# ", | |
9731 | 1, | |
9732 | }; | |
9733 | ||
7fc626de | 9734 | static struct cmd_node bgp_ipv6_unicast_node = |
718e3744 | 9735 | { |
9736 | BGP_IPV6_NODE, | |
9737 | "%s(config-router-af)# ", | |
9738 | 1, | |
9739 | }; | |
9740 | ||
7fc626de | 9741 | static struct cmd_node bgp_ipv6_multicast_node = |
25ffbdc1 | 9742 | { |
9743 | BGP_IPV6M_NODE, | |
9744 | "%s(config-router-af)# ", | |
9745 | 1, | |
9746 | }; | |
9747 | ||
7fc626de | 9748 | static struct cmd_node bgp_vpnv4_node = |
718e3744 | 9749 | { |
9750 | BGP_VPNV4_NODE, | |
9751 | "%s(config-router-af)# ", | |
9752 | 1 | |
9753 | }; | |
6b0655a2 | 9754 | |
8ecd3266 | 9755 | static struct cmd_node bgp_vpnv6_node = |
9756 | { | |
9757 | BGP_VPNV6_NODE, | |
9758 | "%s(config-router-af-vpnv6)# ", | |
9759 | 1 | |
9760 | }; | |
9761 | ||
8b1fb8be LB |
9762 | static struct cmd_node bgp_encap_node = |
9763 | { | |
9764 | BGP_ENCAP_NODE, | |
9765 | "%s(config-router-af-encap)# ", | |
9766 | 1 | |
9767 | }; | |
9768 | ||
9769 | static struct cmd_node bgp_encapv6_node = | |
9770 | { | |
9771 | BGP_ENCAPV6_NODE, | |
9772 | "%s(config-router-af-encapv6)# ", | |
9773 | 1 | |
9774 | }; | |
9775 | ||
1f8ae70b | 9776 | static void community_list_vty (void); |
9777 | ||
718e3744 | 9778 | void |
94f2b392 | 9779 | bgp_vty_init (void) |
718e3744 | 9780 | { |
718e3744 | 9781 | /* Install bgp top node. */ |
9782 | install_node (&bgp_node, bgp_config_write); | |
9783 | install_node (&bgp_ipv4_unicast_node, NULL); | |
9784 | install_node (&bgp_ipv4_multicast_node, NULL); | |
9785 | install_node (&bgp_ipv6_unicast_node, NULL); | |
25ffbdc1 | 9786 | install_node (&bgp_ipv6_multicast_node, NULL); |
718e3744 | 9787 | install_node (&bgp_vpnv4_node, NULL); |
8ecd3266 | 9788 | install_node (&bgp_vpnv6_node, NULL); |
8b1fb8be LB |
9789 | install_node (&bgp_encap_node, NULL); |
9790 | install_node (&bgp_encapv6_node, NULL); | |
718e3744 | 9791 | |
9792 | /* Install default VTY commands to new nodes. */ | |
9793 | install_default (BGP_NODE); | |
9794 | install_default (BGP_IPV4_NODE); | |
9795 | install_default (BGP_IPV4M_NODE); | |
9796 | install_default (BGP_IPV6_NODE); | |
25ffbdc1 | 9797 | install_default (BGP_IPV6M_NODE); |
718e3744 | 9798 | install_default (BGP_VPNV4_NODE); |
8ecd3266 | 9799 | install_default (BGP_VPNV6_NODE); |
8b1fb8be LB |
9800 | install_default (BGP_ENCAP_NODE); |
9801 | install_default (BGP_ENCAPV6_NODE); | |
e52702f2 | 9802 | |
718e3744 | 9803 | /* "bgp multiple-instance" commands. */ |
9804 | install_element (CONFIG_NODE, &bgp_multiple_instance_cmd); | |
9805 | install_element (CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
9806 | ||
9807 | /* "bgp config-type" commands. */ | |
9808 | install_element (CONFIG_NODE, &bgp_config_type_cmd); | |
8c3deaae | 9809 | install_element (CONFIG_NODE, &no_bgp_config_type_cmd); |
718e3744 | 9810 | |
5fe9f963 | 9811 | /* bgp route-map delay-timer commands. */ |
9812 | install_element (CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
9813 | install_element (CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
5fe9f963 | 9814 | |
718e3744 | 9815 | /* Dummy commands (Currently not supported) */ |
9816 | install_element (BGP_NODE, &no_synchronization_cmd); | |
9817 | install_element (BGP_NODE, &no_auto_summary_cmd); | |
9818 | ||
9819 | /* "router bgp" commands. */ | |
9820 | install_element (CONFIG_NODE, &router_bgp_cmd); | |
718e3744 | 9821 | |
9822 | /* "no router bgp" commands. */ | |
9823 | install_element (CONFIG_NODE, &no_router_bgp_cmd); | |
718e3744 | 9824 | |
9825 | /* "bgp router-id" commands. */ | |
9826 | install_element (BGP_NODE, &bgp_router_id_cmd); | |
9827 | install_element (BGP_NODE, &no_bgp_router_id_cmd); | |
718e3744 | 9828 | |
9829 | /* "bgp cluster-id" commands. */ | |
9830 | install_element (BGP_NODE, &bgp_cluster_id_cmd); | |
718e3744 | 9831 | install_element (BGP_NODE, &no_bgp_cluster_id_cmd); |
718e3744 | 9832 | |
9833 | /* "bgp confederation" commands. */ | |
9834 | install_element (BGP_NODE, &bgp_confederation_identifier_cmd); | |
9835 | install_element (BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
718e3744 | 9836 | |
9837 | /* "bgp confederation peers" commands. */ | |
9838 | install_element (BGP_NODE, &bgp_confederation_peers_cmd); | |
9839 | install_element (BGP_NODE, &no_bgp_confederation_peers_cmd); | |
9840 | ||
abc920f8 DS |
9841 | /* bgp max-med command */ |
9842 | install_element (BGP_NODE, &bgp_maxmed_admin_cmd); | |
9843 | install_element (BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
9844 | install_element (BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
abc920f8 DS |
9845 | install_element (BGP_NODE, &bgp_maxmed_onstartup_cmd); |
9846 | install_element (BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
abc920f8 | 9847 | install_element (BGP_NODE, &bgp_maxmed_onstartup_medv_cmd); |
abc920f8 | 9848 | |
907f92c8 DS |
9849 | /* bgp disable-ebgp-connected-nh-check */ |
9850 | install_element (BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
9851 | install_element (BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
9852 | ||
f188f2c4 DS |
9853 | /* bgp update-delay command */ |
9854 | install_element (BGP_NODE, &bgp_update_delay_cmd); | |
9855 | install_element (BGP_NODE, &no_bgp_update_delay_cmd); | |
9856 | install_element (BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
f188f2c4 | 9857 | |
cb1faec9 DS |
9858 | install_element (BGP_NODE, &bgp_wpkt_quanta_cmd); |
9859 | install_element (BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
9860 | ||
3f9c7369 DS |
9861 | install_element (BGP_NODE, &bgp_coalesce_time_cmd); |
9862 | install_element (BGP_NODE, &no_bgp_coalesce_time_cmd); | |
9863 | ||
165b5fff JB |
9864 | /* "maximum-paths" commands. */ |
9865 | install_element (BGP_NODE, &bgp_maxpaths_cmd); | |
9866 | install_element (BGP_NODE, &no_bgp_maxpaths_cmd); | |
165b5fff JB |
9867 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_cmd); |
9868 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
431aa9f9 DS |
9869 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_cmd); |
9870 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
165b5fff | 9871 | install_element (BGP_NODE, &bgp_maxpaths_ibgp_cmd); |
5e242b0d | 9872 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
165b5fff | 9873 | install_element (BGP_NODE, &no_bgp_maxpaths_ibgp_cmd); |
165b5fff | 9874 | install_element (BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); |
5e242b0d | 9875 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
165b5fff | 9876 | install_element (BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); |
431aa9f9 | 9877 | install_element (BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); |
5e242b0d | 9878 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); |
431aa9f9 | 9879 | install_element (BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); |
165b5fff | 9880 | |
718e3744 | 9881 | /* "timers bgp" commands. */ |
9882 | install_element (BGP_NODE, &bgp_timers_cmd); | |
9883 | install_element (BGP_NODE, &no_bgp_timers_cmd); | |
718e3744 | 9884 | |
5fe9f963 | 9885 | /* route-map delay-timer commands - per instance for backwards compat. */ |
518f0eb1 DS |
9886 | install_element (BGP_NODE, &bgp_set_route_map_delay_timer_cmd); |
9887 | install_element (BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
9888 | ||
718e3744 | 9889 | /* "bgp client-to-client reflection" commands */ |
9890 | install_element (BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
9891 | install_element (BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
9892 | ||
9893 | /* "bgp always-compare-med" commands */ | |
9894 | install_element (BGP_NODE, &bgp_always_compare_med_cmd); | |
9895 | install_element (BGP_NODE, &no_bgp_always_compare_med_cmd); | |
e52702f2 | 9896 | |
718e3744 | 9897 | /* "bgp deterministic-med" commands */ |
9898 | install_element (BGP_NODE, &bgp_deterministic_med_cmd); | |
9899 | install_element (BGP_NODE, &no_bgp_deterministic_med_cmd); | |
538621f2 | 9900 | |
538621f2 | 9901 | /* "bgp graceful-restart" commands */ |
9902 | install_element (BGP_NODE, &bgp_graceful_restart_cmd); | |
9903 | install_element (BGP_NODE, &no_bgp_graceful_restart_cmd); | |
93406d87 | 9904 | install_element (BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); |
9905 | install_element (BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
eb6f1b41 PG |
9906 | install_element (BGP_NODE, &bgp_graceful_restart_restart_time_cmd); |
9907 | install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
e52702f2 | 9908 | |
43fc21b3 JC |
9909 | install_element (BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); |
9910 | install_element (BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
9911 | ||
718e3744 | 9912 | /* "bgp fast-external-failover" commands */ |
9913 | install_element (BGP_NODE, &bgp_fast_external_failover_cmd); | |
9914 | install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
9915 | ||
9916 | /* "bgp enforce-first-as" commands */ | |
9917 | install_element (BGP_NODE, &bgp_enforce_first_as_cmd); | |
9918 | install_element (BGP_NODE, &no_bgp_enforce_first_as_cmd); | |
9919 | ||
9920 | /* "bgp bestpath compare-routerid" commands */ | |
9921 | install_element (BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
9922 | install_element (BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
9923 | ||
9924 | /* "bgp bestpath as-path ignore" commands */ | |
9925 | install_element (BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
9926 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
9927 | ||
6811845b | 9928 | /* "bgp bestpath as-path confed" commands */ |
9929 | install_element (BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
9930 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
9931 | ||
2fdd455c PM |
9932 | /* "bgp bestpath as-path multipath-relax" commands */ |
9933 | install_element (BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
9934 | install_element (BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
9935 | ||
848973c7 | 9936 | /* "bgp log-neighbor-changes" commands */ |
9937 | install_element (BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
9938 | install_element (BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
9939 | ||
718e3744 | 9940 | /* "bgp bestpath med" commands */ |
9941 | install_element (BGP_NODE, &bgp_bestpath_med_cmd); | |
718e3744 | 9942 | install_element (BGP_NODE, &no_bgp_bestpath_med_cmd); |
718e3744 | 9943 | |
9944 | /* "no bgp default ipv4-unicast" commands. */ | |
9945 | install_element (BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
9946 | install_element (BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
e52702f2 | 9947 | |
718e3744 | 9948 | /* "bgp network import-check" commands. */ |
9949 | install_element (BGP_NODE, &bgp_network_import_check_cmd); | |
8233ef81 | 9950 | install_element (BGP_NODE, &bgp_network_import_check_exact_cmd); |
718e3744 | 9951 | install_element (BGP_NODE, &no_bgp_network_import_check_cmd); |
9952 | ||
9953 | /* "bgp default local-preference" commands. */ | |
9954 | install_element (BGP_NODE, &bgp_default_local_preference_cmd); | |
9955 | install_element (BGP_NODE, &no_bgp_default_local_preference_cmd); | |
718e3744 | 9956 | |
04b6bdc0 DW |
9957 | /* bgp default show-hostname */ |
9958 | install_element (BGP_NODE, &bgp_default_show_hostname_cmd); | |
9959 | install_element (BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
9960 | ||
3f9c7369 DS |
9961 | /* "bgp default subgroup-pkt-queue-max" commands. */ |
9962 | install_element (BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
9963 | install_element (BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
9964 | ||
8bd9d948 DS |
9965 | /* bgp ibgp-allow-policy-mods command */ |
9966 | install_element (BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
9967 | install_element (BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
9968 | ||
f14e6fdb DS |
9969 | /* "bgp listen limit" commands. */ |
9970 | install_element (BGP_NODE, &bgp_listen_limit_cmd); | |
9971 | install_element (BGP_NODE, &no_bgp_listen_limit_cmd); | |
9972 | ||
9973 | /* "bgp listen range" commands. */ | |
9974 | install_element (BGP_NODE, &bgp_listen_range_cmd); | |
9975 | install_element (BGP_NODE, &no_bgp_listen_range_cmd); | |
9976 | ||
718e3744 | 9977 | /* "neighbor remote-as" commands. */ |
9978 | install_element (BGP_NODE, &neighbor_remote_as_cmd); | |
a80beece | 9979 | install_element (BGP_NODE, &neighbor_interface_config_cmd); |
4c48cf63 | 9980 | install_element (BGP_NODE, &neighbor_interface_config_v6only_cmd); |
b3a39dc5 DD |
9981 | install_element (BGP_NODE, &neighbor_interface_config_remote_as_cmd); |
9982 | install_element (BGP_NODE, &neighbor_interface_v6only_config_remote_as_cmd); | |
718e3744 | 9983 | install_element (BGP_NODE, &no_neighbor_cmd); |
a80beece | 9984 | install_element (BGP_NODE, &no_neighbor_interface_config_cmd); |
718e3744 | 9985 | |
9986 | /* "neighbor peer-group" commands. */ | |
9987 | install_element (BGP_NODE, &neighbor_peer_group_cmd); | |
9988 | install_element (BGP_NODE, &no_neighbor_peer_group_cmd); | |
a80beece | 9989 | install_element (BGP_NODE, &no_neighbor_interface_peer_group_remote_as_cmd); |
718e3744 | 9990 | |
9991 | /* "neighbor local-as" commands. */ | |
9992 | install_element (BGP_NODE, &neighbor_local_as_cmd); | |
9993 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
9d3f9705 | 9994 | install_element (BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); |
718e3744 | 9995 | install_element (BGP_NODE, &no_neighbor_local_as_cmd); |
718e3744 | 9996 | |
3f9c7369 DS |
9997 | /* "neighbor solo" commands. */ |
9998 | install_element (BGP_NODE, &neighbor_solo_cmd); | |
9999 | install_element (BGP_NODE, &no_neighbor_solo_cmd); | |
10000 | ||
0df7c91f PJ |
10001 | /* "neighbor password" commands. */ |
10002 | install_element (BGP_NODE, &neighbor_password_cmd); | |
10003 | install_element (BGP_NODE, &no_neighbor_password_cmd); | |
10004 | ||
718e3744 | 10005 | /* "neighbor activate" commands. */ |
10006 | install_element (BGP_NODE, &neighbor_activate_cmd); | |
10007 | install_element (BGP_IPV4_NODE, &neighbor_activate_cmd); | |
10008 | install_element (BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
10009 | install_element (BGP_IPV6_NODE, &neighbor_activate_cmd); | |
25ffbdc1 | 10010 | install_element (BGP_IPV6M_NODE, &neighbor_activate_cmd); |
718e3744 | 10011 | install_element (BGP_VPNV4_NODE, &neighbor_activate_cmd); |
8ecd3266 | 10012 | install_element (BGP_VPNV6_NODE, &neighbor_activate_cmd); |
8b1fb8be LB |
10013 | install_element (BGP_ENCAP_NODE, &neighbor_activate_cmd); |
10014 | install_element (BGP_ENCAPV6_NODE, &neighbor_activate_cmd); | |
718e3744 | 10015 | |
10016 | /* "no neighbor activate" commands. */ | |
10017 | install_element (BGP_NODE, &no_neighbor_activate_cmd); | |
10018 | install_element (BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
10019 | install_element (BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
10020 | install_element (BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
25ffbdc1 | 10021 | install_element (BGP_IPV6M_NODE, &no_neighbor_activate_cmd); |
718e3744 | 10022 | install_element (BGP_VPNV4_NODE, &no_neighbor_activate_cmd); |
8ecd3266 | 10023 | install_element (BGP_VPNV6_NODE, &no_neighbor_activate_cmd); |
8b1fb8be LB |
10024 | install_element (BGP_ENCAP_NODE, &no_neighbor_activate_cmd); |
10025 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_activate_cmd); | |
718e3744 | 10026 | |
c8560b44 DW |
10027 | /* "neighbor peer-group" set commands. |
10028 | * Long term we should only accept this command under BGP_NODE and not all of | |
10029 | * the afi/safi sub-contexts. For now though we need to accept it for backwards | |
10030 | * compatibility. This changed when we stopped requiring that peers be assigned | |
10031 | * to their peer-group under each address-family sub-context. | |
10032 | */ | |
718e3744 | 10033 | install_element (BGP_NODE, &neighbor_set_peer_group_cmd); |
10034 | install_element (BGP_IPV4_NODE, &neighbor_set_peer_group_cmd); | |
10035 | install_element (BGP_IPV4M_NODE, &neighbor_set_peer_group_cmd); | |
10036 | install_element (BGP_IPV6_NODE, &neighbor_set_peer_group_cmd); | |
25ffbdc1 | 10037 | install_element (BGP_IPV6M_NODE, &neighbor_set_peer_group_cmd); |
a58545bb | 10038 | install_element (BGP_VPNV4_NODE, &neighbor_set_peer_group_cmd); |
8ecd3266 | 10039 | install_element (BGP_VPNV6_NODE, &neighbor_set_peer_group_cmd); |
8b1fb8be LB |
10040 | install_element (BGP_ENCAP_NODE, &neighbor_set_peer_group_cmd); |
10041 | install_element (BGP_ENCAPV6_NODE, &neighbor_set_peer_group_cmd); | |
c8560b44 | 10042 | |
718e3744 | 10043 | /* "no neighbor peer-group unset" commands. */ |
10044 | install_element (BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
10045 | install_element (BGP_IPV4_NODE, &no_neighbor_set_peer_group_cmd); | |
10046 | install_element (BGP_IPV4M_NODE, &no_neighbor_set_peer_group_cmd); | |
10047 | install_element (BGP_IPV6_NODE, &no_neighbor_set_peer_group_cmd); | |
25ffbdc1 | 10048 | install_element (BGP_IPV6M_NODE, &no_neighbor_set_peer_group_cmd); |
a58545bb | 10049 | install_element (BGP_VPNV4_NODE, &no_neighbor_set_peer_group_cmd); |
8ecd3266 | 10050 | install_element (BGP_VPNV6_NODE, &no_neighbor_set_peer_group_cmd); |
8b1fb8be LB |
10051 | install_element (BGP_ENCAP_NODE, &no_neighbor_set_peer_group_cmd); |
10052 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_set_peer_group_cmd); | |
e52702f2 | 10053 | |
718e3744 | 10054 | /* "neighbor softreconfiguration inbound" commands.*/ |
10055 | install_element (BGP_NODE, &neighbor_soft_reconfiguration_cmd); | |
10056 | install_element (BGP_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10057 | install_element (BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
10058 | install_element (BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10059 | install_element (BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
10060 | install_element (BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10061 | install_element (BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
10062 | install_element (BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
25ffbdc1 | 10063 | install_element (BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); |
10064 | install_element (BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
a58545bb | 10065 | install_element (BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); |
10066 | install_element (BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
8ecd3266 | 10067 | install_element (BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); |
10068 | install_element (BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
8b1fb8be LB |
10069 | install_element (BGP_ENCAP_NODE, &neighbor_soft_reconfiguration_cmd); |
10070 | install_element (BGP_ENCAP_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
10071 | install_element (BGP_ENCAPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
10072 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
718e3744 | 10073 | |
10074 | /* "neighbor attribute-unchanged" commands. */ | |
10075 | install_element (BGP_NODE, &neighbor_attr_unchanged_cmd); | |
718e3744 | 10076 | install_element (BGP_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10077 | install_element (BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10078 | install_element (BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10079 | install_element (BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10080 | install_element (BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10081 | install_element (BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10082 | install_element (BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); |
25ffbdc1 | 10083 | install_element (BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); |
25ffbdc1 | 10084 | install_element (BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10085 | install_element (BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); |
718e3744 | 10086 | install_element (BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 10087 | install_element (BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); |
8ecd3266 | 10088 | install_element (BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); |
8ecd3266 | 10089 | |
8b1fb8be | 10090 | install_element (BGP_ENCAP_NODE, &neighbor_attr_unchanged_cmd); |
8b1fb8be | 10091 | install_element (BGP_ENCAP_NODE, &no_neighbor_attr_unchanged_cmd); |
8b1fb8be LB |
10092 | |
10093 | install_element (BGP_ENCAPV6_NODE, &neighbor_attr_unchanged_cmd); | |
8b1fb8be | 10094 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_attr_unchanged_cmd); |
718e3744 | 10095 | |
fee0f4c6 | 10096 | /* "nexthop-local unchanged" commands */ |
10097 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
10098 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_local_unchanged_cmd); | |
10099 | ||
718e3744 | 10100 | /* "neighbor next-hop-self" commands. */ |
10101 | install_element (BGP_NODE, &neighbor_nexthop_self_cmd); | |
10102 | install_element (BGP_NODE, &no_neighbor_nexthop_self_cmd); | |
10103 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
10104 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
10105 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
10106 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
10107 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
10108 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
25ffbdc1 | 10109 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); |
10110 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 10111 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); |
10112 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
8ecd3266 | 10113 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); |
10114 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
8b1fb8be LB |
10115 | install_element (BGP_ENCAP_NODE, &neighbor_nexthop_self_cmd); |
10116 | install_element (BGP_ENCAP_NODE, &no_neighbor_nexthop_self_cmd); | |
10117 | install_element (BGP_ENCAPV6_NODE, &neighbor_nexthop_self_cmd); | |
10118 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
718e3744 | 10119 | |
a538debe DS |
10120 | /* "neighbor next-hop-self force" commands. */ |
10121 | install_element (BGP_NODE, &neighbor_nexthop_self_force_cmd); | |
10122 | install_element (BGP_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10123 | install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
10124 | install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10125 | install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
10126 | install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10127 | install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
10128 | install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10129 | install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
10130 | install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
10131 | install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
10132 | install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
8ecd3266 | 10133 | install_element (BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); |
10134 | install_element (BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
a538debe | 10135 | |
c7122e14 DS |
10136 | /* "neighbor as-override" commands. */ |
10137 | install_element (BGP_NODE, &neighbor_as_override_cmd); | |
10138 | install_element (BGP_NODE, &no_neighbor_as_override_cmd); | |
10139 | install_element (BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
10140 | install_element (BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
10141 | install_element (BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
10142 | install_element (BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
10143 | install_element (BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
10144 | install_element (BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
10145 | install_element (BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
10146 | install_element (BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
10147 | install_element (BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
10148 | install_element (BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
8ecd3266 | 10149 | install_element (BGP_VPNV6_NODE, &neighbor_as_override_cmd); |
10150 | install_element (BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
c7122e14 | 10151 | |
718e3744 | 10152 | /* "neighbor remove-private-AS" commands. */ |
10153 | install_element (BGP_NODE, &neighbor_remove_private_as_cmd); | |
10154 | install_element (BGP_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10155 | install_element (BGP_NODE, &neighbor_remove_private_as_all_cmd); |
10156 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10157 | install_element (BGP_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10158 | install_element (BGP_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10159 | install_element (BGP_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10160 | install_element (BGP_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10161 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); |
10162 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10163 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); |
10164 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10165 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10166 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10167 | install_element (BGP_IPV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10168 | install_element (BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10169 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); |
10170 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10171 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); |
10172 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10173 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10174 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10175 | install_element (BGP_IPV4M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10176 | install_element (BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10177 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); |
10178 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10179 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); |
10180 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10181 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10182 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10183 | install_element (BGP_IPV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10184 | install_element (BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
25ffbdc1 | 10185 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); |
10186 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10187 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); |
10188 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10189 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10190 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10191 | install_element (BGP_IPV6M_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10192 | install_element (BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
718e3744 | 10193 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); |
10194 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
5000f21c DS |
10195 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); |
10196 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10197 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10198 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10199 | install_element (BGP_VPNV4_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10200 | install_element (BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
8ecd3266 | 10201 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); |
10202 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
10203 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
10204 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
10205 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_replace_as_cmd); | |
10206 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_replace_as_cmd); | |
10207 | install_element (BGP_VPNV6_NODE, &neighbor_remove_private_as_all_replace_as_cmd); | |
10208 | install_element (BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_replace_as_cmd); | |
8b1fb8be LB |
10209 | install_element (BGP_ENCAP_NODE, &neighbor_remove_private_as_cmd); |
10210 | install_element (BGP_ENCAP_NODE, &no_neighbor_remove_private_as_cmd); | |
10211 | install_element (BGP_ENCAPV6_NODE, &neighbor_remove_private_as_cmd); | |
10212 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
718e3744 | 10213 | |
10214 | /* "neighbor send-community" commands.*/ | |
10215 | install_element (BGP_NODE, &neighbor_send_community_cmd); | |
10216 | install_element (BGP_NODE, &neighbor_send_community_type_cmd); | |
10217 | install_element (BGP_NODE, &no_neighbor_send_community_cmd); | |
10218 | install_element (BGP_NODE, &no_neighbor_send_community_type_cmd); | |
10219 | install_element (BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
10220 | install_element (BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
10221 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
10222 | install_element (BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
10223 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
10224 | install_element (BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
10225 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
10226 | install_element (BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
10227 | install_element (BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
10228 | install_element (BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
10229 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
10230 | install_element (BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
25ffbdc1 | 10231 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_cmd); |
10232 | install_element (BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
10233 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
10234 | install_element (BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 10235 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_cmd); |
10236 | install_element (BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
10237 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
10238 | install_element (BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
8ecd3266 | 10239 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_cmd); |
10240 | install_element (BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
10241 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
10242 | install_element (BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
8b1fb8be LB |
10243 | install_element (BGP_ENCAP_NODE, &neighbor_send_community_cmd); |
10244 | install_element (BGP_ENCAP_NODE, &neighbor_send_community_type_cmd); | |
10245 | install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_cmd); | |
10246 | install_element (BGP_ENCAP_NODE, &no_neighbor_send_community_type_cmd); | |
10247 | install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_cmd); | |
10248 | install_element (BGP_ENCAPV6_NODE, &neighbor_send_community_type_cmd); | |
10249 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_cmd); | |
10250 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_send_community_type_cmd); | |
718e3744 | 10251 | |
10252 | /* "neighbor route-reflector" commands.*/ | |
10253 | install_element (BGP_NODE, &neighbor_route_reflector_client_cmd); | |
10254 | install_element (BGP_NODE, &no_neighbor_route_reflector_client_cmd); | |
10255 | install_element (BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
10256 | install_element (BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
10257 | install_element (BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
10258 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_reflector_client_cmd); | |
10259 | install_element (BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
10260 | install_element (BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
25ffbdc1 | 10261 | install_element (BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); |
10262 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 10263 | install_element (BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); |
10264 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
8ecd3266 | 10265 | install_element (BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); |
10266 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
8b1fb8be LB |
10267 | install_element (BGP_ENCAP_NODE, &neighbor_route_reflector_client_cmd); |
10268 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_reflector_client_cmd); | |
10269 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_reflector_client_cmd); | |
10270 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
718e3744 | 10271 | |
10272 | /* "neighbor route-server" commands.*/ | |
10273 | install_element (BGP_NODE, &neighbor_route_server_client_cmd); | |
10274 | install_element (BGP_NODE, &no_neighbor_route_server_client_cmd); | |
10275 | install_element (BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
10276 | install_element (BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
10277 | install_element (BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
10278 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
10279 | install_element (BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
10280 | install_element (BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
25ffbdc1 | 10281 | install_element (BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); |
10282 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 10283 | install_element (BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); |
10284 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
8ecd3266 | 10285 | install_element (BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); |
10286 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
8b1fb8be LB |
10287 | install_element (BGP_ENCAP_NODE, &neighbor_route_server_client_cmd); |
10288 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_server_client_cmd); | |
10289 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_server_client_cmd); | |
10290 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_server_client_cmd); | |
718e3744 | 10291 | |
adbac85e DW |
10292 | /* "neighbor addpath-tx-all-paths" commands.*/ |
10293 | install_element (BGP_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10294 | install_element (BGP_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10295 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10296 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10297 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10298 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10299 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10300 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10301 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10302 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
10303 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
10304 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
8ecd3266 | 10305 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); |
10306 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
adbac85e | 10307 | |
06370dac DW |
10308 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ |
10309 | install_element (BGP_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10310 | install_element (BGP_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10311 | install_element (BGP_IPV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10312 | install_element (BGP_IPV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10313 | install_element (BGP_IPV4M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10314 | install_element (BGP_IPV4M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10315 | install_element (BGP_IPV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10316 | install_element (BGP_IPV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10317 | install_element (BGP_IPV6M_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10318 | install_element (BGP_IPV6M_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
10319 | install_element (BGP_VPNV4_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); | |
10320 | install_element (BGP_VPNV4_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
8ecd3266 | 10321 | install_element (BGP_VPNV6_NODE, &neighbor_addpath_tx_bestpath_per_as_cmd); |
10322 | install_element (BGP_VPNV6_NODE, &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
06370dac | 10323 | |
718e3744 | 10324 | /* "neighbor passive" commands. */ |
10325 | install_element (BGP_NODE, &neighbor_passive_cmd); | |
10326 | install_element (BGP_NODE, &no_neighbor_passive_cmd); | |
10327 | ||
d5a5c8f0 | 10328 | |
718e3744 | 10329 | /* "neighbor shutdown" commands. */ |
10330 | install_element (BGP_NODE, &neighbor_shutdown_cmd); | |
10331 | install_element (BGP_NODE, &no_neighbor_shutdown_cmd); | |
10332 | ||
8a92a8a0 DS |
10333 | /* "neighbor capability extended-nexthop" commands.*/ |
10334 | install_element (BGP_NODE, &neighbor_capability_enhe_cmd); | |
10335 | install_element (BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
10336 | ||
718e3744 | 10337 | /* "neighbor capability orf prefix-list" commands.*/ |
10338 | install_element (BGP_NODE, &neighbor_capability_orf_prefix_cmd); | |
10339 | install_element (BGP_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10340 | install_element (BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
10341 | install_element (BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10342 | install_element (BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
10343 | install_element (BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
10344 | install_element (BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
10345 | install_element (BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
25ffbdc1 | 10346 | install_element (BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); |
10347 | install_element (BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
718e3744 | 10348 | |
10349 | /* "neighbor capability dynamic" commands.*/ | |
10350 | install_element (BGP_NODE, &neighbor_capability_dynamic_cmd); | |
10351 | install_element (BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
10352 | ||
10353 | /* "neighbor dont-capability-negotiate" commands. */ | |
10354 | install_element (BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
10355 | install_element (BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
10356 | ||
10357 | /* "neighbor ebgp-multihop" commands. */ | |
10358 | install_element (BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
10359 | install_element (BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
10360 | install_element (BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
718e3744 | 10361 | |
6ffd2079 | 10362 | /* "neighbor disable-connected-check" commands. */ |
10363 | install_element (BGP_NODE, &neighbor_disable_connected_check_cmd); | |
10364 | install_element (BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
718e3744 | 10365 | |
10366 | /* "neighbor description" commands. */ | |
10367 | install_element (BGP_NODE, &neighbor_description_cmd); | |
10368 | install_element (BGP_NODE, &no_neighbor_description_cmd); | |
718e3744 | 10369 | |
10370 | /* "neighbor update-source" commands. "*/ | |
10371 | install_element (BGP_NODE, &neighbor_update_source_cmd); | |
10372 | install_element (BGP_NODE, &no_neighbor_update_source_cmd); | |
10373 | ||
10374 | /* "neighbor default-originate" commands. */ | |
10375 | install_element (BGP_NODE, &neighbor_default_originate_cmd); | |
10376 | install_element (BGP_NODE, &neighbor_default_originate_rmap_cmd); | |
10377 | install_element (BGP_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10378 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_cmd); |
10379 | install_element (BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
10380 | install_element (BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10381 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_cmd); |
10382 | install_element (BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
10383 | install_element (BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10384 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_cmd); |
10385 | install_element (BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
10386 | install_element (BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
25ffbdc1 | 10387 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_cmd); |
10388 | install_element (BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
10389 | install_element (BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
718e3744 | 10390 | |
10391 | /* "neighbor port" commands. */ | |
10392 | install_element (BGP_NODE, &neighbor_port_cmd); | |
10393 | install_element (BGP_NODE, &no_neighbor_port_cmd); | |
718e3744 | 10394 | |
10395 | /* "neighbor weight" commands. */ | |
10396 | install_element (BGP_NODE, &neighbor_weight_cmd); | |
10397 | install_element (BGP_NODE, &no_neighbor_weight_cmd); | |
718e3744 | 10398 | |
d93f7ffc DW |
10399 | install_element (BGP_IPV4_NODE, &neighbor_weight_cmd); |
10400 | install_element (BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10401 | install_element (BGP_IPV4M_NODE, &neighbor_weight_cmd); |
10402 | install_element (BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10403 | install_element (BGP_IPV6_NODE, &neighbor_weight_cmd); |
10404 | install_element (BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10405 | install_element (BGP_IPV6M_NODE, &neighbor_weight_cmd); |
10406 | install_element (BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10407 | install_element (BGP_VPNV4_NODE, &neighbor_weight_cmd); |
10408 | install_element (BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10409 | install_element (BGP_VPNV6_NODE, &neighbor_weight_cmd); |
10410 | install_element (BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10411 | install_element (BGP_ENCAP_NODE, &neighbor_weight_cmd); |
10412 | install_element (BGP_ENCAP_NODE, &no_neighbor_weight_cmd); | |
d93f7ffc DW |
10413 | install_element (BGP_ENCAPV6_NODE, &neighbor_weight_cmd); |
10414 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_weight_cmd); | |
718e3744 | 10415 | |
10416 | /* "neighbor override-capability" commands. */ | |
10417 | install_element (BGP_NODE, &neighbor_override_capability_cmd); | |
10418 | install_element (BGP_NODE, &no_neighbor_override_capability_cmd); | |
10419 | ||
10420 | /* "neighbor strict-capability-match" commands. */ | |
10421 | install_element (BGP_NODE, &neighbor_strict_capability_cmd); | |
10422 | install_element (BGP_NODE, &no_neighbor_strict_capability_cmd); | |
10423 | ||
10424 | /* "neighbor timers" commands. */ | |
10425 | install_element (BGP_NODE, &neighbor_timers_cmd); | |
10426 | install_element (BGP_NODE, &no_neighbor_timers_cmd); | |
10427 | ||
10428 | /* "neighbor timers connect" commands. */ | |
10429 | install_element (BGP_NODE, &neighbor_timers_connect_cmd); | |
10430 | install_element (BGP_NODE, &no_neighbor_timers_connect_cmd); | |
718e3744 | 10431 | |
10432 | /* "neighbor advertisement-interval" commands. */ | |
10433 | install_element (BGP_NODE, &neighbor_advertise_interval_cmd); | |
10434 | install_element (BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
718e3744 | 10435 | |
718e3744 | 10436 | /* "neighbor interface" commands. */ |
10437 | install_element (BGP_NODE, &neighbor_interface_cmd); | |
10438 | install_element (BGP_NODE, &no_neighbor_interface_cmd); | |
10439 | ||
10440 | /* "neighbor distribute" commands. */ | |
10441 | install_element (BGP_NODE, &neighbor_distribute_list_cmd); | |
10442 | install_element (BGP_NODE, &no_neighbor_distribute_list_cmd); | |
10443 | install_element (BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
10444 | install_element (BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
10445 | install_element (BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
10446 | install_element (BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
10447 | install_element (BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
10448 | install_element (BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
25ffbdc1 | 10449 | install_element (BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); |
10450 | install_element (BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 10451 | install_element (BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); |
10452 | install_element (BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
8ecd3266 | 10453 | install_element (BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); |
10454 | install_element (BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
8b1fb8be LB |
10455 | install_element (BGP_ENCAP_NODE, &neighbor_distribute_list_cmd); |
10456 | install_element (BGP_ENCAP_NODE, &no_neighbor_distribute_list_cmd); | |
10457 | install_element (BGP_ENCAPV6_NODE, &neighbor_distribute_list_cmd); | |
10458 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_distribute_list_cmd); | |
718e3744 | 10459 | |
10460 | /* "neighbor prefix-list" commands. */ | |
10461 | install_element (BGP_NODE, &neighbor_prefix_list_cmd); | |
10462 | install_element (BGP_NODE, &no_neighbor_prefix_list_cmd); | |
10463 | install_element (BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
10464 | install_element (BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
10465 | install_element (BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
10466 | install_element (BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
10467 | install_element (BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
10468 | install_element (BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
25ffbdc1 | 10469 | install_element (BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); |
10470 | install_element (BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 10471 | install_element (BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); |
10472 | install_element (BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
8ecd3266 | 10473 | install_element (BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); |
10474 | install_element (BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
8b1fb8be LB |
10475 | install_element (BGP_ENCAP_NODE, &neighbor_prefix_list_cmd); |
10476 | install_element (BGP_ENCAP_NODE, &no_neighbor_prefix_list_cmd); | |
10477 | install_element (BGP_ENCAPV6_NODE, &neighbor_prefix_list_cmd); | |
10478 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_prefix_list_cmd); | |
718e3744 | 10479 | |
10480 | /* "neighbor filter-list" commands. */ | |
10481 | install_element (BGP_NODE, &neighbor_filter_list_cmd); | |
10482 | install_element (BGP_NODE, &no_neighbor_filter_list_cmd); | |
10483 | install_element (BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
10484 | install_element (BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
10485 | install_element (BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
10486 | install_element (BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
10487 | install_element (BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
10488 | install_element (BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
25ffbdc1 | 10489 | install_element (BGP_IPV6M_NODE, &neighbor_filter_list_cmd); |
10490 | install_element (BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 10491 | install_element (BGP_VPNV4_NODE, &neighbor_filter_list_cmd); |
10492 | install_element (BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
8ecd3266 | 10493 | install_element (BGP_VPNV6_NODE, &neighbor_filter_list_cmd); |
10494 | install_element (BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
8b1fb8be LB |
10495 | install_element (BGP_ENCAP_NODE, &neighbor_filter_list_cmd); |
10496 | install_element (BGP_ENCAP_NODE, &no_neighbor_filter_list_cmd); | |
10497 | install_element (BGP_ENCAPV6_NODE, &neighbor_filter_list_cmd); | |
10498 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_filter_list_cmd); | |
718e3744 | 10499 | |
10500 | /* "neighbor route-map" commands. */ | |
10501 | install_element (BGP_NODE, &neighbor_route_map_cmd); | |
10502 | install_element (BGP_NODE, &no_neighbor_route_map_cmd); | |
10503 | install_element (BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
10504 | install_element (BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
10505 | install_element (BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
10506 | install_element (BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
10507 | install_element (BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
10508 | install_element (BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
25ffbdc1 | 10509 | install_element (BGP_IPV6M_NODE, &neighbor_route_map_cmd); |
10510 | install_element (BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 10511 | install_element (BGP_VPNV4_NODE, &neighbor_route_map_cmd); |
10512 | install_element (BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
8ecd3266 | 10513 | install_element (BGP_VPNV6_NODE, &neighbor_route_map_cmd); |
10514 | install_element (BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
8b1fb8be LB |
10515 | install_element (BGP_ENCAP_NODE, &neighbor_route_map_cmd); |
10516 | install_element (BGP_ENCAP_NODE, &no_neighbor_route_map_cmd); | |
10517 | install_element (BGP_ENCAPV6_NODE, &neighbor_route_map_cmd); | |
10518 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_route_map_cmd); | |
718e3744 | 10519 | |
10520 | /* "neighbor unsuppress-map" commands. */ | |
10521 | install_element (BGP_NODE, &neighbor_unsuppress_map_cmd); | |
10522 | install_element (BGP_NODE, &no_neighbor_unsuppress_map_cmd); | |
10523 | install_element (BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
10524 | install_element (BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
10525 | install_element (BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
10526 | install_element (BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
10527 | install_element (BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
10528 | install_element (BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
25ffbdc1 | 10529 | install_element (BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); |
10530 | install_element (BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
a58545bb | 10531 | install_element (BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 10532 | install_element (BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); |
8ecd3266 | 10533 | install_element (BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); |
bb86c601 | 10534 | install_element (BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); |
8b1fb8be LB |
10535 | install_element (BGP_ENCAP_NODE, &neighbor_unsuppress_map_cmd); |
10536 | install_element (BGP_ENCAP_NODE, &no_neighbor_unsuppress_map_cmd); | |
10537 | install_element (BGP_ENCAPV6_NODE, &neighbor_unsuppress_map_cmd); | |
10538 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
718e3744 | 10539 | |
10540 | /* "neighbor maximum-prefix" commands. */ | |
10541 | install_element (BGP_NODE, &neighbor_maximum_prefix_cmd); | |
e0701b79 | 10542 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10543 | install_element (BGP_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10544 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10545 | install_element (BGP_NODE, &neighbor_maximum_prefix_restart_cmd); |
10546 | install_element (BGP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10547 | install_element (BGP_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 10548 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10549 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10550 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10551 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10552 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
10553 | install_element (BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10554 | install_element (BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 10555 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10556 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10557 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10558 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10559 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); |
10560 | install_element (BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10561 | install_element (BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); |
718e3744 | 10562 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10563 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10564 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10565 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10566 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); |
10567 | install_element (BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10568 | install_element (BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); |
25ffbdc1 | 10569 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); |
10570 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10571 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10572 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10573 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10574 | install_element (BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10575 | install_element (BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 10576 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); |
e0701b79 | 10577 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); |
718e3744 | 10578 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); |
e0701b79 | 10579 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); |
0a486e5f | 10580 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); |
10581 | install_element (BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
718e3744 | 10582 | install_element (BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); |
8ecd3266 | 10583 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); |
10584 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10585 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10586 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10587 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10588 | install_element (BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10589 | install_element (BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
718e3744 | 10590 | |
8b1fb8be LB |
10591 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_cmd); |
10592 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10593 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10594 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10595 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10596 | install_element (BGP_ENCAP_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10597 | install_element (BGP_ENCAP_NODE, &no_neighbor_maximum_prefix_cmd); | |
8b1fb8be LB |
10598 | |
10599 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_cmd); | |
10600 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
10601 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
10602 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_warning_cmd); | |
10603 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
10604 | install_element (BGP_ENCAPV6_NODE, &neighbor_maximum_prefix_threshold_restart_cmd); | |
10605 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
8b1fb8be | 10606 | |
718e3744 | 10607 | /* "neighbor allowas-in" */ |
10608 | install_element (BGP_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10609 | install_element (BGP_NODE, &no_neighbor_allowas_in_cmd); |
10610 | install_element (BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10611 | install_element (BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); |
10612 | install_element (BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10613 | install_element (BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); |
10614 | install_element (BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
718e3744 | 10615 | install_element (BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); |
25ffbdc1 | 10616 | install_element (BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); |
25ffbdc1 | 10617 | install_element (BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); |
718e3744 | 10618 | install_element (BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); |
718e3744 | 10619 | install_element (BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); |
8ecd3266 | 10620 | install_element (BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); |
8ecd3266 | 10621 | install_element (BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); |
8b1fb8be | 10622 | install_element (BGP_ENCAP_NODE, &neighbor_allowas_in_cmd); |
8b1fb8be LB |
10623 | install_element (BGP_ENCAP_NODE, &no_neighbor_allowas_in_cmd); |
10624 | install_element (BGP_ENCAPV6_NODE, &neighbor_allowas_in_cmd); | |
8b1fb8be | 10625 | install_element (BGP_ENCAPV6_NODE, &no_neighbor_allowas_in_cmd); |
718e3744 | 10626 | |
10627 | /* address-family commands. */ | |
10628 | install_element (BGP_NODE, &address_family_ipv4_cmd); | |
10629 | install_element (BGP_NODE, &address_family_ipv4_safi_cmd); | |
10630 | #ifdef HAVE_IPV6 | |
10631 | install_element (BGP_NODE, &address_family_ipv6_cmd); | |
25ffbdc1 | 10632 | install_element (BGP_NODE, &address_family_ipv6_safi_cmd); |
718e3744 | 10633 | #endif /* HAVE_IPV6 */ |
10634 | install_element (BGP_NODE, &address_family_vpnv4_cmd); | |
718e3744 | 10635 | |
8b1fb8be | 10636 | install_element (BGP_NODE, &address_family_vpnv6_cmd); |
8b1fb8be LB |
10637 | |
10638 | install_element (BGP_NODE, &address_family_encap_cmd); | |
8b1fb8be LB |
10639 | #ifdef HAVE_IPV6 |
10640 | install_element (BGP_NODE, &address_family_encapv6_cmd); | |
10641 | #endif | |
10642 | ||
718e3744 | 10643 | /* "exit-address-family" command. */ |
10644 | install_element (BGP_IPV4_NODE, &exit_address_family_cmd); | |
10645 | install_element (BGP_IPV4M_NODE, &exit_address_family_cmd); | |
10646 | install_element (BGP_IPV6_NODE, &exit_address_family_cmd); | |
25ffbdc1 | 10647 | install_element (BGP_IPV6M_NODE, &exit_address_family_cmd); |
718e3744 | 10648 | install_element (BGP_VPNV4_NODE, &exit_address_family_cmd); |
8ecd3266 | 10649 | install_element (BGP_VPNV6_NODE, &exit_address_family_cmd); |
8b1fb8be LB |
10650 | install_element (BGP_ENCAP_NODE, &exit_address_family_cmd); |
10651 | install_element (BGP_ENCAPV6_NODE, &exit_address_family_cmd); | |
718e3744 | 10652 | |
10653 | /* "clear ip bgp commands" */ | |
10654 | install_element (ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
718e3744 | 10655 | |
8ad7271d DS |
10656 | /* clear ip bgp prefix */ |
10657 | install_element (ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
10658 | install_element (ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
01080f7c | 10659 | install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); |
8ad7271d | 10660 | |
716b2d8a | 10661 | /* "show [ip] bgp summary" commands. */ |
f186de26 | 10662 | install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); |
8386ac43 | 10663 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd); |
8386ac43 | 10664 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); |
271ad8d5 | 10665 | install_element (VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
e52702f2 | 10666 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd); |
e52702f2 | 10667 | install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); |
271ad8d5 | 10668 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); |
e52702f2 | 10669 | install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); |
8c3deaae | 10670 | install_element (VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
271ad8d5 QY |
10671 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); |
10672 | install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); | |
10673 | install_element (VIEW_NODE, &show_ip_bgp_summary_cmd); | |
10674 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); | |
10675 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); | |
10676 | install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd); | |
e3e29b32 | 10677 | |
716b2d8a | 10678 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 10679 | install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd); |
718e3744 | 10680 | |
716b2d8a | 10681 | /* "show [ip] bgp peer-group" commands. */ |
f14e6fdb | 10682 | install_element (VIEW_NODE, &show_ip_bgp_peer_groups_cmd); |
f14e6fdb | 10683 | |
716b2d8a | 10684 | /* "show [ip] bgp paths" commands. */ |
718e3744 | 10685 | install_element (VIEW_NODE, &show_ip_bgp_paths_cmd); |
718e3744 | 10686 | |
716b2d8a | 10687 | /* "show [ip] bgp community" commands. */ |
718e3744 | 10688 | install_element (VIEW_NODE, &show_ip_bgp_community_info_cmd); |
718e3744 | 10689 | |
716b2d8a | 10690 | /* "show [ip] bgp attribute-info" commands. */ |
718e3744 | 10691 | install_element (VIEW_NODE, &show_ip_bgp_attr_info_cmd); |
718e3744 | 10692 | |
10693 | /* "redistribute" commands. */ | |
10694 | install_element (BGP_NODE, &bgp_redistribute_ipv4_cmd); | |
10695 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_cmd); | |
10696 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
718e3744 | 10697 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_cmd); |
718e3744 | 10698 | install_element (BGP_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); |
10699 | install_element (BGP_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
7c8ff89e DS |
10700 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_cmd); |
10701 | install_element (BGP_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
10702 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
7c8ff89e | 10703 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); |
7c8ff89e | 10704 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); |
7c8ff89e | 10705 | install_element (BGP_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); |
919e0666 DW |
10706 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); |
10707 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
10708 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
919e0666 | 10709 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); |
919e0666 DW |
10710 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); |
10711 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
919e0666 DW |
10712 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); |
10713 | install_element (BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
10714 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
919e0666 | 10715 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); |
919e0666 | 10716 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); |
919e0666 | 10717 | install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); |
718e3744 | 10718 | #ifdef HAVE_IPV6 |
10719 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
10720 | install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
10721 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
718e3744 | 10722 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); |
718e3744 | 10723 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); |
10724 | install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
718e3744 | 10725 | #endif /* HAVE_IPV6 */ |
10726 | ||
fa411a21 NH |
10727 | /* ttl_security commands */ |
10728 | install_element (BGP_NODE, &neighbor_ttl_security_cmd); | |
10729 | install_element (BGP_NODE, &no_neighbor_ttl_security_cmd); | |
10730 | ||
716b2d8a | 10731 | /* "show [ip] bgp memory" commands. */ |
4bf6a362 | 10732 | install_element (VIEW_NODE, &show_bgp_memory_cmd); |
e52702f2 | 10733 | |
716b2d8a | 10734 | /* "show [ip] bgp views" commands. */ |
e0081f70 | 10735 | install_element (VIEW_NODE, &show_bgp_views_cmd); |
e52702f2 | 10736 | |
716b2d8a | 10737 | /* "show [ip] bgp vrfs" commands. */ |
8386ac43 | 10738 | install_element (VIEW_NODE, &show_bgp_vrfs_cmd); |
e52702f2 | 10739 | |
718e3744 | 10740 | /* Community-list. */ |
10741 | community_list_vty (); | |
10742 | } | |
6b0655a2 | 10743 | |
718e3744 | 10744 | #include "memory.h" |
10745 | #include "bgp_regex.h" | |
10746 | #include "bgp_clist.h" | |
10747 | #include "bgp_ecommunity.h" | |
10748 | ||
10749 | /* VTY functions. */ | |
10750 | ||
10751 | /* Direction value to string conversion. */ | |
94f2b392 | 10752 | static const char * |
718e3744 | 10753 | community_direct_str (int direct) |
10754 | { | |
10755 | switch (direct) | |
10756 | { | |
10757 | case COMMUNITY_DENY: | |
10758 | return "deny"; | |
718e3744 | 10759 | case COMMUNITY_PERMIT: |
10760 | return "permit"; | |
718e3744 | 10761 | default: |
10762 | return "unknown"; | |
718e3744 | 10763 | } |
10764 | } | |
10765 | ||
10766 | /* Display error string. */ | |
94f2b392 | 10767 | static void |
718e3744 | 10768 | community_list_perror (struct vty *vty, int ret) |
10769 | { | |
10770 | switch (ret) | |
10771 | { | |
10772 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
b729294c | 10773 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 10774 | break; |
10775 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
10776 | vty_out (vty, "%% Malformed community-list value%s", VTY_NEWLINE); | |
10777 | break; | |
10778 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
10779 | vty_out (vty, "%% Community name conflict, previously defined as standard community%s", VTY_NEWLINE); | |
10780 | break; | |
10781 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
10782 | vty_out (vty, "%% Community name conflict, previously defined as expanded community%s", VTY_NEWLINE); | |
10783 | break; | |
10784 | } | |
10785 | } | |
10786 | ||
5bf15956 DW |
10787 | /* "community-list" keyword help string. */ |
10788 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
10789 | ||
718e3744 | 10790 | |
5bf15956 | 10791 | /* ip community-list standard */ |
718e3744 | 10792 | DEFUN (ip_community_list_standard, |
10793 | ip_community_list_standard_cmd, | |
e961923c | 10794 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 10795 | IP_STR |
10796 | COMMUNITY_LIST_STR | |
10797 | "Community list number (standard)\n" | |
5bf15956 | 10798 | "Add an standard community-list entry\n" |
718e3744 | 10799 | "Community list name\n" |
10800 | "Specify community to reject\n" | |
10801 | "Specify community to accept\n" | |
10802 | COMMUNITY_VAL_STR) | |
10803 | { | |
42f914d4 QY |
10804 | char *cl_name_or_number = NULL; |
10805 | int direct = 0; | |
10806 | int style = COMMUNITY_LIST_STANDARD; | |
10807 | ||
10808 | int idx = 0; | |
10809 | argv_find (argv, argc, "(1-99)", &idx); | |
10810 | argv_find (argv, argc, "WORD", &idx); | |
10811 | cl_name_or_number = argv[idx]->arg; | |
10812 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
10813 | argv_find (argv, argc, "AA:NN", &idx); | |
10814 | char *str = argv_concat (argv, argc, idx); | |
10815 | ||
10816 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
10817 | ||
10818 | XFREE (MTYPE_TMP, str); | |
10819 | ||
10820 | if (ret < 0) | |
10821 | { | |
10822 | /* Display error string. */ | |
10823 | community_list_perror (vty, ret); | |
10824 | return CMD_WARNING; | |
10825 | } | |
10826 | ||
10827 | return CMD_SUCCESS; | |
718e3744 | 10828 | } |
10829 | ||
fee6e4e4 | 10830 | DEFUN (no_ip_community_list_standard_all, |
10831 | no_ip_community_list_standard_all_cmd, | |
e961923c | 10832 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 10833 | NO_STR |
10834 | IP_STR | |
10835 | COMMUNITY_LIST_STR | |
10836 | "Community list number (standard)\n" | |
5bf15956 DW |
10837 | "Add an standard community-list entry\n" |
10838 | "Community list name\n" | |
718e3744 | 10839 | "Specify community to reject\n" |
10840 | "Specify community to accept\n" | |
10841 | COMMUNITY_VAL_STR) | |
10842 | { | |
42f914d4 QY |
10843 | int delete_all = 0; |
10844 | ||
10845 | char *cl_name_or_number = NULL; | |
10846 | int direct = 0; | |
10847 | int style = COMMUNITY_LIST_STANDARD; | |
10848 | ||
10849 | int idx = 0; | |
10850 | argv_find (argv, argc, "(1-99)", &idx); | |
10851 | argv_find (argv, argc, "WORD", &idx); | |
10852 | cl_name_or_number = argv[idx]->arg; | |
10853 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
10854 | argv_find (argv, argc, "AA:NN", &idx); | |
10855 | char *str = argv_concat (argv, argc, idx); | |
10856 | ||
10857 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
10858 | ||
10859 | if (ret < 0) | |
10860 | { | |
10861 | community_list_perror (vty, ret); | |
10862 | return CMD_WARNING; | |
10863 | } | |
10864 | ||
10865 | return CMD_SUCCESS; | |
718e3744 | 10866 | } |
10867 | ||
5bf15956 DW |
10868 | /* ip community-list expanded */ |
10869 | DEFUN (ip_community_list_expanded_all, | |
10870 | ip_community_list_expanded_all_cmd, | |
42f914d4 | 10871 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 10872 | IP_STR |
10873 | COMMUNITY_LIST_STR | |
10874 | "Community list number (expanded)\n" | |
5bf15956 | 10875 | "Add an expanded community-list entry\n" |
718e3744 | 10876 | "Community list name\n" |
10877 | "Specify community to reject\n" | |
10878 | "Specify community to accept\n" | |
10879 | COMMUNITY_VAL_STR) | |
10880 | { | |
42f914d4 QY |
10881 | char *cl_name_or_number = NULL; |
10882 | int direct = 0; | |
10883 | int style = COMMUNITY_LIST_EXPANDED; | |
10884 | ||
10885 | int idx = 0; | |
10886 | argv_find (argv, argc, "(100-500)", &idx); | |
10887 | argv_find (argv, argc, "WORD", &idx); | |
10888 | cl_name_or_number = argv[idx]->arg; | |
10889 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
10890 | argv_find (argv, argc, "AA:NN", &idx); | |
10891 | char *str = argv_concat (argv, argc, idx); | |
10892 | ||
10893 | int ret = community_list_set (bgp_clist, cl_name_or_number, str, direct, style); | |
10894 | ||
10895 | XFREE (MTYPE_TMP, str); | |
10896 | ||
10897 | if (ret < 0) | |
10898 | { | |
10899 | /* Display error string. */ | |
10900 | community_list_perror (vty, ret); | |
10901 | return CMD_WARNING; | |
10902 | } | |
10903 | ||
10904 | return CMD_SUCCESS; | |
718e3744 | 10905 | } |
10906 | ||
5bf15956 DW |
10907 | DEFUN (no_ip_community_list_expanded_all, |
10908 | no_ip_community_list_expanded_all_cmd, | |
42f914d4 | 10909 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 10910 | NO_STR |
10911 | IP_STR | |
10912 | COMMUNITY_LIST_STR | |
5bf15956 DW |
10913 | "Community list number (expanded)\n" |
10914 | "Add an expanded community-list entry\n" | |
718e3744 | 10915 | "Community list name\n" |
10916 | "Specify community to reject\n" | |
10917 | "Specify community to accept\n" | |
5bf15956 | 10918 | COMMUNITY_VAL_STR) |
718e3744 | 10919 | { |
42f914d4 QY |
10920 | int delete_all = 0; |
10921 | ||
10922 | char *cl_name_or_number = NULL; | |
10923 | int direct = 0; | |
10924 | int style = COMMUNITY_LIST_EXPANDED; | |
10925 | ||
10926 | int idx = 0; | |
10927 | argv_find (argv, argc, "(100-500)", &idx); | |
10928 | argv_find (argv, argc, "WORD", &idx); | |
10929 | cl_name_or_number = argv[idx]->arg; | |
10930 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
10931 | argv_find (argv, argc, "AA:NN", &idx); | |
10932 | char *str = argv_concat (argv, argc, idx); | |
10933 | ||
10934 | int ret = community_list_unset (bgp_clist, cl_name_or_number, str, direct, style, delete_all); | |
10935 | ||
10936 | if (ret < 0) | |
10937 | { | |
10938 | community_list_perror (vty, ret); | |
10939 | return CMD_WARNING; | |
10940 | } | |
10941 | ||
10942 | return CMD_SUCCESS; | |
718e3744 | 10943 | } |
10944 | ||
94f2b392 | 10945 | static void |
718e3744 | 10946 | community_list_show (struct vty *vty, struct community_list *list) |
10947 | { | |
10948 | struct community_entry *entry; | |
10949 | ||
10950 | for (entry = list->head; entry; entry = entry->next) | |
10951 | { | |
10952 | if (entry == list->head) | |
10953 | { | |
10954 | if (all_digit (list->name)) | |
10955 | vty_out (vty, "Community %s list %s%s", | |
10956 | entry->style == COMMUNITY_LIST_STANDARD ? | |
10957 | "standard" : "(expanded) access", | |
10958 | list->name, VTY_NEWLINE); | |
10959 | else | |
10960 | vty_out (vty, "Named Community %s list %s%s", | |
10961 | entry->style == COMMUNITY_LIST_STANDARD ? | |
10962 | "standard" : "expanded", | |
10963 | list->name, VTY_NEWLINE); | |
10964 | } | |
10965 | if (entry->any) | |
10966 | vty_out (vty, " %s%s", | |
10967 | community_direct_str (entry->direct), VTY_NEWLINE); | |
10968 | else | |
10969 | vty_out (vty, " %s %s%s", | |
10970 | community_direct_str (entry->direct), | |
10971 | entry->style == COMMUNITY_LIST_STANDARD | |
10972 | ? community_str (entry->u.com) : entry->config, | |
10973 | VTY_NEWLINE); | |
10974 | } | |
10975 | } | |
10976 | ||
10977 | DEFUN (show_ip_community_list, | |
10978 | show_ip_community_list_cmd, | |
10979 | "show ip community-list", | |
10980 | SHOW_STR | |
10981 | IP_STR | |
10982 | "List community-list\n") | |
10983 | { | |
10984 | struct community_list *list; | |
10985 | struct community_list_master *cm; | |
10986 | ||
fee6e4e4 | 10987 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 10988 | if (! cm) |
10989 | return CMD_SUCCESS; | |
10990 | ||
10991 | for (list = cm->num.head; list; list = list->next) | |
10992 | community_list_show (vty, list); | |
10993 | ||
10994 | for (list = cm->str.head; list; list = list->next) | |
10995 | community_list_show (vty, list); | |
10996 | ||
10997 | return CMD_SUCCESS; | |
10998 | } | |
10999 | ||
11000 | DEFUN (show_ip_community_list_arg, | |
11001 | show_ip_community_list_arg_cmd, | |
6147e2c6 | 11002 | "show ip community-list <(1-500)|WORD>", |
718e3744 | 11003 | SHOW_STR |
11004 | IP_STR | |
11005 | "List community-list\n" | |
11006 | "Community-list number\n" | |
11007 | "Community-list name\n") | |
11008 | { | |
c500ae40 | 11009 | int idx_comm_list = 3; |
718e3744 | 11010 | struct community_list *list; |
11011 | ||
c500ae40 | 11012 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, COMMUNITY_LIST_MASTER); |
718e3744 | 11013 | if (! list) |
11014 | { | |
b729294c | 11015 | vty_out (vty, "%% Can't find community-list%s", VTY_NEWLINE); |
718e3744 | 11016 | return CMD_WARNING; |
11017 | } | |
11018 | ||
11019 | community_list_show (vty, list); | |
11020 | ||
11021 | return CMD_SUCCESS; | |
11022 | } | |
6b0655a2 | 11023 | |
718e3744 | 11024 | /* "extcommunity-list" keyword help string. */ |
11025 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
11026 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
11027 | ||
11028 | DEFUN (ip_extcommunity_list_standard, | |
11029 | ip_extcommunity_list_standard_cmd, | |
e961923c | 11030 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 11031 | IP_STR |
11032 | EXTCOMMUNITY_LIST_STR | |
11033 | "Extended Community list number (standard)\n" | |
718e3744 | 11034 | "Specify standard extcommunity-list\n" |
5bf15956 | 11035 | "Community list name\n" |
718e3744 | 11036 | "Specify community to reject\n" |
11037 | "Specify community to accept\n" | |
11038 | EXTCOMMUNITY_VAL_STR) | |
11039 | { | |
42f914d4 QY |
11040 | int style = EXTCOMMUNITY_LIST_STANDARD; |
11041 | int direct = 0; | |
11042 | char *cl_number_or_name = NULL; | |
11043 | ||
11044 | int idx = 0; | |
11045 | argv_find (argv, argc, "(1-99)", &idx); | |
11046 | argv_find (argv, argc, "WORD", &idx); | |
11047 | cl_number_or_name = argv[idx]->arg; | |
11048 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11049 | argv_find (argv, argc, "AA:NN", &idx); | |
11050 | char *str = argv_concat (argv, argc, idx); | |
11051 | ||
11052 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
11053 | ||
11054 | XFREE (MTYPE_TMP, str); | |
11055 | ||
11056 | if (ret < 0) | |
11057 | { | |
11058 | community_list_perror (vty, ret); | |
11059 | return CMD_WARNING; | |
11060 | } | |
11061 | ||
11062 | return CMD_SUCCESS; | |
718e3744 | 11063 | } |
11064 | ||
718e3744 | 11065 | DEFUN (ip_extcommunity_list_name_expanded, |
11066 | ip_extcommunity_list_name_expanded_cmd, | |
e961923c | 11067 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 11068 | IP_STR |
11069 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 11070 | "Extended Community list number (expanded)\n" |
718e3744 | 11071 | "Specify expanded extcommunity-list\n" |
11072 | "Extended Community list name\n" | |
11073 | "Specify community to reject\n" | |
11074 | "Specify community to accept\n" | |
11075 | "An ordered list as a regular-expression\n") | |
11076 | { | |
42f914d4 QY |
11077 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
11078 | int direct = 0; | |
11079 | char *cl_number_or_name = NULL; | |
11080 | ||
11081 | int idx = 0; | |
11082 | argv_find (argv, argc, "(100-500)", &idx); | |
11083 | argv_find (argv, argc, "WORD", &idx); | |
11084 | cl_number_or_name = argv[idx]->arg; | |
11085 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11086 | argv_find (argv, argc, "LINE", &idx); | |
11087 | char *str = argv_concat (argv, argc, idx); | |
11088 | ||
11089 | int ret = extcommunity_list_set (bgp_clist, cl_number_or_name, str, direct, style); | |
11090 | ||
11091 | XFREE (MTYPE_TMP, str); | |
11092 | ||
11093 | if (ret < 0) | |
11094 | { | |
11095 | community_list_perror (vty, ret); | |
11096 | return CMD_WARNING; | |
11097 | } | |
11098 | ||
11099 | return CMD_SUCCESS; | |
718e3744 | 11100 | } |
11101 | ||
fee6e4e4 | 11102 | DEFUN (no_ip_extcommunity_list_standard_all, |
11103 | no_ip_extcommunity_list_standard_all_cmd, | |
e961923c | 11104 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
813d4307 DW |
11105 | NO_STR |
11106 | IP_STR | |
11107 | EXTCOMMUNITY_LIST_STR | |
11108 | "Extended Community list number (standard)\n" | |
718e3744 | 11109 | "Specify standard extcommunity-list\n" |
5bf15956 | 11110 | "Community list name\n" |
718e3744 | 11111 | "Specify community to reject\n" |
11112 | "Specify community to accept\n" | |
11113 | EXTCOMMUNITY_VAL_STR) | |
11114 | { | |
42f914d4 QY |
11115 | int deleteall = 0; |
11116 | ||
11117 | int style = EXTCOMMUNITY_LIST_STANDARD; | |
11118 | int direct = 0; | |
11119 | char *cl_number_or_name = NULL; | |
11120 | ||
11121 | int idx = 0; | |
11122 | argv_find (argv, argc, "(1-99)", &idx); | |
11123 | argv_find (argv, argc, "WORD", &idx); | |
11124 | cl_number_or_name = argv[idx]->arg; | |
11125 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11126 | argv_find (argv, argc, "AA:NN", &idx); | |
11127 | char *str = argv_concat (argv, argc, idx); | |
11128 | ||
11129 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
11130 | ||
11131 | XFREE (MTYPE_TMP, str); | |
11132 | ||
11133 | if (ret < 0) | |
11134 | { | |
11135 | community_list_perror (vty, ret); | |
11136 | return CMD_WARNING; | |
11137 | } | |
11138 | ||
11139 | return CMD_SUCCESS; | |
718e3744 | 11140 | } |
11141 | ||
5bf15956 DW |
11142 | DEFUN (no_ip_extcommunity_list_expanded_all, |
11143 | no_ip_extcommunity_list_expanded_all_cmd, | |
e961923c | 11144 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 11145 | NO_STR |
11146 | IP_STR | |
11147 | EXTCOMMUNITY_LIST_STR | |
11148 | "Extended Community list number (expanded)\n" | |
718e3744 | 11149 | "Specify expanded extcommunity-list\n" |
5bf15956 | 11150 | "Extended Community list name\n" |
718e3744 | 11151 | "Specify community to reject\n" |
11152 | "Specify community to accept\n" | |
11153 | "An ordered list as a regular-expression\n") | |
11154 | { | |
42f914d4 QY |
11155 | int deleteall = 0; |
11156 | ||
11157 | int style = EXTCOMMUNITY_LIST_EXPANDED; | |
11158 | int direct = 0; | |
11159 | char *cl_number_or_name = NULL; | |
11160 | ||
11161 | int idx = 0; | |
11162 | argv_find (argv, argc, "(100-500)", &idx); | |
11163 | argv_find (argv, argc, "WORD", &idx); | |
11164 | cl_number_or_name = argv[idx]->arg; | |
11165 | direct = argv_find (argv, argc, "permit", &idx) ? COMMUNITY_PERMIT : COMMUNITY_DENY; | |
11166 | argv_find (argv, argc, "LINE", &idx); | |
11167 | char *str = argv_concat (argv, argc, idx); | |
11168 | ||
11169 | int ret = extcommunity_list_unset (bgp_clist, cl_number_or_name, str, direct, style, deleteall); | |
11170 | ||
11171 | XFREE (MTYPE_TMP, str); | |
11172 | ||
11173 | if (ret < 0) | |
11174 | { | |
11175 | community_list_perror (vty, ret); | |
11176 | return CMD_WARNING; | |
11177 | } | |
11178 | ||
11179 | return CMD_SUCCESS; | |
718e3744 | 11180 | } |
11181 | ||
94f2b392 | 11182 | static void |
718e3744 | 11183 | extcommunity_list_show (struct vty *vty, struct community_list *list) |
11184 | { | |
11185 | struct community_entry *entry; | |
11186 | ||
11187 | for (entry = list->head; entry; entry = entry->next) | |
11188 | { | |
11189 | if (entry == list->head) | |
11190 | { | |
11191 | if (all_digit (list->name)) | |
11192 | vty_out (vty, "Extended community %s list %s%s", | |
11193 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11194 | "standard" : "(expanded) access", | |
11195 | list->name, VTY_NEWLINE); | |
11196 | else | |
11197 | vty_out (vty, "Named extended community %s list %s%s", | |
11198 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11199 | "standard" : "expanded", | |
11200 | list->name, VTY_NEWLINE); | |
11201 | } | |
11202 | if (entry->any) | |
11203 | vty_out (vty, " %s%s", | |
11204 | community_direct_str (entry->direct), VTY_NEWLINE); | |
11205 | else | |
11206 | vty_out (vty, " %s %s%s", | |
11207 | community_direct_str (entry->direct), | |
11208 | entry->style == EXTCOMMUNITY_LIST_STANDARD ? | |
11209 | entry->u.ecom->str : entry->config, | |
11210 | VTY_NEWLINE); | |
11211 | } | |
11212 | } | |
11213 | ||
11214 | DEFUN (show_ip_extcommunity_list, | |
11215 | show_ip_extcommunity_list_cmd, | |
11216 | "show ip extcommunity-list", | |
11217 | SHOW_STR | |
11218 | IP_STR | |
11219 | "List extended-community list\n") | |
11220 | { | |
11221 | struct community_list *list; | |
11222 | struct community_list_master *cm; | |
11223 | ||
fee6e4e4 | 11224 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 11225 | if (! cm) |
11226 | return CMD_SUCCESS; | |
11227 | ||
11228 | for (list = cm->num.head; list; list = list->next) | |
11229 | extcommunity_list_show (vty, list); | |
11230 | ||
11231 | for (list = cm->str.head; list; list = list->next) | |
11232 | extcommunity_list_show (vty, list); | |
11233 | ||
11234 | return CMD_SUCCESS; | |
11235 | } | |
11236 | ||
11237 | DEFUN (show_ip_extcommunity_list_arg, | |
11238 | show_ip_extcommunity_list_arg_cmd, | |
6147e2c6 | 11239 | "show ip extcommunity-list <(1-500)|WORD>", |
718e3744 | 11240 | SHOW_STR |
11241 | IP_STR | |
11242 | "List extended-community list\n" | |
11243 | "Extcommunity-list number\n" | |
11244 | "Extcommunity-list name\n") | |
11245 | { | |
c500ae40 | 11246 | int idx_comm_list = 3; |
718e3744 | 11247 | struct community_list *list; |
11248 | ||
c500ae40 | 11249 | list = community_list_lookup (bgp_clist, argv[idx_comm_list]->arg, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 11250 | if (! list) |
11251 | { | |
b729294c | 11252 | vty_out (vty, "%% Can't find extcommunity-list%s", VTY_NEWLINE); |
718e3744 | 11253 | return CMD_WARNING; |
11254 | } | |
11255 | ||
11256 | extcommunity_list_show (vty, list); | |
11257 | ||
11258 | return CMD_SUCCESS; | |
11259 | } | |
6b0655a2 | 11260 | |
718e3744 | 11261 | /* Return configuration string of community-list entry. */ |
fd79ac91 | 11262 | static const char * |
718e3744 | 11263 | community_list_config_str (struct community_entry *entry) |
11264 | { | |
fd79ac91 | 11265 | const char *str; |
718e3744 | 11266 | |
11267 | if (entry->any) | |
11268 | str = ""; | |
11269 | else | |
11270 | { | |
11271 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
11272 | str = community_str (entry->u.com); | |
11273 | else | |
11274 | str = entry->config; | |
11275 | } | |
11276 | return str; | |
11277 | } | |
11278 | ||
11279 | /* Display community-list and extcommunity-list configuration. */ | |
94f2b392 | 11280 | static int |
718e3744 | 11281 | community_list_config_write (struct vty *vty) |
11282 | { | |
11283 | struct community_list *list; | |
11284 | struct community_entry *entry; | |
11285 | struct community_list_master *cm; | |
11286 | int write = 0; | |
11287 | ||
11288 | /* Community-list. */ | |
fee6e4e4 | 11289 | cm = community_list_master_lookup (bgp_clist, COMMUNITY_LIST_MASTER); |
718e3744 | 11290 | |
11291 | for (list = cm->num.head; list; list = list->next) | |
11292 | for (entry = list->head; entry; entry = entry->next) | |
11293 | { | |
fee6e4e4 | 11294 | vty_out (vty, "ip community-list %s %s %s%s", |
11295 | list->name, community_direct_str (entry->direct), | |
11296 | community_list_config_str (entry), | |
11297 | VTY_NEWLINE); | |
718e3744 | 11298 | write++; |
11299 | } | |
11300 | for (list = cm->str.head; list; list = list->next) | |
11301 | for (entry = list->head; entry; entry = entry->next) | |
11302 | { | |
11303 | vty_out (vty, "ip community-list %s %s %s %s%s", | |
11304 | entry->style == COMMUNITY_LIST_STANDARD | |
11305 | ? "standard" : "expanded", | |
11306 | list->name, community_direct_str (entry->direct), | |
11307 | community_list_config_str (entry), | |
11308 | VTY_NEWLINE); | |
11309 | write++; | |
11310 | } | |
11311 | ||
11312 | /* Extcommunity-list. */ | |
fee6e4e4 | 11313 | cm = community_list_master_lookup (bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
718e3744 | 11314 | |
11315 | for (list = cm->num.head; list; list = list->next) | |
11316 | for (entry = list->head; entry; entry = entry->next) | |
11317 | { | |
fee6e4e4 | 11318 | vty_out (vty, "ip extcommunity-list %s %s %s%s", |
11319 | list->name, community_direct_str (entry->direct), | |
11320 | community_list_config_str (entry), VTY_NEWLINE); | |
718e3744 | 11321 | write++; |
11322 | } | |
11323 | for (list = cm->str.head; list; list = list->next) | |
11324 | for (entry = list->head; entry; entry = entry->next) | |
11325 | { | |
11326 | vty_out (vty, "ip extcommunity-list %s %s %s %s%s", | |
11327 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
11328 | ? "standard" : "expanded", | |
11329 | list->name, community_direct_str (entry->direct), | |
11330 | community_list_config_str (entry), VTY_NEWLINE); | |
11331 | write++; | |
11332 | } | |
11333 | return write; | |
11334 | } | |
11335 | ||
7fc626de | 11336 | static struct cmd_node community_list_node = |
718e3744 | 11337 | { |
11338 | COMMUNITY_LIST_NODE, | |
11339 | "", | |
11340 | 1 /* Export to vtysh. */ | |
11341 | }; | |
11342 | ||
94f2b392 | 11343 | static void |
11344 | community_list_vty (void) | |
718e3744 | 11345 | { |
11346 | install_node (&community_list_node, community_list_config_write); | |
11347 | ||
11348 | /* Community-list. */ | |
718e3744 | 11349 | install_element (CONFIG_NODE, &ip_community_list_standard_cmd); |
d7d73ffc | 11350 | install_element (CONFIG_NODE, &ip_community_list_expanded_all_cmd); |
fee6e4e4 | 11351 | install_element (CONFIG_NODE, &no_ip_community_list_standard_all_cmd); |
11352 | install_element (CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); | |
718e3744 | 11353 | install_element (VIEW_NODE, &show_ip_community_list_cmd); |
11354 | install_element (VIEW_NODE, &show_ip_community_list_arg_cmd); | |
718e3744 | 11355 | |
11356 | /* Extcommunity-list. */ | |
11357 | install_element (CONFIG_NODE, &ip_extcommunity_list_standard_cmd); | |
718e3744 | 11358 | install_element (CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); |
fee6e4e4 | 11359 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); |
11360 | install_element (CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
718e3744 | 11361 | install_element (VIEW_NODE, &show_ip_extcommunity_list_cmd); |
11362 | install_element (VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
5bf15956 | 11363 | } |