]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP VTY interface. |
896014f4 DL |
2 | * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License along | |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
718e3744 | 20 | |
21 | #include <zebra.h> | |
22 | ||
23 | #include "command.h" | |
afec25d9 | 24 | #include "lib/json.h" |
718e3744 | 25 | #include "prefix.h" |
26 | #include "plist.h" | |
27 | #include "buffer.h" | |
28 | #include "linklist.h" | |
29 | #include "stream.h" | |
30 | #include "thread.h" | |
31 | #include "log.h" | |
3b8b1855 | 32 | #include "memory.h" |
fc7948fa | 33 | #include "memory_vty.h" |
4bf6a362 | 34 | #include "hash.h" |
3f9c7369 | 35 | #include "queue.h" |
039f3a34 | 36 | #include "filter.h" |
718e3744 | 37 | |
38 | #include "bgpd/bgpd.h" | |
4bf6a362 | 39 | #include "bgpd/bgp_advertise.h" |
718e3744 | 40 | #include "bgpd/bgp_attr.h" |
41 | #include "bgpd/bgp_aspath.h" | |
42 | #include "bgpd/bgp_community.h" | |
4bf6a362 | 43 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 44 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 45 | #include "bgpd/bgp_damp.h" |
718e3744 | 46 | #include "bgpd/bgp_debug.h" |
e0701b79 | 47 | #include "bgpd/bgp_fsm.h" |
4bf6a362 | 48 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 49 | #include "bgpd/bgp_open.h" |
4bf6a362 | 50 | #include "bgpd/bgp_regex.h" |
718e3744 | 51 | #include "bgpd/bgp_route.h" |
c016b6c7 | 52 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 53 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 54 | #include "bgpd/bgp_table.h" |
94f2b392 | 55 | #include "bgpd/bgp_vty.h" |
165b5fff | 56 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 57 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 58 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 59 | #include "bgpd/bgp_bfd.h" |
718e3744 | 60 | |
d62a17ae | 61 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
62 | struct prefix *range, int exact); | |
63 | ||
64 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) | |
65 | { | |
66 | switch (afi) { | |
67 | case AFI_IP: | |
68 | switch (safi) { | |
69 | case SAFI_UNICAST: | |
70 | return BGP_IPV4_NODE; | |
71 | break; | |
72 | case SAFI_MULTICAST: | |
73 | return BGP_IPV4M_NODE; | |
74 | break; | |
75 | case SAFI_LABELED_UNICAST: | |
76 | return BGP_IPV4L_NODE; | |
77 | break; | |
78 | case SAFI_MPLS_VPN: | |
79 | return BGP_VPNV4_NODE; | |
80 | break; | |
81 | } | |
82 | break; | |
83 | case AFI_IP6: | |
84 | switch (safi) { | |
85 | case SAFI_UNICAST: | |
86 | return BGP_IPV6_NODE; | |
87 | break; | |
88 | case SAFI_MULTICAST: | |
89 | return BGP_IPV6M_NODE; | |
90 | break; | |
91 | case SAFI_LABELED_UNICAST: | |
92 | return BGP_IPV6L_NODE; | |
93 | break; | |
94 | case SAFI_MPLS_VPN: | |
95 | return BGP_VPNV6_NODE; | |
96 | break; | |
97 | } | |
98 | break; | |
99 | case AFI_L2VPN: | |
100 | return BGP_EVPN_NODE; | |
101 | break; | |
102 | case AFI_MAX: | |
103 | // We should never be here but to clarify the switch statement.. | |
104 | return BGP_IPV4_NODE; | |
105 | break; | |
106 | } | |
107 | ||
108 | // Impossible to happen | |
109 | return BGP_IPV4_NODE; | |
f51bae9c | 110 | } |
20eb8864 | 111 | |
718e3744 | 112 | /* Utility function to get address family from current node. */ |
d62a17ae | 113 | afi_t bgp_node_afi(struct vty *vty) |
114 | { | |
115 | afi_t afi; | |
116 | switch (vty->node) { | |
117 | case BGP_IPV6_NODE: | |
118 | case BGP_IPV6M_NODE: | |
119 | case BGP_IPV6L_NODE: | |
120 | case BGP_VPNV6_NODE: | |
121 | afi = AFI_IP6; | |
122 | break; | |
123 | case BGP_EVPN_NODE: | |
124 | afi = AFI_L2VPN; | |
125 | break; | |
126 | default: | |
127 | afi = AFI_IP; | |
128 | break; | |
129 | } | |
130 | return afi; | |
718e3744 | 131 | } |
132 | ||
133 | /* Utility function to get subsequent address family from current | |
134 | node. */ | |
d62a17ae | 135 | safi_t bgp_node_safi(struct vty *vty) |
136 | { | |
137 | safi_t safi; | |
138 | switch (vty->node) { | |
139 | case BGP_VPNV4_NODE: | |
140 | case BGP_VPNV6_NODE: | |
141 | safi = SAFI_MPLS_VPN; | |
142 | break; | |
143 | case BGP_IPV4M_NODE: | |
144 | case BGP_IPV6M_NODE: | |
145 | safi = SAFI_MULTICAST; | |
146 | break; | |
147 | case BGP_EVPN_NODE: | |
148 | safi = SAFI_EVPN; | |
149 | break; | |
150 | case BGP_IPV4L_NODE: | |
151 | case BGP_IPV6L_NODE: | |
152 | safi = SAFI_LABELED_UNICAST; | |
153 | break; | |
154 | default: | |
155 | safi = SAFI_UNICAST; | |
156 | break; | |
157 | } | |
158 | return safi; | |
718e3744 | 159 | } |
160 | ||
55f91488 QY |
161 | /** |
162 | * Converts an AFI in string form to afi_t | |
163 | * | |
164 | * @param afi string, one of | |
165 | * - "ipv4" | |
166 | * - "ipv6" | |
167 | * @return the corresponding afi_t | |
168 | */ | |
d62a17ae | 169 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
170 | { | |
171 | afi_t afi = AFI_MAX; /* unknown */ | |
172 | if (strmatch(afi_str, "ipv4")) | |
173 | afi = AFI_IP; | |
174 | else if (strmatch(afi_str, "ipv6")) | |
175 | afi = AFI_IP6; | |
176 | return afi; | |
177 | } | |
178 | ||
179 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
180 | afi_t *afi) | |
181 | { | |
182 | int ret = 0; | |
183 | if (argv_find(argv, argc, "ipv4", index)) { | |
184 | ret = 1; | |
185 | if (afi) | |
186 | *afi = AFI_IP; | |
187 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
188 | ret = 1; | |
189 | if (afi) | |
190 | *afi = AFI_IP6; | |
191 | } | |
192 | return ret; | |
46f296b4 LB |
193 | } |
194 | ||
375a2e67 | 195 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 196 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
197 | { | |
198 | safi_t safi = SAFI_MAX; /* unknown */ | |
199 | if (strmatch(safi_str, "multicast")) | |
200 | safi = SAFI_MULTICAST; | |
201 | else if (strmatch(safi_str, "unicast")) | |
202 | safi = SAFI_UNICAST; | |
203 | else if (strmatch(safi_str, "vpn")) | |
204 | safi = SAFI_MPLS_VPN; | |
205 | else if (strmatch(safi_str, "labeled-unicast")) | |
206 | safi = SAFI_LABELED_UNICAST; | |
207 | return safi; | |
208 | } | |
209 | ||
210 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
211 | safi_t *safi) | |
212 | { | |
213 | int ret = 0; | |
214 | if (argv_find(argv, argc, "unicast", index)) { | |
215 | ret = 1; | |
216 | if (safi) | |
217 | *safi = SAFI_UNICAST; | |
218 | } else if (argv_find(argv, argc, "multicast", index)) { | |
219 | ret = 1; | |
220 | if (safi) | |
221 | *safi = SAFI_MULTICAST; | |
222 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
223 | ret = 1; | |
224 | if (safi) | |
225 | *safi = SAFI_LABELED_UNICAST; | |
226 | } else if (argv_find(argv, argc, "vpn", index)) { | |
227 | ret = 1; | |
228 | if (safi) | |
229 | *safi = SAFI_MPLS_VPN; | |
230 | } | |
231 | return ret; | |
46f296b4 LB |
232 | } |
233 | ||
7eeee51e | 234 | /* |
f212a857 | 235 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 236 | * |
f212a857 DS |
237 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
238 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
239 | * to appropriate values for the calling function. This is to allow the |
240 | * calling function to make decisions appropriate for the show command | |
241 | * that is being parsed. | |
242 | * | |
243 | * The show commands are generally of the form: | |
d62a17ae | 244 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
245 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
246 | * |
247 | * Since we use argv_find if the show command in particular doesn't have: | |
248 | * [ip] | |
18c57037 | 249 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 250 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
251 | * The command parsing should still be ok. |
252 | * | |
253 | * vty -> The vty for the command so we can output some useful data in | |
254 | * the event of a parse error in the vrf. | |
255 | * argv -> The command tokens | |
256 | * argc -> How many command tokens we have | |
d62a17ae | 257 | * idx -> The current place in the command, generally should be 0 for this |
258 | * function | |
7eeee51e DS |
259 | * afi -> The parsed afi if it was included in the show command, returned here |
260 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 261 | * bgp -> Pointer to the bgp data structure we need to fill in. |
7eeee51e DS |
262 | * |
263 | * The function returns the correct location in the parse tree for the | |
264 | * last token found. | |
0e37c258 DS |
265 | * |
266 | * Returns 0 for failure to parse correctly, else the idx position of where | |
267 | * it found the last token. | |
7eeee51e | 268 | */ |
d62a17ae | 269 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
270 | struct cmd_token **argv, int argc, | |
271 | int *idx, afi_t *afi, safi_t *safi, | |
272 | struct bgp **bgp) | |
273 | { | |
274 | char *vrf_name = NULL; | |
275 | ||
276 | assert(afi); | |
277 | assert(safi); | |
278 | assert(bgp); | |
279 | ||
280 | if (argv_find(argv, argc, "ip", idx)) | |
281 | *afi = AFI_IP; | |
282 | ||
283 | if (argv_find(argv, argc, "view", idx) | |
284 | || argv_find(argv, argc, "vrf", idx)) { | |
285 | vrf_name = argv[*idx + 1]->arg; | |
286 | ||
287 | if (strmatch(vrf_name, "all")) | |
288 | *bgp = NULL; | |
289 | else { | |
290 | *bgp = bgp_lookup_by_name(vrf_name); | |
291 | if (!*bgp) { | |
292 | vty_out(vty, | |
293 | "View/Vrf specified is unknown: %s\n", | |
294 | vrf_name); | |
295 | *idx = 0; | |
296 | return 0; | |
297 | } | |
298 | } | |
299 | } else { | |
300 | *bgp = bgp_get_default(); | |
301 | if (!*bgp) { | |
302 | vty_out(vty, "Unable to find default BGP instance\n"); | |
303 | *idx = 0; | |
304 | return 0; | |
305 | } | |
306 | } | |
307 | ||
308 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
309 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
310 | ||
311 | *idx += 1; | |
312 | return *idx; | |
313 | } | |
314 | ||
315 | static int peer_address_self_check(struct bgp *bgp, union sockunion *su) | |
316 | { | |
317 | struct interface *ifp = NULL; | |
318 | ||
319 | if (su->sa.sa_family == AF_INET) | |
320 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
321 | else if (su->sa.sa_family == AF_INET6) | |
322 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
323 | su->sin6.sin6_scope_id, | |
324 | bgp->vrf_id); | |
325 | ||
326 | if (ifp) | |
327 | return 1; | |
328 | ||
329 | return 0; | |
718e3744 | 330 | } |
331 | ||
332 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
333 | /* This is used only for configuration, so disallow if attempted on |
334 | * a dynamic neighbor. | |
335 | */ | |
d62a17ae | 336 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
337 | { | |
338 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
339 | int ret; | |
340 | union sockunion su; | |
341 | struct peer *peer; | |
342 | ||
343 | if (!bgp) { | |
344 | return NULL; | |
345 | } | |
346 | ||
347 | ret = str2sockunion(ip_str, &su); | |
348 | if (ret < 0) { | |
349 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
350 | if (!peer) { | |
351 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
352 | == NULL) { | |
353 | vty_out(vty, | |
354 | "%% Malformed address or name: %s\n", | |
355 | ip_str); | |
356 | return NULL; | |
357 | } | |
358 | } | |
359 | } else { | |
360 | peer = peer_lookup(bgp, &su); | |
361 | if (!peer) { | |
362 | vty_out(vty, | |
363 | "%% Specify remote-as or peer-group commands first\n"); | |
364 | return NULL; | |
365 | } | |
366 | if (peer_dynamic_neighbor(peer)) { | |
367 | vty_out(vty, | |
368 | "%% Operation not allowed on a dynamic neighbor\n"); | |
369 | return NULL; | |
370 | } | |
371 | } | |
372 | return peer; | |
718e3744 | 373 | } |
374 | ||
375 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
376 | /* This is used only for configuration, so disallow if attempted on |
377 | * a dynamic neighbor. | |
378 | */ | |
d62a17ae | 379 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
380 | { | |
381 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
382 | int ret; | |
383 | union sockunion su; | |
384 | struct peer *peer = NULL; | |
385 | struct peer_group *group = NULL; | |
386 | ||
387 | if (!bgp) { | |
388 | return NULL; | |
389 | } | |
390 | ||
391 | ret = str2sockunion(peer_str, &su); | |
392 | if (ret == 0) { | |
393 | /* IP address, locate peer. */ | |
394 | peer = peer_lookup(bgp, &su); | |
395 | } else { | |
396 | /* Not IP, could match either peer configured on interface or a | |
397 | * group. */ | |
398 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
399 | if (!peer) | |
400 | group = peer_group_lookup(bgp, peer_str); | |
401 | } | |
402 | ||
403 | if (peer) { | |
404 | if (peer_dynamic_neighbor(peer)) { | |
405 | vty_out(vty, | |
406 | "%% Operation not allowed on a dynamic neighbor\n"); | |
407 | return NULL; | |
408 | } | |
409 | ||
410 | return peer; | |
411 | } | |
412 | ||
413 | if (group) | |
414 | return group->conf; | |
415 | ||
416 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
417 | ||
418 | return NULL; | |
419 | } | |
420 | ||
421 | int bgp_vty_return(struct vty *vty, int ret) | |
422 | { | |
423 | const char *str = NULL; | |
424 | ||
425 | switch (ret) { | |
426 | case BGP_ERR_INVALID_VALUE: | |
427 | str = "Invalid value"; | |
428 | break; | |
429 | case BGP_ERR_INVALID_FLAG: | |
430 | str = "Invalid flag"; | |
431 | break; | |
432 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
433 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
434 | break; | |
435 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
436 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
437 | break; | |
438 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
439 | str = "Specify remote-as or peer-group remote AS first"; | |
440 | break; | |
441 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
442 | str = "Cannot change the peer-group. Deconfigure first"; | |
443 | break; | |
444 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
445 | str = "Peer is not a member of this peer-group"; | |
446 | break; | |
447 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
448 | str = "Prefix/distribute list can not co-exist"; | |
449 | break; | |
450 | case BGP_ERR_NOT_INTERNAL_PEER: | |
451 | str = "Invalid command. Not an internal neighbor"; | |
452 | break; | |
453 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
454 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
455 | break; | |
456 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
457 | str = "Local-AS allowed only for EBGP peers"; | |
458 | break; | |
459 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
460 | str = "Cannot have local-as same as BGP AS number"; | |
461 | break; | |
462 | case BGP_ERR_TCPSIG_FAILED: | |
463 | str = "Error while applying TCP-Sig to session(s)"; | |
464 | break; | |
465 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
466 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
467 | break; | |
468 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
469 | str = "ttl-security only allowed for EBGP peers"; | |
470 | break; | |
471 | case BGP_ERR_AS_OVERRIDE: | |
472 | str = "as-override cannot be configured for IBGP peers"; | |
473 | break; | |
474 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
475 | str = "Invalid limit for number of dynamic neighbors"; | |
476 | break; | |
477 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
478 | str = "Dynamic neighbor listen range already exists"; | |
479 | break; | |
480 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
481 | str = "Operation not allowed on a dynamic neighbor"; | |
482 | break; | |
483 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
484 | str = "Operation not allowed on a directly connected neighbor"; | |
485 | break; | |
486 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
487 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; | |
488 | break; | |
489 | } | |
490 | if (str) { | |
491 | vty_out(vty, "%% %s\n", str); | |
492 | return CMD_WARNING_CONFIG_FAILED; | |
493 | } | |
494 | return CMD_SUCCESS; | |
718e3744 | 495 | } |
496 | ||
7aafcaca | 497 | /* BGP clear sort. */ |
d62a17ae | 498 | enum clear_sort { |
499 | clear_all, | |
500 | clear_peer, | |
501 | clear_group, | |
502 | clear_external, | |
503 | clear_as | |
7aafcaca DS |
504 | }; |
505 | ||
d62a17ae | 506 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
507 | safi_t safi, int error) | |
508 | { | |
509 | switch (error) { | |
510 | case BGP_ERR_AF_UNCONFIGURED: | |
511 | vty_out(vty, | |
512 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
513 | afi_safi_print(afi, safi), peer->host); | |
514 | break; | |
515 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
516 | vty_out(vty, | |
517 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
518 | peer->host); | |
519 | break; | |
520 | default: | |
521 | break; | |
522 | } | |
7aafcaca DS |
523 | } |
524 | ||
525 | /* `clear ip bgp' functions. */ | |
d62a17ae | 526 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
527 | enum clear_sort sort, enum bgp_clear_type stype, | |
528 | const char *arg) | |
529 | { | |
530 | int ret; | |
531 | struct peer *peer; | |
532 | struct listnode *node, *nnode; | |
533 | ||
534 | /* Clear all neighbors. */ | |
535 | /* | |
536 | * Pass along pointer to next node to peer_clear() when walking all | |
537 | * nodes | |
538 | * on the BGP instance as that may get freed if it is a doppelganger | |
539 | */ | |
540 | if (sort == clear_all) { | |
541 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
542 | if (stype == BGP_CLEAR_SOFT_NONE) | |
543 | ret = peer_clear(peer, &nnode); | |
544 | else if (peer->afc[afi][safi]) | |
545 | ret = peer_clear_soft(peer, afi, safi, stype); | |
546 | else | |
547 | ret = 0; | |
548 | ||
549 | if (ret < 0) | |
550 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
04b6bdc0 | 551 | } |
d62a17ae | 552 | |
553 | /* This is to apply read-only mode on this clear. */ | |
554 | if (stype == BGP_CLEAR_SOFT_NONE) | |
555 | bgp->update_delay_over = 0; | |
556 | ||
557 | return CMD_SUCCESS; | |
7aafcaca DS |
558 | } |
559 | ||
d62a17ae | 560 | /* Clear specified neighbors. */ |
561 | if (sort == clear_peer) { | |
562 | union sockunion su; | |
563 | int ret; | |
564 | ||
565 | /* Make sockunion for lookup. */ | |
566 | ret = str2sockunion(arg, &su); | |
567 | if (ret < 0) { | |
568 | peer = peer_lookup_by_conf_if(bgp, arg); | |
569 | if (!peer) { | |
570 | peer = peer_lookup_by_hostname(bgp, arg); | |
571 | if (!peer) { | |
572 | vty_out(vty, | |
573 | "Malformed address or name: %s\n", | |
574 | arg); | |
575 | return CMD_WARNING; | |
576 | } | |
577 | } | |
578 | } else { | |
579 | peer = peer_lookup(bgp, &su); | |
580 | if (!peer) { | |
581 | vty_out(vty, | |
582 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
583 | arg); | |
584 | return CMD_WARNING; | |
585 | } | |
586 | } | |
7aafcaca | 587 | |
d62a17ae | 588 | if (stype == BGP_CLEAR_SOFT_NONE) |
589 | ret = peer_clear(peer, NULL); | |
590 | else | |
591 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 592 | |
d62a17ae | 593 | if (ret < 0) |
594 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 595 | |
d62a17ae | 596 | return CMD_SUCCESS; |
7aafcaca | 597 | } |
7aafcaca | 598 | |
d62a17ae | 599 | /* Clear all peer-group members. */ |
600 | if (sort == clear_group) { | |
601 | struct peer_group *group; | |
7aafcaca | 602 | |
d62a17ae | 603 | group = peer_group_lookup(bgp, arg); |
604 | if (!group) { | |
605 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
606 | return CMD_WARNING; | |
607 | } | |
608 | ||
609 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
610 | if (stype == BGP_CLEAR_SOFT_NONE) { | |
611 | peer_clear(peer, NULL); | |
612 | continue; | |
613 | } | |
614 | ||
615 | if (!peer->afc[afi][safi]) | |
616 | continue; | |
617 | ||
618 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 619 | |
d62a17ae | 620 | if (ret < 0) |
621 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
622 | } | |
623 | return CMD_SUCCESS; | |
7aafcaca | 624 | } |
7aafcaca | 625 | |
d62a17ae | 626 | if (sort == clear_external) { |
627 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
628 | if (peer->sort == BGP_PEER_IBGP) | |
629 | continue; | |
7aafcaca | 630 | |
d62a17ae | 631 | if (stype == BGP_CLEAR_SOFT_NONE) |
632 | ret = peer_clear(peer, &nnode); | |
633 | else | |
634 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 635 | |
d62a17ae | 636 | if (ret < 0) |
637 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
638 | } | |
639 | return CMD_SUCCESS; | |
640 | } | |
641 | ||
642 | if (sort == clear_as) { | |
643 | as_t as; | |
644 | int find = 0; | |
645 | ||
646 | as = strtoul(arg, NULL, 10); | |
647 | ||
648 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
649 | if (peer->as != as) | |
650 | continue; | |
651 | ||
652 | find = 1; | |
653 | if (stype == BGP_CLEAR_SOFT_NONE) | |
654 | ret = peer_clear(peer, &nnode); | |
655 | else | |
656 | ret = peer_clear_soft(peer, afi, safi, stype); | |
657 | ||
658 | if (ret < 0) | |
659 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
660 | } | |
661 | if (!find) | |
662 | vty_out(vty, | |
663 | "%%BGP: No peer is configured with AS %s\n", | |
664 | arg); | |
665 | return CMD_SUCCESS; | |
666 | } | |
667 | ||
668 | return CMD_SUCCESS; | |
669 | } | |
670 | ||
671 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
672 | safi_t safi, enum clear_sort sort, | |
673 | enum bgp_clear_type stype, const char *arg) | |
674 | { | |
675 | struct bgp *bgp; | |
676 | ||
677 | /* BGP structure lookup. */ | |
678 | if (name) { | |
679 | bgp = bgp_lookup_by_name(name); | |
680 | if (bgp == NULL) { | |
681 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
682 | return CMD_WARNING; | |
683 | } | |
684 | } else { | |
685 | bgp = bgp_get_default(); | |
686 | if (bgp == NULL) { | |
687 | vty_out(vty, "No BGP process is configured\n"); | |
688 | return CMD_WARNING; | |
689 | } | |
690 | } | |
691 | ||
692 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
693 | } |
694 | ||
695 | /* clear soft inbound */ | |
d62a17ae | 696 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 697 | { |
d62a17ae | 698 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
699 | BGP_CLEAR_SOFT_IN, NULL); | |
700 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
701 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
702 | } |
703 | ||
704 | /* clear soft outbound */ | |
d62a17ae | 705 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 706 | { |
d62a17ae | 707 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
708 | BGP_CLEAR_SOFT_OUT, NULL); | |
709 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
710 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
711 | } |
712 | ||
713 | ||
f787d7a0 DL |
714 | #ifndef VTYSH_EXTRACT_PL |
715 | #include "bgp_vty_clippy.c" | |
716 | #endif | |
717 | ||
718e3744 | 718 | /* BGP global configuration. */ |
719 | ||
720 | DEFUN (bgp_multiple_instance_func, | |
721 | bgp_multiple_instance_cmd, | |
722 | "bgp multiple-instance", | |
723 | BGP_STR | |
724 | "Enable bgp multiple instance\n") | |
725 | { | |
d62a17ae | 726 | bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE); |
727 | return CMD_SUCCESS; | |
718e3744 | 728 | } |
729 | ||
730 | DEFUN (no_bgp_multiple_instance, | |
731 | no_bgp_multiple_instance_cmd, | |
732 | "no bgp multiple-instance", | |
733 | NO_STR | |
734 | BGP_STR | |
735 | "BGP multiple instance\n") | |
736 | { | |
d62a17ae | 737 | int ret; |
718e3744 | 738 | |
d62a17ae | 739 | ret = bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE); |
740 | if (ret < 0) { | |
741 | vty_out(vty, "%% There are more than two BGP instances\n"); | |
742 | return CMD_WARNING_CONFIG_FAILED; | |
743 | } | |
744 | return CMD_SUCCESS; | |
718e3744 | 745 | } |
746 | ||
747 | DEFUN (bgp_config_type, | |
748 | bgp_config_type_cmd, | |
6147e2c6 | 749 | "bgp config-type <cisco|zebra>", |
718e3744 | 750 | BGP_STR |
751 | "Configuration type\n" | |
752 | "cisco\n" | |
753 | "zebra\n") | |
754 | { | |
d62a17ae | 755 | int idx = 0; |
756 | if (argv_find(argv, argc, "cisco", &idx)) | |
757 | bgp_option_set(BGP_OPT_CONFIG_CISCO); | |
758 | else | |
759 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); | |
718e3744 | 760 | |
d62a17ae | 761 | return CMD_SUCCESS; |
718e3744 | 762 | } |
763 | ||
764 | DEFUN (no_bgp_config_type, | |
765 | no_bgp_config_type_cmd, | |
c7178fe7 | 766 | "no bgp config-type [<cisco|zebra>]", |
718e3744 | 767 | NO_STR |
768 | BGP_STR | |
838758ac DW |
769 | "Display configuration type\n" |
770 | "cisco\n" | |
771 | "zebra\n") | |
718e3744 | 772 | { |
d62a17ae | 773 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
774 | return CMD_SUCCESS; | |
718e3744 | 775 | } |
776 | ||
813d4307 | 777 | |
718e3744 | 778 | DEFUN (no_synchronization, |
779 | no_synchronization_cmd, | |
780 | "no synchronization", | |
781 | NO_STR | |
782 | "Perform IGP synchronization\n") | |
783 | { | |
d62a17ae | 784 | return CMD_SUCCESS; |
718e3744 | 785 | } |
786 | ||
787 | DEFUN (no_auto_summary, | |
788 | no_auto_summary_cmd, | |
789 | "no auto-summary", | |
790 | NO_STR | |
791 | "Enable automatic network number summarization\n") | |
792 | { | |
d62a17ae | 793 | return CMD_SUCCESS; |
718e3744 | 794 | } |
3d515fd9 | 795 | |
718e3744 | 796 | /* "router bgp" commands. */ |
505e5056 | 797 | DEFUN_NOSH (router_bgp, |
f412b39a | 798 | router_bgp_cmd, |
18c57037 | 799 | "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 800 | ROUTER_STR |
801 | BGP_STR | |
31500417 DW |
802 | AS_STR |
803 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 804 | { |
d62a17ae | 805 | int idx_asn = 2; |
806 | int idx_view_vrf = 3; | |
807 | int idx_vrf = 4; | |
808 | int ret; | |
809 | as_t as; | |
810 | struct bgp *bgp; | |
811 | const char *name = NULL; | |
812 | enum bgp_instance_type inst_type; | |
813 | ||
814 | // "router bgp" without an ASN | |
815 | if (argc == 2) { | |
816 | // Pending: Make VRF option available for ASN less config | |
817 | bgp = bgp_get_default(); | |
818 | ||
819 | if (bgp == NULL) { | |
820 | vty_out(vty, "%% No BGP process is configured\n"); | |
821 | return CMD_WARNING_CONFIG_FAILED; | |
822 | } | |
823 | ||
824 | if (listcount(bm->bgp) > 1) { | |
825 | vty_out(vty, | |
826 | "%% Multiple BGP processes are configured\n"); | |
827 | return CMD_WARNING_CONFIG_FAILED; | |
828 | } | |
829 | } | |
830 | ||
831 | // "router bgp X" | |
832 | else { | |
833 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
834 | ||
835 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
836 | if (argc > 3) { | |
837 | name = argv[idx_vrf]->arg; | |
838 | ||
839 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) | |
840 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
841 | else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
842 | inst_type = BGP_INSTANCE_TYPE_VIEW; | |
843 | } | |
844 | ||
845 | ret = bgp_get(&bgp, &as, name, inst_type); | |
846 | switch (ret) { | |
847 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
848 | vty_out(vty, | |
849 | "Please specify 'bgp multiple-instance' first\n"); | |
850 | return CMD_WARNING_CONFIG_FAILED; | |
851 | case BGP_ERR_AS_MISMATCH: | |
852 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
853 | return CMD_WARNING_CONFIG_FAILED; | |
854 | case BGP_ERR_INSTANCE_MISMATCH: | |
855 | vty_out(vty, | |
856 | "BGP instance name and AS number mismatch\n"); | |
857 | vty_out(vty, | |
858 | "BGP instance is already running; AS is %u\n", | |
859 | as); | |
860 | return CMD_WARNING_CONFIG_FAILED; | |
861 | } | |
862 | ||
863 | /* Pending: handle when user tries to change a view to vrf n vv. | |
864 | */ | |
865 | } | |
866 | ||
867 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
868 | ||
869 | return CMD_SUCCESS; | |
718e3744 | 870 | } |
871 | ||
718e3744 | 872 | /* "no router bgp" commands. */ |
873 | DEFUN (no_router_bgp, | |
874 | no_router_bgp_cmd, | |
18c57037 | 875 | "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 876 | NO_STR |
877 | ROUTER_STR | |
878 | BGP_STR | |
31500417 DW |
879 | AS_STR |
880 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 881 | { |
d62a17ae | 882 | int idx_asn = 3; |
883 | int idx_vrf = 5; | |
884 | as_t as; | |
885 | struct bgp *bgp; | |
886 | const char *name = NULL; | |
718e3744 | 887 | |
d62a17ae | 888 | // "no router bgp" without an ASN |
889 | if (argc == 3) { | |
890 | // Pending: Make VRF option available for ASN less config | |
891 | bgp = bgp_get_default(); | |
718e3744 | 892 | |
d62a17ae | 893 | if (bgp == NULL) { |
894 | vty_out(vty, "%% No BGP process is configured\n"); | |
895 | return CMD_WARNING_CONFIG_FAILED; | |
896 | } | |
7fb21a9f | 897 | |
d62a17ae | 898 | if (listcount(bm->bgp) > 1) { |
899 | vty_out(vty, | |
900 | "%% Multiple BGP processes are configured\n"); | |
901 | return CMD_WARNING_CONFIG_FAILED; | |
902 | } | |
903 | } else { | |
904 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 905 | |
d62a17ae | 906 | if (argc > 4) |
907 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 908 | |
d62a17ae | 909 | /* Lookup bgp structure. */ |
910 | bgp = bgp_lookup(as, name); | |
911 | if (!bgp) { | |
912 | vty_out(vty, "%% Can't find BGP instance\n"); | |
913 | return CMD_WARNING_CONFIG_FAILED; | |
914 | } | |
915 | } | |
718e3744 | 916 | |
d62a17ae | 917 | bgp_delete(bgp); |
718e3744 | 918 | |
d62a17ae | 919 | return CMD_SUCCESS; |
718e3744 | 920 | } |
921 | ||
6b0655a2 | 922 | |
718e3744 | 923 | /* BGP router-id. */ |
924 | ||
f787d7a0 | 925 | DEFPY (bgp_router_id, |
718e3744 | 926 | bgp_router_id_cmd, |
927 | "bgp router-id A.B.C.D", | |
928 | BGP_STR | |
929 | "Override configured router identifier\n" | |
930 | "Manually configured router identifier\n") | |
931 | { | |
d62a17ae | 932 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
933 | bgp_router_id_static_set(bgp, router_id); | |
934 | return CMD_SUCCESS; | |
718e3744 | 935 | } |
936 | ||
f787d7a0 | 937 | DEFPY (no_bgp_router_id, |
718e3744 | 938 | no_bgp_router_id_cmd, |
31500417 | 939 | "no bgp router-id [A.B.C.D]", |
718e3744 | 940 | NO_STR |
941 | BGP_STR | |
31500417 DW |
942 | "Override configured router identifier\n" |
943 | "Manually configured router identifier\n") | |
718e3744 | 944 | { |
d62a17ae | 945 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 946 | |
d62a17ae | 947 | if (router_id_str) { |
948 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
949 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
950 | return CMD_WARNING_CONFIG_FAILED; | |
951 | } | |
e018c7cc | 952 | } |
718e3744 | 953 | |
d62a17ae | 954 | router_id.s_addr = 0; |
955 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 956 | |
d62a17ae | 957 | return CMD_SUCCESS; |
718e3744 | 958 | } |
959 | ||
6b0655a2 | 960 | |
718e3744 | 961 | /* BGP Cluster ID. */ |
718e3744 | 962 | DEFUN (bgp_cluster_id, |
963 | bgp_cluster_id_cmd, | |
838758ac | 964 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 965 | BGP_STR |
966 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
967 | "Route-Reflector Cluster-id in IP address format\n" |
968 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 969 | { |
d62a17ae | 970 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
971 | int idx_ipv4 = 2; | |
972 | int ret; | |
973 | struct in_addr cluster; | |
718e3744 | 974 | |
d62a17ae | 975 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
976 | if (!ret) { | |
977 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
978 | return CMD_WARNING_CONFIG_FAILED; | |
979 | } | |
718e3744 | 980 | |
d62a17ae | 981 | bgp_cluster_id_set(bgp, &cluster); |
982 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 983 | |
d62a17ae | 984 | return CMD_SUCCESS; |
718e3744 | 985 | } |
986 | ||
718e3744 | 987 | DEFUN (no_bgp_cluster_id, |
988 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 989 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 990 | NO_STR |
991 | BGP_STR | |
838758ac DW |
992 | "Configure Route-Reflector Cluster-id\n" |
993 | "Route-Reflector Cluster-id in IP address format\n" | |
994 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 995 | { |
d62a17ae | 996 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
997 | bgp_cluster_id_unset(bgp); | |
998 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 999 | |
d62a17ae | 1000 | return CMD_SUCCESS; |
718e3744 | 1001 | } |
1002 | ||
718e3744 | 1003 | DEFUN (bgp_confederation_identifier, |
1004 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1005 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1006 | "BGP specific commands\n" |
1007 | "AS confederation parameters\n" | |
1008 | "AS number\n" | |
1009 | "Set routing domain confederation AS\n") | |
1010 | { | |
d62a17ae | 1011 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1012 | int idx_number = 3; | |
1013 | as_t as; | |
718e3744 | 1014 | |
d62a17ae | 1015 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1016 | |
d62a17ae | 1017 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1018 | |
d62a17ae | 1019 | return CMD_SUCCESS; |
718e3744 | 1020 | } |
1021 | ||
1022 | DEFUN (no_bgp_confederation_identifier, | |
1023 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1024 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1025 | NO_STR |
1026 | "BGP specific commands\n" | |
1027 | "AS confederation parameters\n" | |
3a2d747c QY |
1028 | "AS number\n" |
1029 | "Set routing domain confederation AS\n") | |
718e3744 | 1030 | { |
d62a17ae | 1031 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1032 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1033 | |
d62a17ae | 1034 | return CMD_SUCCESS; |
718e3744 | 1035 | } |
1036 | ||
718e3744 | 1037 | DEFUN (bgp_confederation_peers, |
1038 | bgp_confederation_peers_cmd, | |
12dcf78e | 1039 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1040 | "BGP specific commands\n" |
1041 | "AS confederation parameters\n" | |
1042 | "Peer ASs in BGP confederation\n" | |
1043 | AS_STR) | |
1044 | { | |
d62a17ae | 1045 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1046 | int idx_asn = 3; | |
1047 | as_t as; | |
1048 | int i; | |
718e3744 | 1049 | |
d62a17ae | 1050 | for (i = idx_asn; i < argc; i++) { |
1051 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1052 | |
d62a17ae | 1053 | if (bgp->as == as) { |
1054 | vty_out(vty, | |
1055 | "%% Local member-AS not allowed in confed peer list\n"); | |
1056 | continue; | |
1057 | } | |
718e3744 | 1058 | |
d62a17ae | 1059 | bgp_confederation_peers_add(bgp, as); |
1060 | } | |
1061 | return CMD_SUCCESS; | |
718e3744 | 1062 | } |
1063 | ||
1064 | DEFUN (no_bgp_confederation_peers, | |
1065 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1066 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1067 | NO_STR |
1068 | "BGP specific commands\n" | |
1069 | "AS confederation parameters\n" | |
1070 | "Peer ASs in BGP confederation\n" | |
1071 | AS_STR) | |
1072 | { | |
d62a17ae | 1073 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1074 | int idx_asn = 4; | |
1075 | as_t as; | |
1076 | int i; | |
718e3744 | 1077 | |
d62a17ae | 1078 | for (i = idx_asn; i < argc; i++) { |
1079 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1080 | |
d62a17ae | 1081 | bgp_confederation_peers_remove(bgp, as); |
1082 | } | |
1083 | return CMD_SUCCESS; | |
718e3744 | 1084 | } |
6b0655a2 | 1085 | |
5e242b0d DS |
1086 | /** |
1087 | * Central routine for maximum-paths configuration. | |
1088 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1089 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1090 | */ | |
d62a17ae | 1091 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
1092 | const char *mpaths, u_int16_t options, | |
1093 | int set) | |
1094 | { | |
1095 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1096 | u_int16_t maxpaths = 0; | |
1097 | int ret; | |
1098 | afi_t afi; | |
1099 | safi_t safi; | |
1100 | ||
1101 | afi = bgp_node_afi(vty); | |
1102 | safi = bgp_node_safi(vty); | |
1103 | ||
1104 | if (set) { | |
1105 | maxpaths = strtol(mpaths, NULL, 10); | |
1106 | if (maxpaths > multipath_num) { | |
1107 | vty_out(vty, | |
1108 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1109 | maxpaths, multipath_num); | |
1110 | return CMD_WARNING_CONFIG_FAILED; | |
1111 | } | |
1112 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1113 | options); | |
1114 | } else | |
1115 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1116 | ||
1117 | if (ret < 0) { | |
1118 | vty_out(vty, | |
1119 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1120 | (set == 1) ? "" : "un", | |
1121 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1122 | maxpaths, afi, safi); | |
1123 | return CMD_WARNING_CONFIG_FAILED; | |
1124 | } | |
1125 | ||
1126 | bgp_recalculate_all_bestpaths(bgp); | |
1127 | ||
1128 | return CMD_SUCCESS; | |
165b5fff JB |
1129 | } |
1130 | ||
abc920f8 DS |
1131 | DEFUN (bgp_maxmed_admin, |
1132 | bgp_maxmed_admin_cmd, | |
1133 | "bgp max-med administrative ", | |
1134 | BGP_STR | |
1135 | "Advertise routes with max-med\n" | |
1136 | "Administratively applied, for an indefinite period\n") | |
1137 | { | |
d62a17ae | 1138 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1139 | |
d62a17ae | 1140 | bgp->v_maxmed_admin = 1; |
1141 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1142 | |
d62a17ae | 1143 | bgp_maxmed_update(bgp); |
abc920f8 | 1144 | |
d62a17ae | 1145 | return CMD_SUCCESS; |
abc920f8 DS |
1146 | } |
1147 | ||
1148 | DEFUN (bgp_maxmed_admin_medv, | |
1149 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1150 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1151 | BGP_STR |
1152 | "Advertise routes with max-med\n" | |
1153 | "Administratively applied, for an indefinite period\n" | |
1154 | "Max MED value to be used\n") | |
1155 | { | |
d62a17ae | 1156 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1157 | int idx_number = 3; | |
abc920f8 | 1158 | |
d62a17ae | 1159 | bgp->v_maxmed_admin = 1; |
1160 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1161 | |
d62a17ae | 1162 | bgp_maxmed_update(bgp); |
abc920f8 | 1163 | |
d62a17ae | 1164 | return CMD_SUCCESS; |
abc920f8 DS |
1165 | } |
1166 | ||
1167 | DEFUN (no_bgp_maxmed_admin, | |
1168 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1169 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1170 | NO_STR |
1171 | BGP_STR | |
1172 | "Advertise routes with max-med\n" | |
838758ac DW |
1173 | "Administratively applied, for an indefinite period\n" |
1174 | "Max MED value to be used\n") | |
abc920f8 | 1175 | { |
d62a17ae | 1176 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1177 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1178 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1179 | bgp_maxmed_update(bgp); | |
abc920f8 | 1180 | |
d62a17ae | 1181 | return CMD_SUCCESS; |
abc920f8 DS |
1182 | } |
1183 | ||
abc920f8 DS |
1184 | DEFUN (bgp_maxmed_onstartup, |
1185 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1186 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1187 | BGP_STR |
1188 | "Advertise routes with max-med\n" | |
1189 | "Effective on a startup\n" | |
1190 | "Time (seconds) period for max-med\n" | |
1191 | "Max MED value to be used\n") | |
1192 | { | |
d62a17ae | 1193 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1194 | int idx = 0; | |
4668a151 | 1195 | |
d62a17ae | 1196 | argv_find(argv, argc, "(5-86400)", &idx); |
1197 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1198 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1199 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1200 | else | |
1201 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1202 | |
d62a17ae | 1203 | bgp_maxmed_update(bgp); |
abc920f8 | 1204 | |
d62a17ae | 1205 | return CMD_SUCCESS; |
abc920f8 DS |
1206 | } |
1207 | ||
1208 | DEFUN (no_bgp_maxmed_onstartup, | |
1209 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1210 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1211 | NO_STR |
1212 | BGP_STR | |
1213 | "Advertise routes with max-med\n" | |
838758ac DW |
1214 | "Effective on a startup\n" |
1215 | "Time (seconds) period for max-med\n" | |
1216 | "Max MED value to be used\n") | |
abc920f8 | 1217 | { |
d62a17ae | 1218 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1219 | |
d62a17ae | 1220 | /* Cancel max-med onstartup if its on */ |
1221 | if (bgp->t_maxmed_onstartup) { | |
1222 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1223 | bgp->maxmed_onstartup_over = 1; | |
1224 | } | |
abc920f8 | 1225 | |
d62a17ae | 1226 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1227 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1228 | |
d62a17ae | 1229 | bgp_maxmed_update(bgp); |
abc920f8 | 1230 | |
d62a17ae | 1231 | return CMD_SUCCESS; |
abc920f8 DS |
1232 | } |
1233 | ||
d62a17ae | 1234 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1235 | const char *wait) | |
f188f2c4 | 1236 | { |
d62a17ae | 1237 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1238 | u_int16_t update_delay; | |
1239 | u_int16_t establish_wait; | |
f188f2c4 | 1240 | |
d62a17ae | 1241 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1242 | |
d62a17ae | 1243 | if (!wait) /* update-delay <delay> */ |
1244 | { | |
1245 | bgp->v_update_delay = update_delay; | |
1246 | bgp->v_establish_wait = bgp->v_update_delay; | |
1247 | return CMD_SUCCESS; | |
1248 | } | |
f188f2c4 | 1249 | |
d62a17ae | 1250 | /* update-delay <delay> <establish-wait> */ |
1251 | establish_wait = atoi(wait); | |
1252 | if (update_delay < establish_wait) { | |
1253 | vty_out(vty, | |
1254 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1255 | return CMD_WARNING_CONFIG_FAILED; | |
1256 | } | |
f188f2c4 | 1257 | |
d62a17ae | 1258 | bgp->v_update_delay = update_delay; |
1259 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1260 | |
d62a17ae | 1261 | return CMD_SUCCESS; |
f188f2c4 DS |
1262 | } |
1263 | ||
d62a17ae | 1264 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1265 | { |
d62a17ae | 1266 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1267 | |
d62a17ae | 1268 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1269 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1270 | |
d62a17ae | 1271 | return CMD_SUCCESS; |
f188f2c4 DS |
1272 | } |
1273 | ||
d62a17ae | 1274 | int bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1275 | { |
d62a17ae | 1276 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1277 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1278 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1279 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1280 | vty_out(vty, "\n"); | |
1281 | } | |
f188f2c4 | 1282 | |
d62a17ae | 1283 | return 0; |
f188f2c4 DS |
1284 | } |
1285 | ||
1286 | ||
1287 | /* Update-delay configuration */ | |
1288 | DEFUN (bgp_update_delay, | |
1289 | bgp_update_delay_cmd, | |
6147e2c6 | 1290 | "update-delay (0-3600)", |
f188f2c4 DS |
1291 | "Force initial delay for best-path and updates\n" |
1292 | "Seconds\n") | |
1293 | { | |
d62a17ae | 1294 | int idx_number = 1; |
1295 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1296 | } |
1297 | ||
1298 | DEFUN (bgp_update_delay_establish_wait, | |
1299 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1300 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1301 | "Force initial delay for best-path and updates\n" |
1302 | "Seconds\n" | |
f188f2c4 DS |
1303 | "Seconds\n") |
1304 | { | |
d62a17ae | 1305 | int idx_number = 1; |
1306 | int idx_number_2 = 2; | |
1307 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1308 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1309 | } |
1310 | ||
1311 | /* Update-delay deconfiguration */ | |
1312 | DEFUN (no_bgp_update_delay, | |
1313 | no_bgp_update_delay_cmd, | |
838758ac DW |
1314 | "no update-delay [(0-3600) [(1-3600)]]", |
1315 | NO_STR | |
f188f2c4 | 1316 | "Force initial delay for best-path and updates\n" |
838758ac | 1317 | "Seconds\n" |
7111c1a0 | 1318 | "Seconds\n") |
f188f2c4 | 1319 | { |
d62a17ae | 1320 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1321 | } |
1322 | ||
5e242b0d | 1323 | |
d62a17ae | 1324 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, const char *num, |
1325 | char set) | |
cb1faec9 | 1326 | { |
d62a17ae | 1327 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1328 | |
d62a17ae | 1329 | if (set) |
1330 | bgp->wpkt_quanta = strtoul(num, NULL, 10); | |
1331 | else | |
1332 | bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX; | |
cb1faec9 | 1333 | |
d62a17ae | 1334 | return CMD_SUCCESS; |
cb1faec9 DS |
1335 | } |
1336 | ||
d62a17ae | 1337 | int bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1338 | { |
d62a17ae | 1339 | if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX) |
1340 | vty_out(vty, " write-quanta %d\n", bgp->wpkt_quanta); | |
cb1faec9 | 1341 | |
d62a17ae | 1342 | return 0; |
cb1faec9 DS |
1343 | } |
1344 | ||
1345 | ||
1346 | /* Update-delay configuration */ | |
1347 | DEFUN (bgp_wpkt_quanta, | |
1348 | bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1349 | "write-quanta (1-10000)", |
cb1faec9 DS |
1350 | "How many packets to write to peer socket per run\n" |
1351 | "Number of packets\n") | |
1352 | { | |
d62a17ae | 1353 | int idx_number = 1; |
1354 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1355 | } |
1356 | ||
1357 | /* Update-delay deconfiguration */ | |
1358 | DEFUN (no_bgp_wpkt_quanta, | |
1359 | no_bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1360 | "no write-quanta (1-10000)", |
d7fa34c1 | 1361 | NO_STR |
cb1faec9 DS |
1362 | "How many packets to write to peer socket per run\n" |
1363 | "Number of packets\n") | |
1364 | { | |
d62a17ae | 1365 | int idx_number = 2; |
1366 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1367 | } |
1368 | ||
d62a17ae | 1369 | int bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1370 | { |
d62a17ae | 1371 | if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME) |
1372 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); | |
3f9c7369 | 1373 | |
d62a17ae | 1374 | return 0; |
3f9c7369 DS |
1375 | } |
1376 | ||
1377 | ||
1378 | DEFUN (bgp_coalesce_time, | |
1379 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1380 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1381 | "Subgroup coalesce timer\n" |
1382 | "Subgroup coalesce timer value (in ms)\n") | |
1383 | { | |
d62a17ae | 1384 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1385 | |
d62a17ae | 1386 | int idx = 0; |
1387 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
1388 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); | |
1389 | return CMD_SUCCESS; | |
3f9c7369 DS |
1390 | } |
1391 | ||
1392 | DEFUN (no_bgp_coalesce_time, | |
1393 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1394 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1395 | NO_STR |
3f9c7369 DS |
1396 | "Subgroup coalesce timer\n" |
1397 | "Subgroup coalesce timer value (in ms)\n") | |
1398 | { | |
d62a17ae | 1399 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1400 | |
d62a17ae | 1401 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1402 | return CMD_SUCCESS; | |
3f9c7369 DS |
1403 | } |
1404 | ||
5e242b0d DS |
1405 | /* Maximum-paths configuration */ |
1406 | DEFUN (bgp_maxpaths, | |
1407 | bgp_maxpaths_cmd, | |
6319fd63 | 1408 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1409 | "Forward packets over multiple paths\n" |
1410 | "Number of paths\n") | |
1411 | { | |
d62a17ae | 1412 | int idx_number = 1; |
1413 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1414 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1415 | } |
1416 | ||
d62a17ae | 1417 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1418 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1419 | "Forward packets over multiple paths\n" | |
1420 | "Number of paths\n") | |
596c17ba | 1421 | |
165b5fff JB |
1422 | DEFUN (bgp_maxpaths_ibgp, |
1423 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1424 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1425 | "Forward packets over multiple paths\n" |
1426 | "iBGP-multipath\n" | |
1427 | "Number of paths\n") | |
1428 | { | |
d62a17ae | 1429 | int idx_number = 2; |
1430 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1431 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1432 | } |
165b5fff | 1433 | |
d62a17ae | 1434 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1435 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1436 | "Forward packets over multiple paths\n" | |
1437 | "iBGP-multipath\n" | |
1438 | "Number of paths\n") | |
596c17ba | 1439 | |
5e242b0d DS |
1440 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1441 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1442 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1443 | "Forward packets over multiple paths\n" |
1444 | "iBGP-multipath\n" | |
1445 | "Number of paths\n" | |
1446 | "Match the cluster length\n") | |
1447 | { | |
d62a17ae | 1448 | int idx_number = 2; |
1449 | return bgp_maxpaths_config_vty( | |
1450 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1451 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1452 | } |
1453 | ||
d62a17ae | 1454 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1455 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1456 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1457 | "Forward packets over multiple paths\n" | |
1458 | "iBGP-multipath\n" | |
1459 | "Number of paths\n" | |
1460 | "Match the cluster length\n") | |
596c17ba | 1461 | |
165b5fff JB |
1462 | DEFUN (no_bgp_maxpaths, |
1463 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1464 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1465 | NO_STR |
1466 | "Forward packets over multiple paths\n" | |
1467 | "Number of paths\n") | |
1468 | { | |
d62a17ae | 1469 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1470 | } |
1471 | ||
d62a17ae | 1472 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
9d303b37 | 1473 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1474 | "Forward packets over multiple paths\n" |
1475 | "Number of paths\n") | |
596c17ba | 1476 | |
165b5fff JB |
1477 | DEFUN (no_bgp_maxpaths_ibgp, |
1478 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1479 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1480 | NO_STR |
1481 | "Forward packets over multiple paths\n" | |
1482 | "iBGP-multipath\n" | |
838758ac DW |
1483 | "Number of paths\n" |
1484 | "Match the cluster length\n") | |
165b5fff | 1485 | { |
d62a17ae | 1486 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1487 | } |
1488 | ||
d62a17ae | 1489 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1490 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1491 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1492 | NO_STR | |
1493 | "Forward packets over multiple paths\n" | |
1494 | "iBGP-multipath\n" | |
1495 | "Number of paths\n" | |
1496 | "Match the cluster length\n") | |
596c17ba | 1497 | |
d62a17ae | 1498 | int bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi, |
1499 | safi_t safi, int *write) | |
165b5fff | 1500 | { |
d62a17ae | 1501 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
1502 | bgp_config_write_family_header(vty, afi, safi, write); | |
1503 | vty_out(vty, " maximum-paths %d\n", | |
1504 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1505 | } | |
165b5fff | 1506 | |
d62a17ae | 1507 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
1508 | bgp_config_write_family_header(vty, afi, safi, write); | |
1509 | vty_out(vty, " maximum-paths ibgp %d", | |
1510 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1511 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1512 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1513 | vty_out(vty, " equal-cluster-length"); | |
1514 | vty_out(vty, "\n"); | |
1515 | } | |
165b5fff | 1516 | |
d62a17ae | 1517 | return 0; |
165b5fff | 1518 | } |
6b0655a2 | 1519 | |
718e3744 | 1520 | /* BGP timers. */ |
1521 | ||
1522 | DEFUN (bgp_timers, | |
1523 | bgp_timers_cmd, | |
6147e2c6 | 1524 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1525 | "Adjust routing timers\n" |
1526 | "BGP timers\n" | |
1527 | "Keepalive interval\n" | |
1528 | "Holdtime\n") | |
1529 | { | |
d62a17ae | 1530 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1531 | int idx_number = 2; | |
1532 | int idx_number_2 = 3; | |
1533 | unsigned long keepalive = 0; | |
1534 | unsigned long holdtime = 0; | |
718e3744 | 1535 | |
d62a17ae | 1536 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1537 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1538 | |
d62a17ae | 1539 | /* Holdtime value check. */ |
1540 | if (holdtime < 3 && holdtime != 0) { | |
1541 | vty_out(vty, | |
1542 | "%% hold time value must be either 0 or greater than 3\n"); | |
1543 | return CMD_WARNING_CONFIG_FAILED; | |
1544 | } | |
718e3744 | 1545 | |
d62a17ae | 1546 | bgp_timers_set(bgp, keepalive, holdtime); |
718e3744 | 1547 | |
d62a17ae | 1548 | return CMD_SUCCESS; |
718e3744 | 1549 | } |
1550 | ||
1551 | DEFUN (no_bgp_timers, | |
1552 | no_bgp_timers_cmd, | |
838758ac | 1553 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1554 | NO_STR |
1555 | "Adjust routing timers\n" | |
838758ac DW |
1556 | "BGP timers\n" |
1557 | "Keepalive interval\n" | |
1558 | "Holdtime\n") | |
718e3744 | 1559 | { |
d62a17ae | 1560 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1561 | bgp_timers_unset(bgp); | |
718e3744 | 1562 | |
d62a17ae | 1563 | return CMD_SUCCESS; |
718e3744 | 1564 | } |
1565 | ||
6b0655a2 | 1566 | |
718e3744 | 1567 | DEFUN (bgp_client_to_client_reflection, |
1568 | bgp_client_to_client_reflection_cmd, | |
1569 | "bgp client-to-client reflection", | |
1570 | "BGP specific commands\n" | |
1571 | "Configure client to client route reflection\n" | |
1572 | "reflection of routes allowed\n") | |
1573 | { | |
d62a17ae | 1574 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1575 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1576 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1577 | |
d62a17ae | 1578 | return CMD_SUCCESS; |
718e3744 | 1579 | } |
1580 | ||
1581 | DEFUN (no_bgp_client_to_client_reflection, | |
1582 | no_bgp_client_to_client_reflection_cmd, | |
1583 | "no bgp client-to-client reflection", | |
1584 | NO_STR | |
1585 | "BGP specific commands\n" | |
1586 | "Configure client to client route reflection\n" | |
1587 | "reflection of routes allowed\n") | |
1588 | { | |
d62a17ae | 1589 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1590 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1591 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1592 | |
d62a17ae | 1593 | return CMD_SUCCESS; |
718e3744 | 1594 | } |
1595 | ||
1596 | /* "bgp always-compare-med" configuration. */ | |
1597 | DEFUN (bgp_always_compare_med, | |
1598 | bgp_always_compare_med_cmd, | |
1599 | "bgp always-compare-med", | |
1600 | "BGP specific commands\n" | |
1601 | "Allow comparing MED from different neighbors\n") | |
1602 | { | |
d62a17ae | 1603 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1604 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1605 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1606 | |
d62a17ae | 1607 | return CMD_SUCCESS; |
718e3744 | 1608 | } |
1609 | ||
1610 | DEFUN (no_bgp_always_compare_med, | |
1611 | no_bgp_always_compare_med_cmd, | |
1612 | "no bgp always-compare-med", | |
1613 | NO_STR | |
1614 | "BGP specific commands\n" | |
1615 | "Allow comparing MED from different neighbors\n") | |
1616 | { | |
d62a17ae | 1617 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1618 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1619 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1620 | |
d62a17ae | 1621 | return CMD_SUCCESS; |
718e3744 | 1622 | } |
6b0655a2 | 1623 | |
718e3744 | 1624 | /* "bgp deterministic-med" configuration. */ |
1625 | DEFUN (bgp_deterministic_med, | |
1626 | bgp_deterministic_med_cmd, | |
1627 | "bgp deterministic-med", | |
1628 | "BGP specific commands\n" | |
1629 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1630 | { | |
d62a17ae | 1631 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 1632 | |
d62a17ae | 1633 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
1634 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1635 | bgp_recalculate_all_bestpaths(bgp); | |
1636 | } | |
7aafcaca | 1637 | |
d62a17ae | 1638 | return CMD_SUCCESS; |
718e3744 | 1639 | } |
1640 | ||
1641 | DEFUN (no_bgp_deterministic_med, | |
1642 | no_bgp_deterministic_med_cmd, | |
1643 | "no bgp deterministic-med", | |
1644 | NO_STR | |
1645 | "BGP specific commands\n" | |
1646 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1647 | { | |
d62a17ae | 1648 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1649 | int bestpath_per_as_used; | |
1650 | afi_t afi; | |
1651 | safi_t safi; | |
1652 | struct peer *peer; | |
1653 | struct listnode *node, *nnode; | |
1654 | ||
1655 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
1656 | bestpath_per_as_used = 0; | |
1657 | ||
1658 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1659 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
1660 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; | |
1661 | safi++) | |
1662 | if (CHECK_FLAG( | |
1663 | peer->af_flags[afi][safi], | |
1664 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) { | |
1665 | bestpath_per_as_used = 1; | |
1666 | break; | |
1667 | } | |
1668 | ||
1669 | if (bestpath_per_as_used) | |
1670 | break; | |
1671 | } | |
1672 | ||
1673 | if (bestpath_per_as_used) { | |
1674 | vty_out(vty, | |
1675 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
1676 | return CMD_WARNING_CONFIG_FAILED; | |
1677 | } else { | |
1678 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1679 | bgp_recalculate_all_bestpaths(bgp); | |
1680 | } | |
1681 | } | |
1682 | ||
1683 | return CMD_SUCCESS; | |
718e3744 | 1684 | } |
538621f2 | 1685 | |
1686 | /* "bgp graceful-restart" configuration. */ | |
1687 | DEFUN (bgp_graceful_restart, | |
1688 | bgp_graceful_restart_cmd, | |
1689 | "bgp graceful-restart", | |
1690 | "BGP specific commands\n" | |
1691 | "Graceful restart capability parameters\n") | |
1692 | { | |
d62a17ae | 1693 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1694 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1695 | return CMD_SUCCESS; | |
538621f2 | 1696 | } |
1697 | ||
1698 | DEFUN (no_bgp_graceful_restart, | |
1699 | no_bgp_graceful_restart_cmd, | |
1700 | "no bgp graceful-restart", | |
1701 | NO_STR | |
1702 | "BGP specific commands\n" | |
1703 | "Graceful restart capability parameters\n") | |
1704 | { | |
d62a17ae | 1705 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1706 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1707 | return CMD_SUCCESS; | |
538621f2 | 1708 | } |
1709 | ||
93406d87 | 1710 | DEFUN (bgp_graceful_restart_stalepath_time, |
1711 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1712 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1713 | "BGP specific commands\n" |
1714 | "Graceful restart capability parameters\n" | |
1715 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1716 | "Delay value (seconds)\n") | |
1717 | { | |
d62a17ae | 1718 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1719 | int idx_number = 3; | |
1720 | u_int32_t stalepath; | |
93406d87 | 1721 | |
d62a17ae | 1722 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
1723 | bgp->stalepath_time = stalepath; | |
1724 | return CMD_SUCCESS; | |
93406d87 | 1725 | } |
1726 | ||
eb6f1b41 PG |
1727 | DEFUN (bgp_graceful_restart_restart_time, |
1728 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1729 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1730 | "BGP specific commands\n" |
1731 | "Graceful restart capability parameters\n" | |
1732 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1733 | "Delay value (seconds)\n") | |
1734 | { | |
d62a17ae | 1735 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1736 | int idx_number = 3; | |
1737 | u_int32_t restart; | |
eb6f1b41 | 1738 | |
d62a17ae | 1739 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
1740 | bgp->restart_time = restart; | |
1741 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1742 | } |
1743 | ||
93406d87 | 1744 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1745 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1746 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1747 | NO_STR |
1748 | "BGP specific commands\n" | |
1749 | "Graceful restart capability parameters\n" | |
838758ac DW |
1750 | "Set the max time to hold onto restarting peer's stale paths\n" |
1751 | "Delay value (seconds)\n") | |
93406d87 | 1752 | { |
d62a17ae | 1753 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1754 | |
d62a17ae | 1755 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
1756 | return CMD_SUCCESS; | |
93406d87 | 1757 | } |
1758 | ||
eb6f1b41 PG |
1759 | DEFUN (no_bgp_graceful_restart_restart_time, |
1760 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1761 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1762 | NO_STR |
1763 | "BGP specific commands\n" | |
1764 | "Graceful restart capability parameters\n" | |
838758ac DW |
1765 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1766 | "Delay value (seconds)\n") | |
eb6f1b41 | 1767 | { |
d62a17ae | 1768 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 1769 | |
d62a17ae | 1770 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
1771 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1772 | } |
1773 | ||
43fc21b3 JC |
1774 | DEFUN (bgp_graceful_restart_preserve_fw, |
1775 | bgp_graceful_restart_preserve_fw_cmd, | |
1776 | "bgp graceful-restart preserve-fw-state", | |
1777 | "BGP specific commands\n" | |
1778 | "Graceful restart capability parameters\n" | |
1779 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1780 | { | |
d62a17ae | 1781 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1782 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1783 | return CMD_SUCCESS; | |
43fc21b3 JC |
1784 | } |
1785 | ||
1786 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
1787 | no_bgp_graceful_restart_preserve_fw_cmd, | |
1788 | "no bgp graceful-restart preserve-fw-state", | |
1789 | NO_STR | |
1790 | "BGP specific commands\n" | |
1791 | "Graceful restart capability parameters\n" | |
1792 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1793 | { | |
d62a17ae | 1794 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1795 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1796 | return CMD_SUCCESS; | |
43fc21b3 JC |
1797 | } |
1798 | ||
718e3744 | 1799 | /* "bgp fast-external-failover" configuration. */ |
1800 | DEFUN (bgp_fast_external_failover, | |
1801 | bgp_fast_external_failover_cmd, | |
1802 | "bgp fast-external-failover", | |
1803 | BGP_STR | |
1804 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1805 | { | |
d62a17ae | 1806 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1807 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
1808 | return CMD_SUCCESS; | |
718e3744 | 1809 | } |
1810 | ||
1811 | DEFUN (no_bgp_fast_external_failover, | |
1812 | no_bgp_fast_external_failover_cmd, | |
1813 | "no bgp fast-external-failover", | |
1814 | NO_STR | |
1815 | BGP_STR | |
1816 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1817 | { | |
d62a17ae | 1818 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1819 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
1820 | return CMD_SUCCESS; | |
718e3744 | 1821 | } |
6b0655a2 | 1822 | |
718e3744 | 1823 | /* "bgp enforce-first-as" configuration. */ |
1824 | DEFUN (bgp_enforce_first_as, | |
1825 | bgp_enforce_first_as_cmd, | |
1826 | "bgp enforce-first-as", | |
1827 | BGP_STR | |
1828 | "Enforce the first AS for EBGP routes\n") | |
1829 | { | |
d62a17ae | 1830 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1831 | bgp_flag_set(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
1832 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 1833 | |
d62a17ae | 1834 | return CMD_SUCCESS; |
718e3744 | 1835 | } |
1836 | ||
1837 | DEFUN (no_bgp_enforce_first_as, | |
1838 | no_bgp_enforce_first_as_cmd, | |
1839 | "no bgp enforce-first-as", | |
1840 | NO_STR | |
1841 | BGP_STR | |
1842 | "Enforce the first AS for EBGP routes\n") | |
1843 | { | |
d62a17ae | 1844 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1845 | bgp_flag_unset(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
1846 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 1847 | |
d62a17ae | 1848 | return CMD_SUCCESS; |
718e3744 | 1849 | } |
6b0655a2 | 1850 | |
718e3744 | 1851 | /* "bgp bestpath compare-routerid" configuration. */ |
1852 | DEFUN (bgp_bestpath_compare_router_id, | |
1853 | bgp_bestpath_compare_router_id_cmd, | |
1854 | "bgp bestpath compare-routerid", | |
1855 | "BGP specific commands\n" | |
1856 | "Change the default bestpath selection\n" | |
1857 | "Compare router-id for identical EBGP paths\n") | |
1858 | { | |
d62a17ae | 1859 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1860 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
1861 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1862 | |
d62a17ae | 1863 | return CMD_SUCCESS; |
718e3744 | 1864 | } |
1865 | ||
1866 | DEFUN (no_bgp_bestpath_compare_router_id, | |
1867 | no_bgp_bestpath_compare_router_id_cmd, | |
1868 | "no bgp bestpath compare-routerid", | |
1869 | NO_STR | |
1870 | "BGP specific commands\n" | |
1871 | "Change the default bestpath selection\n" | |
1872 | "Compare router-id for identical EBGP paths\n") | |
1873 | { | |
d62a17ae | 1874 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1875 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
1876 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1877 | |
d62a17ae | 1878 | return CMD_SUCCESS; |
718e3744 | 1879 | } |
6b0655a2 | 1880 | |
718e3744 | 1881 | /* "bgp bestpath as-path ignore" configuration. */ |
1882 | DEFUN (bgp_bestpath_aspath_ignore, | |
1883 | bgp_bestpath_aspath_ignore_cmd, | |
1884 | "bgp bestpath as-path ignore", | |
1885 | "BGP specific commands\n" | |
1886 | "Change the default bestpath selection\n" | |
1887 | "AS-path attribute\n" | |
1888 | "Ignore as-path length in selecting a route\n") | |
1889 | { | |
d62a17ae | 1890 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1891 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
1892 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1893 | |
d62a17ae | 1894 | return CMD_SUCCESS; |
718e3744 | 1895 | } |
1896 | ||
1897 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
1898 | no_bgp_bestpath_aspath_ignore_cmd, | |
1899 | "no bgp bestpath as-path ignore", | |
1900 | NO_STR | |
1901 | "BGP specific commands\n" | |
1902 | "Change the default bestpath selection\n" | |
1903 | "AS-path attribute\n" | |
1904 | "Ignore as-path length in selecting a route\n") | |
1905 | { | |
d62a17ae | 1906 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1907 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
1908 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1909 | |
d62a17ae | 1910 | return CMD_SUCCESS; |
718e3744 | 1911 | } |
6b0655a2 | 1912 | |
6811845b | 1913 | /* "bgp bestpath as-path confed" configuration. */ |
1914 | DEFUN (bgp_bestpath_aspath_confed, | |
1915 | bgp_bestpath_aspath_confed_cmd, | |
1916 | "bgp bestpath as-path confed", | |
1917 | "BGP specific commands\n" | |
1918 | "Change the default bestpath selection\n" | |
1919 | "AS-path attribute\n" | |
1920 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
1921 | { | |
d62a17ae | 1922 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1923 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
1924 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1925 | |
d62a17ae | 1926 | return CMD_SUCCESS; |
6811845b | 1927 | } |
1928 | ||
1929 | DEFUN (no_bgp_bestpath_aspath_confed, | |
1930 | no_bgp_bestpath_aspath_confed_cmd, | |
1931 | "no bgp bestpath as-path confed", | |
1932 | NO_STR | |
1933 | "BGP specific commands\n" | |
1934 | "Change the default bestpath selection\n" | |
1935 | "AS-path attribute\n" | |
1936 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
1937 | { | |
d62a17ae | 1938 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1939 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
1940 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1941 | |
d62a17ae | 1942 | return CMD_SUCCESS; |
6811845b | 1943 | } |
6b0655a2 | 1944 | |
2fdd455c PM |
1945 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
1946 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
1947 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 1948 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
1949 | "BGP specific commands\n" |
1950 | "Change the default bestpath selection\n" | |
1951 | "AS-path attribute\n" | |
1952 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 1953 | "Generate an AS_SET\n" |
16fc1eec DS |
1954 | "Do not generate an AS_SET\n") |
1955 | { | |
d62a17ae | 1956 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1957 | int idx = 0; | |
1958 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 1959 | |
d62a17ae | 1960 | /* no-as-set is now the default behavior so we can silently |
1961 | * ignore it */ | |
1962 | if (argv_find(argv, argc, "as-set", &idx)) | |
1963 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
1964 | else | |
1965 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 1966 | |
d62a17ae | 1967 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 1968 | |
d62a17ae | 1969 | return CMD_SUCCESS; |
16fc1eec DS |
1970 | } |
1971 | ||
219178b6 DW |
1972 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
1973 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 1974 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
1975 | NO_STR |
1976 | "BGP specific commands\n" | |
1977 | "Change the default bestpath selection\n" | |
1978 | "AS-path attribute\n" | |
1979 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 1980 | "Generate an AS_SET\n" |
16fc1eec DS |
1981 | "Do not generate an AS_SET\n") |
1982 | { | |
d62a17ae | 1983 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1984 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
1985 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
1986 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1987 | |
d62a17ae | 1988 | return CMD_SUCCESS; |
2fdd455c | 1989 | } |
6b0655a2 | 1990 | |
848973c7 | 1991 | /* "bgp log-neighbor-changes" configuration. */ |
1992 | DEFUN (bgp_log_neighbor_changes, | |
1993 | bgp_log_neighbor_changes_cmd, | |
1994 | "bgp log-neighbor-changes", | |
1995 | "BGP specific commands\n" | |
1996 | "Log neighbor up/down and reset reason\n") | |
1997 | { | |
d62a17ae | 1998 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1999 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2000 | return CMD_SUCCESS; | |
848973c7 | 2001 | } |
2002 | ||
2003 | DEFUN (no_bgp_log_neighbor_changes, | |
2004 | no_bgp_log_neighbor_changes_cmd, | |
2005 | "no bgp log-neighbor-changes", | |
2006 | NO_STR | |
2007 | "BGP specific commands\n" | |
2008 | "Log neighbor up/down and reset reason\n") | |
2009 | { | |
d62a17ae | 2010 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2011 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2012 | return CMD_SUCCESS; | |
848973c7 | 2013 | } |
6b0655a2 | 2014 | |
718e3744 | 2015 | /* "bgp bestpath med" configuration. */ |
2016 | DEFUN (bgp_bestpath_med, | |
2017 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2018 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2019 | "BGP specific commands\n" |
2020 | "Change the default bestpath selection\n" | |
2021 | "MED attribute\n" | |
2022 | "Compare MED among confederation paths\n" | |
838758ac DW |
2023 | "Treat missing MED as the least preferred one\n" |
2024 | "Treat missing MED as the least preferred one\n" | |
2025 | "Compare MED among confederation paths\n") | |
718e3744 | 2026 | { |
d62a17ae | 2027 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2028 | |
d62a17ae | 2029 | int idx = 0; |
2030 | if (argv_find(argv, argc, "confed", &idx)) | |
2031 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2032 | idx = 0; | |
2033 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2034 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2035 | |
d62a17ae | 2036 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2037 | |
d62a17ae | 2038 | return CMD_SUCCESS; |
718e3744 | 2039 | } |
2040 | ||
718e3744 | 2041 | DEFUN (no_bgp_bestpath_med, |
2042 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2043 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2044 | NO_STR |
2045 | "BGP specific commands\n" | |
2046 | "Change the default bestpath selection\n" | |
2047 | "MED attribute\n" | |
2048 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2049 | "Treat missing MED as the least preferred one\n" |
2050 | "Treat missing MED as the least preferred one\n" | |
2051 | "Compare MED among confederation paths\n") | |
718e3744 | 2052 | { |
d62a17ae | 2053 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2054 | |
d62a17ae | 2055 | int idx = 0; |
2056 | if (argv_find(argv, argc, "confed", &idx)) | |
2057 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2058 | idx = 0; | |
2059 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2060 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2061 | |
d62a17ae | 2062 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2063 | |
d62a17ae | 2064 | return CMD_SUCCESS; |
718e3744 | 2065 | } |
2066 | ||
718e3744 | 2067 | /* "no bgp default ipv4-unicast". */ |
2068 | DEFUN (no_bgp_default_ipv4_unicast, | |
2069 | no_bgp_default_ipv4_unicast_cmd, | |
2070 | "no bgp default ipv4-unicast", | |
2071 | NO_STR | |
2072 | "BGP specific commands\n" | |
2073 | "Configure BGP defaults\n" | |
2074 | "Activate ipv4-unicast for a peer by default\n") | |
2075 | { | |
d62a17ae | 2076 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2077 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2078 | return CMD_SUCCESS; | |
718e3744 | 2079 | } |
2080 | ||
2081 | DEFUN (bgp_default_ipv4_unicast, | |
2082 | bgp_default_ipv4_unicast_cmd, | |
2083 | "bgp default ipv4-unicast", | |
2084 | "BGP specific commands\n" | |
2085 | "Configure BGP defaults\n" | |
2086 | "Activate ipv4-unicast for a peer by default\n") | |
2087 | { | |
d62a17ae | 2088 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2089 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2090 | return CMD_SUCCESS; | |
718e3744 | 2091 | } |
6b0655a2 | 2092 | |
04b6bdc0 DW |
2093 | /* Display hostname in certain command outputs */ |
2094 | DEFUN (bgp_default_show_hostname, | |
2095 | bgp_default_show_hostname_cmd, | |
2096 | "bgp default show-hostname", | |
2097 | "BGP specific commands\n" | |
2098 | "Configure BGP defaults\n" | |
2099 | "Show hostname in certain command ouputs\n") | |
2100 | { | |
d62a17ae | 2101 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2102 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2103 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2104 | } |
2105 | ||
2106 | DEFUN (no_bgp_default_show_hostname, | |
2107 | no_bgp_default_show_hostname_cmd, | |
2108 | "no bgp default show-hostname", | |
2109 | NO_STR | |
2110 | "BGP specific commands\n" | |
2111 | "Configure BGP defaults\n" | |
2112 | "Show hostname in certain command ouputs\n") | |
2113 | { | |
d62a17ae | 2114 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2115 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2116 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2117 | } |
2118 | ||
8233ef81 | 2119 | /* "bgp network import-check" configuration. */ |
718e3744 | 2120 | DEFUN (bgp_network_import_check, |
2121 | bgp_network_import_check_cmd, | |
5623e905 | 2122 | "bgp network import-check", |
718e3744 | 2123 | "BGP specific commands\n" |
2124 | "BGP network command\n" | |
5623e905 | 2125 | "Check BGP network route exists in IGP\n") |
718e3744 | 2126 | { |
d62a17ae | 2127 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2128 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2129 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
2130 | bgp_static_redo_import_check(bgp); | |
2131 | } | |
078430f6 | 2132 | |
d62a17ae | 2133 | return CMD_SUCCESS; |
718e3744 | 2134 | } |
2135 | ||
d62a17ae | 2136 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
2137 | "bgp network import-check exact", | |
2138 | "BGP specific commands\n" | |
2139 | "BGP network command\n" | |
2140 | "Check BGP network route exists in IGP\n" | |
2141 | "Match route precisely\n") | |
8233ef81 | 2142 | |
718e3744 | 2143 | DEFUN (no_bgp_network_import_check, |
2144 | no_bgp_network_import_check_cmd, | |
5623e905 | 2145 | "no bgp network import-check", |
718e3744 | 2146 | NO_STR |
2147 | "BGP specific commands\n" | |
2148 | "BGP network command\n" | |
2149 | "Check BGP network route exists in IGP\n") | |
2150 | { | |
d62a17ae | 2151 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2152 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2153 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
2154 | bgp_static_redo_import_check(bgp); | |
2155 | } | |
5623e905 | 2156 | |
d62a17ae | 2157 | return CMD_SUCCESS; |
718e3744 | 2158 | } |
6b0655a2 | 2159 | |
718e3744 | 2160 | DEFUN (bgp_default_local_preference, |
2161 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2162 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2163 | "BGP specific commands\n" |
2164 | "Configure BGP defaults\n" | |
2165 | "local preference (higher=more preferred)\n" | |
2166 | "Configure default local preference value\n") | |
2167 | { | |
d62a17ae | 2168 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2169 | int idx_number = 3; | |
2170 | u_int32_t local_pref; | |
718e3744 | 2171 | |
d62a17ae | 2172 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2173 | |
d62a17ae | 2174 | bgp_default_local_preference_set(bgp, local_pref); |
2175 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 2176 | |
d62a17ae | 2177 | return CMD_SUCCESS; |
718e3744 | 2178 | } |
2179 | ||
2180 | DEFUN (no_bgp_default_local_preference, | |
2181 | no_bgp_default_local_preference_cmd, | |
838758ac | 2182 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2183 | NO_STR |
2184 | "BGP specific commands\n" | |
2185 | "Configure BGP defaults\n" | |
838758ac DW |
2186 | "local preference (higher=more preferred)\n" |
2187 | "Configure default local preference value\n") | |
718e3744 | 2188 | { |
d62a17ae | 2189 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2190 | bgp_default_local_preference_unset(bgp); | |
2191 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2192 | |
d62a17ae | 2193 | return CMD_SUCCESS; |
718e3744 | 2194 | } |
2195 | ||
6b0655a2 | 2196 | |
3f9c7369 DS |
2197 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2198 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2199 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2200 | "BGP specific commands\n" |
2201 | "Configure BGP defaults\n" | |
2202 | "subgroup-pkt-queue-max\n" | |
2203 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2204 | { |
d62a17ae | 2205 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2206 | int idx_number = 3; | |
2207 | u_int32_t max_size; | |
8bd9d948 | 2208 | |
d62a17ae | 2209 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 2210 | |
d62a17ae | 2211 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 2212 | |
d62a17ae | 2213 | return CMD_SUCCESS; |
3f9c7369 DS |
2214 | } |
2215 | ||
2216 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2217 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2218 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2219 | NO_STR |
2220 | "BGP specific commands\n" | |
2221 | "Configure BGP defaults\n" | |
838758ac DW |
2222 | "subgroup-pkt-queue-max\n" |
2223 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2224 | { |
d62a17ae | 2225 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2226 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
2227 | return CMD_SUCCESS; | |
8bd9d948 DS |
2228 | } |
2229 | ||
813d4307 | 2230 | |
8bd9d948 DS |
2231 | DEFUN (bgp_rr_allow_outbound_policy, |
2232 | bgp_rr_allow_outbound_policy_cmd, | |
2233 | "bgp route-reflector allow-outbound-policy", | |
2234 | "BGP specific commands\n" | |
2235 | "Allow modifications made by out route-map\n" | |
2236 | "on ibgp neighbors\n") | |
2237 | { | |
d62a17ae | 2238 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2239 | |
d62a17ae | 2240 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2241 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2242 | update_group_announce_rrclients(bgp); | |
2243 | bgp_clear_star_soft_out(vty, bgp->name); | |
2244 | } | |
8bd9d948 | 2245 | |
d62a17ae | 2246 | return CMD_SUCCESS; |
8bd9d948 DS |
2247 | } |
2248 | ||
2249 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2250 | no_bgp_rr_allow_outbound_policy_cmd, | |
2251 | "no bgp route-reflector allow-outbound-policy", | |
2252 | NO_STR | |
2253 | "BGP specific commands\n" | |
2254 | "Allow modifications made by out route-map\n" | |
2255 | "on ibgp neighbors\n") | |
2256 | { | |
d62a17ae | 2257 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2258 | |
d62a17ae | 2259 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2260 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2261 | update_group_announce_rrclients(bgp); | |
2262 | bgp_clear_star_soft_out(vty, bgp->name); | |
2263 | } | |
8bd9d948 | 2264 | |
d62a17ae | 2265 | return CMD_SUCCESS; |
8bd9d948 DS |
2266 | } |
2267 | ||
f14e6fdb DS |
2268 | DEFUN (bgp_listen_limit, |
2269 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2270 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2271 | "BGP specific commands\n" |
2272 | "Configure BGP defaults\n" | |
2273 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2274 | "Configure Dynamic Neighbors listen limit value\n") | |
2275 | { | |
d62a17ae | 2276 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2277 | int idx_number = 3; | |
2278 | int listen_limit; | |
f14e6fdb | 2279 | |
d62a17ae | 2280 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 2281 | |
d62a17ae | 2282 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 2283 | |
d62a17ae | 2284 | return CMD_SUCCESS; |
f14e6fdb DS |
2285 | } |
2286 | ||
2287 | DEFUN (no_bgp_listen_limit, | |
2288 | no_bgp_listen_limit_cmd, | |
838758ac | 2289 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2290 | "BGP specific commands\n" |
2291 | "Configure BGP defaults\n" | |
2292 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2293 | "Configure Dynamic Neighbors listen limit value to default\n" |
2294 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2295 | { |
d62a17ae | 2296 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2297 | bgp_listen_limit_unset(bgp); | |
2298 | return CMD_SUCCESS; | |
f14e6fdb DS |
2299 | } |
2300 | ||
2301 | ||
20eb8864 | 2302 | /* |
2303 | * Check if this listen range is already configured. Check for exact | |
2304 | * match or overlap based on input. | |
2305 | */ | |
d62a17ae | 2306 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
2307 | struct prefix *range, int exact) | |
2308 | { | |
2309 | struct listnode *node, *nnode; | |
2310 | struct listnode *node1, *nnode1; | |
2311 | struct peer_group *group; | |
2312 | struct prefix *lr; | |
2313 | afi_t afi; | |
2314 | int match; | |
2315 | ||
2316 | afi = family2afi(range->family); | |
2317 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2318 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
2319 | lr)) { | |
2320 | if (exact) | |
2321 | match = prefix_same(range, lr); | |
2322 | else | |
2323 | match = (prefix_match(range, lr) | |
2324 | || prefix_match(lr, range)); | |
2325 | if (match) | |
2326 | return group; | |
2327 | } | |
2328 | } | |
2329 | ||
2330 | return NULL; | |
20eb8864 | 2331 | } |
2332 | ||
f14e6fdb DS |
2333 | DEFUN (bgp_listen_range, |
2334 | bgp_listen_range_cmd, | |
9ccf14f7 | 2335 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2336 | "BGP specific commands\n" |
d7fa34c1 QY |
2337 | "Configure BGP dynamic neighbors listen range\n" |
2338 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2339 | NEIGHBOR_ADDR_STR |
2340 | "Member of the peer-group\n" | |
2341 | "Peer-group name\n") | |
f14e6fdb | 2342 | { |
d62a17ae | 2343 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2344 | struct prefix range; | |
2345 | struct peer_group *group, *existing_group; | |
2346 | afi_t afi; | |
2347 | int ret; | |
2348 | int idx = 0; | |
2349 | ||
2350 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2351 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2352 | char *prefix = argv[idx]->arg; | |
2353 | argv_find(argv, argc, "WORD", &idx); | |
2354 | char *peergroup = argv[idx]->arg; | |
2355 | ||
2356 | /* Convert IP prefix string to struct prefix. */ | |
2357 | ret = str2prefix(prefix, &range); | |
2358 | if (!ret) { | |
2359 | vty_out(vty, "%% Malformed listen range\n"); | |
2360 | return CMD_WARNING_CONFIG_FAILED; | |
2361 | } | |
2362 | ||
2363 | afi = family2afi(range.family); | |
2364 | ||
2365 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2366 | vty_out(vty, | |
2367 | "%% Malformed listen range (link-local address)\n"); | |
2368 | return CMD_WARNING_CONFIG_FAILED; | |
2369 | } | |
2370 | ||
2371 | apply_mask(&range); | |
2372 | ||
2373 | /* Check if same listen range is already configured. */ | |
2374 | existing_group = listen_range_exists(bgp, &range, 1); | |
2375 | if (existing_group) { | |
2376 | if (strcmp(existing_group->name, peergroup) == 0) | |
2377 | return CMD_SUCCESS; | |
2378 | else { | |
2379 | vty_out(vty, | |
2380 | "%% Same listen range is attached to peer-group %s\n", | |
2381 | existing_group->name); | |
2382 | return CMD_WARNING_CONFIG_FAILED; | |
2383 | } | |
2384 | } | |
2385 | ||
2386 | /* Check if an overlapping listen range exists. */ | |
2387 | if (listen_range_exists(bgp, &range, 0)) { | |
2388 | vty_out(vty, | |
2389 | "%% Listen range overlaps with existing listen range\n"); | |
2390 | return CMD_WARNING_CONFIG_FAILED; | |
2391 | } | |
2392 | ||
2393 | group = peer_group_lookup(bgp, peergroup); | |
2394 | if (!group) { | |
2395 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2396 | return CMD_WARNING_CONFIG_FAILED; | |
2397 | } | |
2398 | ||
2399 | ret = peer_group_listen_range_add(group, &range); | |
2400 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
2401 | } |
2402 | ||
2403 | DEFUN (no_bgp_listen_range, | |
2404 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2405 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2406 | NO_STR | |
f14e6fdb | 2407 | "BGP specific commands\n" |
d7fa34c1 QY |
2408 | "Unconfigure BGP dynamic neighbors listen range\n" |
2409 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2410 | NEIGHBOR_ADDR_STR | |
2411 | "Member of the peer-group\n" | |
2412 | "Peer-group name\n") | |
f14e6fdb | 2413 | { |
d62a17ae | 2414 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2415 | struct prefix range; | |
2416 | struct peer_group *group; | |
2417 | afi_t afi; | |
2418 | int ret; | |
2419 | int idx = 0; | |
2420 | ||
2421 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2422 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2423 | char *prefix = argv[idx]->arg; | |
2424 | argv_find(argv, argc, "WORD", &idx); | |
2425 | char *peergroup = argv[idx]->arg; | |
2426 | ||
2427 | /* Convert IP prefix string to struct prefix. */ | |
2428 | ret = str2prefix(prefix, &range); | |
2429 | if (!ret) { | |
2430 | vty_out(vty, "%% Malformed listen range\n"); | |
2431 | return CMD_WARNING_CONFIG_FAILED; | |
2432 | } | |
2433 | ||
2434 | afi = family2afi(range.family); | |
2435 | ||
2436 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2437 | vty_out(vty, | |
2438 | "%% Malformed listen range (link-local address)\n"); | |
2439 | return CMD_WARNING_CONFIG_FAILED; | |
2440 | } | |
2441 | ||
2442 | apply_mask(&range); | |
2443 | ||
2444 | group = peer_group_lookup(bgp, peergroup); | |
2445 | if (!group) { | |
2446 | vty_out(vty, "%% Peer-group does not exist\n"); | |
2447 | return CMD_WARNING_CONFIG_FAILED; | |
2448 | } | |
2449 | ||
2450 | ret = peer_group_listen_range_del(group, &range); | |
2451 | return bgp_vty_return(vty, ret); | |
2452 | } | |
2453 | ||
2454 | int bgp_config_write_listen(struct vty *vty, struct bgp *bgp) | |
2455 | { | |
2456 | struct peer_group *group; | |
2457 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2458 | struct prefix *range; | |
2459 | afi_t afi; | |
2460 | char buf[PREFIX2STR_BUFFER]; | |
2461 | ||
2462 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2463 | vty_out(vty, " bgp listen limit %d\n", | |
2464 | bgp->dynamic_neighbors_limit); | |
2465 | ||
2466 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2467 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
2468 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
2469 | nrnode, range)) { | |
2470 | prefix2str(range, buf, sizeof(buf)); | |
2471 | vty_out(vty, | |
2472 | " bgp listen range %s peer-group %s\n", | |
2473 | buf, group->name); | |
2474 | } | |
2475 | } | |
2476 | } | |
2477 | ||
2478 | return 0; | |
f14e6fdb DS |
2479 | } |
2480 | ||
2481 | ||
907f92c8 DS |
2482 | DEFUN (bgp_disable_connected_route_check, |
2483 | bgp_disable_connected_route_check_cmd, | |
2484 | "bgp disable-ebgp-connected-route-check", | |
2485 | "BGP specific commands\n" | |
2486 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2487 | { | |
d62a17ae | 2488 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2489 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2490 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2491 | |
d62a17ae | 2492 | return CMD_SUCCESS; |
907f92c8 DS |
2493 | } |
2494 | ||
2495 | DEFUN (no_bgp_disable_connected_route_check, | |
2496 | no_bgp_disable_connected_route_check_cmd, | |
2497 | "no bgp disable-ebgp-connected-route-check", | |
2498 | NO_STR | |
2499 | "BGP specific commands\n" | |
2500 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2501 | { | |
d62a17ae | 2502 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2503 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2504 | bgp_clear_star_soft_in(vty, bgp->name); | |
2505 | ||
2506 | return CMD_SUCCESS; | |
2507 | } | |
2508 | ||
2509 | ||
2510 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
2511 | const char *as_str, afi_t afi, safi_t safi) | |
2512 | { | |
2513 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2514 | int ret; | |
2515 | as_t as; | |
2516 | int as_type = AS_SPECIFIED; | |
2517 | union sockunion su; | |
2518 | ||
2519 | if (as_str[0] == 'i') { | |
2520 | as = 0; | |
2521 | as_type = AS_INTERNAL; | |
2522 | } else if (as_str[0] == 'e') { | |
2523 | as = 0; | |
2524 | as_type = AS_EXTERNAL; | |
2525 | } else { | |
2526 | /* Get AS number. */ | |
2527 | as = strtoul(as_str, NULL, 10); | |
2528 | } | |
2529 | ||
2530 | /* If peer is peer group, call proper function. */ | |
2531 | ret = str2sockunion(peer_str, &su); | |
2532 | if (ret < 0) { | |
2533 | /* Check for peer by interface */ | |
2534 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, | |
2535 | safi); | |
2536 | if (ret < 0) { | |
2537 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); | |
2538 | if (ret < 0) { | |
2539 | vty_out(vty, | |
2540 | "%% Create the peer-group or interface first\n"); | |
2541 | return CMD_WARNING_CONFIG_FAILED; | |
2542 | } | |
2543 | return CMD_SUCCESS; | |
2544 | } | |
2545 | } else { | |
2546 | if (peer_address_self_check(bgp, &su)) { | |
2547 | vty_out(vty, | |
2548 | "%% Can not configure the local system as neighbor\n"); | |
2549 | return CMD_WARNING_CONFIG_FAILED; | |
2550 | } | |
2551 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
2552 | } | |
2553 | ||
2554 | /* This peer belongs to peer group. */ | |
2555 | switch (ret) { | |
2556 | case BGP_ERR_PEER_GROUP_MEMBER: | |
2557 | vty_out(vty, | |
2558 | "%% Peer-group AS %u. Cannot configure remote-as for member\n", | |
2559 | as); | |
2560 | return CMD_WARNING_CONFIG_FAILED; | |
2561 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
2562 | vty_out(vty, | |
2563 | "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n", | |
2564 | as, as_str); | |
2565 | return CMD_WARNING_CONFIG_FAILED; | |
2566 | } | |
2567 | return bgp_vty_return(vty, ret); | |
718e3744 | 2568 | } |
2569 | ||
2570 | DEFUN (neighbor_remote_as, | |
2571 | neighbor_remote_as_cmd, | |
3a2d747c | 2572 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2573 | NEIGHBOR_STR |
2574 | NEIGHBOR_ADDR_STR2 | |
2575 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2576 | AS_STR |
3a2d747c QY |
2577 | "Internal BGP peer\n" |
2578 | "External BGP peer\n") | |
718e3744 | 2579 | { |
d62a17ae | 2580 | int idx_peer = 1; |
2581 | int idx_remote_as = 3; | |
2582 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
2583 | argv[idx_remote_as]->arg, AFI_IP, | |
2584 | SAFI_UNICAST); | |
2585 | } | |
2586 | ||
2587 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
2588 | afi_t afi, safi_t safi, int v6only, | |
2589 | const char *peer_group_name, | |
2590 | const char *as_str) | |
2591 | { | |
2592 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2593 | as_t as = 0; | |
2594 | int as_type = AS_UNSPECIFIED; | |
2595 | struct peer *peer; | |
2596 | struct peer_group *group; | |
2597 | int ret = 0; | |
2598 | union sockunion su; | |
2599 | ||
2600 | group = peer_group_lookup(bgp, conf_if); | |
2601 | ||
2602 | if (group) { | |
2603 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
2604 | return CMD_WARNING_CONFIG_FAILED; | |
2605 | } | |
2606 | ||
2607 | if (as_str) { | |
2608 | if (as_str[0] == 'i') { | |
2609 | as_type = AS_INTERNAL; | |
2610 | } else if (as_str[0] == 'e') { | |
2611 | as_type = AS_EXTERNAL; | |
2612 | } else { | |
2613 | /* Get AS number. */ | |
2614 | as = strtoul(as_str, NULL, 10); | |
2615 | as_type = AS_SPECIFIED; | |
2616 | } | |
2617 | } | |
2618 | ||
2619 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
2620 | if (peer) { | |
2621 | if (as_str) | |
2622 | ret = peer_remote_as(bgp, &su, conf_if, &as, as_type, | |
2623 | afi, safi); | |
2624 | } else { | |
2625 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2626 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
2627 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2628 | as_type, 0, 0, NULL); | |
2629 | else | |
2630 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2631 | as_type, afi, safi, NULL); | |
2632 | ||
2633 | if (!peer) { | |
2634 | vty_out(vty, "%% BGP failed to create peer\n"); | |
2635 | return CMD_WARNING_CONFIG_FAILED; | |
2636 | } | |
2637 | ||
2638 | if (v6only) | |
2639 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2640 | ||
2641 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
2642 | * this | |
2643 | * any unnumbered peer in order to not worry about run-time | |
2644 | * transitions | |
2645 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
2646 | * address | |
2647 | * gets deleted later etc.) | |
2648 | */ | |
2649 | if (peer->ifp) | |
2650 | bgp_zebra_initiate_radv(bgp, peer); | |
2651 | } | |
2652 | ||
2653 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
2654 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
2655 | if (v6only) | |
2656 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2657 | else | |
2658 | UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2659 | ||
2660 | /* v6only flag changed. Reset bgp seesion */ | |
2661 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2662 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2663 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2664 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2665 | } else | |
2666 | bgp_session_reset(peer); | |
2667 | } | |
2668 | ||
2669 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) | |
2670 | peer_flag_set(peer, PEER_FLAG_CAPABILITY_ENHE); | |
2671 | ||
2672 | if (peer_group_name) { | |
2673 | group = peer_group_lookup(bgp, peer_group_name); | |
2674 | if (!group) { | |
2675 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2676 | return CMD_WARNING_CONFIG_FAILED; | |
2677 | } | |
2678 | ||
2679 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
2680 | } | |
2681 | ||
2682 | return bgp_vty_return(vty, ret); | |
a80beece DS |
2683 | } |
2684 | ||
4c48cf63 DW |
2685 | DEFUN (neighbor_interface_config, |
2686 | neighbor_interface_config_cmd, | |
31500417 | 2687 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2688 | NEIGHBOR_STR |
2689 | "Interface name or neighbor tag\n" | |
31500417 DW |
2690 | "Enable BGP on interface\n" |
2691 | "Member of the peer-group\n" | |
16cedbb0 | 2692 | "Peer-group name\n") |
4c48cf63 | 2693 | { |
d62a17ae | 2694 | int idx_word = 1; |
2695 | int idx_peer_group_word = 4; | |
31500417 | 2696 | |
d62a17ae | 2697 | if (argc > idx_peer_group_word) |
2698 | return peer_conf_interface_get( | |
2699 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2700 | argv[idx_peer_group_word]->arg, NULL); | |
2701 | else | |
2702 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2703 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
2704 | } |
2705 | ||
4c48cf63 DW |
2706 | DEFUN (neighbor_interface_config_v6only, |
2707 | neighbor_interface_config_v6only_cmd, | |
31500417 | 2708 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
2709 | NEIGHBOR_STR |
2710 | "Interface name or neighbor tag\n" | |
2711 | "Enable BGP on interface\n" | |
31500417 DW |
2712 | "Enable BGP with v6 link-local only\n" |
2713 | "Member of the peer-group\n" | |
16cedbb0 | 2714 | "Peer-group name\n") |
4c48cf63 | 2715 | { |
d62a17ae | 2716 | int idx_word = 1; |
2717 | int idx_peer_group_word = 5; | |
31500417 | 2718 | |
d62a17ae | 2719 | if (argc > idx_peer_group_word) |
2720 | return peer_conf_interface_get( | |
2721 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2722 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 2723 | |
d62a17ae | 2724 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
2725 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
2726 | } |
2727 | ||
a80beece | 2728 | |
b3a39dc5 DD |
2729 | DEFUN (neighbor_interface_config_remote_as, |
2730 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2731 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2732 | NEIGHBOR_STR |
2733 | "Interface name or neighbor tag\n" | |
2734 | "Enable BGP on interface\n" | |
3a2d747c | 2735 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2736 | AS_STR |
3a2d747c QY |
2737 | "Internal BGP peer\n" |
2738 | "External BGP peer\n") | |
b3a39dc5 | 2739 | { |
d62a17ae | 2740 | int idx_word = 1; |
2741 | int idx_remote_as = 4; | |
2742 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2743 | SAFI_UNICAST, 0, NULL, | |
2744 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2745 | } |
2746 | ||
2747 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
2748 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 2749 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2750 | NEIGHBOR_STR |
2751 | "Interface name or neighbor tag\n" | |
3a2d747c | 2752 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 2753 | "Enable BGP on interface\n" |
3a2d747c | 2754 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2755 | AS_STR |
3a2d747c QY |
2756 | "Internal BGP peer\n" |
2757 | "External BGP peer\n") | |
b3a39dc5 | 2758 | { |
d62a17ae | 2759 | int idx_word = 1; |
2760 | int idx_remote_as = 5; | |
2761 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2762 | SAFI_UNICAST, 1, NULL, | |
2763 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2764 | } |
2765 | ||
718e3744 | 2766 | DEFUN (neighbor_peer_group, |
2767 | neighbor_peer_group_cmd, | |
2768 | "neighbor WORD peer-group", | |
2769 | NEIGHBOR_STR | |
a80beece | 2770 | "Interface name or neighbor tag\n" |
718e3744 | 2771 | "Configure peer-group\n") |
2772 | { | |
d62a17ae | 2773 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2774 | int idx_word = 1; | |
2775 | struct peer *peer; | |
2776 | struct peer_group *group; | |
718e3744 | 2777 | |
d62a17ae | 2778 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
2779 | if (peer) { | |
2780 | vty_out(vty, "%% Name conflict with interface: \n"); | |
2781 | return CMD_WARNING_CONFIG_FAILED; | |
2782 | } | |
718e3744 | 2783 | |
d62a17ae | 2784 | group = peer_group_get(bgp, argv[idx_word]->arg); |
2785 | if (!group) { | |
2786 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
2787 | return CMD_WARNING_CONFIG_FAILED; | |
2788 | } | |
718e3744 | 2789 | |
d62a17ae | 2790 | return CMD_SUCCESS; |
718e3744 | 2791 | } |
2792 | ||
2793 | DEFUN (no_neighbor, | |
2794 | no_neighbor_cmd, | |
dab8cd00 | 2795 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 2796 | NO_STR |
2797 | NEIGHBOR_STR | |
3a2d747c QY |
2798 | NEIGHBOR_ADDR_STR2 |
2799 | "Specify a BGP neighbor\n" | |
2800 | AS_STR | |
2801 | "Internal BGP peer\n" | |
2802 | "External BGP peer\n") | |
718e3744 | 2803 | { |
d62a17ae | 2804 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2805 | int idx_peer = 2; | |
2806 | int ret; | |
2807 | union sockunion su; | |
2808 | struct peer_group *group; | |
2809 | struct peer *peer; | |
2810 | struct peer *other; | |
2811 | ||
2812 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
2813 | if (ret < 0) { | |
2814 | /* look up for neighbor by interface name config. */ | |
2815 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
2816 | if (peer) { | |
2817 | /* Request zebra to terminate IPv6 RAs on this | |
2818 | * interface. */ | |
2819 | if (peer->ifp) | |
2820 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
2821 | peer_delete(peer); | |
2822 | return CMD_SUCCESS; | |
2823 | } | |
f14e6fdb | 2824 | |
d62a17ae | 2825 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
2826 | if (group) | |
2827 | peer_group_delete(group); | |
2828 | else { | |
2829 | vty_out(vty, "%% Create the peer-group first\n"); | |
2830 | return CMD_WARNING_CONFIG_FAILED; | |
2831 | } | |
2832 | } else { | |
2833 | peer = peer_lookup(bgp, &su); | |
2834 | if (peer) { | |
2835 | if (peer_dynamic_neighbor(peer)) { | |
2836 | vty_out(vty, | |
2837 | "%% Operation not allowed on a dynamic neighbor\n"); | |
2838 | return CMD_WARNING_CONFIG_FAILED; | |
2839 | } | |
2840 | ||
2841 | other = peer->doppelganger; | |
2842 | peer_delete(peer); | |
2843 | if (other && other->status != Deleted) | |
2844 | peer_delete(other); | |
2845 | } | |
1ff9a340 | 2846 | } |
718e3744 | 2847 | |
d62a17ae | 2848 | return CMD_SUCCESS; |
718e3744 | 2849 | } |
2850 | ||
a80beece DS |
2851 | DEFUN (no_neighbor_interface_config, |
2852 | no_neighbor_interface_config_cmd, | |
31500417 | 2853 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
2854 | NO_STR |
2855 | NEIGHBOR_STR | |
2856 | "Interface name\n" | |
31500417 DW |
2857 | "Configure BGP on interface\n" |
2858 | "Enable BGP with v6 link-local only\n" | |
2859 | "Member of the peer-group\n" | |
16cedbb0 | 2860 | "Peer-group name\n" |
3a2d747c QY |
2861 | "Specify a BGP neighbor\n" |
2862 | AS_STR | |
2863 | "Internal BGP peer\n" | |
2864 | "External BGP peer\n") | |
a80beece | 2865 | { |
d62a17ae | 2866 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2867 | int idx_word = 2; | |
2868 | struct peer *peer; | |
2869 | ||
2870 | /* look up for neighbor by interface name config. */ | |
2871 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
2872 | if (peer) { | |
2873 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
2874 | if (peer->ifp) | |
2875 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
2876 | peer_delete(peer); | |
2877 | } else { | |
2878 | vty_out(vty, "%% Create the bgp interface first\n"); | |
2879 | return CMD_WARNING_CONFIG_FAILED; | |
2880 | } | |
2881 | return CMD_SUCCESS; | |
a80beece DS |
2882 | } |
2883 | ||
718e3744 | 2884 | DEFUN (no_neighbor_peer_group, |
2885 | no_neighbor_peer_group_cmd, | |
2886 | "no neighbor WORD peer-group", | |
2887 | NO_STR | |
2888 | NEIGHBOR_STR | |
2889 | "Neighbor tag\n" | |
2890 | "Configure peer-group\n") | |
2891 | { | |
d62a17ae | 2892 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2893 | int idx_word = 2; | |
2894 | struct peer_group *group; | |
718e3744 | 2895 | |
d62a17ae | 2896 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
2897 | if (group) | |
2898 | peer_group_delete(group); | |
2899 | else { | |
2900 | vty_out(vty, "%% Create the peer-group first\n"); | |
2901 | return CMD_WARNING_CONFIG_FAILED; | |
2902 | } | |
2903 | return CMD_SUCCESS; | |
718e3744 | 2904 | } |
2905 | ||
a80beece DS |
2906 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
2907 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 2908 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2909 | NO_STR |
2910 | NEIGHBOR_STR | |
a80beece | 2911 | "Interface name or neighbor tag\n" |
718e3744 | 2912 | "Specify a BGP neighbor\n" |
3a2d747c QY |
2913 | AS_STR |
2914 | "Internal BGP peer\n" | |
2915 | "External BGP peer\n") | |
718e3744 | 2916 | { |
d62a17ae | 2917 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2918 | int idx_word = 2; | |
2919 | struct peer_group *group; | |
2920 | struct peer *peer; | |
2921 | ||
2922 | /* look up for neighbor by interface name config. */ | |
2923 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
2924 | if (peer) { | |
2925 | peer_as_change(peer, 0, AS_SPECIFIED); | |
2926 | return CMD_SUCCESS; | |
2927 | } | |
2928 | ||
2929 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
2930 | if (group) | |
2931 | peer_group_remote_as_delete(group); | |
2932 | else { | |
2933 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
2934 | return CMD_WARNING_CONFIG_FAILED; | |
2935 | } | |
2936 | return CMD_SUCCESS; | |
718e3744 | 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 | { | |
d62a17ae | 2947 | int idx_peer = 1; |
2948 | int idx_number = 3; | |
2949 | struct peer *peer; | |
2950 | int ret; | |
2951 | as_t as; | |
718e3744 | 2952 | |
d62a17ae | 2953 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2954 | if (!peer) | |
2955 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 2956 | |
d62a17ae | 2957 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
2958 | ret = peer_local_as_set(peer, as, 0, 0); | |
2959 | return bgp_vty_return(vty, ret); | |
718e3744 | 2960 | } |
2961 | ||
2962 | DEFUN (neighbor_local_as_no_prepend, | |
2963 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 2964 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 2965 | NEIGHBOR_STR |
2966 | NEIGHBOR_ADDR_STR2 | |
2967 | "Specify a local-as number\n" | |
2968 | "AS number used as local AS\n" | |
2969 | "Do not prepend local-as to updates from ebgp peers\n") | |
2970 | { | |
d62a17ae | 2971 | int idx_peer = 1; |
2972 | int idx_number = 3; | |
2973 | struct peer *peer; | |
2974 | int ret; | |
2975 | as_t as; | |
718e3744 | 2976 | |
d62a17ae | 2977 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2978 | if (!peer) | |
2979 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 2980 | |
d62a17ae | 2981 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
2982 | ret = peer_local_as_set(peer, as, 1, 0); | |
2983 | return bgp_vty_return(vty, ret); | |
718e3744 | 2984 | } |
2985 | ||
9d3f9705 AC |
2986 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
2987 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 2988 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
2989 | NEIGHBOR_STR |
2990 | NEIGHBOR_ADDR_STR2 | |
2991 | "Specify a local-as number\n" | |
2992 | "AS number used as local AS\n" | |
2993 | "Do not prepend local-as to updates from ebgp peers\n" | |
2994 | "Do not prepend local-as to updates from ibgp peers\n") | |
2995 | { | |
d62a17ae | 2996 | int idx_peer = 1; |
2997 | int idx_number = 3; | |
2998 | struct peer *peer; | |
2999 | int ret; | |
3000 | as_t as; | |
9d3f9705 | 3001 | |
d62a17ae | 3002 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3003 | if (!peer) | |
3004 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3005 | |
d62a17ae | 3006 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3007 | ret = peer_local_as_set(peer, as, 1, 1); | |
3008 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3009 | } |
3010 | ||
718e3744 | 3011 | DEFUN (no_neighbor_local_as, |
3012 | no_neighbor_local_as_cmd, | |
a636c635 | 3013 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3014 | NO_STR |
3015 | NEIGHBOR_STR | |
3016 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3017 | "Specify a local-as number\n" |
3018 | "AS number used as local AS\n" | |
3019 | "Do not prepend local-as to updates from ebgp peers\n" | |
3020 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3021 | { |
d62a17ae | 3022 | int idx_peer = 2; |
3023 | struct peer *peer; | |
3024 | int ret; | |
718e3744 | 3025 | |
d62a17ae | 3026 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3027 | if (!peer) | |
3028 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3029 | |
d62a17ae | 3030 | ret = peer_local_as_unset(peer); |
3031 | return bgp_vty_return(vty, ret); | |
718e3744 | 3032 | } |
3033 | ||
718e3744 | 3034 | |
3f9c7369 DS |
3035 | DEFUN (neighbor_solo, |
3036 | neighbor_solo_cmd, | |
9ccf14f7 | 3037 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3038 | NEIGHBOR_STR |
3039 | NEIGHBOR_ADDR_STR2 | |
3040 | "Solo peer - part of its own update group\n") | |
3041 | { | |
d62a17ae | 3042 | int idx_peer = 1; |
3043 | struct peer *peer; | |
3044 | int ret; | |
3f9c7369 | 3045 | |
d62a17ae | 3046 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3047 | if (!peer) | |
3048 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3049 | |
d62a17ae | 3050 | ret = update_group_adjust_soloness(peer, 1); |
3051 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3052 | } |
3053 | ||
3054 | DEFUN (no_neighbor_solo, | |
3055 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3056 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3057 | NO_STR |
3058 | NEIGHBOR_STR | |
3059 | NEIGHBOR_ADDR_STR2 | |
3060 | "Solo peer - part of its own update group\n") | |
3061 | { | |
d62a17ae | 3062 | int idx_peer = 2; |
3063 | struct peer *peer; | |
3064 | int ret; | |
3f9c7369 | 3065 | |
d62a17ae | 3066 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3067 | if (!peer) | |
3068 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3069 | |
d62a17ae | 3070 | ret = update_group_adjust_soloness(peer, 0); |
3071 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3072 | } |
3073 | ||
0df7c91f PJ |
3074 | DEFUN (neighbor_password, |
3075 | neighbor_password_cmd, | |
9ccf14f7 | 3076 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3077 | NEIGHBOR_STR |
3078 | NEIGHBOR_ADDR_STR2 | |
3079 | "Set a password\n" | |
3080 | "The password\n") | |
3081 | { | |
d62a17ae | 3082 | int idx_peer = 1; |
3083 | int idx_line = 3; | |
3084 | struct peer *peer; | |
3085 | int ret; | |
0df7c91f | 3086 | |
d62a17ae | 3087 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3088 | if (!peer) | |
3089 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3090 | |
d62a17ae | 3091 | ret = peer_password_set(peer, argv[idx_line]->arg); |
3092 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
3093 | } |
3094 | ||
3095 | DEFUN (no_neighbor_password, | |
3096 | no_neighbor_password_cmd, | |
a636c635 | 3097 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3098 | NO_STR |
3099 | NEIGHBOR_STR | |
3100 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3101 | "Set a password\n" |
3102 | "The password\n") | |
0df7c91f | 3103 | { |
d62a17ae | 3104 | int idx_peer = 2; |
3105 | struct peer *peer; | |
3106 | int ret; | |
0df7c91f | 3107 | |
d62a17ae | 3108 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3109 | if (!peer) | |
3110 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3111 | |
d62a17ae | 3112 | ret = peer_password_unset(peer); |
3113 | return bgp_vty_return(vty, ret); | |
0df7c91f | 3114 | } |
6b0655a2 | 3115 | |
813d4307 | 3116 | |
718e3744 | 3117 | DEFUN (neighbor_activate, |
3118 | neighbor_activate_cmd, | |
9ccf14f7 | 3119 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3120 | NEIGHBOR_STR |
3121 | NEIGHBOR_ADDR_STR2 | |
3122 | "Enable the Address Family for this Neighbor\n") | |
3123 | { | |
d62a17ae | 3124 | int idx_peer = 1; |
3125 | int ret; | |
3126 | struct peer *peer; | |
718e3744 | 3127 | |
d62a17ae | 3128 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3129 | if (!peer) | |
3130 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3131 | |
d62a17ae | 3132 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3133 | return bgp_vty_return(vty, ret); | |
718e3744 | 3134 | } |
3135 | ||
d62a17ae | 3136 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
3137 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3138 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3139 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3140 | |
718e3744 | 3141 | DEFUN (no_neighbor_activate, |
3142 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3143 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3144 | NO_STR |
3145 | NEIGHBOR_STR | |
3146 | NEIGHBOR_ADDR_STR2 | |
3147 | "Enable the Address Family for this Neighbor\n") | |
3148 | { | |
d62a17ae | 3149 | int idx_peer = 2; |
3150 | int ret; | |
3151 | struct peer *peer; | |
718e3744 | 3152 | |
d62a17ae | 3153 | /* Lookup peer. */ |
3154 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3155 | if (!peer) | |
3156 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3157 | |
d62a17ae | 3158 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3159 | return bgp_vty_return(vty, ret); | |
718e3744 | 3160 | } |
6b0655a2 | 3161 | |
d62a17ae | 3162 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
3163 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3164 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3165 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3166 | |
718e3744 | 3167 | DEFUN (neighbor_set_peer_group, |
3168 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3169 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3170 | NEIGHBOR_STR |
a80beece | 3171 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3172 | "Member of the peer-group\n" |
16cedbb0 | 3173 | "Peer-group name\n") |
718e3744 | 3174 | { |
d62a17ae | 3175 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3176 | int idx_peer = 1; | |
3177 | int idx_word = 3; | |
3178 | int ret; | |
3179 | as_t as; | |
3180 | union sockunion su; | |
3181 | struct peer *peer; | |
3182 | struct peer_group *group; | |
3183 | ||
3184 | peer = NULL; | |
3185 | ||
3186 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3187 | if (ret < 0) { | |
3188 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3189 | if (!peer) { | |
3190 | vty_out(vty, "%% Malformed address or name: %s\n", | |
3191 | argv[idx_peer]->arg); | |
3192 | return CMD_WARNING_CONFIG_FAILED; | |
3193 | } | |
3194 | } else { | |
3195 | if (peer_address_self_check(bgp, &su)) { | |
3196 | vty_out(vty, | |
3197 | "%% Can not configure the local system as neighbor\n"); | |
3198 | return CMD_WARNING_CONFIG_FAILED; | |
3199 | } | |
3200 | ||
3201 | /* Disallow for dynamic neighbor. */ | |
3202 | peer = peer_lookup(bgp, &su); | |
3203 | if (peer && peer_dynamic_neighbor(peer)) { | |
3204 | vty_out(vty, | |
3205 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3206 | return CMD_WARNING_CONFIG_FAILED; | |
3207 | } | |
3208 | } | |
3209 | ||
3210 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3211 | if (!group) { | |
3212 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3213 | return CMD_WARNING_CONFIG_FAILED; | |
3214 | } | |
3215 | ||
3216 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3217 | ||
3218 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
3219 | vty_out(vty, | |
3220 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
3221 | as); | |
3222 | return CMD_WARNING_CONFIG_FAILED; | |
3223 | } | |
3224 | ||
3225 | return bgp_vty_return(vty, ret); | |
3226 | } | |
3227 | ||
3228 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
3229 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3230 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3231 | "Member of the peer-group\n" | |
3232 | "Peer-group name\n") | |
596c17ba | 3233 | |
718e3744 | 3234 | DEFUN (no_neighbor_set_peer_group, |
3235 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3236 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3237 | NO_STR |
3238 | NEIGHBOR_STR | |
a80beece | 3239 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3240 | "Member of the peer-group\n" |
16cedbb0 | 3241 | "Peer-group name\n") |
718e3744 | 3242 | { |
d62a17ae | 3243 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3244 | int idx_peer = 2; | |
3245 | int idx_word = 4; | |
3246 | int ret; | |
3247 | struct peer *peer; | |
3248 | struct peer_group *group; | |
3249 | ||
3250 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
3251 | if (!peer) | |
3252 | return CMD_WARNING_CONFIG_FAILED; | |
3253 | ||
3254 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3255 | if (!group) { | |
3256 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3257 | return CMD_WARNING_CONFIG_FAILED; | |
3258 | } | |
718e3744 | 3259 | |
d62a17ae | 3260 | ret = peer_group_unbind(bgp, peer, group); |
718e3744 | 3261 | |
d62a17ae | 3262 | return bgp_vty_return(vty, ret); |
718e3744 | 3263 | } |
6b0655a2 | 3264 | |
d62a17ae | 3265 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
3266 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3267 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3268 | "Member of the peer-group\n" | |
3269 | "Peer-group name\n") | |
596c17ba | 3270 | |
d62a17ae | 3271 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
3272 | u_int16_t flag, int set) | |
718e3744 | 3273 | { |
d62a17ae | 3274 | int ret; |
3275 | struct peer *peer; | |
718e3744 | 3276 | |
d62a17ae | 3277 | peer = peer_and_group_lookup_vty(vty, ip_str); |
3278 | if (!peer) | |
3279 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3280 | |
d62a17ae | 3281 | /* |
3282 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3283 | * we should not accept disable-connected-check. | |
3284 | */ | |
3285 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3286 | vty_out(vty, | |
3287 | "%s is directly connected peer, cannot accept disable-" | |
3288 | "connected-check\n", | |
3289 | ip_str); | |
3290 | return CMD_WARNING_CONFIG_FAILED; | |
3291 | } | |
8cdabf90 | 3292 | |
d62a17ae | 3293 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3294 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 3295 | |
d62a17ae | 3296 | if (set) |
3297 | ret = peer_flag_set(peer, flag); | |
3298 | else | |
3299 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 3300 | |
d62a17ae | 3301 | return bgp_vty_return(vty, ret); |
718e3744 | 3302 | } |
3303 | ||
d62a17ae | 3304 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, |
3305 | u_int16_t flag) | |
718e3744 | 3306 | { |
d62a17ae | 3307 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 3308 | } |
3309 | ||
d62a17ae | 3310 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
3311 | u_int16_t flag) | |
718e3744 | 3312 | { |
d62a17ae | 3313 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 3314 | } |
3315 | ||
3316 | /* neighbor passive. */ | |
3317 | DEFUN (neighbor_passive, | |
3318 | neighbor_passive_cmd, | |
9ccf14f7 | 3319 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3320 | NEIGHBOR_STR |
3321 | NEIGHBOR_ADDR_STR2 | |
3322 | "Don't send open messages to this neighbor\n") | |
3323 | { | |
d62a17ae | 3324 | int idx_peer = 1; |
3325 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3326 | } |
3327 | ||
3328 | DEFUN (no_neighbor_passive, | |
3329 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3330 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3331 | NO_STR |
3332 | NEIGHBOR_STR | |
3333 | NEIGHBOR_ADDR_STR2 | |
3334 | "Don't send open messages to this neighbor\n") | |
3335 | { | |
d62a17ae | 3336 | int idx_peer = 2; |
3337 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3338 | } |
6b0655a2 | 3339 | |
718e3744 | 3340 | /* neighbor shutdown. */ |
73d70fa6 DL |
3341 | DEFUN (neighbor_shutdown_msg, |
3342 | neighbor_shutdown_msg_cmd, | |
3343 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3344 | NEIGHBOR_STR |
3345 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3346 | "Administratively shut down this neighbor\n" |
3347 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3348 | "Shutdown message\n") | |
718e3744 | 3349 | { |
d62a17ae | 3350 | int idx_peer = 1; |
73d70fa6 | 3351 | |
d62a17ae | 3352 | if (argc >= 5) { |
3353 | struct peer *peer = | |
3354 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3355 | char *message; | |
73d70fa6 | 3356 | |
d62a17ae | 3357 | if (!peer) |
3358 | return CMD_WARNING_CONFIG_FAILED; | |
3359 | message = argv_concat(argv, argc, 4); | |
3360 | peer_tx_shutdown_message_set(peer, message); | |
3361 | XFREE(MTYPE_TMP, message); | |
3362 | } | |
73d70fa6 | 3363 | |
d62a17ae | 3364 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3365 | } |
3366 | ||
d62a17ae | 3367 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
3368 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3369 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3370 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3371 | |
3372 | DEFUN (no_neighbor_shutdown_msg, | |
3373 | no_neighbor_shutdown_msg_cmd, | |
3374 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3375 | NO_STR | |
3376 | NEIGHBOR_STR | |
3377 | NEIGHBOR_ADDR_STR2 | |
3378 | "Administratively shut down this neighbor\n" | |
3379 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3380 | "Shutdown message\n") | |
718e3744 | 3381 | { |
d62a17ae | 3382 | int idx_peer = 2; |
73d70fa6 | 3383 | |
d62a17ae | 3384 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
3385 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 3386 | } |
6b0655a2 | 3387 | |
d62a17ae | 3388 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
3389 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3390 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3391 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 3392 | |
718e3744 | 3393 | /* neighbor capability dynamic. */ |
3394 | DEFUN (neighbor_capability_dynamic, | |
3395 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3396 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3397 | NEIGHBOR_STR |
3398 | NEIGHBOR_ADDR_STR2 | |
3399 | "Advertise capability to the peer\n" | |
3400 | "Advertise dynamic capability to this neighbor\n") | |
3401 | { | |
d62a17ae | 3402 | int idx_peer = 1; |
3403 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3404 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3405 | } |
3406 | ||
3407 | DEFUN (no_neighbor_capability_dynamic, | |
3408 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3409 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3410 | NO_STR |
3411 | NEIGHBOR_STR | |
3412 | NEIGHBOR_ADDR_STR2 | |
3413 | "Advertise capability to the peer\n" | |
3414 | "Advertise dynamic capability to this neighbor\n") | |
3415 | { | |
d62a17ae | 3416 | int idx_peer = 2; |
3417 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3418 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3419 | } |
6b0655a2 | 3420 | |
718e3744 | 3421 | /* neighbor dont-capability-negotiate */ |
3422 | DEFUN (neighbor_dont_capability_negotiate, | |
3423 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3424 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3425 | NEIGHBOR_STR |
3426 | NEIGHBOR_ADDR_STR2 | |
3427 | "Do not perform capability negotiation\n") | |
3428 | { | |
d62a17ae | 3429 | int idx_peer = 1; |
3430 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3431 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3432 | } |
3433 | ||
3434 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3435 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3436 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3437 | NO_STR |
3438 | NEIGHBOR_STR | |
3439 | NEIGHBOR_ADDR_STR2 | |
3440 | "Do not perform capability negotiation\n") | |
3441 | { | |
d62a17ae | 3442 | int idx_peer = 2; |
3443 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3444 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3445 | } |
6b0655a2 | 3446 | |
8a92a8a0 DS |
3447 | /* neighbor capability extended next hop encoding */ |
3448 | DEFUN (neighbor_capability_enhe, | |
3449 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3450 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3451 | NEIGHBOR_STR |
3452 | NEIGHBOR_ADDR_STR2 | |
3453 | "Advertise capability to the peer\n" | |
3454 | "Advertise extended next-hop capability to the peer\n") | |
3455 | { | |
d62a17ae | 3456 | int idx_peer = 1; |
3457 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3458 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3459 | } |
3460 | ||
3461 | DEFUN (no_neighbor_capability_enhe, | |
3462 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3463 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3464 | NO_STR |
3465 | NEIGHBOR_STR | |
3466 | NEIGHBOR_ADDR_STR2 | |
3467 | "Advertise capability to the peer\n" | |
3468 | "Advertise extended next-hop capability to the peer\n") | |
3469 | { | |
d62a17ae | 3470 | int idx_peer = 2; |
3471 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3472 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3473 | } |
3474 | ||
d62a17ae | 3475 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
3476 | afi_t afi, safi_t safi, u_int32_t flag, | |
3477 | int set) | |
718e3744 | 3478 | { |
d62a17ae | 3479 | int ret; |
3480 | struct peer *peer; | |
718e3744 | 3481 | |
d62a17ae | 3482 | peer = peer_and_group_lookup_vty(vty, peer_str); |
3483 | if (!peer) | |
3484 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3485 | |
d62a17ae | 3486 | if (set) |
3487 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
3488 | else | |
3489 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 3490 | |
d62a17ae | 3491 | return bgp_vty_return(vty, ret); |
718e3744 | 3492 | } |
3493 | ||
d62a17ae | 3494 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
3495 | afi_t afi, safi_t safi, u_int32_t flag) | |
718e3744 | 3496 | { |
d62a17ae | 3497 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 3498 | } |
3499 | ||
d62a17ae | 3500 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
3501 | afi_t afi, safi_t safi, u_int32_t flag) | |
718e3744 | 3502 | { |
d62a17ae | 3503 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 3504 | } |
6b0655a2 | 3505 | |
718e3744 | 3506 | /* neighbor capability orf prefix-list. */ |
3507 | DEFUN (neighbor_capability_orf_prefix, | |
3508 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3509 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3510 | NEIGHBOR_STR |
3511 | NEIGHBOR_ADDR_STR2 | |
3512 | "Advertise capability to the peer\n" | |
3513 | "Advertise ORF capability to the peer\n" | |
3514 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3515 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3516 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3517 | "Capability to SEND the ORF to this neighbor\n") | |
3518 | { | |
d62a17ae | 3519 | int idx_peer = 1; |
3520 | int idx_send_recv = 5; | |
3521 | u_int16_t flag = 0; | |
3522 | ||
3523 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3524 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3525 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3526 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3527 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3528 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3529 | else { | |
3530 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3531 | return CMD_WARNING_CONFIG_FAILED; | |
3532 | } | |
3533 | ||
3534 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3535 | bgp_node_safi(vty), flag); | |
3536 | } | |
3537 | ||
3538 | ALIAS_HIDDEN( | |
3539 | neighbor_capability_orf_prefix, | |
3540 | neighbor_capability_orf_prefix_hidden_cmd, | |
3541 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3542 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3543 | "Advertise capability to the peer\n" | |
3544 | "Advertise ORF capability to the peer\n" | |
3545 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3546 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3547 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3548 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3549 | |
718e3744 | 3550 | DEFUN (no_neighbor_capability_orf_prefix, |
3551 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3552 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3553 | NO_STR |
3554 | NEIGHBOR_STR | |
3555 | NEIGHBOR_ADDR_STR2 | |
3556 | "Advertise capability to the peer\n" | |
3557 | "Advertise ORF capability to the peer\n" | |
3558 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3559 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3560 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3561 | "Capability to SEND the ORF to this neighbor\n") | |
3562 | { | |
d62a17ae | 3563 | int idx_peer = 2; |
3564 | int idx_send_recv = 6; | |
3565 | u_int16_t flag = 0; | |
3566 | ||
3567 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3568 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3569 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3570 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3571 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3572 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3573 | else { | |
3574 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3575 | return CMD_WARNING_CONFIG_FAILED; | |
3576 | } | |
3577 | ||
3578 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3579 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3580 | flag); | |
3581 | } | |
3582 | ||
3583 | ALIAS_HIDDEN( | |
3584 | no_neighbor_capability_orf_prefix, | |
3585 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
3586 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3587 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3588 | "Advertise capability to the peer\n" | |
3589 | "Advertise ORF capability to the peer\n" | |
3590 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3591 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3592 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3593 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3594 | |
718e3744 | 3595 | /* neighbor next-hop-self. */ |
3596 | DEFUN (neighbor_nexthop_self, | |
3597 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3598 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3599 | NEIGHBOR_STR |
3600 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3601 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3602 | { |
d62a17ae | 3603 | int idx_peer = 1; |
3604 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3605 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 3606 | } |
9e7a53c1 | 3607 | |
d62a17ae | 3608 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
3609 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3610 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3611 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3612 | |
a538debe DS |
3613 | /* neighbor next-hop-self. */ |
3614 | DEFUN (neighbor_nexthop_self_force, | |
3615 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3616 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3617 | NEIGHBOR_STR |
3618 | NEIGHBOR_ADDR_STR2 | |
3619 | "Disable the next hop calculation for this neighbor\n" | |
3620 | "Set the next hop to self for reflected routes\n") | |
3621 | { | |
d62a17ae | 3622 | int idx_peer = 1; |
3623 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3624 | bgp_node_safi(vty), | |
3625 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 3626 | } |
3627 | ||
d62a17ae | 3628 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3629 | neighbor_nexthop_self_force_hidden_cmd, | |
3630 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3631 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3632 | "Disable the next hop calculation for this neighbor\n" | |
3633 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3634 | |
718e3744 | 3635 | DEFUN (no_neighbor_nexthop_self, |
3636 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3637 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3638 | NO_STR |
3639 | NEIGHBOR_STR | |
3640 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3641 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3642 | { |
d62a17ae | 3643 | int idx_peer = 2; |
3644 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3645 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3646 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 3647 | } |
6b0655a2 | 3648 | |
d62a17ae | 3649 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
3650 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3651 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3652 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3653 | |
88b8ed8d | 3654 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3655 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3656 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3657 | NO_STR |
3658 | NEIGHBOR_STR | |
3659 | NEIGHBOR_ADDR_STR2 | |
3660 | "Disable the next hop calculation for this neighbor\n" | |
3661 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3662 | { |
d62a17ae | 3663 | int idx_peer = 2; |
3664 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3665 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3666 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 3667 | } |
a538debe | 3668 | |
d62a17ae | 3669 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
3670 | no_neighbor_nexthop_self_force_hidden_cmd, | |
3671 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3672 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3673 | "Disable the next hop calculation for this neighbor\n" | |
3674 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3675 | |
c7122e14 DS |
3676 | /* neighbor as-override */ |
3677 | DEFUN (neighbor_as_override, | |
3678 | neighbor_as_override_cmd, | |
9ccf14f7 | 3679 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3680 | NEIGHBOR_STR |
3681 | NEIGHBOR_ADDR_STR2 | |
3682 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3683 | { | |
d62a17ae | 3684 | int idx_peer = 1; |
3685 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3686 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3687 | } |
3688 | ||
d62a17ae | 3689 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
3690 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3691 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3692 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3693 | |
c7122e14 DS |
3694 | DEFUN (no_neighbor_as_override, |
3695 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3696 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3697 | NO_STR |
3698 | NEIGHBOR_STR | |
3699 | NEIGHBOR_ADDR_STR2 | |
3700 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3701 | { | |
d62a17ae | 3702 | int idx_peer = 2; |
3703 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3704 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3705 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3706 | } |
3707 | ||
d62a17ae | 3708 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
3709 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3710 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3711 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3712 | |
718e3744 | 3713 | /* neighbor remove-private-AS. */ |
3714 | DEFUN (neighbor_remove_private_as, | |
3715 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3716 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3717 | NEIGHBOR_STR |
3718 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3719 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3720 | { |
d62a17ae | 3721 | int idx_peer = 1; |
3722 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3723 | bgp_node_safi(vty), | |
3724 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 3725 | } |
3726 | ||
d62a17ae | 3727 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
3728 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
3729 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3730 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 3731 | |
5000f21c DS |
3732 | DEFUN (neighbor_remove_private_as_all, |
3733 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 3734 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3735 | NEIGHBOR_STR |
3736 | NEIGHBOR_ADDR_STR2 | |
3737 | "Remove private ASNs in outbound updates\n" | |
3738 | "Apply to all AS numbers") | |
3739 | { | |
d62a17ae | 3740 | int idx_peer = 1; |
3741 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3742 | bgp_node_safi(vty), | |
3743 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
3744 | } |
3745 | ||
d62a17ae | 3746 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
3747 | neighbor_remove_private_as_all_hidden_cmd, | |
3748 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
3749 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3750 | "Remove private ASNs in outbound updates\n" | |
3751 | "Apply to all AS numbers") | |
596c17ba | 3752 | |
5000f21c DS |
3753 | DEFUN (neighbor_remove_private_as_replace_as, |
3754 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 3755 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3756 | NEIGHBOR_STR |
3757 | NEIGHBOR_ADDR_STR2 | |
3758 | "Remove private ASNs in outbound updates\n" | |
3759 | "Replace private ASNs with our ASN in outbound updates\n") | |
3760 | { | |
d62a17ae | 3761 | int idx_peer = 1; |
3762 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3763 | bgp_node_safi(vty), | |
3764 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
3765 | } |
3766 | ||
d62a17ae | 3767 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
3768 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
3769 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
3770 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3771 | "Remove private ASNs in outbound updates\n" | |
3772 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3773 | |
5000f21c DS |
3774 | DEFUN (neighbor_remove_private_as_all_replace_as, |
3775 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 3776 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3777 | NEIGHBOR_STR |
3778 | NEIGHBOR_ADDR_STR2 | |
3779 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3780 | "Apply to all AS numbers\n" |
5000f21c DS |
3781 | "Replace private ASNs with our ASN in outbound updates\n") |
3782 | { | |
d62a17ae | 3783 | int idx_peer = 1; |
3784 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3785 | bgp_node_safi(vty), | |
3786 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
3787 | } |
3788 | ||
d62a17ae | 3789 | ALIAS_HIDDEN( |
3790 | neighbor_remove_private_as_all_replace_as, | |
3791 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
3792 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
3793 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3794 | "Remove private ASNs in outbound updates\n" | |
3795 | "Apply to all AS numbers\n" | |
3796 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3797 | |
718e3744 | 3798 | DEFUN (no_neighbor_remove_private_as, |
3799 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3800 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3801 | NO_STR |
3802 | NEIGHBOR_STR | |
3803 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3804 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3805 | { |
d62a17ae | 3806 | int idx_peer = 2; |
3807 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3808 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3809 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 3810 | } |
6b0655a2 | 3811 | |
d62a17ae | 3812 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
3813 | no_neighbor_remove_private_as_hidden_cmd, | |
3814 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
3815 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3816 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 3817 | |
88b8ed8d | 3818 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 3819 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 3820 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3821 | NO_STR |
3822 | NEIGHBOR_STR | |
3823 | NEIGHBOR_ADDR_STR2 | |
3824 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3825 | "Apply to all AS numbers\n") |
88b8ed8d | 3826 | { |
d62a17ae | 3827 | int idx_peer = 2; |
3828 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3829 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3830 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 3831 | } |
5000f21c | 3832 | |
d62a17ae | 3833 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
3834 | no_neighbor_remove_private_as_all_hidden_cmd, | |
3835 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
3836 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3837 | "Remove private ASNs in outbound updates\n" | |
3838 | "Apply to all AS numbers\n") | |
596c17ba | 3839 | |
88b8ed8d | 3840 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 3841 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 3842 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3843 | NO_STR |
3844 | NEIGHBOR_STR | |
3845 | NEIGHBOR_ADDR_STR2 | |
3846 | "Remove private ASNs in outbound updates\n" | |
3847 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 3848 | { |
d62a17ae | 3849 | int idx_peer = 2; |
3850 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3851 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3852 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 3853 | } |
5000f21c | 3854 | |
d62a17ae | 3855 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
3856 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
3857 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
3858 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3859 | "Remove private ASNs in outbound updates\n" | |
3860 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3861 | |
88b8ed8d | 3862 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 3863 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 3864 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3865 | NO_STR |
3866 | NEIGHBOR_STR | |
3867 | NEIGHBOR_ADDR_STR2 | |
3868 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3869 | "Apply to all AS numbers\n" |
5000f21c | 3870 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 3871 | { |
d62a17ae | 3872 | int idx_peer = 2; |
3873 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3874 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3875 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 3876 | } |
5000f21c | 3877 | |
d62a17ae | 3878 | ALIAS_HIDDEN( |
3879 | no_neighbor_remove_private_as_all_replace_as, | |
3880 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
3881 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
3882 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3883 | "Remove private ASNs in outbound updates\n" | |
3884 | "Apply to all AS numbers\n" | |
3885 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3886 | |
5000f21c | 3887 | |
718e3744 | 3888 | /* neighbor send-community. */ |
3889 | DEFUN (neighbor_send_community, | |
3890 | neighbor_send_community_cmd, | |
9ccf14f7 | 3891 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3892 | NEIGHBOR_STR |
3893 | NEIGHBOR_ADDR_STR2 | |
3894 | "Send Community attribute to this neighbor\n") | |
3895 | { | |
d62a17ae | 3896 | int idx_peer = 1; |
3897 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3898 | bgp_node_safi(vty), | |
3899 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 3900 | } |
3901 | ||
d62a17ae | 3902 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
3903 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
3904 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3905 | "Send Community attribute to this neighbor\n") | |
596c17ba | 3906 | |
718e3744 | 3907 | DEFUN (no_neighbor_send_community, |
3908 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 3909 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3910 | NO_STR |
3911 | NEIGHBOR_STR | |
3912 | NEIGHBOR_ADDR_STR2 | |
3913 | "Send Community attribute to this neighbor\n") | |
3914 | { | |
d62a17ae | 3915 | int idx_peer = 2; |
3916 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3917 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3918 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 3919 | } |
6b0655a2 | 3920 | |
d62a17ae | 3921 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
3922 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
3923 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3924 | "Send Community attribute to this neighbor\n") | |
596c17ba | 3925 | |
718e3744 | 3926 | /* neighbor send-community extended. */ |
3927 | DEFUN (neighbor_send_community_type, | |
3928 | neighbor_send_community_type_cmd, | |
57d187bc | 3929 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 3930 | NEIGHBOR_STR |
3931 | NEIGHBOR_ADDR_STR2 | |
3932 | "Send Community attribute to this neighbor\n" | |
3933 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 3934 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 3935 | "Send Extended Community attributes\n" |
57d187bc JS |
3936 | "Send Standard Community attributes\n" |
3937 | "Send Large Community attributes\n") | |
718e3744 | 3938 | { |
d62a17ae | 3939 | int idx = 0; |
3940 | u_int32_t flag = 0; | |
3941 | ||
3942 | char *peer = argv[1]->arg; | |
3943 | ||
3944 | if (argv_find(argv, argc, "standard", &idx)) | |
3945 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
3946 | else if (argv_find(argv, argc, "extended", &idx)) | |
3947 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3948 | else if (argv_find(argv, argc, "large", &idx)) | |
3949 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
3950 | else if (argv_find(argv, argc, "both", &idx)) { | |
3951 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
3952 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3953 | } else { | |
3954 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
3955 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3956 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
3957 | } | |
3958 | ||
3959 | return peer_af_flag_set_vty(vty, peer, bgp_node_afi(vty), | |
3960 | bgp_node_safi(vty), flag); | |
3961 | } | |
3962 | ||
3963 | ALIAS_HIDDEN( | |
3964 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
3965 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
3966 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3967 | "Send Community attribute to this neighbor\n" | |
3968 | "Send Standard and Extended Community attributes\n" | |
3969 | "Send Standard, Large and Extended Community attributes\n" | |
3970 | "Send Extended Community attributes\n" | |
3971 | "Send Standard Community attributes\n" | |
3972 | "Send Large Community attributes\n") | |
596c17ba | 3973 | |
718e3744 | 3974 | DEFUN (no_neighbor_send_community_type, |
3975 | no_neighbor_send_community_type_cmd, | |
57d187bc | 3976 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 3977 | NO_STR |
3978 | NEIGHBOR_STR | |
3979 | NEIGHBOR_ADDR_STR2 | |
3980 | "Send Community attribute to this neighbor\n" | |
3981 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 3982 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 3983 | "Send Extended Community attributes\n" |
57d187bc JS |
3984 | "Send Standard Community attributes\n" |
3985 | "Send Large Community attributes\n") | |
718e3744 | 3986 | { |
d62a17ae | 3987 | int idx_peer = 2; |
3988 | ||
3989 | const char *type = argv[argc - 1]->text; | |
3990 | ||
3991 | if (strmatch(type, "standard")) | |
3992 | return peer_af_flag_unset_vty( | |
3993 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3994 | bgp_node_safi(vty), PEER_FLAG_SEND_COMMUNITY); | |
3995 | if (strmatch(type, "extended")) | |
3996 | return peer_af_flag_unset_vty( | |
3997 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3998 | bgp_node_safi(vty), PEER_FLAG_SEND_EXT_COMMUNITY); | |
3999 | if (strmatch(type, "large")) | |
4000 | return peer_af_flag_unset_vty( | |
4001 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4002 | bgp_node_safi(vty), PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4003 | if (strmatch(type, "both")) | |
4004 | return peer_af_flag_unset_vty( | |
4005 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4006 | bgp_node_safi(vty), | |
4007 | PEER_FLAG_SEND_COMMUNITY | |
4008 | | PEER_FLAG_SEND_EXT_COMMUNITY); | |
4009 | ||
4010 | /* if (strmatch (type, "all")) */ | |
4011 | return peer_af_flag_unset_vty( | |
4012 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4013 | (PEER_FLAG_SEND_COMMUNITY | PEER_FLAG_SEND_EXT_COMMUNITY | |
4014 | | PEER_FLAG_SEND_LARGE_COMMUNITY)); | |
4015 | } | |
4016 | ||
4017 | ALIAS_HIDDEN( | |
4018 | no_neighbor_send_community_type, | |
4019 | no_neighbor_send_community_type_hidden_cmd, | |
4020 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4021 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4022 | "Send Community attribute to this neighbor\n" | |
4023 | "Send Standard and Extended Community attributes\n" | |
4024 | "Send Standard, Large and Extended Community attributes\n" | |
4025 | "Send Extended Community attributes\n" | |
4026 | "Send Standard Community attributes\n" | |
4027 | "Send Large Community attributes\n") | |
596c17ba | 4028 | |
718e3744 | 4029 | /* neighbor soft-reconfig. */ |
4030 | DEFUN (neighbor_soft_reconfiguration, | |
4031 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4032 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4033 | NEIGHBOR_STR |
4034 | NEIGHBOR_ADDR_STR2 | |
4035 | "Per neighbor soft reconfiguration\n" | |
4036 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4037 | { | |
d62a17ae | 4038 | int idx_peer = 1; |
4039 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4040 | bgp_node_safi(vty), | |
4041 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4042 | } |
4043 | ||
d62a17ae | 4044 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4045 | neighbor_soft_reconfiguration_hidden_cmd, | |
4046 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4047 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4048 | "Per neighbor soft reconfiguration\n" | |
4049 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4050 | |
718e3744 | 4051 | DEFUN (no_neighbor_soft_reconfiguration, |
4052 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4053 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4054 | NO_STR |
4055 | NEIGHBOR_STR | |
4056 | NEIGHBOR_ADDR_STR2 | |
4057 | "Per neighbor soft reconfiguration\n" | |
4058 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4059 | { | |
d62a17ae | 4060 | int idx_peer = 2; |
4061 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4062 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4063 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4064 | } |
6b0655a2 | 4065 | |
d62a17ae | 4066 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
4067 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4068 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4069 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4070 | "Per neighbor soft reconfiguration\n" | |
4071 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4072 | |
718e3744 | 4073 | DEFUN (neighbor_route_reflector_client, |
4074 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4075 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4076 | NEIGHBOR_STR |
4077 | NEIGHBOR_ADDR_STR2 | |
4078 | "Configure a neighbor as Route Reflector client\n") | |
4079 | { | |
d62a17ae | 4080 | int idx_peer = 1; |
4081 | struct peer *peer; | |
718e3744 | 4082 | |
4083 | ||
d62a17ae | 4084 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4085 | if (!peer) | |
4086 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4087 | |
d62a17ae | 4088 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4089 | bgp_node_safi(vty), | |
4090 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4091 | } |
4092 | ||
d62a17ae | 4093 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
4094 | neighbor_route_reflector_client_hidden_cmd, | |
4095 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4096 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4097 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4098 | |
718e3744 | 4099 | DEFUN (no_neighbor_route_reflector_client, |
4100 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4101 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4102 | NO_STR |
4103 | NEIGHBOR_STR | |
4104 | NEIGHBOR_ADDR_STR2 | |
4105 | "Configure a neighbor as Route Reflector client\n") | |
4106 | { | |
d62a17ae | 4107 | int idx_peer = 2; |
4108 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4109 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4110 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4111 | } |
6b0655a2 | 4112 | |
d62a17ae | 4113 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
4114 | no_neighbor_route_reflector_client_hidden_cmd, | |
4115 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4116 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4117 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4118 | |
718e3744 | 4119 | /* neighbor route-server-client. */ |
4120 | DEFUN (neighbor_route_server_client, | |
4121 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4122 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4123 | NEIGHBOR_STR |
4124 | NEIGHBOR_ADDR_STR2 | |
4125 | "Configure a neighbor as Route Server client\n") | |
4126 | { | |
d62a17ae | 4127 | int idx_peer = 1; |
4128 | struct peer *peer; | |
2a3d5731 | 4129 | |
d62a17ae | 4130 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4131 | if (!peer) | |
4132 | return CMD_WARNING_CONFIG_FAILED; | |
4133 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4134 | bgp_node_safi(vty), | |
4135 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4136 | } |
4137 | ||
d62a17ae | 4138 | ALIAS_HIDDEN(neighbor_route_server_client, |
4139 | neighbor_route_server_client_hidden_cmd, | |
4140 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4141 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4142 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4143 | |
718e3744 | 4144 | DEFUN (no_neighbor_route_server_client, |
4145 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4146 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4147 | NO_STR |
4148 | NEIGHBOR_STR | |
4149 | NEIGHBOR_ADDR_STR2 | |
4150 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4151 | { |
d62a17ae | 4152 | int idx_peer = 2; |
4153 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4154 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4155 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4156 | } |
6b0655a2 | 4157 | |
d62a17ae | 4158 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
4159 | no_neighbor_route_server_client_hidden_cmd, | |
4160 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4161 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4162 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4163 | |
fee0f4c6 | 4164 | DEFUN (neighbor_nexthop_local_unchanged, |
4165 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4166 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4167 | NEIGHBOR_STR |
4168 | NEIGHBOR_ADDR_STR2 | |
4169 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4170 | "Leave link-local nexthop unchanged for this peer\n") | |
4171 | { | |
d62a17ae | 4172 | int idx_peer = 1; |
4173 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4174 | bgp_node_safi(vty), | |
4175 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 4176 | } |
6b0655a2 | 4177 | |
fee0f4c6 | 4178 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4179 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4180 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4181 | NO_STR |
4182 | NEIGHBOR_STR | |
4183 | NEIGHBOR_ADDR_STR2 | |
4184 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4185 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4186 | { |
d62a17ae | 4187 | int idx_peer = 2; |
4188 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4189 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4190 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 4191 | } |
6b0655a2 | 4192 | |
718e3744 | 4193 | DEFUN (neighbor_attr_unchanged, |
4194 | neighbor_attr_unchanged_cmd, | |
a8206004 | 4195 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 4196 | NEIGHBOR_STR |
4197 | NEIGHBOR_ADDR_STR2 | |
4198 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4199 | "As-path attribute\n" | |
4200 | "Nexthop attribute\n" | |
a8206004 | 4201 | "Med attribute\n") |
718e3744 | 4202 | { |
d62a17ae | 4203 | int idx = 0; |
4204 | char *peer = argv[1]->arg; | |
4205 | u_int16_t flags = 0; | |
4206 | ||
4207 | if (argv_find(argv, argc, "as-path", &idx)) | |
4208 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4209 | idx = 0; | |
4210 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4211 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4212 | idx = 0; | |
4213 | if (argv_find(argv, argc, "med", &idx)) | |
4214 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4215 | ||
4216 | if (!flags) // no flags means all of them! | |
4217 | { | |
4218 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4219 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4220 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4221 | } | |
4222 | ||
4223 | return peer_af_flag_set_vty(vty, peer, bgp_node_afi(vty), | |
4224 | bgp_node_safi(vty), flags); | |
4225 | } | |
4226 | ||
4227 | ALIAS_HIDDEN( | |
4228 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
4229 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4230 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4231 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4232 | "As-path attribute\n" | |
4233 | "Nexthop attribute\n" | |
4234 | "Med attribute\n") | |
596c17ba | 4235 | |
718e3744 | 4236 | DEFUN (no_neighbor_attr_unchanged, |
4237 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 4238 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 4239 | NO_STR |
718e3744 | 4240 | NEIGHBOR_STR |
4241 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4242 | "BGP attribute is propagated unchanged to this neighbor\n" |
4243 | "As-path attribute\n" | |
40e718b5 | 4244 | "Nexthop attribute\n" |
a8206004 | 4245 | "Med attribute\n") |
718e3744 | 4246 | { |
d62a17ae | 4247 | int idx = 0; |
4248 | char *peer = argv[2]->arg; | |
4249 | u_int16_t flags = 0; | |
4250 | ||
4251 | if (argv_find(argv, argc, "as-path", &idx)) | |
4252 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4253 | idx = 0; | |
4254 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4255 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4256 | idx = 0; | |
4257 | if (argv_find(argv, argc, "med", &idx)) | |
4258 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4259 | ||
4260 | if (!flags) // no flags means all of them! | |
4261 | { | |
4262 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4263 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4264 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4265 | } | |
4266 | ||
4267 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
4268 | bgp_node_safi(vty), flags); | |
4269 | } | |
4270 | ||
4271 | ALIAS_HIDDEN( | |
4272 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
4273 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4274 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4275 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4276 | "As-path attribute\n" | |
4277 | "Nexthop attribute\n" | |
4278 | "Med attribute\n") | |
718e3744 | 4279 | |
718e3744 | 4280 | /* EBGP multihop configuration. */ |
d62a17ae | 4281 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
4282 | const char *ttl_str) | |
718e3744 | 4283 | { |
d62a17ae | 4284 | struct peer *peer; |
4285 | unsigned int ttl; | |
718e3744 | 4286 | |
d62a17ae | 4287 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4288 | if (!peer) | |
4289 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4290 | |
d62a17ae | 4291 | if (peer->conf_if) |
4292 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 4293 | |
d62a17ae | 4294 | if (!ttl_str) |
4295 | ttl = MAXTTL; | |
4296 | else | |
4297 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 4298 | |
d62a17ae | 4299 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 4300 | } |
4301 | ||
d62a17ae | 4302 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4303 | { |
d62a17ae | 4304 | struct peer *peer; |
718e3744 | 4305 | |
d62a17ae | 4306 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4307 | if (!peer) | |
4308 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4309 | |
d62a17ae | 4310 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 4311 | } |
4312 | ||
4313 | /* neighbor ebgp-multihop. */ | |
4314 | DEFUN (neighbor_ebgp_multihop, | |
4315 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4316 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4317 | NEIGHBOR_STR |
4318 | NEIGHBOR_ADDR_STR2 | |
4319 | "Allow EBGP neighbors not on directly connected networks\n") | |
4320 | { | |
d62a17ae | 4321 | int idx_peer = 1; |
4322 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4323 | } |
4324 | ||
4325 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4326 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4327 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4328 | NEIGHBOR_STR |
4329 | NEIGHBOR_ADDR_STR2 | |
4330 | "Allow EBGP neighbors not on directly connected networks\n" | |
4331 | "maximum hop count\n") | |
4332 | { | |
d62a17ae | 4333 | int idx_peer = 1; |
4334 | int idx_number = 3; | |
4335 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
4336 | argv[idx_number]->arg); | |
718e3744 | 4337 | } |
4338 | ||
4339 | DEFUN (no_neighbor_ebgp_multihop, | |
4340 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4341 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4342 | NO_STR |
4343 | NEIGHBOR_STR | |
4344 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4345 | "Allow EBGP neighbors not on directly connected networks\n" |
4346 | "maximum hop count\n") | |
718e3744 | 4347 | { |
d62a17ae | 4348 | int idx_peer = 2; |
4349 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4350 | } |
4351 | ||
6b0655a2 | 4352 | |
6ffd2079 | 4353 | /* disable-connected-check */ |
4354 | DEFUN (neighbor_disable_connected_check, | |
4355 | neighbor_disable_connected_check_cmd, | |
a636c635 | 4356 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4357 | NEIGHBOR_STR |
4358 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4359 | "one-hop away EBGP peer using loopback address\n" |
4360 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4361 | { |
d62a17ae | 4362 | int idx_peer = 1; |
4363 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4364 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4365 | } |
4366 | ||
4367 | DEFUN (no_neighbor_disable_connected_check, | |
4368 | no_neighbor_disable_connected_check_cmd, | |
a636c635 | 4369 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4370 | NO_STR |
4371 | NEIGHBOR_STR | |
4372 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4373 | "one-hop away EBGP peer using loopback address\n" |
4374 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4375 | { |
d62a17ae | 4376 | int idx_peer = 2; |
4377 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4378 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4379 | } |
4380 | ||
718e3744 | 4381 | DEFUN (neighbor_description, |
4382 | neighbor_description_cmd, | |
e961923c | 4383 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4384 | NEIGHBOR_STR |
4385 | NEIGHBOR_ADDR_STR2 | |
4386 | "Neighbor specific description\n" | |
4387 | "Up to 80 characters describing this neighbor\n") | |
4388 | { | |
d62a17ae | 4389 | int idx_peer = 1; |
4390 | int idx_line = 3; | |
4391 | struct peer *peer; | |
4392 | char *str; | |
718e3744 | 4393 | |
d62a17ae | 4394 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4395 | if (!peer) | |
4396 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4397 | |
d62a17ae | 4398 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4399 | |
d62a17ae | 4400 | peer_description_set(peer, str); |
718e3744 | 4401 | |
d62a17ae | 4402 | XFREE(MTYPE_TMP, str); |
718e3744 | 4403 | |
d62a17ae | 4404 | return CMD_SUCCESS; |
718e3744 | 4405 | } |
4406 | ||
4407 | DEFUN (no_neighbor_description, | |
4408 | no_neighbor_description_cmd, | |
a636c635 | 4409 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]", |
718e3744 | 4410 | NO_STR |
4411 | NEIGHBOR_STR | |
4412 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4413 | "Neighbor specific description\n" |
4414 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 4415 | { |
d62a17ae | 4416 | int idx_peer = 2; |
4417 | struct peer *peer; | |
718e3744 | 4418 | |
d62a17ae | 4419 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4420 | if (!peer) | |
4421 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4422 | |
d62a17ae | 4423 | peer_description_unset(peer); |
718e3744 | 4424 | |
d62a17ae | 4425 | return CMD_SUCCESS; |
718e3744 | 4426 | } |
4427 | ||
6b0655a2 | 4428 | |
718e3744 | 4429 | /* Neighbor update-source. */ |
d62a17ae | 4430 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
4431 | const char *source_str) | |
4432 | { | |
4433 | struct peer *peer; | |
4434 | struct prefix p; | |
4435 | ||
4436 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4437 | if (!peer) | |
4438 | return CMD_WARNING_CONFIG_FAILED; | |
4439 | ||
4440 | if (peer->conf_if) | |
4441 | return CMD_WARNING; | |
4442 | ||
4443 | if (source_str) { | |
4444 | union sockunion su; | |
4445 | int ret = str2sockunion(source_str, &su); | |
4446 | ||
4447 | if (ret == 0) | |
4448 | peer_update_source_addr_set(peer, &su); | |
4449 | else { | |
4450 | if (str2prefix(source_str, &p)) { | |
4451 | vty_out(vty, | |
4452 | "%% Invalid update-source, remove prefix length \n"); | |
4453 | return CMD_WARNING_CONFIG_FAILED; | |
4454 | } else | |
4455 | peer_update_source_if_set(peer, source_str); | |
4456 | } | |
4457 | } else | |
4458 | peer_update_source_unset(peer); | |
4459 | ||
4460 | return CMD_SUCCESS; | |
4461 | } | |
4462 | ||
4463 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
4464 | "IPv4 address\n" \ | |
4465 | "IPv6 address\n" \ | |
4466 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4467 | |
718e3744 | 4468 | DEFUN (neighbor_update_source, |
4469 | neighbor_update_source_cmd, | |
9ccf14f7 | 4470 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4471 | NEIGHBOR_STR |
4472 | NEIGHBOR_ADDR_STR2 | |
4473 | "Source of routing updates\n" | |
369688c0 | 4474 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4475 | { |
d62a17ae | 4476 | int idx_peer = 1; |
4477 | int idx_peer_2 = 3; | |
4478 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
4479 | argv[idx_peer_2]->arg); | |
718e3744 | 4480 | } |
4481 | ||
4482 | DEFUN (no_neighbor_update_source, | |
4483 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4484 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4485 | NO_STR |
4486 | NEIGHBOR_STR | |
4487 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4488 | "Source of routing updates\n" |
4489 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4490 | { |
d62a17ae | 4491 | int idx_peer = 2; |
4492 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4493 | } |
6b0655a2 | 4494 | |
d62a17ae | 4495 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
4496 | afi_t afi, safi_t safi, | |
4497 | const char *rmap, int set) | |
718e3744 | 4498 | { |
d62a17ae | 4499 | int ret; |
4500 | struct peer *peer; | |
718e3744 | 4501 | |
d62a17ae | 4502 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4503 | if (!peer) | |
4504 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4505 | |
d62a17ae | 4506 | if (set) |
4507 | ret = peer_default_originate_set(peer, afi, safi, rmap); | |
4508 | else | |
4509 | ret = peer_default_originate_unset(peer, afi, safi); | |
718e3744 | 4510 | |
d62a17ae | 4511 | return bgp_vty_return(vty, ret); |
718e3744 | 4512 | } |
4513 | ||
4514 | /* neighbor default-originate. */ | |
4515 | DEFUN (neighbor_default_originate, | |
4516 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4517 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4518 | NEIGHBOR_STR |
4519 | NEIGHBOR_ADDR_STR2 | |
4520 | "Originate default route to this neighbor\n") | |
4521 | { | |
d62a17ae | 4522 | int idx_peer = 1; |
4523 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4524 | bgp_node_afi(vty), | |
4525 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 4526 | } |
4527 | ||
d62a17ae | 4528 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
4529 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
4530 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4531 | "Originate default route to this neighbor\n") | |
596c17ba | 4532 | |
718e3744 | 4533 | DEFUN (neighbor_default_originate_rmap, |
4534 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4535 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4536 | NEIGHBOR_STR |
4537 | NEIGHBOR_ADDR_STR2 | |
4538 | "Originate default route to this neighbor\n" | |
4539 | "Route-map to specify criteria to originate default\n" | |
4540 | "route-map name\n") | |
4541 | { | |
d62a17ae | 4542 | int idx_peer = 1; |
4543 | int idx_word = 4; | |
4544 | return peer_default_originate_set_vty( | |
4545 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4546 | argv[idx_word]->arg, 1); | |
718e3744 | 4547 | } |
4548 | ||
d62a17ae | 4549 | ALIAS_HIDDEN( |
4550 | neighbor_default_originate_rmap, | |
4551 | neighbor_default_originate_rmap_hidden_cmd, | |
4552 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
4553 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4554 | "Originate default route to this neighbor\n" | |
4555 | "Route-map to specify criteria to originate default\n" | |
4556 | "route-map name\n") | |
596c17ba | 4557 | |
718e3744 | 4558 | DEFUN (no_neighbor_default_originate, |
4559 | no_neighbor_default_originate_cmd, | |
a636c635 | 4560 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4561 | NO_STR |
4562 | NEIGHBOR_STR | |
4563 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4564 | "Originate default route to this neighbor\n" |
4565 | "Route-map to specify criteria to originate default\n" | |
4566 | "route-map name\n") | |
718e3744 | 4567 | { |
d62a17ae | 4568 | int idx_peer = 2; |
4569 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4570 | bgp_node_afi(vty), | |
4571 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 4572 | } |
4573 | ||
d62a17ae | 4574 | ALIAS_HIDDEN( |
4575 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
4576 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
4577 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4578 | "Originate default route to this neighbor\n" | |
4579 | "Route-map to specify criteria to originate default\n" | |
4580 | "route-map name\n") | |
596c17ba | 4581 | |
6b0655a2 | 4582 | |
718e3744 | 4583 | /* Set neighbor's BGP port. */ |
d62a17ae | 4584 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
4585 | const char *port_str) | |
4586 | { | |
4587 | struct peer *peer; | |
4588 | u_int16_t port; | |
4589 | struct servent *sp; | |
4590 | ||
4591 | peer = peer_lookup_vty(vty, ip_str); | |
4592 | if (!peer) | |
4593 | return CMD_WARNING_CONFIG_FAILED; | |
4594 | ||
4595 | if (!port_str) { | |
4596 | sp = getservbyname("bgp", "tcp"); | |
4597 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
4598 | } else { | |
4599 | port = strtoul(port_str, NULL, 10); | |
4600 | } | |
718e3744 | 4601 | |
d62a17ae | 4602 | peer_port_set(peer, port); |
718e3744 | 4603 | |
d62a17ae | 4604 | return CMD_SUCCESS; |
718e3744 | 4605 | } |
4606 | ||
f418446b | 4607 | /* Set specified peer's BGP port. */ |
718e3744 | 4608 | DEFUN (neighbor_port, |
4609 | neighbor_port_cmd, | |
9ccf14f7 | 4610 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4611 | NEIGHBOR_STR |
4612 | NEIGHBOR_ADDR_STR | |
4613 | "Neighbor's BGP port\n" | |
4614 | "TCP port number\n") | |
4615 | { | |
d62a17ae | 4616 | int idx_ip = 1; |
4617 | int idx_number = 3; | |
4618 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
4619 | argv[idx_number]->arg); | |
718e3744 | 4620 | } |
4621 | ||
4622 | DEFUN (no_neighbor_port, | |
4623 | no_neighbor_port_cmd, | |
9ccf14f7 | 4624 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4625 | NO_STR |
4626 | NEIGHBOR_STR | |
4627 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4628 | "Neighbor's BGP port\n" |
4629 | "TCP port number\n") | |
718e3744 | 4630 | { |
d62a17ae | 4631 | int idx_ip = 2; |
4632 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4633 | } |
4634 | ||
6b0655a2 | 4635 | |
718e3744 | 4636 | /* neighbor weight. */ |
d62a17ae | 4637 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4638 | safi_t safi, const char *weight_str) | |
718e3744 | 4639 | { |
d62a17ae | 4640 | int ret; |
4641 | struct peer *peer; | |
4642 | unsigned long weight; | |
718e3744 | 4643 | |
d62a17ae | 4644 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4645 | if (!peer) | |
4646 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4647 | |
d62a17ae | 4648 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 4649 | |
d62a17ae | 4650 | ret = peer_weight_set(peer, afi, safi, weight); |
4651 | return bgp_vty_return(vty, ret); | |
718e3744 | 4652 | } |
4653 | ||
d62a17ae | 4654 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4655 | safi_t safi) | |
718e3744 | 4656 | { |
d62a17ae | 4657 | int ret; |
4658 | struct peer *peer; | |
718e3744 | 4659 | |
d62a17ae | 4660 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4661 | if (!peer) | |
4662 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4663 | |
d62a17ae | 4664 | ret = peer_weight_unset(peer, afi, safi); |
4665 | return bgp_vty_return(vty, ret); | |
718e3744 | 4666 | } |
4667 | ||
4668 | DEFUN (neighbor_weight, | |
4669 | neighbor_weight_cmd, | |
9ccf14f7 | 4670 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 4671 | NEIGHBOR_STR |
4672 | NEIGHBOR_ADDR_STR2 | |
4673 | "Set default weight for routes from this neighbor\n" | |
4674 | "default weight\n") | |
4675 | { | |
d62a17ae | 4676 | int idx_peer = 1; |
4677 | int idx_number = 3; | |
4678 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4679 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 4680 | } |
4681 | ||
d62a17ae | 4682 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
4683 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
4684 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4685 | "Set default weight for routes from this neighbor\n" | |
4686 | "default weight\n") | |
596c17ba | 4687 | |
718e3744 | 4688 | DEFUN (no_neighbor_weight, |
4689 | no_neighbor_weight_cmd, | |
9ccf14f7 | 4690 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 4691 | NO_STR |
4692 | NEIGHBOR_STR | |
4693 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4694 | "Set default weight for routes from this neighbor\n" |
4695 | "default weight\n") | |
718e3744 | 4696 | { |
d62a17ae | 4697 | int idx_peer = 2; |
4698 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
4699 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 4700 | } |
4701 | ||
d62a17ae | 4702 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
4703 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
4704 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4705 | "Set default weight for routes from this neighbor\n" | |
4706 | "default weight\n") | |
596c17ba | 4707 | |
6b0655a2 | 4708 | |
718e3744 | 4709 | /* Override capability negotiation. */ |
4710 | DEFUN (neighbor_override_capability, | |
4711 | neighbor_override_capability_cmd, | |
9ccf14f7 | 4712 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4713 | NEIGHBOR_STR |
4714 | NEIGHBOR_ADDR_STR2 | |
4715 | "Override capability negotiation result\n") | |
4716 | { | |
d62a17ae | 4717 | int idx_peer = 1; |
4718 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4719 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4720 | } |
4721 | ||
4722 | DEFUN (no_neighbor_override_capability, | |
4723 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 4724 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4725 | NO_STR |
4726 | NEIGHBOR_STR | |
4727 | NEIGHBOR_ADDR_STR2 | |
4728 | "Override capability negotiation result\n") | |
4729 | { | |
d62a17ae | 4730 | int idx_peer = 2; |
4731 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4732 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4733 | } |
6b0655a2 | 4734 | |
718e3744 | 4735 | DEFUN (neighbor_strict_capability, |
4736 | neighbor_strict_capability_cmd, | |
9ccf14f7 | 4737 | "neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4738 | NEIGHBOR_STR |
4739 | NEIGHBOR_ADDR_STR | |
4740 | "Strict capability negotiation match\n") | |
4741 | { | |
d62a17ae | 4742 | int idx_ip = 1; |
4743 | return peer_flag_set_vty(vty, argv[idx_ip]->arg, | |
4744 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4745 | } |
4746 | ||
4747 | DEFUN (no_neighbor_strict_capability, | |
4748 | no_neighbor_strict_capability_cmd, | |
9ccf14f7 | 4749 | "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4750 | NO_STR |
4751 | NEIGHBOR_STR | |
4752 | NEIGHBOR_ADDR_STR | |
4753 | "Strict capability negotiation match\n") | |
4754 | { | |
d62a17ae | 4755 | int idx_ip = 2; |
4756 | return peer_flag_unset_vty(vty, argv[idx_ip]->arg, | |
4757 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4758 | } |
6b0655a2 | 4759 | |
d62a17ae | 4760 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
4761 | const char *keep_str, const char *hold_str) | |
718e3744 | 4762 | { |
d62a17ae | 4763 | int ret; |
4764 | struct peer *peer; | |
4765 | u_int32_t keepalive; | |
4766 | u_int32_t holdtime; | |
718e3744 | 4767 | |
d62a17ae | 4768 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4769 | if (!peer) | |
4770 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4771 | |
d62a17ae | 4772 | keepalive = strtoul(keep_str, NULL, 10); |
4773 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 4774 | |
d62a17ae | 4775 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 4776 | |
d62a17ae | 4777 | return bgp_vty_return(vty, ret); |
718e3744 | 4778 | } |
6b0655a2 | 4779 | |
d62a17ae | 4780 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4781 | { |
d62a17ae | 4782 | int ret; |
4783 | struct peer *peer; | |
718e3744 | 4784 | |
d62a17ae | 4785 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4786 | if (!peer) | |
4787 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4788 | |
d62a17ae | 4789 | ret = peer_timers_unset(peer); |
718e3744 | 4790 | |
d62a17ae | 4791 | return bgp_vty_return(vty, ret); |
718e3744 | 4792 | } |
4793 | ||
4794 | DEFUN (neighbor_timers, | |
4795 | neighbor_timers_cmd, | |
9ccf14f7 | 4796 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 4797 | NEIGHBOR_STR |
4798 | NEIGHBOR_ADDR_STR2 | |
4799 | "BGP per neighbor timers\n" | |
4800 | "Keepalive interval\n" | |
4801 | "Holdtime\n") | |
4802 | { | |
d62a17ae | 4803 | int idx_peer = 1; |
4804 | int idx_number = 3; | |
4805 | int idx_number_2 = 4; | |
4806 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
4807 | argv[idx_number]->arg, | |
4808 | argv[idx_number_2]->arg); | |
718e3744 | 4809 | } |
4810 | ||
4811 | DEFUN (no_neighbor_timers, | |
4812 | no_neighbor_timers_cmd, | |
9ccf14f7 | 4813 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 4814 | NO_STR |
4815 | NEIGHBOR_STR | |
4816 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4817 | "BGP per neighbor timers\n" |
4818 | "Keepalive interval\n" | |
4819 | "Holdtime\n") | |
718e3744 | 4820 | { |
d62a17ae | 4821 | int idx_peer = 2; |
4822 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4823 | } |
6b0655a2 | 4824 | |
813d4307 | 4825 | |
d62a17ae | 4826 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
4827 | const char *time_str) | |
718e3744 | 4828 | { |
d62a17ae | 4829 | int ret; |
4830 | struct peer *peer; | |
4831 | u_int32_t connect; | |
718e3744 | 4832 | |
d62a17ae | 4833 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4834 | if (!peer) | |
4835 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4836 | |
d62a17ae | 4837 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 4838 | |
d62a17ae | 4839 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 4840 | |
d62a17ae | 4841 | return bgp_vty_return(vty, ret); |
718e3744 | 4842 | } |
4843 | ||
d62a17ae | 4844 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4845 | { |
d62a17ae | 4846 | int ret; |
4847 | struct peer *peer; | |
718e3744 | 4848 | |
d62a17ae | 4849 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4850 | if (!peer) | |
4851 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4852 | |
d62a17ae | 4853 | ret = peer_timers_connect_unset(peer); |
718e3744 | 4854 | |
d62a17ae | 4855 | return bgp_vty_return(vty, ret); |
718e3744 | 4856 | } |
4857 | ||
4858 | DEFUN (neighbor_timers_connect, | |
4859 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 4860 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 4861 | NEIGHBOR_STR |
966f821c | 4862 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4863 | "BGP per neighbor timers\n" |
4864 | "BGP connect timer\n" | |
4865 | "Connect timer\n") | |
4866 | { | |
d62a17ae | 4867 | int idx_peer = 1; |
4868 | int idx_number = 4; | |
4869 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
4870 | argv[idx_number]->arg); | |
718e3744 | 4871 | } |
4872 | ||
4873 | DEFUN (no_neighbor_timers_connect, | |
4874 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 4875 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 4876 | NO_STR |
4877 | NEIGHBOR_STR | |
966f821c | 4878 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4879 | "BGP per neighbor timers\n" |
8334fd5a DW |
4880 | "BGP connect timer\n" |
4881 | "Connect timer\n") | |
718e3744 | 4882 | { |
d62a17ae | 4883 | int idx_peer = 2; |
4884 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4885 | } |
4886 | ||
6b0655a2 | 4887 | |
d62a17ae | 4888 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
4889 | const char *time_str, int set) | |
718e3744 | 4890 | { |
d62a17ae | 4891 | int ret; |
4892 | struct peer *peer; | |
4893 | u_int32_t routeadv = 0; | |
718e3744 | 4894 | |
d62a17ae | 4895 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4896 | if (!peer) | |
4897 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4898 | |
d62a17ae | 4899 | if (time_str) |
4900 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 4901 | |
d62a17ae | 4902 | if (set) |
4903 | ret = peer_advertise_interval_set(peer, routeadv); | |
4904 | else | |
4905 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 4906 | |
d62a17ae | 4907 | return bgp_vty_return(vty, ret); |
718e3744 | 4908 | } |
4909 | ||
4910 | DEFUN (neighbor_advertise_interval, | |
4911 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4912 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 4913 | NEIGHBOR_STR |
966f821c | 4914 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4915 | "Minimum interval between sending BGP routing updates\n" |
4916 | "time in seconds\n") | |
4917 | { | |
d62a17ae | 4918 | int idx_peer = 1; |
4919 | int idx_number = 3; | |
4920 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
4921 | argv[idx_number]->arg, 1); | |
718e3744 | 4922 | } |
4923 | ||
4924 | DEFUN (no_neighbor_advertise_interval, | |
4925 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4926 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 4927 | NO_STR |
4928 | NEIGHBOR_STR | |
966f821c | 4929 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
4930 | "Minimum interval between sending BGP routing updates\n" |
4931 | "time in seconds\n") | |
718e3744 | 4932 | { |
d62a17ae | 4933 | int idx_peer = 2; |
4934 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 4935 | } |
4936 | ||
6b0655a2 | 4937 | |
518f0eb1 DS |
4938 | /* Time to wait before processing route-map updates */ |
4939 | DEFUN (bgp_set_route_map_delay_timer, | |
4940 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 4941 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
4942 | SET_STR |
4943 | "BGP route-map delay timer\n" | |
4944 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 4945 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 4946 | { |
d62a17ae | 4947 | int idx_number = 3; |
4948 | u_int32_t rmap_delay_timer; | |
4949 | ||
4950 | if (argv[idx_number]->arg) { | |
4951 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
4952 | bm->rmap_update_timer = rmap_delay_timer; | |
4953 | ||
4954 | /* if the dynamic update handling is being disabled, and a timer | |
4955 | * is | |
4956 | * running, stop the timer and act as if the timer has already | |
4957 | * fired. | |
4958 | */ | |
4959 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
4960 | BGP_TIMER_OFF(bm->t_rmap_update); | |
4961 | thread_execute(bm->master, bgp_route_map_update_timer, | |
4962 | NULL, 0); | |
4963 | } | |
4964 | return CMD_SUCCESS; | |
4965 | } else { | |
4966 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
4967 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 4968 | } |
518f0eb1 DS |
4969 | } |
4970 | ||
4971 | DEFUN (no_bgp_set_route_map_delay_timer, | |
4972 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 4973 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 4974 | NO_STR |
3a2d747c | 4975 | BGP_STR |
518f0eb1 | 4976 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
4977 | "Reset to default time to wait for processing route-map changes\n" |
4978 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 4979 | { |
518f0eb1 | 4980 | |
d62a17ae | 4981 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 4982 | |
d62a17ae | 4983 | return CMD_SUCCESS; |
518f0eb1 DS |
4984 | } |
4985 | ||
f414725f | 4986 | |
718e3744 | 4987 | /* neighbor interface */ |
d62a17ae | 4988 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
4989 | const char *str) | |
718e3744 | 4990 | { |
d62a17ae | 4991 | struct peer *peer; |
718e3744 | 4992 | |
d62a17ae | 4993 | peer = peer_lookup_vty(vty, ip_str); |
4994 | if (!peer || peer->conf_if) { | |
4995 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
4996 | return CMD_WARNING_CONFIG_FAILED; | |
4997 | } | |
718e3744 | 4998 | |
d62a17ae | 4999 | if (str) |
5000 | peer_interface_set(peer, str); | |
5001 | else | |
5002 | peer_interface_unset(peer); | |
718e3744 | 5003 | |
d62a17ae | 5004 | return CMD_SUCCESS; |
718e3744 | 5005 | } |
5006 | ||
5007 | DEFUN (neighbor_interface, | |
5008 | neighbor_interface_cmd, | |
9ccf14f7 | 5009 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5010 | NEIGHBOR_STR |
5011 | NEIGHBOR_ADDR_STR | |
5012 | "Interface\n" | |
5013 | "Interface name\n") | |
5014 | { | |
d62a17ae | 5015 | int idx_ip = 1; |
5016 | int idx_word = 3; | |
5017 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 5018 | } |
5019 | ||
5020 | DEFUN (no_neighbor_interface, | |
5021 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5022 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5023 | NO_STR |
5024 | NEIGHBOR_STR | |
16cedbb0 | 5025 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5026 | "Interface\n" |
5027 | "Interface name\n") | |
5028 | { | |
d62a17ae | 5029 | int idx_peer = 2; |
5030 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5031 | } |
6b0655a2 | 5032 | |
718e3744 | 5033 | DEFUN (neighbor_distribute_list, |
5034 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5035 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5036 | NEIGHBOR_STR |
5037 | NEIGHBOR_ADDR_STR2 | |
5038 | "Filter updates to/from this neighbor\n" | |
5039 | "IP access-list number\n" | |
5040 | "IP access-list number (expanded range)\n" | |
5041 | "IP Access-list name\n" | |
5042 | "Filter incoming updates\n" | |
5043 | "Filter outgoing updates\n") | |
5044 | { | |
d62a17ae | 5045 | int idx_peer = 1; |
5046 | int idx_acl = 3; | |
5047 | int direct, ret; | |
5048 | struct peer *peer; | |
a8206004 | 5049 | |
d62a17ae | 5050 | const char *pstr = argv[idx_peer]->arg; |
5051 | const char *acl = argv[idx_acl]->arg; | |
5052 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5053 | |
d62a17ae | 5054 | peer = peer_and_group_lookup_vty(vty, pstr); |
5055 | if (!peer) | |
5056 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5057 | |
d62a17ae | 5058 | /* Check filter direction. */ |
5059 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5060 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5061 | direct, acl); | |
a8206004 | 5062 | |
d62a17ae | 5063 | return bgp_vty_return(vty, ret); |
718e3744 | 5064 | } |
5065 | ||
d62a17ae | 5066 | ALIAS_HIDDEN( |
5067 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
5068 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5069 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5070 | "Filter updates to/from this neighbor\n" | |
5071 | "IP access-list number\n" | |
5072 | "IP access-list number (expanded range)\n" | |
5073 | "IP Access-list name\n" | |
5074 | "Filter incoming updates\n" | |
5075 | "Filter outgoing updates\n") | |
596c17ba | 5076 | |
718e3744 | 5077 | DEFUN (no_neighbor_distribute_list, |
5078 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5079 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5080 | NO_STR |
5081 | NEIGHBOR_STR | |
5082 | NEIGHBOR_ADDR_STR2 | |
5083 | "Filter updates to/from this neighbor\n" | |
5084 | "IP access-list number\n" | |
5085 | "IP access-list number (expanded range)\n" | |
5086 | "IP Access-list name\n" | |
5087 | "Filter incoming updates\n" | |
5088 | "Filter outgoing updates\n") | |
5089 | { | |
d62a17ae | 5090 | int idx_peer = 2; |
5091 | int direct, ret; | |
5092 | struct peer *peer; | |
a8206004 | 5093 | |
d62a17ae | 5094 | const char *pstr = argv[idx_peer]->arg; |
5095 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5096 | |
d62a17ae | 5097 | peer = peer_and_group_lookup_vty(vty, pstr); |
5098 | if (!peer) | |
5099 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5100 | |
d62a17ae | 5101 | /* Check filter direction. */ |
5102 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5103 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5104 | direct); | |
a8206004 | 5105 | |
d62a17ae | 5106 | return bgp_vty_return(vty, ret); |
718e3744 | 5107 | } |
6b0655a2 | 5108 | |
d62a17ae | 5109 | ALIAS_HIDDEN( |
5110 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
5111 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5112 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5113 | "Filter updates to/from this neighbor\n" | |
5114 | "IP access-list number\n" | |
5115 | "IP access-list number (expanded range)\n" | |
5116 | "IP Access-list name\n" | |
5117 | "Filter incoming updates\n" | |
5118 | "Filter outgoing updates\n") | |
596c17ba | 5119 | |
718e3744 | 5120 | /* Set prefix list to the peer. */ |
d62a17ae | 5121 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
5122 | afi_t afi, safi_t safi, | |
5123 | const char *name_str, | |
5124 | const char *direct_str) | |
718e3744 | 5125 | { |
d62a17ae | 5126 | int ret; |
5127 | struct peer *peer; | |
5128 | int direct = FILTER_IN; | |
718e3744 | 5129 | |
d62a17ae | 5130 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5131 | if (!peer) | |
5132 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5133 | |
d62a17ae | 5134 | /* Check filter direction. */ |
5135 | if (strncmp(direct_str, "i", 1) == 0) | |
5136 | direct = FILTER_IN; | |
5137 | else if (strncmp(direct_str, "o", 1) == 0) | |
5138 | direct = FILTER_OUT; | |
718e3744 | 5139 | |
d62a17ae | 5140 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 5141 | |
d62a17ae | 5142 | return bgp_vty_return(vty, ret); |
718e3744 | 5143 | } |
5144 | ||
d62a17ae | 5145 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
5146 | afi_t afi, safi_t safi, | |
5147 | const char *direct_str) | |
718e3744 | 5148 | { |
d62a17ae | 5149 | int ret; |
5150 | struct peer *peer; | |
5151 | int direct = FILTER_IN; | |
718e3744 | 5152 | |
d62a17ae | 5153 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5154 | if (!peer) | |
5155 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 5156 | |
d62a17ae | 5157 | /* Check filter direction. */ |
5158 | if (strncmp(direct_str, "i", 1) == 0) | |
5159 | direct = FILTER_IN; | |
5160 | else if (strncmp(direct_str, "o", 1) == 0) | |
5161 | direct = FILTER_OUT; | |
718e3744 | 5162 | |
d62a17ae | 5163 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 5164 | |
d62a17ae | 5165 | return bgp_vty_return(vty, ret); |
718e3744 | 5166 | } |
5167 | ||
5168 | DEFUN (neighbor_prefix_list, | |
5169 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5170 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5171 | NEIGHBOR_STR |
5172 | NEIGHBOR_ADDR_STR2 | |
5173 | "Filter updates to/from this neighbor\n" | |
5174 | "Name of a prefix list\n" | |
5175 | "Filter incoming updates\n" | |
5176 | "Filter outgoing updates\n") | |
5177 | { | |
d62a17ae | 5178 | int idx_peer = 1; |
5179 | int idx_word = 3; | |
5180 | int idx_in_out = 4; | |
5181 | return peer_prefix_list_set_vty( | |
5182 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5183 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5184 | } |
5185 | ||
d62a17ae | 5186 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
5187 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5188 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5189 | "Filter updates to/from this neighbor\n" | |
5190 | "Name of a prefix list\n" | |
5191 | "Filter incoming updates\n" | |
5192 | "Filter outgoing updates\n") | |
596c17ba | 5193 | |
718e3744 | 5194 | DEFUN (no_neighbor_prefix_list, |
5195 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5196 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5197 | NO_STR |
5198 | NEIGHBOR_STR | |
5199 | NEIGHBOR_ADDR_STR2 | |
5200 | "Filter updates to/from this neighbor\n" | |
5201 | "Name of a prefix list\n" | |
5202 | "Filter incoming updates\n" | |
5203 | "Filter outgoing updates\n") | |
5204 | { | |
d62a17ae | 5205 | int idx_peer = 2; |
5206 | int idx_in_out = 5; | |
5207 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
5208 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5209 | argv[idx_in_out]->arg); | |
718e3744 | 5210 | } |
6b0655a2 | 5211 | |
d62a17ae | 5212 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
5213 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5214 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5215 | "Filter updates to/from this neighbor\n" | |
5216 | "Name of a prefix list\n" | |
5217 | "Filter incoming updates\n" | |
5218 | "Filter outgoing updates\n") | |
596c17ba | 5219 | |
d62a17ae | 5220 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5221 | safi_t safi, const char *name_str, | |
5222 | const char *direct_str) | |
718e3744 | 5223 | { |
d62a17ae | 5224 | int ret; |
5225 | struct peer *peer; | |
5226 | int direct = FILTER_IN; | |
718e3744 | 5227 | |
d62a17ae | 5228 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5229 | if (!peer) | |
5230 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5231 | |
d62a17ae | 5232 | /* Check filter direction. */ |
5233 | if (strncmp(direct_str, "i", 1) == 0) | |
5234 | direct = FILTER_IN; | |
5235 | else if (strncmp(direct_str, "o", 1) == 0) | |
5236 | direct = FILTER_OUT; | |
718e3744 | 5237 | |
d62a17ae | 5238 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 5239 | |
d62a17ae | 5240 | return bgp_vty_return(vty, ret); |
718e3744 | 5241 | } |
5242 | ||
d62a17ae | 5243 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5244 | safi_t safi, const char *direct_str) | |
718e3744 | 5245 | { |
d62a17ae | 5246 | int ret; |
5247 | struct peer *peer; | |
5248 | int direct = FILTER_IN; | |
718e3744 | 5249 | |
d62a17ae | 5250 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5251 | if (!peer) | |
5252 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5253 | |
d62a17ae | 5254 | /* Check filter direction. */ |
5255 | if (strncmp(direct_str, "i", 1) == 0) | |
5256 | direct = FILTER_IN; | |
5257 | else if (strncmp(direct_str, "o", 1) == 0) | |
5258 | direct = FILTER_OUT; | |
718e3744 | 5259 | |
d62a17ae | 5260 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 5261 | |
d62a17ae | 5262 | return bgp_vty_return(vty, ret); |
718e3744 | 5263 | } |
5264 | ||
5265 | DEFUN (neighbor_filter_list, | |
5266 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5267 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5268 | NEIGHBOR_STR |
5269 | NEIGHBOR_ADDR_STR2 | |
5270 | "Establish BGP filters\n" | |
5271 | "AS path access-list name\n" | |
5272 | "Filter incoming routes\n" | |
5273 | "Filter outgoing routes\n") | |
5274 | { | |
d62a17ae | 5275 | int idx_peer = 1; |
5276 | int idx_word = 3; | |
5277 | int idx_in_out = 4; | |
5278 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5279 | bgp_node_safi(vty), argv[idx_word]->arg, | |
5280 | argv[idx_in_out]->arg); | |
718e3744 | 5281 | } |
5282 | ||
d62a17ae | 5283 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
5284 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5285 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5286 | "Establish BGP filters\n" | |
5287 | "AS path access-list name\n" | |
5288 | "Filter incoming routes\n" | |
5289 | "Filter outgoing routes\n") | |
596c17ba | 5290 | |
718e3744 | 5291 | DEFUN (no_neighbor_filter_list, |
5292 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5293 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5294 | NO_STR |
5295 | NEIGHBOR_STR | |
5296 | NEIGHBOR_ADDR_STR2 | |
5297 | "Establish BGP filters\n" | |
5298 | "AS path access-list name\n" | |
5299 | "Filter incoming routes\n" | |
5300 | "Filter outgoing routes\n") | |
5301 | { | |
d62a17ae | 5302 | int idx_peer = 2; |
5303 | int idx_in_out = 5; | |
5304 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
5305 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5306 | argv[idx_in_out]->arg); | |
718e3744 | 5307 | } |
6b0655a2 | 5308 | |
d62a17ae | 5309 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
5310 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5311 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5312 | "Establish BGP filters\n" | |
5313 | "AS path access-list name\n" | |
5314 | "Filter incoming routes\n" | |
5315 | "Filter outgoing routes\n") | |
596c17ba | 5316 | |
718e3744 | 5317 | /* Set route-map to the peer. */ |
d62a17ae | 5318 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
5319 | afi_t afi, safi_t safi, const char *name_str, | |
5320 | const char *direct_str) | |
718e3744 | 5321 | { |
d62a17ae | 5322 | int ret; |
5323 | struct peer *peer; | |
5324 | int direct = RMAP_IN; | |
718e3744 | 5325 | |
d62a17ae | 5326 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5327 | if (!peer) | |
5328 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5329 | |
d62a17ae | 5330 | /* Check filter direction. */ |
5331 | if (strncmp(direct_str, "in", 2) == 0) | |
5332 | direct = RMAP_IN; | |
5333 | else if (strncmp(direct_str, "o", 1) == 0) | |
5334 | direct = RMAP_OUT; | |
718e3744 | 5335 | |
d62a17ae | 5336 | ret = peer_route_map_set(peer, afi, safi, direct, name_str); |
718e3744 | 5337 | |
d62a17ae | 5338 | return bgp_vty_return(vty, ret); |
718e3744 | 5339 | } |
5340 | ||
d62a17ae | 5341 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
5342 | afi_t afi, safi_t safi, | |
5343 | const char *direct_str) | |
718e3744 | 5344 | { |
d62a17ae | 5345 | int ret; |
5346 | struct peer *peer; | |
5347 | int direct = RMAP_IN; | |
718e3744 | 5348 | |
d62a17ae | 5349 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5350 | if (!peer) | |
5351 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5352 | |
d62a17ae | 5353 | /* Check filter direction. */ |
5354 | if (strncmp(direct_str, "in", 2) == 0) | |
5355 | direct = RMAP_IN; | |
5356 | else if (strncmp(direct_str, "o", 1) == 0) | |
5357 | direct = RMAP_OUT; | |
718e3744 | 5358 | |
d62a17ae | 5359 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 5360 | |
d62a17ae | 5361 | return bgp_vty_return(vty, ret); |
718e3744 | 5362 | } |
5363 | ||
5364 | DEFUN (neighbor_route_map, | |
5365 | neighbor_route_map_cmd, | |
9ccf14f7 | 5366 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5367 | NEIGHBOR_STR |
5368 | NEIGHBOR_ADDR_STR2 | |
5369 | "Apply route map to neighbor\n" | |
5370 | "Name of route map\n" | |
5371 | "Apply map to incoming routes\n" | |
2a3d5731 | 5372 | "Apply map to outbound routes\n") |
718e3744 | 5373 | { |
d62a17ae | 5374 | int idx_peer = 1; |
5375 | int idx_word = 3; | |
5376 | int idx_in_out = 4; | |
5377 | return peer_route_map_set_vty( | |
5378 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5379 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5380 | } |
5381 | ||
d62a17ae | 5382 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
5383 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5384 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5385 | "Apply route map to neighbor\n" | |
5386 | "Name of route map\n" | |
5387 | "Apply map to incoming routes\n" | |
5388 | "Apply map to outbound routes\n") | |
596c17ba | 5389 | |
718e3744 | 5390 | DEFUN (no_neighbor_route_map, |
5391 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5392 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5393 | NO_STR |
5394 | NEIGHBOR_STR | |
5395 | NEIGHBOR_ADDR_STR2 | |
5396 | "Apply route map to neighbor\n" | |
5397 | "Name of route map\n" | |
5398 | "Apply map to incoming routes\n" | |
2a3d5731 | 5399 | "Apply map to outbound routes\n") |
718e3744 | 5400 | { |
d62a17ae | 5401 | int idx_peer = 2; |
5402 | int idx_in_out = 5; | |
5403 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
5404 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5405 | argv[idx_in_out]->arg); | |
718e3744 | 5406 | } |
6b0655a2 | 5407 | |
d62a17ae | 5408 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
5409 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5410 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5411 | "Apply route map to neighbor\n" | |
5412 | "Name of route map\n" | |
5413 | "Apply map to incoming routes\n" | |
5414 | "Apply map to outbound routes\n") | |
596c17ba | 5415 | |
718e3744 | 5416 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 5417 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
5418 | afi_t afi, safi_t safi, | |
5419 | const char *name_str) | |
718e3744 | 5420 | { |
d62a17ae | 5421 | int ret; |
5422 | struct peer *peer; | |
718e3744 | 5423 | |
d62a17ae | 5424 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5425 | if (!peer) | |
5426 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5427 | |
d62a17ae | 5428 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str); |
718e3744 | 5429 | |
d62a17ae | 5430 | return bgp_vty_return(vty, ret); |
718e3744 | 5431 | } |
5432 | ||
5433 | /* Unset route-map from the peer. */ | |
d62a17ae | 5434 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
5435 | afi_t afi, safi_t safi) | |
718e3744 | 5436 | { |
d62a17ae | 5437 | int ret; |
5438 | struct peer *peer; | |
718e3744 | 5439 | |
d62a17ae | 5440 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5441 | if (!peer) | |
5442 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5443 | |
d62a17ae | 5444 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 5445 | |
d62a17ae | 5446 | return bgp_vty_return(vty, ret); |
718e3744 | 5447 | } |
5448 | ||
5449 | DEFUN (neighbor_unsuppress_map, | |
5450 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5451 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5452 | NEIGHBOR_STR |
5453 | NEIGHBOR_ADDR_STR2 | |
5454 | "Route-map to selectively unsuppress suppressed routes\n" | |
5455 | "Name of route map\n") | |
5456 | { | |
d62a17ae | 5457 | int idx_peer = 1; |
5458 | int idx_word = 3; | |
5459 | return peer_unsuppress_map_set_vty( | |
5460 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5461 | argv[idx_word]->arg); | |
718e3744 | 5462 | } |
5463 | ||
d62a17ae | 5464 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
5465 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5466 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5467 | "Route-map to selectively unsuppress suppressed routes\n" | |
5468 | "Name of route map\n") | |
596c17ba | 5469 | |
718e3744 | 5470 | DEFUN (no_neighbor_unsuppress_map, |
5471 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5472 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5473 | NO_STR |
5474 | NEIGHBOR_STR | |
5475 | NEIGHBOR_ADDR_STR2 | |
5476 | "Route-map to selectively unsuppress suppressed routes\n" | |
5477 | "Name of route map\n") | |
5478 | { | |
d62a17ae | 5479 | int idx_peer = 2; |
5480 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
5481 | bgp_node_afi(vty), | |
5482 | bgp_node_safi(vty)); | |
718e3744 | 5483 | } |
6b0655a2 | 5484 | |
d62a17ae | 5485 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
5486 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5487 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5488 | "Route-map to selectively unsuppress suppressed routes\n" | |
5489 | "Name of route map\n") | |
596c17ba | 5490 | |
d62a17ae | 5491 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
5492 | afi_t afi, safi_t safi, | |
5493 | const char *num_str, | |
5494 | const char *threshold_str, int warning, | |
5495 | const char *restart_str) | |
718e3744 | 5496 | { |
d62a17ae | 5497 | int ret; |
5498 | struct peer *peer; | |
5499 | u_int32_t max; | |
5500 | u_char threshold; | |
5501 | u_int16_t restart; | |
718e3744 | 5502 | |
d62a17ae | 5503 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5504 | if (!peer) | |
5505 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5506 | |
d62a17ae | 5507 | max = strtoul(num_str, NULL, 10); |
5508 | if (threshold_str) | |
5509 | threshold = atoi(threshold_str); | |
5510 | else | |
5511 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5512 | |
d62a17ae | 5513 | if (restart_str) |
5514 | restart = atoi(restart_str); | |
5515 | else | |
5516 | restart = 0; | |
0a486e5f | 5517 | |
d62a17ae | 5518 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
5519 | restart); | |
718e3744 | 5520 | |
d62a17ae | 5521 | return bgp_vty_return(vty, ret); |
718e3744 | 5522 | } |
5523 | ||
d62a17ae | 5524 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
5525 | afi_t afi, safi_t safi) | |
718e3744 | 5526 | { |
d62a17ae | 5527 | int ret; |
5528 | struct peer *peer; | |
718e3744 | 5529 | |
d62a17ae | 5530 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5531 | if (!peer) | |
5532 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5533 | |
d62a17ae | 5534 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 5535 | |
d62a17ae | 5536 | return bgp_vty_return(vty, ret); |
718e3744 | 5537 | } |
5538 | ||
5539 | /* Maximum number of prefix configuration. prefix count is different | |
5540 | for each peer configuration. So this configuration can be set for | |
5541 | each peer configuration. */ | |
5542 | DEFUN (neighbor_maximum_prefix, | |
5543 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5544 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5545 | NEIGHBOR_STR |
5546 | NEIGHBOR_ADDR_STR2 | |
5547 | "Maximum number of prefix accept from this peer\n" | |
5548 | "maximum no. of prefix limit\n") | |
5549 | { | |
d62a17ae | 5550 | int idx_peer = 1; |
5551 | int idx_number = 3; | |
5552 | return peer_maximum_prefix_set_vty( | |
5553 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5554 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 5555 | } |
5556 | ||
d62a17ae | 5557 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
5558 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
5559 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5560 | "Maximum number of prefix accept from this peer\n" | |
5561 | "maximum no. of prefix limit\n") | |
596c17ba | 5562 | |
e0701b79 | 5563 | DEFUN (neighbor_maximum_prefix_threshold, |
5564 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5565 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5566 | NEIGHBOR_STR |
5567 | NEIGHBOR_ADDR_STR2 | |
5568 | "Maximum number of prefix accept from this peer\n" | |
5569 | "maximum no. of prefix limit\n" | |
5570 | "Threshold value (%) at which to generate a warning msg\n") | |
5571 | { | |
d62a17ae | 5572 | int idx_peer = 1; |
5573 | int idx_number = 3; | |
5574 | int idx_number_2 = 4; | |
5575 | return peer_maximum_prefix_set_vty( | |
5576 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5577 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 5578 | } |
e0701b79 | 5579 | |
d62a17ae | 5580 | ALIAS_HIDDEN( |
5581 | neighbor_maximum_prefix_threshold, | |
5582 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
5583 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
5584 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5585 | "Maximum number of prefix accept from this peer\n" | |
5586 | "maximum no. of prefix limit\n" | |
5587 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 5588 | |
718e3744 | 5589 | DEFUN (neighbor_maximum_prefix_warning, |
5590 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5591 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5592 | NEIGHBOR_STR |
5593 | NEIGHBOR_ADDR_STR2 | |
5594 | "Maximum number of prefix accept from this peer\n" | |
5595 | "maximum no. of prefix limit\n" | |
5596 | "Only give warning message when limit is exceeded\n") | |
5597 | { | |
d62a17ae | 5598 | int idx_peer = 1; |
5599 | int idx_number = 3; | |
5600 | return peer_maximum_prefix_set_vty( | |
5601 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5602 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 5603 | } |
5604 | ||
d62a17ae | 5605 | ALIAS_HIDDEN( |
5606 | neighbor_maximum_prefix_warning, | |
5607 | neighbor_maximum_prefix_warning_hidden_cmd, | |
5608 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
5609 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5610 | "Maximum number of prefix accept from this peer\n" | |
5611 | "maximum no. of prefix limit\n" | |
5612 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5613 | |
e0701b79 | 5614 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5615 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5616 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5617 | NEIGHBOR_STR |
5618 | NEIGHBOR_ADDR_STR2 | |
5619 | "Maximum number of prefix accept from this peer\n" | |
5620 | "maximum no. of prefix limit\n" | |
5621 | "Threshold value (%) at which to generate a warning msg\n" | |
5622 | "Only give warning message when limit is exceeded\n") | |
5623 | { | |
d62a17ae | 5624 | int idx_peer = 1; |
5625 | int idx_number = 3; | |
5626 | int idx_number_2 = 4; | |
5627 | return peer_maximum_prefix_set_vty( | |
5628 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5629 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5630 | } |
5631 | ||
d62a17ae | 5632 | ALIAS_HIDDEN( |
5633 | neighbor_maximum_prefix_threshold_warning, | |
5634 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
5635 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
5636 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5637 | "Maximum number of prefix accept from this peer\n" | |
5638 | "maximum no. of prefix limit\n" | |
5639 | "Threshold value (%) at which to generate a warning msg\n" | |
5640 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5641 | |
0a486e5f | 5642 | DEFUN (neighbor_maximum_prefix_restart, |
5643 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5644 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 5645 | NEIGHBOR_STR |
5646 | NEIGHBOR_ADDR_STR2 | |
5647 | "Maximum number of prefix accept from this peer\n" | |
5648 | "maximum no. of prefix limit\n" | |
5649 | "Restart bgp connection after limit is exceeded\n" | |
5650 | "Restart interval in minutes") | |
5651 | { | |
d62a17ae | 5652 | int idx_peer = 1; |
5653 | int idx_number = 3; | |
5654 | int idx_number_2 = 5; | |
5655 | return peer_maximum_prefix_set_vty( | |
5656 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5657 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 5658 | } |
5659 | ||
d62a17ae | 5660 | ALIAS_HIDDEN( |
5661 | neighbor_maximum_prefix_restart, | |
5662 | neighbor_maximum_prefix_restart_hidden_cmd, | |
5663 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
5664 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5665 | "Maximum number of prefix accept from this peer\n" | |
5666 | "maximum no. of prefix limit\n" | |
5667 | "Restart bgp connection after limit is exceeded\n" | |
5668 | "Restart interval in minutes") | |
596c17ba | 5669 | |
0a486e5f | 5670 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
5671 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 5672 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 5673 | NEIGHBOR_STR |
5674 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5675 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 5676 | "maximum no. of prefix limit\n" |
5677 | "Threshold value (%) at which to generate a warning msg\n" | |
5678 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5679 | "Restart interval in minutes\n") |
0a486e5f | 5680 | { |
d62a17ae | 5681 | int idx_peer = 1; |
5682 | int idx_number = 3; | |
5683 | int idx_number_2 = 4; | |
5684 | int idx_number_3 = 6; | |
5685 | return peer_maximum_prefix_set_vty( | |
5686 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5687 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
5688 | argv[idx_number_3]->arg); | |
5689 | } | |
5690 | ||
5691 | ALIAS_HIDDEN( | |
5692 | neighbor_maximum_prefix_threshold_restart, | |
5693 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
5694 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
5695 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5696 | "Maximum number of prefixes to accept from this peer\n" | |
5697 | "maximum no. of prefix limit\n" | |
5698 | "Threshold value (%) at which to generate a warning msg\n" | |
5699 | "Restart bgp connection after limit is exceeded\n" | |
5700 | "Restart interval in minutes\n") | |
596c17ba | 5701 | |
718e3744 | 5702 | DEFUN (no_neighbor_maximum_prefix, |
5703 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 5704 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 5705 | NO_STR |
5706 | NEIGHBOR_STR | |
5707 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5708 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
5709 | "maximum no. of prefix limit\n" |
5710 | "Threshold value (%) at which to generate a warning msg\n" | |
5711 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5712 | "Restart interval in minutes\n" |
31500417 | 5713 | "Only give warning message when limit is exceeded\n") |
718e3744 | 5714 | { |
d62a17ae | 5715 | int idx_peer = 2; |
5716 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
5717 | bgp_node_afi(vty), | |
5718 | bgp_node_safi(vty)); | |
718e3744 | 5719 | } |
e52702f2 | 5720 | |
d62a17ae | 5721 | ALIAS_HIDDEN( |
5722 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
5723 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
5724 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5725 | "Maximum number of prefixes to accept from this peer\n" | |
5726 | "maximum no. of prefix limit\n" | |
5727 | "Threshold value (%) at which to generate a warning msg\n" | |
5728 | "Restart bgp connection after limit is exceeded\n" | |
5729 | "Restart interval in minutes\n" | |
5730 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5731 | |
718e3744 | 5732 | |
718e3744 | 5733 | /* "neighbor allowas-in" */ |
5734 | DEFUN (neighbor_allowas_in, | |
5735 | neighbor_allowas_in_cmd, | |
fd8503f5 | 5736 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5737 | NEIGHBOR_STR |
5738 | NEIGHBOR_ADDR_STR2 | |
31500417 | 5739 | "Accept as-path with my AS present in it\n" |
fd8503f5 QY |
5740 | "Number of occurances of AS number\n" |
5741 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5742 | { |
d62a17ae | 5743 | int idx_peer = 1; |
5744 | int idx_number_origin = 3; | |
5745 | int ret; | |
5746 | int origin = 0; | |
5747 | struct peer *peer; | |
5748 | int allow_num = 0; | |
5749 | ||
5750 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5751 | if (!peer) | |
5752 | return CMD_WARNING_CONFIG_FAILED; | |
5753 | ||
5754 | if (argc <= idx_number_origin) | |
5755 | allow_num = 3; | |
5756 | else { | |
5757 | if (argv[idx_number_origin]->type == WORD_TKN) | |
5758 | origin = 1; | |
5759 | else | |
5760 | allow_num = atoi(argv[idx_number_origin]->arg); | |
5761 | } | |
5762 | ||
5763 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5764 | allow_num, origin); | |
5765 | ||
5766 | return bgp_vty_return(vty, ret); | |
5767 | } | |
5768 | ||
5769 | ALIAS_HIDDEN( | |
5770 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
5771 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
5772 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5773 | "Accept as-path with my AS present in it\n" | |
5774 | "Number of occurances of AS number\n" | |
5775 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
596c17ba | 5776 | |
718e3744 | 5777 | DEFUN (no_neighbor_allowas_in, |
5778 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 5779 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5780 | NO_STR |
5781 | NEIGHBOR_STR | |
5782 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 5783 | "allow local ASN appears in aspath attribute\n" |
fd8503f5 QY |
5784 | "Number of occurances of AS number\n" |
5785 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5786 | { |
d62a17ae | 5787 | int idx_peer = 2; |
5788 | int ret; | |
5789 | struct peer *peer; | |
718e3744 | 5790 | |
d62a17ae | 5791 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5792 | if (!peer) | |
5793 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5794 | |
d62a17ae | 5795 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
5796 | bgp_node_safi(vty)); | |
718e3744 | 5797 | |
d62a17ae | 5798 | return bgp_vty_return(vty, ret); |
718e3744 | 5799 | } |
6b0655a2 | 5800 | |
d62a17ae | 5801 | ALIAS_HIDDEN( |
5802 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
5803 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
5804 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5805 | "allow local ASN appears in aspath attribute\n" | |
5806 | "Number of occurances of AS number\n" | |
5807 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
596c17ba | 5808 | |
fa411a21 NH |
5809 | DEFUN (neighbor_ttl_security, |
5810 | neighbor_ttl_security_cmd, | |
9ccf14f7 | 5811 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5812 | NEIGHBOR_STR |
5813 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5814 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
5815 | "Specify the maximum number of hops to the BGP peer\n" |
5816 | "Number of hops to BGP peer\n") | |
fa411a21 | 5817 | { |
d62a17ae | 5818 | int idx_peer = 1; |
5819 | int idx_number = 4; | |
5820 | struct peer *peer; | |
5821 | int gtsm_hops; | |
5822 | ||
5823 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5824 | if (!peer) | |
5825 | return CMD_WARNING_CONFIG_FAILED; | |
5826 | ||
5827 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
5828 | ||
5829 | /* | |
5830 | * If 'neighbor swpX', then this is for directly connected peers, | |
5831 | * we should not accept a ttl-security hops value greater than 1. | |
5832 | */ | |
5833 | if (peer->conf_if && (gtsm_hops > 1)) { | |
5834 | vty_out(vty, | |
5835 | "%s is directly connected peer, hops cannot exceed 1\n", | |
5836 | argv[idx_peer]->arg); | |
5837 | return CMD_WARNING_CONFIG_FAILED; | |
5838 | } | |
8cdabf90 | 5839 | |
d62a17ae | 5840 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
5841 | } |
5842 | ||
5843 | DEFUN (no_neighbor_ttl_security, | |
5844 | no_neighbor_ttl_security_cmd, | |
9ccf14f7 | 5845 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5846 | NO_STR |
5847 | NEIGHBOR_STR | |
5848 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5849 | "BGP ttl-security parameters\n" |
3a2d747c QY |
5850 | "Specify the maximum number of hops to the BGP peer\n" |
5851 | "Number of hops to BGP peer\n") | |
fa411a21 | 5852 | { |
d62a17ae | 5853 | int idx_peer = 2; |
5854 | struct peer *peer; | |
fa411a21 | 5855 | |
d62a17ae | 5856 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5857 | if (!peer) | |
5858 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 5859 | |
d62a17ae | 5860 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 5861 | } |
6b0655a2 | 5862 | |
adbac85e DW |
5863 | DEFUN (neighbor_addpath_tx_all_paths, |
5864 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5865 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5866 | NEIGHBOR_STR |
5867 | NEIGHBOR_ADDR_STR2 | |
5868 | "Use addpath to advertise all paths to a neighbor\n") | |
5869 | { | |
d62a17ae | 5870 | int idx_peer = 1; |
5871 | struct peer *peer; | |
adbac85e | 5872 | |
d62a17ae | 5873 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5874 | if (!peer) | |
5875 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 5876 | |
d62a17ae | 5877 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5878 | bgp_node_safi(vty), | |
5879 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
adbac85e DW |
5880 | } |
5881 | ||
d62a17ae | 5882 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
5883 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
5884 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
5885 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5886 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 5887 | |
adbac85e DW |
5888 | DEFUN (no_neighbor_addpath_tx_all_paths, |
5889 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5890 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5891 | NO_STR |
5892 | NEIGHBOR_STR | |
5893 | NEIGHBOR_ADDR_STR2 | |
5894 | "Use addpath to advertise all paths to a neighbor\n") | |
5895 | { | |
d62a17ae | 5896 | int idx_peer = 2; |
5897 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5898 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5899 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
adbac85e DW |
5900 | } |
5901 | ||
d62a17ae | 5902 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
5903 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
5904 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
5905 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5906 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 5907 | |
06370dac DW |
5908 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
5909 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5910 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5911 | NEIGHBOR_STR |
5912 | NEIGHBOR_ADDR_STR2 | |
5913 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5914 | { | |
d62a17ae | 5915 | int idx_peer = 1; |
5916 | struct peer *peer; | |
06370dac | 5917 | |
d62a17ae | 5918 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5919 | if (!peer) | |
5920 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 5921 | |
d62a17ae | 5922 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5923 | bgp_node_safi(vty), | |
5924 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
06370dac DW |
5925 | } |
5926 | ||
d62a17ae | 5927 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
5928 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
5929 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
5930 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5931 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 5932 | |
06370dac DW |
5933 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
5934 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5935 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5936 | NO_STR |
5937 | NEIGHBOR_STR | |
5938 | NEIGHBOR_ADDR_STR2 | |
5939 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5940 | { | |
d62a17ae | 5941 | int idx_peer = 2; |
5942 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5943 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5944 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
06370dac DW |
5945 | } |
5946 | ||
d62a17ae | 5947 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
5948 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
5949 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
5950 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5951 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 5952 | |
505e5056 | 5953 | DEFUN_NOSH (address_family_ipv4_safi, |
718e3744 | 5954 | address_family_ipv4_safi_cmd, |
5b1f0f29 | 5955 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast>]", |
718e3744 | 5956 | "Enter Address Family command mode\n" |
8c3deaae | 5957 | "Address Family\n" |
b6ab5a3a | 5958 | BGP_SAFI_WITH_LABEL_HELP_STR) |
718e3744 | 5959 | { |
f51bae9c | 5960 | |
d62a17ae | 5961 | if (argc == 3) { |
5962 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
5963 | vty->node = bgp_node_type(AFI_IP, safi); | |
5964 | } else | |
5965 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 5966 | |
d62a17ae | 5967 | return CMD_SUCCESS; |
718e3744 | 5968 | } |
5969 | ||
505e5056 | 5970 | DEFUN_NOSH (address_family_ipv6_safi, |
25ffbdc1 | 5971 | address_family_ipv6_safi_cmd, |
5b1f0f29 | 5972 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast>]", |
718e3744 | 5973 | "Enter Address Family command mode\n" |
8c3deaae | 5974 | "Address Family\n" |
b6ab5a3a | 5975 | BGP_SAFI_WITH_LABEL_HELP_STR) |
25ffbdc1 | 5976 | { |
d62a17ae | 5977 | if (argc == 3) { |
5978 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
5979 | vty->node = bgp_node_type(AFI_IP6, safi); | |
5980 | } else | |
5981 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 5982 | |
d62a17ae | 5983 | return CMD_SUCCESS; |
25ffbdc1 | 5984 | } |
718e3744 | 5985 | |
d6902373 | 5986 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 5987 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 5988 | address_family_vpnv4_cmd, |
8334fd5a | 5989 | "address-family vpnv4 [unicast]", |
718e3744 | 5990 | "Enter Address Family command mode\n" |
8c3deaae | 5991 | "Address Family\n" |
3a2d747c | 5992 | "Address Family modifier\n") |
718e3744 | 5993 | { |
d62a17ae | 5994 | vty->node = BGP_VPNV4_NODE; |
5995 | return CMD_SUCCESS; | |
718e3744 | 5996 | } |
5997 | ||
505e5056 | 5998 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 5999 | address_family_vpnv6_cmd, |
8334fd5a | 6000 | "address-family vpnv6 [unicast]", |
8ecd3266 | 6001 | "Enter Address Family command mode\n" |
8c3deaae | 6002 | "Address Family\n" |
3a2d747c | 6003 | "Address Family modifier\n") |
8ecd3266 | 6004 | { |
d62a17ae | 6005 | vty->node = BGP_VPNV6_NODE; |
6006 | return CMD_SUCCESS; | |
8ecd3266 | 6007 | } |
c016b6c7 | 6008 | #endif |
d6902373 | 6009 | |
505e5056 | 6010 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 6011 | address_family_evpn_cmd, |
7111c1a0 | 6012 | "address-family l2vpn evpn", |
4e0b7b6d | 6013 | "Enter Address Family command mode\n" |
7111c1a0 QY |
6014 | "Address Family\n" |
6015 | "Address Family modifier\n") | |
4e0b7b6d | 6016 | { |
d62a17ae | 6017 | vty->node = BGP_EVPN_NODE; |
6018 | return CMD_SUCCESS; | |
4e0b7b6d PG |
6019 | } |
6020 | ||
505e5056 | 6021 | DEFUN_NOSH (exit_address_family, |
718e3744 | 6022 | exit_address_family_cmd, |
6023 | "exit-address-family", | |
6024 | "Exit from Address Family configuration mode\n") | |
6025 | { | |
d62a17ae | 6026 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
6027 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
6028 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
6029 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
6030 | || vty->node == BGP_EVPN_NODE) | |
6031 | vty->node = BGP_NODE; | |
6032 | return CMD_SUCCESS; | |
718e3744 | 6033 | } |
6b0655a2 | 6034 | |
8ad7271d | 6035 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 6036 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
6037 | const char *ip_str, afi_t afi, safi_t safi, | |
6038 | struct prefix_rd *prd) | |
6039 | { | |
6040 | int ret; | |
6041 | struct prefix match; | |
6042 | struct bgp_node *rn; | |
6043 | struct bgp_node *rm; | |
6044 | struct bgp *bgp; | |
6045 | struct bgp_table *table; | |
6046 | struct bgp_table *rib; | |
6047 | ||
6048 | /* BGP structure lookup. */ | |
6049 | if (view_name) { | |
6050 | bgp = bgp_lookup_by_name(view_name); | |
6051 | if (bgp == NULL) { | |
6052 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
6053 | view_name); | |
6054 | return CMD_WARNING; | |
6055 | } | |
6056 | } else { | |
6057 | bgp = bgp_get_default(); | |
6058 | if (bgp == NULL) { | |
6059 | vty_out(vty, "%% No BGP process is configured\n"); | |
6060 | return CMD_WARNING; | |
6061 | } | |
6062 | } | |
6063 | ||
6064 | /* Check IP address argument. */ | |
6065 | ret = str2prefix(ip_str, &match); | |
6066 | if (!ret) { | |
6067 | vty_out(vty, "%% address is malformed\n"); | |
6068 | return CMD_WARNING; | |
6069 | } | |
6070 | ||
6071 | match.family = afi2family(afi); | |
6072 | rib = bgp->rib[afi][safi]; | |
6073 | ||
6074 | if (safi == SAFI_MPLS_VPN) { | |
6075 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
6076 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
6077 | continue; | |
6078 | ||
6079 | if ((table = rn->info) != NULL) { | |
6080 | if ((rm = bgp_node_match(table, &match)) | |
6081 | != NULL) { | |
6082 | if (rm->p.prefixlen | |
6083 | == match.prefixlen) { | |
6084 | SET_FLAG(rn->flags, | |
6085 | BGP_NODE_USER_CLEAR); | |
6086 | bgp_process(bgp, rm, afi, safi); | |
6087 | } | |
6088 | bgp_unlock_node(rm); | |
6089 | } | |
6090 | } | |
6091 | } | |
6092 | } else { | |
6093 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
6094 | if (rn->p.prefixlen == match.prefixlen) { | |
6095 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
6096 | bgp_process(bgp, rn, afi, safi); | |
6097 | } | |
6098 | bgp_unlock_node(rn); | |
6099 | } | |
6100 | } | |
6101 | ||
6102 | return CMD_SUCCESS; | |
8ad7271d DS |
6103 | } |
6104 | ||
b09b5ae0 | 6105 | /* one clear bgp command to rule them all */ |
718e3744 | 6106 | DEFUN (clear_ip_bgp_all, |
6107 | clear_ip_bgp_all_cmd, | |
c1a44e43 | 6108 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_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 | 6109 | CLEAR_STR |
6110 | IP_STR | |
6111 | BGP_STR | |
838758ac | 6112 | BGP_INSTANCE_HELP_STR |
b09b5ae0 DW |
6113 | "Clear all peers\n" |
6114 | "BGP neighbor address to clear\n" | |
a80beece | 6115 | "BGP IPv6 neighbor to clear\n" |
838758ac | 6116 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
6117 | "Clear peers with the AS number\n" |
6118 | "Clear all external peers\n" | |
718e3744 | 6119 | "Clear all members of peer-group\n" |
b09b5ae0 | 6120 | "BGP peer-group name\n" |
46f296b4 | 6121 | BGP_AFI_HELP_STR |
9bedbb1e | 6122 | BGP_SAFI_WITH_LABEL_HELP_STR |
b09b5ae0 DW |
6123 | BGP_SOFT_STR |
6124 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
6125 | BGP_SOFT_OUT_STR |
6126 | BGP_SOFT_IN_STR | |
6127 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 6128 | BGP_SOFT_OUT_STR) |
718e3744 | 6129 | { |
d62a17ae | 6130 | char *vrf = NULL; |
6131 | ||
6132 | afi_t afi = AFI_IP6; | |
6133 | safi_t safi = SAFI_UNICAST; | |
6134 | enum clear_sort clr_sort = clear_peer; | |
6135 | enum bgp_clear_type clr_type; | |
6136 | char *clr_arg = NULL; | |
6137 | ||
6138 | int idx = 0; | |
6139 | ||
6140 | /* clear [ip] bgp */ | |
6141 | if (argv_find(argv, argc, "ip", &idx)) | |
6142 | afi = AFI_IP; | |
6143 | ||
6144 | /* [<view|vrf> VIEWVRFNAME] */ | |
6145 | if (argv_find(argv, argc, "view", &idx) | |
6146 | || argv_find(argv, argc, "vrf", &idx)) { | |
6147 | vrf = argv[idx + 1]->arg; | |
6148 | idx += 2; | |
6149 | } | |
6150 | ||
6151 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
6152 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
6153 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
6154 | ||
6155 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ | |
6156 | if (argv_find(argv, argc, "*", &idx)) { | |
6157 | clr_sort = clear_all; | |
6158 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
6159 | clr_sort = clear_peer; | |
6160 | clr_arg = argv[idx]->arg; | |
6161 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
6162 | clr_sort = clear_peer; | |
6163 | clr_arg = argv[idx]->arg; | |
6164 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
6165 | clr_sort = clear_group; | |
6166 | idx++; | |
6167 | clr_arg = argv[idx]->arg; | |
6168 | } else if (argv_find(argv, argc, "WORD", &idx)) { | |
6169 | clr_sort = clear_peer; | |
6170 | clr_arg = argv[idx]->arg; | |
6171 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { | |
6172 | clr_sort = clear_as; | |
6173 | clr_arg = argv[idx]->arg; | |
6174 | } else if (argv_find(argv, argc, "external", &idx)) { | |
6175 | clr_sort = clear_external; | |
6176 | } | |
6177 | ||
6178 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
6179 | if (argv_find(argv, argc, "soft", &idx)) { | |
6180 | if (argv_find(argv, argc, "in", &idx) | |
6181 | || argv_find(argv, argc, "out", &idx)) | |
6182 | clr_type = strmatch(argv[idx]->text, "in") | |
6183 | ? BGP_CLEAR_SOFT_IN | |
6184 | : BGP_CLEAR_SOFT_OUT; | |
6185 | else | |
6186 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
6187 | } else if (argv_find(argv, argc, "in", &idx)) { | |
6188 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
6189 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
6190 | : BGP_CLEAR_SOFT_IN; | |
6191 | } else if (argv_find(argv, argc, "out", &idx)) { | |
6192 | clr_type = BGP_CLEAR_SOFT_OUT; | |
6193 | } else | |
6194 | clr_type = BGP_CLEAR_SOFT_NONE; | |
6195 | ||
6196 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 6197 | } |
01080f7c | 6198 | |
8ad7271d DS |
6199 | DEFUN (clear_ip_bgp_prefix, |
6200 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 6201 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
6202 | CLEAR_STR |
6203 | IP_STR | |
6204 | BGP_STR | |
838758ac | 6205 | BGP_INSTANCE_HELP_STR |
8ad7271d | 6206 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6207 | "IPv4 prefix\n") |
8ad7271d | 6208 | { |
d62a17ae | 6209 | char *vrf = NULL; |
6210 | char *prefix = NULL; | |
8ad7271d | 6211 | |
d62a17ae | 6212 | int idx = 0; |
01080f7c | 6213 | |
d62a17ae | 6214 | /* [<view|vrf> VIEWVRFNAME] */ |
6215 | if (argv_find(argv, argc, "WORD", &idx)) | |
6216 | vrf = argv[idx]->arg; | |
0c7b1b01 | 6217 | |
d62a17ae | 6218 | prefix = argv[argc - 1]->arg; |
8ad7271d | 6219 | |
d62a17ae | 6220 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 6221 | } |
8ad7271d | 6222 | |
b09b5ae0 DW |
6223 | DEFUN (clear_bgp_ipv6_safi_prefix, |
6224 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 6225 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6226 | CLEAR_STR |
3a2d747c | 6227 | IP_STR |
718e3744 | 6228 | BGP_STR |
8c3deaae | 6229 | "Address Family\n" |
46f296b4 | 6230 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6231 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6232 | "IPv6 prefix\n") |
718e3744 | 6233 | { |
d62a17ae | 6234 | int idx_safi = 3; |
6235 | int idx_ipv6_prefixlen = 5; | |
6236 | return bgp_clear_prefix( | |
6237 | vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, | |
6238 | bgp_vty_safi_from_str(argv[idx_safi]->text), NULL); | |
838758ac | 6239 | } |
01080f7c | 6240 | |
b09b5ae0 DW |
6241 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
6242 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 6243 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6244 | CLEAR_STR |
3a2d747c | 6245 | IP_STR |
718e3744 | 6246 | BGP_STR |
838758ac | 6247 | BGP_INSTANCE_HELP_STR |
8c3deaae | 6248 | "Address Family\n" |
46f296b4 | 6249 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6250 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6251 | "IPv6 prefix\n") |
718e3744 | 6252 | { |
d62a17ae | 6253 | int idx_word = 3; |
6254 | int idx_safi = 5; | |
6255 | int idx_ipv6_prefixlen = 7; | |
6256 | return bgp_clear_prefix( | |
6257 | vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, | |
6258 | AFI_IP6, bgp_vty_safi_from_str(argv[idx_safi]->text), NULL); | |
718e3744 | 6259 | } |
6260 | ||
b09b5ae0 DW |
6261 | DEFUN (show_bgp_views, |
6262 | show_bgp_views_cmd, | |
d6e3c605 | 6263 | "show [ip] bgp views", |
b09b5ae0 | 6264 | SHOW_STR |
d6e3c605 | 6265 | IP_STR |
01080f7c | 6266 | BGP_STR |
b09b5ae0 | 6267 | "Show the defined BGP views\n") |
01080f7c | 6268 | { |
d62a17ae | 6269 | struct list *inst = bm->bgp; |
6270 | struct listnode *node; | |
6271 | struct bgp *bgp; | |
01080f7c | 6272 | |
d62a17ae | 6273 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { |
6274 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
6275 | return CMD_WARNING; | |
6276 | } | |
e52702f2 | 6277 | |
d62a17ae | 6278 | vty_out(vty, "Defined BGP views:\n"); |
6279 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
6280 | /* Skip VRFs. */ | |
6281 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
6282 | continue; | |
6283 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
6284 | bgp->as); | |
6285 | } | |
e52702f2 | 6286 | |
d62a17ae | 6287 | return CMD_SUCCESS; |
e0081f70 ML |
6288 | } |
6289 | ||
8386ac43 | 6290 | DEFUN (show_bgp_vrfs, |
6291 | show_bgp_vrfs_cmd, | |
d6e3c605 | 6292 | "show [ip] bgp vrfs [json]", |
8386ac43 | 6293 | SHOW_STR |
d6e3c605 | 6294 | IP_STR |
8386ac43 | 6295 | BGP_STR |
6296 | "Show BGP VRFs\n" | |
9973d184 | 6297 | JSON_STR) |
8386ac43 | 6298 | { |
d62a17ae | 6299 | struct list *inst = bm->bgp; |
6300 | struct listnode *node; | |
6301 | struct bgp *bgp; | |
6302 | u_char uj = use_json(argc, argv); | |
6303 | json_object *json = NULL; | |
6304 | json_object *json_vrfs = NULL; | |
6305 | int count = 0; | |
6306 | static char header[] = | |
6307 | "Type Id RouterId #PeersCfg #PeersEstb Name"; | |
6308 | ||
6309 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { | |
6310 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
6311 | return CMD_WARNING; | |
6312 | } | |
6313 | ||
6314 | if (uj) { | |
6315 | json = json_object_new_object(); | |
6316 | json_vrfs = json_object_new_object(); | |
6317 | } | |
6318 | ||
6319 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
6320 | const char *name, *type; | |
6321 | struct peer *peer; | |
6322 | struct listnode *node, *nnode; | |
6323 | int peers_cfg, peers_estb; | |
6324 | json_object *json_vrf = NULL; | |
6325 | int vrf_id_ui; | |
6326 | ||
6327 | /* Skip Views. */ | |
6328 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
6329 | continue; | |
6330 | ||
6331 | count++; | |
6332 | if (!uj && count == 1) | |
6333 | vty_out(vty, "%s\n", header); | |
6334 | ||
6335 | peers_cfg = peers_estb = 0; | |
6336 | if (uj) | |
6337 | json_vrf = json_object_new_object(); | |
6338 | ||
6339 | ||
6340 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
6341 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6342 | continue; | |
6343 | peers_cfg++; | |
6344 | if (peer->status == Established) | |
6345 | peers_estb++; | |
6346 | } | |
6347 | ||
6348 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
6349 | name = "Default"; | |
6350 | type = "DFLT"; | |
6351 | } else { | |
6352 | name = bgp->name; | |
6353 | type = "VRF"; | |
6354 | } | |
6355 | ||
6356 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; | |
6357 | if (uj) { | |
6358 | json_object_string_add(json_vrf, "type", type); | |
6359 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
6360 | json_object_string_add(json_vrf, "routerId", | |
6361 | inet_ntoa(bgp->router_id)); | |
6362 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
6363 | peers_cfg); | |
6364 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
6365 | peers_estb); | |
6366 | ||
6367 | json_object_object_add(json_vrfs, name, json_vrf); | |
6368 | } else | |
6369 | vty_out(vty, "%4s %-5d %-16s %9u %10u %s\n", type, | |
6370 | vrf_id_ui, inet_ntoa(bgp->router_id), peers_cfg, | |
6371 | peers_estb, name); | |
6372 | } | |
6373 | ||
6374 | if (uj) { | |
6375 | json_object_object_add(json, "vrfs", json_vrfs); | |
6376 | ||
6377 | json_object_int_add(json, "totalVrfs", count); | |
6378 | ||
9d303b37 DL |
6379 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
6380 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 6381 | json_object_free(json); |
6382 | } else { | |
6383 | if (count) | |
6384 | vty_out(vty, | |
6385 | "\nTotal number of VRFs (including default): %d\n", | |
6386 | count); | |
6387 | } | |
6388 | ||
6389 | return CMD_SUCCESS; | |
8386ac43 | 6390 | } |
6391 | ||
f412b39a | 6392 | DEFUN (show_bgp_memory, |
4bf6a362 | 6393 | show_bgp_memory_cmd, |
7fa12b13 | 6394 | "show [ip] bgp memory", |
4bf6a362 | 6395 | SHOW_STR |
3a2d747c | 6396 | IP_STR |
4bf6a362 PJ |
6397 | BGP_STR |
6398 | "Global BGP memory statistics\n") | |
6399 | { | |
d62a17ae | 6400 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
6401 | unsigned long count; | |
6402 | ||
6403 | /* RIB related usage stats */ | |
6404 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
6405 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
6406 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6407 | count * sizeof(struct bgp_node))); | |
6408 | ||
6409 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
6410 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
6411 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6412 | count * sizeof(struct bgp_info))); | |
6413 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) | |
6414 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
6415 | count, | |
6416 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6417 | count * sizeof(struct bgp_info_extra))); | |
6418 | ||
6419 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
6420 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
6421 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6422 | count * sizeof(struct bgp_static))); | |
6423 | ||
6424 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
6425 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
6426 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6427 | count * sizeof(struct bpacket))); | |
6428 | ||
6429 | /* Adj-In/Out */ | |
6430 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
6431 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
6432 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6433 | count * sizeof(struct bgp_adj_in))); | |
6434 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
6435 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
6436 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6437 | count * sizeof(struct bgp_adj_out))); | |
6438 | ||
6439 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
6440 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
6441 | count, | |
6442 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6443 | count * sizeof(struct bgp_nexthop_cache))); | |
6444 | ||
6445 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
6446 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
6447 | count, | |
6448 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6449 | count * sizeof(struct bgp_damp_info))); | |
6450 | ||
6451 | /* Attributes */ | |
6452 | count = attr_count(); | |
6453 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
6454 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6455 | count * sizeof(struct attr))); | |
6456 | ||
6457 | if ((count = attr_unknown_count())) | |
6458 | vty_out(vty, "%ld unknown attributes\n", count); | |
6459 | ||
6460 | /* AS_PATH attributes */ | |
6461 | count = aspath_count(); | |
6462 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
6463 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6464 | count * sizeof(struct aspath))); | |
6465 | ||
6466 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
6467 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
6468 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6469 | count * sizeof(struct assegment))); | |
6470 | ||
6471 | /* Other attributes */ | |
6472 | if ((count = community_count())) | |
6473 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
9d303b37 DL |
6474 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
6475 | count * sizeof(struct community))); | |
d62a17ae | 6476 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
6477 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
9d303b37 DL |
6478 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
6479 | count * sizeof(struct ecommunity))); | |
d62a17ae | 6480 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
6481 | vty_out(vty, | |
6482 | "%ld BGP large-community entries, using %s of memory\n", | |
9d303b37 DL |
6483 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
6484 | count * sizeof(struct lcommunity))); | |
d62a17ae | 6485 | |
6486 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
6487 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
6488 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6489 | count * sizeof(struct cluster_list))); | |
6490 | ||
6491 | /* Peer related usage */ | |
6492 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
6493 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
6494 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6495 | count * sizeof(struct peer))); | |
6496 | ||
6497 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
6498 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
6499 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6500 | count * sizeof(struct peer_group))); | |
6501 | ||
6502 | /* Other */ | |
6503 | if ((count = mtype_stats_alloc(MTYPE_HASH))) | |
6504 | vty_out(vty, "%ld hash tables, using %s of memory\n", count, | |
6505 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6506 | count * sizeof(struct hash))); | |
6507 | if ((count = mtype_stats_alloc(MTYPE_HASH_BACKET))) | |
6508 | vty_out(vty, "%ld hash buckets, using %s of memory\n", count, | |
6509 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6510 | count * sizeof(struct hash_backet))); | |
6511 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) | |
6512 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
9d303b37 DL |
6513 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
6514 | count * sizeof(regex_t))); | |
d62a17ae | 6515 | return CMD_SUCCESS; |
4bf6a362 | 6516 | } |
fee0f4c6 | 6517 | |
718e3744 | 6518 | /* Show BGP peer's summary information. */ |
d62a17ae | 6519 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
6520 | u_char use_json, json_object *json) | |
6521 | { | |
6522 | struct peer *peer; | |
6523 | struct listnode *node, *nnode; | |
6524 | unsigned int count = 0, dn_count = 0; | |
6525 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
6526 | char neighbor_buf[VTY_BUFSIZ]; | |
6527 | int neighbor_col_default_width = 16; | |
6528 | int len; | |
6529 | int max_neighbor_width = 0; | |
6530 | int pfx_rcd_safi; | |
6531 | json_object *json_peer = NULL; | |
6532 | json_object *json_peers = NULL; | |
6533 | ||
6534 | /* labeled-unicast routes are installed in the unicast table so in order | |
6535 | * to | |
6536 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
6537 | */ | |
6538 | if (safi == SAFI_LABELED_UNICAST) | |
6539 | pfx_rcd_safi = SAFI_UNICAST; | |
6540 | else | |
6541 | pfx_rcd_safi = safi; | |
6542 | ||
6543 | if (use_json) { | |
6544 | if (json == NULL) | |
6545 | json = json_object_new_object(); | |
6546 | ||
6547 | json_peers = json_object_new_object(); | |
6548 | } else { | |
6549 | /* Loop over all neighbors that will be displayed to determine | |
6550 | * how many | |
6551 | * characters are needed for the Neighbor column | |
6552 | */ | |
6553 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
6554 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6555 | continue; | |
6556 | ||
6557 | if (peer->afc[afi][safi]) { | |
6558 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
6559 | if (peer_dynamic_neighbor(peer)) | |
6560 | dn_flag[0] = '*'; | |
6561 | ||
6562 | if (peer->hostname | |
6563 | && bgp_flag_check(bgp, | |
6564 | BGP_FLAG_SHOW_HOSTNAME)) | |
6565 | sprintf(neighbor_buf, "%s%s(%s) ", | |
6566 | dn_flag, peer->hostname, | |
6567 | peer->host); | |
6568 | else | |
6569 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
6570 | peer->host); | |
6571 | ||
6572 | len = strlen(neighbor_buf); | |
6573 | ||
6574 | if (len > max_neighbor_width) | |
6575 | max_neighbor_width = len; | |
6576 | } | |
6577 | } | |
f933309e | 6578 | |
d62a17ae | 6579 | /* Originally we displayed the Neighbor column as 16 |
6580 | * characters wide so make that the default | |
6581 | */ | |
6582 | if (max_neighbor_width < neighbor_col_default_width) | |
6583 | max_neighbor_width = neighbor_col_default_width; | |
6584 | } | |
f933309e | 6585 | |
d62a17ae | 6586 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
6587 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6588 | continue; | |
6589 | ||
6590 | if (peer->afc[afi][safi]) { | |
6591 | if (!count) { | |
6592 | unsigned long ents; | |
6593 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
6594 | int vrf_id_ui; | |
6595 | ||
6596 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) | |
6597 | ? -1 | |
6598 | : bgp->vrf_id; | |
6599 | ||
6600 | /* Usage summary and header */ | |
6601 | if (use_json) { | |
6602 | json_object_string_add( | |
6603 | json, "routerId", | |
6604 | inet_ntoa(bgp->router_id)); | |
6605 | json_object_int_add(json, "as", | |
6606 | bgp->as); | |
6607 | json_object_int_add(json, "vrfId", | |
6608 | vrf_id_ui); | |
6609 | json_object_string_add( | |
6610 | json, "vrfName", | |
6611 | (bgp->inst_type | |
6612 | == BGP_INSTANCE_TYPE_DEFAULT) | |
6613 | ? "Default" | |
6614 | : bgp->name); | |
6615 | } else { | |
6616 | vty_out(vty, | |
6617 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
6618 | inet_ntoa(bgp->router_id), | |
6619 | bgp->as, vrf_id_ui); | |
6620 | vty_out(vty, "\n"); | |
6621 | } | |
6622 | ||
6623 | if (bgp_update_delay_configured(bgp)) { | |
6624 | if (use_json) { | |
6625 | json_object_int_add( | |
6626 | json, | |
6627 | "updateDelayLimit", | |
6628 | bgp->v_update_delay); | |
6629 | ||
6630 | if (bgp->v_update_delay | |
6631 | != bgp->v_establish_wait) | |
6632 | json_object_int_add( | |
6633 | json, | |
6634 | "updateDelayEstablishWait", | |
6635 | bgp->v_establish_wait); | |
6636 | ||
6637 | if (bgp_update_delay_active( | |
6638 | bgp)) { | |
6639 | json_object_string_add( | |
6640 | json, | |
6641 | "updateDelayFirstNeighbor", | |
6642 | bgp->update_delay_begin_time); | |
6643 | json_object_boolean_true_add( | |
6644 | json, | |
6645 | "updateDelayInProgress"); | |
6646 | } else { | |
6647 | if (bgp->update_delay_over) { | |
6648 | json_object_string_add( | |
6649 | json, | |
6650 | "updateDelayFirstNeighbor", | |
6651 | bgp->update_delay_begin_time); | |
6652 | json_object_string_add( | |
6653 | json, | |
6654 | "updateDelayBestpathResumed", | |
6655 | bgp->update_delay_end_time); | |
6656 | json_object_string_add( | |
6657 | json, | |
6658 | "updateDelayZebraUpdateResume", | |
6659 | bgp->update_delay_zebra_resume_time); | |
6660 | json_object_string_add( | |
6661 | json, | |
6662 | "updateDelayPeerUpdateResume", | |
6663 | bgp->update_delay_peers_resume_time); | |
6664 | } | |
6665 | } | |
6666 | } else { | |
6667 | vty_out(vty, | |
6668 | "Read-only mode update-delay limit: %d seconds\n", | |
6669 | bgp->v_update_delay); | |
6670 | if (bgp->v_update_delay | |
6671 | != bgp->v_establish_wait) | |
6672 | vty_out(vty, | |
6673 | " Establish wait: %d seconds\n", | |
6674 | bgp->v_establish_wait); | |
6675 | ||
6676 | if (bgp_update_delay_active( | |
6677 | bgp)) { | |
6678 | vty_out(vty, | |
6679 | " First neighbor established: %s\n", | |
6680 | bgp->update_delay_begin_time); | |
6681 | vty_out(vty, | |
6682 | " Delay in progress\n"); | |
6683 | } else { | |
6684 | if (bgp->update_delay_over) { | |
6685 | vty_out(vty, | |
6686 | " First neighbor established: %s\n", | |
6687 | bgp->update_delay_begin_time); | |
6688 | vty_out(vty, | |
6689 | " Best-paths resumed: %s\n", | |
6690 | bgp->update_delay_end_time); | |
6691 | vty_out(vty, | |
6692 | " zebra update resumed: %s\n", | |
6693 | bgp->update_delay_zebra_resume_time); | |
6694 | vty_out(vty, | |
6695 | " peers update resumed: %s\n", | |
6696 | bgp->update_delay_peers_resume_time); | |
6697 | } | |
6698 | } | |
6699 | } | |
6700 | } | |
6701 | ||
6702 | if (use_json) { | |
6703 | if (bgp_maxmed_onstartup_configured(bgp) | |
6704 | && bgp->maxmed_active) | |
6705 | json_object_boolean_true_add( | |
6706 | json, | |
6707 | "maxMedOnStartup"); | |
6708 | if (bgp->v_maxmed_admin) | |
6709 | json_object_boolean_true_add( | |
6710 | json, | |
6711 | "maxMedAdministrative"); | |
6712 | ||
6713 | json_object_int_add( | |
6714 | json, "tableVersion", | |
6715 | bgp_table_version( | |
6716 | bgp->rib[afi][safi])); | |
6717 | ||
6718 | ents = bgp_table_count( | |
6719 | bgp->rib[afi][safi]); | |
6720 | json_object_int_add(json, "ribCount", | |
6721 | ents); | |
6722 | json_object_int_add( | |
6723 | json, "ribMemory", | |
6724 | ents * sizeof(struct bgp_node)); | |
6725 | ||
6726 | ents = listcount(bgp->peer); | |
6727 | json_object_int_add(json, "peerCount", | |
6728 | ents); | |
6729 | json_object_int_add( | |
6730 | json, "peerMemory", | |
6731 | ents * sizeof(struct peer)); | |
6732 | ||
6733 | if ((ents = listcount(bgp->group))) { | |
6734 | json_object_int_add( | |
6735 | json, "peerGroupCount", | |
6736 | ents); | |
6737 | json_object_int_add( | |
6738 | json, "peerGroupMemory", | |
9d303b37 DL |
6739 | ents * sizeof(struct |
6740 | peer_group)); | |
d62a17ae | 6741 | } |
6742 | ||
6743 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
6744 | BGP_CONFIG_DAMPENING)) | |
6745 | json_object_boolean_true_add( | |
6746 | json, | |
6747 | "dampeningEnabled"); | |
6748 | } else { | |
6749 | if (bgp_maxmed_onstartup_configured(bgp) | |
6750 | && bgp->maxmed_active) | |
6751 | vty_out(vty, | |
6752 | "Max-med on-startup active\n"); | |
6753 | if (bgp->v_maxmed_admin) | |
6754 | vty_out(vty, | |
6755 | "Max-med administrative active\n"); | |
6756 | ||
6757 | vty_out(vty, | |
6758 | "BGP table version %" PRIu64 | |
6759 | "\n", | |
6760 | bgp_table_version( | |
6761 | bgp->rib[afi][safi])); | |
6762 | ||
6763 | ents = bgp_table_count( | |
6764 | bgp->rib[afi][safi]); | |
6765 | vty_out(vty, | |
6766 | "RIB entries %ld, using %s of memory\n", | |
6767 | ents, | |
6768 | mtype_memstr( | |
6769 | memstrbuf, | |
6770 | sizeof(memstrbuf), | |
9d303b37 DL |
6771 | ents * sizeof(struct |
6772 | bgp_node))); | |
d62a17ae | 6773 | |
6774 | /* Peer related usage */ | |
6775 | ents = listcount(bgp->peer); | |
6776 | vty_out(vty, | |
6777 | "Peers %ld, using %s of memory\n", | |
6778 | ents, | |
6779 | mtype_memstr( | |
6780 | memstrbuf, | |
6781 | sizeof(memstrbuf), | |
9d303b37 DL |
6782 | ents * sizeof(struct |
6783 | peer))); | |
d62a17ae | 6784 | |
6785 | if ((ents = listcount(bgp->group))) | |
6786 | vty_out(vty, | |
6787 | "Peer groups %ld, using %s of memory\n", | |
6788 | ents, | |
6789 | mtype_memstr( | |
6790 | memstrbuf, | |
6791 | sizeof(memstrbuf), | |
9d303b37 DL |
6792 | ents * sizeof(struct |
6793 | peer_group))); | |
d62a17ae | 6794 | |
6795 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
6796 | BGP_CONFIG_DAMPENING)) | |
6797 | vty_out(vty, | |
6798 | "Dampening enabled.\n"); | |
6799 | vty_out(vty, "\n"); | |
6800 | ||
6801 | /* Subtract 8 here because 'Neighbor' is | |
6802 | * 8 characters */ | |
6803 | vty_out(vty, "Neighbor"); | |
6804 | vty_out(vty, "%*s", | |
6805 | max_neighbor_width - 8, " "); | |
6806 | vty_out(vty, | |
6807 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); | |
6808 | } | |
6809 | } | |
6810 | ||
6811 | count++; | |
6812 | ||
6813 | if (use_json) { | |
6814 | json_peer = json_object_new_object(); | |
6815 | ||
6816 | if (peer_dynamic_neighbor(peer)) | |
6817 | json_object_boolean_true_add( | |
6818 | json_peer, "dynamicPeer"); | |
6819 | ||
6820 | if (peer->hostname) | |
6821 | json_object_string_add(json_peer, | |
6822 | "hostname", | |
6823 | peer->hostname); | |
6824 | ||
6825 | if (peer->domainname) | |
6826 | json_object_string_add( | |
6827 | json_peer, "domainname", | |
6828 | peer->domainname); | |
6829 | ||
6830 | json_object_int_add(json_peer, "remoteAs", | |
6831 | peer->as); | |
6832 | json_object_int_add(json_peer, "version", 4); | |
6833 | json_object_int_add( | |
6834 | json_peer, "msgRcvd", | |
6835 | peer->open_in + peer->update_in | |
6836 | + peer->keepalive_in | |
6837 | + peer->notify_in | |
6838 | + peer->refresh_in | |
6839 | + peer->dynamic_cap_in); | |
6840 | json_object_int_add( | |
6841 | json_peer, "msgSent", | |
6842 | peer->open_out + peer->update_out | |
6843 | + peer->keepalive_out | |
6844 | + peer->notify_out | |
6845 | + peer->refresh_out | |
6846 | + peer->dynamic_cap_out); | |
6847 | ||
6848 | json_object_int_add(json_peer, "tableVersion", | |
6849 | peer->version[afi][safi]); | |
6850 | json_object_int_add(json_peer, "outq", | |
6851 | peer->obuf->count); | |
6852 | json_object_int_add(json_peer, "inq", 0); | |
6853 | peer_uptime(peer->uptime, timebuf, | |
6854 | BGP_UPTIME_LEN, use_json, | |
6855 | json_peer); | |
6856 | json_object_int_add( | |
6857 | json_peer, "prefixReceivedCount", | |
6858 | peer->pcount[afi][pfx_rcd_safi]); | |
6859 | ||
6860 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
6861 | json_object_string_add(json_peer, | |
6862 | "state", | |
6863 | "Idle (Admin)"); | |
6864 | else if (CHECK_FLAG( | |
6865 | peer->sflags, | |
6866 | PEER_STATUS_PREFIX_OVERFLOW)) | |
6867 | json_object_string_add(json_peer, | |
6868 | "state", | |
6869 | "Idle (PfxCt)"); | |
6870 | else | |
6871 | json_object_string_add( | |
6872 | json_peer, "state", | |
6873 | lookup_msg(bgp_status_msg, | |
6874 | peer->status, NULL)); | |
6875 | ||
6876 | if (peer->conf_if) | |
6877 | json_object_string_add(json_peer, | |
6878 | "idType", | |
6879 | "interface"); | |
6880 | else if (peer->su.sa.sa_family == AF_INET) | |
6881 | json_object_string_add( | |
6882 | json_peer, "idType", "ipv4"); | |
6883 | else if (peer->su.sa.sa_family == AF_INET6) | |
6884 | json_object_string_add( | |
6885 | json_peer, "idType", "ipv6"); | |
6886 | ||
6887 | json_object_object_add(json_peers, peer->host, | |
6888 | json_peer); | |
6889 | } else { | |
6890 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
6891 | if (peer_dynamic_neighbor(peer)) { | |
6892 | dn_count++; | |
6893 | dn_flag[0] = '*'; | |
6894 | } | |
6895 | ||
6896 | if (peer->hostname | |
6897 | && bgp_flag_check(bgp, | |
6898 | BGP_FLAG_SHOW_HOSTNAME)) | |
6899 | len = vty_out(vty, "%s%s(%s)", dn_flag, | |
6900 | peer->hostname, | |
6901 | peer->host); | |
6902 | else | |
6903 | len = vty_out(vty, "%s%s", dn_flag, | |
6904 | peer->host); | |
6905 | ||
6906 | /* pad the neighbor column with spaces */ | |
6907 | if (len < max_neighbor_width) | |
6908 | vty_out(vty, "%*s", | |
6909 | max_neighbor_width - len, " "); | |
6910 | ||
9d303b37 DL |
6911 | vty_out(vty, "4 %10u %7d %7d %8" PRIu64 |
6912 | " %4d %4zd %8s", | |
d62a17ae | 6913 | peer->as, |
6914 | peer->open_in + peer->update_in | |
6915 | + peer->keepalive_in | |
6916 | + peer->notify_in | |
6917 | + peer->refresh_in | |
6918 | + peer->dynamic_cap_in, | |
6919 | peer->open_out + peer->update_out | |
6920 | + peer->keepalive_out | |
6921 | + peer->notify_out | |
6922 | + peer->refresh_out | |
6923 | + peer->dynamic_cap_out, | |
6924 | peer->version[afi][safi], 0, | |
6925 | peer->obuf->count, | |
6926 | peer_uptime(peer->uptime, timebuf, | |
6927 | BGP_UPTIME_LEN, 0, NULL)); | |
6928 | ||
6929 | if (peer->status == Established) | |
6930 | vty_out(vty, " %12ld", | |
6931 | peer->pcount[afi] | |
6932 | [pfx_rcd_safi]); | |
6933 | else { | |
6934 | if (CHECK_FLAG(peer->flags, | |
6935 | PEER_FLAG_SHUTDOWN)) | |
6936 | vty_out(vty, " Idle (Admin)"); | |
6937 | else if ( | |
6938 | CHECK_FLAG( | |
6939 | peer->sflags, | |
6940 | PEER_STATUS_PREFIX_OVERFLOW)) | |
6941 | vty_out(vty, " Idle (PfxCt)"); | |
6942 | else | |
6943 | vty_out(vty, " %12s", | |
6944 | lookup_msg( | |
6945 | bgp_status_msg, | |
6946 | peer->status, | |
6947 | NULL)); | |
6948 | } | |
6949 | vty_out(vty, "\n"); | |
6950 | } | |
6951 | } | |
6952 | } | |
f933309e | 6953 | |
d62a17ae | 6954 | if (use_json) { |
6955 | json_object_object_add(json, "peers", json_peers); | |
6956 | ||
6957 | json_object_int_add(json, "totalPeers", count); | |
6958 | json_object_int_add(json, "dynamicPeers", dn_count); | |
6959 | ||
9d303b37 DL |
6960 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
6961 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 6962 | json_object_free(json); |
6963 | } else { | |
6964 | if (count) | |
6965 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
6966 | else { | |
6967 | if (use_json) | |
6968 | vty_out(vty, | |
6969 | "{\"error\": {\"message\": \"No %s neighbor configured\"}}\n", | |
6970 | afi_safi_print(afi, safi)); | |
6971 | else | |
6972 | vty_out(vty, "No %s neighbor is configured\n", | |
6973 | afi_safi_print(afi, safi)); | |
6974 | } | |
b05a1c8b | 6975 | |
d62a17ae | 6976 | if (dn_count && !use_json) { |
6977 | vty_out(vty, "* - dynamic neighbor\n"); | |
6978 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
6979 | dn_count, bgp->dynamic_neighbors_limit); | |
6980 | } | |
6981 | } | |
1ff9a340 | 6982 | |
d62a17ae | 6983 | return CMD_SUCCESS; |
718e3744 | 6984 | } |
6985 | ||
798c3572 DS |
6986 | /* |
6987 | * Return if we have a peer configured to use this afi/safi | |
6988 | */ | |
d62a17ae | 6989 | static int bgp_show_summary_afi_safi_peer_exists(struct bgp *bgp, int afi, |
6990 | int safi) | |
6991 | { | |
6992 | struct listnode *node; | |
6993 | struct peer *peer; | |
6994 | ||
6995 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) { | |
6996 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6997 | continue; | |
6998 | ||
6999 | if (peer->afc[afi][safi]) | |
7000 | return 1; | |
7001 | } | |
7002 | ||
7003 | return 0; | |
7004 | } | |
7005 | ||
7006 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, | |
7007 | int safi, u_char use_json, | |
7008 | json_object *json) | |
7009 | { | |
7010 | int is_first = 1; | |
7011 | int afi_wildcard = (afi == AFI_MAX); | |
7012 | int safi_wildcard = (safi == SAFI_MAX); | |
7013 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
7014 | bool json_output = false; | |
7015 | ||
7016 | if (use_json && is_wildcard) | |
7017 | vty_out(vty, "{\n"); | |
7018 | if (afi_wildcard) | |
7019 | afi = 1; /* AFI_IP */ | |
7020 | while (afi < AFI_MAX) { | |
7021 | if (safi_wildcard) | |
7022 | safi = 1; /* SAFI_UNICAST */ | |
7023 | while (safi < SAFI_MAX) { | |
7024 | if (bgp_show_summary_afi_safi_peer_exists(bgp, afi, | |
7025 | safi)) { | |
7026 | json_output = true; | |
7027 | if (is_wildcard) { | |
7028 | /* | |
7029 | * So limit output to those afi/safi | |
7030 | * pairs that | |
7031 | * actualy have something interesting in | |
7032 | * them | |
7033 | */ | |
7034 | if (use_json) { | |
7035 | json = json_object_new_object(); | |
7036 | ||
7037 | if (!is_first) | |
7038 | vty_out(vty, ",\n"); | |
7039 | else | |
7040 | is_first = 0; | |
7041 | ||
7042 | vty_out(vty, "\"%s\":", | |
7043 | afi_safi_json(afi, | |
7044 | safi)); | |
7045 | } else { | |
7046 | vty_out(vty, "\n%s Summary:\n", | |
7047 | afi_safi_print(afi, | |
7048 | safi)); | |
7049 | } | |
7050 | } | |
7051 | bgp_show_summary(vty, bgp, afi, safi, use_json, | |
7052 | json); | |
7053 | } | |
7054 | safi++; | |
7055 | if (safi == SAFI_RESERVED_4 | |
9d303b37 DL |
7056 | || safi |
7057 | == SAFI_RESERVED_5) /* handle special | |
7058 | cases to match | |
7059 | zebra.h */ | |
d62a17ae | 7060 | safi++; |
7061 | if (!safi_wildcard) | |
7062 | safi = SAFI_MAX; | |
7063 | } | |
7064 | afi++; | |
7065 | if (!afi_wildcard | |
7066 | || afi == AFI_L2VPN) /* special case, not handled yet */ | |
7067 | afi = AFI_MAX; | |
7068 | } | |
7069 | ||
7070 | if (use_json && is_wildcard) | |
7071 | vty_out(vty, "}\n"); | |
7072 | else if (use_json && !json_output) | |
7073 | vty_out(vty, "{}\n"); | |
7074 | } | |
7075 | ||
7076 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
7077 | safi_t safi, u_char use_json) | |
7078 | { | |
7079 | struct listnode *node, *nnode; | |
7080 | struct bgp *bgp; | |
7081 | json_object *json = NULL; | |
7082 | int is_first = 1; | |
7083 | ||
7084 | if (use_json) | |
7085 | vty_out(vty, "{\n"); | |
7086 | ||
7087 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
7088 | if (use_json) { | |
7089 | json = json_object_new_object(); | |
7090 | ||
7091 | if (!is_first) | |
7092 | vty_out(vty, ",\n"); | |
7093 | else | |
7094 | is_first = 0; | |
7095 | ||
7096 | vty_out(vty, "\"%s\":", | |
7097 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7098 | ? "Default" | |
7099 | : bgp->name); | |
7100 | } else { | |
7101 | vty_out(vty, "\nInstance %s:\n", | |
7102 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7103 | ? "Default" | |
7104 | : bgp->name); | |
7105 | } | |
7106 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, json); | |
7107 | } | |
7108 | ||
7109 | if (use_json) | |
7110 | vty_out(vty, "}\n"); | |
7111 | } | |
7112 | ||
7113 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
7114 | safi_t safi, u_char use_json) | |
7115 | { | |
7116 | struct bgp *bgp; | |
7117 | ||
7118 | if (name) { | |
7119 | if (strmatch(name, "all")) { | |
7120 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
7121 | use_json); | |
7122 | return CMD_SUCCESS; | |
7123 | } else { | |
7124 | bgp = bgp_lookup_by_name(name); | |
7125 | ||
7126 | if (!bgp) { | |
7127 | if (use_json) | |
7128 | vty_out(vty, "{}\n"); | |
7129 | else | |
7130 | vty_out(vty, | |
7131 | "%% No such BGP instance exist\n"); | |
7132 | return CMD_WARNING; | |
7133 | } | |
7134 | ||
7135 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, | |
7136 | NULL); | |
7137 | return CMD_SUCCESS; | |
7138 | } | |
7139 | } | |
7140 | ||
7141 | bgp = bgp_get_default(); | |
7142 | ||
7143 | if (bgp) | |
7144 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, NULL); | |
7145 | ||
7146 | return CMD_SUCCESS; | |
4fb25c53 DW |
7147 | } |
7148 | ||
716b2d8a | 7149 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 7150 | DEFUN (show_ip_bgp_summary, |
718e3744 | 7151 | show_ip_bgp_summary_cmd, |
dd6bd0f1 | 7152 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [json]", |
718e3744 | 7153 | SHOW_STR |
7154 | IP_STR | |
7155 | BGP_STR | |
8386ac43 | 7156 | BGP_INSTANCE_HELP_STR |
46f296b4 | 7157 | BGP_AFI_HELP_STR |
dd6bd0f1 | 7158 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 7159 | "Summary of BGP neighbor status\n" |
9973d184 | 7160 | JSON_STR) |
718e3744 | 7161 | { |
d62a17ae | 7162 | char *vrf = NULL; |
7163 | afi_t afi = AFI_MAX; | |
7164 | safi_t safi = SAFI_MAX; | |
7165 | ||
7166 | int idx = 0; | |
7167 | ||
7168 | /* show [ip] bgp */ | |
7169 | if (argv_find(argv, argc, "ip", &idx)) | |
7170 | afi = AFI_IP; | |
7171 | /* [<view|vrf> VIEWVRFNAME] */ | |
7172 | if (argv_find(argv, argc, "view", &idx) | |
7173 | || argv_find(argv, argc, "vrf", &idx)) | |
7174 | vrf = argv[++idx]->arg; | |
7175 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
7176 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
7177 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
7178 | } | |
7179 | ||
7180 | int uj = use_json(argc, argv); | |
7181 | ||
7182 | return bgp_show_summary_vty(vty, vrf, afi, safi, uj); | |
7183 | } | |
7184 | ||
7185 | const char *afi_safi_print(afi_t afi, safi_t safi) | |
7186 | { | |
7187 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
7188 | return "IPv4 Unicast"; | |
7189 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
7190 | return "IPv4 Multicast"; | |
7191 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
7192 | return "IPv4 Labeled Unicast"; | |
7193 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
7194 | return "IPv4 VPN"; | |
7195 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
7196 | return "IPv4 Encap"; | |
7197 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
7198 | return "IPv6 Unicast"; | |
7199 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
7200 | return "IPv6 Multicast"; | |
7201 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
7202 | return "IPv6 Labeled Unicast"; | |
7203 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
7204 | return "IPv6 VPN"; | |
7205 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
7206 | return "IPv6 Encap"; | |
7207 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
7208 | return "L2VPN EVPN"; | |
7209 | else | |
7210 | return "Unknown"; | |
538621f2 | 7211 | } |
7212 | ||
b9f77ec8 DS |
7213 | /* |
7214 | * Please note that we have intentionally camelCased | |
7215 | * the return strings here. So if you want | |
7216 | * to use this function, please ensure you | |
7217 | * are doing this within json output | |
7218 | */ | |
d62a17ae | 7219 | const char *afi_safi_json(afi_t afi, safi_t safi) |
7220 | { | |
7221 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
7222 | return "ipv4Unicast"; | |
7223 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
7224 | return "ipv4Multicast"; | |
7225 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
7226 | return "ipv4LabeledUnicast"; | |
7227 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
7228 | return "ipv4Vpn"; | |
7229 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
7230 | return "ipv4Encap"; | |
7231 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
7232 | return "ipv6Unicast"; | |
7233 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
7234 | return "ipv6Multicast"; | |
7235 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
7236 | return "ipv6LabeledUnicast"; | |
7237 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
7238 | return "ipv6Vpn"; | |
7239 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
7240 | return "ipv6Encap"; | |
7241 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
7242 | return "l2VpnEvpn"; | |
7243 | else | |
7244 | return "Unknown"; | |
27162734 LB |
7245 | } |
7246 | ||
718e3744 | 7247 | /* Show BGP peer's information. */ |
d62a17ae | 7248 | enum show_type { show_all, show_peer }; |
7249 | ||
7250 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
7251 | afi_t afi, safi_t safi, | |
7252 | u_int16_t adv_smcap, u_int16_t adv_rmcap, | |
7253 | u_int16_t rcv_smcap, u_int16_t rcv_rmcap, | |
7254 | u_char use_json, json_object *json_pref) | |
7255 | { | |
7256 | /* Send-Mode */ | |
7257 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
7258 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
7259 | if (use_json) { | |
7260 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
7261 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
7262 | json_object_string_add(json_pref, "sendMode", | |
7263 | "advertisedAndReceived"); | |
7264 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
7265 | json_object_string_add(json_pref, "sendMode", | |
7266 | "advertised"); | |
7267 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
7268 | json_object_string_add(json_pref, "sendMode", | |
7269 | "received"); | |
7270 | } else { | |
7271 | vty_out(vty, " Send-mode: "); | |
7272 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
7273 | vty_out(vty, "advertised"); | |
7274 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
7275 | vty_out(vty, "%sreceived", | |
7276 | CHECK_FLAG(p->af_cap[afi][safi], | |
7277 | adv_smcap) | |
7278 | ? ", " | |
7279 | : ""); | |
7280 | vty_out(vty, "\n"); | |
7281 | } | |
7282 | } | |
7283 | ||
7284 | /* Receive-Mode */ | |
7285 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
7286 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
7287 | if (use_json) { | |
7288 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
7289 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
7290 | json_object_string_add(json_pref, "recvMode", | |
7291 | "advertisedAndReceived"); | |
7292 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
7293 | json_object_string_add(json_pref, "recvMode", | |
7294 | "advertised"); | |
7295 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
7296 | json_object_string_add(json_pref, "recvMode", | |
7297 | "received"); | |
7298 | } else { | |
7299 | vty_out(vty, " Receive-mode: "); | |
7300 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
7301 | vty_out(vty, "advertised"); | |
7302 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
7303 | vty_out(vty, "%sreceived", | |
7304 | CHECK_FLAG(p->af_cap[afi][safi], | |
7305 | adv_rmcap) | |
7306 | ? ", " | |
7307 | : ""); | |
7308 | vty_out(vty, "\n"); | |
7309 | } | |
7310 | } | |
7311 | } | |
7312 | ||
7313 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, | |
7314 | safi_t safi, u_char use_json, | |
7315 | json_object *json_neigh) | |
7316 | { | |
7317 | struct bgp_filter *filter; | |
7318 | struct peer_af *paf; | |
7319 | char orf_pfx_name[BUFSIZ]; | |
7320 | int orf_pfx_count; | |
7321 | json_object *json_af = NULL; | |
7322 | json_object *json_prefA = NULL; | |
7323 | json_object *json_prefB = NULL; | |
7324 | json_object *json_addr = NULL; | |
7325 | ||
7326 | if (use_json) { | |
7327 | json_addr = json_object_new_object(); | |
7328 | json_af = json_object_new_object(); | |
7329 | filter = &p->filter[afi][safi]; | |
7330 | ||
7331 | if (peer_group_active(p)) | |
7332 | json_object_string_add(json_addr, "peerGroupMember", | |
7333 | p->group->name); | |
7334 | ||
7335 | paf = peer_af_find(p, afi, safi); | |
7336 | if (paf && PAF_SUBGRP(paf)) { | |
7337 | json_object_int_add(json_addr, "updateGroupId", | |
7338 | PAF_UPDGRP(paf)->id); | |
7339 | json_object_int_add(json_addr, "subGroupId", | |
7340 | PAF_SUBGRP(paf)->id); | |
7341 | json_object_int_add(json_addr, "packetQueueLength", | |
7342 | bpacket_queue_virtual_length(paf)); | |
7343 | } | |
7344 | ||
7345 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7346 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7347 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7348 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7349 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7350 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7351 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
7352 | json_object_int_add(json_af, "orfType", | |
7353 | ORF_TYPE_PREFIX); | |
7354 | json_prefA = json_object_new_object(); | |
7355 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
7356 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7357 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7358 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7359 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
7360 | use_json, json_prefA); | |
7361 | json_object_object_add(json_af, "orfPrefixList", | |
7362 | json_prefA); | |
7363 | } | |
7364 | ||
7365 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7366 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7367 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7368 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7369 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7370 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7371 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
7372 | json_object_int_add(json_af, "orfOldType", | |
7373 | ORF_TYPE_PREFIX_OLD); | |
7374 | json_prefB = json_object_new_object(); | |
7375 | bgp_show_peer_afi_orf_cap( | |
7376 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
7377 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7378 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7379 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
7380 | json_prefB); | |
7381 | json_object_object_add(json_af, "orfOldPrefixList", | |
7382 | json_prefB); | |
7383 | } | |
7384 | ||
7385 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7386 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7387 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7388 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7389 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7390 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7391 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7392 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7393 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
7394 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7395 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7396 | json_object_object_add(json_addr, "afDependentCap", | |
7397 | json_af); | |
7398 | else | |
7399 | json_object_free(json_af); | |
7400 | ||
7401 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
7402 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
7403 | NULL, afi, orf_pfx_name, use_json); | |
7404 | ||
7405 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7406 | PEER_STATUS_ORF_PREFIX_SEND) | |
7407 | || orf_pfx_count) { | |
7408 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7409 | PEER_STATUS_ORF_PREFIX_SEND)) | |
7410 | json_object_boolean_true_add(json_neigh, | |
7411 | "orfSent"); | |
7412 | if (orf_pfx_count) | |
7413 | json_object_int_add(json_addr, "orfRecvCounter", | |
7414 | orf_pfx_count); | |
7415 | } | |
7416 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7417 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
7418 | json_object_string_add( | |
7419 | json_addr, "orfFirstUpdate", | |
7420 | "deferredUntilORFOrRouteRefreshRecvd"); | |
7421 | ||
7422 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7423 | PEER_FLAG_REFLECTOR_CLIENT)) | |
7424 | json_object_boolean_true_add(json_addr, | |
7425 | "routeReflectorClient"); | |
7426 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7427 | PEER_FLAG_RSERVER_CLIENT)) | |
7428 | json_object_boolean_true_add(json_addr, | |
7429 | "routeServerClient"); | |
7430 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7431 | json_object_boolean_true_add(json_addr, | |
7432 | "inboundSoftConfigPermit"); | |
7433 | ||
7434 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7435 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
7436 | json_object_boolean_true_add( | |
7437 | json_addr, | |
7438 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
7439 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7440 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
7441 | json_object_boolean_true_add( | |
7442 | json_addr, | |
7443 | "privateAsNumsReplacedInUpdatesToNbr"); | |
7444 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7445 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
7446 | json_object_boolean_true_add( | |
7447 | json_addr, | |
7448 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
7449 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7450 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
7451 | json_object_boolean_true_add( | |
7452 | json_addr, | |
7453 | "privateAsNumsRemovedInUpdatesToNbr"); | |
7454 | ||
7455 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7456 | PEER_FLAG_ADDPATH_TX_ALL_PATHS)) | |
7457 | json_object_boolean_true_add(json_addr, | |
7458 | "addpathTxAllPaths"); | |
7459 | ||
7460 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7461 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
7462 | json_object_boolean_true_add(json_addr, | |
7463 | "addpathTxBestpathPerAS"); | |
7464 | ||
7465 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
7466 | json_object_string_add(json_addr, | |
7467 | "overrideASNsInOutboundUpdates", | |
7468 | "ifAspathEqualRemoteAs"); | |
7469 | ||
7470 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
7471 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7472 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7473 | json_object_boolean_true_add(json_addr, | |
7474 | "routerAlwaysNextHop"); | |
7475 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7476 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
7477 | json_object_boolean_true_add( | |
7478 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
7479 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7480 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7481 | json_object_boolean_true_add( | |
7482 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
7483 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7484 | json_object_boolean_true_add( | |
7485 | json_addr, "unchangedMedPropogatedToNbr"); | |
7486 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7487 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7488 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
7489 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7490 | PEER_FLAG_SEND_COMMUNITY) | |
7491 | && CHECK_FLAG(p->af_flags[afi][safi], | |
7492 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7493 | json_object_string_add(json_addr, | |
7494 | "commAttriSentToNbr", | |
7495 | "extendedAndStandard"); | |
7496 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7497 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7498 | json_object_string_add(json_addr, | |
7499 | "commAttriSentToNbr", | |
7500 | "extended"); | |
7501 | else | |
7502 | json_object_string_add(json_addr, | |
7503 | "commAttriSentToNbr", | |
7504 | "standard"); | |
7505 | } | |
7506 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7507 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
7508 | if (p->default_rmap[afi][safi].name) | |
7509 | json_object_string_add( | |
7510 | json_addr, "defaultRouteMap", | |
7511 | p->default_rmap[afi][safi].name); | |
7512 | ||
7513 | if (paf && PAF_SUBGRP(paf) | |
7514 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
7515 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7516 | json_object_boolean_true_add(json_addr, | |
7517 | "defaultSent"); | |
7518 | else | |
7519 | json_object_boolean_true_add(json_addr, | |
7520 | "defaultNotSent"); | |
7521 | } | |
7522 | ||
7523 | if (filter->plist[FILTER_IN].name | |
7524 | || filter->dlist[FILTER_IN].name | |
7525 | || filter->aslist[FILTER_IN].name | |
7526 | || filter->map[RMAP_IN].name) | |
7527 | json_object_boolean_true_add(json_addr, | |
7528 | "inboundPathPolicyConfig"); | |
7529 | if (filter->plist[FILTER_OUT].name | |
7530 | || filter->dlist[FILTER_OUT].name | |
7531 | || filter->aslist[FILTER_OUT].name | |
7532 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
7533 | json_object_boolean_true_add( | |
7534 | json_addr, "outboundPathPolicyConfig"); | |
7535 | ||
7536 | /* prefix-list */ | |
7537 | if (filter->plist[FILTER_IN].name) | |
7538 | json_object_string_add(json_addr, | |
7539 | "incomingUpdatePrefixFilterList", | |
7540 | filter->plist[FILTER_IN].name); | |
7541 | if (filter->plist[FILTER_OUT].name) | |
7542 | json_object_string_add(json_addr, | |
7543 | "outgoingUpdatePrefixFilterList", | |
7544 | filter->plist[FILTER_OUT].name); | |
7545 | ||
7546 | /* distribute-list */ | |
7547 | if (filter->dlist[FILTER_IN].name) | |
7548 | json_object_string_add( | |
7549 | json_addr, "incomingUpdateNetworkFilterList", | |
7550 | filter->dlist[FILTER_IN].name); | |
7551 | if (filter->dlist[FILTER_OUT].name) | |
7552 | json_object_string_add( | |
7553 | json_addr, "outgoingUpdateNetworkFilterList", | |
7554 | filter->dlist[FILTER_OUT].name); | |
7555 | ||
7556 | /* filter-list. */ | |
7557 | if (filter->aslist[FILTER_IN].name) | |
7558 | json_object_string_add(json_addr, | |
7559 | "incomingUpdateAsPathFilterList", | |
7560 | filter->aslist[FILTER_IN].name); | |
7561 | if (filter->aslist[FILTER_OUT].name) | |
7562 | json_object_string_add(json_addr, | |
7563 | "outgoingUpdateAsPathFilterList", | |
7564 | filter->aslist[FILTER_OUT].name); | |
7565 | ||
7566 | /* route-map. */ | |
7567 | if (filter->map[RMAP_IN].name) | |
7568 | json_object_string_add( | |
7569 | json_addr, "routeMapForIncomingAdvertisements", | |
7570 | filter->map[RMAP_IN].name); | |
7571 | if (filter->map[RMAP_OUT].name) | |
7572 | json_object_string_add( | |
7573 | json_addr, "routeMapForOutgoingAdvertisements", | |
7574 | filter->map[RMAP_OUT].name); | |
7575 | ||
7576 | /* unsuppress-map */ | |
7577 | if (filter->usmap.name) | |
7578 | json_object_string_add(json_addr, | |
7579 | "selectiveUnsuppressRouteMap", | |
7580 | filter->usmap.name); | |
7581 | ||
7582 | /* Receive prefix count */ | |
7583 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
7584 | p->pcount[afi][safi]); | |
7585 | ||
7586 | /* Maximum prefix */ | |
7587 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
7588 | json_object_int_add(json_addr, "prefixAllowedMax", | |
7589 | p->pmax[afi][safi]); | |
7590 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7591 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
7592 | json_object_boolean_true_add( | |
7593 | json_addr, "prefixAllowedMaxWarning"); | |
7594 | json_object_int_add(json_addr, | |
7595 | "prefixAllowedWarningThresh", | |
7596 | p->pmax_threshold[afi][safi]); | |
7597 | if (p->pmax_restart[afi][safi]) | |
7598 | json_object_int_add( | |
7599 | json_addr, | |
7600 | "prefixAllowedRestartIntervalMsecs", | |
7601 | p->pmax_restart[afi][safi] * 60000); | |
7602 | } | |
7603 | json_object_object_add(json_neigh, afi_safi_print(afi, safi), | |
7604 | json_addr); | |
7605 | ||
7606 | } else { | |
7607 | filter = &p->filter[afi][safi]; | |
7608 | ||
7609 | vty_out(vty, " For address family: %s\n", | |
7610 | afi_safi_print(afi, safi)); | |
7611 | ||
7612 | if (peer_group_active(p)) | |
7613 | vty_out(vty, " %s peer-group member\n", | |
7614 | p->group->name); | |
7615 | ||
7616 | paf = peer_af_find(p, afi, safi); | |
7617 | if (paf && PAF_SUBGRP(paf)) { | |
9d303b37 DL |
7618 | vty_out(vty, " Update group %" PRIu64 |
7619 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 7620 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
7621 | vty_out(vty, " Packet Queue length %d\n", | |
7622 | bpacket_queue_virtual_length(paf)); | |
7623 | } else { | |
7624 | vty_out(vty, " Not part of any update group\n"); | |
7625 | } | |
7626 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7627 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7628 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7629 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7630 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7631 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7632 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7633 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7634 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
7635 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7636 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7637 | vty_out(vty, " AF-dependant capabilities:\n"); | |
7638 | ||
7639 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7640 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7641 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7642 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7643 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7644 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7645 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
7646 | vty_out(vty, | |
7647 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
7648 | ORF_TYPE_PREFIX); | |
7649 | bgp_show_peer_afi_orf_cap( | |
7650 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
7651 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7652 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7653 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
7654 | } | |
7655 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7656 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7657 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7658 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7659 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7660 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7661 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
7662 | vty_out(vty, | |
7663 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
7664 | ORF_TYPE_PREFIX_OLD); | |
7665 | bgp_show_peer_afi_orf_cap( | |
7666 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
7667 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7668 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7669 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
7670 | } | |
7671 | ||
7672 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
7673 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
7674 | NULL, afi, orf_pfx_name, use_json); | |
7675 | ||
7676 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7677 | PEER_STATUS_ORF_PREFIX_SEND) | |
7678 | || orf_pfx_count) { | |
7679 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
7680 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7681 | PEER_STATUS_ORF_PREFIX_SEND)) | |
7682 | vty_out(vty, " sent;"); | |
7683 | if (orf_pfx_count) | |
7684 | vty_out(vty, " received (%d entries)", | |
7685 | orf_pfx_count); | |
7686 | vty_out(vty, "\n"); | |
7687 | } | |
7688 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7689 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
7690 | vty_out(vty, | |
7691 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
7692 | ||
7693 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7694 | PEER_FLAG_REFLECTOR_CLIENT)) | |
7695 | vty_out(vty, " Route-Reflector Client\n"); | |
7696 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7697 | PEER_FLAG_RSERVER_CLIENT)) | |
7698 | vty_out(vty, " Route-Server Client\n"); | |
7699 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7700 | vty_out(vty, | |
7701 | " Inbound soft reconfiguration allowed\n"); | |
7702 | ||
7703 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7704 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
7705 | vty_out(vty, | |
7706 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
7707 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7708 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
7709 | vty_out(vty, | |
7710 | " Private AS numbers replaced in updates to this neighbor\n"); | |
7711 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7712 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
7713 | vty_out(vty, | |
7714 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
7715 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7716 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
7717 | vty_out(vty, | |
7718 | " Private AS numbers removed in updates to this neighbor\n"); | |
7719 | ||
7720 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7721 | PEER_FLAG_ADDPATH_TX_ALL_PATHS)) | |
7722 | vty_out(vty, " Advertise all paths via addpath\n"); | |
7723 | ||
7724 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7725 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
7726 | vty_out(vty, | |
7727 | " Advertise bestpath per AS via addpath\n"); | |
7728 | ||
7729 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
7730 | vty_out(vty, | |
7731 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
7732 | ||
7733 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
7734 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7735 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7736 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
7737 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7738 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
7739 | vty_out(vty, | |
7740 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
7741 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7742 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7743 | vty_out(vty, | |
7744 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
7745 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7746 | vty_out(vty, | |
7747 | " MED is propagated unchanged to this neighbor\n"); | |
7748 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7749 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7750 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
7751 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7752 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
7753 | vty_out(vty, | |
7754 | " Community attribute sent to this neighbor"); | |
7755 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7756 | PEER_FLAG_SEND_COMMUNITY) | |
7757 | && CHECK_FLAG(p->af_flags[afi][safi], | |
7758 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
7759 | && CHECK_FLAG(p->af_flags[afi][safi], | |
7760 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7761 | vty_out(vty, "(all)\n"); | |
7762 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7763 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7764 | vty_out(vty, "(large)\n"); | |
7765 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7766 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7767 | vty_out(vty, "(extended)\n"); | |
7768 | else | |
7769 | vty_out(vty, "(standard)\n"); | |
7770 | } | |
7771 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7772 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
7773 | vty_out(vty, " Default information originate,"); | |
7774 | ||
7775 | if (p->default_rmap[afi][safi].name) | |
7776 | vty_out(vty, " default route-map %s%s,", | |
7777 | p->default_rmap[afi][safi].map ? "*" | |
7778 | : "", | |
7779 | p->default_rmap[afi][safi].name); | |
7780 | if (paf && PAF_SUBGRP(paf) | |
7781 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
7782 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7783 | vty_out(vty, " default sent\n"); | |
7784 | else | |
7785 | vty_out(vty, " default not sent\n"); | |
7786 | } | |
7787 | ||
7788 | if (filter->plist[FILTER_IN].name | |
7789 | || filter->dlist[FILTER_IN].name | |
7790 | || filter->aslist[FILTER_IN].name | |
7791 | || filter->map[RMAP_IN].name) | |
7792 | vty_out(vty, " Inbound path policy configured\n"); | |
7793 | if (filter->plist[FILTER_OUT].name | |
7794 | || filter->dlist[FILTER_OUT].name | |
7795 | || filter->aslist[FILTER_OUT].name | |
7796 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
7797 | vty_out(vty, " Outbound path policy configured\n"); | |
7798 | ||
7799 | /* prefix-list */ | |
7800 | if (filter->plist[FILTER_IN].name) | |
7801 | vty_out(vty, | |
7802 | " Incoming update prefix filter list is %s%s\n", | |
7803 | filter->plist[FILTER_IN].plist ? "*" : "", | |
7804 | filter->plist[FILTER_IN].name); | |
7805 | if (filter->plist[FILTER_OUT].name) | |
7806 | vty_out(vty, | |
7807 | " Outgoing update prefix filter list is %s%s\n", | |
7808 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
7809 | filter->plist[FILTER_OUT].name); | |
7810 | ||
7811 | /* distribute-list */ | |
7812 | if (filter->dlist[FILTER_IN].name) | |
7813 | vty_out(vty, | |
7814 | " Incoming update network filter list is %s%s\n", | |
7815 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
7816 | filter->dlist[FILTER_IN].name); | |
7817 | if (filter->dlist[FILTER_OUT].name) | |
7818 | vty_out(vty, | |
7819 | " Outgoing update network filter list is %s%s\n", | |
7820 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
7821 | filter->dlist[FILTER_OUT].name); | |
7822 | ||
7823 | /* filter-list. */ | |
7824 | if (filter->aslist[FILTER_IN].name) | |
7825 | vty_out(vty, | |
7826 | " Incoming update AS path filter list is %s%s\n", | |
7827 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
7828 | filter->aslist[FILTER_IN].name); | |
7829 | if (filter->aslist[FILTER_OUT].name) | |
7830 | vty_out(vty, | |
7831 | " Outgoing update AS path filter list is %s%s\n", | |
7832 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
7833 | filter->aslist[FILTER_OUT].name); | |
7834 | ||
7835 | /* route-map. */ | |
7836 | if (filter->map[RMAP_IN].name) | |
7837 | vty_out(vty, | |
7838 | " Route map for incoming advertisements is %s%s\n", | |
7839 | filter->map[RMAP_IN].map ? "*" : "", | |
7840 | filter->map[RMAP_IN].name); | |
7841 | if (filter->map[RMAP_OUT].name) | |
7842 | vty_out(vty, | |
7843 | " Route map for outgoing advertisements is %s%s\n", | |
7844 | filter->map[RMAP_OUT].map ? "*" : "", | |
7845 | filter->map[RMAP_OUT].name); | |
7846 | ||
7847 | /* unsuppress-map */ | |
7848 | if (filter->usmap.name) | |
7849 | vty_out(vty, | |
7850 | " Route map for selective unsuppress is %s%s\n", | |
7851 | filter->usmap.map ? "*" : "", | |
7852 | filter->usmap.name); | |
7853 | ||
7854 | /* Receive prefix count */ | |
7855 | vty_out(vty, " %ld accepted prefixes\n", p->pcount[afi][safi]); | |
7856 | ||
7857 | /* Maximum prefix */ | |
7858 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
7859 | vty_out(vty, " Maximum prefixes allowed %ld%s\n", | |
7860 | p->pmax[afi][safi], | |
7861 | CHECK_FLAG(p->af_flags[afi][safi], | |
7862 | PEER_FLAG_MAX_PREFIX_WARNING) | |
7863 | ? " (warning-only)" | |
7864 | : ""); | |
7865 | vty_out(vty, " Threshold for warning message %d%%", | |
7866 | p->pmax_threshold[afi][safi]); | |
7867 | if (p->pmax_restart[afi][safi]) | |
7868 | vty_out(vty, ", restart interval %d min", | |
7869 | p->pmax_restart[afi][safi]); | |
7870 | vty_out(vty, "\n"); | |
7871 | } | |
7872 | ||
7873 | vty_out(vty, "\n"); | |
7874 | } | |
7875 | } | |
7876 | ||
7877 | static void bgp_show_peer(struct vty *vty, struct peer *p, u_char use_json, | |
7878 | json_object *json) | |
718e3744 | 7879 | { |
d62a17ae | 7880 | struct bgp *bgp; |
7881 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
7882 | char timebuf[BGP_UPTIME_LEN]; | |
7883 | char dn_flag[2]; | |
7884 | const char *subcode_str; | |
7885 | const char *code_str; | |
7886 | afi_t afi; | |
7887 | safi_t safi; | |
7888 | u_int16_t i; | |
7889 | u_char *msg; | |
7890 | json_object *json_neigh = NULL; | |
7891 | time_t epoch_tbuf; | |
718e3744 | 7892 | |
d62a17ae | 7893 | bgp = p->bgp; |
7894 | ||
7895 | if (use_json) | |
7896 | json_neigh = json_object_new_object(); | |
7897 | ||
7898 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7899 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
7900 | dn_flag[0] = '*'; | |
7901 | ||
7902 | if (!use_json) { | |
7903 | if (p->conf_if) /* Configured interface name. */ | |
7904 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
7905 | BGP_PEER_SU_UNSPEC(p) | |
7906 | ? "None" | |
7907 | : sockunion2str(&p->su, buf, | |
7908 | SU_ADDRSTRLEN)); | |
7909 | else /* Configured IP address. */ | |
7910 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
7911 | p->host); | |
7912 | } | |
7913 | ||
7914 | if (use_json) { | |
7915 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
7916 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
7917 | "none"); | |
7918 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
7919 | json_object_string_add( | |
7920 | json_neigh, "bgpNeighborAddr", | |
7921 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
7922 | ||
7923 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
7924 | ||
7925 | if (p->change_local_as) | |
7926 | json_object_int_add(json_neigh, "localAs", | |
7927 | p->change_local_as); | |
7928 | else | |
7929 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
7930 | ||
7931 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
7932 | json_object_boolean_true_add(json_neigh, | |
7933 | "localAsNoPrepend"); | |
7934 | ||
7935 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
7936 | json_object_boolean_true_add(json_neigh, | |
7937 | "localAsReplaceAs"); | |
7938 | } else { | |
7939 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
7940 | || (p->as_type == AS_INTERNAL)) | |
7941 | vty_out(vty, "remote AS %u, ", p->as); | |
7942 | else | |
7943 | vty_out(vty, "remote AS Unspecified, "); | |
7944 | vty_out(vty, "local AS %u%s%s, ", | |
7945 | p->change_local_as ? p->change_local_as : p->local_as, | |
7946 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
7947 | ? " no-prepend" | |
7948 | : "", | |
7949 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
7950 | ? " replace-as" | |
7951 | : ""); | |
7952 | } | |
7953 | /* peer type internal, external, confed-internal or confed-external */ | |
7954 | if (p->as == p->local_as) { | |
7955 | if (use_json) { | |
7956 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7957 | json_object_boolean_true_add( | |
7958 | json_neigh, "nbrConfedInternalLink"); | |
7959 | else | |
7960 | json_object_boolean_true_add(json_neigh, | |
7961 | "nbrInternalLink"); | |
7962 | } else { | |
7963 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7964 | vty_out(vty, "confed-internal link\n"); | |
7965 | else | |
7966 | vty_out(vty, "internal link\n"); | |
7967 | } | |
7968 | } else { | |
7969 | if (use_json) { | |
7970 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7971 | json_object_boolean_true_add( | |
7972 | json_neigh, "nbrConfedExternalLink"); | |
7973 | else | |
7974 | json_object_boolean_true_add(json_neigh, | |
7975 | "nbrExternalLink"); | |
7976 | } else { | |
7977 | if (bgp_confederation_peers_check(bgp, p->as)) | |
7978 | vty_out(vty, "confed-external link\n"); | |
7979 | else | |
7980 | vty_out(vty, "external link\n"); | |
7981 | } | |
7982 | } | |
7983 | ||
7984 | /* Description. */ | |
7985 | if (p->desc) { | |
7986 | if (use_json) | |
7987 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
7988 | else | |
7989 | vty_out(vty, " Description: %s\n", p->desc); | |
7990 | } | |
7991 | ||
7992 | if (p->hostname) { | |
7993 | if (use_json) { | |
7994 | if (p->hostname) | |
7995 | json_object_string_add(json_neigh, "hostname", | |
7996 | p->hostname); | |
7997 | ||
7998 | if (p->domainname) | |
7999 | json_object_string_add(json_neigh, "domainname", | |
8000 | p->domainname); | |
8001 | } else { | |
8002 | if (p->domainname && (p->domainname[0] != '\0')) | |
8003 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
8004 | p->domainname); | |
8005 | else | |
8006 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
8007 | } | |
8008 | } | |
8009 | ||
8010 | /* Peer-group */ | |
8011 | if (p->group) { | |
8012 | if (use_json) { | |
8013 | json_object_string_add(json_neigh, "peerGroup", | |
8014 | p->group->name); | |
8015 | ||
8016 | if (dn_flag[0]) { | |
8017 | struct prefix prefix, *range = NULL; | |
8018 | ||
8019 | sockunion2hostprefix(&(p->su), &prefix); | |
8020 | range = peer_group_lookup_dynamic_neighbor_range( | |
8021 | p->group, &prefix); | |
8022 | ||
8023 | if (range) { | |
8024 | prefix2str(range, buf1, sizeof(buf1)); | |
8025 | json_object_string_add( | |
8026 | json_neigh, | |
8027 | "peerSubnetRangeGroup", buf1); | |
8028 | } | |
8029 | } | |
8030 | } else { | |
8031 | vty_out(vty, | |
8032 | " Member of peer-group %s for session parameters\n", | |
8033 | p->group->name); | |
8034 | ||
8035 | if (dn_flag[0]) { | |
8036 | struct prefix prefix, *range = NULL; | |
8037 | ||
8038 | sockunion2hostprefix(&(p->su), &prefix); | |
8039 | range = peer_group_lookup_dynamic_neighbor_range( | |
8040 | p->group, &prefix); | |
8041 | ||
8042 | if (range) { | |
8043 | prefix2str(range, buf1, sizeof(buf1)); | |
8044 | vty_out(vty, | |
8045 | " Belongs to the subnet range group: %s\n", | |
8046 | buf1); | |
8047 | } | |
8048 | } | |
8049 | } | |
8050 | } | |
8051 | ||
8052 | if (use_json) { | |
8053 | /* Administrative shutdown. */ | |
8054 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
8055 | json_object_boolean_true_add(json_neigh, | |
8056 | "adminShutDown"); | |
8057 | ||
8058 | /* BGP Version. */ | |
8059 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
8060 | json_object_string_add( | |
8061 | json_neigh, "remoteRouterId", | |
8062 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
8063 | ||
8064 | /* Confederation */ | |
8065 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
8066 | && bgp_confederation_peers_check(bgp, p->as)) | |
8067 | json_object_boolean_true_add(json_neigh, | |
8068 | "nbrCommonAdmin"); | |
8069 | ||
8070 | /* Status. */ | |
8071 | json_object_string_add( | |
8072 | json_neigh, "bgpState", | |
8073 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
8074 | ||
8075 | if (p->status == Established) { | |
8076 | time_t uptime; | |
8077 | struct tm *tm; | |
8078 | ||
8079 | uptime = bgp_clock(); | |
8080 | uptime -= p->uptime; | |
8081 | tm = gmtime(&uptime); | |
8082 | epoch_tbuf = time(NULL) - uptime; | |
8083 | ||
8084 | json_object_int_add(json_neigh, "bgpTimerUp", | |
8085 | (tm->tm_sec * 1000) | |
8086 | + (tm->tm_min * 60000) | |
8087 | + (tm->tm_hour * 3600000)); | |
8088 | json_object_string_add(json_neigh, "bgpTimerUpString", | |
8089 | peer_uptime(p->uptime, timebuf, | |
8090 | BGP_UPTIME_LEN, 0, | |
8091 | NULL)); | |
8092 | json_object_int_add(json_neigh, | |
8093 | "bgpTimerUpEstablishedEpoch", | |
8094 | epoch_tbuf); | |
8095 | } | |
8096 | ||
8097 | else if (p->status == Active) { | |
8098 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
8099 | json_object_string_add(json_neigh, "bgpStateIs", | |
8100 | "passive"); | |
8101 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
8102 | json_object_string_add(json_neigh, "bgpStateIs", | |
8103 | "passiveNSF"); | |
8104 | } | |
8105 | ||
8106 | /* read timer */ | |
8107 | time_t uptime; | |
8108 | struct tm *tm; | |
8109 | ||
8110 | uptime = bgp_clock(); | |
8111 | uptime -= p->readtime; | |
8112 | tm = gmtime(&uptime); | |
8113 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
8114 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
8115 | + (tm->tm_hour * 3600000)); | |
8116 | ||
8117 | uptime = bgp_clock(); | |
8118 | uptime -= p->last_write; | |
8119 | tm = gmtime(&uptime); | |
8120 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
8121 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
8122 | + (tm->tm_hour * 3600000)); | |
8123 | ||
8124 | uptime = bgp_clock(); | |
8125 | uptime -= p->update_time; | |
8126 | tm = gmtime(&uptime); | |
8127 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
8128 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
8129 | + (tm->tm_hour * 3600000)); | |
8130 | ||
8131 | /* Configured timer values. */ | |
8132 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
8133 | p->v_holdtime * 1000); | |
8134 | json_object_int_add(json_neigh, | |
8135 | "bgpTimerKeepAliveIntervalMsecs", | |
8136 | p->v_keepalive * 1000); | |
8137 | ||
8138 | if (CHECK_FLAG(p->config, PEER_CONFIG_TIMER)) { | |
8139 | json_object_int_add(json_neigh, | |
8140 | "bgpTimerConfiguredHoldTimeMsecs", | |
8141 | p->holdtime * 1000); | |
8142 | json_object_int_add( | |
8143 | json_neigh, | |
8144 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
8145 | p->keepalive * 1000); | |
8146 | } | |
8147 | } else { | |
8148 | /* Administrative shutdown. */ | |
8149 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
8150 | vty_out(vty, " Administratively shut down\n"); | |
8151 | ||
8152 | /* BGP Version. */ | |
8153 | vty_out(vty, " BGP version 4"); | |
8154 | vty_out(vty, ", remote router ID %s\n", | |
8155 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
8156 | ||
8157 | /* Confederation */ | |
8158 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
8159 | && bgp_confederation_peers_check(bgp, p->as)) | |
8160 | vty_out(vty, | |
8161 | " Neighbor under common administration\n"); | |
8162 | ||
8163 | /* Status. */ | |
8164 | vty_out(vty, " BGP state = %s", | |
8165 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
8166 | ||
8167 | if (p->status == Established) | |
8168 | vty_out(vty, ", up for %8s", | |
8169 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
8170 | 0, NULL)); | |
8171 | ||
8172 | else if (p->status == Active) { | |
8173 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
8174 | vty_out(vty, " (passive)"); | |
8175 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
8176 | vty_out(vty, " (NSF passive)"); | |
8177 | } | |
8178 | vty_out(vty, "\n"); | |
8179 | ||
8180 | /* read timer */ | |
8181 | vty_out(vty, " Last read %s", | |
8182 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
8183 | NULL)); | |
8184 | vty_out(vty, ", Last write %s\n", | |
8185 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
8186 | NULL)); | |
8187 | ||
8188 | /* Configured timer values. */ | |
8189 | vty_out(vty, | |
8190 | " Hold time is %d, keepalive interval is %d seconds\n", | |
8191 | p->v_holdtime, p->v_keepalive); | |
8192 | if (CHECK_FLAG(p->config, PEER_CONFIG_TIMER)) { | |
8193 | vty_out(vty, " Configured hold time is %d", | |
8194 | p->holdtime); | |
8195 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
8196 | p->keepalive); | |
8197 | } | |
8198 | } | |
8199 | /* Capability. */ | |
8200 | if (p->status == Established) { | |
8201 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
8202 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
8203 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
8204 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
8205 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
8206 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
8207 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
8208 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
8209 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
8210 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
8211 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
8212 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
8213 | || p->afc_adv[AFI_IP][SAFI_ENCAP] | |
8214 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
8215 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] | |
8216 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
8217 | if (use_json) { | |
8218 | json_object *json_cap = NULL; | |
8219 | ||
8220 | json_cap = json_object_new_object(); | |
8221 | ||
8222 | /* AS4 */ | |
8223 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
8224 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
8225 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
8226 | && CHECK_FLAG(p->cap, | |
8227 | PEER_CAP_AS4_RCV)) | |
8228 | json_object_string_add( | |
8229 | json_cap, "4byteAs", | |
8230 | "advertisedAndReceived"); | |
8231 | else if (CHECK_FLAG(p->cap, | |
8232 | PEER_CAP_AS4_ADV)) | |
8233 | json_object_string_add( | |
8234 | json_cap, "4byteAs", | |
8235 | "advertised"); | |
8236 | else if (CHECK_FLAG(p->cap, | |
8237 | PEER_CAP_AS4_RCV)) | |
8238 | json_object_string_add( | |
8239 | json_cap, "4byteAs", | |
8240 | "received"); | |
8241 | } | |
8242 | ||
8243 | /* AddPath */ | |
8244 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
8245 | || CHECK_FLAG(p->cap, | |
8246 | PEER_CAP_ADDPATH_ADV)) { | |
8247 | json_object *json_add = NULL; | |
8248 | const char *print_store; | |
8249 | ||
8250 | json_add = json_object_new_object(); | |
8251 | ||
8252 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
8253 | for (safi = SAFI_UNICAST; | |
8254 | safi < SAFI_MAX; safi++) { | |
8255 | json_object *json_sub = | |
8256 | NULL; | |
8257 | json_sub = | |
8258 | json_object_new_object(); | |
8259 | print_store = | |
8260 | afi_safi_print( | |
8261 | afi, | |
8262 | safi); | |
8263 | ||
8264 | if (CHECK_FLAG( | |
8265 | p->af_cap | |
8266 | [afi] | |
8267 | [safi], | |
8268 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8269 | || CHECK_FLAG( | |
8270 | p->af_cap | |
8271 | [afi] | |
8272 | [safi], | |
8273 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
8274 | if (CHECK_FLAG( | |
8275 | p->af_cap | |
8276 | [afi] | |
8277 | [safi], | |
8278 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8279 | && CHECK_FLAG( | |
8280 | p->af_cap | |
8281 | [afi] | |
8282 | [safi], | |
8283 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8284 | json_object_boolean_true_add( | |
8285 | json_sub, | |
8286 | "txAdvertisedAndReceived"); | |
8287 | else if ( | |
8288 | CHECK_FLAG( | |
8289 | p->af_cap | |
8290 | [afi] | |
8291 | [safi], | |
8292 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
8293 | json_object_boolean_true_add( | |
8294 | json_sub, | |
8295 | "txAdvertised"); | |
8296 | else if ( | |
8297 | CHECK_FLAG( | |
8298 | p->af_cap | |
8299 | [afi] | |
8300 | [safi], | |
8301 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8302 | json_object_boolean_true_add( | |
8303 | json_sub, | |
8304 | "txReceived"); | |
8305 | } | |
8306 | ||
8307 | if (CHECK_FLAG( | |
8308 | p->af_cap | |
8309 | [afi] | |
8310 | [safi], | |
8311 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8312 | || CHECK_FLAG( | |
8313 | p->af_cap | |
8314 | [afi] | |
8315 | [safi], | |
8316 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
8317 | if (CHECK_FLAG( | |
8318 | p->af_cap | |
8319 | [afi] | |
8320 | [safi], | |
8321 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8322 | && CHECK_FLAG( | |
8323 | p->af_cap | |
8324 | [afi] | |
8325 | [safi], | |
8326 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8327 | json_object_boolean_true_add( | |
8328 | json_sub, | |
8329 | "rxAdvertisedAndReceived"); | |
8330 | else if ( | |
8331 | CHECK_FLAG( | |
8332 | p->af_cap | |
8333 | [afi] | |
8334 | [safi], | |
8335 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
8336 | json_object_boolean_true_add( | |
8337 | json_sub, | |
8338 | "rxAdvertised"); | |
8339 | else if ( | |
8340 | CHECK_FLAG( | |
8341 | p->af_cap | |
8342 | [afi] | |
8343 | [safi], | |
8344 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8345 | json_object_boolean_true_add( | |
8346 | json_sub, | |
8347 | "rxReceived"); | |
8348 | } | |
8349 | ||
8350 | if (CHECK_FLAG( | |
8351 | p->af_cap | |
8352 | [afi] | |
8353 | [safi], | |
8354 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8355 | || CHECK_FLAG( | |
8356 | p->af_cap | |
8357 | [afi] | |
8358 | [safi], | |
8359 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
8360 | || CHECK_FLAG( | |
8361 | p->af_cap | |
8362 | [afi] | |
8363 | [safi], | |
8364 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8365 | || CHECK_FLAG( | |
8366 | p->af_cap | |
8367 | [afi] | |
8368 | [safi], | |
8369 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8370 | json_object_object_add( | |
8371 | json_add, | |
8372 | print_store, | |
8373 | json_sub); | |
8374 | else | |
8375 | json_object_free( | |
8376 | json_sub); | |
8377 | } | |
8378 | ||
8379 | json_object_object_add( | |
8380 | json_cap, "addPath", json_add); | |
8381 | } | |
8382 | ||
8383 | /* Dynamic */ | |
8384 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
8385 | || CHECK_FLAG(p->cap, | |
8386 | PEER_CAP_DYNAMIC_ADV)) { | |
8387 | if (CHECK_FLAG(p->cap, | |
8388 | PEER_CAP_DYNAMIC_ADV) | |
8389 | && CHECK_FLAG(p->cap, | |
8390 | PEER_CAP_DYNAMIC_RCV)) | |
8391 | json_object_string_add( | |
8392 | json_cap, "dynamic", | |
8393 | "advertisedAndReceived"); | |
8394 | else if (CHECK_FLAG( | |
8395 | p->cap, | |
8396 | PEER_CAP_DYNAMIC_ADV)) | |
8397 | json_object_string_add( | |
8398 | json_cap, "dynamic", | |
8399 | "advertised"); | |
8400 | else if (CHECK_FLAG( | |
8401 | p->cap, | |
8402 | PEER_CAP_DYNAMIC_RCV)) | |
8403 | json_object_string_add( | |
8404 | json_cap, "dynamic", | |
8405 | "received"); | |
8406 | } | |
8407 | ||
8408 | /* Extended nexthop */ | |
8409 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
8410 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
8411 | json_object *json_nxt = NULL; | |
8412 | const char *print_store; | |
8413 | ||
8414 | ||
8415 | if (CHECK_FLAG(p->cap, | |
8416 | PEER_CAP_ENHE_ADV) | |
8417 | && CHECK_FLAG(p->cap, | |
8418 | PEER_CAP_ENHE_RCV)) | |
8419 | json_object_string_add( | |
8420 | json_cap, | |
8421 | "extendedNexthop", | |
8422 | "advertisedAndReceived"); | |
8423 | else if (CHECK_FLAG(p->cap, | |
8424 | PEER_CAP_ENHE_ADV)) | |
8425 | json_object_string_add( | |
8426 | json_cap, | |
8427 | "extendedNexthop", | |
8428 | "advertised"); | |
8429 | else if (CHECK_FLAG(p->cap, | |
8430 | PEER_CAP_ENHE_RCV)) | |
8431 | json_object_string_add( | |
8432 | json_cap, | |
8433 | "extendedNexthop", | |
8434 | "received"); | |
8435 | ||
8436 | if (CHECK_FLAG(p->cap, | |
8437 | PEER_CAP_ENHE_RCV)) { | |
8438 | json_nxt = | |
8439 | json_object_new_object(); | |
8440 | ||
8441 | for (safi = SAFI_UNICAST; | |
8442 | safi < SAFI_MAX; safi++) { | |
8443 | if (CHECK_FLAG( | |
8444 | p->af_cap | |
8445 | [AFI_IP] | |
8446 | [safi], | |
8447 | PEER_CAP_ENHE_AF_RCV)) { | |
8448 | print_store = afi_safi_print( | |
8449 | AFI_IP, | |
8450 | safi); | |
8451 | json_object_string_add( | |
8452 | json_nxt, | |
8453 | print_store, | |
8454 | "recieved"); | |
8455 | } | |
8456 | } | |
8457 | json_object_object_add( | |
8458 | json_cap, | |
8459 | "extendedNexthopFamililesByPeer", | |
8460 | json_nxt); | |
8461 | } | |
8462 | } | |
8463 | ||
8464 | /* Route Refresh */ | |
8465 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
8466 | || CHECK_FLAG(p->cap, | |
8467 | PEER_CAP_REFRESH_NEW_RCV) | |
8468 | || CHECK_FLAG(p->cap, | |
8469 | PEER_CAP_REFRESH_OLD_RCV)) { | |
8470 | if (CHECK_FLAG(p->cap, | |
8471 | PEER_CAP_REFRESH_ADV) | |
8472 | && (CHECK_FLAG( | |
8473 | p->cap, | |
8474 | PEER_CAP_REFRESH_NEW_RCV) | |
8475 | || CHECK_FLAG( | |
8476 | p->cap, | |
8477 | PEER_CAP_REFRESH_OLD_RCV))) { | |
8478 | if (CHECK_FLAG( | |
8479 | p->cap, | |
8480 | PEER_CAP_REFRESH_OLD_RCV) | |
8481 | && CHECK_FLAG( | |
8482 | p->cap, | |
8483 | PEER_CAP_REFRESH_NEW_RCV)) | |
8484 | json_object_string_add( | |
8485 | json_cap, | |
8486 | "routeRefresh", | |
8487 | "advertisedAndReceivedOldNew"); | |
8488 | else { | |
8489 | if (CHECK_FLAG( | |
8490 | p->cap, | |
8491 | PEER_CAP_REFRESH_OLD_RCV)) | |
8492 | json_object_string_add( | |
8493 | json_cap, | |
8494 | "routeRefresh", | |
8495 | "advertisedAndReceivedOld"); | |
8496 | else | |
8497 | json_object_string_add( | |
8498 | json_cap, | |
8499 | "routeRefresh", | |
8500 | "advertisedAndReceivedNew"); | |
8501 | } | |
8502 | } else if ( | |
8503 | CHECK_FLAG( | |
8504 | p->cap, | |
8505 | PEER_CAP_REFRESH_ADV)) | |
8506 | json_object_string_add( | |
8507 | json_cap, | |
8508 | "routeRefresh", | |
8509 | "advertised"); | |
8510 | else if ( | |
8511 | CHECK_FLAG( | |
8512 | p->cap, | |
8513 | PEER_CAP_REFRESH_NEW_RCV) | |
8514 | || CHECK_FLAG( | |
8515 | p->cap, | |
8516 | PEER_CAP_REFRESH_OLD_RCV)) | |
8517 | json_object_string_add( | |
8518 | json_cap, | |
8519 | "routeRefresh", | |
8520 | "received"); | |
8521 | } | |
8522 | ||
8523 | /* Multiprotocol Extensions */ | |
8524 | json_object *json_multi = NULL; | |
8525 | json_multi = json_object_new_object(); | |
8526 | ||
8527 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
8528 | for (safi = SAFI_UNICAST; | |
8529 | safi < SAFI_MAX; safi++) { | |
8530 | if (p->afc_adv[afi][safi] | |
8531 | || p->afc_recv[afi][safi]) { | |
8532 | json_object | |
8533 | *json_exten = | |
8534 | NULL; | |
8535 | json_exten = | |
8536 | json_object_new_object(); | |
8537 | ||
8538 | if (p->afc_adv[afi] | |
8539 | [safi] | |
8540 | && p->afc_recv | |
8541 | [afi] | |
8542 | [safi]) | |
8543 | json_object_boolean_true_add( | |
8544 | json_exten, | |
8545 | "advertisedAndReceived"); | |
8546 | else if (p->afc_adv | |
8547 | [afi] | |
8548 | [safi]) | |
8549 | json_object_boolean_true_add( | |
8550 | json_exten, | |
8551 | "advertised"); | |
8552 | else if (p->afc_recv | |
8553 | [afi] | |
8554 | [safi]) | |
8555 | json_object_boolean_true_add( | |
8556 | json_exten, | |
8557 | "received"); | |
8558 | ||
8559 | json_object_object_add( | |
8560 | json_multi, | |
8561 | afi_safi_print( | |
8562 | afi, | |
8563 | safi), | |
8564 | json_exten); | |
8565 | } | |
8566 | } | |
8567 | } | |
8568 | json_object_object_add( | |
8569 | json_cap, "multiprotocolExtensions", | |
8570 | json_multi); | |
8571 | ||
8572 | /* Gracefull Restart */ | |
8573 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
8574 | || CHECK_FLAG(p->cap, | |
8575 | PEER_CAP_RESTART_ADV)) { | |
8576 | if (CHECK_FLAG(p->cap, | |
8577 | PEER_CAP_RESTART_ADV) | |
8578 | && CHECK_FLAG(p->cap, | |
8579 | PEER_CAP_RESTART_RCV)) | |
8580 | json_object_string_add( | |
8581 | json_cap, | |
8582 | "gracefulRestart", | |
8583 | "advertisedAndReceived"); | |
8584 | else if (CHECK_FLAG( | |
8585 | p->cap, | |
8586 | PEER_CAP_RESTART_ADV)) | |
8587 | json_object_string_add( | |
8588 | json_cap, | |
8589 | "gracefulRestartCapability", | |
8590 | "advertised"); | |
8591 | else if (CHECK_FLAG( | |
8592 | p->cap, | |
8593 | PEER_CAP_RESTART_RCV)) | |
8594 | json_object_string_add( | |
8595 | json_cap, | |
8596 | "gracefulRestartCapability", | |
8597 | "received"); | |
8598 | ||
8599 | if (CHECK_FLAG(p->cap, | |
8600 | PEER_CAP_RESTART_RCV)) { | |
8601 | int restart_af_count = 0; | |
8602 | json_object *json_restart = | |
8603 | NULL; | |
8604 | json_restart = | |
8605 | json_object_new_object(); | |
8606 | ||
8607 | json_object_int_add( | |
8608 | json_cap, | |
8609 | "gracefulRestartRemoteTimerMsecs", | |
8610 | p->v_gr_restart * 1000); | |
8611 | ||
8612 | for (afi = AFI_IP; | |
8613 | afi < AFI_MAX; afi++) { | |
8614 | for (safi = SAFI_UNICAST; | |
8615 | safi < SAFI_MAX; | |
8616 | safi++) { | |
8617 | if (CHECK_FLAG( | |
8618 | p->af_cap | |
8619 | [afi] | |
8620 | [safi], | |
8621 | PEER_CAP_RESTART_AF_RCV)) { | |
8622 | json_object *json_sub = | |
8623 | NULL; | |
8624 | json_sub = | |
8625 | json_object_new_object(); | |
8626 | ||
8627 | if (CHECK_FLAG( | |
8628 | p->af_cap | |
8629 | [afi] | |
8630 | [safi], | |
8631 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) | |
8632 | json_object_boolean_true_add( | |
8633 | json_sub, | |
8634 | "preserved"); | |
8635 | restart_af_count++; | |
8636 | json_object_object_add( | |
8637 | json_restart, | |
8638 | afi_safi_print( | |
8639 | afi, | |
8640 | safi), | |
8641 | json_sub); | |
8642 | } | |
8643 | } | |
8644 | } | |
8645 | if (!restart_af_count) { | |
8646 | json_object_string_add( | |
8647 | json_cap, | |
8648 | "addressFamiliesByPeer", | |
8649 | "none"); | |
8650 | json_object_free( | |
8651 | json_restart); | |
8652 | } else | |
8653 | json_object_object_add( | |
8654 | json_cap, | |
8655 | "addressFamiliesByPeer", | |
8656 | json_restart); | |
8657 | } | |
8658 | } | |
8659 | json_object_object_add(json_neigh, | |
8660 | "neighborCapabilities", | |
8661 | json_cap); | |
8662 | } else { | |
8663 | vty_out(vty, " Neighbor capabilities:\n"); | |
8664 | ||
8665 | /* AS4 */ | |
8666 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
8667 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
8668 | vty_out(vty, " 4 Byte AS:"); | |
8669 | if (CHECK_FLAG(p->cap, | |
8670 | PEER_CAP_AS4_ADV)) | |
8671 | vty_out(vty, " advertised"); | |
8672 | if (CHECK_FLAG(p->cap, | |
8673 | PEER_CAP_AS4_RCV)) | |
8674 | vty_out(vty, " %sreceived", | |
8675 | CHECK_FLAG( | |
8676 | p->cap, | |
8677 | PEER_CAP_AS4_ADV) | |
8678 | ? "and " | |
8679 | : ""); | |
8680 | vty_out(vty, "\n"); | |
8681 | } | |
8682 | ||
8683 | /* AddPath */ | |
8684 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
8685 | || CHECK_FLAG(p->cap, | |
8686 | PEER_CAP_ADDPATH_ADV)) { | |
8687 | vty_out(vty, " AddPath:\n"); | |
8688 | ||
8689 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
8690 | for (safi = SAFI_UNICAST; | |
8691 | safi < SAFI_MAX; safi++) { | |
8692 | if (CHECK_FLAG( | |
8693 | p->af_cap | |
8694 | [afi] | |
8695 | [safi], | |
8696 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8697 | || CHECK_FLAG( | |
8698 | p->af_cap | |
8699 | [afi] | |
8700 | [safi], | |
8701 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
8702 | vty_out(vty, | |
8703 | " %s: TX ", | |
8704 | afi_safi_print( | |
8705 | afi, | |
8706 | safi)); | |
8707 | ||
8708 | if (CHECK_FLAG( | |
8709 | p->af_cap | |
8710 | [afi] | |
8711 | [safi], | |
8712 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
8713 | vty_out(vty, | |
8714 | "advertised %s", | |
8715 | afi_safi_print( | |
8716 | afi, | |
8717 | safi)); | |
8718 | ||
8719 | if (CHECK_FLAG( | |
8720 | p->af_cap | |
8721 | [afi] | |
8722 | [safi], | |
8723 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8724 | vty_out(vty, | |
8725 | "%sreceived", | |
8726 | CHECK_FLAG( | |
8727 | p->af_cap | |
8728 | [afi] | |
8729 | [safi], | |
8730 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8731 | ? " and " | |
8732 | : ""); | |
8733 | ||
8734 | vty_out(vty, | |
8735 | "\n"); | |
8736 | } | |
8737 | ||
8738 | if (CHECK_FLAG( | |
8739 | p->af_cap | |
8740 | [afi] | |
8741 | [safi], | |
8742 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8743 | || CHECK_FLAG( | |
8744 | p->af_cap | |
8745 | [afi] | |
8746 | [safi], | |
8747 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
8748 | vty_out(vty, | |
8749 | " %s: RX ", | |
8750 | afi_safi_print( | |
8751 | afi, | |
8752 | safi)); | |
8753 | ||
8754 | if (CHECK_FLAG( | |
8755 | p->af_cap | |
8756 | [afi] | |
8757 | [safi], | |
8758 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
8759 | vty_out(vty, | |
8760 | "advertised %s", | |
8761 | afi_safi_print( | |
8762 | afi, | |
8763 | safi)); | |
8764 | ||
8765 | if (CHECK_FLAG( | |
8766 | p->af_cap | |
8767 | [afi] | |
8768 | [safi], | |
8769 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8770 | vty_out(vty, | |
8771 | "%sreceived", | |
8772 | CHECK_FLAG( | |
8773 | p->af_cap | |
8774 | [afi] | |
8775 | [safi], | |
8776 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8777 | ? " and " | |
8778 | : ""); | |
8779 | ||
8780 | vty_out(vty, | |
8781 | "\n"); | |
8782 | } | |
8783 | } | |
8784 | } | |
8785 | ||
8786 | /* Dynamic */ | |
8787 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
8788 | || CHECK_FLAG(p->cap, | |
8789 | PEER_CAP_DYNAMIC_ADV)) { | |
8790 | vty_out(vty, " Dynamic:"); | |
8791 | if (CHECK_FLAG(p->cap, | |
8792 | PEER_CAP_DYNAMIC_ADV)) | |
8793 | vty_out(vty, " advertised"); | |
8794 | if (CHECK_FLAG(p->cap, | |
8795 | PEER_CAP_DYNAMIC_RCV)) | |
8796 | vty_out(vty, " %sreceived", | |
8797 | CHECK_FLAG( | |
8798 | p->cap, | |
8799 | PEER_CAP_DYNAMIC_ADV) | |
8800 | ? "and " | |
8801 | : ""); | |
8802 | vty_out(vty, "\n"); | |
8803 | } | |
8804 | ||
8805 | /* Extended nexthop */ | |
8806 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
8807 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
8808 | vty_out(vty, " Extended nexthop:"); | |
8809 | if (CHECK_FLAG(p->cap, | |
8810 | PEER_CAP_ENHE_ADV)) | |
8811 | vty_out(vty, " advertised"); | |
8812 | if (CHECK_FLAG(p->cap, | |
8813 | PEER_CAP_ENHE_RCV)) | |
8814 | vty_out(vty, " %sreceived", | |
8815 | CHECK_FLAG( | |
8816 | p->cap, | |
8817 | PEER_CAP_ENHE_ADV) | |
8818 | ? "and " | |
8819 | : ""); | |
8820 | vty_out(vty, "\n"); | |
8821 | ||
8822 | if (CHECK_FLAG(p->cap, | |
8823 | PEER_CAP_ENHE_RCV)) { | |
8824 | vty_out(vty, | |
8825 | " Address families by peer:\n "); | |
8826 | for (safi = SAFI_UNICAST; | |
8827 | safi < SAFI_MAX; safi++) | |
8828 | if (CHECK_FLAG( | |
8829 | p->af_cap | |
8830 | [AFI_IP] | |
8831 | [safi], | |
8832 | PEER_CAP_ENHE_AF_RCV)) | |
8833 | vty_out(vty, | |
8834 | " %s\n", | |
8835 | afi_safi_print( | |
8836 | AFI_IP, | |
8837 | safi)); | |
8838 | } | |
8839 | } | |
8840 | ||
8841 | /* Route Refresh */ | |
8842 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
8843 | || CHECK_FLAG(p->cap, | |
8844 | PEER_CAP_REFRESH_NEW_RCV) | |
8845 | || CHECK_FLAG(p->cap, | |
8846 | PEER_CAP_REFRESH_OLD_RCV)) { | |
8847 | vty_out(vty, " Route refresh:"); | |
8848 | if (CHECK_FLAG(p->cap, | |
8849 | PEER_CAP_REFRESH_ADV)) | |
8850 | vty_out(vty, " advertised"); | |
8851 | if (CHECK_FLAG(p->cap, | |
8852 | PEER_CAP_REFRESH_NEW_RCV) | |
8853 | || CHECK_FLAG( | |
8854 | p->cap, | |
8855 | PEER_CAP_REFRESH_OLD_RCV)) | |
8856 | vty_out(vty, " %sreceived(%s)", | |
8857 | CHECK_FLAG( | |
8858 | p->cap, | |
8859 | PEER_CAP_REFRESH_ADV) | |
8860 | ? "and " | |
8861 | : "", | |
8862 | (CHECK_FLAG( | |
8863 | p->cap, | |
8864 | PEER_CAP_REFRESH_OLD_RCV) | |
8865 | && CHECK_FLAG( | |
8866 | p->cap, | |
8867 | PEER_CAP_REFRESH_NEW_RCV)) | |
8868 | ? "old & new" | |
8869 | : CHECK_FLAG( | |
8870 | p->cap, | |
8871 | PEER_CAP_REFRESH_OLD_RCV) | |
8872 | ? "old" | |
8873 | : "new"); | |
8874 | ||
8875 | vty_out(vty, "\n"); | |
8876 | } | |
8877 | ||
8878 | /* Multiprotocol Extensions */ | |
8879 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
8880 | for (safi = SAFI_UNICAST; | |
8881 | safi < SAFI_MAX; safi++) | |
8882 | if (p->afc_adv[afi][safi] | |
8883 | || p->afc_recv[afi][safi]) { | |
8884 | vty_out(vty, | |
8885 | " Address Family %s:", | |
8886 | afi_safi_print( | |
8887 | afi, | |
8888 | safi)); | |
8889 | if (p->afc_adv[afi] | |
8890 | [safi]) | |
8891 | vty_out(vty, | |
8892 | " advertised"); | |
8893 | if (p->afc_recv[afi] | |
8894 | [safi]) | |
8895 | vty_out(vty, | |
8896 | " %sreceived", | |
8897 | p->afc_adv[afi] | |
8898 | [safi] | |
8899 | ? "and " | |
8900 | : ""); | |
8901 | vty_out(vty, "\n"); | |
8902 | } | |
8903 | ||
8904 | /* Hostname capability */ | |
8905 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV) | |
8906 | || CHECK_FLAG(p->cap, | |
8907 | PEER_CAP_HOSTNAME_RCV)) { | |
8908 | vty_out(vty, | |
8909 | " Hostname Capability:"); | |
8910 | if (CHECK_FLAG(p->cap, | |
8911 | PEER_CAP_HOSTNAME_ADV)) | |
8912 | vty_out(vty, " advertised"); | |
8913 | if (CHECK_FLAG(p->cap, | |
8914 | PEER_CAP_HOSTNAME_RCV)) | |
8915 | vty_out(vty, " %sreceived", | |
8916 | CHECK_FLAG( | |
8917 | p->cap, | |
8918 | PEER_CAP_HOSTNAME_ADV) | |
8919 | ? "and " | |
8920 | : ""); | |
8921 | vty_out(vty, "\n"); | |
8922 | } | |
8923 | ||
8924 | /* Gracefull Restart */ | |
8925 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
8926 | || CHECK_FLAG(p->cap, | |
8927 | PEER_CAP_RESTART_ADV)) { | |
8928 | vty_out(vty, | |
8929 | " Graceful Restart Capabilty:"); | |
8930 | if (CHECK_FLAG(p->cap, | |
8931 | PEER_CAP_RESTART_ADV)) | |
8932 | vty_out(vty, " advertised"); | |
8933 | if (CHECK_FLAG(p->cap, | |
8934 | PEER_CAP_RESTART_RCV)) | |
8935 | vty_out(vty, " %sreceived", | |
8936 | CHECK_FLAG( | |
8937 | p->cap, | |
8938 | PEER_CAP_RESTART_ADV) | |
8939 | ? "and " | |
8940 | : ""); | |
8941 | vty_out(vty, "\n"); | |
8942 | ||
8943 | if (CHECK_FLAG(p->cap, | |
8944 | PEER_CAP_RESTART_RCV)) { | |
8945 | int restart_af_count = 0; | |
8946 | ||
8947 | vty_out(vty, | |
8948 | " Remote Restart timer is %d seconds\n", | |
8949 | p->v_gr_restart); | |
8950 | vty_out(vty, | |
8951 | " Address families by peer:\n "); | |
8952 | ||
8953 | for (afi = AFI_IP; | |
8954 | afi < AFI_MAX; afi++) | |
8955 | for (safi = SAFI_UNICAST; | |
8956 | safi < SAFI_MAX; | |
8957 | safi++) | |
8958 | if (CHECK_FLAG( | |
8959 | p->af_cap | |
8960 | [afi] | |
8961 | [safi], | |
8962 | PEER_CAP_RESTART_AF_RCV)) { | |
8963 | vty_out(vty, | |
8964 | "%s%s(%s)", | |
8965 | restart_af_count | |
8966 | ? ", " | |
8967 | : "", | |
8968 | afi_safi_print( | |
8969 | afi, | |
8970 | safi), | |
8971 | CHECK_FLAG( | |
8972 | p->af_cap | |
8973 | [afi] | |
8974 | [safi], | |
8975 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
8976 | ? "preserved" | |
8977 | : "not preserved"); | |
8978 | restart_af_count++; | |
8979 | } | |
8980 | if (!restart_af_count) | |
8981 | vty_out(vty, "none"); | |
8982 | vty_out(vty, "\n"); | |
8983 | } | |
8984 | } | |
8985 | } | |
8986 | } | |
8987 | } | |
8988 | ||
8989 | /* graceful restart information */ | |
8990 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || p->t_gr_restart | |
8991 | || p->t_gr_stale) { | |
8992 | json_object *json_grace = NULL; | |
8993 | json_object *json_grace_send = NULL; | |
8994 | json_object *json_grace_recv = NULL; | |
8995 | int eor_send_af_count = 0; | |
8996 | int eor_receive_af_count = 0; | |
8997 | ||
8998 | if (use_json) { | |
8999 | json_grace = json_object_new_object(); | |
9000 | json_grace_send = json_object_new_object(); | |
9001 | json_grace_recv = json_object_new_object(); | |
9002 | ||
9003 | if (p->status == Established) { | |
9004 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9005 | for (safi = SAFI_UNICAST; | |
9006 | safi < SAFI_MAX; safi++) { | |
9007 | if (CHECK_FLAG( | |
9008 | p->af_sflags[afi] | |
9009 | [safi], | |
9010 | PEER_STATUS_EOR_SEND)) { | |
9011 | json_object_boolean_true_add( | |
9012 | json_grace_send, | |
9013 | afi_safi_print( | |
9014 | afi, | |
9015 | safi)); | |
9016 | eor_send_af_count++; | |
9017 | } | |
9018 | } | |
9019 | } | |
9020 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9021 | for (safi = SAFI_UNICAST; | |
9022 | safi < SAFI_MAX; safi++) { | |
9023 | if (CHECK_FLAG( | |
9024 | p->af_sflags[afi] | |
9025 | [safi], | |
9026 | PEER_STATUS_EOR_RECEIVED)) { | |
9027 | json_object_boolean_true_add( | |
9028 | json_grace_recv, | |
9029 | afi_safi_print( | |
9030 | afi, | |
9031 | safi)); | |
9032 | eor_receive_af_count++; | |
9033 | } | |
9034 | } | |
9035 | } | |
9036 | } | |
9037 | ||
9038 | json_object_object_add(json_grace, "endOfRibSend", | |
9039 | json_grace_send); | |
9040 | json_object_object_add(json_grace, "endOfRibRecv", | |
9041 | json_grace_recv); | |
9042 | ||
9043 | if (p->t_gr_restart) | |
9044 | json_object_int_add(json_grace, | |
9045 | "gracefulRestartTimerMsecs", | |
9046 | thread_timer_remain_second( | |
9047 | p->t_gr_restart) | |
9048 | * 1000); | |
9049 | ||
9050 | if (p->t_gr_stale) | |
9051 | json_object_int_add( | |
9052 | json_grace, | |
9053 | "gracefulStalepathTimerMsecs", | |
9054 | thread_timer_remain_second( | |
9055 | p->t_gr_stale) | |
9056 | * 1000); | |
9057 | ||
9058 | json_object_object_add( | |
9059 | json_neigh, "gracefulRestartInfo", json_grace); | |
9060 | } else { | |
9061 | vty_out(vty, " Graceful restart informations:\n"); | |
9062 | if (p->status == Established) { | |
9063 | vty_out(vty, " End-of-RIB send: "); | |
9064 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9065 | for (safi = SAFI_UNICAST; | |
9066 | safi < SAFI_MAX; safi++) { | |
9067 | if (CHECK_FLAG( | |
9068 | p->af_sflags[afi] | |
9069 | [safi], | |
9070 | PEER_STATUS_EOR_SEND)) { | |
9071 | vty_out(vty, "%s%s", | |
9072 | eor_send_af_count | |
9073 | ? ", " | |
9074 | : "", | |
9075 | afi_safi_print( | |
9076 | afi, | |
9077 | safi)); | |
9078 | eor_send_af_count++; | |
9079 | } | |
9080 | } | |
9081 | } | |
9082 | vty_out(vty, "\n"); | |
9083 | vty_out(vty, " End-of-RIB received: "); | |
9084 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9085 | for (safi = SAFI_UNICAST; | |
9086 | safi < SAFI_MAX; safi++) { | |
9087 | if (CHECK_FLAG( | |
9088 | p->af_sflags[afi] | |
9089 | [safi], | |
9090 | PEER_STATUS_EOR_RECEIVED)) { | |
9091 | vty_out(vty, "%s%s", | |
9092 | eor_receive_af_count | |
9093 | ? ", " | |
9094 | : "", | |
9095 | afi_safi_print( | |
9096 | afi, | |
9097 | safi)); | |
9098 | eor_receive_af_count++; | |
9099 | } | |
9100 | } | |
9101 | } | |
9102 | vty_out(vty, "\n"); | |
9103 | } | |
9104 | ||
9105 | if (p->t_gr_restart) | |
9106 | vty_out(vty, | |
9107 | " The remaining time of restart timer is %ld\n", | |
9108 | thread_timer_remain_second( | |
9109 | p->t_gr_restart)); | |
9110 | ||
9111 | if (p->t_gr_stale) | |
9112 | vty_out(vty, | |
9113 | " The remaining time of stalepath timer is %ld\n", | |
9114 | thread_timer_remain_second( | |
9115 | p->t_gr_stale)); | |
9116 | } | |
9117 | } | |
9118 | if (use_json) { | |
9119 | json_object *json_stat = NULL; | |
9120 | json_stat = json_object_new_object(); | |
9121 | /* Packet counts. */ | |
9122 | json_object_int_add(json_stat, "depthInq", 0); | |
9123 | json_object_int_add(json_stat, "depthOutq", | |
9124 | (unsigned long)p->obuf->count); | |
9125 | json_object_int_add(json_stat, "opensSent", p->open_out); | |
9126 | json_object_int_add(json_stat, "opensRecv", p->open_in); | |
9127 | json_object_int_add(json_stat, "notificationsSent", | |
9128 | p->notify_out); | |
9129 | json_object_int_add(json_stat, "notificationsRecv", | |
9130 | p->notify_in); | |
9131 | json_object_int_add(json_stat, "updatesSent", p->update_out); | |
9132 | json_object_int_add(json_stat, "updatesRecv", p->update_in); | |
9133 | json_object_int_add(json_stat, "keepalivesSent", | |
9134 | p->keepalive_out); | |
9135 | json_object_int_add(json_stat, "keepalivesRecv", | |
9136 | p->keepalive_in); | |
9137 | json_object_int_add(json_stat, "routeRefreshSent", | |
9138 | p->refresh_out); | |
9139 | json_object_int_add(json_stat, "routeRefreshRecv", | |
9140 | p->refresh_in); | |
9141 | json_object_int_add(json_stat, "capabilitySent", | |
9142 | p->dynamic_cap_out); | |
9143 | json_object_int_add(json_stat, "capabilityRecv", | |
9144 | p->dynamic_cap_in); | |
9145 | json_object_int_add(json_stat, "totalSent", | |
9146 | p->open_out + p->notify_out + p->update_out | |
9147 | + p->keepalive_out + p->refresh_out | |
9148 | + p->dynamic_cap_out); | |
9149 | json_object_int_add(json_stat, "totalRecv", | |
9150 | p->open_in + p->notify_in + p->update_in | |
9151 | + p->keepalive_in + p->refresh_in | |
9152 | + p->dynamic_cap_in); | |
9153 | json_object_object_add(json_neigh, "messageStats", json_stat); | |
9154 | } else { | |
9155 | /* Packet counts. */ | |
9156 | vty_out(vty, " Message statistics:\n"); | |
9157 | vty_out(vty, " Inq depth is 0\n"); | |
9158 | vty_out(vty, " Outq depth is %lu\n", | |
9159 | (unsigned long)p->obuf->count); | |
9160 | vty_out(vty, " Sent Rcvd\n"); | |
9161 | vty_out(vty, " Opens: %10d %10d\n", p->open_out, | |
9162 | p->open_in); | |
9163 | vty_out(vty, " Notifications: %10d %10d\n", p->notify_out, | |
9164 | p->notify_in); | |
9165 | vty_out(vty, " Updates: %10d %10d\n", p->update_out, | |
9166 | p->update_in); | |
9167 | vty_out(vty, " Keepalives: %10d %10d\n", p->keepalive_out, | |
9168 | p->keepalive_in); | |
9169 | vty_out(vty, " Route Refresh: %10d %10d\n", p->refresh_out, | |
9170 | p->refresh_in); | |
9171 | vty_out(vty, " Capability: %10d %10d\n", | |
9172 | p->dynamic_cap_out, p->dynamic_cap_in); | |
9173 | vty_out(vty, " Total: %10d %10d\n", | |
9174 | p->open_out + p->notify_out + p->update_out | |
9175 | + p->keepalive_out + p->refresh_out | |
9176 | + p->dynamic_cap_out, | |
9177 | p->open_in + p->notify_in + p->update_in | |
9178 | + p->keepalive_in + p->refresh_in | |
9179 | + p->dynamic_cap_in); | |
9180 | } | |
9181 | ||
9182 | if (use_json) { | |
9183 | /* advertisement-interval */ | |
9184 | json_object_int_add(json_neigh, | |
9185 | "minBtwnAdvertisementRunsTimerMsecs", | |
9186 | p->v_routeadv * 1000); | |
9187 | ||
9188 | /* Update-source. */ | |
9189 | if (p->update_if || p->update_source) { | |
9190 | if (p->update_if) | |
9191 | json_object_string_add(json_neigh, | |
9192 | "updateSource", | |
9193 | p->update_if); | |
9194 | else if (p->update_source) | |
9195 | json_object_string_add( | |
9196 | json_neigh, "updateSource", | |
9197 | sockunion2str(p->update_source, buf1, | |
9198 | SU_ADDRSTRLEN)); | |
9199 | } | |
9200 | } else { | |
9201 | /* advertisement-interval */ | |
9202 | vty_out(vty, | |
9203 | " Minimum time between advertisement runs is %d seconds\n", | |
9204 | p->v_routeadv); | |
9205 | ||
9206 | /* Update-source. */ | |
9207 | if (p->update_if || p->update_source) { | |
9208 | vty_out(vty, " Update source is "); | |
9209 | if (p->update_if) | |
9210 | vty_out(vty, "%s", p->update_if); | |
9211 | else if (p->update_source) | |
9212 | vty_out(vty, "%s", | |
9213 | sockunion2str(p->update_source, buf1, | |
9214 | SU_ADDRSTRLEN)); | |
9215 | vty_out(vty, "\n"); | |
9216 | } | |
9217 | ||
9218 | vty_out(vty, "\n"); | |
9219 | } | |
9220 | ||
9221 | /* Address Family Information */ | |
9222 | json_object *json_hold = NULL; | |
9223 | ||
9224 | if (use_json) | |
9225 | json_hold = json_object_new_object(); | |
9226 | ||
9227 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9228 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
9229 | if (p->afc[afi][safi]) | |
9230 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
9231 | json_hold); | |
9232 | ||
9233 | if (use_json) { | |
9234 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
9235 | json_hold); | |
9236 | json_object_int_add(json_neigh, "connectionsEstablished", | |
9237 | p->established); | |
9238 | json_object_int_add(json_neigh, "connectionsDropped", | |
9239 | p->dropped); | |
9240 | } else | |
9241 | vty_out(vty, " Connections established %d; dropped %d\n", | |
9242 | p->established, p->dropped); | |
9243 | ||
9244 | if (!p->last_reset) { | |
9245 | if (use_json) | |
9246 | json_object_string_add(json_neigh, "lastReset", | |
9247 | "never"); | |
9248 | else | |
9249 | vty_out(vty, " Last reset never\n"); | |
9250 | } else { | |
9251 | if (use_json) { | |
9252 | time_t uptime; | |
9253 | struct tm *tm; | |
9254 | ||
9255 | uptime = bgp_clock(); | |
9256 | uptime -= p->resettime; | |
9257 | tm = gmtime(&uptime); | |
9258 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
9259 | (tm->tm_sec * 1000) | |
9260 | + (tm->tm_min * 60000) | |
9261 | + (tm->tm_hour * 3600000)); | |
9262 | json_object_string_add( | |
9263 | json_neigh, "lastResetDueTo", | |
9264 | peer_down_str[(int)p->last_reset]); | |
9265 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
9266 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
9267 | char errorcodesubcode_hexstr[5]; | |
9268 | char errorcodesubcode_str[256]; | |
9269 | ||
9270 | code_str = bgp_notify_code_str(p->notify.code); | |
9271 | subcode_str = bgp_notify_subcode_str( | |
9272 | p->notify.code, p->notify.subcode); | |
9273 | ||
9274 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
9275 | p->notify.code, p->notify.subcode); | |
9276 | json_object_string_add(json_neigh, | |
9277 | "lastErrorCodeSubcode", | |
9278 | errorcodesubcode_hexstr); | |
9279 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
9280 | code_str, subcode_str); | |
9281 | json_object_string_add(json_neigh, | |
9282 | "lastNotificationReason", | |
9283 | errorcodesubcode_str); | |
9284 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
9285 | && p->notify.code == BGP_NOTIFY_CEASE | |
9286 | && (p->notify.subcode | |
9287 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
9288 | || p->notify.subcode | |
9289 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
9290 | && p->notify.length) { | |
9291 | char msgbuf[1024]; | |
9292 | const char *msg_str; | |
9293 | ||
9294 | msg_str = bgp_notify_admin_message( | |
9295 | msgbuf, sizeof(msgbuf), | |
9296 | (u_char *)p->notify.data, | |
9297 | p->notify.length); | |
9298 | if (msg_str) | |
9299 | json_object_string_add( | |
9300 | json_neigh, | |
9301 | "lastShutdownDescription", | |
9302 | msg_str); | |
9303 | } | |
9304 | } | |
9305 | } else { | |
9306 | vty_out(vty, " Last reset %s, ", | |
9307 | peer_uptime(p->resettime, timebuf, | |
9308 | BGP_UPTIME_LEN, 0, NULL)); | |
9309 | ||
9310 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
9311 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
9312 | code_str = bgp_notify_code_str(p->notify.code); | |
9313 | subcode_str = bgp_notify_subcode_str( | |
9314 | p->notify.code, p->notify.subcode); | |
9315 | vty_out(vty, "due to NOTIFICATION %s (%s%s)\n", | |
9316 | p->last_reset == PEER_DOWN_NOTIFY_SEND | |
9317 | ? "sent" | |
9318 | : "received", | |
9319 | code_str, subcode_str); | |
9320 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
9321 | && p->notify.code == BGP_NOTIFY_CEASE | |
9322 | && (p->notify.subcode | |
9323 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
9324 | || p->notify.subcode | |
9325 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
9326 | && p->notify.length) { | |
9327 | char msgbuf[1024]; | |
9328 | const char *msg_str; | |
9329 | ||
9330 | msg_str = bgp_notify_admin_message( | |
9331 | msgbuf, sizeof(msgbuf), | |
9332 | (u_char *)p->notify.data, | |
9333 | p->notify.length); | |
9334 | if (msg_str) | |
9335 | vty_out(vty, | |
9336 | " Message: \"%s\"\n", | |
9337 | msg_str); | |
9338 | } | |
9339 | } else { | |
9340 | vty_out(vty, "due to %s\n", | |
9341 | peer_down_str[(int)p->last_reset]); | |
9342 | } | |
9343 | ||
9344 | if (p->last_reset_cause_size) { | |
9345 | msg = p->last_reset_cause; | |
9346 | vty_out(vty, | |
9347 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
9348 | for (i = 1; i <= p->last_reset_cause_size; | |
9349 | i++) { | |
9350 | vty_out(vty, "%02X", *msg++); | |
9351 | ||
9352 | if (i != p->last_reset_cause_size) { | |
9353 | if (i % 16 == 0) { | |
9354 | vty_out(vty, "\n "); | |
9355 | } else if (i % 4 == 0) { | |
9356 | vty_out(vty, " "); | |
9357 | } | |
9358 | } | |
9359 | } | |
9360 | vty_out(vty, "\n"); | |
9361 | } | |
9362 | } | |
9363 | } | |
9364 | ||
9365 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
9366 | if (use_json) | |
9367 | json_object_boolean_true_add(json_neigh, | |
9368 | "prefixesConfigExceedMax"); | |
9369 | else | |
9370 | vty_out(vty, | |
9371 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
9372 | ||
9373 | if (p->t_pmax_restart) { | |
9374 | if (use_json) { | |
9375 | json_object_boolean_true_add( | |
9376 | json_neigh, "reducePrefixNumFrom"); | |
9377 | json_object_int_add(json_neigh, | |
9378 | "restartInTimerMsec", | |
9379 | thread_timer_remain_second( | |
9380 | p->t_pmax_restart) | |
9381 | * 1000); | |
9382 | } else | |
9383 | vty_out(vty, | |
9384 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
9d303b37 DL |
9385 | p->host, thread_timer_remain_second( |
9386 | p->t_pmax_restart)); | |
d62a17ae | 9387 | } else { |
9388 | if (use_json) | |
9389 | json_object_boolean_true_add( | |
9390 | json_neigh, | |
9391 | "reducePrefixNumAndClearIpBgp"); | |
9392 | else | |
9393 | vty_out(vty, | |
9394 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
9395 | p->host); | |
9396 | } | |
9397 | } | |
9398 | ||
9399 | /* EBGP Multihop and GTSM */ | |
9400 | if (p->sort != BGP_PEER_IBGP) { | |
9401 | if (use_json) { | |
9402 | if (p->gtsm_hops > 0) | |
9403 | json_object_int_add(json_neigh, | |
9404 | "externalBgpNbrMaxHopsAway", | |
9405 | p->gtsm_hops); | |
9406 | else if (p->ttl > 1) | |
9407 | json_object_int_add(json_neigh, | |
9408 | "externalBgpNbrMaxHopsAway", | |
9409 | p->ttl); | |
9410 | } else { | |
9411 | if (p->gtsm_hops > 0) | |
9412 | vty_out(vty, | |
9413 | " External BGP neighbor may be up to %d hops away.\n", | |
9414 | p->gtsm_hops); | |
9415 | else if (p->ttl > 1) | |
9416 | vty_out(vty, | |
9417 | " External BGP neighbor may be up to %d hops away.\n", | |
9418 | p->ttl); | |
9419 | } | |
9420 | } else { | |
9421 | if (p->gtsm_hops > 0) { | |
9422 | if (use_json) | |
9423 | json_object_int_add(json_neigh, | |
9424 | "internalBgpNbrMaxHopsAway", | |
9425 | p->gtsm_hops); | |
9426 | else | |
9427 | vty_out(vty, | |
9428 | " Internal BGP neighbor may be up to %d hops away.\n", | |
9429 | p->gtsm_hops); | |
9430 | } | |
9431 | } | |
9432 | ||
9433 | /* Local address. */ | |
9434 | if (p->su_local) { | |
9435 | if (use_json) { | |
9436 | json_object_string_add(json_neigh, "hostLocal", | |
9437 | sockunion2str(p->su_local, buf1, | |
9438 | SU_ADDRSTRLEN)); | |
9439 | json_object_int_add(json_neigh, "portLocal", | |
9440 | ntohs(p->su_local->sin.sin_port)); | |
9441 | } else | |
9442 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
9443 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
9444 | ntohs(p->su_local->sin.sin_port)); | |
9445 | } | |
9446 | ||
9447 | /* Remote address. */ | |
9448 | if (p->su_remote) { | |
9449 | if (use_json) { | |
9450 | json_object_string_add(json_neigh, "hostForeign", | |
9451 | sockunion2str(p->su_remote, buf1, | |
9452 | SU_ADDRSTRLEN)); | |
9453 | json_object_int_add(json_neigh, "portForeign", | |
9454 | ntohs(p->su_remote->sin.sin_port)); | |
9455 | } else | |
9456 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
9457 | sockunion2str(p->su_remote, buf1, | |
9458 | SU_ADDRSTRLEN), | |
9459 | ntohs(p->su_remote->sin.sin_port)); | |
9460 | } | |
9461 | ||
9462 | /* Nexthop display. */ | |
9463 | if (p->su_local) { | |
9464 | if (use_json) { | |
9465 | json_object_string_add(json_neigh, "nexthop", | |
9466 | inet_ntop(AF_INET, | |
9467 | &p->nexthop.v4, buf1, | |
9468 | sizeof(buf1))); | |
9469 | json_object_string_add(json_neigh, "nexthopGlobal", | |
9470 | inet_ntop(AF_INET6, | |
9471 | &p->nexthop.v6_global, | |
9472 | buf1, sizeof(buf1))); | |
9473 | json_object_string_add(json_neigh, "nexthopLocal", | |
9474 | inet_ntop(AF_INET6, | |
9475 | &p->nexthop.v6_local, | |
9476 | buf1, sizeof(buf1))); | |
9477 | if (p->shared_network) | |
9478 | json_object_string_add(json_neigh, | |
9479 | "bgpConnection", | |
9480 | "sharedNetwork"); | |
9481 | else | |
9482 | json_object_string_add(json_neigh, | |
9483 | "bgpConnection", | |
9484 | "nonSharedNetwork"); | |
9485 | } else { | |
9486 | vty_out(vty, "Nexthop: %s\n", | |
9487 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
9488 | sizeof(buf1))); | |
9489 | vty_out(vty, "Nexthop global: %s\n", | |
9490 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
9491 | sizeof(buf1))); | |
9492 | vty_out(vty, "Nexthop local: %s\n", | |
9493 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
9494 | sizeof(buf1))); | |
9495 | vty_out(vty, "BGP connection: %s\n", | |
9496 | p->shared_network ? "shared network" | |
9497 | : "non shared network"); | |
9498 | } | |
9499 | } | |
9500 | ||
9501 | /* Timer information. */ | |
9502 | if (use_json) { | |
9503 | json_object_int_add(json_neigh, "connectRetryTimer", | |
9504 | p->v_connect); | |
9505 | if (p->status == Established && p->rtt) | |
9506 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
9507 | p->rtt); | |
9508 | if (p->t_start) | |
9509 | json_object_int_add( | |
9510 | json_neigh, "nextStartTimerDueInMsecs", | |
9511 | thread_timer_remain_second(p->t_start) * 1000); | |
9512 | if (p->t_connect) | |
9513 | json_object_int_add( | |
9514 | json_neigh, "nextConnectTimerDueInMsecs", | |
9515 | thread_timer_remain_second(p->t_connect) | |
9516 | * 1000); | |
9517 | if (p->t_routeadv) { | |
9518 | json_object_int_add(json_neigh, "mraiInterval", | |
9519 | p->v_routeadv); | |
9520 | json_object_int_add( | |
9521 | json_neigh, "mraiTimerExpireInMsecs", | |
9522 | thread_timer_remain_second(p->t_routeadv) | |
9523 | * 1000); | |
9524 | } | |
9525 | if (p->password) | |
9526 | json_object_int_add(json_neigh, "authenticationEnabled", | |
9527 | 1); | |
9528 | ||
9529 | if (p->t_read) | |
9530 | json_object_string_add(json_neigh, "readThread", "on"); | |
9531 | else | |
9532 | json_object_string_add(json_neigh, "readThread", "off"); | |
9533 | if (p->t_write) | |
9534 | json_object_string_add(json_neigh, "writeThread", "on"); | |
9535 | else | |
9536 | json_object_string_add(json_neigh, "writeThread", | |
9537 | "off"); | |
9538 | } else { | |
9539 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
9540 | p->v_connect); | |
9541 | if (p->status == Established && p->rtt) | |
9542 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
9543 | p->rtt); | |
9544 | if (p->t_start) | |
9545 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
9546 | thread_timer_remain_second(p->t_start)); | |
9547 | if (p->t_connect) | |
9548 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
9549 | thread_timer_remain_second(p->t_connect)); | |
9550 | if (p->t_routeadv) | |
9551 | vty_out(vty, | |
9552 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
9553 | p->v_routeadv, | |
9554 | thread_timer_remain_second(p->t_routeadv)); | |
9555 | if (p->password) | |
9556 | vty_out(vty, "Peer Authentication Enabled\n"); | |
9557 | ||
9558 | vty_out(vty, "Read thread: %s Write thread: %s\n", | |
9559 | p->t_read ? "on" : "off", p->t_write ? "on" : "off"); | |
9560 | } | |
9561 | ||
9562 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
9563 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
9564 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
9565 | ||
9566 | if (!use_json) | |
9567 | vty_out(vty, "\n"); | |
9568 | ||
9569 | /* BFD information. */ | |
9570 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
9571 | ||
9572 | if (use_json) { | |
9573 | if (p->conf_if) /* Configured interface name. */ | |
9574 | json_object_object_add(json, p->conf_if, json_neigh); | |
9575 | else /* Configured IP address. */ | |
9576 | json_object_object_add(json, p->host, json_neigh); | |
9577 | } | |
9578 | } | |
9579 | ||
9580 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, | |
9581 | enum show_type type, union sockunion *su, | |
9582 | const char *conf_if, u_char use_json, | |
9583 | json_object *json) | |
9584 | { | |
9585 | struct listnode *node, *nnode; | |
9586 | struct peer *peer; | |
9587 | int find = 0; | |
9588 | ||
9589 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
9590 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
9591 | continue; | |
9592 | ||
9593 | switch (type) { | |
9594 | case show_all: | |
9595 | bgp_show_peer(vty, peer, use_json, json); | |
9596 | break; | |
9597 | case show_peer: | |
9598 | if (conf_if) { | |
9599 | if ((peer->conf_if | |
9600 | && !strcmp(peer->conf_if, conf_if)) | |
9601 | || (peer->hostname | |
9602 | && !strcmp(peer->hostname, conf_if))) { | |
9603 | find = 1; | |
9604 | bgp_show_peer(vty, peer, use_json, | |
9605 | json); | |
9606 | } | |
9607 | } else { | |
9608 | if (sockunion_same(&peer->su, su)) { | |
9609 | find = 1; | |
9610 | bgp_show_peer(vty, peer, use_json, | |
9611 | json); | |
9612 | } | |
9613 | } | |
9614 | break; | |
9615 | } | |
9616 | } | |
9617 | ||
9618 | if (type == show_peer && !find) { | |
9619 | if (use_json) | |
9620 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
9621 | else | |
9622 | vty_out(vty, "%% No such neighbor\n"); | |
9623 | } | |
9624 | ||
9625 | if (use_json) { | |
9d303b37 DL |
9626 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
9627 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9628 | json_object_free(json); |
9629 | } else { | |
9630 | vty_out(vty, "\n"); | |
9631 | } | |
9632 | ||
9633 | return CMD_SUCCESS; | |
9634 | } | |
9635 | ||
9636 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, | |
9637 | u_char use_json) | |
9638 | { | |
9639 | struct listnode *node, *nnode; | |
9640 | struct bgp *bgp; | |
9641 | json_object *json = NULL; | |
9642 | int is_first = 1; | |
9643 | ||
9644 | if (use_json) | |
9645 | vty_out(vty, "{\n"); | |
9646 | ||
9647 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9648 | if (use_json) { | |
9649 | if (!(json = json_object_new_object())) { | |
9650 | zlog_err( | |
9651 | "Unable to allocate memory for JSON object"); | |
9652 | vty_out(vty, | |
9653 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
9654 | return; | |
9655 | } | |
9656 | ||
9657 | json_object_int_add(json, "vrfId", | |
9658 | (bgp->vrf_id == VRF_UNKNOWN) | |
9659 | ? -1 | |
9660 | : bgp->vrf_id); | |
9661 | json_object_string_add( | |
9662 | json, "vrfName", | |
9663 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9664 | ? "Default" | |
9665 | : bgp->name); | |
9666 | ||
9667 | if (!is_first) | |
9668 | vty_out(vty, ",\n"); | |
9669 | else | |
9670 | is_first = 0; | |
9671 | ||
9672 | vty_out(vty, "\"%s\":", | |
9673 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9674 | ? "Default" | |
9675 | : bgp->name); | |
9676 | } else { | |
9677 | vty_out(vty, "\nInstance %s:\n", | |
9678 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9679 | ? "Default" | |
9680 | : bgp->name); | |
9681 | } | |
9682 | bgp_show_neighbor(vty, bgp, show_all, NULL, NULL, use_json, | |
9683 | json); | |
9684 | } | |
9685 | ||
9686 | if (use_json) | |
9687 | vty_out(vty, "}\n"); | |
9688 | } | |
9689 | ||
9690 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
9691 | enum show_type type, const char *ip_str, | |
9692 | u_char use_json) | |
9693 | { | |
9694 | int ret; | |
9695 | struct bgp *bgp; | |
9696 | union sockunion su; | |
9697 | json_object *json = NULL; | |
9698 | ||
9699 | if (name) { | |
9700 | if (strmatch(name, "all")) { | |
9701 | bgp_show_all_instances_neighbors_vty(vty, use_json); | |
9702 | return CMD_SUCCESS; | |
9703 | } else { | |
9704 | bgp = bgp_lookup_by_name(name); | |
9705 | if (!bgp) { | |
9706 | if (use_json) { | |
9707 | json = json_object_new_object(); | |
9708 | json_object_boolean_true_add( | |
9709 | json, "bgpNoSuchInstance"); | |
9710 | vty_out(vty, "%s\n", | |
9711 | json_object_to_json_string_ext( | |
9712 | json, | |
9713 | JSON_C_TO_STRING_PRETTY)); | |
9714 | json_object_free(json); | |
9715 | } else | |
9716 | vty_out(vty, | |
9717 | "%% No such BGP instance exist\n"); | |
9718 | ||
9719 | return CMD_WARNING; | |
9720 | } | |
9721 | } | |
9722 | } else { | |
9723 | bgp = bgp_get_default(); | |
9724 | } | |
9725 | ||
9726 | if (bgp) { | |
9727 | json = json_object_new_object(); | |
9728 | if (ip_str) { | |
9729 | ret = str2sockunion(ip_str, &su); | |
9730 | if (ret < 0) | |
9731 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
9732 | use_json, json); | |
9733 | else | |
9734 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
9735 | use_json, json); | |
9736 | } else { | |
9737 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
9738 | json); | |
9739 | } | |
9740 | json_object_free(json); | |
9741 | } | |
9742 | ||
9743 | return CMD_SUCCESS; | |
4fb25c53 DW |
9744 | } |
9745 | ||
716b2d8a | 9746 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 9747 | DEFUN (show_ip_bgp_neighbors, |
9748 | show_ip_bgp_neighbors_cmd, | |
18c57037 | 9749 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|vpnv4 <all|rd ASN:nn_or_IP-address:nn>>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 9750 | SHOW_STR |
9751 | IP_STR | |
9752 | BGP_STR | |
f2a8972b | 9753 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
9754 | "Address Family\n" |
9755 | "Address Family\n" | |
91d37724 QY |
9756 | "Address Family\n" |
9757 | "Display information about all VPNv4 NLRIs\n" | |
9758 | "Display information for a route distinguisher\n" | |
9759 | "VPN Route Distinguisher\n" | |
718e3744 | 9760 | "Detailed information on TCP and BGP neighbor connections\n" |
9761 | "Neighbor to display information about\n" | |
a80beece | 9762 | "Neighbor to display information about\n" |
91d37724 | 9763 | "Neighbor on BGP configured interface\n" |
9973d184 | 9764 | JSON_STR) |
718e3744 | 9765 | { |
d62a17ae | 9766 | char *vrf = NULL; |
9767 | char *sh_arg = NULL; | |
9768 | enum show_type sh_type; | |
718e3744 | 9769 | |
d62a17ae | 9770 | u_char uj = use_json(argc, argv); |
718e3744 | 9771 | |
d62a17ae | 9772 | int idx = 0; |
718e3744 | 9773 | |
d62a17ae | 9774 | if (argv_find(argv, argc, "view", &idx) |
9775 | || argv_find(argv, argc, "vrf", &idx)) | |
9776 | vrf = argv[idx + 1]->arg; | |
718e3744 | 9777 | |
d62a17ae | 9778 | idx++; |
9779 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
9780 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
9781 | || argv_find(argv, argc, "WORD", &idx)) { | |
9782 | sh_type = show_peer; | |
9783 | sh_arg = argv[idx]->arg; | |
9784 | } else | |
9785 | sh_type = show_all; | |
856ca177 | 9786 | |
d62a17ae | 9787 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 9788 | } |
9789 | ||
716b2d8a | 9790 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 9791 | paths' and `show ip mbgp paths'. Those functions results are the |
9792 | same.*/ | |
f412b39a | 9793 | DEFUN (show_ip_bgp_paths, |
718e3744 | 9794 | show_ip_bgp_paths_cmd, |
46f296b4 | 9795 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 9796 | SHOW_STR |
9797 | IP_STR | |
9798 | BGP_STR | |
46f296b4 | 9799 | BGP_SAFI_HELP_STR |
718e3744 | 9800 | "Path information\n") |
9801 | { | |
d62a17ae | 9802 | vty_out(vty, "Address Refcnt Path\n"); |
9803 | aspath_print_all_vty(vty); | |
9804 | return CMD_SUCCESS; | |
718e3744 | 9805 | } |
9806 | ||
718e3744 | 9807 | #include "hash.h" |
9808 | ||
d62a17ae | 9809 | static void community_show_all_iterator(struct hash_backet *backet, |
9810 | struct vty *vty) | |
718e3744 | 9811 | { |
d62a17ae | 9812 | struct community *com; |
718e3744 | 9813 | |
d62a17ae | 9814 | com = (struct community *)backet->data; |
9815 | vty_out(vty, "[%p] (%ld) %s\n", (void *)backet, com->refcnt, | |
9816 | community_str(com)); | |
718e3744 | 9817 | } |
9818 | ||
9819 | /* Show BGP's community internal data. */ | |
f412b39a | 9820 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 9821 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 9822 | "show [ip] bgp community-info", |
718e3744 | 9823 | SHOW_STR |
9824 | IP_STR | |
9825 | BGP_STR | |
9826 | "List all bgp community information\n") | |
9827 | { | |
d62a17ae | 9828 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 9829 | |
d62a17ae | 9830 | hash_iterate(community_hash(), |
9831 | (void (*)(struct hash_backet *, | |
9832 | void *))community_show_all_iterator, | |
9833 | vty); | |
718e3744 | 9834 | |
d62a17ae | 9835 | return CMD_SUCCESS; |
718e3744 | 9836 | } |
9837 | ||
d62a17ae | 9838 | static void lcommunity_show_all_iterator(struct hash_backet *backet, |
9839 | struct vty *vty) | |
57d187bc | 9840 | { |
d62a17ae | 9841 | struct lcommunity *lcom; |
57d187bc | 9842 | |
d62a17ae | 9843 | lcom = (struct lcommunity *)backet->data; |
9844 | vty_out(vty, "[%p] (%ld) %s\n", (void *)backet, lcom->refcnt, | |
9845 | lcommunity_str(lcom)); | |
57d187bc JS |
9846 | } |
9847 | ||
9848 | /* Show BGP's community internal data. */ | |
9849 | DEFUN (show_ip_bgp_lcommunity_info, | |
9850 | show_ip_bgp_lcommunity_info_cmd, | |
9851 | "show ip bgp large-community-info", | |
9852 | SHOW_STR | |
9853 | IP_STR | |
9854 | BGP_STR | |
9855 | "List all bgp large-community information\n") | |
9856 | { | |
d62a17ae | 9857 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 9858 | |
d62a17ae | 9859 | hash_iterate(lcommunity_hash(), |
9860 | (void (*)(struct hash_backet *, | |
9861 | void *))lcommunity_show_all_iterator, | |
9862 | vty); | |
57d187bc | 9863 | |
d62a17ae | 9864 | return CMD_SUCCESS; |
57d187bc JS |
9865 | } |
9866 | ||
9867 | ||
f412b39a | 9868 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 9869 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 9870 | "show [ip] bgp attribute-info", |
718e3744 | 9871 | SHOW_STR |
9872 | IP_STR | |
9873 | BGP_STR | |
9874 | "List all bgp attribute information\n") | |
9875 | { | |
d62a17ae | 9876 | attr_show_all(vty); |
9877 | return CMD_SUCCESS; | |
718e3744 | 9878 | } |
6b0655a2 | 9879 | |
d62a17ae | 9880 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
9881 | safi_t safi) | |
f186de26 | 9882 | { |
d62a17ae | 9883 | struct listnode *node, *nnode; |
9884 | struct bgp *bgp; | |
f186de26 | 9885 | |
d62a17ae | 9886 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
9887 | vty_out(vty, "\nInstance %s:\n", | |
9888 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9889 | ? "Default" | |
9890 | : bgp->name); | |
9891 | update_group_show(bgp, afi, safi, vty, 0); | |
9892 | } | |
f186de26 | 9893 | } |
9894 | ||
d62a17ae | 9895 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
9896 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 9897 | { |
d62a17ae | 9898 | struct bgp *bgp; |
4fb25c53 | 9899 | |
d62a17ae | 9900 | if (name) { |
9901 | if (strmatch(name, "all")) { | |
9902 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
9903 | return CMD_SUCCESS; | |
9904 | } else { | |
9905 | bgp = bgp_lookup_by_name(name); | |
9906 | } | |
9907 | } else { | |
9908 | bgp = bgp_get_default(); | |
9909 | } | |
4fb25c53 | 9910 | |
d62a17ae | 9911 | if (bgp) |
9912 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
9913 | return CMD_SUCCESS; | |
4fb25c53 DW |
9914 | } |
9915 | ||
8fe8a7f6 DS |
9916 | DEFUN (show_ip_bgp_updgrps, |
9917 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 9918 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 9919 | SHOW_STR |
9920 | IP_STR | |
9921 | BGP_STR | |
9922 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 9923 | BGP_AFI_HELP_STR |
9bedbb1e | 9924 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
9925 | "Detailed info about dynamic update groups\n" |
9926 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 9927 | { |
d62a17ae | 9928 | char *vrf = NULL; |
9929 | afi_t afi = AFI_IP6; | |
9930 | safi_t safi = SAFI_UNICAST; | |
9931 | uint64_t subgrp_id = 0; | |
9932 | ||
9933 | int idx = 0; | |
9934 | ||
9935 | /* show [ip] bgp */ | |
9936 | if (argv_find(argv, argc, "ip", &idx)) | |
9937 | afi = AFI_IP; | |
9938 | /* [<view|vrf> VIEWVRFNAME] */ | |
9939 | if (argv_find(argv, argc, "view", &idx) | |
9940 | || argv_find(argv, argc, "vrf", &idx)) | |
9941 | vrf = argv[++idx]->arg; | |
9942 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
9943 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
9944 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9945 | } | |
5bf15956 | 9946 | |
d62a17ae | 9947 | /* get subgroup id, if provided */ |
9948 | idx = argc - 1; | |
9949 | if (argv[idx]->type == VARIABLE_TKN) | |
9950 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 9951 | |
d62a17ae | 9952 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
9953 | } |
9954 | ||
f186de26 | 9955 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
9956 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 9957 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 9958 | SHOW_STR |
716b2d8a | 9959 | IP_STR |
f186de26 | 9960 | BGP_STR |
9961 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 9962 | "Detailed info about dynamic update groups\n") |
f186de26 | 9963 | { |
d62a17ae | 9964 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
9965 | return CMD_SUCCESS; | |
f186de26 | 9966 | } |
9967 | ||
5bf15956 DW |
9968 | DEFUN (show_bgp_updgrps_stats, |
9969 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 9970 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 9971 | SHOW_STR |
716b2d8a | 9972 | IP_STR |
3f9c7369 | 9973 | BGP_STR |
0c7b1b01 | 9974 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9975 | "Statistics\n") |
9976 | { | |
d62a17ae | 9977 | struct bgp *bgp; |
3f9c7369 | 9978 | |
d62a17ae | 9979 | bgp = bgp_get_default(); |
9980 | if (bgp) | |
9981 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 9982 | |
d62a17ae | 9983 | return CMD_SUCCESS; |
3f9c7369 DS |
9984 | } |
9985 | ||
8386ac43 | 9986 | DEFUN (show_bgp_instance_updgrps_stats, |
9987 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 9988 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 9989 | SHOW_STR |
716b2d8a | 9990 | IP_STR |
8386ac43 | 9991 | BGP_STR |
9992 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 9993 | "Detailed info about dynamic update groups\n" |
8386ac43 | 9994 | "Statistics\n") |
9995 | { | |
d62a17ae | 9996 | int idx_word = 3; |
9997 | struct bgp *bgp; | |
8386ac43 | 9998 | |
d62a17ae | 9999 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
10000 | if (bgp) | |
10001 | update_group_show_stats(bgp, vty); | |
8386ac43 | 10002 | |
d62a17ae | 10003 | return CMD_SUCCESS; |
8386ac43 | 10004 | } |
10005 | ||
d62a17ae | 10006 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
10007 | afi_t afi, safi_t safi, | |
10008 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 10009 | { |
d62a17ae | 10010 | struct bgp *bgp; |
8386ac43 | 10011 | |
d62a17ae | 10012 | if (name) |
10013 | bgp = bgp_lookup_by_name(name); | |
10014 | else | |
10015 | bgp = bgp_get_default(); | |
8386ac43 | 10016 | |
d62a17ae | 10017 | if (bgp) { |
10018 | if (!strcmp(what, "advertise-queue")) | |
10019 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
10020 | subgrp_id); | |
10021 | else if (!strcmp(what, "advertised-routes")) | |
10022 | update_group_show_advertised(bgp, afi, safi, vty, | |
10023 | subgrp_id); | |
10024 | else if (!strcmp(what, "packet-queue")) | |
10025 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
10026 | subgrp_id); | |
10027 | } | |
3f9c7369 DS |
10028 | } |
10029 | ||
10030 | DEFUN (show_ip_bgp_updgrps_adj, | |
10031 | show_ip_bgp_updgrps_adj_cmd, | |
716b2d8a | 10032 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
10033 | SHOW_STR |
10034 | IP_STR | |
10035 | BGP_STR | |
0c7b1b01 | 10036 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
10037 | "Advertisement queue\n" |
10038 | "Announced routes\n" | |
10039 | "Packet queue\n") | |
10040 | { | |
d62a17ae | 10041 | int idx_type = 4; |
10042 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, | |
10043 | argv[idx_type]->arg, 0); | |
10044 | return CMD_SUCCESS; | |
8386ac43 | 10045 | } |
10046 | ||
10047 | DEFUN (show_ip_bgp_instance_updgrps_adj, | |
10048 | show_ip_bgp_instance_updgrps_adj_cmd, | |
18c57037 | 10049 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10050 | SHOW_STR |
10051 | IP_STR | |
10052 | BGP_STR | |
10053 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10054 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10055 | "Advertisement queue\n" |
10056 | "Announced routes\n" | |
10057 | "Packet queue\n") | |
8386ac43 | 10058 | { |
d62a17ae | 10059 | int idx_word = 4; |
10060 | int idx_type = 6; | |
10061 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, | |
10062 | SAFI_UNICAST, argv[idx_type]->arg, 0); | |
10063 | return CMD_SUCCESS; | |
3f9c7369 DS |
10064 | } |
10065 | ||
10066 | DEFUN (show_bgp_updgrps_afi_adj, | |
10067 | show_bgp_updgrps_afi_adj_cmd, | |
46f296b4 | 10068 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 10069 | SHOW_STR |
716b2d8a | 10070 | IP_STR |
3f9c7369 | 10071 | BGP_STR |
46f296b4 | 10072 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 10073 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
10074 | "Advertisement queue\n" |
10075 | "Announced routes\n" | |
7111c1a0 | 10076 | "Packet queue\n") |
3f9c7369 | 10077 | { |
d62a17ae | 10078 | int idx_afi = 2; |
10079 | int idx_safi = 3; | |
10080 | int idx_type = 5; | |
10081 | show_bgp_updgrps_adj_info_aux( | |
10082 | vty, NULL, bgp_vty_afi_from_str(argv[idx_afi]->text), | |
10083 | bgp_vty_safi_from_str(argv[idx_safi]->text), | |
10084 | argv[idx_type]->arg, 0); | |
10085 | return CMD_SUCCESS; | |
3f9c7369 DS |
10086 | } |
10087 | ||
10088 | DEFUN (show_bgp_updgrps_adj, | |
10089 | show_bgp_updgrps_adj_cmd, | |
716b2d8a | 10090 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 10091 | SHOW_STR |
716b2d8a | 10092 | IP_STR |
3f9c7369 | 10093 | BGP_STR |
0c7b1b01 | 10094 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
10095 | "Advertisement queue\n" |
10096 | "Announced routes\n" | |
10097 | "Packet queue\n") | |
10098 | { | |
d62a17ae | 10099 | int idx_type = 3; |
10100 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, | |
10101 | argv[idx_type]->arg, 0); | |
10102 | return CMD_SUCCESS; | |
8386ac43 | 10103 | } |
10104 | ||
10105 | DEFUN (show_bgp_instance_updgrps_adj, | |
10106 | show_bgp_instance_updgrps_adj_cmd, | |
18c57037 | 10107 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10108 | SHOW_STR |
716b2d8a | 10109 | IP_STR |
8386ac43 | 10110 | BGP_STR |
10111 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10112 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10113 | "Advertisement queue\n" |
10114 | "Announced routes\n" | |
10115 | "Packet queue\n") | |
10116 | { | |
d62a17ae | 10117 | int idx_word = 3; |
10118 | int idx_type = 5; | |
10119 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, | |
10120 | SAFI_UNICAST, argv[idx_type]->arg, 0); | |
10121 | return CMD_SUCCESS; | |
3f9c7369 DS |
10122 | } |
10123 | ||
10124 | DEFUN (show_ip_bgp_updgrps_adj_s, | |
8fe8a7f6 | 10125 | show_ip_bgp_updgrps_adj_s_cmd, |
716b2d8a | 10126 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
10127 | SHOW_STR |
10128 | IP_STR | |
10129 | BGP_STR | |
0c7b1b01 | 10130 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 10131 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
10132 | "Advertisement queue\n" |
10133 | "Announced routes\n" | |
10134 | "Packet queue\n") | |
3f9c7369 | 10135 | { |
d62a17ae | 10136 | int idx_subgroup_id = 4; |
10137 | int idx_type = 5; | |
10138 | uint64_t subgrp_id; | |
8fe8a7f6 | 10139 | |
d62a17ae | 10140 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8fe8a7f6 | 10141 | |
d62a17ae | 10142 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, |
10143 | argv[idx_type]->arg, subgrp_id); | |
10144 | return CMD_SUCCESS; | |
8386ac43 | 10145 | } |
10146 | ||
10147 | DEFUN (show_ip_bgp_instance_updgrps_adj_s, | |
10148 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
18c57037 | 10149 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10150 | SHOW_STR |
10151 | IP_STR | |
10152 | BGP_STR | |
10153 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10154 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10155 | "Specific subgroup to display info for\n" |
10156 | "Advertisement queue\n" | |
10157 | "Announced routes\n" | |
10158 | "Packet queue\n") | |
8386ac43 | 10159 | { |
d62a17ae | 10160 | int idx_vrf = 4; |
10161 | int idx_subgroup_id = 6; | |
10162 | int idx_type = 7; | |
10163 | uint64_t subgrp_id; | |
8386ac43 | 10164 | |
d62a17ae | 10165 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8386ac43 | 10166 | |
d62a17ae | 10167 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP, |
10168 | SAFI_UNICAST, argv[idx_type]->arg, | |
10169 | subgrp_id); | |
10170 | return CMD_SUCCESS; | |
3f9c7369 DS |
10171 | } |
10172 | ||
8fe8a7f6 DS |
10173 | DEFUN (show_bgp_updgrps_afi_adj_s, |
10174 | show_bgp_updgrps_afi_adj_s_cmd, | |
46f296b4 | 10175 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 10176 | SHOW_STR |
716b2d8a | 10177 | IP_STR |
3f9c7369 | 10178 | BGP_STR |
46f296b4 | 10179 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 10180 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 10181 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
10182 | "Advertisement queue\n" |
10183 | "Announced routes\n" | |
7111c1a0 | 10184 | "Packet queue\n") |
3f9c7369 | 10185 | { |
d62a17ae | 10186 | int idx_afi = 2; |
10187 | int idx_safi = 3; | |
10188 | int idx_subgroup_id = 5; | |
10189 | int idx_type = 6; | |
10190 | uint64_t subgrp_id; | |
3f9c7369 | 10191 | |
d62a17ae | 10192 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8fe8a7f6 | 10193 | |
d62a17ae | 10194 | show_bgp_updgrps_adj_info_aux( |
10195 | vty, NULL, bgp_vty_afi_from_str(argv[idx_afi]->text), | |
10196 | bgp_vty_safi_from_str(argv[idx_safi]->text), | |
10197 | argv[idx_type]->arg, subgrp_id); | |
10198 | return CMD_SUCCESS; | |
3f9c7369 DS |
10199 | } |
10200 | ||
8fe8a7f6 DS |
10201 | DEFUN (show_bgp_updgrps_adj_s, |
10202 | show_bgp_updgrps_adj_s_cmd, | |
716b2d8a | 10203 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8fe8a7f6 | 10204 | SHOW_STR |
716b2d8a | 10205 | IP_STR |
8fe8a7f6 | 10206 | BGP_STR |
0c7b1b01 | 10207 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 DS |
10208 | "Specific subgroup to display info for\n" |
10209 | "Advertisement queue\n" | |
10210 | "Announced routes\n" | |
10211 | "Packet queue\n") | |
10212 | { | |
d62a17ae | 10213 | int idx_subgroup_id = 3; |
10214 | int idx_type = 4; | |
10215 | uint64_t subgrp_id; | |
8fe8a7f6 | 10216 | |
d62a17ae | 10217 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8fe8a7f6 | 10218 | |
d62a17ae | 10219 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, |
10220 | argv[idx_type]->arg, subgrp_id); | |
10221 | return CMD_SUCCESS; | |
8fe8a7f6 DS |
10222 | } |
10223 | ||
8386ac43 | 10224 | DEFUN (show_bgp_instance_updgrps_adj_s, |
10225 | show_bgp_instance_updgrps_adj_s_cmd, | |
18c57037 | 10226 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10227 | SHOW_STR |
716b2d8a | 10228 | IP_STR |
8386ac43 | 10229 | BGP_STR |
10230 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10231 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10232 | "Specific subgroup to display info for\n" |
10233 | "Advertisement queue\n" | |
10234 | "Announced routes\n" | |
10235 | "Packet queue\n") | |
10236 | { | |
d62a17ae | 10237 | int idx_vrf = 3; |
10238 | int idx_subgroup_id = 5; | |
10239 | int idx_type = 6; | |
10240 | uint64_t subgrp_id; | |
10241 | ||
10242 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); | |
10243 | ||
10244 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP6, | |
10245 | SAFI_UNICAST, argv[idx_type]->arg, | |
10246 | subgrp_id); | |
10247 | return CMD_SUCCESS; | |
10248 | } | |
10249 | ||
10250 | ||
10251 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) | |
10252 | { | |
10253 | struct listnode *node, *nnode; | |
10254 | struct prefix *range; | |
10255 | struct peer *conf; | |
10256 | struct peer *peer; | |
10257 | char buf[PREFIX2STR_BUFFER]; | |
10258 | afi_t afi; | |
10259 | safi_t safi; | |
10260 | const char *peer_status; | |
10261 | const char *af_str; | |
10262 | int lr_count; | |
10263 | int dynamic; | |
10264 | int af_cfgd; | |
10265 | ||
10266 | conf = group->conf; | |
10267 | ||
10268 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
10269 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
10270 | conf->as); | |
10271 | } else if (conf->as_type == AS_INTERNAL) { | |
10272 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
10273 | group->bgp->as); | |
10274 | } else { | |
10275 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
10276 | } | |
f14e6fdb | 10277 | |
d62a17ae | 10278 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
10279 | vty_out(vty, " Peer-group type is internal\n"); | |
10280 | else | |
10281 | vty_out(vty, " Peer-group type is external\n"); | |
10282 | ||
10283 | /* Display AFs configured. */ | |
10284 | vty_out(vty, " Configured address-families:"); | |
10285 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
10286 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { | |
10287 | if (conf->afc[afi][safi]) { | |
10288 | af_cfgd = 1; | |
10289 | vty_out(vty, " %s;", afi_safi_print(afi, safi)); | |
10290 | } | |
10291 | } | |
10292 | if (!af_cfgd) | |
10293 | vty_out(vty, " none\n"); | |
10294 | else | |
10295 | vty_out(vty, "\n"); | |
10296 | ||
10297 | /* Display listen ranges (for dynamic neighbors), if any */ | |
10298 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
10299 | if (afi == AFI_IP) | |
10300 | af_str = "IPv4"; | |
10301 | else if (afi == AFI_IP6) | |
10302 | af_str = "IPv6"; | |
10303 | else | |
10304 | af_str = "???"; | |
10305 | lr_count = listcount(group->listen_range[afi]); | |
10306 | if (lr_count) { | |
10307 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
10308 | af_str); | |
10309 | ||
10310 | ||
10311 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
10312 | nnode, range)) { | |
10313 | prefix2str(range, buf, sizeof(buf)); | |
10314 | vty_out(vty, " %s\n", buf); | |
10315 | } | |
10316 | } | |
10317 | } | |
f14e6fdb | 10318 | |
d62a17ae | 10319 | /* Display group members and their status */ |
10320 | if (listcount(group->peer)) { | |
10321 | vty_out(vty, " Peer-group members:\n"); | |
10322 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
10323 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
10324 | peer_status = "Idle (Admin)"; | |
10325 | else if (CHECK_FLAG(peer->sflags, | |
10326 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10327 | peer_status = "Idle (PfxCt)"; | |
10328 | else | |
10329 | peer_status = lookup_msg(bgp_status_msg, | |
10330 | peer->status, NULL); | |
10331 | ||
10332 | dynamic = peer_dynamic_neighbor(peer); | |
10333 | vty_out(vty, " %s %s %s \n", peer->host, | |
10334 | dynamic ? "(dynamic)" : "", peer_status); | |
10335 | } | |
10336 | } | |
f14e6fdb | 10337 | |
d62a17ae | 10338 | return CMD_SUCCESS; |
10339 | } | |
10340 | ||
10341 | /* Show BGP peer group's information. */ | |
10342 | enum show_group_type { show_all_groups, show_peer_group }; | |
10343 | ||
10344 | static int bgp_show_peer_group(struct vty *vty, struct bgp *bgp, | |
10345 | enum show_group_type type, | |
10346 | const char *group_name) | |
10347 | { | |
10348 | struct listnode *node, *nnode; | |
10349 | struct peer_group *group; | |
10350 | int find = 0; | |
10351 | ||
10352 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
10353 | switch (type) { | |
10354 | case show_all_groups: | |
10355 | bgp_show_one_peer_group(vty, group); | |
10356 | break; | |
10357 | case show_peer_group: | |
10358 | if (group_name | |
10359 | && (strcmp(group->name, group_name) == 0)) { | |
10360 | find = 1; | |
10361 | bgp_show_one_peer_group(vty, group); | |
10362 | } | |
10363 | break; | |
10364 | } | |
f14e6fdb | 10365 | } |
f14e6fdb | 10366 | |
d62a17ae | 10367 | if (type == show_peer_group && !find) |
10368 | vty_out(vty, "%% No such peer-group\n"); | |
f14e6fdb | 10369 | |
d62a17ae | 10370 | return CMD_SUCCESS; |
f14e6fdb DS |
10371 | } |
10372 | ||
d62a17ae | 10373 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
10374 | enum show_group_type type, | |
10375 | const char *group_name) | |
f14e6fdb | 10376 | { |
d62a17ae | 10377 | struct bgp *bgp; |
10378 | int ret = CMD_SUCCESS; | |
f14e6fdb | 10379 | |
d62a17ae | 10380 | if (name) |
10381 | bgp = bgp_lookup_by_name(name); | |
10382 | else | |
10383 | bgp = bgp_get_default(); | |
f14e6fdb | 10384 | |
d62a17ae | 10385 | if (!bgp) { |
10386 | vty_out(vty, "%% No such BGP instance exist\n"); | |
10387 | return CMD_WARNING; | |
10388 | } | |
f14e6fdb | 10389 | |
d62a17ae | 10390 | ret = bgp_show_peer_group(vty, bgp, type, group_name); |
f14e6fdb | 10391 | |
d62a17ae | 10392 | return ret; |
f14e6fdb DS |
10393 | } |
10394 | ||
10395 | DEFUN (show_ip_bgp_peer_groups, | |
10396 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 10397 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
10398 | SHOW_STR |
10399 | IP_STR | |
10400 | BGP_STR | |
8386ac43 | 10401 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
10402 | "Detailed information on BGP peer groups\n" |
10403 | "Peer group name\n") | |
f14e6fdb | 10404 | { |
d62a17ae | 10405 | char *vrf, *pg; |
10406 | vrf = pg = NULL; | |
10407 | int idx = 0; | |
f14e6fdb | 10408 | |
d62a17ae | 10409 | vrf = argv_find(argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL; |
10410 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; | |
f14e6fdb | 10411 | |
d62a17ae | 10412 | return bgp_show_peer_group_vty(vty, vrf, show_all_groups, pg); |
f14e6fdb | 10413 | } |
3f9c7369 | 10414 | |
d6e3c605 | 10415 | |
718e3744 | 10416 | /* Redistribute VTY commands. */ |
10417 | ||
718e3744 | 10418 | DEFUN (bgp_redistribute_ipv4, |
10419 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 10420 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 10421 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10422 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 10423 | { |
d62a17ae | 10424 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10425 | int idx_protocol = 1; | |
10426 | int type; | |
718e3744 | 10427 | |
d62a17ae | 10428 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
10429 | if (type < 0) { | |
10430 | vty_out(vty, "%% Invalid route type\n"); | |
10431 | return CMD_WARNING_CONFIG_FAILED; | |
10432 | } | |
10433 | bgp_redist_add(bgp, AFI_IP, type, 0); | |
10434 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
718e3744 | 10435 | } |
10436 | ||
d62a17ae | 10437 | ALIAS_HIDDEN( |
10438 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
10439 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
10440 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 10441 | |
718e3744 | 10442 | DEFUN (bgp_redistribute_ipv4_rmap, |
10443 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 10444 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 10445 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10446 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10447 | "Route map reference\n" |
10448 | "Pointer to route-map entries\n") | |
10449 | { | |
d62a17ae | 10450 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10451 | int idx_protocol = 1; | |
10452 | int idx_word = 3; | |
10453 | int type; | |
10454 | struct bgp_redist *red; | |
718e3744 | 10455 | |
d62a17ae | 10456 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
10457 | if (type < 0) { | |
10458 | vty_out(vty, "%% Invalid route type\n"); | |
10459 | return CMD_WARNING_CONFIG_FAILED; | |
10460 | } | |
718e3744 | 10461 | |
d62a17ae | 10462 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
10463 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10464 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
718e3744 | 10465 | } |
10466 | ||
d62a17ae | 10467 | ALIAS_HIDDEN( |
10468 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
10469 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
10470 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10471 | "Route map reference\n" | |
10472 | "Pointer to route-map entries\n") | |
596c17ba | 10473 | |
718e3744 | 10474 | DEFUN (bgp_redistribute_ipv4_metric, |
10475 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 10476 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 10477 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10478 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10479 | "Metric for redistributed routes\n" |
10480 | "Default metric\n") | |
10481 | { | |
d62a17ae | 10482 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10483 | int idx_protocol = 1; | |
10484 | int idx_number = 3; | |
10485 | int type; | |
10486 | u_int32_t metric; | |
10487 | struct bgp_redist *red; | |
10488 | ||
10489 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
10490 | if (type < 0) { | |
10491 | vty_out(vty, "%% Invalid route type\n"); | |
10492 | return CMD_WARNING_CONFIG_FAILED; | |
10493 | } | |
10494 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
10495 | ||
10496 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
10497 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
10498 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
10499 | } | |
10500 | ||
10501 | ALIAS_HIDDEN( | |
10502 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
10503 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
10504 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10505 | "Metric for redistributed routes\n" | |
10506 | "Default metric\n") | |
596c17ba | 10507 | |
718e3744 | 10508 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
10509 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 10510 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 10511 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10512 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10513 | "Route map reference\n" |
10514 | "Pointer to route-map entries\n" | |
10515 | "Metric for redistributed routes\n" | |
10516 | "Default metric\n") | |
10517 | { | |
d62a17ae | 10518 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10519 | int idx_protocol = 1; | |
10520 | int idx_word = 3; | |
10521 | int idx_number = 5; | |
10522 | int type; | |
10523 | u_int32_t metric; | |
10524 | struct bgp_redist *red; | |
10525 | ||
10526 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
10527 | if (type < 0) { | |
10528 | vty_out(vty, "%% Invalid route type\n"); | |
10529 | return CMD_WARNING_CONFIG_FAILED; | |
10530 | } | |
10531 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
10532 | ||
10533 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
10534 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10535 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
10536 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
10537 | } | |
10538 | ||
10539 | ALIAS_HIDDEN( | |
10540 | bgp_redistribute_ipv4_rmap_metric, | |
10541 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
10542 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
10543 | " route-map WORD metric (0-4294967295)", | |
10544 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10545 | "Route map reference\n" | |
10546 | "Pointer to route-map entries\n" | |
10547 | "Metric for redistributed routes\n" | |
10548 | "Default metric\n") | |
596c17ba | 10549 | |
718e3744 | 10550 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
10551 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 10552 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 10553 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10554 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10555 | "Metric for redistributed routes\n" |
10556 | "Default metric\n" | |
10557 | "Route map reference\n" | |
10558 | "Pointer to route-map entries\n") | |
10559 | { | |
d62a17ae | 10560 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10561 | int idx_protocol = 1; | |
10562 | int idx_number = 3; | |
10563 | int idx_word = 5; | |
10564 | int type; | |
10565 | u_int32_t metric; | |
10566 | struct bgp_redist *red; | |
10567 | ||
10568 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
10569 | if (type < 0) { | |
10570 | vty_out(vty, "%% Invalid route type\n"); | |
10571 | return CMD_WARNING_CONFIG_FAILED; | |
10572 | } | |
10573 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
10574 | ||
10575 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
10576 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
10577 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10578 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
10579 | } | |
10580 | ||
10581 | ALIAS_HIDDEN( | |
10582 | bgp_redistribute_ipv4_metric_rmap, | |
10583 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
10584 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
10585 | " metric (0-4294967295) route-map WORD", | |
10586 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10587 | "Metric for redistributed routes\n" | |
10588 | "Default metric\n" | |
10589 | "Route map reference\n" | |
10590 | "Pointer to route-map entries\n") | |
596c17ba | 10591 | |
7c8ff89e DS |
10592 | DEFUN (bgp_redistribute_ipv4_ospf, |
10593 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 10594 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
10595 | "Redistribute information from another routing protocol\n" |
10596 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10597 | "Non-main Kernel Routing Table\n" |
10598 | "Instance ID/Table ID\n") | |
7c8ff89e | 10599 | { |
d62a17ae | 10600 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10601 | int idx_ospf_table = 1; | |
10602 | int idx_number = 2; | |
10603 | u_short instance; | |
10604 | u_short protocol; | |
7c8ff89e | 10605 | |
d62a17ae | 10606 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 10607 | |
d62a17ae | 10608 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
10609 | protocol = ZEBRA_ROUTE_OSPF; | |
10610 | else | |
10611 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 10612 | |
d62a17ae | 10613 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
10614 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
10615 | } |
10616 | ||
d62a17ae | 10617 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
10618 | "redistribute <ospf|table> (1-65535)", | |
10619 | "Redistribute information from another routing protocol\n" | |
10620 | "Open Shortest Path First (OSPFv2)\n" | |
10621 | "Non-main Kernel Routing Table\n" | |
10622 | "Instance ID/Table ID\n") | |
596c17ba | 10623 | |
7c8ff89e DS |
10624 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
10625 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 10626 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
10627 | "Redistribute information from another routing protocol\n" |
10628 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10629 | "Non-main Kernel Routing Table\n" |
10630 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10631 | "Route map reference\n" |
10632 | "Pointer to route-map entries\n") | |
10633 | { | |
d62a17ae | 10634 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10635 | int idx_ospf_table = 1; | |
10636 | int idx_number = 2; | |
10637 | int idx_word = 4; | |
10638 | struct bgp_redist *red; | |
10639 | u_short instance; | |
10640 | int protocol; | |
10641 | ||
10642 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10643 | protocol = ZEBRA_ROUTE_OSPF; | |
10644 | else | |
10645 | protocol = ZEBRA_ROUTE_TABLE; | |
10646 | ||
10647 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10648 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
10649 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10650 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
10651 | } | |
10652 | ||
10653 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
10654 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
10655 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
10656 | "Redistribute information from another routing protocol\n" | |
10657 | "Open Shortest Path First (OSPFv2)\n" | |
10658 | "Non-main Kernel Routing Table\n" | |
10659 | "Instance ID/Table ID\n" | |
10660 | "Route map reference\n" | |
10661 | "Pointer to route-map entries\n") | |
596c17ba | 10662 | |
7c8ff89e DS |
10663 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
10664 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 10665 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
10666 | "Redistribute information from another routing protocol\n" |
10667 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10668 | "Non-main Kernel Routing Table\n" |
10669 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10670 | "Metric for redistributed routes\n" |
10671 | "Default metric\n") | |
10672 | { | |
d62a17ae | 10673 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10674 | int idx_ospf_table = 1; | |
10675 | int idx_number = 2; | |
10676 | int idx_number_2 = 4; | |
10677 | u_int32_t metric; | |
10678 | struct bgp_redist *red; | |
10679 | u_short instance; | |
10680 | int protocol; | |
10681 | ||
10682 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10683 | protocol = ZEBRA_ROUTE_OSPF; | |
10684 | else | |
10685 | protocol = ZEBRA_ROUTE_TABLE; | |
10686 | ||
10687 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10688 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
10689 | ||
10690 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
10691 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
10692 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
10693 | } | |
10694 | ||
10695 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
10696 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
10697 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
10698 | "Redistribute information from another routing protocol\n" | |
10699 | "Open Shortest Path First (OSPFv2)\n" | |
10700 | "Non-main Kernel Routing Table\n" | |
10701 | "Instance ID/Table ID\n" | |
10702 | "Metric for redistributed routes\n" | |
10703 | "Default metric\n") | |
596c17ba | 10704 | |
7c8ff89e DS |
10705 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
10706 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 10707 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
10708 | "Redistribute information from another routing protocol\n" |
10709 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10710 | "Non-main Kernel Routing Table\n" |
10711 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10712 | "Route map reference\n" |
10713 | "Pointer to route-map entries\n" | |
10714 | "Metric for redistributed routes\n" | |
10715 | "Default metric\n") | |
10716 | { | |
d62a17ae | 10717 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10718 | int idx_ospf_table = 1; | |
10719 | int idx_number = 2; | |
10720 | int idx_word = 4; | |
10721 | int idx_number_2 = 6; | |
10722 | u_int32_t metric; | |
10723 | struct bgp_redist *red; | |
10724 | u_short instance; | |
10725 | int protocol; | |
10726 | ||
10727 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10728 | protocol = ZEBRA_ROUTE_OSPF; | |
10729 | else | |
10730 | protocol = ZEBRA_ROUTE_TABLE; | |
10731 | ||
10732 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10733 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
10734 | ||
10735 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
10736 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10737 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
10738 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
10739 | } | |
10740 | ||
10741 | ALIAS_HIDDEN( | |
10742 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
10743 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
10744 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
10745 | "Redistribute information from another routing protocol\n" | |
10746 | "Open Shortest Path First (OSPFv2)\n" | |
10747 | "Non-main Kernel Routing Table\n" | |
10748 | "Instance ID/Table ID\n" | |
10749 | "Route map reference\n" | |
10750 | "Pointer to route-map entries\n" | |
10751 | "Metric for redistributed routes\n" | |
10752 | "Default metric\n") | |
596c17ba | 10753 | |
7c8ff89e DS |
10754 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
10755 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 10756 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
10757 | "Redistribute information from another routing protocol\n" |
10758 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10759 | "Non-main Kernel Routing Table\n" |
10760 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10761 | "Metric for redistributed routes\n" |
10762 | "Default metric\n" | |
10763 | "Route map reference\n" | |
10764 | "Pointer to route-map entries\n") | |
10765 | { | |
d62a17ae | 10766 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10767 | int idx_ospf_table = 1; | |
10768 | int idx_number = 2; | |
10769 | int idx_number_2 = 4; | |
10770 | int idx_word = 6; | |
10771 | u_int32_t metric; | |
10772 | struct bgp_redist *red; | |
10773 | u_short instance; | |
10774 | int protocol; | |
10775 | ||
10776 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10777 | protocol = ZEBRA_ROUTE_OSPF; | |
10778 | else | |
10779 | protocol = ZEBRA_ROUTE_TABLE; | |
10780 | ||
10781 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10782 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
10783 | ||
10784 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
10785 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
10786 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10787 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
10788 | } | |
10789 | ||
10790 | ALIAS_HIDDEN( | |
10791 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
10792 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
10793 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
10794 | "Redistribute information from another routing protocol\n" | |
10795 | "Open Shortest Path First (OSPFv2)\n" | |
10796 | "Non-main Kernel Routing Table\n" | |
10797 | "Instance ID/Table ID\n" | |
10798 | "Metric for redistributed routes\n" | |
10799 | "Default metric\n" | |
10800 | "Route map reference\n" | |
10801 | "Pointer to route-map entries\n") | |
596c17ba | 10802 | |
7c8ff89e DS |
10803 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
10804 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 10805 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
10806 | NO_STR |
10807 | "Redistribute information from another routing protocol\n" | |
10808 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 10809 | "Non-main Kernel Routing Table\n" |
31500417 DW |
10810 | "Instance ID/Table ID\n" |
10811 | "Metric for redistributed routes\n" | |
10812 | "Default metric\n" | |
10813 | "Route map reference\n" | |
10814 | "Pointer to route-map entries\n") | |
7c8ff89e | 10815 | { |
d62a17ae | 10816 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10817 | int idx_ospf_table = 2; | |
10818 | int idx_number = 3; | |
10819 | u_short instance; | |
10820 | int protocol; | |
10821 | ||
10822 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10823 | protocol = ZEBRA_ROUTE_OSPF; | |
10824 | else | |
10825 | protocol = ZEBRA_ROUTE_TABLE; | |
10826 | ||
10827 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10828 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
10829 | } | |
10830 | ||
10831 | ALIAS_HIDDEN( | |
10832 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
10833 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", | |
10834 | NO_STR | |
10835 | "Redistribute information from another routing protocol\n" | |
10836 | "Open Shortest Path First (OSPFv2)\n" | |
10837 | "Non-main Kernel Routing Table\n" | |
10838 | "Instance ID/Table ID\n" | |
10839 | "Metric for redistributed routes\n" | |
10840 | "Default metric\n" | |
10841 | "Route map reference\n" | |
10842 | "Pointer to route-map entries\n") | |
596c17ba | 10843 | |
718e3744 | 10844 | DEFUN (no_bgp_redistribute_ipv4, |
10845 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 10846 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 10847 | NO_STR |
10848 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 10849 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
10850 | "Metric for redistributed routes\n" |
10851 | "Default metric\n" | |
10852 | "Route map reference\n" | |
10853 | "Pointer to route-map entries\n") | |
718e3744 | 10854 | { |
d62a17ae | 10855 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10856 | int idx_protocol = 2; | |
10857 | int type; | |
10858 | ||
10859 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
10860 | if (type < 0) { | |
10861 | vty_out(vty, "%% Invalid route type\n"); | |
10862 | return CMD_WARNING_CONFIG_FAILED; | |
10863 | } | |
10864 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
10865 | } | |
10866 | ||
10867 | ALIAS_HIDDEN( | |
10868 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
10869 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
10870 | " [metric (0-4294967295)] [route-map WORD]", | |
10871 | NO_STR | |
10872 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10873 | "Metric for redistributed routes\n" | |
10874 | "Default metric\n" | |
10875 | "Route map reference\n" | |
10876 | "Pointer to route-map entries\n") | |
596c17ba | 10877 | |
718e3744 | 10878 | DEFUN (bgp_redistribute_ipv6, |
10879 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 10880 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 10881 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10882 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 10883 | { |
d62a17ae | 10884 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10885 | int idx_protocol = 1; | |
10886 | int type; | |
718e3744 | 10887 | |
d62a17ae | 10888 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
10889 | if (type < 0) { | |
10890 | vty_out(vty, "%% Invalid route type\n"); | |
10891 | return CMD_WARNING_CONFIG_FAILED; | |
10892 | } | |
718e3744 | 10893 | |
d62a17ae | 10894 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
10895 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 10896 | } |
10897 | ||
10898 | DEFUN (bgp_redistribute_ipv6_rmap, | |
10899 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 10900 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 10901 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10902 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 10903 | "Route map reference\n" |
10904 | "Pointer to route-map entries\n") | |
10905 | { | |
d62a17ae | 10906 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10907 | int idx_protocol = 1; | |
10908 | int idx_word = 3; | |
10909 | int type; | |
10910 | struct bgp_redist *red; | |
718e3744 | 10911 | |
d62a17ae | 10912 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
10913 | if (type < 0) { | |
10914 | vty_out(vty, "%% Invalid route type\n"); | |
10915 | return CMD_WARNING_CONFIG_FAILED; | |
10916 | } | |
718e3744 | 10917 | |
d62a17ae | 10918 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
10919 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10920 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 10921 | } |
10922 | ||
10923 | DEFUN (bgp_redistribute_ipv6_metric, | |
10924 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 10925 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 10926 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10927 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 10928 | "Metric for redistributed routes\n" |
10929 | "Default metric\n") | |
10930 | { | |
d62a17ae | 10931 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10932 | int idx_protocol = 1; | |
10933 | int idx_number = 3; | |
10934 | int type; | |
10935 | u_int32_t metric; | |
10936 | struct bgp_redist *red; | |
10937 | ||
10938 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
10939 | if (type < 0) { | |
10940 | vty_out(vty, "%% Invalid route type\n"); | |
10941 | return CMD_WARNING_CONFIG_FAILED; | |
10942 | } | |
10943 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 10944 | |
d62a17ae | 10945 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
10946 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
10947 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 10948 | } |
10949 | ||
10950 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
10951 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 10952 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 10953 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10954 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 10955 | "Route map reference\n" |
10956 | "Pointer to route-map entries\n" | |
10957 | "Metric for redistributed routes\n" | |
10958 | "Default metric\n") | |
10959 | { | |
d62a17ae | 10960 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10961 | int idx_protocol = 1; | |
10962 | int idx_word = 3; | |
10963 | int idx_number = 5; | |
10964 | int type; | |
10965 | u_int32_t metric; | |
10966 | struct bgp_redist *red; | |
10967 | ||
10968 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
10969 | if (type < 0) { | |
10970 | vty_out(vty, "%% Invalid route type\n"); | |
10971 | return CMD_WARNING_CONFIG_FAILED; | |
10972 | } | |
10973 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 10974 | |
d62a17ae | 10975 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
10976 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10977 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
10978 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 10979 | } |
10980 | ||
10981 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
10982 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 10983 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 10984 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10985 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 10986 | "Metric for redistributed routes\n" |
10987 | "Default metric\n" | |
10988 | "Route map reference\n" | |
10989 | "Pointer to route-map entries\n") | |
10990 | { | |
d62a17ae | 10991 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10992 | int idx_protocol = 1; | |
10993 | int idx_number = 3; | |
10994 | int idx_word = 5; | |
10995 | int type; | |
10996 | u_int32_t metric; | |
10997 | struct bgp_redist *red; | |
10998 | ||
10999 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
11000 | if (type < 0) { | |
11001 | vty_out(vty, "%% Invalid route type\n"); | |
11002 | return CMD_WARNING_CONFIG_FAILED; | |
11003 | } | |
11004 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 11005 | |
d62a17ae | 11006 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11007 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric); | |
11008 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11009 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11010 | } |
11011 | ||
11012 | DEFUN (no_bgp_redistribute_ipv6, | |
11013 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 11014 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 11015 | NO_STR |
11016 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 11017 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
11018 | "Metric for redistributed routes\n" |
11019 | "Default metric\n" | |
11020 | "Route map reference\n" | |
11021 | "Pointer to route-map entries\n") | |
718e3744 | 11022 | { |
d62a17ae | 11023 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11024 | int idx_protocol = 2; | |
11025 | int type; | |
718e3744 | 11026 | |
d62a17ae | 11027 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
11028 | if (type < 0) { | |
11029 | vty_out(vty, "%% Invalid route type\n"); | |
11030 | return CMD_WARNING_CONFIG_FAILED; | |
11031 | } | |
718e3744 | 11032 | |
d62a17ae | 11033 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
11034 | } | |
11035 | ||
11036 | int bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi, | |
11037 | safi_t safi, int *write) | |
11038 | { | |
11039 | int i; | |
11040 | ||
11041 | /* Unicast redistribution only. */ | |
11042 | if (safi != SAFI_UNICAST) | |
11043 | return 0; | |
11044 | ||
11045 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
11046 | /* Redistribute BGP does not make sense. */ | |
11047 | if (i != ZEBRA_ROUTE_BGP) { | |
11048 | struct list *red_list; | |
11049 | struct listnode *node; | |
11050 | struct bgp_redist *red; | |
11051 | ||
11052 | red_list = bgp->redist[afi][i]; | |
11053 | if (!red_list) | |
11054 | continue; | |
11055 | ||
11056 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
11057 | /* Display "address-family" when it is not yet | |
11058 | * diplayed. */ | |
11059 | bgp_config_write_family_header(vty, afi, safi, | |
11060 | write); | |
11061 | ||
11062 | /* "redistribute" configuration. */ | |
11063 | vty_out(vty, " redistribute %s", | |
11064 | zebra_route_string(i)); | |
11065 | if (red->instance) | |
11066 | vty_out(vty, " %d", red->instance); | |
11067 | if (red->redist_metric_flag) | |
11068 | vty_out(vty, " metric %u", | |
11069 | red->redist_metric); | |
11070 | if (red->rmap.name) | |
11071 | vty_out(vty, " route-map %s", | |
11072 | red->rmap.name); | |
11073 | vty_out(vty, "\n"); | |
11074 | } | |
11075 | } | |
11076 | } | |
11077 | return *write; | |
718e3744 | 11078 | } |
6b0655a2 | 11079 | |
718e3744 | 11080 | /* BGP node structure. */ |
d62a17ae | 11081 | static struct cmd_node bgp_node = { |
9d303b37 | 11082 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 11083 | }; |
11084 | ||
d62a17ae | 11085 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 11086 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 11087 | }; |
11088 | ||
d62a17ae | 11089 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 11090 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 11091 | }; |
11092 | ||
d62a17ae | 11093 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 11094 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
11095 | }; |
11096 | ||
d62a17ae | 11097 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 11098 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 11099 | }; |
11100 | ||
d62a17ae | 11101 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 11102 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 11103 | }; |
11104 | ||
d62a17ae | 11105 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 11106 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
11107 | }; |
11108 | ||
d62a17ae | 11109 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
11110 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 11111 | |
d62a17ae | 11112 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
11113 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 11114 | |
d62a17ae | 11115 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
11116 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 11117 | |
d62a17ae | 11118 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
11119 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 11120 | |
d62a17ae | 11121 | static void community_list_vty(void); |
1f8ae70b | 11122 | |
d62a17ae | 11123 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 11124 | { |
d62a17ae | 11125 | struct bgp *bgp; |
11126 | struct peer *peer; | |
11127 | struct peer_group *group; | |
11128 | struct listnode *lnbgp, *lnpeer; | |
b8a815e5 | 11129 | |
d62a17ae | 11130 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
11131 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
11132 | /* only provide suggestions on the appropriate input | |
11133 | * token type, | |
11134 | * they'll otherwise show up multiple times */ | |
11135 | enum cmd_token_type match_type; | |
11136 | char *name = peer->host; | |
d48ed3e0 | 11137 | |
d62a17ae | 11138 | if (peer->conf_if) { |
11139 | match_type = VARIABLE_TKN; | |
11140 | name = peer->conf_if; | |
11141 | } else if (strchr(peer->host, ':')) | |
11142 | match_type = IPV6_TKN; | |
11143 | else | |
11144 | match_type = IPV4_TKN; | |
d48ed3e0 | 11145 | |
d62a17ae | 11146 | if (token->type != match_type) |
11147 | continue; | |
d48ed3e0 | 11148 | |
d62a17ae | 11149 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
11150 | } | |
d48ed3e0 | 11151 | |
d62a17ae | 11152 | if (token->type == VARIABLE_TKN) |
11153 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
11154 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
11155 | group->name)); | |
11156 | } | |
b8a815e5 DL |
11157 | } |
11158 | ||
11159 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 11160 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
11161 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
11162 | {.completions = NULL}}; | |
11163 | ||
11164 | void bgp_vty_init(void) | |
11165 | { | |
11166 | cmd_variable_handler_register(bgp_var_neighbor); | |
11167 | ||
11168 | /* Install bgp top node. */ | |
11169 | install_node(&bgp_node, bgp_config_write); | |
11170 | install_node(&bgp_ipv4_unicast_node, NULL); | |
11171 | install_node(&bgp_ipv4_multicast_node, NULL); | |
11172 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
11173 | install_node(&bgp_ipv6_unicast_node, NULL); | |
11174 | install_node(&bgp_ipv6_multicast_node, NULL); | |
11175 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
11176 | install_node(&bgp_vpnv4_node, NULL); | |
11177 | install_node(&bgp_vpnv6_node, NULL); | |
11178 | install_node(&bgp_evpn_node, NULL); | |
11179 | install_node(&bgp_evpn_vni_node, NULL); | |
11180 | ||
11181 | /* Install default VTY commands to new nodes. */ | |
11182 | install_default(BGP_NODE); | |
11183 | install_default(BGP_IPV4_NODE); | |
11184 | install_default(BGP_IPV4M_NODE); | |
11185 | install_default(BGP_IPV4L_NODE); | |
11186 | install_default(BGP_IPV6_NODE); | |
11187 | install_default(BGP_IPV6M_NODE); | |
11188 | install_default(BGP_IPV6L_NODE); | |
11189 | install_default(BGP_VPNV4_NODE); | |
11190 | install_default(BGP_VPNV6_NODE); | |
11191 | install_default(BGP_EVPN_NODE); | |
11192 | install_default(BGP_EVPN_VNI_NODE); | |
11193 | ||
11194 | /* "bgp multiple-instance" commands. */ | |
11195 | install_element(CONFIG_NODE, &bgp_multiple_instance_cmd); | |
11196 | install_element(CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
11197 | ||
11198 | /* "bgp config-type" commands. */ | |
11199 | install_element(CONFIG_NODE, &bgp_config_type_cmd); | |
11200 | install_element(CONFIG_NODE, &no_bgp_config_type_cmd); | |
11201 | ||
11202 | /* bgp route-map delay-timer commands. */ | |
11203 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
11204 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
11205 | ||
11206 | /* Dummy commands (Currently not supported) */ | |
11207 | install_element(BGP_NODE, &no_synchronization_cmd); | |
11208 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
11209 | ||
11210 | /* "router bgp" commands. */ | |
11211 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
11212 | ||
11213 | /* "no router bgp" commands. */ | |
11214 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
11215 | ||
11216 | /* "bgp router-id" commands. */ | |
11217 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
11218 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
11219 | ||
11220 | /* "bgp cluster-id" commands. */ | |
11221 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
11222 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
11223 | ||
11224 | /* "bgp confederation" commands. */ | |
11225 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
11226 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
11227 | ||
11228 | /* "bgp confederation peers" commands. */ | |
11229 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
11230 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
11231 | ||
11232 | /* bgp max-med command */ | |
11233 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
11234 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
11235 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
11236 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
11237 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
11238 | ||
11239 | /* bgp disable-ebgp-connected-nh-check */ | |
11240 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
11241 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
11242 | ||
11243 | /* bgp update-delay command */ | |
11244 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
11245 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
11246 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
11247 | ||
11248 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
11249 | install_element(BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
11250 | ||
11251 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
11252 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
11253 | ||
11254 | /* "maximum-paths" commands. */ | |
11255 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
11256 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
11257 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
11258 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
11259 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
11260 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
11261 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
11262 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
11263 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
11264 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
11265 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
11266 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
11267 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
11268 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
11269 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
11270 | ||
11271 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
11272 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
11273 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
11274 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
11275 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
11276 | ||
11277 | /* "timers bgp" commands. */ | |
11278 | install_element(BGP_NODE, &bgp_timers_cmd); | |
11279 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
11280 | ||
11281 | /* route-map delay-timer commands - per instance for backwards compat. | |
11282 | */ | |
11283 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
11284 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
11285 | ||
11286 | /* "bgp client-to-client reflection" commands */ | |
11287 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
11288 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
11289 | ||
11290 | /* "bgp always-compare-med" commands */ | |
11291 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
11292 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
11293 | ||
11294 | /* "bgp deterministic-med" commands */ | |
11295 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
11296 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
11297 | ||
11298 | /* "bgp graceful-restart" commands */ | |
11299 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); | |
11300 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
11301 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); | |
11302 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
11303 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
11304 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
11305 | ||
11306 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); | |
11307 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
11308 | ||
11309 | /* "bgp fast-external-failover" commands */ | |
11310 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
11311 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
11312 | ||
11313 | /* "bgp enforce-first-as" commands */ | |
11314 | install_element(BGP_NODE, &bgp_enforce_first_as_cmd); | |
11315 | install_element(BGP_NODE, &no_bgp_enforce_first_as_cmd); | |
11316 | ||
11317 | /* "bgp bestpath compare-routerid" commands */ | |
11318 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
11319 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
11320 | ||
11321 | /* "bgp bestpath as-path ignore" commands */ | |
11322 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
11323 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
11324 | ||
11325 | /* "bgp bestpath as-path confed" commands */ | |
11326 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
11327 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
11328 | ||
11329 | /* "bgp bestpath as-path multipath-relax" commands */ | |
11330 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
11331 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
11332 | ||
11333 | /* "bgp log-neighbor-changes" commands */ | |
11334 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
11335 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
11336 | ||
11337 | /* "bgp bestpath med" commands */ | |
11338 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
11339 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
11340 | ||
11341 | /* "no bgp default ipv4-unicast" commands. */ | |
11342 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
11343 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
11344 | ||
11345 | /* "bgp network import-check" commands. */ | |
11346 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
11347 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
11348 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
11349 | ||
11350 | /* "bgp default local-preference" commands. */ | |
11351 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
11352 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
11353 | ||
11354 | /* bgp default show-hostname */ | |
11355 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
11356 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
11357 | ||
11358 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
11359 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
11360 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
11361 | ||
11362 | /* bgp ibgp-allow-policy-mods command */ | |
11363 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
11364 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
11365 | ||
11366 | /* "bgp listen limit" commands. */ | |
11367 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
11368 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
11369 | ||
11370 | /* "bgp listen range" commands. */ | |
11371 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
11372 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
11373 | ||
11374 | /* "neighbor remote-as" commands. */ | |
11375 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
11376 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
11377 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
11378 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
11379 | install_element(BGP_NODE, | |
11380 | &neighbor_interface_v6only_config_remote_as_cmd); | |
11381 | install_element(BGP_NODE, &no_neighbor_cmd); | |
11382 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
11383 | ||
11384 | /* "neighbor peer-group" commands. */ | |
11385 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
11386 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
11387 | install_element(BGP_NODE, | |
11388 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
11389 | ||
11390 | /* "neighbor local-as" commands. */ | |
11391 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
11392 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
11393 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
11394 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
11395 | ||
11396 | /* "neighbor solo" commands. */ | |
11397 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
11398 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
11399 | ||
11400 | /* "neighbor password" commands. */ | |
11401 | install_element(BGP_NODE, &neighbor_password_cmd); | |
11402 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
11403 | ||
11404 | /* "neighbor activate" commands. */ | |
11405 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
11406 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
11407 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
11408 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
11409 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
11410 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
11411 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
11412 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
11413 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
11414 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); | |
11415 | ||
11416 | /* "no neighbor activate" commands. */ | |
11417 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
11418 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
11419 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
11420 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
11421 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
11422 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
11423 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
11424 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
11425 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
11426 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); | |
11427 | ||
11428 | /* "neighbor peer-group" set commands. */ | |
11429 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
11430 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11431 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11432 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11433 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11434 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11435 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11436 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11437 | ||
11438 | /* "no neighbor peer-group unset" commands. */ | |
11439 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
11440 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11441 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11442 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11443 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11444 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11445 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11446 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11447 | ||
11448 | /* "neighbor softreconfiguration inbound" commands.*/ | |
11449 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
11450 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
11451 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
11452 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11453 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
11454 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11455 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
11456 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11457 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
11458 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11459 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
11460 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11461 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
11462 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11463 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
11464 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11465 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
11466 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11467 | ||
11468 | /* "neighbor attribute-unchanged" commands. */ | |
11469 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
11470 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
11471 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
11472 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
11473 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
11474 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
11475 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
11476 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
11477 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
11478 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
11479 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
11480 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
11481 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
11482 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
11483 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
11484 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
11485 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
11486 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
11487 | ||
11488 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
11489 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
11490 | ||
11491 | /* "nexthop-local unchanged" commands */ | |
11492 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
11493 | install_element(BGP_IPV6_NODE, | |
11494 | &no_neighbor_nexthop_local_unchanged_cmd); | |
11495 | ||
11496 | /* "neighbor next-hop-self" commands. */ | |
11497 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
11498 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
11499 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
11500 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
11501 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
11502 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
11503 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
11504 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
11505 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
11506 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
11507 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
11508 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
11509 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
11510 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
11511 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
11512 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
11513 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
11514 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
11515 | ||
11516 | /* "neighbor next-hop-self force" commands. */ | |
11517 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
11518 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
11519 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
11520 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11521 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
11522 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11523 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); | |
11524 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11525 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
11526 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11527 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
11528 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11529 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); | |
11530 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11531 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
11532 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11533 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); | |
11534 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11535 | ||
11536 | /* "neighbor as-override" commands. */ | |
11537 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
11538 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
11539 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
11540 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
11541 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
11542 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
11543 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
11544 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
11545 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
11546 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
11547 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
11548 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
11549 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
11550 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
11551 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
11552 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
11553 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
11554 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
11555 | ||
11556 | /* "neighbor remove-private-AS" commands. */ | |
11557 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
11558 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
11559 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
11560 | install_element(BGP_NODE, | |
11561 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
11562 | install_element(BGP_NODE, | |
11563 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
11564 | install_element(BGP_NODE, | |
11565 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
11566 | install_element(BGP_NODE, | |
11567 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
11568 | install_element( | |
11569 | BGP_NODE, | |
11570 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
11571 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
11572 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
11573 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
11574 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11575 | install_element(BGP_IPV4_NODE, | |
11576 | &neighbor_remove_private_as_replace_as_cmd); | |
11577 | install_element(BGP_IPV4_NODE, | |
11578 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11579 | install_element(BGP_IPV4_NODE, | |
11580 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11581 | install_element(BGP_IPV4_NODE, | |
11582 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11583 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
11584 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
11585 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
11586 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11587 | install_element(BGP_IPV4M_NODE, | |
11588 | &neighbor_remove_private_as_replace_as_cmd); | |
11589 | install_element(BGP_IPV4M_NODE, | |
11590 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11591 | install_element(BGP_IPV4M_NODE, | |
11592 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11593 | install_element(BGP_IPV4M_NODE, | |
11594 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11595 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
11596 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
11597 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
11598 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11599 | install_element(BGP_IPV4L_NODE, | |
11600 | &neighbor_remove_private_as_replace_as_cmd); | |
11601 | install_element(BGP_IPV4L_NODE, | |
11602 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11603 | install_element(BGP_IPV4L_NODE, | |
11604 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11605 | install_element(BGP_IPV4L_NODE, | |
11606 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11607 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
11608 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
11609 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
11610 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11611 | install_element(BGP_IPV6_NODE, | |
11612 | &neighbor_remove_private_as_replace_as_cmd); | |
11613 | install_element(BGP_IPV6_NODE, | |
11614 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11615 | install_element(BGP_IPV6_NODE, | |
11616 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11617 | install_element(BGP_IPV6_NODE, | |
11618 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11619 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
11620 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
11621 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
11622 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11623 | install_element(BGP_IPV6M_NODE, | |
11624 | &neighbor_remove_private_as_replace_as_cmd); | |
11625 | install_element(BGP_IPV6M_NODE, | |
11626 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11627 | install_element(BGP_IPV6M_NODE, | |
11628 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11629 | install_element(BGP_IPV6M_NODE, | |
11630 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11631 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
11632 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
11633 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
11634 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11635 | install_element(BGP_IPV6L_NODE, | |
11636 | &neighbor_remove_private_as_replace_as_cmd); | |
11637 | install_element(BGP_IPV6L_NODE, | |
11638 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11639 | install_element(BGP_IPV6L_NODE, | |
11640 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11641 | install_element(BGP_IPV6L_NODE, | |
11642 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11643 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
11644 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
11645 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
11646 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11647 | install_element(BGP_VPNV4_NODE, | |
11648 | &neighbor_remove_private_as_replace_as_cmd); | |
11649 | install_element(BGP_VPNV4_NODE, | |
11650 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11651 | install_element(BGP_VPNV4_NODE, | |
11652 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11653 | install_element(BGP_VPNV4_NODE, | |
11654 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11655 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
11656 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
11657 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
11658 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11659 | install_element(BGP_VPNV6_NODE, | |
11660 | &neighbor_remove_private_as_replace_as_cmd); | |
11661 | install_element(BGP_VPNV6_NODE, | |
11662 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11663 | install_element(BGP_VPNV6_NODE, | |
11664 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11665 | install_element(BGP_VPNV6_NODE, | |
11666 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11667 | ||
11668 | /* "neighbor send-community" commands.*/ | |
11669 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
11670 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
11671 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
11672 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
11673 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
11674 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
11675 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
11676 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
11677 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
11678 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
11679 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
11680 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
11681 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
11682 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
11683 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
11684 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
11685 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
11686 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
11687 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
11688 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
11689 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
11690 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
11691 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
11692 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
11693 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
11694 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
11695 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
11696 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
11697 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
11698 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
11699 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
11700 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
11701 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
11702 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
11703 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
11704 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
11705 | ||
11706 | /* "neighbor route-reflector" commands.*/ | |
11707 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
11708 | install_element(BGP_NODE, | |
11709 | &no_neighbor_route_reflector_client_hidden_cmd); | |
11710 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
11711 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
11712 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
11713 | install_element(BGP_IPV4M_NODE, | |
11714 | &no_neighbor_route_reflector_client_cmd); | |
11715 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
11716 | install_element(BGP_IPV4L_NODE, | |
11717 | &no_neighbor_route_reflector_client_cmd); | |
11718 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
11719 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
11720 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
11721 | install_element(BGP_IPV6M_NODE, | |
11722 | &no_neighbor_route_reflector_client_cmd); | |
11723 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
11724 | install_element(BGP_IPV6L_NODE, | |
11725 | &no_neighbor_route_reflector_client_cmd); | |
11726 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
11727 | install_element(BGP_VPNV4_NODE, | |
11728 | &no_neighbor_route_reflector_client_cmd); | |
11729 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
11730 | install_element(BGP_VPNV6_NODE, | |
11731 | &no_neighbor_route_reflector_client_cmd); | |
11732 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); | |
11733 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
11734 | ||
11735 | /* "neighbor route-server" commands.*/ | |
11736 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
11737 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
11738 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
11739 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
11740 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
11741 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
11742 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
11743 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
11744 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
11745 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
11746 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
11747 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
11748 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
11749 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
11750 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
11751 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
11752 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
11753 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
11754 | ||
11755 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
11756 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
11757 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
11758 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11759 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11760 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11761 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11762 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11763 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11764 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11765 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11766 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11767 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11768 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11769 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11770 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11771 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11772 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11773 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11774 | ||
11775 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
11776 | install_element(BGP_NODE, | |
11777 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
11778 | install_element(BGP_NODE, | |
11779 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
11780 | install_element(BGP_IPV4_NODE, | |
11781 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11782 | install_element(BGP_IPV4_NODE, | |
11783 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11784 | install_element(BGP_IPV4M_NODE, | |
11785 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11786 | install_element(BGP_IPV4M_NODE, | |
11787 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11788 | install_element(BGP_IPV4L_NODE, | |
11789 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11790 | install_element(BGP_IPV4L_NODE, | |
11791 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11792 | install_element(BGP_IPV6_NODE, | |
11793 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11794 | install_element(BGP_IPV6_NODE, | |
11795 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11796 | install_element(BGP_IPV6M_NODE, | |
11797 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11798 | install_element(BGP_IPV6M_NODE, | |
11799 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11800 | install_element(BGP_IPV6L_NODE, | |
11801 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11802 | install_element(BGP_IPV6L_NODE, | |
11803 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11804 | install_element(BGP_VPNV4_NODE, | |
11805 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11806 | install_element(BGP_VPNV4_NODE, | |
11807 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11808 | install_element(BGP_VPNV6_NODE, | |
11809 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11810 | install_element(BGP_VPNV6_NODE, | |
11811 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11812 | ||
11813 | /* "neighbor passive" commands. */ | |
11814 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
11815 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
11816 | ||
11817 | ||
11818 | /* "neighbor shutdown" commands. */ | |
11819 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
11820 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
11821 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
11822 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
11823 | ||
11824 | /* "neighbor capability extended-nexthop" commands.*/ | |
11825 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
11826 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
11827 | ||
11828 | /* "neighbor capability orf prefix-list" commands.*/ | |
11829 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
11830 | install_element(BGP_NODE, | |
11831 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
11832 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
11833 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11834 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
11835 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11836 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
11837 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11838 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
11839 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11840 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
11841 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11842 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
11843 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11844 | ||
11845 | /* "neighbor capability dynamic" commands.*/ | |
11846 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
11847 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
11848 | ||
11849 | /* "neighbor dont-capability-negotiate" commands. */ | |
11850 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
11851 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
11852 | ||
11853 | /* "neighbor ebgp-multihop" commands. */ | |
11854 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
11855 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
11856 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
11857 | ||
11858 | /* "neighbor disable-connected-check" commands. */ | |
11859 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
11860 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
11861 | ||
11862 | /* "neighbor description" commands. */ | |
11863 | install_element(BGP_NODE, &neighbor_description_cmd); | |
11864 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
11865 | ||
11866 | /* "neighbor update-source" commands. "*/ | |
11867 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
11868 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
11869 | ||
11870 | /* "neighbor default-originate" commands. */ | |
11871 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
11872 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
11873 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
11874 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
11875 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
11876 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
11877 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
11878 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
11879 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
11880 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
11881 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
11882 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
11883 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
11884 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
11885 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
11886 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
11887 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
11888 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
11889 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
11890 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
11891 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
11892 | ||
11893 | /* "neighbor port" commands. */ | |
11894 | install_element(BGP_NODE, &neighbor_port_cmd); | |
11895 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
11896 | ||
11897 | /* "neighbor weight" commands. */ | |
11898 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
11899 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
11900 | ||
11901 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
11902 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
11903 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
11904 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
11905 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
11906 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
11907 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
11908 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
11909 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
11910 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
11911 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
11912 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
11913 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
11914 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
11915 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
11916 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
11917 | ||
11918 | /* "neighbor override-capability" commands. */ | |
11919 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
11920 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
11921 | ||
11922 | /* "neighbor strict-capability-match" commands. */ | |
11923 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
11924 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
11925 | ||
11926 | /* "neighbor timers" commands. */ | |
11927 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
11928 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
11929 | ||
11930 | /* "neighbor timers connect" commands. */ | |
11931 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
11932 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
11933 | ||
11934 | /* "neighbor advertisement-interval" commands. */ | |
11935 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
11936 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
11937 | ||
11938 | /* "neighbor interface" commands. */ | |
11939 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
11940 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
11941 | ||
11942 | /* "neighbor distribute" commands. */ | |
11943 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
11944 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
11945 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
11946 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
11947 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
11948 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
11949 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
11950 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
11951 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
11952 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
11953 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
11954 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
11955 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
11956 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
11957 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
11958 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
11959 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
11960 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
11961 | ||
11962 | /* "neighbor prefix-list" commands. */ | |
11963 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
11964 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
11965 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
11966 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
11967 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
11968 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
11969 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
11970 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
11971 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
11972 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
11973 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
11974 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
11975 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
11976 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
11977 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
11978 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
11979 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
11980 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
11981 | ||
11982 | /* "neighbor filter-list" commands. */ | |
11983 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
11984 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
11985 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
11986 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
11987 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
11988 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
11989 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
11990 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
11991 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
11992 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
11993 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
11994 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
11995 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
11996 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
11997 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
11998 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
11999 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
12000 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
12001 | ||
12002 | /* "neighbor route-map" commands. */ | |
12003 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
12004 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
12005 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
12006 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
12007 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
12008 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
12009 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
12010 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
12011 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
12012 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
12013 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
12014 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
12015 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
12016 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
12017 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
12018 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
12019 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
12020 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
12021 | ||
12022 | /* "neighbor unsuppress-map" commands. */ | |
12023 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
12024 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
12025 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
12026 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
12027 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
12028 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
12029 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
12030 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
12031 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
12032 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
12033 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
12034 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
12035 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
12036 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
12037 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
12038 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
12039 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
12040 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
12041 | ||
12042 | /* "neighbor maximum-prefix" commands. */ | |
12043 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
12044 | install_element(BGP_NODE, | |
12045 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
12046 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
12047 | install_element(BGP_NODE, | |
12048 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
12049 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
12050 | install_element(BGP_NODE, | |
12051 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
12052 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
12053 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
12054 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12055 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12056 | install_element(BGP_IPV4_NODE, | |
12057 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12058 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12059 | install_element(BGP_IPV4_NODE, | |
12060 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12061 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
12062 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
12063 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12064 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12065 | install_element(BGP_IPV4M_NODE, | |
12066 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12067 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12068 | install_element(BGP_IPV4M_NODE, | |
12069 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12070 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
12071 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
12072 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12073 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12074 | install_element(BGP_IPV4L_NODE, | |
12075 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12076 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12077 | install_element(BGP_IPV4L_NODE, | |
12078 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12079 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
12080 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
12081 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12082 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12083 | install_element(BGP_IPV6_NODE, | |
12084 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12085 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12086 | install_element(BGP_IPV6_NODE, | |
12087 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12088 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
12089 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
12090 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12091 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12092 | install_element(BGP_IPV6M_NODE, | |
12093 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12094 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12095 | install_element(BGP_IPV6M_NODE, | |
12096 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12097 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
12098 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
12099 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12100 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12101 | install_element(BGP_IPV6L_NODE, | |
12102 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12103 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12104 | install_element(BGP_IPV6L_NODE, | |
12105 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12106 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
12107 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
12108 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12109 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12110 | install_element(BGP_VPNV4_NODE, | |
12111 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12112 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12113 | install_element(BGP_VPNV4_NODE, | |
12114 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12115 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
12116 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
12117 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12118 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12119 | install_element(BGP_VPNV6_NODE, | |
12120 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12121 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12122 | install_element(BGP_VPNV6_NODE, | |
12123 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12124 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
12125 | ||
12126 | /* "neighbor allowas-in" */ | |
12127 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
12128 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
12129 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
12130 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
12131 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
12132 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
12133 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
12134 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
12135 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
12136 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
12137 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
12138 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
12139 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
12140 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
12141 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
12142 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
12143 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
12144 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
12145 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
12146 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
12147 | ||
12148 | /* address-family commands. */ | |
12149 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
12150 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 12151 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 12152 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
12153 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 12154 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 12155 | |
d62a17ae | 12156 | install_element(BGP_NODE, &address_family_evpn_cmd); |
12157 | ||
12158 | /* "exit-address-family" command. */ | |
12159 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
12160 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
12161 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
12162 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
12163 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
12164 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
12165 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
12166 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
12167 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); | |
12168 | ||
12169 | /* "clear ip bgp commands" */ | |
12170 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
12171 | ||
12172 | /* clear ip bgp prefix */ | |
12173 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
12174 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
12175 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
12176 | ||
12177 | /* "show [ip] bgp summary" commands. */ | |
12178 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
12179 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd); | |
12180 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); | |
12181 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); | |
12182 | install_element(VIEW_NODE, &show_bgp_updgrps_adj_cmd); | |
12183 | install_element(VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); | |
12184 | install_element(VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); | |
12185 | install_element(VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); | |
12186 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); | |
12187 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); | |
12188 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); | |
12189 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
12190 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); | |
12191 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); | |
12192 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); | |
12193 | ||
12194 | /* "show [ip] bgp neighbors" commands. */ | |
12195 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
12196 | ||
12197 | /* "show [ip] bgp peer-group" commands. */ | |
12198 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
12199 | ||
12200 | /* "show [ip] bgp paths" commands. */ | |
12201 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
12202 | ||
12203 | /* "show [ip] bgp community" commands. */ | |
12204 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
12205 | ||
12206 | /* "show ip bgp large-community" commands. */ | |
12207 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
12208 | /* "show [ip] bgp attribute-info" commands. */ | |
12209 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
12210 | ||
12211 | /* "redistribute" commands. */ | |
12212 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
12213 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
12214 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
12215 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
12216 | install_element(BGP_NODE, | |
12217 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
12218 | install_element(BGP_NODE, | |
12219 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
12220 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
12221 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
12222 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
12223 | install_element(BGP_NODE, | |
12224 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
12225 | install_element(BGP_NODE, | |
12226 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
12227 | install_element(BGP_NODE, | |
12228 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
12229 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
12230 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
12231 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
12232 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
12233 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
12234 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
12235 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
12236 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
12237 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
12238 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
12239 | install_element(BGP_IPV4_NODE, | |
12240 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
12241 | install_element(BGP_IPV4_NODE, | |
12242 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
12243 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
12244 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
12245 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
12246 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
12247 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
12248 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
12249 | ||
12250 | /* ttl_security commands */ | |
12251 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
12252 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
12253 | ||
12254 | /* "show [ip] bgp memory" commands. */ | |
12255 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
12256 | ||
12257 | /* "show [ip] bgp views" commands. */ | |
12258 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
12259 | ||
12260 | /* "show [ip] bgp vrfs" commands. */ | |
12261 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
12262 | ||
12263 | /* Community-list. */ | |
12264 | community_list_vty(); | |
718e3744 | 12265 | } |
6b0655a2 | 12266 | |
718e3744 | 12267 | #include "memory.h" |
12268 | #include "bgp_regex.h" | |
12269 | #include "bgp_clist.h" | |
12270 | #include "bgp_ecommunity.h" | |
12271 | ||
12272 | /* VTY functions. */ | |
12273 | ||
12274 | /* Direction value to string conversion. */ | |
d62a17ae | 12275 | static const char *community_direct_str(int direct) |
12276 | { | |
12277 | switch (direct) { | |
12278 | case COMMUNITY_DENY: | |
12279 | return "deny"; | |
12280 | case COMMUNITY_PERMIT: | |
12281 | return "permit"; | |
12282 | default: | |
12283 | return "unknown"; | |
12284 | } | |
718e3744 | 12285 | } |
12286 | ||
12287 | /* Display error string. */ | |
d62a17ae | 12288 | static void community_list_perror(struct vty *vty, int ret) |
12289 | { | |
12290 | switch (ret) { | |
12291 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
12292 | vty_out(vty, "%% Can't find community-list\n"); | |
12293 | break; | |
12294 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
12295 | vty_out(vty, "%% Malformed community-list value\n"); | |
12296 | break; | |
12297 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
12298 | vty_out(vty, | |
12299 | "%% Community name conflict, previously defined as standard community\n"); | |
12300 | break; | |
12301 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
12302 | vty_out(vty, | |
12303 | "%% Community name conflict, previously defined as expanded community\n"); | |
12304 | break; | |
12305 | } | |
718e3744 | 12306 | } |
12307 | ||
5bf15956 DW |
12308 | /* "community-list" keyword help string. */ |
12309 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
12310 | ||
5bf15956 | 12311 | /* ip community-list standard */ |
718e3744 | 12312 | DEFUN (ip_community_list_standard, |
12313 | ip_community_list_standard_cmd, | |
e961923c | 12314 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 12315 | IP_STR |
12316 | COMMUNITY_LIST_STR | |
12317 | "Community list number (standard)\n" | |
5bf15956 | 12318 | "Add an standard community-list entry\n" |
718e3744 | 12319 | "Community list name\n" |
12320 | "Specify community to reject\n" | |
12321 | "Specify community to accept\n" | |
12322 | COMMUNITY_VAL_STR) | |
12323 | { | |
d62a17ae | 12324 | char *cl_name_or_number = NULL; |
12325 | int direct = 0; | |
12326 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 12327 | |
d62a17ae | 12328 | int idx = 0; |
12329 | argv_find(argv, argc, "(1-99)", &idx); | |
12330 | argv_find(argv, argc, "WORD", &idx); | |
12331 | cl_name_or_number = argv[idx]->arg; | |
12332 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12333 | : COMMUNITY_DENY; | |
12334 | argv_find(argv, argc, "AA:NN", &idx); | |
12335 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12336 | |
d62a17ae | 12337 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
12338 | style); | |
42f914d4 | 12339 | |
d62a17ae | 12340 | XFREE(MTYPE_TMP, str); |
42f914d4 | 12341 | |
d62a17ae | 12342 | if (ret < 0) { |
12343 | /* Display error string. */ | |
12344 | community_list_perror(vty, ret); | |
12345 | return CMD_WARNING_CONFIG_FAILED; | |
12346 | } | |
42f914d4 | 12347 | |
d62a17ae | 12348 | return CMD_SUCCESS; |
718e3744 | 12349 | } |
12350 | ||
fee6e4e4 | 12351 | DEFUN (no_ip_community_list_standard_all, |
12352 | no_ip_community_list_standard_all_cmd, | |
e961923c | 12353 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 12354 | NO_STR |
12355 | IP_STR | |
12356 | COMMUNITY_LIST_STR | |
12357 | "Community list number (standard)\n" | |
5bf15956 DW |
12358 | "Add an standard community-list entry\n" |
12359 | "Community list name\n" | |
718e3744 | 12360 | "Specify community to reject\n" |
12361 | "Specify community to accept\n" | |
12362 | COMMUNITY_VAL_STR) | |
12363 | { | |
d62a17ae | 12364 | int delete_all = 0; |
42f914d4 | 12365 | |
d62a17ae | 12366 | char *cl_name_or_number = NULL; |
12367 | int direct = 0; | |
12368 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 12369 | |
d62a17ae | 12370 | int idx = 0; |
12371 | argv_find(argv, argc, "(1-99)", &idx); | |
12372 | argv_find(argv, argc, "WORD", &idx); | |
12373 | cl_name_or_number = argv[idx]->arg; | |
12374 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12375 | : COMMUNITY_DENY; | |
12376 | argv_find(argv, argc, "AA:NN", &idx); | |
12377 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12378 | |
d62a17ae | 12379 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
12380 | direct, style, delete_all); | |
42f914d4 | 12381 | |
d62a17ae | 12382 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 12383 | |
d62a17ae | 12384 | if (ret < 0) { |
12385 | community_list_perror(vty, ret); | |
12386 | return CMD_WARNING_CONFIG_FAILED; | |
12387 | } | |
42f914d4 | 12388 | |
d62a17ae | 12389 | return CMD_SUCCESS; |
718e3744 | 12390 | } |
12391 | ||
5bf15956 DW |
12392 | /* ip community-list expanded */ |
12393 | DEFUN (ip_community_list_expanded_all, | |
12394 | ip_community_list_expanded_all_cmd, | |
42f914d4 | 12395 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 12396 | IP_STR |
12397 | COMMUNITY_LIST_STR | |
12398 | "Community list number (expanded)\n" | |
5bf15956 | 12399 | "Add an expanded community-list entry\n" |
718e3744 | 12400 | "Community list name\n" |
12401 | "Specify community to reject\n" | |
12402 | "Specify community to accept\n" | |
12403 | COMMUNITY_VAL_STR) | |
12404 | { | |
d62a17ae | 12405 | char *cl_name_or_number = NULL; |
12406 | int direct = 0; | |
12407 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 12408 | |
d62a17ae | 12409 | int idx = 0; |
12410 | argv_find(argv, argc, "(100-500)", &idx); | |
12411 | argv_find(argv, argc, "WORD", &idx); | |
12412 | cl_name_or_number = argv[idx]->arg; | |
12413 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12414 | : COMMUNITY_DENY; | |
12415 | argv_find(argv, argc, "AA:NN", &idx); | |
12416 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12417 | |
d62a17ae | 12418 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
12419 | style); | |
42f914d4 | 12420 | |
d62a17ae | 12421 | XFREE(MTYPE_TMP, str); |
42f914d4 | 12422 | |
d62a17ae | 12423 | if (ret < 0) { |
12424 | /* Display error string. */ | |
12425 | community_list_perror(vty, ret); | |
12426 | return CMD_WARNING_CONFIG_FAILED; | |
12427 | } | |
42f914d4 | 12428 | |
d62a17ae | 12429 | return CMD_SUCCESS; |
718e3744 | 12430 | } |
12431 | ||
5bf15956 DW |
12432 | DEFUN (no_ip_community_list_expanded_all, |
12433 | no_ip_community_list_expanded_all_cmd, | |
42f914d4 | 12434 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 12435 | NO_STR |
12436 | IP_STR | |
12437 | COMMUNITY_LIST_STR | |
5bf15956 DW |
12438 | "Community list number (expanded)\n" |
12439 | "Add an expanded community-list entry\n" | |
718e3744 | 12440 | "Community list name\n" |
12441 | "Specify community to reject\n" | |
12442 | "Specify community to accept\n" | |
5bf15956 | 12443 | COMMUNITY_VAL_STR) |
718e3744 | 12444 | { |
d62a17ae | 12445 | int delete_all = 0; |
42f914d4 | 12446 | |
d62a17ae | 12447 | char *cl_name_or_number = NULL; |
12448 | int direct = 0; | |
12449 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 12450 | |
d62a17ae | 12451 | int idx = 0; |
12452 | argv_find(argv, argc, "(100-500)", &idx); | |
12453 | argv_find(argv, argc, "WORD", &idx); | |
12454 | cl_name_or_number = argv[idx]->arg; | |
12455 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12456 | : COMMUNITY_DENY; | |
12457 | argv_find(argv, argc, "AA:NN", &idx); | |
12458 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12459 | |
d62a17ae | 12460 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
12461 | direct, style, delete_all); | |
42f914d4 | 12462 | |
d62a17ae | 12463 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 12464 | |
d62a17ae | 12465 | if (ret < 0) { |
12466 | community_list_perror(vty, ret); | |
12467 | return CMD_WARNING_CONFIG_FAILED; | |
12468 | } | |
42f914d4 | 12469 | |
d62a17ae | 12470 | return CMD_SUCCESS; |
718e3744 | 12471 | } |
12472 | ||
d62a17ae | 12473 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 12474 | { |
d62a17ae | 12475 | struct community_entry *entry; |
718e3744 | 12476 | |
d62a17ae | 12477 | for (entry = list->head; entry; entry = entry->next) { |
12478 | if (entry == list->head) { | |
12479 | if (all_digit(list->name)) | |
12480 | vty_out(vty, "Community %s list %s\n", | |
12481 | entry->style == COMMUNITY_LIST_STANDARD | |
12482 | ? "standard" | |
12483 | : "(expanded) access", | |
12484 | list->name); | |
12485 | else | |
12486 | vty_out(vty, "Named Community %s list %s\n", | |
12487 | entry->style == COMMUNITY_LIST_STANDARD | |
12488 | ? "standard" | |
12489 | : "expanded", | |
12490 | list->name); | |
12491 | } | |
12492 | if (entry->any) | |
12493 | vty_out(vty, " %s\n", | |
12494 | community_direct_str(entry->direct)); | |
12495 | else | |
12496 | vty_out(vty, " %s %s\n", | |
12497 | community_direct_str(entry->direct), | |
12498 | entry->style == COMMUNITY_LIST_STANDARD | |
12499 | ? community_str(entry->u.com) | |
12500 | : entry->config); | |
12501 | } | |
718e3744 | 12502 | } |
12503 | ||
12504 | DEFUN (show_ip_community_list, | |
12505 | show_ip_community_list_cmd, | |
12506 | "show ip community-list", | |
12507 | SHOW_STR | |
12508 | IP_STR | |
12509 | "List community-list\n") | |
12510 | { | |
d62a17ae | 12511 | struct community_list *list; |
12512 | struct community_list_master *cm; | |
718e3744 | 12513 | |
d62a17ae | 12514 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
12515 | if (!cm) | |
12516 | return CMD_SUCCESS; | |
718e3744 | 12517 | |
d62a17ae | 12518 | for (list = cm->num.head; list; list = list->next) |
12519 | community_list_show(vty, list); | |
718e3744 | 12520 | |
d62a17ae | 12521 | for (list = cm->str.head; list; list = list->next) |
12522 | community_list_show(vty, list); | |
718e3744 | 12523 | |
d62a17ae | 12524 | return CMD_SUCCESS; |
718e3744 | 12525 | } |
12526 | ||
12527 | DEFUN (show_ip_community_list_arg, | |
12528 | show_ip_community_list_arg_cmd, | |
6147e2c6 | 12529 | "show ip community-list <(1-500)|WORD>", |
718e3744 | 12530 | SHOW_STR |
12531 | IP_STR | |
12532 | "List community-list\n" | |
12533 | "Community-list number\n" | |
12534 | "Community-list name\n") | |
12535 | { | |
d62a17ae | 12536 | int idx_comm_list = 3; |
12537 | struct community_list *list; | |
718e3744 | 12538 | |
d62a17ae | 12539 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
12540 | COMMUNITY_LIST_MASTER); | |
12541 | if (!list) { | |
12542 | vty_out(vty, "%% Can't find community-list\n"); | |
12543 | return CMD_WARNING; | |
12544 | } | |
718e3744 | 12545 | |
d62a17ae | 12546 | community_list_show(vty, list); |
718e3744 | 12547 | |
d62a17ae | 12548 | return CMD_SUCCESS; |
718e3744 | 12549 | } |
6b0655a2 | 12550 | |
57d187bc JS |
12551 | /* |
12552 | * Large Community code. | |
12553 | */ | |
d62a17ae | 12554 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
12555 | struct cmd_token **argv, int style, | |
12556 | int reject_all_digit_name) | |
12557 | { | |
12558 | int ret; | |
12559 | int direct; | |
12560 | char *str; | |
12561 | int idx = 0; | |
12562 | char *cl_name; | |
12563 | ||
12564 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12565 | : COMMUNITY_DENY; | |
12566 | ||
12567 | /* All digit name check. */ | |
12568 | idx = 0; | |
12569 | argv_find(argv, argc, "WORD", &idx); | |
12570 | argv_find(argv, argc, "(1-99)", &idx); | |
12571 | argv_find(argv, argc, "(100-500)", &idx); | |
12572 | cl_name = argv[idx]->arg; | |
12573 | if (reject_all_digit_name && all_digit(cl_name)) { | |
12574 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
12575 | return CMD_WARNING_CONFIG_FAILED; | |
12576 | } | |
12577 | ||
12578 | idx = 0; | |
12579 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
12580 | argv_find(argv, argc, "LINE", &idx); | |
12581 | /* Concat community string argument. */ | |
12582 | if (idx) | |
12583 | str = argv_concat(argv, argc, idx); | |
12584 | else | |
12585 | str = NULL; | |
12586 | ||
12587 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
12588 | ||
12589 | /* Free temporary community list string allocated by | |
12590 | argv_concat(). */ | |
12591 | if (str) | |
12592 | XFREE(MTYPE_TMP, str); | |
12593 | ||
12594 | if (ret < 0) { | |
12595 | community_list_perror(vty, ret); | |
12596 | return CMD_WARNING_CONFIG_FAILED; | |
12597 | } | |
12598 | return CMD_SUCCESS; | |
12599 | } | |
12600 | ||
12601 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
12602 | struct cmd_token **argv, int style) | |
12603 | { | |
12604 | int ret; | |
12605 | int direct = 0; | |
12606 | char *str = NULL; | |
12607 | int idx = 0; | |
12608 | ||
12609 | argv_find(argv, argc, "permit", &idx); | |
12610 | argv_find(argv, argc, "deny", &idx); | |
12611 | ||
12612 | if (idx) { | |
12613 | /* Check the list direct. */ | |
12614 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
12615 | direct = COMMUNITY_PERMIT; | |
12616 | else | |
12617 | direct = COMMUNITY_DENY; | |
12618 | ||
12619 | idx = 0; | |
12620 | argv_find(argv, argc, "LINE", &idx); | |
12621 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
12622 | /* Concat community string argument. */ | |
12623 | str = argv_concat(argv, argc, idx); | |
12624 | } | |
12625 | ||
12626 | idx = 0; | |
12627 | argv_find(argv, argc, "(1-99)", &idx); | |
12628 | argv_find(argv, argc, "(100-500)", &idx); | |
12629 | argv_find(argv, argc, "WORD", &idx); | |
12630 | ||
12631 | /* Unset community list. */ | |
12632 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
12633 | style); | |
12634 | ||
12635 | /* Free temporary community list string allocated by | |
12636 | argv_concat(). */ | |
12637 | if (str) | |
12638 | XFREE(MTYPE_TMP, str); | |
12639 | ||
12640 | if (ret < 0) { | |
12641 | community_list_perror(vty, ret); | |
12642 | return CMD_WARNING_CONFIG_FAILED; | |
12643 | } | |
12644 | ||
12645 | return CMD_SUCCESS; | |
57d187bc JS |
12646 | } |
12647 | ||
12648 | /* "large-community-list" keyword help string. */ | |
12649 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
12650 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
12651 | ||
12652 | DEFUN (ip_lcommunity_list_standard, | |
12653 | ip_lcommunity_list_standard_cmd, | |
52951b63 DS |
12654 | "ip large-community-list (1-99) <deny|permit>", |
12655 | IP_STR | |
12656 | LCOMMUNITY_LIST_STR | |
12657 | "Large Community list number (standard)\n" | |
12658 | "Specify large community to reject\n" | |
7111c1a0 | 12659 | "Specify large community to accept\n") |
52951b63 | 12660 | { |
d62a17ae | 12661 | return lcommunity_list_set_vty(vty, argc, argv, |
12662 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
12663 | } |
12664 | ||
12665 | DEFUN (ip_lcommunity_list_standard1, | |
12666 | ip_lcommunity_list_standard1_cmd, | |
12667 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
12668 | IP_STR |
12669 | LCOMMUNITY_LIST_STR | |
12670 | "Large Community list number (standard)\n" | |
12671 | "Specify large community to reject\n" | |
12672 | "Specify large community to accept\n" | |
12673 | LCOMMUNITY_VAL_STR) | |
12674 | { | |
d62a17ae | 12675 | return lcommunity_list_set_vty(vty, argc, argv, |
12676 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
57d187bc JS |
12677 | } |
12678 | ||
12679 | DEFUN (ip_lcommunity_list_expanded, | |
12680 | ip_lcommunity_list_expanded_cmd, | |
12681 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
12682 | IP_STR | |
12683 | LCOMMUNITY_LIST_STR | |
12684 | "Large Community list number (expanded)\n" | |
12685 | "Specify large community to reject\n" | |
12686 | "Specify large community to accept\n" | |
12687 | "An ordered list as a regular-expression\n") | |
12688 | { | |
d62a17ae | 12689 | return lcommunity_list_set_vty(vty, argc, argv, |
12690 | LARGE_COMMUNITY_LIST_EXPANDED, 0); | |
57d187bc JS |
12691 | } |
12692 | ||
12693 | DEFUN (ip_lcommunity_list_name_standard, | |
12694 | ip_lcommunity_list_name_standard_cmd, | |
52951b63 DS |
12695 | "ip large-community-list standard WORD <deny|permit>", |
12696 | IP_STR | |
12697 | LCOMMUNITY_LIST_STR | |
12698 | "Specify standard large-community-list\n" | |
12699 | "Large Community list name\n" | |
12700 | "Specify large community to reject\n" | |
12701 | "Specify large community to accept\n") | |
12702 | { | |
d62a17ae | 12703 | return lcommunity_list_set_vty(vty, argc, argv, |
12704 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
12705 | } |
12706 | ||
12707 | DEFUN (ip_lcommunity_list_name_standard1, | |
12708 | ip_lcommunity_list_name_standard1_cmd, | |
12709 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
12710 | IP_STR |
12711 | LCOMMUNITY_LIST_STR | |
12712 | "Specify standard large-community-list\n" | |
12713 | "Large Community list name\n" | |
12714 | "Specify large community to reject\n" | |
12715 | "Specify large community to accept\n" | |
12716 | LCOMMUNITY_VAL_STR) | |
12717 | { | |
d62a17ae | 12718 | return lcommunity_list_set_vty(vty, argc, argv, |
12719 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
57d187bc JS |
12720 | } |
12721 | ||
12722 | DEFUN (ip_lcommunity_list_name_expanded, | |
12723 | ip_lcommunity_list_name_expanded_cmd, | |
12724 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
12725 | IP_STR | |
12726 | LCOMMUNITY_LIST_STR | |
12727 | "Specify expanded large-community-list\n" | |
12728 | "Large Community list name\n" | |
12729 | "Specify large community to reject\n" | |
12730 | "Specify large community to accept\n" | |
12731 | "An ordered list as a regular-expression\n") | |
12732 | { | |
d62a17ae | 12733 | return lcommunity_list_set_vty(vty, argc, argv, |
12734 | LARGE_COMMUNITY_LIST_EXPANDED, 1); | |
57d187bc JS |
12735 | } |
12736 | ||
12737 | DEFUN (no_ip_lcommunity_list_standard_all, | |
12738 | no_ip_lcommunity_list_standard_all_cmd, | |
12739 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
12740 | NO_STR | |
12741 | IP_STR | |
12742 | LCOMMUNITY_LIST_STR | |
12743 | "Large Community list number (standard)\n" | |
12744 | "Large Community list number (expanded)\n" | |
12745 | "Large Community list name\n") | |
12746 | { | |
d62a17ae | 12747 | return lcommunity_list_unset_vty(vty, argc, argv, |
12748 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
12749 | } |
12750 | ||
12751 | DEFUN (no_ip_lcommunity_list_name_expanded_all, | |
12752 | no_ip_lcommunity_list_name_expanded_all_cmd, | |
12753 | "no ip large-community-list expanded WORD", | |
12754 | NO_STR | |
12755 | IP_STR | |
12756 | LCOMMUNITY_LIST_STR | |
12757 | "Specify expanded large-community-list\n" | |
12758 | "Large Community list name\n") | |
12759 | { | |
d62a17ae | 12760 | return lcommunity_list_unset_vty(vty, argc, argv, |
12761 | LARGE_COMMUNITY_LIST_EXPANDED); | |
57d187bc JS |
12762 | } |
12763 | ||
12764 | DEFUN (no_ip_lcommunity_list_standard, | |
12765 | no_ip_lcommunity_list_standard_cmd, | |
12766 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
12767 | NO_STR | |
12768 | IP_STR | |
12769 | LCOMMUNITY_LIST_STR | |
12770 | "Large Community list number (standard)\n" | |
12771 | "Specify large community to reject\n" | |
12772 | "Specify large community to accept\n" | |
12773 | LCOMMUNITY_VAL_STR) | |
12774 | { | |
d62a17ae | 12775 | return lcommunity_list_unset_vty(vty, argc, argv, |
12776 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
12777 | } |
12778 | ||
12779 | DEFUN (no_ip_lcommunity_list_expanded, | |
12780 | no_ip_lcommunity_list_expanded_cmd, | |
12781 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
12782 | NO_STR | |
12783 | IP_STR | |
12784 | LCOMMUNITY_LIST_STR | |
12785 | "Large Community list number (expanded)\n" | |
12786 | "Specify large community to reject\n" | |
12787 | "Specify large community to accept\n" | |
12788 | "An ordered list as a regular-expression\n") | |
12789 | { | |
d62a17ae | 12790 | return lcommunity_list_unset_vty(vty, argc, argv, |
12791 | LARGE_COMMUNITY_LIST_EXPANDED); | |
57d187bc JS |
12792 | } |
12793 | ||
12794 | DEFUN (no_ip_lcommunity_list_name_standard, | |
12795 | no_ip_lcommunity_list_name_standard_cmd, | |
12796 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
12797 | NO_STR | |
12798 | IP_STR | |
12799 | LCOMMUNITY_LIST_STR | |
12800 | "Specify standard large-community-list\n" | |
12801 | "Large Community list name\n" | |
12802 | "Specify large community to reject\n" | |
12803 | "Specify large community to accept\n" | |
12804 | LCOMMUNITY_VAL_STR) | |
12805 | { | |
d62a17ae | 12806 | return lcommunity_list_unset_vty(vty, argc, argv, |
12807 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
12808 | } |
12809 | ||
12810 | DEFUN (no_ip_lcommunity_list_name_expanded, | |
12811 | no_ip_lcommunity_list_name_expanded_cmd, | |
12812 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
12813 | NO_STR | |
12814 | IP_STR | |
12815 | LCOMMUNITY_LIST_STR | |
12816 | "Specify expanded large-community-list\n" | |
12817 | "Large community list name\n" | |
12818 | "Specify large community to reject\n" | |
12819 | "Specify large community to accept\n" | |
12820 | "An ordered list as a regular-expression\n") | |
12821 | { | |
d62a17ae | 12822 | return lcommunity_list_unset_vty(vty, argc, argv, |
12823 | LARGE_COMMUNITY_LIST_EXPANDED); | |
12824 | } | |
12825 | ||
12826 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) | |
12827 | { | |
12828 | struct community_entry *entry; | |
12829 | ||
12830 | for (entry = list->head; entry; entry = entry->next) { | |
12831 | if (entry == list->head) { | |
12832 | if (all_digit(list->name)) | |
12833 | vty_out(vty, "Large community %s list %s\n", | |
12834 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
12835 | ? "standard" | |
12836 | : "(expanded) access", | |
12837 | list->name); | |
12838 | else | |
12839 | vty_out(vty, | |
12840 | "Named large community %s list %s\n", | |
12841 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
12842 | ? "standard" | |
12843 | : "expanded", | |
12844 | list->name); | |
12845 | } | |
12846 | if (entry->any) | |
12847 | vty_out(vty, " %s\n", | |
12848 | community_direct_str(entry->direct)); | |
12849 | else | |
12850 | vty_out(vty, " %s %s\n", | |
12851 | community_direct_str(entry->direct), | |
12852 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
12853 | ? entry->u.ecom->str | |
12854 | : entry->config); | |
12855 | } | |
57d187bc JS |
12856 | } |
12857 | ||
12858 | DEFUN (show_ip_lcommunity_list, | |
12859 | show_ip_lcommunity_list_cmd, | |
12860 | "show ip large-community-list", | |
12861 | SHOW_STR | |
12862 | IP_STR | |
12863 | "List large-community list\n") | |
12864 | { | |
d62a17ae | 12865 | struct community_list *list; |
12866 | struct community_list_master *cm; | |
57d187bc | 12867 | |
d62a17ae | 12868 | cm = community_list_master_lookup(bgp_clist, |
12869 | LARGE_COMMUNITY_LIST_MASTER); | |
12870 | if (!cm) | |
12871 | return CMD_SUCCESS; | |
57d187bc | 12872 | |
d62a17ae | 12873 | for (list = cm->num.head; list; list = list->next) |
12874 | lcommunity_list_show(vty, list); | |
57d187bc | 12875 | |
d62a17ae | 12876 | for (list = cm->str.head; list; list = list->next) |
12877 | lcommunity_list_show(vty, list); | |
57d187bc | 12878 | |
d62a17ae | 12879 | return CMD_SUCCESS; |
57d187bc JS |
12880 | } |
12881 | ||
12882 | DEFUN (show_ip_lcommunity_list_arg, | |
12883 | show_ip_lcommunity_list_arg_cmd, | |
12884 | "show ip large-community-list <(1-500)|WORD>", | |
12885 | SHOW_STR | |
12886 | IP_STR | |
12887 | "List large-community list\n" | |
12888 | "large-community-list number\n" | |
12889 | "large-community-list name\n") | |
12890 | { | |
d62a17ae | 12891 | struct community_list *list; |
57d187bc | 12892 | |
d62a17ae | 12893 | list = community_list_lookup(bgp_clist, argv[3]->arg, |
12894 | LARGE_COMMUNITY_LIST_MASTER); | |
12895 | if (!list) { | |
12896 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
12897 | return CMD_WARNING; | |
12898 | } | |
57d187bc | 12899 | |
d62a17ae | 12900 | lcommunity_list_show(vty, list); |
57d187bc | 12901 | |
d62a17ae | 12902 | return CMD_SUCCESS; |
57d187bc JS |
12903 | } |
12904 | ||
718e3744 | 12905 | /* "extcommunity-list" keyword help string. */ |
12906 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
12907 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
12908 | ||
12909 | DEFUN (ip_extcommunity_list_standard, | |
12910 | ip_extcommunity_list_standard_cmd, | |
e961923c | 12911 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 12912 | IP_STR |
12913 | EXTCOMMUNITY_LIST_STR | |
12914 | "Extended Community list number (standard)\n" | |
718e3744 | 12915 | "Specify standard extcommunity-list\n" |
5bf15956 | 12916 | "Community list name\n" |
718e3744 | 12917 | "Specify community to reject\n" |
12918 | "Specify community to accept\n" | |
12919 | EXTCOMMUNITY_VAL_STR) | |
12920 | { | |
d62a17ae | 12921 | int style = EXTCOMMUNITY_LIST_STANDARD; |
12922 | int direct = 0; | |
12923 | char *cl_number_or_name = NULL; | |
42f914d4 | 12924 | |
d62a17ae | 12925 | int idx = 0; |
12926 | argv_find(argv, argc, "(1-99)", &idx); | |
12927 | argv_find(argv, argc, "WORD", &idx); | |
12928 | cl_number_or_name = argv[idx]->arg; | |
12929 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12930 | : COMMUNITY_DENY; | |
12931 | argv_find(argv, argc, "AA:NN", &idx); | |
12932 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12933 | |
d62a17ae | 12934 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
12935 | direct, style); | |
42f914d4 | 12936 | |
d62a17ae | 12937 | XFREE(MTYPE_TMP, str); |
42f914d4 | 12938 | |
d62a17ae | 12939 | if (ret < 0) { |
12940 | community_list_perror(vty, ret); | |
12941 | return CMD_WARNING_CONFIG_FAILED; | |
12942 | } | |
42f914d4 | 12943 | |
d62a17ae | 12944 | return CMD_SUCCESS; |
718e3744 | 12945 | } |
12946 | ||
718e3744 | 12947 | DEFUN (ip_extcommunity_list_name_expanded, |
12948 | ip_extcommunity_list_name_expanded_cmd, | |
e961923c | 12949 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 12950 | IP_STR |
12951 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 12952 | "Extended Community list number (expanded)\n" |
718e3744 | 12953 | "Specify expanded extcommunity-list\n" |
12954 | "Extended Community list name\n" | |
12955 | "Specify community to reject\n" | |
12956 | "Specify community to accept\n" | |
12957 | "An ordered list as a regular-expression\n") | |
12958 | { | |
d62a17ae | 12959 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
12960 | int direct = 0; | |
12961 | char *cl_number_or_name = NULL; | |
42f914d4 | 12962 | |
d62a17ae | 12963 | int idx = 0; |
12964 | argv_find(argv, argc, "(100-500)", &idx); | |
12965 | argv_find(argv, argc, "WORD", &idx); | |
12966 | cl_number_or_name = argv[idx]->arg; | |
12967 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12968 | : COMMUNITY_DENY; | |
12969 | argv_find(argv, argc, "LINE", &idx); | |
12970 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12971 | |
d62a17ae | 12972 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
12973 | direct, style); | |
42f914d4 | 12974 | |
d62a17ae | 12975 | XFREE(MTYPE_TMP, str); |
42f914d4 | 12976 | |
d62a17ae | 12977 | if (ret < 0) { |
12978 | community_list_perror(vty, ret); | |
12979 | return CMD_WARNING_CONFIG_FAILED; | |
12980 | } | |
42f914d4 | 12981 | |
d62a17ae | 12982 | return CMD_SUCCESS; |
718e3744 | 12983 | } |
12984 | ||
fee6e4e4 | 12985 | DEFUN (no_ip_extcommunity_list_standard_all, |
12986 | no_ip_extcommunity_list_standard_all_cmd, | |
e961923c | 12987 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
813d4307 DW |
12988 | NO_STR |
12989 | IP_STR | |
12990 | EXTCOMMUNITY_LIST_STR | |
12991 | "Extended Community list number (standard)\n" | |
718e3744 | 12992 | "Specify standard extcommunity-list\n" |
5bf15956 | 12993 | "Community list name\n" |
718e3744 | 12994 | "Specify community to reject\n" |
12995 | "Specify community to accept\n" | |
12996 | EXTCOMMUNITY_VAL_STR) | |
12997 | { | |
d62a17ae | 12998 | int deleteall = 0; |
42f914d4 | 12999 | |
d62a17ae | 13000 | int style = EXTCOMMUNITY_LIST_STANDARD; |
13001 | int direct = 0; | |
13002 | char *cl_number_or_name = NULL; | |
42f914d4 | 13003 | |
d62a17ae | 13004 | int idx = 0; |
13005 | argv_find(argv, argc, "(1-99)", &idx); | |
13006 | argv_find(argv, argc, "WORD", &idx); | |
13007 | cl_number_or_name = argv[idx]->arg; | |
13008 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13009 | : COMMUNITY_DENY; | |
13010 | argv_find(argv, argc, "AA:NN", &idx); | |
13011 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13012 | |
d62a17ae | 13013 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
13014 | direct, style, deleteall); | |
42f914d4 | 13015 | |
d62a17ae | 13016 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13017 | |
d62a17ae | 13018 | if (ret < 0) { |
13019 | community_list_perror(vty, ret); | |
13020 | return CMD_WARNING_CONFIG_FAILED; | |
13021 | } | |
42f914d4 | 13022 | |
d62a17ae | 13023 | return CMD_SUCCESS; |
718e3744 | 13024 | } |
13025 | ||
5bf15956 DW |
13026 | DEFUN (no_ip_extcommunity_list_expanded_all, |
13027 | no_ip_extcommunity_list_expanded_all_cmd, | |
e961923c | 13028 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 13029 | NO_STR |
13030 | IP_STR | |
13031 | EXTCOMMUNITY_LIST_STR | |
13032 | "Extended Community list number (expanded)\n" | |
718e3744 | 13033 | "Specify expanded extcommunity-list\n" |
5bf15956 | 13034 | "Extended Community list name\n" |
718e3744 | 13035 | "Specify community to reject\n" |
13036 | "Specify community to accept\n" | |
13037 | "An ordered list as a regular-expression\n") | |
13038 | { | |
d62a17ae | 13039 | int deleteall = 0; |
42f914d4 | 13040 | |
d62a17ae | 13041 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
13042 | int direct = 0; | |
13043 | char *cl_number_or_name = NULL; | |
42f914d4 | 13044 | |
d62a17ae | 13045 | int idx = 0; |
13046 | argv_find(argv, argc, "(100-500)", &idx); | |
13047 | argv_find(argv, argc, "WORD", &idx); | |
13048 | cl_number_or_name = argv[idx]->arg; | |
13049 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13050 | : COMMUNITY_DENY; | |
13051 | argv_find(argv, argc, "LINE", &idx); | |
13052 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13053 | |
d62a17ae | 13054 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
13055 | direct, style, deleteall); | |
42f914d4 | 13056 | |
d62a17ae | 13057 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13058 | |
d62a17ae | 13059 | if (ret < 0) { |
13060 | community_list_perror(vty, ret); | |
13061 | return CMD_WARNING_CONFIG_FAILED; | |
13062 | } | |
42f914d4 | 13063 | |
d62a17ae | 13064 | return CMD_SUCCESS; |
718e3744 | 13065 | } |
13066 | ||
d62a17ae | 13067 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 13068 | { |
d62a17ae | 13069 | struct community_entry *entry; |
718e3744 | 13070 | |
d62a17ae | 13071 | for (entry = list->head; entry; entry = entry->next) { |
13072 | if (entry == list->head) { | |
13073 | if (all_digit(list->name)) | |
13074 | vty_out(vty, "Extended community %s list %s\n", | |
13075 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13076 | ? "standard" | |
13077 | : "(expanded) access", | |
13078 | list->name); | |
13079 | else | |
13080 | vty_out(vty, | |
13081 | "Named extended community %s list %s\n", | |
13082 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13083 | ? "standard" | |
13084 | : "expanded", | |
13085 | list->name); | |
13086 | } | |
13087 | if (entry->any) | |
13088 | vty_out(vty, " %s\n", | |
13089 | community_direct_str(entry->direct)); | |
13090 | else | |
13091 | vty_out(vty, " %s %s\n", | |
13092 | community_direct_str(entry->direct), | |
13093 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13094 | ? entry->u.ecom->str | |
13095 | : entry->config); | |
13096 | } | |
718e3744 | 13097 | } |
13098 | ||
13099 | DEFUN (show_ip_extcommunity_list, | |
13100 | show_ip_extcommunity_list_cmd, | |
13101 | "show ip extcommunity-list", | |
13102 | SHOW_STR | |
13103 | IP_STR | |
13104 | "List extended-community list\n") | |
13105 | { | |
d62a17ae | 13106 | struct community_list *list; |
13107 | struct community_list_master *cm; | |
718e3744 | 13108 | |
d62a17ae | 13109 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
13110 | if (!cm) | |
13111 | return CMD_SUCCESS; | |
718e3744 | 13112 | |
d62a17ae | 13113 | for (list = cm->num.head; list; list = list->next) |
13114 | extcommunity_list_show(vty, list); | |
718e3744 | 13115 | |
d62a17ae | 13116 | for (list = cm->str.head; list; list = list->next) |
13117 | extcommunity_list_show(vty, list); | |
718e3744 | 13118 | |
d62a17ae | 13119 | return CMD_SUCCESS; |
718e3744 | 13120 | } |
13121 | ||
13122 | DEFUN (show_ip_extcommunity_list_arg, | |
13123 | show_ip_extcommunity_list_arg_cmd, | |
6147e2c6 | 13124 | "show ip extcommunity-list <(1-500)|WORD>", |
718e3744 | 13125 | SHOW_STR |
13126 | IP_STR | |
13127 | "List extended-community list\n" | |
13128 | "Extcommunity-list number\n" | |
13129 | "Extcommunity-list name\n") | |
13130 | { | |
d62a17ae | 13131 | int idx_comm_list = 3; |
13132 | struct community_list *list; | |
718e3744 | 13133 | |
d62a17ae | 13134 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
13135 | EXTCOMMUNITY_LIST_MASTER); | |
13136 | if (!list) { | |
13137 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
13138 | return CMD_WARNING; | |
13139 | } | |
718e3744 | 13140 | |
d62a17ae | 13141 | extcommunity_list_show(vty, list); |
718e3744 | 13142 | |
d62a17ae | 13143 | return CMD_SUCCESS; |
718e3744 | 13144 | } |
6b0655a2 | 13145 | |
718e3744 | 13146 | /* Return configuration string of community-list entry. */ |
d62a17ae | 13147 | static const char *community_list_config_str(struct community_entry *entry) |
718e3744 | 13148 | { |
d62a17ae | 13149 | const char *str; |
718e3744 | 13150 | |
d62a17ae | 13151 | if (entry->any) |
13152 | str = ""; | |
13153 | else { | |
13154 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
13155 | str = community_str(entry->u.com); | |
13156 | else | |
13157 | str = entry->config; | |
13158 | } | |
13159 | return str; | |
718e3744 | 13160 | } |
13161 | ||
13162 | /* Display community-list and extcommunity-list configuration. */ | |
d62a17ae | 13163 | static int community_list_config_write(struct vty *vty) |
13164 | { | |
13165 | struct community_list *list; | |
13166 | struct community_entry *entry; | |
13167 | struct community_list_master *cm; | |
13168 | int write = 0; | |
13169 | ||
13170 | /* Community-list. */ | |
13171 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
13172 | ||
13173 | for (list = cm->num.head; list; list = list->next) | |
13174 | for (entry = list->head; entry; entry = entry->next) { | |
13175 | vty_out(vty, "ip community-list %s %s %s\n", list->name, | |
13176 | community_direct_str(entry->direct), | |
13177 | community_list_config_str(entry)); | |
13178 | write++; | |
13179 | } | |
13180 | for (list = cm->str.head; list; list = list->next) | |
13181 | for (entry = list->head; entry; entry = entry->next) { | |
13182 | vty_out(vty, "ip community-list %s %s %s %s\n", | |
13183 | entry->style == COMMUNITY_LIST_STANDARD | |
13184 | ? "standard" | |
13185 | : "expanded", | |
13186 | list->name, community_direct_str(entry->direct), | |
13187 | community_list_config_str(entry)); | |
13188 | write++; | |
13189 | } | |
13190 | ||
13191 | /* Extcommunity-list. */ | |
13192 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
13193 | ||
13194 | for (list = cm->num.head; list; list = list->next) | |
13195 | for (entry = list->head; entry; entry = entry->next) { | |
13196 | vty_out(vty, "ip extcommunity-list %s %s %s\n", | |
13197 | list->name, community_direct_str(entry->direct), | |
13198 | community_list_config_str(entry)); | |
13199 | write++; | |
13200 | } | |
13201 | for (list = cm->str.head; list; list = list->next) | |
13202 | for (entry = list->head; entry; entry = entry->next) { | |
13203 | vty_out(vty, "ip extcommunity-list %s %s %s %s\n", | |
13204 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13205 | ? "standard" | |
13206 | : "expanded", | |
13207 | list->name, community_direct_str(entry->direct), | |
13208 | community_list_config_str(entry)); | |
13209 | write++; | |
13210 | } | |
13211 | ||
13212 | ||
13213 | /* lcommunity-list. */ | |
13214 | cm = community_list_master_lookup(bgp_clist, | |
13215 | LARGE_COMMUNITY_LIST_MASTER); | |
13216 | ||
13217 | for (list = cm->num.head; list; list = list->next) | |
13218 | for (entry = list->head; entry; entry = entry->next) { | |
13219 | vty_out(vty, "ip large-community-list %s %s %s\n", | |
13220 | list->name, community_direct_str(entry->direct), | |
13221 | community_list_config_str(entry)); | |
13222 | write++; | |
13223 | } | |
13224 | for (list = cm->str.head; list; list = list->next) | |
13225 | for (entry = list->head; entry; entry = entry->next) { | |
13226 | vty_out(vty, "ip large-community-list %s %s %s %s\n", | |
13227 | entry->style == LARGE_COMMUNITY_LIST_STANDARD | |
13228 | ? "standard" | |
13229 | : "expanded", | |
13230 | list->name, community_direct_str(entry->direct), | |
13231 | community_list_config_str(entry)); | |
13232 | write++; | |
13233 | } | |
13234 | ||
13235 | return write; | |
13236 | } | |
13237 | ||
13238 | static struct cmd_node community_list_node = { | |
13239 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 13240 | }; |
13241 | ||
d62a17ae | 13242 | static void community_list_vty(void) |
13243 | { | |
13244 | install_node(&community_list_node, community_list_config_write); | |
13245 | ||
13246 | /* Community-list. */ | |
13247 | install_element(CONFIG_NODE, &ip_community_list_standard_cmd); | |
13248 | install_element(CONFIG_NODE, &ip_community_list_expanded_all_cmd); | |
13249 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_cmd); | |
13250 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); | |
13251 | install_element(VIEW_NODE, &show_ip_community_list_cmd); | |
13252 | install_element(VIEW_NODE, &show_ip_community_list_arg_cmd); | |
13253 | ||
13254 | /* Extcommunity-list. */ | |
13255 | install_element(CONFIG_NODE, &ip_extcommunity_list_standard_cmd); | |
13256 | install_element(CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); | |
13257 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); | |
13258 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
13259 | install_element(VIEW_NODE, &show_ip_extcommunity_list_cmd); | |
13260 | install_element(VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
13261 | ||
13262 | /* Large Community List */ | |
13263 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard_cmd); | |
13264 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); | |
13265 | install_element(CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); | |
13266 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
13267 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); | |
13268 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); | |
13269 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
13270 | install_element(CONFIG_NODE, | |
13271 | &no_ip_lcommunity_list_name_expanded_all_cmd); | |
13272 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
13273 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
13274 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
13275 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
13276 | install_element(VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
13277 | install_element(VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 13278 | } |