]>
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, |
c14777c6 | 1473 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
1474 | NO_STR | |
d62a17ae | 1475 | "Forward packets over multiple paths\n" |
1476 | "Number of paths\n") | |
596c17ba | 1477 | |
165b5fff JB |
1478 | DEFUN (no_bgp_maxpaths_ibgp, |
1479 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1480 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1481 | NO_STR |
1482 | "Forward packets over multiple paths\n" | |
1483 | "iBGP-multipath\n" | |
838758ac DW |
1484 | "Number of paths\n" |
1485 | "Match the cluster length\n") | |
165b5fff | 1486 | { |
d62a17ae | 1487 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1488 | } |
1489 | ||
d62a17ae | 1490 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1491 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1492 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1493 | NO_STR | |
1494 | "Forward packets over multiple paths\n" | |
1495 | "iBGP-multipath\n" | |
1496 | "Number of paths\n" | |
1497 | "Match the cluster length\n") | |
596c17ba | 1498 | |
d62a17ae | 1499 | int bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi, |
1500 | safi_t safi, int *write) | |
165b5fff | 1501 | { |
d62a17ae | 1502 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
1503 | bgp_config_write_family_header(vty, afi, safi, write); | |
1504 | vty_out(vty, " maximum-paths %d\n", | |
1505 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1506 | } | |
165b5fff | 1507 | |
d62a17ae | 1508 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
1509 | bgp_config_write_family_header(vty, afi, safi, write); | |
1510 | vty_out(vty, " maximum-paths ibgp %d", | |
1511 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1512 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1513 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1514 | vty_out(vty, " equal-cluster-length"); | |
1515 | vty_out(vty, "\n"); | |
1516 | } | |
165b5fff | 1517 | |
d62a17ae | 1518 | return 0; |
165b5fff | 1519 | } |
6b0655a2 | 1520 | |
718e3744 | 1521 | /* BGP timers. */ |
1522 | ||
1523 | DEFUN (bgp_timers, | |
1524 | bgp_timers_cmd, | |
6147e2c6 | 1525 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1526 | "Adjust routing timers\n" |
1527 | "BGP timers\n" | |
1528 | "Keepalive interval\n" | |
1529 | "Holdtime\n") | |
1530 | { | |
d62a17ae | 1531 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1532 | int idx_number = 2; | |
1533 | int idx_number_2 = 3; | |
1534 | unsigned long keepalive = 0; | |
1535 | unsigned long holdtime = 0; | |
718e3744 | 1536 | |
d62a17ae | 1537 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1538 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1539 | |
d62a17ae | 1540 | /* Holdtime value check. */ |
1541 | if (holdtime < 3 && holdtime != 0) { | |
1542 | vty_out(vty, | |
1543 | "%% hold time value must be either 0 or greater than 3\n"); | |
1544 | return CMD_WARNING_CONFIG_FAILED; | |
1545 | } | |
718e3744 | 1546 | |
d62a17ae | 1547 | bgp_timers_set(bgp, keepalive, holdtime); |
718e3744 | 1548 | |
d62a17ae | 1549 | return CMD_SUCCESS; |
718e3744 | 1550 | } |
1551 | ||
1552 | DEFUN (no_bgp_timers, | |
1553 | no_bgp_timers_cmd, | |
838758ac | 1554 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1555 | NO_STR |
1556 | "Adjust routing timers\n" | |
838758ac DW |
1557 | "BGP timers\n" |
1558 | "Keepalive interval\n" | |
1559 | "Holdtime\n") | |
718e3744 | 1560 | { |
d62a17ae | 1561 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1562 | bgp_timers_unset(bgp); | |
718e3744 | 1563 | |
d62a17ae | 1564 | return CMD_SUCCESS; |
718e3744 | 1565 | } |
1566 | ||
6b0655a2 | 1567 | |
718e3744 | 1568 | DEFUN (bgp_client_to_client_reflection, |
1569 | bgp_client_to_client_reflection_cmd, | |
1570 | "bgp client-to-client reflection", | |
1571 | "BGP specific commands\n" | |
1572 | "Configure client to client route reflection\n" | |
1573 | "reflection of routes allowed\n") | |
1574 | { | |
d62a17ae | 1575 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1576 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1577 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1578 | |
d62a17ae | 1579 | return CMD_SUCCESS; |
718e3744 | 1580 | } |
1581 | ||
1582 | DEFUN (no_bgp_client_to_client_reflection, | |
1583 | no_bgp_client_to_client_reflection_cmd, | |
1584 | "no bgp client-to-client reflection", | |
1585 | NO_STR | |
1586 | "BGP specific commands\n" | |
1587 | "Configure client to client route reflection\n" | |
1588 | "reflection of routes allowed\n") | |
1589 | { | |
d62a17ae | 1590 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1591 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1592 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1593 | |
d62a17ae | 1594 | return CMD_SUCCESS; |
718e3744 | 1595 | } |
1596 | ||
1597 | /* "bgp always-compare-med" configuration. */ | |
1598 | DEFUN (bgp_always_compare_med, | |
1599 | bgp_always_compare_med_cmd, | |
1600 | "bgp always-compare-med", | |
1601 | "BGP specific commands\n" | |
1602 | "Allow comparing MED from different neighbors\n") | |
1603 | { | |
d62a17ae | 1604 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1605 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1606 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1607 | |
d62a17ae | 1608 | return CMD_SUCCESS; |
718e3744 | 1609 | } |
1610 | ||
1611 | DEFUN (no_bgp_always_compare_med, | |
1612 | no_bgp_always_compare_med_cmd, | |
1613 | "no bgp always-compare-med", | |
1614 | NO_STR | |
1615 | "BGP specific commands\n" | |
1616 | "Allow comparing MED from different neighbors\n") | |
1617 | { | |
d62a17ae | 1618 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1619 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1620 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1621 | |
d62a17ae | 1622 | return CMD_SUCCESS; |
718e3744 | 1623 | } |
6b0655a2 | 1624 | |
718e3744 | 1625 | /* "bgp deterministic-med" configuration. */ |
1626 | DEFUN (bgp_deterministic_med, | |
1627 | bgp_deterministic_med_cmd, | |
1628 | "bgp deterministic-med", | |
1629 | "BGP specific commands\n" | |
1630 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1631 | { | |
d62a17ae | 1632 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 1633 | |
d62a17ae | 1634 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
1635 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1636 | bgp_recalculate_all_bestpaths(bgp); | |
1637 | } | |
7aafcaca | 1638 | |
d62a17ae | 1639 | return CMD_SUCCESS; |
718e3744 | 1640 | } |
1641 | ||
1642 | DEFUN (no_bgp_deterministic_med, | |
1643 | no_bgp_deterministic_med_cmd, | |
1644 | "no bgp deterministic-med", | |
1645 | NO_STR | |
1646 | "BGP specific commands\n" | |
1647 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1648 | { | |
d62a17ae | 1649 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1650 | int bestpath_per_as_used; | |
1651 | afi_t afi; | |
1652 | safi_t safi; | |
1653 | struct peer *peer; | |
1654 | struct listnode *node, *nnode; | |
1655 | ||
1656 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
1657 | bestpath_per_as_used = 0; | |
1658 | ||
1659 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1660 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
1661 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; | |
1662 | safi++) | |
1663 | if (CHECK_FLAG( | |
1664 | peer->af_flags[afi][safi], | |
1665 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) { | |
1666 | bestpath_per_as_used = 1; | |
1667 | break; | |
1668 | } | |
1669 | ||
1670 | if (bestpath_per_as_used) | |
1671 | break; | |
1672 | } | |
1673 | ||
1674 | if (bestpath_per_as_used) { | |
1675 | vty_out(vty, | |
1676 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
1677 | return CMD_WARNING_CONFIG_FAILED; | |
1678 | } else { | |
1679 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1680 | bgp_recalculate_all_bestpaths(bgp); | |
1681 | } | |
1682 | } | |
1683 | ||
1684 | return CMD_SUCCESS; | |
718e3744 | 1685 | } |
538621f2 | 1686 | |
1687 | /* "bgp graceful-restart" configuration. */ | |
1688 | DEFUN (bgp_graceful_restart, | |
1689 | bgp_graceful_restart_cmd, | |
1690 | "bgp graceful-restart", | |
1691 | "BGP specific commands\n" | |
1692 | "Graceful restart capability parameters\n") | |
1693 | { | |
d62a17ae | 1694 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1695 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1696 | return CMD_SUCCESS; | |
538621f2 | 1697 | } |
1698 | ||
1699 | DEFUN (no_bgp_graceful_restart, | |
1700 | no_bgp_graceful_restart_cmd, | |
1701 | "no bgp graceful-restart", | |
1702 | NO_STR | |
1703 | "BGP specific commands\n" | |
1704 | "Graceful restart capability parameters\n") | |
1705 | { | |
d62a17ae | 1706 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1707 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1708 | return CMD_SUCCESS; | |
538621f2 | 1709 | } |
1710 | ||
93406d87 | 1711 | DEFUN (bgp_graceful_restart_stalepath_time, |
1712 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1713 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1714 | "BGP specific commands\n" |
1715 | "Graceful restart capability parameters\n" | |
1716 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1717 | "Delay value (seconds)\n") | |
1718 | { | |
d62a17ae | 1719 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1720 | int idx_number = 3; | |
1721 | u_int32_t stalepath; | |
93406d87 | 1722 | |
d62a17ae | 1723 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
1724 | bgp->stalepath_time = stalepath; | |
1725 | return CMD_SUCCESS; | |
93406d87 | 1726 | } |
1727 | ||
eb6f1b41 PG |
1728 | DEFUN (bgp_graceful_restart_restart_time, |
1729 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1730 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1731 | "BGP specific commands\n" |
1732 | "Graceful restart capability parameters\n" | |
1733 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1734 | "Delay value (seconds)\n") | |
1735 | { | |
d62a17ae | 1736 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1737 | int idx_number = 3; | |
1738 | u_int32_t restart; | |
eb6f1b41 | 1739 | |
d62a17ae | 1740 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
1741 | bgp->restart_time = restart; | |
1742 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1743 | } |
1744 | ||
93406d87 | 1745 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1746 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1747 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1748 | NO_STR |
1749 | "BGP specific commands\n" | |
1750 | "Graceful restart capability parameters\n" | |
838758ac DW |
1751 | "Set the max time to hold onto restarting peer's stale paths\n" |
1752 | "Delay value (seconds)\n") | |
93406d87 | 1753 | { |
d62a17ae | 1754 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1755 | |
d62a17ae | 1756 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
1757 | return CMD_SUCCESS; | |
93406d87 | 1758 | } |
1759 | ||
eb6f1b41 PG |
1760 | DEFUN (no_bgp_graceful_restart_restart_time, |
1761 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1762 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1763 | NO_STR |
1764 | "BGP specific commands\n" | |
1765 | "Graceful restart capability parameters\n" | |
838758ac DW |
1766 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1767 | "Delay value (seconds)\n") | |
eb6f1b41 | 1768 | { |
d62a17ae | 1769 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 1770 | |
d62a17ae | 1771 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
1772 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1773 | } |
1774 | ||
43fc21b3 JC |
1775 | DEFUN (bgp_graceful_restart_preserve_fw, |
1776 | bgp_graceful_restart_preserve_fw_cmd, | |
1777 | "bgp graceful-restart preserve-fw-state", | |
1778 | "BGP specific commands\n" | |
1779 | "Graceful restart capability parameters\n" | |
1780 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1781 | { | |
d62a17ae | 1782 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1783 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1784 | return CMD_SUCCESS; | |
43fc21b3 JC |
1785 | } |
1786 | ||
1787 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
1788 | no_bgp_graceful_restart_preserve_fw_cmd, | |
1789 | "no bgp graceful-restart preserve-fw-state", | |
1790 | NO_STR | |
1791 | "BGP specific commands\n" | |
1792 | "Graceful restart capability parameters\n" | |
1793 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1794 | { | |
d62a17ae | 1795 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1796 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1797 | return CMD_SUCCESS; | |
43fc21b3 JC |
1798 | } |
1799 | ||
718e3744 | 1800 | /* "bgp fast-external-failover" configuration. */ |
1801 | DEFUN (bgp_fast_external_failover, | |
1802 | bgp_fast_external_failover_cmd, | |
1803 | "bgp fast-external-failover", | |
1804 | BGP_STR | |
1805 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1806 | { | |
d62a17ae | 1807 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1808 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
1809 | return CMD_SUCCESS; | |
718e3744 | 1810 | } |
1811 | ||
1812 | DEFUN (no_bgp_fast_external_failover, | |
1813 | no_bgp_fast_external_failover_cmd, | |
1814 | "no bgp fast-external-failover", | |
1815 | NO_STR | |
1816 | BGP_STR | |
1817 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1818 | { | |
d62a17ae | 1819 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1820 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
1821 | return CMD_SUCCESS; | |
718e3744 | 1822 | } |
6b0655a2 | 1823 | |
718e3744 | 1824 | /* "bgp enforce-first-as" configuration. */ |
1825 | DEFUN (bgp_enforce_first_as, | |
1826 | bgp_enforce_first_as_cmd, | |
1827 | "bgp enforce-first-as", | |
1828 | BGP_STR | |
1829 | "Enforce the first AS for EBGP routes\n") | |
1830 | { | |
d62a17ae | 1831 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1832 | bgp_flag_set(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
1833 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 1834 | |
d62a17ae | 1835 | return CMD_SUCCESS; |
718e3744 | 1836 | } |
1837 | ||
1838 | DEFUN (no_bgp_enforce_first_as, | |
1839 | no_bgp_enforce_first_as_cmd, | |
1840 | "no bgp enforce-first-as", | |
1841 | NO_STR | |
1842 | BGP_STR | |
1843 | "Enforce the first AS for EBGP routes\n") | |
1844 | { | |
d62a17ae | 1845 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1846 | bgp_flag_unset(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
1847 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 1848 | |
d62a17ae | 1849 | return CMD_SUCCESS; |
718e3744 | 1850 | } |
6b0655a2 | 1851 | |
718e3744 | 1852 | /* "bgp bestpath compare-routerid" configuration. */ |
1853 | DEFUN (bgp_bestpath_compare_router_id, | |
1854 | bgp_bestpath_compare_router_id_cmd, | |
1855 | "bgp bestpath compare-routerid", | |
1856 | "BGP specific commands\n" | |
1857 | "Change the default bestpath selection\n" | |
1858 | "Compare router-id for identical EBGP paths\n") | |
1859 | { | |
d62a17ae | 1860 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1861 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
1862 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1863 | |
d62a17ae | 1864 | return CMD_SUCCESS; |
718e3744 | 1865 | } |
1866 | ||
1867 | DEFUN (no_bgp_bestpath_compare_router_id, | |
1868 | no_bgp_bestpath_compare_router_id_cmd, | |
1869 | "no bgp bestpath compare-routerid", | |
1870 | NO_STR | |
1871 | "BGP specific commands\n" | |
1872 | "Change the default bestpath selection\n" | |
1873 | "Compare router-id for identical EBGP paths\n") | |
1874 | { | |
d62a17ae | 1875 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1876 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
1877 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1878 | |
d62a17ae | 1879 | return CMD_SUCCESS; |
718e3744 | 1880 | } |
6b0655a2 | 1881 | |
718e3744 | 1882 | /* "bgp bestpath as-path ignore" configuration. */ |
1883 | DEFUN (bgp_bestpath_aspath_ignore, | |
1884 | bgp_bestpath_aspath_ignore_cmd, | |
1885 | "bgp bestpath as-path ignore", | |
1886 | "BGP specific commands\n" | |
1887 | "Change the default bestpath selection\n" | |
1888 | "AS-path attribute\n" | |
1889 | "Ignore as-path length in selecting a route\n") | |
1890 | { | |
d62a17ae | 1891 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1892 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
1893 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1894 | |
d62a17ae | 1895 | return CMD_SUCCESS; |
718e3744 | 1896 | } |
1897 | ||
1898 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
1899 | no_bgp_bestpath_aspath_ignore_cmd, | |
1900 | "no bgp bestpath as-path ignore", | |
1901 | NO_STR | |
1902 | "BGP specific commands\n" | |
1903 | "Change the default bestpath selection\n" | |
1904 | "AS-path attribute\n" | |
1905 | "Ignore as-path length in selecting a route\n") | |
1906 | { | |
d62a17ae | 1907 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1908 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
1909 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1910 | |
d62a17ae | 1911 | return CMD_SUCCESS; |
718e3744 | 1912 | } |
6b0655a2 | 1913 | |
6811845b | 1914 | /* "bgp bestpath as-path confed" configuration. */ |
1915 | DEFUN (bgp_bestpath_aspath_confed, | |
1916 | bgp_bestpath_aspath_confed_cmd, | |
1917 | "bgp bestpath as-path confed", | |
1918 | "BGP specific commands\n" | |
1919 | "Change the default bestpath selection\n" | |
1920 | "AS-path attribute\n" | |
1921 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
1922 | { | |
d62a17ae | 1923 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1924 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
1925 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1926 | |
d62a17ae | 1927 | return CMD_SUCCESS; |
6811845b | 1928 | } |
1929 | ||
1930 | DEFUN (no_bgp_bestpath_aspath_confed, | |
1931 | no_bgp_bestpath_aspath_confed_cmd, | |
1932 | "no bgp bestpath as-path confed", | |
1933 | NO_STR | |
1934 | "BGP specific commands\n" | |
1935 | "Change the default bestpath selection\n" | |
1936 | "AS-path attribute\n" | |
1937 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
1938 | { | |
d62a17ae | 1939 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1940 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
1941 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1942 | |
d62a17ae | 1943 | return CMD_SUCCESS; |
6811845b | 1944 | } |
6b0655a2 | 1945 | |
2fdd455c PM |
1946 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
1947 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
1948 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 1949 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
1950 | "BGP specific commands\n" |
1951 | "Change the default bestpath selection\n" | |
1952 | "AS-path attribute\n" | |
1953 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 1954 | "Generate an AS_SET\n" |
16fc1eec DS |
1955 | "Do not generate an AS_SET\n") |
1956 | { | |
d62a17ae | 1957 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1958 | int idx = 0; | |
1959 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 1960 | |
d62a17ae | 1961 | /* no-as-set is now the default behavior so we can silently |
1962 | * ignore it */ | |
1963 | if (argv_find(argv, argc, "as-set", &idx)) | |
1964 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
1965 | else | |
1966 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 1967 | |
d62a17ae | 1968 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 1969 | |
d62a17ae | 1970 | return CMD_SUCCESS; |
16fc1eec DS |
1971 | } |
1972 | ||
219178b6 DW |
1973 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
1974 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 1975 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
1976 | NO_STR |
1977 | "BGP specific commands\n" | |
1978 | "Change the default bestpath selection\n" | |
1979 | "AS-path attribute\n" | |
1980 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 1981 | "Generate an AS_SET\n" |
16fc1eec DS |
1982 | "Do not generate an AS_SET\n") |
1983 | { | |
d62a17ae | 1984 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1985 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
1986 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
1987 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1988 | |
d62a17ae | 1989 | return CMD_SUCCESS; |
2fdd455c | 1990 | } |
6b0655a2 | 1991 | |
848973c7 | 1992 | /* "bgp log-neighbor-changes" configuration. */ |
1993 | DEFUN (bgp_log_neighbor_changes, | |
1994 | bgp_log_neighbor_changes_cmd, | |
1995 | "bgp log-neighbor-changes", | |
1996 | "BGP specific commands\n" | |
1997 | "Log neighbor up/down and reset reason\n") | |
1998 | { | |
d62a17ae | 1999 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2000 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2001 | return CMD_SUCCESS; | |
848973c7 | 2002 | } |
2003 | ||
2004 | DEFUN (no_bgp_log_neighbor_changes, | |
2005 | no_bgp_log_neighbor_changes_cmd, | |
2006 | "no bgp log-neighbor-changes", | |
2007 | NO_STR | |
2008 | "BGP specific commands\n" | |
2009 | "Log neighbor up/down and reset reason\n") | |
2010 | { | |
d62a17ae | 2011 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2012 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2013 | return CMD_SUCCESS; | |
848973c7 | 2014 | } |
6b0655a2 | 2015 | |
718e3744 | 2016 | /* "bgp bestpath med" configuration. */ |
2017 | DEFUN (bgp_bestpath_med, | |
2018 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2019 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2020 | "BGP specific commands\n" |
2021 | "Change the default bestpath selection\n" | |
2022 | "MED attribute\n" | |
2023 | "Compare MED among confederation paths\n" | |
838758ac DW |
2024 | "Treat missing MED as the least preferred one\n" |
2025 | "Treat missing MED as the least preferred one\n" | |
2026 | "Compare MED among confederation paths\n") | |
718e3744 | 2027 | { |
d62a17ae | 2028 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2029 | |
d62a17ae | 2030 | int idx = 0; |
2031 | if (argv_find(argv, argc, "confed", &idx)) | |
2032 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2033 | idx = 0; | |
2034 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2035 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2036 | |
d62a17ae | 2037 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2038 | |
d62a17ae | 2039 | return CMD_SUCCESS; |
718e3744 | 2040 | } |
2041 | ||
718e3744 | 2042 | DEFUN (no_bgp_bestpath_med, |
2043 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2044 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2045 | NO_STR |
2046 | "BGP specific commands\n" | |
2047 | "Change the default bestpath selection\n" | |
2048 | "MED attribute\n" | |
2049 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2050 | "Treat missing MED as the least preferred one\n" |
2051 | "Treat missing MED as the least preferred one\n" | |
2052 | "Compare MED among confederation paths\n") | |
718e3744 | 2053 | { |
d62a17ae | 2054 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2055 | |
d62a17ae | 2056 | int idx = 0; |
2057 | if (argv_find(argv, argc, "confed", &idx)) | |
2058 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2059 | idx = 0; | |
2060 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2061 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2062 | |
d62a17ae | 2063 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2064 | |
d62a17ae | 2065 | return CMD_SUCCESS; |
718e3744 | 2066 | } |
2067 | ||
718e3744 | 2068 | /* "no bgp default ipv4-unicast". */ |
2069 | DEFUN (no_bgp_default_ipv4_unicast, | |
2070 | no_bgp_default_ipv4_unicast_cmd, | |
2071 | "no bgp default ipv4-unicast", | |
2072 | NO_STR | |
2073 | "BGP specific commands\n" | |
2074 | "Configure BGP defaults\n" | |
2075 | "Activate ipv4-unicast for a peer by default\n") | |
2076 | { | |
d62a17ae | 2077 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2078 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2079 | return CMD_SUCCESS; | |
718e3744 | 2080 | } |
2081 | ||
2082 | DEFUN (bgp_default_ipv4_unicast, | |
2083 | bgp_default_ipv4_unicast_cmd, | |
2084 | "bgp default ipv4-unicast", | |
2085 | "BGP specific commands\n" | |
2086 | "Configure BGP defaults\n" | |
2087 | "Activate ipv4-unicast for a peer by default\n") | |
2088 | { | |
d62a17ae | 2089 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2090 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2091 | return CMD_SUCCESS; | |
718e3744 | 2092 | } |
6b0655a2 | 2093 | |
04b6bdc0 DW |
2094 | /* Display hostname in certain command outputs */ |
2095 | DEFUN (bgp_default_show_hostname, | |
2096 | bgp_default_show_hostname_cmd, | |
2097 | "bgp default show-hostname", | |
2098 | "BGP specific commands\n" | |
2099 | "Configure BGP defaults\n" | |
2100 | "Show hostname in certain command ouputs\n") | |
2101 | { | |
d62a17ae | 2102 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2103 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2104 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2105 | } |
2106 | ||
2107 | DEFUN (no_bgp_default_show_hostname, | |
2108 | no_bgp_default_show_hostname_cmd, | |
2109 | "no bgp default show-hostname", | |
2110 | NO_STR | |
2111 | "BGP specific commands\n" | |
2112 | "Configure BGP defaults\n" | |
2113 | "Show hostname in certain command ouputs\n") | |
2114 | { | |
d62a17ae | 2115 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2116 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2117 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2118 | } |
2119 | ||
8233ef81 | 2120 | /* "bgp network import-check" configuration. */ |
718e3744 | 2121 | DEFUN (bgp_network_import_check, |
2122 | bgp_network_import_check_cmd, | |
5623e905 | 2123 | "bgp network import-check", |
718e3744 | 2124 | "BGP specific commands\n" |
2125 | "BGP network command\n" | |
5623e905 | 2126 | "Check BGP network route exists in IGP\n") |
718e3744 | 2127 | { |
d62a17ae | 2128 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2129 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2130 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
2131 | bgp_static_redo_import_check(bgp); | |
2132 | } | |
078430f6 | 2133 | |
d62a17ae | 2134 | return CMD_SUCCESS; |
718e3744 | 2135 | } |
2136 | ||
d62a17ae | 2137 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
2138 | "bgp network import-check exact", | |
2139 | "BGP specific commands\n" | |
2140 | "BGP network command\n" | |
2141 | "Check BGP network route exists in IGP\n" | |
2142 | "Match route precisely\n") | |
8233ef81 | 2143 | |
718e3744 | 2144 | DEFUN (no_bgp_network_import_check, |
2145 | no_bgp_network_import_check_cmd, | |
5623e905 | 2146 | "no bgp network import-check", |
718e3744 | 2147 | NO_STR |
2148 | "BGP specific commands\n" | |
2149 | "BGP network command\n" | |
2150 | "Check BGP network route exists in IGP\n") | |
2151 | { | |
d62a17ae | 2152 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2153 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2154 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
2155 | bgp_static_redo_import_check(bgp); | |
2156 | } | |
5623e905 | 2157 | |
d62a17ae | 2158 | return CMD_SUCCESS; |
718e3744 | 2159 | } |
6b0655a2 | 2160 | |
718e3744 | 2161 | DEFUN (bgp_default_local_preference, |
2162 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2163 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2164 | "BGP specific commands\n" |
2165 | "Configure BGP defaults\n" | |
2166 | "local preference (higher=more preferred)\n" | |
2167 | "Configure default local preference value\n") | |
2168 | { | |
d62a17ae | 2169 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2170 | int idx_number = 3; | |
2171 | u_int32_t local_pref; | |
718e3744 | 2172 | |
d62a17ae | 2173 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2174 | |
d62a17ae | 2175 | bgp_default_local_preference_set(bgp, local_pref); |
2176 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 2177 | |
d62a17ae | 2178 | return CMD_SUCCESS; |
718e3744 | 2179 | } |
2180 | ||
2181 | DEFUN (no_bgp_default_local_preference, | |
2182 | no_bgp_default_local_preference_cmd, | |
838758ac | 2183 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2184 | NO_STR |
2185 | "BGP specific commands\n" | |
2186 | "Configure BGP defaults\n" | |
838758ac DW |
2187 | "local preference (higher=more preferred)\n" |
2188 | "Configure default local preference value\n") | |
718e3744 | 2189 | { |
d62a17ae | 2190 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2191 | bgp_default_local_preference_unset(bgp); | |
2192 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2193 | |
d62a17ae | 2194 | return CMD_SUCCESS; |
718e3744 | 2195 | } |
2196 | ||
6b0655a2 | 2197 | |
3f9c7369 DS |
2198 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2199 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2200 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2201 | "BGP specific commands\n" |
2202 | "Configure BGP defaults\n" | |
2203 | "subgroup-pkt-queue-max\n" | |
2204 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2205 | { |
d62a17ae | 2206 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2207 | int idx_number = 3; | |
2208 | u_int32_t max_size; | |
8bd9d948 | 2209 | |
d62a17ae | 2210 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 2211 | |
d62a17ae | 2212 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 2213 | |
d62a17ae | 2214 | return CMD_SUCCESS; |
3f9c7369 DS |
2215 | } |
2216 | ||
2217 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2218 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2219 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2220 | NO_STR |
2221 | "BGP specific commands\n" | |
2222 | "Configure BGP defaults\n" | |
838758ac DW |
2223 | "subgroup-pkt-queue-max\n" |
2224 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2225 | { |
d62a17ae | 2226 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2227 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
2228 | return CMD_SUCCESS; | |
8bd9d948 DS |
2229 | } |
2230 | ||
813d4307 | 2231 | |
8bd9d948 DS |
2232 | DEFUN (bgp_rr_allow_outbound_policy, |
2233 | bgp_rr_allow_outbound_policy_cmd, | |
2234 | "bgp route-reflector allow-outbound-policy", | |
2235 | "BGP specific commands\n" | |
2236 | "Allow modifications made by out route-map\n" | |
2237 | "on ibgp neighbors\n") | |
2238 | { | |
d62a17ae | 2239 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2240 | |
d62a17ae | 2241 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2242 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2243 | update_group_announce_rrclients(bgp); | |
2244 | bgp_clear_star_soft_out(vty, bgp->name); | |
2245 | } | |
8bd9d948 | 2246 | |
d62a17ae | 2247 | return CMD_SUCCESS; |
8bd9d948 DS |
2248 | } |
2249 | ||
2250 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2251 | no_bgp_rr_allow_outbound_policy_cmd, | |
2252 | "no bgp route-reflector allow-outbound-policy", | |
2253 | NO_STR | |
2254 | "BGP specific commands\n" | |
2255 | "Allow modifications made by out route-map\n" | |
2256 | "on ibgp neighbors\n") | |
2257 | { | |
d62a17ae | 2258 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2259 | |
d62a17ae | 2260 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2261 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2262 | update_group_announce_rrclients(bgp); | |
2263 | bgp_clear_star_soft_out(vty, bgp->name); | |
2264 | } | |
8bd9d948 | 2265 | |
d62a17ae | 2266 | return CMD_SUCCESS; |
8bd9d948 DS |
2267 | } |
2268 | ||
f14e6fdb DS |
2269 | DEFUN (bgp_listen_limit, |
2270 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2271 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2272 | "BGP specific commands\n" |
2273 | "Configure BGP defaults\n" | |
2274 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2275 | "Configure Dynamic Neighbors listen limit value\n") | |
2276 | { | |
d62a17ae | 2277 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2278 | int idx_number = 3; | |
2279 | int listen_limit; | |
f14e6fdb | 2280 | |
d62a17ae | 2281 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 2282 | |
d62a17ae | 2283 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 2284 | |
d62a17ae | 2285 | return CMD_SUCCESS; |
f14e6fdb DS |
2286 | } |
2287 | ||
2288 | DEFUN (no_bgp_listen_limit, | |
2289 | no_bgp_listen_limit_cmd, | |
838758ac | 2290 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2291 | "BGP specific commands\n" |
2292 | "Configure BGP defaults\n" | |
2293 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2294 | "Configure Dynamic Neighbors listen limit value to default\n" |
2295 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2296 | { |
d62a17ae | 2297 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2298 | bgp_listen_limit_unset(bgp); | |
2299 | return CMD_SUCCESS; | |
f14e6fdb DS |
2300 | } |
2301 | ||
2302 | ||
20eb8864 | 2303 | /* |
2304 | * Check if this listen range is already configured. Check for exact | |
2305 | * match or overlap based on input. | |
2306 | */ | |
d62a17ae | 2307 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
2308 | struct prefix *range, int exact) | |
2309 | { | |
2310 | struct listnode *node, *nnode; | |
2311 | struct listnode *node1, *nnode1; | |
2312 | struct peer_group *group; | |
2313 | struct prefix *lr; | |
2314 | afi_t afi; | |
2315 | int match; | |
2316 | ||
2317 | afi = family2afi(range->family); | |
2318 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2319 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
2320 | lr)) { | |
2321 | if (exact) | |
2322 | match = prefix_same(range, lr); | |
2323 | else | |
2324 | match = (prefix_match(range, lr) | |
2325 | || prefix_match(lr, range)); | |
2326 | if (match) | |
2327 | return group; | |
2328 | } | |
2329 | } | |
2330 | ||
2331 | return NULL; | |
20eb8864 | 2332 | } |
2333 | ||
f14e6fdb DS |
2334 | DEFUN (bgp_listen_range, |
2335 | bgp_listen_range_cmd, | |
9ccf14f7 | 2336 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2337 | "BGP specific commands\n" |
d7fa34c1 QY |
2338 | "Configure BGP dynamic neighbors listen range\n" |
2339 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2340 | NEIGHBOR_ADDR_STR |
2341 | "Member of the peer-group\n" | |
2342 | "Peer-group name\n") | |
f14e6fdb | 2343 | { |
d62a17ae | 2344 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2345 | struct prefix range; | |
2346 | struct peer_group *group, *existing_group; | |
2347 | afi_t afi; | |
2348 | int ret; | |
2349 | int idx = 0; | |
2350 | ||
2351 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2352 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2353 | char *prefix = argv[idx]->arg; | |
2354 | argv_find(argv, argc, "WORD", &idx); | |
2355 | char *peergroup = argv[idx]->arg; | |
2356 | ||
2357 | /* Convert IP prefix string to struct prefix. */ | |
2358 | ret = str2prefix(prefix, &range); | |
2359 | if (!ret) { | |
2360 | vty_out(vty, "%% Malformed listen range\n"); | |
2361 | return CMD_WARNING_CONFIG_FAILED; | |
2362 | } | |
2363 | ||
2364 | afi = family2afi(range.family); | |
2365 | ||
2366 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2367 | vty_out(vty, | |
2368 | "%% Malformed listen range (link-local address)\n"); | |
2369 | return CMD_WARNING_CONFIG_FAILED; | |
2370 | } | |
2371 | ||
2372 | apply_mask(&range); | |
2373 | ||
2374 | /* Check if same listen range is already configured. */ | |
2375 | existing_group = listen_range_exists(bgp, &range, 1); | |
2376 | if (existing_group) { | |
2377 | if (strcmp(existing_group->name, peergroup) == 0) | |
2378 | return CMD_SUCCESS; | |
2379 | else { | |
2380 | vty_out(vty, | |
2381 | "%% Same listen range is attached to peer-group %s\n", | |
2382 | existing_group->name); | |
2383 | return CMD_WARNING_CONFIG_FAILED; | |
2384 | } | |
2385 | } | |
2386 | ||
2387 | /* Check if an overlapping listen range exists. */ | |
2388 | if (listen_range_exists(bgp, &range, 0)) { | |
2389 | vty_out(vty, | |
2390 | "%% Listen range overlaps with existing listen range\n"); | |
2391 | return CMD_WARNING_CONFIG_FAILED; | |
2392 | } | |
2393 | ||
2394 | group = peer_group_lookup(bgp, peergroup); | |
2395 | if (!group) { | |
2396 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2397 | return CMD_WARNING_CONFIG_FAILED; | |
2398 | } | |
2399 | ||
2400 | ret = peer_group_listen_range_add(group, &range); | |
2401 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
2402 | } |
2403 | ||
2404 | DEFUN (no_bgp_listen_range, | |
2405 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2406 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2407 | NO_STR | |
f14e6fdb | 2408 | "BGP specific commands\n" |
d7fa34c1 QY |
2409 | "Unconfigure BGP dynamic neighbors listen range\n" |
2410 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2411 | NEIGHBOR_ADDR_STR | |
2412 | "Member of the peer-group\n" | |
2413 | "Peer-group name\n") | |
f14e6fdb | 2414 | { |
d62a17ae | 2415 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2416 | struct prefix range; | |
2417 | struct peer_group *group; | |
2418 | afi_t afi; | |
2419 | int ret; | |
2420 | int idx = 0; | |
2421 | ||
2422 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2423 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2424 | char *prefix = argv[idx]->arg; | |
2425 | argv_find(argv, argc, "WORD", &idx); | |
2426 | char *peergroup = argv[idx]->arg; | |
2427 | ||
2428 | /* Convert IP prefix string to struct prefix. */ | |
2429 | ret = str2prefix(prefix, &range); | |
2430 | if (!ret) { | |
2431 | vty_out(vty, "%% Malformed listen range\n"); | |
2432 | return CMD_WARNING_CONFIG_FAILED; | |
2433 | } | |
2434 | ||
2435 | afi = family2afi(range.family); | |
2436 | ||
2437 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2438 | vty_out(vty, | |
2439 | "%% Malformed listen range (link-local address)\n"); | |
2440 | return CMD_WARNING_CONFIG_FAILED; | |
2441 | } | |
2442 | ||
2443 | apply_mask(&range); | |
2444 | ||
2445 | group = peer_group_lookup(bgp, peergroup); | |
2446 | if (!group) { | |
2447 | vty_out(vty, "%% Peer-group does not exist\n"); | |
2448 | return CMD_WARNING_CONFIG_FAILED; | |
2449 | } | |
2450 | ||
2451 | ret = peer_group_listen_range_del(group, &range); | |
2452 | return bgp_vty_return(vty, ret); | |
2453 | } | |
2454 | ||
2455 | int bgp_config_write_listen(struct vty *vty, struct bgp *bgp) | |
2456 | { | |
2457 | struct peer_group *group; | |
2458 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2459 | struct prefix *range; | |
2460 | afi_t afi; | |
2461 | char buf[PREFIX2STR_BUFFER]; | |
2462 | ||
2463 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2464 | vty_out(vty, " bgp listen limit %d\n", | |
2465 | bgp->dynamic_neighbors_limit); | |
2466 | ||
2467 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2468 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
2469 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
2470 | nrnode, range)) { | |
2471 | prefix2str(range, buf, sizeof(buf)); | |
2472 | vty_out(vty, | |
2473 | " bgp listen range %s peer-group %s\n", | |
2474 | buf, group->name); | |
2475 | } | |
2476 | } | |
2477 | } | |
2478 | ||
2479 | return 0; | |
f14e6fdb DS |
2480 | } |
2481 | ||
2482 | ||
907f92c8 DS |
2483 | DEFUN (bgp_disable_connected_route_check, |
2484 | bgp_disable_connected_route_check_cmd, | |
2485 | "bgp disable-ebgp-connected-route-check", | |
2486 | "BGP specific commands\n" | |
2487 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2488 | { | |
d62a17ae | 2489 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2490 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2491 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2492 | |
d62a17ae | 2493 | return CMD_SUCCESS; |
907f92c8 DS |
2494 | } |
2495 | ||
2496 | DEFUN (no_bgp_disable_connected_route_check, | |
2497 | no_bgp_disable_connected_route_check_cmd, | |
2498 | "no bgp disable-ebgp-connected-route-check", | |
2499 | NO_STR | |
2500 | "BGP specific commands\n" | |
2501 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2502 | { | |
d62a17ae | 2503 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2504 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2505 | bgp_clear_star_soft_in(vty, bgp->name); | |
2506 | ||
2507 | return CMD_SUCCESS; | |
2508 | } | |
2509 | ||
2510 | ||
2511 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
2512 | const char *as_str, afi_t afi, safi_t safi) | |
2513 | { | |
2514 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2515 | int ret; | |
2516 | as_t as; | |
2517 | int as_type = AS_SPECIFIED; | |
2518 | union sockunion su; | |
2519 | ||
2520 | if (as_str[0] == 'i') { | |
2521 | as = 0; | |
2522 | as_type = AS_INTERNAL; | |
2523 | } else if (as_str[0] == 'e') { | |
2524 | as = 0; | |
2525 | as_type = AS_EXTERNAL; | |
2526 | } else { | |
2527 | /* Get AS number. */ | |
2528 | as = strtoul(as_str, NULL, 10); | |
2529 | } | |
2530 | ||
2531 | /* If peer is peer group, call proper function. */ | |
2532 | ret = str2sockunion(peer_str, &su); | |
2533 | if (ret < 0) { | |
2534 | /* Check for peer by interface */ | |
2535 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, | |
2536 | safi); | |
2537 | if (ret < 0) { | |
2538 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); | |
2539 | if (ret < 0) { | |
2540 | vty_out(vty, | |
2541 | "%% Create the peer-group or interface first\n"); | |
2542 | return CMD_WARNING_CONFIG_FAILED; | |
2543 | } | |
2544 | return CMD_SUCCESS; | |
2545 | } | |
2546 | } else { | |
2547 | if (peer_address_self_check(bgp, &su)) { | |
2548 | vty_out(vty, | |
2549 | "%% Can not configure the local system as neighbor\n"); | |
2550 | return CMD_WARNING_CONFIG_FAILED; | |
2551 | } | |
2552 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
2553 | } | |
2554 | ||
2555 | /* This peer belongs to peer group. */ | |
2556 | switch (ret) { | |
2557 | case BGP_ERR_PEER_GROUP_MEMBER: | |
2558 | vty_out(vty, | |
2559 | "%% Peer-group AS %u. Cannot configure remote-as for member\n", | |
2560 | as); | |
2561 | return CMD_WARNING_CONFIG_FAILED; | |
2562 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
2563 | vty_out(vty, | |
2564 | "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n", | |
2565 | as, as_str); | |
2566 | return CMD_WARNING_CONFIG_FAILED; | |
2567 | } | |
2568 | return bgp_vty_return(vty, ret); | |
718e3744 | 2569 | } |
2570 | ||
2571 | DEFUN (neighbor_remote_as, | |
2572 | neighbor_remote_as_cmd, | |
3a2d747c | 2573 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2574 | NEIGHBOR_STR |
2575 | NEIGHBOR_ADDR_STR2 | |
2576 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2577 | AS_STR |
3a2d747c QY |
2578 | "Internal BGP peer\n" |
2579 | "External BGP peer\n") | |
718e3744 | 2580 | { |
d62a17ae | 2581 | int idx_peer = 1; |
2582 | int idx_remote_as = 3; | |
2583 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
2584 | argv[idx_remote_as]->arg, AFI_IP, | |
2585 | SAFI_UNICAST); | |
2586 | } | |
2587 | ||
2588 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
2589 | afi_t afi, safi_t safi, int v6only, | |
2590 | const char *peer_group_name, | |
2591 | const char *as_str) | |
2592 | { | |
2593 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2594 | as_t as = 0; | |
2595 | int as_type = AS_UNSPECIFIED; | |
2596 | struct peer *peer; | |
2597 | struct peer_group *group; | |
2598 | int ret = 0; | |
2599 | union sockunion su; | |
2600 | ||
2601 | group = peer_group_lookup(bgp, conf_if); | |
2602 | ||
2603 | if (group) { | |
2604 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
2605 | return CMD_WARNING_CONFIG_FAILED; | |
2606 | } | |
2607 | ||
2608 | if (as_str) { | |
2609 | if (as_str[0] == 'i') { | |
2610 | as_type = AS_INTERNAL; | |
2611 | } else if (as_str[0] == 'e') { | |
2612 | as_type = AS_EXTERNAL; | |
2613 | } else { | |
2614 | /* Get AS number. */ | |
2615 | as = strtoul(as_str, NULL, 10); | |
2616 | as_type = AS_SPECIFIED; | |
2617 | } | |
2618 | } | |
2619 | ||
2620 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
2621 | if (peer) { | |
2622 | if (as_str) | |
2623 | ret = peer_remote_as(bgp, &su, conf_if, &as, as_type, | |
2624 | afi, safi); | |
2625 | } else { | |
2626 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2627 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
2628 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2629 | as_type, 0, 0, NULL); | |
2630 | else | |
2631 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2632 | as_type, afi, safi, NULL); | |
2633 | ||
2634 | if (!peer) { | |
2635 | vty_out(vty, "%% BGP failed to create peer\n"); | |
2636 | return CMD_WARNING_CONFIG_FAILED; | |
2637 | } | |
2638 | ||
2639 | if (v6only) | |
2640 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2641 | ||
2642 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
2643 | * this | |
2644 | * any unnumbered peer in order to not worry about run-time | |
2645 | * transitions | |
2646 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
2647 | * address | |
2648 | * gets deleted later etc.) | |
2649 | */ | |
2650 | if (peer->ifp) | |
2651 | bgp_zebra_initiate_radv(bgp, peer); | |
2652 | } | |
2653 | ||
2654 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
2655 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
2656 | if (v6only) | |
2657 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2658 | else | |
2659 | UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2660 | ||
2661 | /* v6only flag changed. Reset bgp seesion */ | |
2662 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2663 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2664 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2665 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2666 | } else | |
2667 | bgp_session_reset(peer); | |
2668 | } | |
2669 | ||
2670 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) | |
2671 | peer_flag_set(peer, PEER_FLAG_CAPABILITY_ENHE); | |
2672 | ||
2673 | if (peer_group_name) { | |
2674 | group = peer_group_lookup(bgp, peer_group_name); | |
2675 | if (!group) { | |
2676 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2677 | return CMD_WARNING_CONFIG_FAILED; | |
2678 | } | |
2679 | ||
2680 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
2681 | } | |
2682 | ||
2683 | return bgp_vty_return(vty, ret); | |
a80beece DS |
2684 | } |
2685 | ||
4c48cf63 DW |
2686 | DEFUN (neighbor_interface_config, |
2687 | neighbor_interface_config_cmd, | |
31500417 | 2688 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2689 | NEIGHBOR_STR |
2690 | "Interface name or neighbor tag\n" | |
31500417 DW |
2691 | "Enable BGP on interface\n" |
2692 | "Member of the peer-group\n" | |
16cedbb0 | 2693 | "Peer-group name\n") |
4c48cf63 | 2694 | { |
d62a17ae | 2695 | int idx_word = 1; |
2696 | int idx_peer_group_word = 4; | |
31500417 | 2697 | |
d62a17ae | 2698 | if (argc > idx_peer_group_word) |
2699 | return peer_conf_interface_get( | |
2700 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2701 | argv[idx_peer_group_word]->arg, NULL); | |
2702 | else | |
2703 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2704 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
2705 | } |
2706 | ||
4c48cf63 DW |
2707 | DEFUN (neighbor_interface_config_v6only, |
2708 | neighbor_interface_config_v6only_cmd, | |
31500417 | 2709 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
2710 | NEIGHBOR_STR |
2711 | "Interface name or neighbor tag\n" | |
2712 | "Enable BGP on interface\n" | |
31500417 DW |
2713 | "Enable BGP with v6 link-local only\n" |
2714 | "Member of the peer-group\n" | |
16cedbb0 | 2715 | "Peer-group name\n") |
4c48cf63 | 2716 | { |
d62a17ae | 2717 | int idx_word = 1; |
2718 | int idx_peer_group_word = 5; | |
31500417 | 2719 | |
d62a17ae | 2720 | if (argc > idx_peer_group_word) |
2721 | return peer_conf_interface_get( | |
2722 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2723 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 2724 | |
d62a17ae | 2725 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
2726 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
2727 | } |
2728 | ||
a80beece | 2729 | |
b3a39dc5 DD |
2730 | DEFUN (neighbor_interface_config_remote_as, |
2731 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2732 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2733 | NEIGHBOR_STR |
2734 | "Interface name or neighbor tag\n" | |
2735 | "Enable BGP on interface\n" | |
3a2d747c | 2736 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2737 | AS_STR |
3a2d747c QY |
2738 | "Internal BGP peer\n" |
2739 | "External BGP peer\n") | |
b3a39dc5 | 2740 | { |
d62a17ae | 2741 | int idx_word = 1; |
2742 | int idx_remote_as = 4; | |
2743 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2744 | SAFI_UNICAST, 0, NULL, | |
2745 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2746 | } |
2747 | ||
2748 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
2749 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 2750 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2751 | NEIGHBOR_STR |
2752 | "Interface name or neighbor tag\n" | |
3a2d747c | 2753 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 2754 | "Enable BGP on interface\n" |
3a2d747c | 2755 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2756 | AS_STR |
3a2d747c QY |
2757 | "Internal BGP peer\n" |
2758 | "External BGP peer\n") | |
b3a39dc5 | 2759 | { |
d62a17ae | 2760 | int idx_word = 1; |
2761 | int idx_remote_as = 5; | |
2762 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2763 | SAFI_UNICAST, 1, NULL, | |
2764 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2765 | } |
2766 | ||
718e3744 | 2767 | DEFUN (neighbor_peer_group, |
2768 | neighbor_peer_group_cmd, | |
2769 | "neighbor WORD peer-group", | |
2770 | NEIGHBOR_STR | |
a80beece | 2771 | "Interface name or neighbor tag\n" |
718e3744 | 2772 | "Configure peer-group\n") |
2773 | { | |
d62a17ae | 2774 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2775 | int idx_word = 1; | |
2776 | struct peer *peer; | |
2777 | struct peer_group *group; | |
718e3744 | 2778 | |
d62a17ae | 2779 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
2780 | if (peer) { | |
2781 | vty_out(vty, "%% Name conflict with interface: \n"); | |
2782 | return CMD_WARNING_CONFIG_FAILED; | |
2783 | } | |
718e3744 | 2784 | |
d62a17ae | 2785 | group = peer_group_get(bgp, argv[idx_word]->arg); |
2786 | if (!group) { | |
2787 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
2788 | return CMD_WARNING_CONFIG_FAILED; | |
2789 | } | |
718e3744 | 2790 | |
d62a17ae | 2791 | return CMD_SUCCESS; |
718e3744 | 2792 | } |
2793 | ||
2794 | DEFUN (no_neighbor, | |
2795 | no_neighbor_cmd, | |
dab8cd00 | 2796 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 2797 | NO_STR |
2798 | NEIGHBOR_STR | |
3a2d747c QY |
2799 | NEIGHBOR_ADDR_STR2 |
2800 | "Specify a BGP neighbor\n" | |
2801 | AS_STR | |
2802 | "Internal BGP peer\n" | |
2803 | "External BGP peer\n") | |
718e3744 | 2804 | { |
d62a17ae | 2805 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2806 | int idx_peer = 2; | |
2807 | int ret; | |
2808 | union sockunion su; | |
2809 | struct peer_group *group; | |
2810 | struct peer *peer; | |
2811 | struct peer *other; | |
2812 | ||
2813 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
2814 | if (ret < 0) { | |
2815 | /* look up for neighbor by interface name config. */ | |
2816 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
2817 | if (peer) { | |
2818 | /* Request zebra to terminate IPv6 RAs on this | |
2819 | * interface. */ | |
2820 | if (peer->ifp) | |
2821 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
2822 | peer_delete(peer); | |
2823 | return CMD_SUCCESS; | |
2824 | } | |
f14e6fdb | 2825 | |
d62a17ae | 2826 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
2827 | if (group) | |
2828 | peer_group_delete(group); | |
2829 | else { | |
2830 | vty_out(vty, "%% Create the peer-group first\n"); | |
2831 | return CMD_WARNING_CONFIG_FAILED; | |
2832 | } | |
2833 | } else { | |
2834 | peer = peer_lookup(bgp, &su); | |
2835 | if (peer) { | |
2836 | if (peer_dynamic_neighbor(peer)) { | |
2837 | vty_out(vty, | |
2838 | "%% Operation not allowed on a dynamic neighbor\n"); | |
2839 | return CMD_WARNING_CONFIG_FAILED; | |
2840 | } | |
2841 | ||
2842 | other = peer->doppelganger; | |
2843 | peer_delete(peer); | |
2844 | if (other && other->status != Deleted) | |
2845 | peer_delete(other); | |
2846 | } | |
1ff9a340 | 2847 | } |
718e3744 | 2848 | |
d62a17ae | 2849 | return CMD_SUCCESS; |
718e3744 | 2850 | } |
2851 | ||
a80beece DS |
2852 | DEFUN (no_neighbor_interface_config, |
2853 | no_neighbor_interface_config_cmd, | |
31500417 | 2854 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
2855 | NO_STR |
2856 | NEIGHBOR_STR | |
2857 | "Interface name\n" | |
31500417 DW |
2858 | "Configure BGP on interface\n" |
2859 | "Enable BGP with v6 link-local only\n" | |
2860 | "Member of the peer-group\n" | |
16cedbb0 | 2861 | "Peer-group name\n" |
3a2d747c QY |
2862 | "Specify a BGP neighbor\n" |
2863 | AS_STR | |
2864 | "Internal BGP peer\n" | |
2865 | "External BGP peer\n") | |
a80beece | 2866 | { |
d62a17ae | 2867 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2868 | int idx_word = 2; | |
2869 | struct peer *peer; | |
2870 | ||
2871 | /* look up for neighbor by interface name config. */ | |
2872 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
2873 | if (peer) { | |
2874 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
2875 | if (peer->ifp) | |
2876 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
2877 | peer_delete(peer); | |
2878 | } else { | |
2879 | vty_out(vty, "%% Create the bgp interface first\n"); | |
2880 | return CMD_WARNING_CONFIG_FAILED; | |
2881 | } | |
2882 | return CMD_SUCCESS; | |
a80beece DS |
2883 | } |
2884 | ||
718e3744 | 2885 | DEFUN (no_neighbor_peer_group, |
2886 | no_neighbor_peer_group_cmd, | |
2887 | "no neighbor WORD peer-group", | |
2888 | NO_STR | |
2889 | NEIGHBOR_STR | |
2890 | "Neighbor tag\n" | |
2891 | "Configure peer-group\n") | |
2892 | { | |
d62a17ae | 2893 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2894 | int idx_word = 2; | |
2895 | struct peer_group *group; | |
718e3744 | 2896 | |
d62a17ae | 2897 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
2898 | if (group) | |
2899 | peer_group_delete(group); | |
2900 | else { | |
2901 | vty_out(vty, "%% Create the peer-group first\n"); | |
2902 | return CMD_WARNING_CONFIG_FAILED; | |
2903 | } | |
2904 | return CMD_SUCCESS; | |
718e3744 | 2905 | } |
2906 | ||
a80beece DS |
2907 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
2908 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 2909 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2910 | NO_STR |
2911 | NEIGHBOR_STR | |
a80beece | 2912 | "Interface name or neighbor tag\n" |
718e3744 | 2913 | "Specify a BGP neighbor\n" |
3a2d747c QY |
2914 | AS_STR |
2915 | "Internal BGP peer\n" | |
2916 | "External BGP peer\n") | |
718e3744 | 2917 | { |
d62a17ae | 2918 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2919 | int idx_word = 2; | |
2920 | struct peer_group *group; | |
2921 | struct peer *peer; | |
2922 | ||
2923 | /* look up for neighbor by interface name config. */ | |
2924 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
2925 | if (peer) { | |
2926 | peer_as_change(peer, 0, AS_SPECIFIED); | |
2927 | return CMD_SUCCESS; | |
2928 | } | |
2929 | ||
2930 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
2931 | if (group) | |
2932 | peer_group_remote_as_delete(group); | |
2933 | else { | |
2934 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
2935 | return CMD_WARNING_CONFIG_FAILED; | |
2936 | } | |
2937 | return CMD_SUCCESS; | |
718e3744 | 2938 | } |
6b0655a2 | 2939 | |
718e3744 | 2940 | DEFUN (neighbor_local_as, |
2941 | neighbor_local_as_cmd, | |
9ccf14f7 | 2942 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 2943 | NEIGHBOR_STR |
2944 | NEIGHBOR_ADDR_STR2 | |
2945 | "Specify a local-as number\n" | |
2946 | "AS number used as local AS\n") | |
2947 | { | |
d62a17ae | 2948 | int idx_peer = 1; |
2949 | int idx_number = 3; | |
2950 | struct peer *peer; | |
2951 | int ret; | |
2952 | as_t as; | |
718e3744 | 2953 | |
d62a17ae | 2954 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2955 | if (!peer) | |
2956 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 2957 | |
d62a17ae | 2958 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
2959 | ret = peer_local_as_set(peer, as, 0, 0); | |
2960 | return bgp_vty_return(vty, ret); | |
718e3744 | 2961 | } |
2962 | ||
2963 | DEFUN (neighbor_local_as_no_prepend, | |
2964 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 2965 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 2966 | NEIGHBOR_STR |
2967 | NEIGHBOR_ADDR_STR2 | |
2968 | "Specify a local-as number\n" | |
2969 | "AS number used as local AS\n" | |
2970 | "Do not prepend local-as to updates from ebgp peers\n") | |
2971 | { | |
d62a17ae | 2972 | int idx_peer = 1; |
2973 | int idx_number = 3; | |
2974 | struct peer *peer; | |
2975 | int ret; | |
2976 | as_t as; | |
718e3744 | 2977 | |
d62a17ae | 2978 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2979 | if (!peer) | |
2980 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 2981 | |
d62a17ae | 2982 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
2983 | ret = peer_local_as_set(peer, as, 1, 0); | |
2984 | return bgp_vty_return(vty, ret); | |
718e3744 | 2985 | } |
2986 | ||
9d3f9705 AC |
2987 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
2988 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 2989 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
2990 | NEIGHBOR_STR |
2991 | NEIGHBOR_ADDR_STR2 | |
2992 | "Specify a local-as number\n" | |
2993 | "AS number used as local AS\n" | |
2994 | "Do not prepend local-as to updates from ebgp peers\n" | |
2995 | "Do not prepend local-as to updates from ibgp peers\n") | |
2996 | { | |
d62a17ae | 2997 | int idx_peer = 1; |
2998 | int idx_number = 3; | |
2999 | struct peer *peer; | |
3000 | int ret; | |
3001 | as_t as; | |
9d3f9705 | 3002 | |
d62a17ae | 3003 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3004 | if (!peer) | |
3005 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3006 | |
d62a17ae | 3007 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3008 | ret = peer_local_as_set(peer, as, 1, 1); | |
3009 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3010 | } |
3011 | ||
718e3744 | 3012 | DEFUN (no_neighbor_local_as, |
3013 | no_neighbor_local_as_cmd, | |
a636c635 | 3014 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3015 | NO_STR |
3016 | NEIGHBOR_STR | |
3017 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3018 | "Specify a local-as number\n" |
3019 | "AS number used as local AS\n" | |
3020 | "Do not prepend local-as to updates from ebgp peers\n" | |
3021 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3022 | { |
d62a17ae | 3023 | int idx_peer = 2; |
3024 | struct peer *peer; | |
3025 | int ret; | |
718e3744 | 3026 | |
d62a17ae | 3027 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3028 | if (!peer) | |
3029 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3030 | |
d62a17ae | 3031 | ret = peer_local_as_unset(peer); |
3032 | return bgp_vty_return(vty, ret); | |
718e3744 | 3033 | } |
3034 | ||
718e3744 | 3035 | |
3f9c7369 DS |
3036 | DEFUN (neighbor_solo, |
3037 | neighbor_solo_cmd, | |
9ccf14f7 | 3038 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3039 | NEIGHBOR_STR |
3040 | NEIGHBOR_ADDR_STR2 | |
3041 | "Solo peer - part of its own update group\n") | |
3042 | { | |
d62a17ae | 3043 | int idx_peer = 1; |
3044 | struct peer *peer; | |
3045 | int ret; | |
3f9c7369 | 3046 | |
d62a17ae | 3047 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3048 | if (!peer) | |
3049 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3050 | |
d62a17ae | 3051 | ret = update_group_adjust_soloness(peer, 1); |
3052 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3053 | } |
3054 | ||
3055 | DEFUN (no_neighbor_solo, | |
3056 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3057 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3058 | NO_STR |
3059 | NEIGHBOR_STR | |
3060 | NEIGHBOR_ADDR_STR2 | |
3061 | "Solo peer - part of its own update group\n") | |
3062 | { | |
d62a17ae | 3063 | int idx_peer = 2; |
3064 | struct peer *peer; | |
3065 | int ret; | |
3f9c7369 | 3066 | |
d62a17ae | 3067 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3068 | if (!peer) | |
3069 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3070 | |
d62a17ae | 3071 | ret = update_group_adjust_soloness(peer, 0); |
3072 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3073 | } |
3074 | ||
0df7c91f PJ |
3075 | DEFUN (neighbor_password, |
3076 | neighbor_password_cmd, | |
9ccf14f7 | 3077 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3078 | NEIGHBOR_STR |
3079 | NEIGHBOR_ADDR_STR2 | |
3080 | "Set a password\n" | |
3081 | "The password\n") | |
3082 | { | |
d62a17ae | 3083 | int idx_peer = 1; |
3084 | int idx_line = 3; | |
3085 | struct peer *peer; | |
3086 | int ret; | |
0df7c91f | 3087 | |
d62a17ae | 3088 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3089 | if (!peer) | |
3090 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3091 | |
d62a17ae | 3092 | ret = peer_password_set(peer, argv[idx_line]->arg); |
3093 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
3094 | } |
3095 | ||
3096 | DEFUN (no_neighbor_password, | |
3097 | no_neighbor_password_cmd, | |
a636c635 | 3098 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3099 | NO_STR |
3100 | NEIGHBOR_STR | |
3101 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3102 | "Set a password\n" |
3103 | "The password\n") | |
0df7c91f | 3104 | { |
d62a17ae | 3105 | int idx_peer = 2; |
3106 | struct peer *peer; | |
3107 | int ret; | |
0df7c91f | 3108 | |
d62a17ae | 3109 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3110 | if (!peer) | |
3111 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3112 | |
d62a17ae | 3113 | ret = peer_password_unset(peer); |
3114 | return bgp_vty_return(vty, ret); | |
0df7c91f | 3115 | } |
6b0655a2 | 3116 | |
813d4307 | 3117 | |
718e3744 | 3118 | DEFUN (neighbor_activate, |
3119 | neighbor_activate_cmd, | |
9ccf14f7 | 3120 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3121 | NEIGHBOR_STR |
3122 | NEIGHBOR_ADDR_STR2 | |
3123 | "Enable the Address Family for this Neighbor\n") | |
3124 | { | |
d62a17ae | 3125 | int idx_peer = 1; |
3126 | int ret; | |
3127 | struct peer *peer; | |
718e3744 | 3128 | |
d62a17ae | 3129 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3130 | if (!peer) | |
3131 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3132 | |
d62a17ae | 3133 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3134 | return bgp_vty_return(vty, ret); | |
718e3744 | 3135 | } |
3136 | ||
d62a17ae | 3137 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
3138 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3139 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3140 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3141 | |
718e3744 | 3142 | DEFUN (no_neighbor_activate, |
3143 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3144 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3145 | NO_STR |
3146 | NEIGHBOR_STR | |
3147 | NEIGHBOR_ADDR_STR2 | |
3148 | "Enable the Address Family for this Neighbor\n") | |
3149 | { | |
d62a17ae | 3150 | int idx_peer = 2; |
3151 | int ret; | |
3152 | struct peer *peer; | |
718e3744 | 3153 | |
d62a17ae | 3154 | /* Lookup peer. */ |
3155 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3156 | if (!peer) | |
3157 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3158 | |
d62a17ae | 3159 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3160 | return bgp_vty_return(vty, ret); | |
718e3744 | 3161 | } |
6b0655a2 | 3162 | |
d62a17ae | 3163 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
3164 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3165 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3166 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3167 | |
718e3744 | 3168 | DEFUN (neighbor_set_peer_group, |
3169 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3170 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3171 | NEIGHBOR_STR |
a80beece | 3172 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3173 | "Member of the peer-group\n" |
16cedbb0 | 3174 | "Peer-group name\n") |
718e3744 | 3175 | { |
d62a17ae | 3176 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3177 | int idx_peer = 1; | |
3178 | int idx_word = 3; | |
3179 | int ret; | |
3180 | as_t as; | |
3181 | union sockunion su; | |
3182 | struct peer *peer; | |
3183 | struct peer_group *group; | |
3184 | ||
3185 | peer = NULL; | |
3186 | ||
3187 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3188 | if (ret < 0) { | |
3189 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3190 | if (!peer) { | |
3191 | vty_out(vty, "%% Malformed address or name: %s\n", | |
3192 | argv[idx_peer]->arg); | |
3193 | return CMD_WARNING_CONFIG_FAILED; | |
3194 | } | |
3195 | } else { | |
3196 | if (peer_address_self_check(bgp, &su)) { | |
3197 | vty_out(vty, | |
3198 | "%% Can not configure the local system as neighbor\n"); | |
3199 | return CMD_WARNING_CONFIG_FAILED; | |
3200 | } | |
3201 | ||
3202 | /* Disallow for dynamic neighbor. */ | |
3203 | peer = peer_lookup(bgp, &su); | |
3204 | if (peer && peer_dynamic_neighbor(peer)) { | |
3205 | vty_out(vty, | |
3206 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3207 | return CMD_WARNING_CONFIG_FAILED; | |
3208 | } | |
3209 | } | |
3210 | ||
3211 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3212 | if (!group) { | |
3213 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3214 | return CMD_WARNING_CONFIG_FAILED; | |
3215 | } | |
3216 | ||
3217 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3218 | ||
3219 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
3220 | vty_out(vty, | |
3221 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
3222 | as); | |
3223 | return CMD_WARNING_CONFIG_FAILED; | |
3224 | } | |
3225 | ||
3226 | return bgp_vty_return(vty, ret); | |
3227 | } | |
3228 | ||
3229 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
3230 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3231 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3232 | "Member of the peer-group\n" | |
3233 | "Peer-group name\n") | |
596c17ba | 3234 | |
718e3744 | 3235 | DEFUN (no_neighbor_set_peer_group, |
3236 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3237 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3238 | NO_STR |
3239 | NEIGHBOR_STR | |
a80beece | 3240 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3241 | "Member of the peer-group\n" |
16cedbb0 | 3242 | "Peer-group name\n") |
718e3744 | 3243 | { |
d62a17ae | 3244 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3245 | int idx_peer = 2; | |
3246 | int idx_word = 4; | |
3247 | int ret; | |
3248 | struct peer *peer; | |
3249 | struct peer_group *group; | |
3250 | ||
3251 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
3252 | if (!peer) | |
3253 | return CMD_WARNING_CONFIG_FAILED; | |
3254 | ||
3255 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3256 | if (!group) { | |
3257 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3258 | return CMD_WARNING_CONFIG_FAILED; | |
3259 | } | |
718e3744 | 3260 | |
d62a17ae | 3261 | ret = peer_group_unbind(bgp, peer, group); |
718e3744 | 3262 | |
d62a17ae | 3263 | return bgp_vty_return(vty, ret); |
718e3744 | 3264 | } |
6b0655a2 | 3265 | |
d62a17ae | 3266 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
3267 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3268 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3269 | "Member of the peer-group\n" | |
3270 | "Peer-group name\n") | |
596c17ba | 3271 | |
d62a17ae | 3272 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
3273 | u_int16_t flag, int set) | |
718e3744 | 3274 | { |
d62a17ae | 3275 | int ret; |
3276 | struct peer *peer; | |
718e3744 | 3277 | |
d62a17ae | 3278 | peer = peer_and_group_lookup_vty(vty, ip_str); |
3279 | if (!peer) | |
3280 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3281 | |
d62a17ae | 3282 | /* |
3283 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3284 | * we should not accept disable-connected-check. | |
3285 | */ | |
3286 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3287 | vty_out(vty, | |
3288 | "%s is directly connected peer, cannot accept disable-" | |
3289 | "connected-check\n", | |
3290 | ip_str); | |
3291 | return CMD_WARNING_CONFIG_FAILED; | |
3292 | } | |
8cdabf90 | 3293 | |
d62a17ae | 3294 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3295 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 3296 | |
d62a17ae | 3297 | if (set) |
3298 | ret = peer_flag_set(peer, flag); | |
3299 | else | |
3300 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 3301 | |
d62a17ae | 3302 | return bgp_vty_return(vty, ret); |
718e3744 | 3303 | } |
3304 | ||
d62a17ae | 3305 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, |
3306 | u_int16_t flag) | |
718e3744 | 3307 | { |
d62a17ae | 3308 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 3309 | } |
3310 | ||
d62a17ae | 3311 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
3312 | u_int16_t flag) | |
718e3744 | 3313 | { |
d62a17ae | 3314 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 3315 | } |
3316 | ||
3317 | /* neighbor passive. */ | |
3318 | DEFUN (neighbor_passive, | |
3319 | neighbor_passive_cmd, | |
9ccf14f7 | 3320 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3321 | NEIGHBOR_STR |
3322 | NEIGHBOR_ADDR_STR2 | |
3323 | "Don't send open messages to this neighbor\n") | |
3324 | { | |
d62a17ae | 3325 | int idx_peer = 1; |
3326 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3327 | } |
3328 | ||
3329 | DEFUN (no_neighbor_passive, | |
3330 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3331 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3332 | NO_STR |
3333 | NEIGHBOR_STR | |
3334 | NEIGHBOR_ADDR_STR2 | |
3335 | "Don't send open messages to this neighbor\n") | |
3336 | { | |
d62a17ae | 3337 | int idx_peer = 2; |
3338 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3339 | } |
6b0655a2 | 3340 | |
718e3744 | 3341 | /* neighbor shutdown. */ |
73d70fa6 DL |
3342 | DEFUN (neighbor_shutdown_msg, |
3343 | neighbor_shutdown_msg_cmd, | |
3344 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3345 | NEIGHBOR_STR |
3346 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3347 | "Administratively shut down this neighbor\n" |
3348 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3349 | "Shutdown message\n") | |
718e3744 | 3350 | { |
d62a17ae | 3351 | int idx_peer = 1; |
73d70fa6 | 3352 | |
d62a17ae | 3353 | if (argc >= 5) { |
3354 | struct peer *peer = | |
3355 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3356 | char *message; | |
73d70fa6 | 3357 | |
d62a17ae | 3358 | if (!peer) |
3359 | return CMD_WARNING_CONFIG_FAILED; | |
3360 | message = argv_concat(argv, argc, 4); | |
3361 | peer_tx_shutdown_message_set(peer, message); | |
3362 | XFREE(MTYPE_TMP, message); | |
3363 | } | |
73d70fa6 | 3364 | |
d62a17ae | 3365 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3366 | } |
3367 | ||
d62a17ae | 3368 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
3369 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3370 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3371 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3372 | |
3373 | DEFUN (no_neighbor_shutdown_msg, | |
3374 | no_neighbor_shutdown_msg_cmd, | |
3375 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3376 | NO_STR | |
3377 | NEIGHBOR_STR | |
3378 | NEIGHBOR_ADDR_STR2 | |
3379 | "Administratively shut down this neighbor\n" | |
3380 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3381 | "Shutdown message\n") | |
718e3744 | 3382 | { |
d62a17ae | 3383 | int idx_peer = 2; |
73d70fa6 | 3384 | |
d62a17ae | 3385 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
3386 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 3387 | } |
6b0655a2 | 3388 | |
d62a17ae | 3389 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
3390 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3391 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3392 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 3393 | |
718e3744 | 3394 | /* neighbor capability dynamic. */ |
3395 | DEFUN (neighbor_capability_dynamic, | |
3396 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3397 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3398 | NEIGHBOR_STR |
3399 | NEIGHBOR_ADDR_STR2 | |
3400 | "Advertise capability to the peer\n" | |
3401 | "Advertise dynamic capability to this neighbor\n") | |
3402 | { | |
d62a17ae | 3403 | int idx_peer = 1; |
3404 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3405 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3406 | } |
3407 | ||
3408 | DEFUN (no_neighbor_capability_dynamic, | |
3409 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3410 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3411 | NO_STR |
3412 | NEIGHBOR_STR | |
3413 | NEIGHBOR_ADDR_STR2 | |
3414 | "Advertise capability to the peer\n" | |
3415 | "Advertise dynamic capability to this neighbor\n") | |
3416 | { | |
d62a17ae | 3417 | int idx_peer = 2; |
3418 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3419 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3420 | } |
6b0655a2 | 3421 | |
718e3744 | 3422 | /* neighbor dont-capability-negotiate */ |
3423 | DEFUN (neighbor_dont_capability_negotiate, | |
3424 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3425 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3426 | NEIGHBOR_STR |
3427 | NEIGHBOR_ADDR_STR2 | |
3428 | "Do not perform capability negotiation\n") | |
3429 | { | |
d62a17ae | 3430 | int idx_peer = 1; |
3431 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3432 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3433 | } |
3434 | ||
3435 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3436 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3437 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3438 | NO_STR |
3439 | NEIGHBOR_STR | |
3440 | NEIGHBOR_ADDR_STR2 | |
3441 | "Do not perform capability negotiation\n") | |
3442 | { | |
d62a17ae | 3443 | int idx_peer = 2; |
3444 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3445 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3446 | } |
6b0655a2 | 3447 | |
8a92a8a0 DS |
3448 | /* neighbor capability extended next hop encoding */ |
3449 | DEFUN (neighbor_capability_enhe, | |
3450 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3451 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3452 | NEIGHBOR_STR |
3453 | NEIGHBOR_ADDR_STR2 | |
3454 | "Advertise capability to the peer\n" | |
3455 | "Advertise extended next-hop capability to the peer\n") | |
3456 | { | |
d62a17ae | 3457 | int idx_peer = 1; |
3458 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3459 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3460 | } |
3461 | ||
3462 | DEFUN (no_neighbor_capability_enhe, | |
3463 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3464 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3465 | NO_STR |
3466 | NEIGHBOR_STR | |
3467 | NEIGHBOR_ADDR_STR2 | |
3468 | "Advertise capability to the peer\n" | |
3469 | "Advertise extended next-hop capability to the peer\n") | |
3470 | { | |
d62a17ae | 3471 | int idx_peer = 2; |
3472 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3473 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3474 | } |
3475 | ||
d62a17ae | 3476 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
3477 | afi_t afi, safi_t safi, u_int32_t flag, | |
3478 | int set) | |
718e3744 | 3479 | { |
d62a17ae | 3480 | int ret; |
3481 | struct peer *peer; | |
718e3744 | 3482 | |
d62a17ae | 3483 | peer = peer_and_group_lookup_vty(vty, peer_str); |
3484 | if (!peer) | |
3485 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3486 | |
d62a17ae | 3487 | if (set) |
3488 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
3489 | else | |
3490 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 3491 | |
d62a17ae | 3492 | return bgp_vty_return(vty, ret); |
718e3744 | 3493 | } |
3494 | ||
d62a17ae | 3495 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
3496 | afi_t afi, safi_t safi, u_int32_t flag) | |
718e3744 | 3497 | { |
d62a17ae | 3498 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 3499 | } |
3500 | ||
d62a17ae | 3501 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
3502 | afi_t afi, safi_t safi, u_int32_t flag) | |
718e3744 | 3503 | { |
d62a17ae | 3504 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 3505 | } |
6b0655a2 | 3506 | |
718e3744 | 3507 | /* neighbor capability orf prefix-list. */ |
3508 | DEFUN (neighbor_capability_orf_prefix, | |
3509 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3510 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3511 | NEIGHBOR_STR |
3512 | NEIGHBOR_ADDR_STR2 | |
3513 | "Advertise capability to the peer\n" | |
3514 | "Advertise ORF capability to the peer\n" | |
3515 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3516 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3517 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3518 | "Capability to SEND the ORF to this neighbor\n") | |
3519 | { | |
d62a17ae | 3520 | int idx_peer = 1; |
3521 | int idx_send_recv = 5; | |
3522 | u_int16_t flag = 0; | |
3523 | ||
3524 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3525 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3526 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3527 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3528 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3529 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3530 | else { | |
3531 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3532 | return CMD_WARNING_CONFIG_FAILED; | |
3533 | } | |
3534 | ||
3535 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3536 | bgp_node_safi(vty), flag); | |
3537 | } | |
3538 | ||
3539 | ALIAS_HIDDEN( | |
3540 | neighbor_capability_orf_prefix, | |
3541 | neighbor_capability_orf_prefix_hidden_cmd, | |
3542 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3543 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3544 | "Advertise capability to the peer\n" | |
3545 | "Advertise ORF capability to the peer\n" | |
3546 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3547 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3548 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3549 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3550 | |
718e3744 | 3551 | DEFUN (no_neighbor_capability_orf_prefix, |
3552 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3553 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3554 | NO_STR |
3555 | NEIGHBOR_STR | |
3556 | NEIGHBOR_ADDR_STR2 | |
3557 | "Advertise capability to the peer\n" | |
3558 | "Advertise ORF capability to the peer\n" | |
3559 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3560 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3561 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3562 | "Capability to SEND the ORF to this neighbor\n") | |
3563 | { | |
d62a17ae | 3564 | int idx_peer = 2; |
3565 | int idx_send_recv = 6; | |
3566 | u_int16_t flag = 0; | |
3567 | ||
3568 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3569 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3570 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3571 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3572 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3573 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3574 | else { | |
3575 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3576 | return CMD_WARNING_CONFIG_FAILED; | |
3577 | } | |
3578 | ||
3579 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3580 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3581 | flag); | |
3582 | } | |
3583 | ||
3584 | ALIAS_HIDDEN( | |
3585 | no_neighbor_capability_orf_prefix, | |
3586 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
3587 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3588 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3589 | "Advertise capability to the peer\n" | |
3590 | "Advertise ORF capability to the peer\n" | |
3591 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3592 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3593 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3594 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3595 | |
718e3744 | 3596 | /* neighbor next-hop-self. */ |
3597 | DEFUN (neighbor_nexthop_self, | |
3598 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3599 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3600 | NEIGHBOR_STR |
3601 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3602 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3603 | { |
d62a17ae | 3604 | int idx_peer = 1; |
3605 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3606 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 3607 | } |
9e7a53c1 | 3608 | |
d62a17ae | 3609 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
3610 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3611 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3612 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3613 | |
a538debe DS |
3614 | /* neighbor next-hop-self. */ |
3615 | DEFUN (neighbor_nexthop_self_force, | |
3616 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3617 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3618 | NEIGHBOR_STR |
3619 | NEIGHBOR_ADDR_STR2 | |
3620 | "Disable the next hop calculation for this neighbor\n" | |
3621 | "Set the next hop to self for reflected routes\n") | |
3622 | { | |
d62a17ae | 3623 | int idx_peer = 1; |
3624 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3625 | bgp_node_safi(vty), | |
3626 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 3627 | } |
3628 | ||
d62a17ae | 3629 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3630 | neighbor_nexthop_self_force_hidden_cmd, | |
3631 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3632 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3633 | "Disable the next hop calculation for this neighbor\n" | |
3634 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3635 | |
718e3744 | 3636 | DEFUN (no_neighbor_nexthop_self, |
3637 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3638 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3639 | NO_STR |
3640 | NEIGHBOR_STR | |
3641 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3642 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3643 | { |
d62a17ae | 3644 | int idx_peer = 2; |
3645 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3646 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3647 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 3648 | } |
6b0655a2 | 3649 | |
d62a17ae | 3650 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
3651 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3652 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3653 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3654 | |
88b8ed8d | 3655 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3656 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3657 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3658 | NO_STR |
3659 | NEIGHBOR_STR | |
3660 | NEIGHBOR_ADDR_STR2 | |
3661 | "Disable the next hop calculation for this neighbor\n" | |
3662 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3663 | { |
d62a17ae | 3664 | int idx_peer = 2; |
3665 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3666 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3667 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 3668 | } |
a538debe | 3669 | |
d62a17ae | 3670 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
3671 | no_neighbor_nexthop_self_force_hidden_cmd, | |
3672 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3673 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3674 | "Disable the next hop calculation for this neighbor\n" | |
3675 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3676 | |
c7122e14 DS |
3677 | /* neighbor as-override */ |
3678 | DEFUN (neighbor_as_override, | |
3679 | neighbor_as_override_cmd, | |
9ccf14f7 | 3680 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3681 | NEIGHBOR_STR |
3682 | NEIGHBOR_ADDR_STR2 | |
3683 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3684 | { | |
d62a17ae | 3685 | int idx_peer = 1; |
3686 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3687 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3688 | } |
3689 | ||
d62a17ae | 3690 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
3691 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3692 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3693 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3694 | |
c7122e14 DS |
3695 | DEFUN (no_neighbor_as_override, |
3696 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3697 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3698 | NO_STR |
3699 | NEIGHBOR_STR | |
3700 | NEIGHBOR_ADDR_STR2 | |
3701 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3702 | { | |
d62a17ae | 3703 | int idx_peer = 2; |
3704 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3705 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3706 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3707 | } |
3708 | ||
d62a17ae | 3709 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
3710 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3711 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3712 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3713 | |
718e3744 | 3714 | /* neighbor remove-private-AS. */ |
3715 | DEFUN (neighbor_remove_private_as, | |
3716 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3717 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3718 | NEIGHBOR_STR |
3719 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3720 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3721 | { |
d62a17ae | 3722 | int idx_peer = 1; |
3723 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3724 | bgp_node_safi(vty), | |
3725 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 3726 | } |
3727 | ||
d62a17ae | 3728 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
3729 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
3730 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3731 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 3732 | |
5000f21c DS |
3733 | DEFUN (neighbor_remove_private_as_all, |
3734 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 3735 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3736 | NEIGHBOR_STR |
3737 | NEIGHBOR_ADDR_STR2 | |
3738 | "Remove private ASNs in outbound updates\n" | |
3739 | "Apply to all AS numbers") | |
3740 | { | |
d62a17ae | 3741 | int idx_peer = 1; |
3742 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3743 | bgp_node_safi(vty), | |
3744 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
3745 | } |
3746 | ||
d62a17ae | 3747 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
3748 | neighbor_remove_private_as_all_hidden_cmd, | |
3749 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
3750 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3751 | "Remove private ASNs in outbound updates\n" | |
3752 | "Apply to all AS numbers") | |
596c17ba | 3753 | |
5000f21c DS |
3754 | DEFUN (neighbor_remove_private_as_replace_as, |
3755 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 3756 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3757 | NEIGHBOR_STR |
3758 | NEIGHBOR_ADDR_STR2 | |
3759 | "Remove private ASNs in outbound updates\n" | |
3760 | "Replace private ASNs with our ASN in outbound updates\n") | |
3761 | { | |
d62a17ae | 3762 | int idx_peer = 1; |
3763 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3764 | bgp_node_safi(vty), | |
3765 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
3766 | } |
3767 | ||
d62a17ae | 3768 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
3769 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
3770 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
3771 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3772 | "Remove private ASNs in outbound updates\n" | |
3773 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3774 | |
5000f21c DS |
3775 | DEFUN (neighbor_remove_private_as_all_replace_as, |
3776 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 3777 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3778 | NEIGHBOR_STR |
3779 | NEIGHBOR_ADDR_STR2 | |
3780 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3781 | "Apply to all AS numbers\n" |
5000f21c DS |
3782 | "Replace private ASNs with our ASN in outbound updates\n") |
3783 | { | |
d62a17ae | 3784 | int idx_peer = 1; |
3785 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3786 | bgp_node_safi(vty), | |
3787 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
3788 | } |
3789 | ||
d62a17ae | 3790 | ALIAS_HIDDEN( |
3791 | neighbor_remove_private_as_all_replace_as, | |
3792 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
3793 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
3794 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3795 | "Remove private ASNs in outbound updates\n" | |
3796 | "Apply to all AS numbers\n" | |
3797 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3798 | |
718e3744 | 3799 | DEFUN (no_neighbor_remove_private_as, |
3800 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3801 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3802 | NO_STR |
3803 | NEIGHBOR_STR | |
3804 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3805 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3806 | { |
d62a17ae | 3807 | int idx_peer = 2; |
3808 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3809 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3810 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 3811 | } |
6b0655a2 | 3812 | |
d62a17ae | 3813 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
3814 | no_neighbor_remove_private_as_hidden_cmd, | |
3815 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
3816 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3817 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 3818 | |
88b8ed8d | 3819 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 3820 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 3821 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3822 | NO_STR |
3823 | NEIGHBOR_STR | |
3824 | NEIGHBOR_ADDR_STR2 | |
3825 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3826 | "Apply to all AS numbers\n") |
88b8ed8d | 3827 | { |
d62a17ae | 3828 | int idx_peer = 2; |
3829 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3830 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3831 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 3832 | } |
5000f21c | 3833 | |
d62a17ae | 3834 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
3835 | no_neighbor_remove_private_as_all_hidden_cmd, | |
3836 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
3837 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3838 | "Remove private ASNs in outbound updates\n" | |
3839 | "Apply to all AS numbers\n") | |
596c17ba | 3840 | |
88b8ed8d | 3841 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 3842 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 3843 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3844 | NO_STR |
3845 | NEIGHBOR_STR | |
3846 | NEIGHBOR_ADDR_STR2 | |
3847 | "Remove private ASNs in outbound updates\n" | |
3848 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 3849 | { |
d62a17ae | 3850 | int idx_peer = 2; |
3851 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3852 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3853 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 3854 | } |
5000f21c | 3855 | |
d62a17ae | 3856 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
3857 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
3858 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
3859 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3860 | "Remove private ASNs in outbound updates\n" | |
3861 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3862 | |
88b8ed8d | 3863 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 3864 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 3865 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3866 | NO_STR |
3867 | NEIGHBOR_STR | |
3868 | NEIGHBOR_ADDR_STR2 | |
3869 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3870 | "Apply to all AS numbers\n" |
5000f21c | 3871 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 3872 | { |
d62a17ae | 3873 | int idx_peer = 2; |
3874 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3875 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3876 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 3877 | } |
5000f21c | 3878 | |
d62a17ae | 3879 | ALIAS_HIDDEN( |
3880 | no_neighbor_remove_private_as_all_replace_as, | |
3881 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
3882 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
3883 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3884 | "Remove private ASNs in outbound updates\n" | |
3885 | "Apply to all AS numbers\n" | |
3886 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3887 | |
5000f21c | 3888 | |
718e3744 | 3889 | /* neighbor send-community. */ |
3890 | DEFUN (neighbor_send_community, | |
3891 | neighbor_send_community_cmd, | |
9ccf14f7 | 3892 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3893 | NEIGHBOR_STR |
3894 | NEIGHBOR_ADDR_STR2 | |
3895 | "Send Community attribute to this neighbor\n") | |
3896 | { | |
d62a17ae | 3897 | int idx_peer = 1; |
3898 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3899 | bgp_node_safi(vty), | |
3900 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 3901 | } |
3902 | ||
d62a17ae | 3903 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
3904 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
3905 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3906 | "Send Community attribute to this neighbor\n") | |
596c17ba | 3907 | |
718e3744 | 3908 | DEFUN (no_neighbor_send_community, |
3909 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 3910 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3911 | NO_STR |
3912 | NEIGHBOR_STR | |
3913 | NEIGHBOR_ADDR_STR2 | |
3914 | "Send Community attribute to this neighbor\n") | |
3915 | { | |
d62a17ae | 3916 | int idx_peer = 2; |
3917 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3918 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3919 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 3920 | } |
6b0655a2 | 3921 | |
d62a17ae | 3922 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
3923 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
3924 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3925 | "Send Community attribute to this neighbor\n") | |
596c17ba | 3926 | |
718e3744 | 3927 | /* neighbor send-community extended. */ |
3928 | DEFUN (neighbor_send_community_type, | |
3929 | neighbor_send_community_type_cmd, | |
57d187bc | 3930 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 3931 | NEIGHBOR_STR |
3932 | NEIGHBOR_ADDR_STR2 | |
3933 | "Send Community attribute to this neighbor\n" | |
3934 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 3935 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 3936 | "Send Extended Community attributes\n" |
57d187bc JS |
3937 | "Send Standard Community attributes\n" |
3938 | "Send Large Community attributes\n") | |
718e3744 | 3939 | { |
d62a17ae | 3940 | int idx = 0; |
3941 | u_int32_t flag = 0; | |
3942 | ||
3943 | char *peer = argv[1]->arg; | |
3944 | ||
3945 | if (argv_find(argv, argc, "standard", &idx)) | |
3946 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
3947 | else if (argv_find(argv, argc, "extended", &idx)) | |
3948 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3949 | else if (argv_find(argv, argc, "large", &idx)) | |
3950 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
3951 | else if (argv_find(argv, argc, "both", &idx)) { | |
3952 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
3953 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3954 | } else { | |
3955 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
3956 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3957 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
3958 | } | |
3959 | ||
3960 | return peer_af_flag_set_vty(vty, peer, bgp_node_afi(vty), | |
3961 | bgp_node_safi(vty), flag); | |
3962 | } | |
3963 | ||
3964 | ALIAS_HIDDEN( | |
3965 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
3966 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
3967 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3968 | "Send Community attribute to this neighbor\n" | |
3969 | "Send Standard and Extended Community attributes\n" | |
3970 | "Send Standard, Large and Extended Community attributes\n" | |
3971 | "Send Extended Community attributes\n" | |
3972 | "Send Standard Community attributes\n" | |
3973 | "Send Large Community attributes\n") | |
596c17ba | 3974 | |
718e3744 | 3975 | DEFUN (no_neighbor_send_community_type, |
3976 | no_neighbor_send_community_type_cmd, | |
57d187bc | 3977 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 3978 | NO_STR |
3979 | NEIGHBOR_STR | |
3980 | NEIGHBOR_ADDR_STR2 | |
3981 | "Send Community attribute to this neighbor\n" | |
3982 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 3983 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 3984 | "Send Extended Community attributes\n" |
57d187bc JS |
3985 | "Send Standard Community attributes\n" |
3986 | "Send Large Community attributes\n") | |
718e3744 | 3987 | { |
d62a17ae | 3988 | int idx_peer = 2; |
3989 | ||
3990 | const char *type = argv[argc - 1]->text; | |
3991 | ||
3992 | if (strmatch(type, "standard")) | |
3993 | return peer_af_flag_unset_vty( | |
3994 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3995 | bgp_node_safi(vty), PEER_FLAG_SEND_COMMUNITY); | |
3996 | if (strmatch(type, "extended")) | |
3997 | return peer_af_flag_unset_vty( | |
3998 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3999 | bgp_node_safi(vty), PEER_FLAG_SEND_EXT_COMMUNITY); | |
4000 | if (strmatch(type, "large")) | |
4001 | return peer_af_flag_unset_vty( | |
4002 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4003 | bgp_node_safi(vty), PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4004 | if (strmatch(type, "both")) | |
4005 | return peer_af_flag_unset_vty( | |
4006 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4007 | bgp_node_safi(vty), | |
4008 | PEER_FLAG_SEND_COMMUNITY | |
4009 | | PEER_FLAG_SEND_EXT_COMMUNITY); | |
4010 | ||
4011 | /* if (strmatch (type, "all")) */ | |
4012 | return peer_af_flag_unset_vty( | |
4013 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4014 | (PEER_FLAG_SEND_COMMUNITY | PEER_FLAG_SEND_EXT_COMMUNITY | |
4015 | | PEER_FLAG_SEND_LARGE_COMMUNITY)); | |
4016 | } | |
4017 | ||
4018 | ALIAS_HIDDEN( | |
4019 | no_neighbor_send_community_type, | |
4020 | no_neighbor_send_community_type_hidden_cmd, | |
4021 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4022 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4023 | "Send Community attribute to this neighbor\n" | |
4024 | "Send Standard and Extended Community attributes\n" | |
4025 | "Send Standard, Large and Extended Community attributes\n" | |
4026 | "Send Extended Community attributes\n" | |
4027 | "Send Standard Community attributes\n" | |
4028 | "Send Large Community attributes\n") | |
596c17ba | 4029 | |
718e3744 | 4030 | /* neighbor soft-reconfig. */ |
4031 | DEFUN (neighbor_soft_reconfiguration, | |
4032 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4033 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4034 | NEIGHBOR_STR |
4035 | NEIGHBOR_ADDR_STR2 | |
4036 | "Per neighbor soft reconfiguration\n" | |
4037 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4038 | { | |
d62a17ae | 4039 | int idx_peer = 1; |
4040 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4041 | bgp_node_safi(vty), | |
4042 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4043 | } |
4044 | ||
d62a17ae | 4045 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4046 | neighbor_soft_reconfiguration_hidden_cmd, | |
4047 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4048 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4049 | "Per neighbor soft reconfiguration\n" | |
4050 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4051 | |
718e3744 | 4052 | DEFUN (no_neighbor_soft_reconfiguration, |
4053 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4054 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4055 | NO_STR |
4056 | NEIGHBOR_STR | |
4057 | NEIGHBOR_ADDR_STR2 | |
4058 | "Per neighbor soft reconfiguration\n" | |
4059 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4060 | { | |
d62a17ae | 4061 | int idx_peer = 2; |
4062 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4063 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4064 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4065 | } |
6b0655a2 | 4066 | |
d62a17ae | 4067 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
4068 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4069 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4070 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4071 | "Per neighbor soft reconfiguration\n" | |
4072 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4073 | |
718e3744 | 4074 | DEFUN (neighbor_route_reflector_client, |
4075 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4076 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4077 | NEIGHBOR_STR |
4078 | NEIGHBOR_ADDR_STR2 | |
4079 | "Configure a neighbor as Route Reflector client\n") | |
4080 | { | |
d62a17ae | 4081 | int idx_peer = 1; |
4082 | struct peer *peer; | |
718e3744 | 4083 | |
4084 | ||
d62a17ae | 4085 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4086 | if (!peer) | |
4087 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4088 | |
d62a17ae | 4089 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4090 | bgp_node_safi(vty), | |
4091 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4092 | } |
4093 | ||
d62a17ae | 4094 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
4095 | neighbor_route_reflector_client_hidden_cmd, | |
4096 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4097 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4098 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4099 | |
718e3744 | 4100 | DEFUN (no_neighbor_route_reflector_client, |
4101 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4102 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4103 | NO_STR |
4104 | NEIGHBOR_STR | |
4105 | NEIGHBOR_ADDR_STR2 | |
4106 | "Configure a neighbor as Route Reflector client\n") | |
4107 | { | |
d62a17ae | 4108 | int idx_peer = 2; |
4109 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4110 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4111 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4112 | } |
6b0655a2 | 4113 | |
d62a17ae | 4114 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
4115 | no_neighbor_route_reflector_client_hidden_cmd, | |
4116 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4117 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4118 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4119 | |
718e3744 | 4120 | /* neighbor route-server-client. */ |
4121 | DEFUN (neighbor_route_server_client, | |
4122 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4123 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4124 | NEIGHBOR_STR |
4125 | NEIGHBOR_ADDR_STR2 | |
4126 | "Configure a neighbor as Route Server client\n") | |
4127 | { | |
d62a17ae | 4128 | int idx_peer = 1; |
4129 | struct peer *peer; | |
2a3d5731 | 4130 | |
d62a17ae | 4131 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4132 | if (!peer) | |
4133 | return CMD_WARNING_CONFIG_FAILED; | |
4134 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4135 | bgp_node_safi(vty), | |
4136 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4137 | } |
4138 | ||
d62a17ae | 4139 | ALIAS_HIDDEN(neighbor_route_server_client, |
4140 | neighbor_route_server_client_hidden_cmd, | |
4141 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4142 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4143 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4144 | |
718e3744 | 4145 | DEFUN (no_neighbor_route_server_client, |
4146 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4147 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4148 | NO_STR |
4149 | NEIGHBOR_STR | |
4150 | NEIGHBOR_ADDR_STR2 | |
4151 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4152 | { |
d62a17ae | 4153 | int idx_peer = 2; |
4154 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4155 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4156 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4157 | } |
6b0655a2 | 4158 | |
d62a17ae | 4159 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
4160 | no_neighbor_route_server_client_hidden_cmd, | |
4161 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4162 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4163 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4164 | |
fee0f4c6 | 4165 | DEFUN (neighbor_nexthop_local_unchanged, |
4166 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4167 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4168 | NEIGHBOR_STR |
4169 | NEIGHBOR_ADDR_STR2 | |
4170 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4171 | "Leave link-local nexthop unchanged for this peer\n") | |
4172 | { | |
d62a17ae | 4173 | int idx_peer = 1; |
4174 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4175 | bgp_node_safi(vty), | |
4176 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 4177 | } |
6b0655a2 | 4178 | |
fee0f4c6 | 4179 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4180 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4181 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4182 | NO_STR |
4183 | NEIGHBOR_STR | |
4184 | NEIGHBOR_ADDR_STR2 | |
4185 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4186 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4187 | { |
d62a17ae | 4188 | int idx_peer = 2; |
4189 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4190 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4191 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 4192 | } |
6b0655a2 | 4193 | |
718e3744 | 4194 | DEFUN (neighbor_attr_unchanged, |
4195 | neighbor_attr_unchanged_cmd, | |
a8206004 | 4196 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 4197 | NEIGHBOR_STR |
4198 | NEIGHBOR_ADDR_STR2 | |
4199 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4200 | "As-path attribute\n" | |
4201 | "Nexthop attribute\n" | |
a8206004 | 4202 | "Med attribute\n") |
718e3744 | 4203 | { |
d62a17ae | 4204 | int idx = 0; |
4205 | char *peer = argv[1]->arg; | |
4206 | u_int16_t flags = 0; | |
4207 | ||
4208 | if (argv_find(argv, argc, "as-path", &idx)) | |
4209 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4210 | idx = 0; | |
4211 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4212 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4213 | idx = 0; | |
4214 | if (argv_find(argv, argc, "med", &idx)) | |
4215 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4216 | ||
4217 | if (!flags) // no flags means all of them! | |
4218 | { | |
4219 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4220 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4221 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4222 | } | |
4223 | ||
4224 | return peer_af_flag_set_vty(vty, peer, bgp_node_afi(vty), | |
4225 | bgp_node_safi(vty), flags); | |
4226 | } | |
4227 | ||
4228 | ALIAS_HIDDEN( | |
4229 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
4230 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4231 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4232 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4233 | "As-path attribute\n" | |
4234 | "Nexthop attribute\n" | |
4235 | "Med attribute\n") | |
596c17ba | 4236 | |
718e3744 | 4237 | DEFUN (no_neighbor_attr_unchanged, |
4238 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 4239 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 4240 | NO_STR |
718e3744 | 4241 | NEIGHBOR_STR |
4242 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4243 | "BGP attribute is propagated unchanged to this neighbor\n" |
4244 | "As-path attribute\n" | |
40e718b5 | 4245 | "Nexthop attribute\n" |
a8206004 | 4246 | "Med attribute\n") |
718e3744 | 4247 | { |
d62a17ae | 4248 | int idx = 0; |
4249 | char *peer = argv[2]->arg; | |
4250 | u_int16_t flags = 0; | |
4251 | ||
4252 | if (argv_find(argv, argc, "as-path", &idx)) | |
4253 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4254 | idx = 0; | |
4255 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4256 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4257 | idx = 0; | |
4258 | if (argv_find(argv, argc, "med", &idx)) | |
4259 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4260 | ||
4261 | if (!flags) // no flags means all of them! | |
4262 | { | |
4263 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4264 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4265 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4266 | } | |
4267 | ||
4268 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
4269 | bgp_node_safi(vty), flags); | |
4270 | } | |
4271 | ||
4272 | ALIAS_HIDDEN( | |
4273 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
4274 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4275 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4276 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4277 | "As-path attribute\n" | |
4278 | "Nexthop attribute\n" | |
4279 | "Med attribute\n") | |
718e3744 | 4280 | |
718e3744 | 4281 | /* EBGP multihop configuration. */ |
d62a17ae | 4282 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
4283 | const char *ttl_str) | |
718e3744 | 4284 | { |
d62a17ae | 4285 | struct peer *peer; |
4286 | unsigned int ttl; | |
718e3744 | 4287 | |
d62a17ae | 4288 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4289 | if (!peer) | |
4290 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4291 | |
d62a17ae | 4292 | if (peer->conf_if) |
4293 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 4294 | |
d62a17ae | 4295 | if (!ttl_str) |
4296 | ttl = MAXTTL; | |
4297 | else | |
4298 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 4299 | |
d62a17ae | 4300 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 4301 | } |
4302 | ||
d62a17ae | 4303 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4304 | { |
d62a17ae | 4305 | struct peer *peer; |
718e3744 | 4306 | |
d62a17ae | 4307 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4308 | if (!peer) | |
4309 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4310 | |
d62a17ae | 4311 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 4312 | } |
4313 | ||
4314 | /* neighbor ebgp-multihop. */ | |
4315 | DEFUN (neighbor_ebgp_multihop, | |
4316 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4317 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4318 | NEIGHBOR_STR |
4319 | NEIGHBOR_ADDR_STR2 | |
4320 | "Allow EBGP neighbors not on directly connected networks\n") | |
4321 | { | |
d62a17ae | 4322 | int idx_peer = 1; |
4323 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4324 | } |
4325 | ||
4326 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4327 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4328 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4329 | NEIGHBOR_STR |
4330 | NEIGHBOR_ADDR_STR2 | |
4331 | "Allow EBGP neighbors not on directly connected networks\n" | |
4332 | "maximum hop count\n") | |
4333 | { | |
d62a17ae | 4334 | int idx_peer = 1; |
4335 | int idx_number = 3; | |
4336 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
4337 | argv[idx_number]->arg); | |
718e3744 | 4338 | } |
4339 | ||
4340 | DEFUN (no_neighbor_ebgp_multihop, | |
4341 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4342 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4343 | NO_STR |
4344 | NEIGHBOR_STR | |
4345 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4346 | "Allow EBGP neighbors not on directly connected networks\n" |
4347 | "maximum hop count\n") | |
718e3744 | 4348 | { |
d62a17ae | 4349 | int idx_peer = 2; |
4350 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4351 | } |
4352 | ||
6b0655a2 | 4353 | |
6ffd2079 | 4354 | /* disable-connected-check */ |
4355 | DEFUN (neighbor_disable_connected_check, | |
4356 | neighbor_disable_connected_check_cmd, | |
a636c635 | 4357 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4358 | NEIGHBOR_STR |
4359 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4360 | "one-hop away EBGP peer using loopback address\n" |
4361 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4362 | { |
d62a17ae | 4363 | int idx_peer = 1; |
4364 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4365 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4366 | } |
4367 | ||
4368 | DEFUN (no_neighbor_disable_connected_check, | |
4369 | no_neighbor_disable_connected_check_cmd, | |
a636c635 | 4370 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4371 | NO_STR |
4372 | NEIGHBOR_STR | |
4373 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4374 | "one-hop away EBGP peer using loopback address\n" |
4375 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4376 | { |
d62a17ae | 4377 | int idx_peer = 2; |
4378 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4379 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4380 | } |
4381 | ||
718e3744 | 4382 | DEFUN (neighbor_description, |
4383 | neighbor_description_cmd, | |
e961923c | 4384 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4385 | NEIGHBOR_STR |
4386 | NEIGHBOR_ADDR_STR2 | |
4387 | "Neighbor specific description\n" | |
4388 | "Up to 80 characters describing this neighbor\n") | |
4389 | { | |
d62a17ae | 4390 | int idx_peer = 1; |
4391 | int idx_line = 3; | |
4392 | struct peer *peer; | |
4393 | char *str; | |
718e3744 | 4394 | |
d62a17ae | 4395 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4396 | if (!peer) | |
4397 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4398 | |
d62a17ae | 4399 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4400 | |
d62a17ae | 4401 | peer_description_set(peer, str); |
718e3744 | 4402 | |
d62a17ae | 4403 | XFREE(MTYPE_TMP, str); |
718e3744 | 4404 | |
d62a17ae | 4405 | return CMD_SUCCESS; |
718e3744 | 4406 | } |
4407 | ||
4408 | DEFUN (no_neighbor_description, | |
4409 | no_neighbor_description_cmd, | |
a636c635 | 4410 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]", |
718e3744 | 4411 | NO_STR |
4412 | NEIGHBOR_STR | |
4413 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4414 | "Neighbor specific description\n" |
4415 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 4416 | { |
d62a17ae | 4417 | int idx_peer = 2; |
4418 | struct peer *peer; | |
718e3744 | 4419 | |
d62a17ae | 4420 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4421 | if (!peer) | |
4422 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4423 | |
d62a17ae | 4424 | peer_description_unset(peer); |
718e3744 | 4425 | |
d62a17ae | 4426 | return CMD_SUCCESS; |
718e3744 | 4427 | } |
4428 | ||
6b0655a2 | 4429 | |
718e3744 | 4430 | /* Neighbor update-source. */ |
d62a17ae | 4431 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
4432 | const char *source_str) | |
4433 | { | |
4434 | struct peer *peer; | |
4435 | struct prefix p; | |
4436 | ||
4437 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4438 | if (!peer) | |
4439 | return CMD_WARNING_CONFIG_FAILED; | |
4440 | ||
4441 | if (peer->conf_if) | |
4442 | return CMD_WARNING; | |
4443 | ||
4444 | if (source_str) { | |
4445 | union sockunion su; | |
4446 | int ret = str2sockunion(source_str, &su); | |
4447 | ||
4448 | if (ret == 0) | |
4449 | peer_update_source_addr_set(peer, &su); | |
4450 | else { | |
4451 | if (str2prefix(source_str, &p)) { | |
4452 | vty_out(vty, | |
4453 | "%% Invalid update-source, remove prefix length \n"); | |
4454 | return CMD_WARNING_CONFIG_FAILED; | |
4455 | } else | |
4456 | peer_update_source_if_set(peer, source_str); | |
4457 | } | |
4458 | } else | |
4459 | peer_update_source_unset(peer); | |
4460 | ||
4461 | return CMD_SUCCESS; | |
4462 | } | |
4463 | ||
4464 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
4465 | "IPv4 address\n" \ | |
4466 | "IPv6 address\n" \ | |
4467 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4468 | |
718e3744 | 4469 | DEFUN (neighbor_update_source, |
4470 | neighbor_update_source_cmd, | |
9ccf14f7 | 4471 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4472 | NEIGHBOR_STR |
4473 | NEIGHBOR_ADDR_STR2 | |
4474 | "Source of routing updates\n" | |
369688c0 | 4475 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4476 | { |
d62a17ae | 4477 | int idx_peer = 1; |
4478 | int idx_peer_2 = 3; | |
4479 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
4480 | argv[idx_peer_2]->arg); | |
718e3744 | 4481 | } |
4482 | ||
4483 | DEFUN (no_neighbor_update_source, | |
4484 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4485 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4486 | NO_STR |
4487 | NEIGHBOR_STR | |
4488 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4489 | "Source of routing updates\n" |
4490 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4491 | { |
d62a17ae | 4492 | int idx_peer = 2; |
4493 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4494 | } |
6b0655a2 | 4495 | |
d62a17ae | 4496 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
4497 | afi_t afi, safi_t safi, | |
4498 | const char *rmap, int set) | |
718e3744 | 4499 | { |
d62a17ae | 4500 | int ret; |
4501 | struct peer *peer; | |
718e3744 | 4502 | |
d62a17ae | 4503 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4504 | if (!peer) | |
4505 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4506 | |
d62a17ae | 4507 | if (set) |
4508 | ret = peer_default_originate_set(peer, afi, safi, rmap); | |
4509 | else | |
4510 | ret = peer_default_originate_unset(peer, afi, safi); | |
718e3744 | 4511 | |
d62a17ae | 4512 | return bgp_vty_return(vty, ret); |
718e3744 | 4513 | } |
4514 | ||
4515 | /* neighbor default-originate. */ | |
4516 | DEFUN (neighbor_default_originate, | |
4517 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4518 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4519 | NEIGHBOR_STR |
4520 | NEIGHBOR_ADDR_STR2 | |
4521 | "Originate default route to this neighbor\n") | |
4522 | { | |
d62a17ae | 4523 | int idx_peer = 1; |
4524 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4525 | bgp_node_afi(vty), | |
4526 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 4527 | } |
4528 | ||
d62a17ae | 4529 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
4530 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
4531 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4532 | "Originate default route to this neighbor\n") | |
596c17ba | 4533 | |
718e3744 | 4534 | DEFUN (neighbor_default_originate_rmap, |
4535 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4536 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4537 | NEIGHBOR_STR |
4538 | NEIGHBOR_ADDR_STR2 | |
4539 | "Originate default route to this neighbor\n" | |
4540 | "Route-map to specify criteria to originate default\n" | |
4541 | "route-map name\n") | |
4542 | { | |
d62a17ae | 4543 | int idx_peer = 1; |
4544 | int idx_word = 4; | |
4545 | return peer_default_originate_set_vty( | |
4546 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4547 | argv[idx_word]->arg, 1); | |
718e3744 | 4548 | } |
4549 | ||
d62a17ae | 4550 | ALIAS_HIDDEN( |
4551 | neighbor_default_originate_rmap, | |
4552 | neighbor_default_originate_rmap_hidden_cmd, | |
4553 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
4554 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4555 | "Originate default route to this neighbor\n" | |
4556 | "Route-map to specify criteria to originate default\n" | |
4557 | "route-map name\n") | |
596c17ba | 4558 | |
718e3744 | 4559 | DEFUN (no_neighbor_default_originate, |
4560 | no_neighbor_default_originate_cmd, | |
a636c635 | 4561 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4562 | NO_STR |
4563 | NEIGHBOR_STR | |
4564 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4565 | "Originate default route to this neighbor\n" |
4566 | "Route-map to specify criteria to originate default\n" | |
4567 | "route-map name\n") | |
718e3744 | 4568 | { |
d62a17ae | 4569 | int idx_peer = 2; |
4570 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4571 | bgp_node_afi(vty), | |
4572 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 4573 | } |
4574 | ||
d62a17ae | 4575 | ALIAS_HIDDEN( |
4576 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
4577 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
4578 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4579 | "Originate default route to this neighbor\n" | |
4580 | "Route-map to specify criteria to originate default\n" | |
4581 | "route-map name\n") | |
596c17ba | 4582 | |
6b0655a2 | 4583 | |
718e3744 | 4584 | /* Set neighbor's BGP port. */ |
d62a17ae | 4585 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
4586 | const char *port_str) | |
4587 | { | |
4588 | struct peer *peer; | |
4589 | u_int16_t port; | |
4590 | struct servent *sp; | |
4591 | ||
4592 | peer = peer_lookup_vty(vty, ip_str); | |
4593 | if (!peer) | |
4594 | return CMD_WARNING_CONFIG_FAILED; | |
4595 | ||
4596 | if (!port_str) { | |
4597 | sp = getservbyname("bgp", "tcp"); | |
4598 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
4599 | } else { | |
4600 | port = strtoul(port_str, NULL, 10); | |
4601 | } | |
718e3744 | 4602 | |
d62a17ae | 4603 | peer_port_set(peer, port); |
718e3744 | 4604 | |
d62a17ae | 4605 | return CMD_SUCCESS; |
718e3744 | 4606 | } |
4607 | ||
f418446b | 4608 | /* Set specified peer's BGP port. */ |
718e3744 | 4609 | DEFUN (neighbor_port, |
4610 | neighbor_port_cmd, | |
9ccf14f7 | 4611 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4612 | NEIGHBOR_STR |
4613 | NEIGHBOR_ADDR_STR | |
4614 | "Neighbor's BGP port\n" | |
4615 | "TCP port number\n") | |
4616 | { | |
d62a17ae | 4617 | int idx_ip = 1; |
4618 | int idx_number = 3; | |
4619 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
4620 | argv[idx_number]->arg); | |
718e3744 | 4621 | } |
4622 | ||
4623 | DEFUN (no_neighbor_port, | |
4624 | no_neighbor_port_cmd, | |
9ccf14f7 | 4625 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4626 | NO_STR |
4627 | NEIGHBOR_STR | |
4628 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4629 | "Neighbor's BGP port\n" |
4630 | "TCP port number\n") | |
718e3744 | 4631 | { |
d62a17ae | 4632 | int idx_ip = 2; |
4633 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4634 | } |
4635 | ||
6b0655a2 | 4636 | |
718e3744 | 4637 | /* neighbor weight. */ |
d62a17ae | 4638 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4639 | safi_t safi, const char *weight_str) | |
718e3744 | 4640 | { |
d62a17ae | 4641 | int ret; |
4642 | struct peer *peer; | |
4643 | unsigned long weight; | |
718e3744 | 4644 | |
d62a17ae | 4645 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4646 | if (!peer) | |
4647 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4648 | |
d62a17ae | 4649 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 4650 | |
d62a17ae | 4651 | ret = peer_weight_set(peer, afi, safi, weight); |
4652 | return bgp_vty_return(vty, ret); | |
718e3744 | 4653 | } |
4654 | ||
d62a17ae | 4655 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4656 | safi_t safi) | |
718e3744 | 4657 | { |
d62a17ae | 4658 | int ret; |
4659 | struct peer *peer; | |
718e3744 | 4660 | |
d62a17ae | 4661 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4662 | if (!peer) | |
4663 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4664 | |
d62a17ae | 4665 | ret = peer_weight_unset(peer, afi, safi); |
4666 | return bgp_vty_return(vty, ret); | |
718e3744 | 4667 | } |
4668 | ||
4669 | DEFUN (neighbor_weight, | |
4670 | neighbor_weight_cmd, | |
9ccf14f7 | 4671 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 4672 | NEIGHBOR_STR |
4673 | NEIGHBOR_ADDR_STR2 | |
4674 | "Set default weight for routes from this neighbor\n" | |
4675 | "default weight\n") | |
4676 | { | |
d62a17ae | 4677 | int idx_peer = 1; |
4678 | int idx_number = 3; | |
4679 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4680 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 4681 | } |
4682 | ||
d62a17ae | 4683 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
4684 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
4685 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4686 | "Set default weight for routes from this neighbor\n" | |
4687 | "default weight\n") | |
596c17ba | 4688 | |
718e3744 | 4689 | DEFUN (no_neighbor_weight, |
4690 | no_neighbor_weight_cmd, | |
9ccf14f7 | 4691 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 4692 | NO_STR |
4693 | NEIGHBOR_STR | |
4694 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4695 | "Set default weight for routes from this neighbor\n" |
4696 | "default weight\n") | |
718e3744 | 4697 | { |
d62a17ae | 4698 | int idx_peer = 2; |
4699 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
4700 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 4701 | } |
4702 | ||
d62a17ae | 4703 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
4704 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
4705 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4706 | "Set default weight for routes from this neighbor\n" | |
4707 | "default weight\n") | |
596c17ba | 4708 | |
6b0655a2 | 4709 | |
718e3744 | 4710 | /* Override capability negotiation. */ |
4711 | DEFUN (neighbor_override_capability, | |
4712 | neighbor_override_capability_cmd, | |
9ccf14f7 | 4713 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4714 | NEIGHBOR_STR |
4715 | NEIGHBOR_ADDR_STR2 | |
4716 | "Override capability negotiation result\n") | |
4717 | { | |
d62a17ae | 4718 | int idx_peer = 1; |
4719 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4720 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4721 | } |
4722 | ||
4723 | DEFUN (no_neighbor_override_capability, | |
4724 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 4725 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4726 | NO_STR |
4727 | NEIGHBOR_STR | |
4728 | NEIGHBOR_ADDR_STR2 | |
4729 | "Override capability negotiation result\n") | |
4730 | { | |
d62a17ae | 4731 | int idx_peer = 2; |
4732 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4733 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4734 | } |
6b0655a2 | 4735 | |
718e3744 | 4736 | DEFUN (neighbor_strict_capability, |
4737 | neighbor_strict_capability_cmd, | |
9ccf14f7 | 4738 | "neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4739 | NEIGHBOR_STR |
4740 | NEIGHBOR_ADDR_STR | |
4741 | "Strict capability negotiation match\n") | |
4742 | { | |
d62a17ae | 4743 | int idx_ip = 1; |
4744 | return peer_flag_set_vty(vty, argv[idx_ip]->arg, | |
4745 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4746 | } |
4747 | ||
4748 | DEFUN (no_neighbor_strict_capability, | |
4749 | no_neighbor_strict_capability_cmd, | |
9ccf14f7 | 4750 | "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4751 | NO_STR |
4752 | NEIGHBOR_STR | |
4753 | NEIGHBOR_ADDR_STR | |
4754 | "Strict capability negotiation match\n") | |
4755 | { | |
d62a17ae | 4756 | int idx_ip = 2; |
4757 | return peer_flag_unset_vty(vty, argv[idx_ip]->arg, | |
4758 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4759 | } |
6b0655a2 | 4760 | |
d62a17ae | 4761 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
4762 | const char *keep_str, const char *hold_str) | |
718e3744 | 4763 | { |
d62a17ae | 4764 | int ret; |
4765 | struct peer *peer; | |
4766 | u_int32_t keepalive; | |
4767 | u_int32_t holdtime; | |
718e3744 | 4768 | |
d62a17ae | 4769 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4770 | if (!peer) | |
4771 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4772 | |
d62a17ae | 4773 | keepalive = strtoul(keep_str, NULL, 10); |
4774 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 4775 | |
d62a17ae | 4776 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 4777 | |
d62a17ae | 4778 | return bgp_vty_return(vty, ret); |
718e3744 | 4779 | } |
6b0655a2 | 4780 | |
d62a17ae | 4781 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4782 | { |
d62a17ae | 4783 | int ret; |
4784 | struct peer *peer; | |
718e3744 | 4785 | |
d62a17ae | 4786 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4787 | if (!peer) | |
4788 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4789 | |
d62a17ae | 4790 | ret = peer_timers_unset(peer); |
718e3744 | 4791 | |
d62a17ae | 4792 | return bgp_vty_return(vty, ret); |
718e3744 | 4793 | } |
4794 | ||
4795 | DEFUN (neighbor_timers, | |
4796 | neighbor_timers_cmd, | |
9ccf14f7 | 4797 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 4798 | NEIGHBOR_STR |
4799 | NEIGHBOR_ADDR_STR2 | |
4800 | "BGP per neighbor timers\n" | |
4801 | "Keepalive interval\n" | |
4802 | "Holdtime\n") | |
4803 | { | |
d62a17ae | 4804 | int idx_peer = 1; |
4805 | int idx_number = 3; | |
4806 | int idx_number_2 = 4; | |
4807 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
4808 | argv[idx_number]->arg, | |
4809 | argv[idx_number_2]->arg); | |
718e3744 | 4810 | } |
4811 | ||
4812 | DEFUN (no_neighbor_timers, | |
4813 | no_neighbor_timers_cmd, | |
9ccf14f7 | 4814 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 4815 | NO_STR |
4816 | NEIGHBOR_STR | |
4817 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4818 | "BGP per neighbor timers\n" |
4819 | "Keepalive interval\n" | |
4820 | "Holdtime\n") | |
718e3744 | 4821 | { |
d62a17ae | 4822 | int idx_peer = 2; |
4823 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4824 | } |
6b0655a2 | 4825 | |
813d4307 | 4826 | |
d62a17ae | 4827 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
4828 | const char *time_str) | |
718e3744 | 4829 | { |
d62a17ae | 4830 | int ret; |
4831 | struct peer *peer; | |
4832 | u_int32_t connect; | |
718e3744 | 4833 | |
d62a17ae | 4834 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4835 | if (!peer) | |
4836 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4837 | |
d62a17ae | 4838 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 4839 | |
d62a17ae | 4840 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 4841 | |
d62a17ae | 4842 | return bgp_vty_return(vty, ret); |
718e3744 | 4843 | } |
4844 | ||
d62a17ae | 4845 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4846 | { |
d62a17ae | 4847 | int ret; |
4848 | struct peer *peer; | |
718e3744 | 4849 | |
d62a17ae | 4850 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4851 | if (!peer) | |
4852 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4853 | |
d62a17ae | 4854 | ret = peer_timers_connect_unset(peer); |
718e3744 | 4855 | |
d62a17ae | 4856 | return bgp_vty_return(vty, ret); |
718e3744 | 4857 | } |
4858 | ||
4859 | DEFUN (neighbor_timers_connect, | |
4860 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 4861 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 4862 | NEIGHBOR_STR |
966f821c | 4863 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4864 | "BGP per neighbor timers\n" |
4865 | "BGP connect timer\n" | |
4866 | "Connect timer\n") | |
4867 | { | |
d62a17ae | 4868 | int idx_peer = 1; |
4869 | int idx_number = 4; | |
4870 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
4871 | argv[idx_number]->arg); | |
718e3744 | 4872 | } |
4873 | ||
4874 | DEFUN (no_neighbor_timers_connect, | |
4875 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 4876 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 4877 | NO_STR |
4878 | NEIGHBOR_STR | |
966f821c | 4879 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4880 | "BGP per neighbor timers\n" |
8334fd5a DW |
4881 | "BGP connect timer\n" |
4882 | "Connect timer\n") | |
718e3744 | 4883 | { |
d62a17ae | 4884 | int idx_peer = 2; |
4885 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4886 | } |
4887 | ||
6b0655a2 | 4888 | |
d62a17ae | 4889 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
4890 | const char *time_str, int set) | |
718e3744 | 4891 | { |
d62a17ae | 4892 | int ret; |
4893 | struct peer *peer; | |
4894 | u_int32_t routeadv = 0; | |
718e3744 | 4895 | |
d62a17ae | 4896 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4897 | if (!peer) | |
4898 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4899 | |
d62a17ae | 4900 | if (time_str) |
4901 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 4902 | |
d62a17ae | 4903 | if (set) |
4904 | ret = peer_advertise_interval_set(peer, routeadv); | |
4905 | else | |
4906 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 4907 | |
d62a17ae | 4908 | return bgp_vty_return(vty, ret); |
718e3744 | 4909 | } |
4910 | ||
4911 | DEFUN (neighbor_advertise_interval, | |
4912 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4913 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 4914 | NEIGHBOR_STR |
966f821c | 4915 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4916 | "Minimum interval between sending BGP routing updates\n" |
4917 | "time in seconds\n") | |
4918 | { | |
d62a17ae | 4919 | int idx_peer = 1; |
4920 | int idx_number = 3; | |
4921 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
4922 | argv[idx_number]->arg, 1); | |
718e3744 | 4923 | } |
4924 | ||
4925 | DEFUN (no_neighbor_advertise_interval, | |
4926 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4927 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 4928 | NO_STR |
4929 | NEIGHBOR_STR | |
966f821c | 4930 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
4931 | "Minimum interval between sending BGP routing updates\n" |
4932 | "time in seconds\n") | |
718e3744 | 4933 | { |
d62a17ae | 4934 | int idx_peer = 2; |
4935 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 4936 | } |
4937 | ||
6b0655a2 | 4938 | |
518f0eb1 DS |
4939 | /* Time to wait before processing route-map updates */ |
4940 | DEFUN (bgp_set_route_map_delay_timer, | |
4941 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 4942 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
4943 | SET_STR |
4944 | "BGP route-map delay timer\n" | |
4945 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 4946 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 4947 | { |
d62a17ae | 4948 | int idx_number = 3; |
4949 | u_int32_t rmap_delay_timer; | |
4950 | ||
4951 | if (argv[idx_number]->arg) { | |
4952 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
4953 | bm->rmap_update_timer = rmap_delay_timer; | |
4954 | ||
4955 | /* if the dynamic update handling is being disabled, and a timer | |
4956 | * is | |
4957 | * running, stop the timer and act as if the timer has already | |
4958 | * fired. | |
4959 | */ | |
4960 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
4961 | BGP_TIMER_OFF(bm->t_rmap_update); | |
4962 | thread_execute(bm->master, bgp_route_map_update_timer, | |
4963 | NULL, 0); | |
4964 | } | |
4965 | return CMD_SUCCESS; | |
4966 | } else { | |
4967 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
4968 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 4969 | } |
518f0eb1 DS |
4970 | } |
4971 | ||
4972 | DEFUN (no_bgp_set_route_map_delay_timer, | |
4973 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 4974 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 4975 | NO_STR |
3a2d747c | 4976 | BGP_STR |
518f0eb1 | 4977 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
4978 | "Reset to default time to wait for processing route-map changes\n" |
4979 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 4980 | { |
518f0eb1 | 4981 | |
d62a17ae | 4982 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 4983 | |
d62a17ae | 4984 | return CMD_SUCCESS; |
518f0eb1 DS |
4985 | } |
4986 | ||
f414725f | 4987 | |
718e3744 | 4988 | /* neighbor interface */ |
d62a17ae | 4989 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
4990 | const char *str) | |
718e3744 | 4991 | { |
d62a17ae | 4992 | struct peer *peer; |
718e3744 | 4993 | |
d62a17ae | 4994 | peer = peer_lookup_vty(vty, ip_str); |
4995 | if (!peer || peer->conf_if) { | |
4996 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
4997 | return CMD_WARNING_CONFIG_FAILED; | |
4998 | } | |
718e3744 | 4999 | |
d62a17ae | 5000 | if (str) |
5001 | peer_interface_set(peer, str); | |
5002 | else | |
5003 | peer_interface_unset(peer); | |
718e3744 | 5004 | |
d62a17ae | 5005 | return CMD_SUCCESS; |
718e3744 | 5006 | } |
5007 | ||
5008 | DEFUN (neighbor_interface, | |
5009 | neighbor_interface_cmd, | |
9ccf14f7 | 5010 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5011 | NEIGHBOR_STR |
5012 | NEIGHBOR_ADDR_STR | |
5013 | "Interface\n" | |
5014 | "Interface name\n") | |
5015 | { | |
d62a17ae | 5016 | int idx_ip = 1; |
5017 | int idx_word = 3; | |
5018 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 5019 | } |
5020 | ||
5021 | DEFUN (no_neighbor_interface, | |
5022 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5023 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5024 | NO_STR |
5025 | NEIGHBOR_STR | |
16cedbb0 | 5026 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5027 | "Interface\n" |
5028 | "Interface name\n") | |
5029 | { | |
d62a17ae | 5030 | int idx_peer = 2; |
5031 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5032 | } |
6b0655a2 | 5033 | |
718e3744 | 5034 | DEFUN (neighbor_distribute_list, |
5035 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5036 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5037 | NEIGHBOR_STR |
5038 | NEIGHBOR_ADDR_STR2 | |
5039 | "Filter updates to/from this neighbor\n" | |
5040 | "IP access-list number\n" | |
5041 | "IP access-list number (expanded range)\n" | |
5042 | "IP Access-list name\n" | |
5043 | "Filter incoming updates\n" | |
5044 | "Filter outgoing updates\n") | |
5045 | { | |
d62a17ae | 5046 | int idx_peer = 1; |
5047 | int idx_acl = 3; | |
5048 | int direct, ret; | |
5049 | struct peer *peer; | |
a8206004 | 5050 | |
d62a17ae | 5051 | const char *pstr = argv[idx_peer]->arg; |
5052 | const char *acl = argv[idx_acl]->arg; | |
5053 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5054 | |
d62a17ae | 5055 | peer = peer_and_group_lookup_vty(vty, pstr); |
5056 | if (!peer) | |
5057 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5058 | |
d62a17ae | 5059 | /* Check filter direction. */ |
5060 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5061 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5062 | direct, acl); | |
a8206004 | 5063 | |
d62a17ae | 5064 | return bgp_vty_return(vty, ret); |
718e3744 | 5065 | } |
5066 | ||
d62a17ae | 5067 | ALIAS_HIDDEN( |
5068 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
5069 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5070 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5071 | "Filter updates to/from this neighbor\n" | |
5072 | "IP access-list number\n" | |
5073 | "IP access-list number (expanded range)\n" | |
5074 | "IP Access-list name\n" | |
5075 | "Filter incoming updates\n" | |
5076 | "Filter outgoing updates\n") | |
596c17ba | 5077 | |
718e3744 | 5078 | DEFUN (no_neighbor_distribute_list, |
5079 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5080 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5081 | NO_STR |
5082 | NEIGHBOR_STR | |
5083 | NEIGHBOR_ADDR_STR2 | |
5084 | "Filter updates to/from this neighbor\n" | |
5085 | "IP access-list number\n" | |
5086 | "IP access-list number (expanded range)\n" | |
5087 | "IP Access-list name\n" | |
5088 | "Filter incoming updates\n" | |
5089 | "Filter outgoing updates\n") | |
5090 | { | |
d62a17ae | 5091 | int idx_peer = 2; |
5092 | int direct, ret; | |
5093 | struct peer *peer; | |
a8206004 | 5094 | |
d62a17ae | 5095 | const char *pstr = argv[idx_peer]->arg; |
5096 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5097 | |
d62a17ae | 5098 | peer = peer_and_group_lookup_vty(vty, pstr); |
5099 | if (!peer) | |
5100 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5101 | |
d62a17ae | 5102 | /* Check filter direction. */ |
5103 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5104 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5105 | direct); | |
a8206004 | 5106 | |
d62a17ae | 5107 | return bgp_vty_return(vty, ret); |
718e3744 | 5108 | } |
6b0655a2 | 5109 | |
d62a17ae | 5110 | ALIAS_HIDDEN( |
5111 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
5112 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5113 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5114 | "Filter updates to/from this neighbor\n" | |
5115 | "IP access-list number\n" | |
5116 | "IP access-list number (expanded range)\n" | |
5117 | "IP Access-list name\n" | |
5118 | "Filter incoming updates\n" | |
5119 | "Filter outgoing updates\n") | |
596c17ba | 5120 | |
718e3744 | 5121 | /* Set prefix list to the peer. */ |
d62a17ae | 5122 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
5123 | afi_t afi, safi_t safi, | |
5124 | const char *name_str, | |
5125 | const char *direct_str) | |
718e3744 | 5126 | { |
d62a17ae | 5127 | int ret; |
5128 | struct peer *peer; | |
5129 | int direct = FILTER_IN; | |
718e3744 | 5130 | |
d62a17ae | 5131 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5132 | if (!peer) | |
5133 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5134 | |
d62a17ae | 5135 | /* Check filter direction. */ |
5136 | if (strncmp(direct_str, "i", 1) == 0) | |
5137 | direct = FILTER_IN; | |
5138 | else if (strncmp(direct_str, "o", 1) == 0) | |
5139 | direct = FILTER_OUT; | |
718e3744 | 5140 | |
d62a17ae | 5141 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 5142 | |
d62a17ae | 5143 | return bgp_vty_return(vty, ret); |
718e3744 | 5144 | } |
5145 | ||
d62a17ae | 5146 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
5147 | afi_t afi, safi_t safi, | |
5148 | const char *direct_str) | |
718e3744 | 5149 | { |
d62a17ae | 5150 | int ret; |
5151 | struct peer *peer; | |
5152 | int direct = FILTER_IN; | |
718e3744 | 5153 | |
d62a17ae | 5154 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5155 | if (!peer) | |
5156 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 5157 | |
d62a17ae | 5158 | /* Check filter direction. */ |
5159 | if (strncmp(direct_str, "i", 1) == 0) | |
5160 | direct = FILTER_IN; | |
5161 | else if (strncmp(direct_str, "o", 1) == 0) | |
5162 | direct = FILTER_OUT; | |
718e3744 | 5163 | |
d62a17ae | 5164 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 5165 | |
d62a17ae | 5166 | return bgp_vty_return(vty, ret); |
718e3744 | 5167 | } |
5168 | ||
5169 | DEFUN (neighbor_prefix_list, | |
5170 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5171 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5172 | NEIGHBOR_STR |
5173 | NEIGHBOR_ADDR_STR2 | |
5174 | "Filter updates to/from this neighbor\n" | |
5175 | "Name of a prefix list\n" | |
5176 | "Filter incoming updates\n" | |
5177 | "Filter outgoing updates\n") | |
5178 | { | |
d62a17ae | 5179 | int idx_peer = 1; |
5180 | int idx_word = 3; | |
5181 | int idx_in_out = 4; | |
5182 | return peer_prefix_list_set_vty( | |
5183 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5184 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5185 | } |
5186 | ||
d62a17ae | 5187 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
5188 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5189 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5190 | "Filter updates to/from this neighbor\n" | |
5191 | "Name of a prefix list\n" | |
5192 | "Filter incoming updates\n" | |
5193 | "Filter outgoing updates\n") | |
596c17ba | 5194 | |
718e3744 | 5195 | DEFUN (no_neighbor_prefix_list, |
5196 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5197 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5198 | NO_STR |
5199 | NEIGHBOR_STR | |
5200 | NEIGHBOR_ADDR_STR2 | |
5201 | "Filter updates to/from this neighbor\n" | |
5202 | "Name of a prefix list\n" | |
5203 | "Filter incoming updates\n" | |
5204 | "Filter outgoing updates\n") | |
5205 | { | |
d62a17ae | 5206 | int idx_peer = 2; |
5207 | int idx_in_out = 5; | |
5208 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
5209 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5210 | argv[idx_in_out]->arg); | |
718e3744 | 5211 | } |
6b0655a2 | 5212 | |
d62a17ae | 5213 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
5214 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5215 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5216 | "Filter updates to/from this neighbor\n" | |
5217 | "Name of a prefix list\n" | |
5218 | "Filter incoming updates\n" | |
5219 | "Filter outgoing updates\n") | |
596c17ba | 5220 | |
d62a17ae | 5221 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5222 | safi_t safi, const char *name_str, | |
5223 | const char *direct_str) | |
718e3744 | 5224 | { |
d62a17ae | 5225 | int ret; |
5226 | struct peer *peer; | |
5227 | int direct = FILTER_IN; | |
718e3744 | 5228 | |
d62a17ae | 5229 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5230 | if (!peer) | |
5231 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5232 | |
d62a17ae | 5233 | /* Check filter direction. */ |
5234 | if (strncmp(direct_str, "i", 1) == 0) | |
5235 | direct = FILTER_IN; | |
5236 | else if (strncmp(direct_str, "o", 1) == 0) | |
5237 | direct = FILTER_OUT; | |
718e3744 | 5238 | |
d62a17ae | 5239 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 5240 | |
d62a17ae | 5241 | return bgp_vty_return(vty, ret); |
718e3744 | 5242 | } |
5243 | ||
d62a17ae | 5244 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5245 | safi_t safi, const char *direct_str) | |
718e3744 | 5246 | { |
d62a17ae | 5247 | int ret; |
5248 | struct peer *peer; | |
5249 | int direct = FILTER_IN; | |
718e3744 | 5250 | |
d62a17ae | 5251 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5252 | if (!peer) | |
5253 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5254 | |
d62a17ae | 5255 | /* Check filter direction. */ |
5256 | if (strncmp(direct_str, "i", 1) == 0) | |
5257 | direct = FILTER_IN; | |
5258 | else if (strncmp(direct_str, "o", 1) == 0) | |
5259 | direct = FILTER_OUT; | |
718e3744 | 5260 | |
d62a17ae | 5261 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 5262 | |
d62a17ae | 5263 | return bgp_vty_return(vty, ret); |
718e3744 | 5264 | } |
5265 | ||
5266 | DEFUN (neighbor_filter_list, | |
5267 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5268 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5269 | NEIGHBOR_STR |
5270 | NEIGHBOR_ADDR_STR2 | |
5271 | "Establish BGP filters\n" | |
5272 | "AS path access-list name\n" | |
5273 | "Filter incoming routes\n" | |
5274 | "Filter outgoing routes\n") | |
5275 | { | |
d62a17ae | 5276 | int idx_peer = 1; |
5277 | int idx_word = 3; | |
5278 | int idx_in_out = 4; | |
5279 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5280 | bgp_node_safi(vty), argv[idx_word]->arg, | |
5281 | argv[idx_in_out]->arg); | |
718e3744 | 5282 | } |
5283 | ||
d62a17ae | 5284 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
5285 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5286 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5287 | "Establish BGP filters\n" | |
5288 | "AS path access-list name\n" | |
5289 | "Filter incoming routes\n" | |
5290 | "Filter outgoing routes\n") | |
596c17ba | 5291 | |
718e3744 | 5292 | DEFUN (no_neighbor_filter_list, |
5293 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5294 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5295 | NO_STR |
5296 | NEIGHBOR_STR | |
5297 | NEIGHBOR_ADDR_STR2 | |
5298 | "Establish BGP filters\n" | |
5299 | "AS path access-list name\n" | |
5300 | "Filter incoming routes\n" | |
5301 | "Filter outgoing routes\n") | |
5302 | { | |
d62a17ae | 5303 | int idx_peer = 2; |
5304 | int idx_in_out = 5; | |
5305 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
5306 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5307 | argv[idx_in_out]->arg); | |
718e3744 | 5308 | } |
6b0655a2 | 5309 | |
d62a17ae | 5310 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
5311 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5312 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5313 | "Establish BGP filters\n" | |
5314 | "AS path access-list name\n" | |
5315 | "Filter incoming routes\n" | |
5316 | "Filter outgoing routes\n") | |
596c17ba | 5317 | |
718e3744 | 5318 | /* Set route-map to the peer. */ |
d62a17ae | 5319 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
5320 | afi_t afi, safi_t safi, const char *name_str, | |
5321 | const char *direct_str) | |
718e3744 | 5322 | { |
d62a17ae | 5323 | int ret; |
5324 | struct peer *peer; | |
5325 | int direct = RMAP_IN; | |
718e3744 | 5326 | |
d62a17ae | 5327 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5328 | if (!peer) | |
5329 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5330 | |
d62a17ae | 5331 | /* Check filter direction. */ |
5332 | if (strncmp(direct_str, "in", 2) == 0) | |
5333 | direct = RMAP_IN; | |
5334 | else if (strncmp(direct_str, "o", 1) == 0) | |
5335 | direct = RMAP_OUT; | |
718e3744 | 5336 | |
d62a17ae | 5337 | ret = peer_route_map_set(peer, afi, safi, direct, name_str); |
718e3744 | 5338 | |
d62a17ae | 5339 | return bgp_vty_return(vty, ret); |
718e3744 | 5340 | } |
5341 | ||
d62a17ae | 5342 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
5343 | afi_t afi, safi_t safi, | |
5344 | const char *direct_str) | |
718e3744 | 5345 | { |
d62a17ae | 5346 | int ret; |
5347 | struct peer *peer; | |
5348 | int direct = RMAP_IN; | |
718e3744 | 5349 | |
d62a17ae | 5350 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5351 | if (!peer) | |
5352 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5353 | |
d62a17ae | 5354 | /* Check filter direction. */ |
5355 | if (strncmp(direct_str, "in", 2) == 0) | |
5356 | direct = RMAP_IN; | |
5357 | else if (strncmp(direct_str, "o", 1) == 0) | |
5358 | direct = RMAP_OUT; | |
718e3744 | 5359 | |
d62a17ae | 5360 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 5361 | |
d62a17ae | 5362 | return bgp_vty_return(vty, ret); |
718e3744 | 5363 | } |
5364 | ||
5365 | DEFUN (neighbor_route_map, | |
5366 | neighbor_route_map_cmd, | |
9ccf14f7 | 5367 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5368 | NEIGHBOR_STR |
5369 | NEIGHBOR_ADDR_STR2 | |
5370 | "Apply route map to neighbor\n" | |
5371 | "Name of route map\n" | |
5372 | "Apply map to incoming routes\n" | |
2a3d5731 | 5373 | "Apply map to outbound routes\n") |
718e3744 | 5374 | { |
d62a17ae | 5375 | int idx_peer = 1; |
5376 | int idx_word = 3; | |
5377 | int idx_in_out = 4; | |
5378 | return peer_route_map_set_vty( | |
5379 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5380 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5381 | } |
5382 | ||
d62a17ae | 5383 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
5384 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5385 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5386 | "Apply route map to neighbor\n" | |
5387 | "Name of route map\n" | |
5388 | "Apply map to incoming routes\n" | |
5389 | "Apply map to outbound routes\n") | |
596c17ba | 5390 | |
718e3744 | 5391 | DEFUN (no_neighbor_route_map, |
5392 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5393 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5394 | NO_STR |
5395 | NEIGHBOR_STR | |
5396 | NEIGHBOR_ADDR_STR2 | |
5397 | "Apply route map to neighbor\n" | |
5398 | "Name of route map\n" | |
5399 | "Apply map to incoming routes\n" | |
2a3d5731 | 5400 | "Apply map to outbound routes\n") |
718e3744 | 5401 | { |
d62a17ae | 5402 | int idx_peer = 2; |
5403 | int idx_in_out = 5; | |
5404 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
5405 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5406 | argv[idx_in_out]->arg); | |
718e3744 | 5407 | } |
6b0655a2 | 5408 | |
d62a17ae | 5409 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
5410 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5411 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5412 | "Apply route map to neighbor\n" | |
5413 | "Name of route map\n" | |
5414 | "Apply map to incoming routes\n" | |
5415 | "Apply map to outbound routes\n") | |
596c17ba | 5416 | |
718e3744 | 5417 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 5418 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
5419 | afi_t afi, safi_t safi, | |
5420 | const char *name_str) | |
718e3744 | 5421 | { |
d62a17ae | 5422 | int ret; |
5423 | struct peer *peer; | |
718e3744 | 5424 | |
d62a17ae | 5425 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5426 | if (!peer) | |
5427 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5428 | |
d62a17ae | 5429 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str); |
718e3744 | 5430 | |
d62a17ae | 5431 | return bgp_vty_return(vty, ret); |
718e3744 | 5432 | } |
5433 | ||
5434 | /* Unset route-map from the peer. */ | |
d62a17ae | 5435 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
5436 | afi_t afi, safi_t safi) | |
718e3744 | 5437 | { |
d62a17ae | 5438 | int ret; |
5439 | struct peer *peer; | |
718e3744 | 5440 | |
d62a17ae | 5441 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5442 | if (!peer) | |
5443 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5444 | |
d62a17ae | 5445 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 5446 | |
d62a17ae | 5447 | return bgp_vty_return(vty, ret); |
718e3744 | 5448 | } |
5449 | ||
5450 | DEFUN (neighbor_unsuppress_map, | |
5451 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5452 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5453 | NEIGHBOR_STR |
5454 | NEIGHBOR_ADDR_STR2 | |
5455 | "Route-map to selectively unsuppress suppressed routes\n" | |
5456 | "Name of route map\n") | |
5457 | { | |
d62a17ae | 5458 | int idx_peer = 1; |
5459 | int idx_word = 3; | |
5460 | return peer_unsuppress_map_set_vty( | |
5461 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5462 | argv[idx_word]->arg); | |
718e3744 | 5463 | } |
5464 | ||
d62a17ae | 5465 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
5466 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5467 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5468 | "Route-map to selectively unsuppress suppressed routes\n" | |
5469 | "Name of route map\n") | |
596c17ba | 5470 | |
718e3744 | 5471 | DEFUN (no_neighbor_unsuppress_map, |
5472 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5473 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5474 | NO_STR |
5475 | NEIGHBOR_STR | |
5476 | NEIGHBOR_ADDR_STR2 | |
5477 | "Route-map to selectively unsuppress suppressed routes\n" | |
5478 | "Name of route map\n") | |
5479 | { | |
d62a17ae | 5480 | int idx_peer = 2; |
5481 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
5482 | bgp_node_afi(vty), | |
5483 | bgp_node_safi(vty)); | |
718e3744 | 5484 | } |
6b0655a2 | 5485 | |
d62a17ae | 5486 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
5487 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5488 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5489 | "Route-map to selectively unsuppress suppressed routes\n" | |
5490 | "Name of route map\n") | |
596c17ba | 5491 | |
d62a17ae | 5492 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
5493 | afi_t afi, safi_t safi, | |
5494 | const char *num_str, | |
5495 | const char *threshold_str, int warning, | |
5496 | const char *restart_str) | |
718e3744 | 5497 | { |
d62a17ae | 5498 | int ret; |
5499 | struct peer *peer; | |
5500 | u_int32_t max; | |
5501 | u_char threshold; | |
5502 | u_int16_t restart; | |
718e3744 | 5503 | |
d62a17ae | 5504 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5505 | if (!peer) | |
5506 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5507 | |
d62a17ae | 5508 | max = strtoul(num_str, NULL, 10); |
5509 | if (threshold_str) | |
5510 | threshold = atoi(threshold_str); | |
5511 | else | |
5512 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5513 | |
d62a17ae | 5514 | if (restart_str) |
5515 | restart = atoi(restart_str); | |
5516 | else | |
5517 | restart = 0; | |
0a486e5f | 5518 | |
d62a17ae | 5519 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
5520 | restart); | |
718e3744 | 5521 | |
d62a17ae | 5522 | return bgp_vty_return(vty, ret); |
718e3744 | 5523 | } |
5524 | ||
d62a17ae | 5525 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
5526 | afi_t afi, safi_t safi) | |
718e3744 | 5527 | { |
d62a17ae | 5528 | int ret; |
5529 | struct peer *peer; | |
718e3744 | 5530 | |
d62a17ae | 5531 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5532 | if (!peer) | |
5533 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5534 | |
d62a17ae | 5535 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 5536 | |
d62a17ae | 5537 | return bgp_vty_return(vty, ret); |
718e3744 | 5538 | } |
5539 | ||
5540 | /* Maximum number of prefix configuration. prefix count is different | |
5541 | for each peer configuration. So this configuration can be set for | |
5542 | each peer configuration. */ | |
5543 | DEFUN (neighbor_maximum_prefix, | |
5544 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5545 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5546 | NEIGHBOR_STR |
5547 | NEIGHBOR_ADDR_STR2 | |
5548 | "Maximum number of prefix accept from this peer\n" | |
5549 | "maximum no. of prefix limit\n") | |
5550 | { | |
d62a17ae | 5551 | int idx_peer = 1; |
5552 | int idx_number = 3; | |
5553 | return peer_maximum_prefix_set_vty( | |
5554 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5555 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 5556 | } |
5557 | ||
d62a17ae | 5558 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
5559 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
5560 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5561 | "Maximum number of prefix accept from this peer\n" | |
5562 | "maximum no. of prefix limit\n") | |
596c17ba | 5563 | |
e0701b79 | 5564 | DEFUN (neighbor_maximum_prefix_threshold, |
5565 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5566 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5567 | NEIGHBOR_STR |
5568 | NEIGHBOR_ADDR_STR2 | |
5569 | "Maximum number of prefix accept from this peer\n" | |
5570 | "maximum no. of prefix limit\n" | |
5571 | "Threshold value (%) at which to generate a warning msg\n") | |
5572 | { | |
d62a17ae | 5573 | int idx_peer = 1; |
5574 | int idx_number = 3; | |
5575 | int idx_number_2 = 4; | |
5576 | return peer_maximum_prefix_set_vty( | |
5577 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5578 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 5579 | } |
e0701b79 | 5580 | |
d62a17ae | 5581 | ALIAS_HIDDEN( |
5582 | neighbor_maximum_prefix_threshold, | |
5583 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
5584 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
5585 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5586 | "Maximum number of prefix accept from this peer\n" | |
5587 | "maximum no. of prefix limit\n" | |
5588 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 5589 | |
718e3744 | 5590 | DEFUN (neighbor_maximum_prefix_warning, |
5591 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5592 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5593 | NEIGHBOR_STR |
5594 | NEIGHBOR_ADDR_STR2 | |
5595 | "Maximum number of prefix accept from this peer\n" | |
5596 | "maximum no. of prefix limit\n" | |
5597 | "Only give warning message when limit is exceeded\n") | |
5598 | { | |
d62a17ae | 5599 | int idx_peer = 1; |
5600 | int idx_number = 3; | |
5601 | return peer_maximum_prefix_set_vty( | |
5602 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5603 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 5604 | } |
5605 | ||
d62a17ae | 5606 | ALIAS_HIDDEN( |
5607 | neighbor_maximum_prefix_warning, | |
5608 | neighbor_maximum_prefix_warning_hidden_cmd, | |
5609 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
5610 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5611 | "Maximum number of prefix accept from this peer\n" | |
5612 | "maximum no. of prefix limit\n" | |
5613 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5614 | |
e0701b79 | 5615 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5616 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5617 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5618 | NEIGHBOR_STR |
5619 | NEIGHBOR_ADDR_STR2 | |
5620 | "Maximum number of prefix accept from this peer\n" | |
5621 | "maximum no. of prefix limit\n" | |
5622 | "Threshold value (%) at which to generate a warning msg\n" | |
5623 | "Only give warning message when limit is exceeded\n") | |
5624 | { | |
d62a17ae | 5625 | int idx_peer = 1; |
5626 | int idx_number = 3; | |
5627 | int idx_number_2 = 4; | |
5628 | return peer_maximum_prefix_set_vty( | |
5629 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5630 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5631 | } |
5632 | ||
d62a17ae | 5633 | ALIAS_HIDDEN( |
5634 | neighbor_maximum_prefix_threshold_warning, | |
5635 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
5636 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
5637 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5638 | "Maximum number of prefix accept from this peer\n" | |
5639 | "maximum no. of prefix limit\n" | |
5640 | "Threshold value (%) at which to generate a warning msg\n" | |
5641 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5642 | |
0a486e5f | 5643 | DEFUN (neighbor_maximum_prefix_restart, |
5644 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5645 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 5646 | NEIGHBOR_STR |
5647 | NEIGHBOR_ADDR_STR2 | |
5648 | "Maximum number of prefix accept from this peer\n" | |
5649 | "maximum no. of prefix limit\n" | |
5650 | "Restart bgp connection after limit is exceeded\n" | |
5651 | "Restart interval in minutes") | |
5652 | { | |
d62a17ae | 5653 | int idx_peer = 1; |
5654 | int idx_number = 3; | |
5655 | int idx_number_2 = 5; | |
5656 | return peer_maximum_prefix_set_vty( | |
5657 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5658 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 5659 | } |
5660 | ||
d62a17ae | 5661 | ALIAS_HIDDEN( |
5662 | neighbor_maximum_prefix_restart, | |
5663 | neighbor_maximum_prefix_restart_hidden_cmd, | |
5664 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
5665 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5666 | "Maximum number of prefix accept from this peer\n" | |
5667 | "maximum no. of prefix limit\n" | |
5668 | "Restart bgp connection after limit is exceeded\n" | |
5669 | "Restart interval in minutes") | |
596c17ba | 5670 | |
0a486e5f | 5671 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
5672 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 5673 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 5674 | NEIGHBOR_STR |
5675 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5676 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 5677 | "maximum no. of prefix limit\n" |
5678 | "Threshold value (%) at which to generate a warning msg\n" | |
5679 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5680 | "Restart interval in minutes\n") |
0a486e5f | 5681 | { |
d62a17ae | 5682 | int idx_peer = 1; |
5683 | int idx_number = 3; | |
5684 | int idx_number_2 = 4; | |
5685 | int idx_number_3 = 6; | |
5686 | return peer_maximum_prefix_set_vty( | |
5687 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5688 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
5689 | argv[idx_number_3]->arg); | |
5690 | } | |
5691 | ||
5692 | ALIAS_HIDDEN( | |
5693 | neighbor_maximum_prefix_threshold_restart, | |
5694 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
5695 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
5696 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5697 | "Maximum number of prefixes to accept from this peer\n" | |
5698 | "maximum no. of prefix limit\n" | |
5699 | "Threshold value (%) at which to generate a warning msg\n" | |
5700 | "Restart bgp connection after limit is exceeded\n" | |
5701 | "Restart interval in minutes\n") | |
596c17ba | 5702 | |
718e3744 | 5703 | DEFUN (no_neighbor_maximum_prefix, |
5704 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 5705 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 5706 | NO_STR |
5707 | NEIGHBOR_STR | |
5708 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5709 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
5710 | "maximum no. of prefix limit\n" |
5711 | "Threshold value (%) at which to generate a warning msg\n" | |
5712 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5713 | "Restart interval in minutes\n" |
31500417 | 5714 | "Only give warning message when limit is exceeded\n") |
718e3744 | 5715 | { |
d62a17ae | 5716 | int idx_peer = 2; |
5717 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
5718 | bgp_node_afi(vty), | |
5719 | bgp_node_safi(vty)); | |
718e3744 | 5720 | } |
e52702f2 | 5721 | |
d62a17ae | 5722 | ALIAS_HIDDEN( |
5723 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
5724 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
5725 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5726 | "Maximum number of prefixes to accept from this peer\n" | |
5727 | "maximum no. of prefix limit\n" | |
5728 | "Threshold value (%) at which to generate a warning msg\n" | |
5729 | "Restart bgp connection after limit is exceeded\n" | |
5730 | "Restart interval in minutes\n" | |
5731 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5732 | |
718e3744 | 5733 | |
718e3744 | 5734 | /* "neighbor allowas-in" */ |
5735 | DEFUN (neighbor_allowas_in, | |
5736 | neighbor_allowas_in_cmd, | |
fd8503f5 | 5737 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5738 | NEIGHBOR_STR |
5739 | NEIGHBOR_ADDR_STR2 | |
31500417 | 5740 | "Accept as-path with my AS present in it\n" |
fd8503f5 QY |
5741 | "Number of occurances of AS number\n" |
5742 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5743 | { |
d62a17ae | 5744 | int idx_peer = 1; |
5745 | int idx_number_origin = 3; | |
5746 | int ret; | |
5747 | int origin = 0; | |
5748 | struct peer *peer; | |
5749 | int allow_num = 0; | |
5750 | ||
5751 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5752 | if (!peer) | |
5753 | return CMD_WARNING_CONFIG_FAILED; | |
5754 | ||
5755 | if (argc <= idx_number_origin) | |
5756 | allow_num = 3; | |
5757 | else { | |
5758 | if (argv[idx_number_origin]->type == WORD_TKN) | |
5759 | origin = 1; | |
5760 | else | |
5761 | allow_num = atoi(argv[idx_number_origin]->arg); | |
5762 | } | |
5763 | ||
5764 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5765 | allow_num, origin); | |
5766 | ||
5767 | return bgp_vty_return(vty, ret); | |
5768 | } | |
5769 | ||
5770 | ALIAS_HIDDEN( | |
5771 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
5772 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
5773 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5774 | "Accept as-path with my AS present in it\n" | |
5775 | "Number of occurances of AS number\n" | |
5776 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
596c17ba | 5777 | |
718e3744 | 5778 | DEFUN (no_neighbor_allowas_in, |
5779 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 5780 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5781 | NO_STR |
5782 | NEIGHBOR_STR | |
5783 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 5784 | "allow local ASN appears in aspath attribute\n" |
fd8503f5 QY |
5785 | "Number of occurances of AS number\n" |
5786 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5787 | { |
d62a17ae | 5788 | int idx_peer = 2; |
5789 | int ret; | |
5790 | struct peer *peer; | |
718e3744 | 5791 | |
d62a17ae | 5792 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5793 | if (!peer) | |
5794 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5795 | |
d62a17ae | 5796 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
5797 | bgp_node_safi(vty)); | |
718e3744 | 5798 | |
d62a17ae | 5799 | return bgp_vty_return(vty, ret); |
718e3744 | 5800 | } |
6b0655a2 | 5801 | |
d62a17ae | 5802 | ALIAS_HIDDEN( |
5803 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
5804 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
5805 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5806 | "allow local ASN appears in aspath attribute\n" | |
5807 | "Number of occurances of AS number\n" | |
5808 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
596c17ba | 5809 | |
fa411a21 NH |
5810 | DEFUN (neighbor_ttl_security, |
5811 | neighbor_ttl_security_cmd, | |
9ccf14f7 | 5812 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5813 | NEIGHBOR_STR |
5814 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5815 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
5816 | "Specify the maximum number of hops to the BGP peer\n" |
5817 | "Number of hops to BGP peer\n") | |
fa411a21 | 5818 | { |
d62a17ae | 5819 | int idx_peer = 1; |
5820 | int idx_number = 4; | |
5821 | struct peer *peer; | |
5822 | int gtsm_hops; | |
5823 | ||
5824 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5825 | if (!peer) | |
5826 | return CMD_WARNING_CONFIG_FAILED; | |
5827 | ||
5828 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
5829 | ||
5830 | /* | |
5831 | * If 'neighbor swpX', then this is for directly connected peers, | |
5832 | * we should not accept a ttl-security hops value greater than 1. | |
5833 | */ | |
5834 | if (peer->conf_if && (gtsm_hops > 1)) { | |
5835 | vty_out(vty, | |
5836 | "%s is directly connected peer, hops cannot exceed 1\n", | |
5837 | argv[idx_peer]->arg); | |
5838 | return CMD_WARNING_CONFIG_FAILED; | |
5839 | } | |
8cdabf90 | 5840 | |
d62a17ae | 5841 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
5842 | } |
5843 | ||
5844 | DEFUN (no_neighbor_ttl_security, | |
5845 | no_neighbor_ttl_security_cmd, | |
9ccf14f7 | 5846 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5847 | NO_STR |
5848 | NEIGHBOR_STR | |
5849 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5850 | "BGP ttl-security parameters\n" |
3a2d747c QY |
5851 | "Specify the maximum number of hops to the BGP peer\n" |
5852 | "Number of hops to BGP peer\n") | |
fa411a21 | 5853 | { |
d62a17ae | 5854 | int idx_peer = 2; |
5855 | struct peer *peer; | |
fa411a21 | 5856 | |
d62a17ae | 5857 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5858 | if (!peer) | |
5859 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 5860 | |
d62a17ae | 5861 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 5862 | } |
6b0655a2 | 5863 | |
adbac85e DW |
5864 | DEFUN (neighbor_addpath_tx_all_paths, |
5865 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5866 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5867 | NEIGHBOR_STR |
5868 | NEIGHBOR_ADDR_STR2 | |
5869 | "Use addpath to advertise all paths to a neighbor\n") | |
5870 | { | |
d62a17ae | 5871 | int idx_peer = 1; |
5872 | struct peer *peer; | |
adbac85e | 5873 | |
d62a17ae | 5874 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5875 | if (!peer) | |
5876 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 5877 | |
d62a17ae | 5878 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5879 | bgp_node_safi(vty), | |
5880 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
adbac85e DW |
5881 | } |
5882 | ||
d62a17ae | 5883 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
5884 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
5885 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
5886 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5887 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 5888 | |
adbac85e DW |
5889 | DEFUN (no_neighbor_addpath_tx_all_paths, |
5890 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5891 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5892 | NO_STR |
5893 | NEIGHBOR_STR | |
5894 | NEIGHBOR_ADDR_STR2 | |
5895 | "Use addpath to advertise all paths to a neighbor\n") | |
5896 | { | |
d62a17ae | 5897 | int idx_peer = 2; |
5898 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5899 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5900 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
adbac85e DW |
5901 | } |
5902 | ||
d62a17ae | 5903 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
5904 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
5905 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
5906 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5907 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 5908 | |
06370dac DW |
5909 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
5910 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5911 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5912 | NEIGHBOR_STR |
5913 | NEIGHBOR_ADDR_STR2 | |
5914 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5915 | { | |
d62a17ae | 5916 | int idx_peer = 1; |
5917 | struct peer *peer; | |
06370dac | 5918 | |
d62a17ae | 5919 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5920 | if (!peer) | |
5921 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 5922 | |
d62a17ae | 5923 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5924 | bgp_node_safi(vty), | |
5925 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
06370dac DW |
5926 | } |
5927 | ||
d62a17ae | 5928 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
5929 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
5930 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
5931 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5932 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 5933 | |
06370dac DW |
5934 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
5935 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5936 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5937 | NO_STR |
5938 | NEIGHBOR_STR | |
5939 | NEIGHBOR_ADDR_STR2 | |
5940 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5941 | { | |
d62a17ae | 5942 | int idx_peer = 2; |
5943 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5944 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5945 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
06370dac DW |
5946 | } |
5947 | ||
d62a17ae | 5948 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
5949 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
5950 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
5951 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5952 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 5953 | |
505e5056 | 5954 | DEFUN_NOSH (address_family_ipv4_safi, |
718e3744 | 5955 | address_family_ipv4_safi_cmd, |
5b1f0f29 | 5956 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast>]", |
718e3744 | 5957 | "Enter Address Family command mode\n" |
8c3deaae | 5958 | "Address Family\n" |
b6ab5a3a | 5959 | BGP_SAFI_WITH_LABEL_HELP_STR) |
718e3744 | 5960 | { |
f51bae9c | 5961 | |
d62a17ae | 5962 | if (argc == 3) { |
5963 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
5964 | vty->node = bgp_node_type(AFI_IP, safi); | |
5965 | } else | |
5966 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 5967 | |
d62a17ae | 5968 | return CMD_SUCCESS; |
718e3744 | 5969 | } |
5970 | ||
505e5056 | 5971 | DEFUN_NOSH (address_family_ipv6_safi, |
25ffbdc1 | 5972 | address_family_ipv6_safi_cmd, |
5b1f0f29 | 5973 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast>]", |
718e3744 | 5974 | "Enter Address Family command mode\n" |
8c3deaae | 5975 | "Address Family\n" |
b6ab5a3a | 5976 | BGP_SAFI_WITH_LABEL_HELP_STR) |
25ffbdc1 | 5977 | { |
d62a17ae | 5978 | if (argc == 3) { |
5979 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
5980 | vty->node = bgp_node_type(AFI_IP6, safi); | |
5981 | } else | |
5982 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 5983 | |
d62a17ae | 5984 | return CMD_SUCCESS; |
25ffbdc1 | 5985 | } |
718e3744 | 5986 | |
d6902373 | 5987 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 5988 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 5989 | address_family_vpnv4_cmd, |
8334fd5a | 5990 | "address-family vpnv4 [unicast]", |
718e3744 | 5991 | "Enter Address Family command mode\n" |
8c3deaae | 5992 | "Address Family\n" |
3a2d747c | 5993 | "Address Family modifier\n") |
718e3744 | 5994 | { |
d62a17ae | 5995 | vty->node = BGP_VPNV4_NODE; |
5996 | return CMD_SUCCESS; | |
718e3744 | 5997 | } |
5998 | ||
505e5056 | 5999 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 6000 | address_family_vpnv6_cmd, |
8334fd5a | 6001 | "address-family vpnv6 [unicast]", |
8ecd3266 | 6002 | "Enter Address Family command mode\n" |
8c3deaae | 6003 | "Address Family\n" |
3a2d747c | 6004 | "Address Family modifier\n") |
8ecd3266 | 6005 | { |
d62a17ae | 6006 | vty->node = BGP_VPNV6_NODE; |
6007 | return CMD_SUCCESS; | |
8ecd3266 | 6008 | } |
c016b6c7 | 6009 | #endif |
d6902373 | 6010 | |
505e5056 | 6011 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 6012 | address_family_evpn_cmd, |
7111c1a0 | 6013 | "address-family l2vpn evpn", |
4e0b7b6d | 6014 | "Enter Address Family command mode\n" |
7111c1a0 QY |
6015 | "Address Family\n" |
6016 | "Address Family modifier\n") | |
4e0b7b6d | 6017 | { |
d62a17ae | 6018 | vty->node = BGP_EVPN_NODE; |
6019 | return CMD_SUCCESS; | |
4e0b7b6d PG |
6020 | } |
6021 | ||
505e5056 | 6022 | DEFUN_NOSH (exit_address_family, |
718e3744 | 6023 | exit_address_family_cmd, |
6024 | "exit-address-family", | |
6025 | "Exit from Address Family configuration mode\n") | |
6026 | { | |
d62a17ae | 6027 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
6028 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
6029 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
6030 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
6031 | || vty->node == BGP_EVPN_NODE) | |
6032 | vty->node = BGP_NODE; | |
6033 | return CMD_SUCCESS; | |
718e3744 | 6034 | } |
6b0655a2 | 6035 | |
8ad7271d | 6036 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 6037 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
6038 | const char *ip_str, afi_t afi, safi_t safi, | |
6039 | struct prefix_rd *prd) | |
6040 | { | |
6041 | int ret; | |
6042 | struct prefix match; | |
6043 | struct bgp_node *rn; | |
6044 | struct bgp_node *rm; | |
6045 | struct bgp *bgp; | |
6046 | struct bgp_table *table; | |
6047 | struct bgp_table *rib; | |
6048 | ||
6049 | /* BGP structure lookup. */ | |
6050 | if (view_name) { | |
6051 | bgp = bgp_lookup_by_name(view_name); | |
6052 | if (bgp == NULL) { | |
6053 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
6054 | view_name); | |
6055 | return CMD_WARNING; | |
6056 | } | |
6057 | } else { | |
6058 | bgp = bgp_get_default(); | |
6059 | if (bgp == NULL) { | |
6060 | vty_out(vty, "%% No BGP process is configured\n"); | |
6061 | return CMD_WARNING; | |
6062 | } | |
6063 | } | |
6064 | ||
6065 | /* Check IP address argument. */ | |
6066 | ret = str2prefix(ip_str, &match); | |
6067 | if (!ret) { | |
6068 | vty_out(vty, "%% address is malformed\n"); | |
6069 | return CMD_WARNING; | |
6070 | } | |
6071 | ||
6072 | match.family = afi2family(afi); | |
6073 | rib = bgp->rib[afi][safi]; | |
6074 | ||
6075 | if (safi == SAFI_MPLS_VPN) { | |
6076 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
6077 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
6078 | continue; | |
6079 | ||
6080 | if ((table = rn->info) != NULL) { | |
6081 | if ((rm = bgp_node_match(table, &match)) | |
6082 | != NULL) { | |
6083 | if (rm->p.prefixlen | |
6084 | == match.prefixlen) { | |
6085 | SET_FLAG(rn->flags, | |
6086 | BGP_NODE_USER_CLEAR); | |
6087 | bgp_process(bgp, rm, afi, safi); | |
6088 | } | |
6089 | bgp_unlock_node(rm); | |
6090 | } | |
6091 | } | |
6092 | } | |
6093 | } else { | |
6094 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
6095 | if (rn->p.prefixlen == match.prefixlen) { | |
6096 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
6097 | bgp_process(bgp, rn, afi, safi); | |
6098 | } | |
6099 | bgp_unlock_node(rn); | |
6100 | } | |
6101 | } | |
6102 | ||
6103 | return CMD_SUCCESS; | |
8ad7271d DS |
6104 | } |
6105 | ||
b09b5ae0 | 6106 | /* one clear bgp command to rule them all */ |
718e3744 | 6107 | DEFUN (clear_ip_bgp_all, |
6108 | clear_ip_bgp_all_cmd, | |
c1a44e43 | 6109 | "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 | 6110 | CLEAR_STR |
6111 | IP_STR | |
6112 | BGP_STR | |
838758ac | 6113 | BGP_INSTANCE_HELP_STR |
b09b5ae0 DW |
6114 | "Clear all peers\n" |
6115 | "BGP neighbor address to clear\n" | |
a80beece | 6116 | "BGP IPv6 neighbor to clear\n" |
838758ac | 6117 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
6118 | "Clear peers with the AS number\n" |
6119 | "Clear all external peers\n" | |
718e3744 | 6120 | "Clear all members of peer-group\n" |
b09b5ae0 | 6121 | "BGP peer-group name\n" |
46f296b4 | 6122 | BGP_AFI_HELP_STR |
9bedbb1e | 6123 | BGP_SAFI_WITH_LABEL_HELP_STR |
b09b5ae0 DW |
6124 | BGP_SOFT_STR |
6125 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
6126 | BGP_SOFT_OUT_STR |
6127 | BGP_SOFT_IN_STR | |
6128 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 6129 | BGP_SOFT_OUT_STR) |
718e3744 | 6130 | { |
d62a17ae | 6131 | char *vrf = NULL; |
6132 | ||
6133 | afi_t afi = AFI_IP6; | |
6134 | safi_t safi = SAFI_UNICAST; | |
6135 | enum clear_sort clr_sort = clear_peer; | |
6136 | enum bgp_clear_type clr_type; | |
6137 | char *clr_arg = NULL; | |
6138 | ||
6139 | int idx = 0; | |
6140 | ||
6141 | /* clear [ip] bgp */ | |
6142 | if (argv_find(argv, argc, "ip", &idx)) | |
6143 | afi = AFI_IP; | |
6144 | ||
6145 | /* [<view|vrf> VIEWVRFNAME] */ | |
6146 | if (argv_find(argv, argc, "view", &idx) | |
6147 | || argv_find(argv, argc, "vrf", &idx)) { | |
6148 | vrf = argv[idx + 1]->arg; | |
6149 | idx += 2; | |
6150 | } | |
6151 | ||
6152 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
6153 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
6154 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
6155 | ||
6156 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ | |
6157 | if (argv_find(argv, argc, "*", &idx)) { | |
6158 | clr_sort = clear_all; | |
6159 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
6160 | clr_sort = clear_peer; | |
6161 | clr_arg = argv[idx]->arg; | |
6162 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
6163 | clr_sort = clear_peer; | |
6164 | clr_arg = argv[idx]->arg; | |
6165 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
6166 | clr_sort = clear_group; | |
6167 | idx++; | |
6168 | clr_arg = argv[idx]->arg; | |
6169 | } else if (argv_find(argv, argc, "WORD", &idx)) { | |
6170 | clr_sort = clear_peer; | |
6171 | clr_arg = argv[idx]->arg; | |
6172 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { | |
6173 | clr_sort = clear_as; | |
6174 | clr_arg = argv[idx]->arg; | |
6175 | } else if (argv_find(argv, argc, "external", &idx)) { | |
6176 | clr_sort = clear_external; | |
6177 | } | |
6178 | ||
6179 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
6180 | if (argv_find(argv, argc, "soft", &idx)) { | |
6181 | if (argv_find(argv, argc, "in", &idx) | |
6182 | || argv_find(argv, argc, "out", &idx)) | |
6183 | clr_type = strmatch(argv[idx]->text, "in") | |
6184 | ? BGP_CLEAR_SOFT_IN | |
6185 | : BGP_CLEAR_SOFT_OUT; | |
6186 | else | |
6187 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
6188 | } else if (argv_find(argv, argc, "in", &idx)) { | |
6189 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
6190 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
6191 | : BGP_CLEAR_SOFT_IN; | |
6192 | } else if (argv_find(argv, argc, "out", &idx)) { | |
6193 | clr_type = BGP_CLEAR_SOFT_OUT; | |
6194 | } else | |
6195 | clr_type = BGP_CLEAR_SOFT_NONE; | |
6196 | ||
6197 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 6198 | } |
01080f7c | 6199 | |
8ad7271d DS |
6200 | DEFUN (clear_ip_bgp_prefix, |
6201 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 6202 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
6203 | CLEAR_STR |
6204 | IP_STR | |
6205 | BGP_STR | |
838758ac | 6206 | BGP_INSTANCE_HELP_STR |
8ad7271d | 6207 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6208 | "IPv4 prefix\n") |
8ad7271d | 6209 | { |
d62a17ae | 6210 | char *vrf = NULL; |
6211 | char *prefix = NULL; | |
8ad7271d | 6212 | |
d62a17ae | 6213 | int idx = 0; |
01080f7c | 6214 | |
d62a17ae | 6215 | /* [<view|vrf> VIEWVRFNAME] */ |
6216 | if (argv_find(argv, argc, "WORD", &idx)) | |
6217 | vrf = argv[idx]->arg; | |
0c7b1b01 | 6218 | |
d62a17ae | 6219 | prefix = argv[argc - 1]->arg; |
8ad7271d | 6220 | |
d62a17ae | 6221 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 6222 | } |
8ad7271d | 6223 | |
b09b5ae0 DW |
6224 | DEFUN (clear_bgp_ipv6_safi_prefix, |
6225 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 6226 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6227 | CLEAR_STR |
3a2d747c | 6228 | IP_STR |
718e3744 | 6229 | BGP_STR |
8c3deaae | 6230 | "Address Family\n" |
46f296b4 | 6231 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6232 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6233 | "IPv6 prefix\n") |
718e3744 | 6234 | { |
d62a17ae | 6235 | int idx_safi = 3; |
6236 | int idx_ipv6_prefixlen = 5; | |
6237 | return bgp_clear_prefix( | |
6238 | vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, | |
6239 | bgp_vty_safi_from_str(argv[idx_safi]->text), NULL); | |
838758ac | 6240 | } |
01080f7c | 6241 | |
b09b5ae0 DW |
6242 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
6243 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 6244 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6245 | CLEAR_STR |
3a2d747c | 6246 | IP_STR |
718e3744 | 6247 | BGP_STR |
838758ac | 6248 | BGP_INSTANCE_HELP_STR |
8c3deaae | 6249 | "Address Family\n" |
46f296b4 | 6250 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6251 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6252 | "IPv6 prefix\n") |
718e3744 | 6253 | { |
d62a17ae | 6254 | int idx_word = 3; |
6255 | int idx_safi = 5; | |
6256 | int idx_ipv6_prefixlen = 7; | |
6257 | return bgp_clear_prefix( | |
6258 | vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, | |
6259 | AFI_IP6, bgp_vty_safi_from_str(argv[idx_safi]->text), NULL); | |
718e3744 | 6260 | } |
6261 | ||
b09b5ae0 DW |
6262 | DEFUN (show_bgp_views, |
6263 | show_bgp_views_cmd, | |
d6e3c605 | 6264 | "show [ip] bgp views", |
b09b5ae0 | 6265 | SHOW_STR |
d6e3c605 | 6266 | IP_STR |
01080f7c | 6267 | BGP_STR |
b09b5ae0 | 6268 | "Show the defined BGP views\n") |
01080f7c | 6269 | { |
d62a17ae | 6270 | struct list *inst = bm->bgp; |
6271 | struct listnode *node; | |
6272 | struct bgp *bgp; | |
01080f7c | 6273 | |
d62a17ae | 6274 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { |
6275 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
6276 | return CMD_WARNING; | |
6277 | } | |
e52702f2 | 6278 | |
d62a17ae | 6279 | vty_out(vty, "Defined BGP views:\n"); |
6280 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
6281 | /* Skip VRFs. */ | |
6282 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
6283 | continue; | |
6284 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
6285 | bgp->as); | |
6286 | } | |
e52702f2 | 6287 | |
d62a17ae | 6288 | return CMD_SUCCESS; |
e0081f70 ML |
6289 | } |
6290 | ||
8386ac43 | 6291 | DEFUN (show_bgp_vrfs, |
6292 | show_bgp_vrfs_cmd, | |
d6e3c605 | 6293 | "show [ip] bgp vrfs [json]", |
8386ac43 | 6294 | SHOW_STR |
d6e3c605 | 6295 | IP_STR |
8386ac43 | 6296 | BGP_STR |
6297 | "Show BGP VRFs\n" | |
9973d184 | 6298 | JSON_STR) |
8386ac43 | 6299 | { |
d62a17ae | 6300 | struct list *inst = bm->bgp; |
6301 | struct listnode *node; | |
6302 | struct bgp *bgp; | |
6303 | u_char uj = use_json(argc, argv); | |
6304 | json_object *json = NULL; | |
6305 | json_object *json_vrfs = NULL; | |
6306 | int count = 0; | |
6307 | static char header[] = | |
6308 | "Type Id RouterId #PeersCfg #PeersEstb Name"; | |
6309 | ||
6310 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { | |
6311 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
6312 | return CMD_WARNING; | |
6313 | } | |
6314 | ||
6315 | if (uj) { | |
6316 | json = json_object_new_object(); | |
6317 | json_vrfs = json_object_new_object(); | |
6318 | } | |
6319 | ||
6320 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
6321 | const char *name, *type; | |
6322 | struct peer *peer; | |
6323 | struct listnode *node, *nnode; | |
6324 | int peers_cfg, peers_estb; | |
6325 | json_object *json_vrf = NULL; | |
6326 | int vrf_id_ui; | |
6327 | ||
6328 | /* Skip Views. */ | |
6329 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
6330 | continue; | |
6331 | ||
6332 | count++; | |
6333 | if (!uj && count == 1) | |
6334 | vty_out(vty, "%s\n", header); | |
6335 | ||
6336 | peers_cfg = peers_estb = 0; | |
6337 | if (uj) | |
6338 | json_vrf = json_object_new_object(); | |
6339 | ||
6340 | ||
6341 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
6342 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6343 | continue; | |
6344 | peers_cfg++; | |
6345 | if (peer->status == Established) | |
6346 | peers_estb++; | |
6347 | } | |
6348 | ||
6349 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
6350 | name = "Default"; | |
6351 | type = "DFLT"; | |
6352 | } else { | |
6353 | name = bgp->name; | |
6354 | type = "VRF"; | |
6355 | } | |
6356 | ||
6357 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; | |
6358 | if (uj) { | |
6359 | json_object_string_add(json_vrf, "type", type); | |
6360 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
6361 | json_object_string_add(json_vrf, "routerId", | |
6362 | inet_ntoa(bgp->router_id)); | |
6363 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
6364 | peers_cfg); | |
6365 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
6366 | peers_estb); | |
6367 | ||
6368 | json_object_object_add(json_vrfs, name, json_vrf); | |
6369 | } else | |
6370 | vty_out(vty, "%4s %-5d %-16s %9u %10u %s\n", type, | |
6371 | vrf_id_ui, inet_ntoa(bgp->router_id), peers_cfg, | |
6372 | peers_estb, name); | |
6373 | } | |
6374 | ||
6375 | if (uj) { | |
6376 | json_object_object_add(json, "vrfs", json_vrfs); | |
6377 | ||
6378 | json_object_int_add(json, "totalVrfs", count); | |
6379 | ||
c14777c6 | 6380 | vty_out(vty, "%s\n", |
6381 | json_object_to_json_string_ext( | |
6382 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 6383 | json_object_free(json); |
6384 | } else { | |
6385 | if (count) | |
6386 | vty_out(vty, | |
6387 | "\nTotal number of VRFs (including default): %d\n", | |
6388 | count); | |
6389 | } | |
6390 | ||
6391 | return CMD_SUCCESS; | |
8386ac43 | 6392 | } |
6393 | ||
f412b39a | 6394 | DEFUN (show_bgp_memory, |
4bf6a362 | 6395 | show_bgp_memory_cmd, |
7fa12b13 | 6396 | "show [ip] bgp memory", |
4bf6a362 | 6397 | SHOW_STR |
3a2d747c | 6398 | IP_STR |
4bf6a362 PJ |
6399 | BGP_STR |
6400 | "Global BGP memory statistics\n") | |
6401 | { | |
d62a17ae | 6402 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
6403 | unsigned long count; | |
6404 | ||
6405 | /* RIB related usage stats */ | |
6406 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
6407 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
6408 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6409 | count * sizeof(struct bgp_node))); | |
6410 | ||
6411 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
6412 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
6413 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6414 | count * sizeof(struct bgp_info))); | |
6415 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) | |
6416 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
6417 | count, | |
6418 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6419 | count * sizeof(struct bgp_info_extra))); | |
6420 | ||
6421 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
6422 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
6423 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6424 | count * sizeof(struct bgp_static))); | |
6425 | ||
6426 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
6427 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
6428 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6429 | count * sizeof(struct bpacket))); | |
6430 | ||
6431 | /* Adj-In/Out */ | |
6432 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
6433 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
6434 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6435 | count * sizeof(struct bgp_adj_in))); | |
6436 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
6437 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
6438 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6439 | count * sizeof(struct bgp_adj_out))); | |
6440 | ||
6441 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
6442 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
6443 | count, | |
6444 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6445 | count * sizeof(struct bgp_nexthop_cache))); | |
6446 | ||
6447 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
6448 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
6449 | count, | |
6450 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6451 | count * sizeof(struct bgp_damp_info))); | |
6452 | ||
6453 | /* Attributes */ | |
6454 | count = attr_count(); | |
6455 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
6456 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6457 | count * sizeof(struct attr))); | |
6458 | ||
6459 | if ((count = attr_unknown_count())) | |
6460 | vty_out(vty, "%ld unknown attributes\n", count); | |
6461 | ||
6462 | /* AS_PATH attributes */ | |
6463 | count = aspath_count(); | |
6464 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
6465 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6466 | count * sizeof(struct aspath))); | |
6467 | ||
6468 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
6469 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
6470 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6471 | count * sizeof(struct assegment))); | |
6472 | ||
6473 | /* Other attributes */ | |
6474 | if ((count = community_count())) | |
6475 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
c14777c6 | 6476 | count, |
6477 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6478 | count * sizeof(struct community))); | |
d62a17ae | 6479 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
6480 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
c14777c6 | 6481 | count, |
6482 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6483 | count * sizeof(struct ecommunity))); | |
d62a17ae | 6484 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
6485 | vty_out(vty, | |
6486 | "%ld BGP large-community entries, using %s of memory\n", | |
c14777c6 | 6487 | count, |
6488 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6489 | count * sizeof(struct lcommunity))); | |
d62a17ae | 6490 | |
6491 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
6492 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
6493 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6494 | count * sizeof(struct cluster_list))); | |
6495 | ||
6496 | /* Peer related usage */ | |
6497 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
6498 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
6499 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6500 | count * sizeof(struct peer))); | |
6501 | ||
6502 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
6503 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
6504 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6505 | count * sizeof(struct peer_group))); | |
6506 | ||
6507 | /* Other */ | |
6508 | if ((count = mtype_stats_alloc(MTYPE_HASH))) | |
6509 | vty_out(vty, "%ld hash tables, using %s of memory\n", count, | |
6510 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6511 | count * sizeof(struct hash))); | |
6512 | if ((count = mtype_stats_alloc(MTYPE_HASH_BACKET))) | |
6513 | vty_out(vty, "%ld hash buckets, using %s of memory\n", count, | |
6514 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6515 | count * sizeof(struct hash_backet))); | |
6516 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) | |
6517 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
c14777c6 | 6518 | count, |
6519 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6520 | count * sizeof(regex_t))); | |
d62a17ae | 6521 | return CMD_SUCCESS; |
4bf6a362 | 6522 | } |
fee0f4c6 | 6523 | |
718e3744 | 6524 | /* Show BGP peer's summary information. */ |
d62a17ae | 6525 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
6526 | u_char use_json, json_object *json) | |
6527 | { | |
6528 | struct peer *peer; | |
6529 | struct listnode *node, *nnode; | |
6530 | unsigned int count = 0, dn_count = 0; | |
6531 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
6532 | char neighbor_buf[VTY_BUFSIZ]; | |
6533 | int neighbor_col_default_width = 16; | |
6534 | int len; | |
6535 | int max_neighbor_width = 0; | |
6536 | int pfx_rcd_safi; | |
6537 | json_object *json_peer = NULL; | |
6538 | json_object *json_peers = NULL; | |
6539 | ||
6540 | /* labeled-unicast routes are installed in the unicast table so in order | |
6541 | * to | |
6542 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
6543 | */ | |
6544 | if (safi == SAFI_LABELED_UNICAST) | |
6545 | pfx_rcd_safi = SAFI_UNICAST; | |
6546 | else | |
6547 | pfx_rcd_safi = safi; | |
6548 | ||
6549 | if (use_json) { | |
6550 | if (json == NULL) | |
6551 | json = json_object_new_object(); | |
6552 | ||
6553 | json_peers = json_object_new_object(); | |
6554 | } else { | |
6555 | /* Loop over all neighbors that will be displayed to determine | |
6556 | * how many | |
6557 | * characters are needed for the Neighbor column | |
6558 | */ | |
6559 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
6560 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6561 | continue; | |
6562 | ||
6563 | if (peer->afc[afi][safi]) { | |
6564 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
6565 | if (peer_dynamic_neighbor(peer)) | |
6566 | dn_flag[0] = '*'; | |
6567 | ||
6568 | if (peer->hostname | |
6569 | && bgp_flag_check(bgp, | |
6570 | BGP_FLAG_SHOW_HOSTNAME)) | |
6571 | sprintf(neighbor_buf, "%s%s(%s) ", | |
6572 | dn_flag, peer->hostname, | |
6573 | peer->host); | |
6574 | else | |
6575 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
6576 | peer->host); | |
6577 | ||
6578 | len = strlen(neighbor_buf); | |
6579 | ||
6580 | if (len > max_neighbor_width) | |
6581 | max_neighbor_width = len; | |
6582 | } | |
6583 | } | |
f933309e | 6584 | |
d62a17ae | 6585 | /* Originally we displayed the Neighbor column as 16 |
6586 | * characters wide so make that the default | |
6587 | */ | |
6588 | if (max_neighbor_width < neighbor_col_default_width) | |
6589 | max_neighbor_width = neighbor_col_default_width; | |
6590 | } | |
f933309e | 6591 | |
d62a17ae | 6592 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
6593 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6594 | continue; | |
6595 | ||
6596 | if (peer->afc[afi][safi]) { | |
6597 | if (!count) { | |
6598 | unsigned long ents; | |
6599 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
6600 | int vrf_id_ui; | |
6601 | ||
6602 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) | |
6603 | ? -1 | |
6604 | : bgp->vrf_id; | |
6605 | ||
6606 | /* Usage summary and header */ | |
6607 | if (use_json) { | |
6608 | json_object_string_add( | |
6609 | json, "routerId", | |
6610 | inet_ntoa(bgp->router_id)); | |
6611 | json_object_int_add(json, "as", | |
6612 | bgp->as); | |
6613 | json_object_int_add(json, "vrfId", | |
6614 | vrf_id_ui); | |
6615 | json_object_string_add( | |
6616 | json, "vrfName", | |
6617 | (bgp->inst_type | |
6618 | == BGP_INSTANCE_TYPE_DEFAULT) | |
6619 | ? "Default" | |
6620 | : bgp->name); | |
6621 | } else { | |
6622 | vty_out(vty, | |
6623 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
6624 | inet_ntoa(bgp->router_id), | |
6625 | bgp->as, vrf_id_ui); | |
6626 | vty_out(vty, "\n"); | |
6627 | } | |
6628 | ||
6629 | if (bgp_update_delay_configured(bgp)) { | |
6630 | if (use_json) { | |
6631 | json_object_int_add( | |
6632 | json, | |
6633 | "updateDelayLimit", | |
6634 | bgp->v_update_delay); | |
6635 | ||
6636 | if (bgp->v_update_delay | |
6637 | != bgp->v_establish_wait) | |
6638 | json_object_int_add( | |
6639 | json, | |
6640 | "updateDelayEstablishWait", | |
6641 | bgp->v_establish_wait); | |
6642 | ||
6643 | if (bgp_update_delay_active( | |
6644 | bgp)) { | |
6645 | json_object_string_add( | |
6646 | json, | |
6647 | "updateDelayFirstNeighbor", | |
6648 | bgp->update_delay_begin_time); | |
6649 | json_object_boolean_true_add( | |
6650 | json, | |
6651 | "updateDelayInProgress"); | |
6652 | } else { | |
6653 | if (bgp->update_delay_over) { | |
6654 | json_object_string_add( | |
6655 | json, | |
6656 | "updateDelayFirstNeighbor", | |
6657 | bgp->update_delay_begin_time); | |
6658 | json_object_string_add( | |
6659 | json, | |
6660 | "updateDelayBestpathResumed", | |
6661 | bgp->update_delay_end_time); | |
6662 | json_object_string_add( | |
6663 | json, | |
6664 | "updateDelayZebraUpdateResume", | |
6665 | bgp->update_delay_zebra_resume_time); | |
6666 | json_object_string_add( | |
6667 | json, | |
6668 | "updateDelayPeerUpdateResume", | |
6669 | bgp->update_delay_peers_resume_time); | |
6670 | } | |
6671 | } | |
6672 | } else { | |
6673 | vty_out(vty, | |
6674 | "Read-only mode update-delay limit: %d seconds\n", | |
6675 | bgp->v_update_delay); | |
6676 | if (bgp->v_update_delay | |
6677 | != bgp->v_establish_wait) | |
6678 | vty_out(vty, | |
6679 | " Establish wait: %d seconds\n", | |
6680 | bgp->v_establish_wait); | |
6681 | ||
6682 | if (bgp_update_delay_active( | |
6683 | bgp)) { | |
6684 | vty_out(vty, | |
6685 | " First neighbor established: %s\n", | |
6686 | bgp->update_delay_begin_time); | |
6687 | vty_out(vty, | |
6688 | " Delay in progress\n"); | |
6689 | } else { | |
6690 | if (bgp->update_delay_over) { | |
6691 | vty_out(vty, | |
6692 | " First neighbor established: %s\n", | |
6693 | bgp->update_delay_begin_time); | |
6694 | vty_out(vty, | |
6695 | " Best-paths resumed: %s\n", | |
6696 | bgp->update_delay_end_time); | |
6697 | vty_out(vty, | |
6698 | " zebra update resumed: %s\n", | |
6699 | bgp->update_delay_zebra_resume_time); | |
6700 | vty_out(vty, | |
6701 | " peers update resumed: %s\n", | |
6702 | bgp->update_delay_peers_resume_time); | |
6703 | } | |
6704 | } | |
6705 | } | |
6706 | } | |
6707 | ||
6708 | if (use_json) { | |
6709 | if (bgp_maxmed_onstartup_configured(bgp) | |
6710 | && bgp->maxmed_active) | |
6711 | json_object_boolean_true_add( | |
6712 | json, | |
6713 | "maxMedOnStartup"); | |
6714 | if (bgp->v_maxmed_admin) | |
6715 | json_object_boolean_true_add( | |
6716 | json, | |
6717 | "maxMedAdministrative"); | |
6718 | ||
6719 | json_object_int_add( | |
6720 | json, "tableVersion", | |
6721 | bgp_table_version( | |
6722 | bgp->rib[afi][safi])); | |
6723 | ||
6724 | ents = bgp_table_count( | |
6725 | bgp->rib[afi][safi]); | |
6726 | json_object_int_add(json, "ribCount", | |
6727 | ents); | |
6728 | json_object_int_add( | |
6729 | json, "ribMemory", | |
6730 | ents * sizeof(struct bgp_node)); | |
6731 | ||
6732 | ents = listcount(bgp->peer); | |
6733 | json_object_int_add(json, "peerCount", | |
6734 | ents); | |
6735 | json_object_int_add( | |
6736 | json, "peerMemory", | |
6737 | ents * sizeof(struct peer)); | |
6738 | ||
6739 | if ((ents = listcount(bgp->group))) { | |
6740 | json_object_int_add( | |
6741 | json, "peerGroupCount", | |
6742 | ents); | |
6743 | json_object_int_add( | |
6744 | json, "peerGroupMemory", | |
c14777c6 | 6745 | ents |
6746 | * sizeof(struct | |
6747 | peer_group)); | |
d62a17ae | 6748 | } |
6749 | ||
6750 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
6751 | BGP_CONFIG_DAMPENING)) | |
6752 | json_object_boolean_true_add( | |
6753 | json, | |
6754 | "dampeningEnabled"); | |
6755 | } else { | |
6756 | if (bgp_maxmed_onstartup_configured(bgp) | |
6757 | && bgp->maxmed_active) | |
6758 | vty_out(vty, | |
6759 | "Max-med on-startup active\n"); | |
6760 | if (bgp->v_maxmed_admin) | |
6761 | vty_out(vty, | |
6762 | "Max-med administrative active\n"); | |
6763 | ||
6764 | vty_out(vty, | |
6765 | "BGP table version %" PRIu64 | |
6766 | "\n", | |
6767 | bgp_table_version( | |
6768 | bgp->rib[afi][safi])); | |
6769 | ||
6770 | ents = bgp_table_count( | |
6771 | bgp->rib[afi][safi]); | |
6772 | vty_out(vty, | |
6773 | "RIB entries %ld, using %s of memory\n", | |
6774 | ents, | |
6775 | mtype_memstr( | |
6776 | memstrbuf, | |
6777 | sizeof(memstrbuf), | |
c14777c6 | 6778 | ents |
6779 | * sizeof(struct | |
6780 | bgp_node))); | |
d62a17ae | 6781 | |
6782 | /* Peer related usage */ | |
6783 | ents = listcount(bgp->peer); | |
6784 | vty_out(vty, | |
6785 | "Peers %ld, using %s of memory\n", | |
6786 | ents, | |
6787 | mtype_memstr( | |
6788 | memstrbuf, | |
6789 | sizeof(memstrbuf), | |
c14777c6 | 6790 | ents |
6791 | * sizeof(struct | |
6792 | peer))); | |
d62a17ae | 6793 | |
6794 | if ((ents = listcount(bgp->group))) | |
6795 | vty_out(vty, | |
6796 | "Peer groups %ld, using %s of memory\n", | |
6797 | ents, | |
6798 | mtype_memstr( | |
6799 | memstrbuf, | |
6800 | sizeof(memstrbuf), | |
c14777c6 | 6801 | ents |
6802 | * sizeof(struct | |
6803 | peer_group))); | |
d62a17ae | 6804 | |
6805 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
6806 | BGP_CONFIG_DAMPENING)) | |
6807 | vty_out(vty, | |
6808 | "Dampening enabled.\n"); | |
6809 | vty_out(vty, "\n"); | |
6810 | ||
6811 | /* Subtract 8 here because 'Neighbor' is | |
6812 | * 8 characters */ | |
6813 | vty_out(vty, "Neighbor"); | |
6814 | vty_out(vty, "%*s", | |
6815 | max_neighbor_width - 8, " "); | |
6816 | vty_out(vty, | |
6817 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); | |
6818 | } | |
6819 | } | |
6820 | ||
6821 | count++; | |
6822 | ||
6823 | if (use_json) { | |
6824 | json_peer = json_object_new_object(); | |
6825 | ||
6826 | if (peer_dynamic_neighbor(peer)) | |
6827 | json_object_boolean_true_add( | |
6828 | json_peer, "dynamicPeer"); | |
6829 | ||
6830 | if (peer->hostname) | |
6831 | json_object_string_add(json_peer, | |
6832 | "hostname", | |
6833 | peer->hostname); | |
6834 | ||
6835 | if (peer->domainname) | |
6836 | json_object_string_add( | |
6837 | json_peer, "domainname", | |
6838 | peer->domainname); | |
6839 | ||
6840 | json_object_int_add(json_peer, "remoteAs", | |
6841 | peer->as); | |
6842 | json_object_int_add(json_peer, "version", 4); | |
6843 | json_object_int_add( | |
6844 | json_peer, "msgRcvd", | |
6845 | peer->open_in + peer->update_in | |
6846 | + peer->keepalive_in | |
6847 | + peer->notify_in | |
6848 | + peer->refresh_in | |
6849 | + peer->dynamic_cap_in); | |
6850 | json_object_int_add( | |
6851 | json_peer, "msgSent", | |
6852 | peer->open_out + peer->update_out | |
6853 | + peer->keepalive_out | |
6854 | + peer->notify_out | |
6855 | + peer->refresh_out | |
6856 | + peer->dynamic_cap_out); | |
6857 | ||
6858 | json_object_int_add(json_peer, "tableVersion", | |
6859 | peer->version[afi][safi]); | |
6860 | json_object_int_add(json_peer, "outq", | |
6861 | peer->obuf->count); | |
6862 | json_object_int_add(json_peer, "inq", 0); | |
6863 | peer_uptime(peer->uptime, timebuf, | |
6864 | BGP_UPTIME_LEN, use_json, | |
6865 | json_peer); | |
6866 | json_object_int_add( | |
6867 | json_peer, "prefixReceivedCount", | |
6868 | peer->pcount[afi][pfx_rcd_safi]); | |
6869 | ||
6870 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
6871 | json_object_string_add(json_peer, | |
6872 | "state", | |
6873 | "Idle (Admin)"); | |
6874 | else if (CHECK_FLAG( | |
6875 | peer->sflags, | |
6876 | PEER_STATUS_PREFIX_OVERFLOW)) | |
6877 | json_object_string_add(json_peer, | |
6878 | "state", | |
6879 | "Idle (PfxCt)"); | |
6880 | else | |
6881 | json_object_string_add( | |
6882 | json_peer, "state", | |
6883 | lookup_msg(bgp_status_msg, | |
6884 | peer->status, NULL)); | |
6885 | ||
6886 | if (peer->conf_if) | |
6887 | json_object_string_add(json_peer, | |
6888 | "idType", | |
6889 | "interface"); | |
6890 | else if (peer->su.sa.sa_family == AF_INET) | |
6891 | json_object_string_add( | |
6892 | json_peer, "idType", "ipv4"); | |
6893 | else if (peer->su.sa.sa_family == AF_INET6) | |
6894 | json_object_string_add( | |
6895 | json_peer, "idType", "ipv6"); | |
6896 | ||
6897 | json_object_object_add(json_peers, peer->host, | |
6898 | json_peer); | |
6899 | } else { | |
6900 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
6901 | if (peer_dynamic_neighbor(peer)) { | |
6902 | dn_count++; | |
6903 | dn_flag[0] = '*'; | |
6904 | } | |
6905 | ||
6906 | if (peer->hostname | |
6907 | && bgp_flag_check(bgp, | |
6908 | BGP_FLAG_SHOW_HOSTNAME)) | |
6909 | len = vty_out(vty, "%s%s(%s)", dn_flag, | |
6910 | peer->hostname, | |
6911 | peer->host); | |
6912 | else | |
6913 | len = vty_out(vty, "%s%s", dn_flag, | |
6914 | peer->host); | |
6915 | ||
6916 | /* pad the neighbor column with spaces */ | |
6917 | if (len < max_neighbor_width) | |
6918 | vty_out(vty, "%*s", | |
6919 | max_neighbor_width - len, " "); | |
6920 | ||
c14777c6 | 6921 | vty_out(vty, |
6922 | "4 %10u %7d %7d %8" PRIu64 | |
6923 | " %4d %4zd %8s", | |
d62a17ae | 6924 | peer->as, |
6925 | peer->open_in + peer->update_in | |
6926 | + peer->keepalive_in | |
6927 | + peer->notify_in | |
6928 | + peer->refresh_in | |
6929 | + peer->dynamic_cap_in, | |
6930 | peer->open_out + peer->update_out | |
6931 | + peer->keepalive_out | |
6932 | + peer->notify_out | |
6933 | + peer->refresh_out | |
6934 | + peer->dynamic_cap_out, | |
6935 | peer->version[afi][safi], 0, | |
6936 | peer->obuf->count, | |
6937 | peer_uptime(peer->uptime, timebuf, | |
6938 | BGP_UPTIME_LEN, 0, NULL)); | |
6939 | ||
6940 | if (peer->status == Established) | |
6941 | vty_out(vty, " %12ld", | |
6942 | peer->pcount[afi] | |
6943 | [pfx_rcd_safi]); | |
6944 | else { | |
6945 | if (CHECK_FLAG(peer->flags, | |
6946 | PEER_FLAG_SHUTDOWN)) | |
6947 | vty_out(vty, " Idle (Admin)"); | |
6948 | else if ( | |
6949 | CHECK_FLAG( | |
6950 | peer->sflags, | |
6951 | PEER_STATUS_PREFIX_OVERFLOW)) | |
6952 | vty_out(vty, " Idle (PfxCt)"); | |
6953 | else | |
6954 | vty_out(vty, " %12s", | |
6955 | lookup_msg( | |
6956 | bgp_status_msg, | |
6957 | peer->status, | |
6958 | NULL)); | |
6959 | } | |
6960 | vty_out(vty, "\n"); | |
6961 | } | |
6962 | } | |
6963 | } | |
f933309e | 6964 | |
d62a17ae | 6965 | if (use_json) { |
6966 | json_object_object_add(json, "peers", json_peers); | |
6967 | ||
6968 | json_object_int_add(json, "totalPeers", count); | |
6969 | json_object_int_add(json, "dynamicPeers", dn_count); | |
6970 | ||
c14777c6 | 6971 | vty_out(vty, "%s\n", |
6972 | json_object_to_json_string_ext( | |
6973 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 6974 | json_object_free(json); |
6975 | } else { | |
6976 | if (count) | |
6977 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
6978 | else { | |
6979 | if (use_json) | |
6980 | vty_out(vty, | |
6981 | "{\"error\": {\"message\": \"No %s neighbor configured\"}}\n", | |
6982 | afi_safi_print(afi, safi)); | |
6983 | else | |
6984 | vty_out(vty, "No %s neighbor is configured\n", | |
6985 | afi_safi_print(afi, safi)); | |
6986 | } | |
b05a1c8b | 6987 | |
d62a17ae | 6988 | if (dn_count && !use_json) { |
6989 | vty_out(vty, "* - dynamic neighbor\n"); | |
6990 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
6991 | dn_count, bgp->dynamic_neighbors_limit); | |
6992 | } | |
6993 | } | |
1ff9a340 | 6994 | |
d62a17ae | 6995 | return CMD_SUCCESS; |
718e3744 | 6996 | } |
6997 | ||
798c3572 DS |
6998 | /* |
6999 | * Return if we have a peer configured to use this afi/safi | |
7000 | */ | |
d62a17ae | 7001 | static int bgp_show_summary_afi_safi_peer_exists(struct bgp *bgp, int afi, |
7002 | int safi) | |
7003 | { | |
7004 | struct listnode *node; | |
7005 | struct peer *peer; | |
7006 | ||
7007 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) { | |
7008 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7009 | continue; | |
7010 | ||
7011 | if (peer->afc[afi][safi]) | |
7012 | return 1; | |
7013 | } | |
7014 | ||
7015 | return 0; | |
7016 | } | |
7017 | ||
7018 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, | |
7019 | int safi, u_char use_json, | |
7020 | json_object *json) | |
7021 | { | |
7022 | int is_first = 1; | |
7023 | int afi_wildcard = (afi == AFI_MAX); | |
7024 | int safi_wildcard = (safi == SAFI_MAX); | |
7025 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
7026 | bool json_output = false; | |
7027 | ||
7028 | if (use_json && is_wildcard) | |
7029 | vty_out(vty, "{\n"); | |
7030 | if (afi_wildcard) | |
7031 | afi = 1; /* AFI_IP */ | |
7032 | while (afi < AFI_MAX) { | |
7033 | if (safi_wildcard) | |
7034 | safi = 1; /* SAFI_UNICAST */ | |
7035 | while (safi < SAFI_MAX) { | |
7036 | if (bgp_show_summary_afi_safi_peer_exists(bgp, afi, | |
7037 | safi)) { | |
7038 | json_output = true; | |
7039 | if (is_wildcard) { | |
7040 | /* | |
7041 | * So limit output to those afi/safi | |
7042 | * pairs that | |
7043 | * actualy have something interesting in | |
7044 | * them | |
7045 | */ | |
7046 | if (use_json) { | |
7047 | json = json_object_new_object(); | |
7048 | ||
7049 | if (!is_first) | |
7050 | vty_out(vty, ",\n"); | |
7051 | else | |
7052 | is_first = 0; | |
7053 | ||
7054 | vty_out(vty, "\"%s\":", | |
7055 | afi_safi_json(afi, | |
7056 | safi)); | |
7057 | } else { | |
7058 | vty_out(vty, "\n%s Summary:\n", | |
7059 | afi_safi_print(afi, | |
7060 | safi)); | |
7061 | } | |
7062 | } | |
7063 | bgp_show_summary(vty, bgp, afi, safi, use_json, | |
7064 | json); | |
7065 | } | |
7066 | safi++; | |
7067 | if (safi == SAFI_RESERVED_4 | |
c14777c6 | 7068 | || safi == SAFI_RESERVED_5) /* handle special |
7069 | cases to match | |
7070 | zebra.h */ | |
d62a17ae | 7071 | safi++; |
7072 | if (!safi_wildcard) | |
7073 | safi = SAFI_MAX; | |
7074 | } | |
7075 | afi++; | |
7076 | if (!afi_wildcard | |
7077 | || afi == AFI_L2VPN) /* special case, not handled yet */ | |
7078 | afi = AFI_MAX; | |
7079 | } | |
7080 | ||
7081 | if (use_json && is_wildcard) | |
7082 | vty_out(vty, "}\n"); | |
7083 | else if (use_json && !json_output) | |
7084 | vty_out(vty, "{}\n"); | |
7085 | } | |
7086 | ||
7087 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
7088 | safi_t safi, u_char use_json) | |
7089 | { | |
7090 | struct listnode *node, *nnode; | |
7091 | struct bgp *bgp; | |
7092 | json_object *json = NULL; | |
7093 | int is_first = 1; | |
7094 | ||
7095 | if (use_json) | |
7096 | vty_out(vty, "{\n"); | |
7097 | ||
7098 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
7099 | if (use_json) { | |
7100 | json = json_object_new_object(); | |
7101 | ||
7102 | if (!is_first) | |
7103 | vty_out(vty, ",\n"); | |
7104 | else | |
7105 | is_first = 0; | |
7106 | ||
7107 | vty_out(vty, "\"%s\":", | |
7108 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7109 | ? "Default" | |
7110 | : bgp->name); | |
7111 | } else { | |
7112 | vty_out(vty, "\nInstance %s:\n", | |
7113 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7114 | ? "Default" | |
7115 | : bgp->name); | |
7116 | } | |
7117 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, json); | |
7118 | } | |
7119 | ||
7120 | if (use_json) | |
7121 | vty_out(vty, "}\n"); | |
7122 | } | |
7123 | ||
7124 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
7125 | safi_t safi, u_char use_json) | |
7126 | { | |
7127 | struct bgp *bgp; | |
7128 | ||
7129 | if (name) { | |
7130 | if (strmatch(name, "all")) { | |
7131 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
7132 | use_json); | |
7133 | return CMD_SUCCESS; | |
7134 | } else { | |
7135 | bgp = bgp_lookup_by_name(name); | |
7136 | ||
7137 | if (!bgp) { | |
7138 | if (use_json) | |
7139 | vty_out(vty, "{}\n"); | |
7140 | else | |
7141 | vty_out(vty, | |
7142 | "%% No such BGP instance exist\n"); | |
7143 | return CMD_WARNING; | |
7144 | } | |
7145 | ||
7146 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, | |
7147 | NULL); | |
7148 | return CMD_SUCCESS; | |
7149 | } | |
7150 | } | |
7151 | ||
7152 | bgp = bgp_get_default(); | |
7153 | ||
7154 | if (bgp) | |
7155 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, NULL); | |
7156 | ||
7157 | return CMD_SUCCESS; | |
4fb25c53 DW |
7158 | } |
7159 | ||
716b2d8a | 7160 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 7161 | DEFUN (show_ip_bgp_summary, |
718e3744 | 7162 | show_ip_bgp_summary_cmd, |
dd6bd0f1 | 7163 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [json]", |
718e3744 | 7164 | SHOW_STR |
7165 | IP_STR | |
7166 | BGP_STR | |
8386ac43 | 7167 | BGP_INSTANCE_HELP_STR |
46f296b4 | 7168 | BGP_AFI_HELP_STR |
dd6bd0f1 | 7169 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 7170 | "Summary of BGP neighbor status\n" |
9973d184 | 7171 | JSON_STR) |
718e3744 | 7172 | { |
d62a17ae | 7173 | char *vrf = NULL; |
7174 | afi_t afi = AFI_MAX; | |
7175 | safi_t safi = SAFI_MAX; | |
7176 | ||
7177 | int idx = 0; | |
7178 | ||
7179 | /* show [ip] bgp */ | |
7180 | if (argv_find(argv, argc, "ip", &idx)) | |
7181 | afi = AFI_IP; | |
7182 | /* [<view|vrf> VIEWVRFNAME] */ | |
7183 | if (argv_find(argv, argc, "view", &idx) | |
7184 | || argv_find(argv, argc, "vrf", &idx)) | |
7185 | vrf = argv[++idx]->arg; | |
7186 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
7187 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
7188 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
7189 | } | |
7190 | ||
7191 | int uj = use_json(argc, argv); | |
7192 | ||
7193 | return bgp_show_summary_vty(vty, vrf, afi, safi, uj); | |
7194 | } | |
7195 | ||
7196 | const char *afi_safi_print(afi_t afi, safi_t safi) | |
7197 | { | |
7198 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
7199 | return "IPv4 Unicast"; | |
7200 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
7201 | return "IPv4 Multicast"; | |
7202 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
7203 | return "IPv4 Labeled Unicast"; | |
7204 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
7205 | return "IPv4 VPN"; | |
7206 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
7207 | return "IPv4 Encap"; | |
7208 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
7209 | return "IPv6 Unicast"; | |
7210 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
7211 | return "IPv6 Multicast"; | |
7212 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
7213 | return "IPv6 Labeled Unicast"; | |
7214 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
7215 | return "IPv6 VPN"; | |
7216 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
7217 | return "IPv6 Encap"; | |
7218 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
7219 | return "L2VPN EVPN"; | |
7220 | else | |
7221 | return "Unknown"; | |
538621f2 | 7222 | } |
7223 | ||
b9f77ec8 DS |
7224 | /* |
7225 | * Please note that we have intentionally camelCased | |
7226 | * the return strings here. So if you want | |
7227 | * to use this function, please ensure you | |
7228 | * are doing this within json output | |
7229 | */ | |
d62a17ae | 7230 | const char *afi_safi_json(afi_t afi, safi_t safi) |
7231 | { | |
7232 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
7233 | return "ipv4Unicast"; | |
7234 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
7235 | return "ipv4Multicast"; | |
7236 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
7237 | return "ipv4LabeledUnicast"; | |
7238 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
7239 | return "ipv4Vpn"; | |
7240 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
7241 | return "ipv4Encap"; | |
7242 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
7243 | return "ipv6Unicast"; | |
7244 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
7245 | return "ipv6Multicast"; | |
7246 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
7247 | return "ipv6LabeledUnicast"; | |
7248 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
7249 | return "ipv6Vpn"; | |
7250 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
7251 | return "ipv6Encap"; | |
7252 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
7253 | return "l2VpnEvpn"; | |
7254 | else | |
7255 | return "Unknown"; | |
27162734 LB |
7256 | } |
7257 | ||
718e3744 | 7258 | /* Show BGP peer's information. */ |
d62a17ae | 7259 | enum show_type { show_all, show_peer }; |
7260 | ||
7261 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
7262 | afi_t afi, safi_t safi, | |
7263 | u_int16_t adv_smcap, u_int16_t adv_rmcap, | |
7264 | u_int16_t rcv_smcap, u_int16_t rcv_rmcap, | |
7265 | u_char use_json, json_object *json_pref) | |
7266 | { | |
7267 | /* Send-Mode */ | |
7268 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
7269 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
7270 | if (use_json) { | |
7271 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
7272 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
7273 | json_object_string_add(json_pref, "sendMode", | |
7274 | "advertisedAndReceived"); | |
7275 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
7276 | json_object_string_add(json_pref, "sendMode", | |
7277 | "advertised"); | |
7278 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
7279 | json_object_string_add(json_pref, "sendMode", | |
7280 | "received"); | |
7281 | } else { | |
7282 | vty_out(vty, " Send-mode: "); | |
7283 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
7284 | vty_out(vty, "advertised"); | |
7285 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
7286 | vty_out(vty, "%sreceived", | |
7287 | CHECK_FLAG(p->af_cap[afi][safi], | |
7288 | adv_smcap) | |
7289 | ? ", " | |
7290 | : ""); | |
7291 | vty_out(vty, "\n"); | |
7292 | } | |
7293 | } | |
7294 | ||
7295 | /* Receive-Mode */ | |
7296 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
7297 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
7298 | if (use_json) { | |
7299 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
7300 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
7301 | json_object_string_add(json_pref, "recvMode", | |
7302 | "advertisedAndReceived"); | |
7303 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
7304 | json_object_string_add(json_pref, "recvMode", | |
7305 | "advertised"); | |
7306 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
7307 | json_object_string_add(json_pref, "recvMode", | |
7308 | "received"); | |
7309 | } else { | |
7310 | vty_out(vty, " Receive-mode: "); | |
7311 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
7312 | vty_out(vty, "advertised"); | |
7313 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
7314 | vty_out(vty, "%sreceived", | |
7315 | CHECK_FLAG(p->af_cap[afi][safi], | |
7316 | adv_rmcap) | |
7317 | ? ", " | |
7318 | : ""); | |
7319 | vty_out(vty, "\n"); | |
7320 | } | |
7321 | } | |
7322 | } | |
7323 | ||
7324 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, | |
7325 | safi_t safi, u_char use_json, | |
7326 | json_object *json_neigh) | |
7327 | { | |
7328 | struct bgp_filter *filter; | |
7329 | struct peer_af *paf; | |
7330 | char orf_pfx_name[BUFSIZ]; | |
7331 | int orf_pfx_count; | |
7332 | json_object *json_af = NULL; | |
7333 | json_object *json_prefA = NULL; | |
7334 | json_object *json_prefB = NULL; | |
7335 | json_object *json_addr = NULL; | |
7336 | ||
7337 | if (use_json) { | |
7338 | json_addr = json_object_new_object(); | |
7339 | json_af = json_object_new_object(); | |
7340 | filter = &p->filter[afi][safi]; | |
7341 | ||
7342 | if (peer_group_active(p)) | |
7343 | json_object_string_add(json_addr, "peerGroupMember", | |
7344 | p->group->name); | |
7345 | ||
7346 | paf = peer_af_find(p, afi, safi); | |
7347 | if (paf && PAF_SUBGRP(paf)) { | |
7348 | json_object_int_add(json_addr, "updateGroupId", | |
7349 | PAF_UPDGRP(paf)->id); | |
7350 | json_object_int_add(json_addr, "subGroupId", | |
7351 | PAF_SUBGRP(paf)->id); | |
7352 | json_object_int_add(json_addr, "packetQueueLength", | |
7353 | bpacket_queue_virtual_length(paf)); | |
7354 | } | |
7355 | ||
7356 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7357 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7358 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7359 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7360 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7361 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7362 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
7363 | json_object_int_add(json_af, "orfType", | |
7364 | ORF_TYPE_PREFIX); | |
7365 | json_prefA = json_object_new_object(); | |
7366 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
7367 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7368 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7369 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7370 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
7371 | use_json, json_prefA); | |
7372 | json_object_object_add(json_af, "orfPrefixList", | |
7373 | json_prefA); | |
7374 | } | |
7375 | ||
7376 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7377 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7378 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7379 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7380 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7381 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7382 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
7383 | json_object_int_add(json_af, "orfOldType", | |
7384 | ORF_TYPE_PREFIX_OLD); | |
7385 | json_prefB = json_object_new_object(); | |
7386 | bgp_show_peer_afi_orf_cap( | |
7387 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
7388 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7389 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7390 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
7391 | json_prefB); | |
7392 | json_object_object_add(json_af, "orfOldPrefixList", | |
7393 | json_prefB); | |
7394 | } | |
7395 | ||
7396 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7397 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7398 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7399 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7400 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7401 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7402 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7403 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7404 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
7405 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7406 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7407 | json_object_object_add(json_addr, "afDependentCap", | |
7408 | json_af); | |
7409 | else | |
7410 | json_object_free(json_af); | |
7411 | ||
7412 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
7413 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
7414 | NULL, afi, orf_pfx_name, use_json); | |
7415 | ||
7416 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7417 | PEER_STATUS_ORF_PREFIX_SEND) | |
7418 | || orf_pfx_count) { | |
7419 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7420 | PEER_STATUS_ORF_PREFIX_SEND)) | |
7421 | json_object_boolean_true_add(json_neigh, | |
7422 | "orfSent"); | |
7423 | if (orf_pfx_count) | |
7424 | json_object_int_add(json_addr, "orfRecvCounter", | |
7425 | orf_pfx_count); | |
7426 | } | |
7427 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7428 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
7429 | json_object_string_add( | |
7430 | json_addr, "orfFirstUpdate", | |
7431 | "deferredUntilORFOrRouteRefreshRecvd"); | |
7432 | ||
7433 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7434 | PEER_FLAG_REFLECTOR_CLIENT)) | |
7435 | json_object_boolean_true_add(json_addr, | |
7436 | "routeReflectorClient"); | |
7437 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7438 | PEER_FLAG_RSERVER_CLIENT)) | |
7439 | json_object_boolean_true_add(json_addr, | |
7440 | "routeServerClient"); | |
7441 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7442 | json_object_boolean_true_add(json_addr, | |
7443 | "inboundSoftConfigPermit"); | |
7444 | ||
7445 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7446 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
7447 | json_object_boolean_true_add( | |
7448 | json_addr, | |
7449 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
7450 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7451 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
7452 | json_object_boolean_true_add( | |
7453 | json_addr, | |
7454 | "privateAsNumsReplacedInUpdatesToNbr"); | |
7455 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7456 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
7457 | json_object_boolean_true_add( | |
7458 | json_addr, | |
7459 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
7460 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7461 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
7462 | json_object_boolean_true_add( | |
7463 | json_addr, | |
7464 | "privateAsNumsRemovedInUpdatesToNbr"); | |
7465 | ||
7466 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7467 | PEER_FLAG_ADDPATH_TX_ALL_PATHS)) | |
7468 | json_object_boolean_true_add(json_addr, | |
7469 | "addpathTxAllPaths"); | |
7470 | ||
7471 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7472 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
7473 | json_object_boolean_true_add(json_addr, | |
7474 | "addpathTxBestpathPerAS"); | |
7475 | ||
7476 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
7477 | json_object_string_add(json_addr, | |
7478 | "overrideASNsInOutboundUpdates", | |
7479 | "ifAspathEqualRemoteAs"); | |
7480 | ||
7481 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
7482 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7483 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7484 | json_object_boolean_true_add(json_addr, | |
7485 | "routerAlwaysNextHop"); | |
7486 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7487 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
7488 | json_object_boolean_true_add( | |
7489 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
7490 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7491 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7492 | json_object_boolean_true_add( | |
7493 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
7494 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7495 | json_object_boolean_true_add( | |
7496 | json_addr, "unchangedMedPropogatedToNbr"); | |
7497 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7498 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7499 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
7500 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7501 | PEER_FLAG_SEND_COMMUNITY) | |
7502 | && CHECK_FLAG(p->af_flags[afi][safi], | |
7503 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7504 | json_object_string_add(json_addr, | |
7505 | "commAttriSentToNbr", | |
7506 | "extendedAndStandard"); | |
7507 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7508 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7509 | json_object_string_add(json_addr, | |
7510 | "commAttriSentToNbr", | |
7511 | "extended"); | |
7512 | else | |
7513 | json_object_string_add(json_addr, | |
7514 | "commAttriSentToNbr", | |
7515 | "standard"); | |
7516 | } | |
7517 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7518 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
7519 | if (p->default_rmap[afi][safi].name) | |
7520 | json_object_string_add( | |
7521 | json_addr, "defaultRouteMap", | |
7522 | p->default_rmap[afi][safi].name); | |
7523 | ||
7524 | if (paf && PAF_SUBGRP(paf) | |
7525 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
7526 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7527 | json_object_boolean_true_add(json_addr, | |
7528 | "defaultSent"); | |
7529 | else | |
7530 | json_object_boolean_true_add(json_addr, | |
7531 | "defaultNotSent"); | |
7532 | } | |
7533 | ||
7534 | if (filter->plist[FILTER_IN].name | |
7535 | || filter->dlist[FILTER_IN].name | |
7536 | || filter->aslist[FILTER_IN].name | |
7537 | || filter->map[RMAP_IN].name) | |
7538 | json_object_boolean_true_add(json_addr, | |
7539 | "inboundPathPolicyConfig"); | |
7540 | if (filter->plist[FILTER_OUT].name | |
7541 | || filter->dlist[FILTER_OUT].name | |
7542 | || filter->aslist[FILTER_OUT].name | |
7543 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
7544 | json_object_boolean_true_add( | |
7545 | json_addr, "outboundPathPolicyConfig"); | |
7546 | ||
7547 | /* prefix-list */ | |
7548 | if (filter->plist[FILTER_IN].name) | |
7549 | json_object_string_add(json_addr, | |
7550 | "incomingUpdatePrefixFilterList", | |
7551 | filter->plist[FILTER_IN].name); | |
7552 | if (filter->plist[FILTER_OUT].name) | |
7553 | json_object_string_add(json_addr, | |
7554 | "outgoingUpdatePrefixFilterList", | |
7555 | filter->plist[FILTER_OUT].name); | |
7556 | ||
7557 | /* distribute-list */ | |
7558 | if (filter->dlist[FILTER_IN].name) | |
7559 | json_object_string_add( | |
7560 | json_addr, "incomingUpdateNetworkFilterList", | |
7561 | filter->dlist[FILTER_IN].name); | |
7562 | if (filter->dlist[FILTER_OUT].name) | |
7563 | json_object_string_add( | |
7564 | json_addr, "outgoingUpdateNetworkFilterList", | |
7565 | filter->dlist[FILTER_OUT].name); | |
7566 | ||
7567 | /* filter-list. */ | |
7568 | if (filter->aslist[FILTER_IN].name) | |
7569 | json_object_string_add(json_addr, | |
7570 | "incomingUpdateAsPathFilterList", | |
7571 | filter->aslist[FILTER_IN].name); | |
7572 | if (filter->aslist[FILTER_OUT].name) | |
7573 | json_object_string_add(json_addr, | |
7574 | "outgoingUpdateAsPathFilterList", | |
7575 | filter->aslist[FILTER_OUT].name); | |
7576 | ||
7577 | /* route-map. */ | |
7578 | if (filter->map[RMAP_IN].name) | |
7579 | json_object_string_add( | |
7580 | json_addr, "routeMapForIncomingAdvertisements", | |
7581 | filter->map[RMAP_IN].name); | |
7582 | if (filter->map[RMAP_OUT].name) | |
7583 | json_object_string_add( | |
7584 | json_addr, "routeMapForOutgoingAdvertisements", | |
7585 | filter->map[RMAP_OUT].name); | |
7586 | ||
7587 | /* unsuppress-map */ | |
7588 | if (filter->usmap.name) | |
7589 | json_object_string_add(json_addr, | |
7590 | "selectiveUnsuppressRouteMap", | |
7591 | filter->usmap.name); | |
7592 | ||
7593 | /* Receive prefix count */ | |
7594 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
7595 | p->pcount[afi][safi]); | |
7596 | ||
7597 | /* Maximum prefix */ | |
7598 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
7599 | json_object_int_add(json_addr, "prefixAllowedMax", | |
7600 | p->pmax[afi][safi]); | |
7601 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7602 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
7603 | json_object_boolean_true_add( | |
7604 | json_addr, "prefixAllowedMaxWarning"); | |
7605 | json_object_int_add(json_addr, | |
7606 | "prefixAllowedWarningThresh", | |
7607 | p->pmax_threshold[afi][safi]); | |
7608 | if (p->pmax_restart[afi][safi]) | |
7609 | json_object_int_add( | |
7610 | json_addr, | |
7611 | "prefixAllowedRestartIntervalMsecs", | |
7612 | p->pmax_restart[afi][safi] * 60000); | |
7613 | } | |
7614 | json_object_object_add(json_neigh, afi_safi_print(afi, safi), | |
7615 | json_addr); | |
7616 | ||
7617 | } else { | |
7618 | filter = &p->filter[afi][safi]; | |
7619 | ||
7620 | vty_out(vty, " For address family: %s\n", | |
7621 | afi_safi_print(afi, safi)); | |
7622 | ||
7623 | if (peer_group_active(p)) | |
7624 | vty_out(vty, " %s peer-group member\n", | |
7625 | p->group->name); | |
7626 | ||
7627 | paf = peer_af_find(p, afi, safi); | |
7628 | if (paf && PAF_SUBGRP(paf)) { | |
c14777c6 | 7629 | vty_out(vty, |
7630 | " Update group %" PRIu64 ", subgroup %" PRIu64 | |
7631 | "\n", | |
d62a17ae | 7632 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
7633 | vty_out(vty, " Packet Queue length %d\n", | |
7634 | bpacket_queue_virtual_length(paf)); | |
7635 | } else { | |
7636 | vty_out(vty, " Not part of any update group\n"); | |
7637 | } | |
7638 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7639 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7640 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7641 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7642 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7643 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7644 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7645 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7646 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
7647 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7648 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7649 | vty_out(vty, " AF-dependant capabilities:\n"); | |
7650 | ||
7651 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7652 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7653 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7654 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7655 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7656 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7657 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
7658 | vty_out(vty, | |
7659 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
7660 | ORF_TYPE_PREFIX); | |
7661 | bgp_show_peer_afi_orf_cap( | |
7662 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
7663 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7664 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7665 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
7666 | } | |
7667 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7668 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7669 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7670 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7671 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7672 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7673 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
7674 | vty_out(vty, | |
7675 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
7676 | ORF_TYPE_PREFIX_OLD); | |
7677 | bgp_show_peer_afi_orf_cap( | |
7678 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
7679 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7680 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7681 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
7682 | } | |
7683 | ||
7684 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
7685 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
7686 | NULL, afi, orf_pfx_name, use_json); | |
7687 | ||
7688 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7689 | PEER_STATUS_ORF_PREFIX_SEND) | |
7690 | || orf_pfx_count) { | |
7691 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
7692 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7693 | PEER_STATUS_ORF_PREFIX_SEND)) | |
7694 | vty_out(vty, " sent;"); | |
7695 | if (orf_pfx_count) | |
7696 | vty_out(vty, " received (%d entries)", | |
7697 | orf_pfx_count); | |
7698 | vty_out(vty, "\n"); | |
7699 | } | |
7700 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7701 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
7702 | vty_out(vty, | |
7703 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
7704 | ||
7705 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7706 | PEER_FLAG_REFLECTOR_CLIENT)) | |
7707 | vty_out(vty, " Route-Reflector Client\n"); | |
7708 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7709 | PEER_FLAG_RSERVER_CLIENT)) | |
7710 | vty_out(vty, " Route-Server Client\n"); | |
7711 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7712 | vty_out(vty, | |
7713 | " Inbound soft reconfiguration allowed\n"); | |
7714 | ||
7715 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7716 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
7717 | vty_out(vty, | |
7718 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
7719 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7720 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
7721 | vty_out(vty, | |
7722 | " Private AS numbers replaced in updates to this neighbor\n"); | |
7723 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7724 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
7725 | vty_out(vty, | |
7726 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
7727 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7728 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
7729 | vty_out(vty, | |
7730 | " Private AS numbers removed in updates to this neighbor\n"); | |
7731 | ||
7732 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7733 | PEER_FLAG_ADDPATH_TX_ALL_PATHS)) | |
7734 | vty_out(vty, " Advertise all paths via addpath\n"); | |
7735 | ||
7736 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7737 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
7738 | vty_out(vty, | |
7739 | " Advertise bestpath per AS via addpath\n"); | |
7740 | ||
7741 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
7742 | vty_out(vty, | |
7743 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
7744 | ||
7745 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
7746 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7747 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7748 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
7749 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7750 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
7751 | vty_out(vty, | |
7752 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
7753 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7754 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7755 | vty_out(vty, | |
7756 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
7757 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7758 | vty_out(vty, | |
7759 | " MED is propagated unchanged to this neighbor\n"); | |
7760 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7761 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7762 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
7763 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7764 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
7765 | vty_out(vty, | |
7766 | " Community attribute sent to this neighbor"); | |
7767 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7768 | PEER_FLAG_SEND_COMMUNITY) | |
7769 | && CHECK_FLAG(p->af_flags[afi][safi], | |
7770 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
7771 | && CHECK_FLAG(p->af_flags[afi][safi], | |
7772 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7773 | vty_out(vty, "(all)\n"); | |
7774 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7775 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7776 | vty_out(vty, "(large)\n"); | |
7777 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7778 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7779 | vty_out(vty, "(extended)\n"); | |
7780 | else | |
7781 | vty_out(vty, "(standard)\n"); | |
7782 | } | |
7783 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7784 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
7785 | vty_out(vty, " Default information originate,"); | |
7786 | ||
7787 | if (p->default_rmap[afi][safi].name) | |
7788 | vty_out(vty, " default route-map %s%s,", | |
7789 | p->default_rmap[afi][safi].map ? "*" | |
7790 | : "", | |
7791 | p->default_rmap[afi][safi].name); | |
7792 | if (paf && PAF_SUBGRP(paf) | |
7793 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
7794 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7795 | vty_out(vty, " default sent\n"); | |
7796 | else | |
7797 | vty_out(vty, " default not sent\n"); | |
7798 | } | |
7799 | ||
7800 | if (filter->plist[FILTER_IN].name | |
7801 | || filter->dlist[FILTER_IN].name | |
7802 | || filter->aslist[FILTER_IN].name | |
7803 | || filter->map[RMAP_IN].name) | |
7804 | vty_out(vty, " Inbound path policy configured\n"); | |
7805 | if (filter->plist[FILTER_OUT].name | |
7806 | || filter->dlist[FILTER_OUT].name | |
7807 | || filter->aslist[FILTER_OUT].name | |
7808 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
7809 | vty_out(vty, " Outbound path policy configured\n"); | |
7810 | ||
7811 | /* prefix-list */ | |
7812 | if (filter->plist[FILTER_IN].name) | |
7813 | vty_out(vty, | |
7814 | " Incoming update prefix filter list is %s%s\n", | |
7815 | filter->plist[FILTER_IN].plist ? "*" : "", | |
7816 | filter->plist[FILTER_IN].name); | |
7817 | if (filter->plist[FILTER_OUT].name) | |
7818 | vty_out(vty, | |
7819 | " Outgoing update prefix filter list is %s%s\n", | |
7820 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
7821 | filter->plist[FILTER_OUT].name); | |
7822 | ||
7823 | /* distribute-list */ | |
7824 | if (filter->dlist[FILTER_IN].name) | |
7825 | vty_out(vty, | |
7826 | " Incoming update network filter list is %s%s\n", | |
7827 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
7828 | filter->dlist[FILTER_IN].name); | |
7829 | if (filter->dlist[FILTER_OUT].name) | |
7830 | vty_out(vty, | |
7831 | " Outgoing update network filter list is %s%s\n", | |
7832 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
7833 | filter->dlist[FILTER_OUT].name); | |
7834 | ||
7835 | /* filter-list. */ | |
7836 | if (filter->aslist[FILTER_IN].name) | |
7837 | vty_out(vty, | |
7838 | " Incoming update AS path filter list is %s%s\n", | |
7839 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
7840 | filter->aslist[FILTER_IN].name); | |
7841 | if (filter->aslist[FILTER_OUT].name) | |
7842 | vty_out(vty, | |
7843 | " Outgoing update AS path filter list is %s%s\n", | |
7844 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
7845 | filter->aslist[FILTER_OUT].name); | |
7846 | ||
7847 | /* route-map. */ | |
7848 | if (filter->map[RMAP_IN].name) | |
7849 | vty_out(vty, | |
7850 | " Route map for incoming advertisements is %s%s\n", | |
7851 | filter->map[RMAP_IN].map ? "*" : "", | |
7852 | filter->map[RMAP_IN].name); | |
7853 | if (filter->map[RMAP_OUT].name) | |
7854 | vty_out(vty, | |
7855 | " Route map for outgoing advertisements is %s%s\n", | |
7856 | filter->map[RMAP_OUT].map ? "*" : "", | |
7857 | filter->map[RMAP_OUT].name); | |
7858 | ||
7859 | /* unsuppress-map */ | |
7860 | if (filter->usmap.name) | |
7861 | vty_out(vty, | |
7862 | " Route map for selective unsuppress is %s%s\n", | |
7863 | filter->usmap.map ? "*" : "", | |
7864 | filter->usmap.name); | |
7865 | ||
7866 | /* Receive prefix count */ | |
7867 | vty_out(vty, " %ld accepted prefixes\n", p->pcount[afi][safi]); | |
7868 | ||
7869 | /* Maximum prefix */ | |
7870 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
7871 | vty_out(vty, " Maximum prefixes allowed %ld%s\n", | |
7872 | p->pmax[afi][safi], | |
7873 | CHECK_FLAG(p->af_flags[afi][safi], | |
7874 | PEER_FLAG_MAX_PREFIX_WARNING) | |
7875 | ? " (warning-only)" | |
7876 | : ""); | |
7877 | vty_out(vty, " Threshold for warning message %d%%", | |
7878 | p->pmax_threshold[afi][safi]); | |
7879 | if (p->pmax_restart[afi][safi]) | |
7880 | vty_out(vty, ", restart interval %d min", | |
7881 | p->pmax_restart[afi][safi]); | |
7882 | vty_out(vty, "\n"); | |
7883 | } | |
7884 | ||
7885 | vty_out(vty, "\n"); | |
7886 | } | |
7887 | } | |
7888 | ||
7889 | static void bgp_show_peer(struct vty *vty, struct peer *p, u_char use_json, | |
7890 | json_object *json) | |
718e3744 | 7891 | { |
d62a17ae | 7892 | struct bgp *bgp; |
7893 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
7894 | char timebuf[BGP_UPTIME_LEN]; | |
7895 | char dn_flag[2]; | |
7896 | const char *subcode_str; | |
7897 | const char *code_str; | |
7898 | afi_t afi; | |
7899 | safi_t safi; | |
7900 | u_int16_t i; | |
7901 | u_char *msg; | |
7902 | json_object *json_neigh = NULL; | |
7903 | time_t epoch_tbuf; | |
718e3744 | 7904 | |
d62a17ae | 7905 | bgp = p->bgp; |
7906 | ||
7907 | if (use_json) | |
7908 | json_neigh = json_object_new_object(); | |
7909 | ||
7910 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7911 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
7912 | dn_flag[0] = '*'; | |
7913 | ||
7914 | if (!use_json) { | |
7915 | if (p->conf_if) /* Configured interface name. */ | |
7916 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
7917 | BGP_PEER_SU_UNSPEC(p) | |
7918 | ? "None" | |
7919 | : sockunion2str(&p->su, buf, | |
7920 | SU_ADDRSTRLEN)); | |
7921 | else /* Configured IP address. */ | |
7922 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
7923 | p->host); | |
7924 | } | |
7925 | ||
7926 | if (use_json) { | |
7927 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
7928 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
7929 | "none"); | |
7930 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
7931 | json_object_string_add( | |
7932 | json_neigh, "bgpNeighborAddr", | |
7933 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
7934 | ||
7935 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
7936 | ||
7937 | if (p->change_local_as) | |
7938 | json_object_int_add(json_neigh, "localAs", | |
7939 | p->change_local_as); | |
7940 | else | |
7941 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
7942 | ||
7943 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
7944 | json_object_boolean_true_add(json_neigh, | |
7945 | "localAsNoPrepend"); | |
7946 | ||
7947 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
7948 | json_object_boolean_true_add(json_neigh, | |
7949 | "localAsReplaceAs"); | |
7950 | } else { | |
7951 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
7952 | || (p->as_type == AS_INTERNAL)) | |
7953 | vty_out(vty, "remote AS %u, ", p->as); | |
7954 | else | |
7955 | vty_out(vty, "remote AS Unspecified, "); | |
7956 | vty_out(vty, "local AS %u%s%s, ", | |
7957 | p->change_local_as ? p->change_local_as : p->local_as, | |
7958 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
7959 | ? " no-prepend" | |
7960 | : "", | |
7961 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
7962 | ? " replace-as" | |
7963 | : ""); | |
7964 | } | |
7965 | /* peer type internal, external, confed-internal or confed-external */ | |
7966 | if (p->as == p->local_as) { | |
7967 | if (use_json) { | |
7968 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7969 | json_object_boolean_true_add( | |
7970 | json_neigh, "nbrConfedInternalLink"); | |
7971 | else | |
7972 | json_object_boolean_true_add(json_neigh, | |
7973 | "nbrInternalLink"); | |
7974 | } else { | |
7975 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7976 | vty_out(vty, "confed-internal link\n"); | |
7977 | else | |
7978 | vty_out(vty, "internal link\n"); | |
7979 | } | |
7980 | } else { | |
7981 | if (use_json) { | |
7982 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
7983 | json_object_boolean_true_add( | |
7984 | json_neigh, "nbrConfedExternalLink"); | |
7985 | else | |
7986 | json_object_boolean_true_add(json_neigh, | |
7987 | "nbrExternalLink"); | |
7988 | } else { | |
7989 | if (bgp_confederation_peers_check(bgp, p->as)) | |
7990 | vty_out(vty, "confed-external link\n"); | |
7991 | else | |
7992 | vty_out(vty, "external link\n"); | |
7993 | } | |
7994 | } | |
7995 | ||
7996 | /* Description. */ | |
7997 | if (p->desc) { | |
7998 | if (use_json) | |
7999 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
8000 | else | |
8001 | vty_out(vty, " Description: %s\n", p->desc); | |
8002 | } | |
8003 | ||
8004 | if (p->hostname) { | |
8005 | if (use_json) { | |
8006 | if (p->hostname) | |
8007 | json_object_string_add(json_neigh, "hostname", | |
8008 | p->hostname); | |
8009 | ||
8010 | if (p->domainname) | |
8011 | json_object_string_add(json_neigh, "domainname", | |
8012 | p->domainname); | |
8013 | } else { | |
8014 | if (p->domainname && (p->domainname[0] != '\0')) | |
8015 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
8016 | p->domainname); | |
8017 | else | |
8018 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
8019 | } | |
8020 | } | |
8021 | ||
8022 | /* Peer-group */ | |
8023 | if (p->group) { | |
8024 | if (use_json) { | |
8025 | json_object_string_add(json_neigh, "peerGroup", | |
8026 | p->group->name); | |
8027 | ||
8028 | if (dn_flag[0]) { | |
8029 | struct prefix prefix, *range = NULL; | |
8030 | ||
8031 | sockunion2hostprefix(&(p->su), &prefix); | |
8032 | range = peer_group_lookup_dynamic_neighbor_range( | |
8033 | p->group, &prefix); | |
8034 | ||
8035 | if (range) { | |
8036 | prefix2str(range, buf1, sizeof(buf1)); | |
8037 | json_object_string_add( | |
8038 | json_neigh, | |
8039 | "peerSubnetRangeGroup", buf1); | |
8040 | } | |
8041 | } | |
8042 | } else { | |
8043 | vty_out(vty, | |
8044 | " Member of peer-group %s for session parameters\n", | |
8045 | p->group->name); | |
8046 | ||
8047 | if (dn_flag[0]) { | |
8048 | struct prefix prefix, *range = NULL; | |
8049 | ||
8050 | sockunion2hostprefix(&(p->su), &prefix); | |
8051 | range = peer_group_lookup_dynamic_neighbor_range( | |
8052 | p->group, &prefix); | |
8053 | ||
8054 | if (range) { | |
8055 | prefix2str(range, buf1, sizeof(buf1)); | |
8056 | vty_out(vty, | |
8057 | " Belongs to the subnet range group: %s\n", | |
8058 | buf1); | |
8059 | } | |
8060 | } | |
8061 | } | |
8062 | } | |
8063 | ||
8064 | if (use_json) { | |
8065 | /* Administrative shutdown. */ | |
8066 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
8067 | json_object_boolean_true_add(json_neigh, | |
8068 | "adminShutDown"); | |
8069 | ||
8070 | /* BGP Version. */ | |
8071 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
8072 | json_object_string_add( | |
8073 | json_neigh, "remoteRouterId", | |
8074 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
8075 | ||
8076 | /* Confederation */ | |
8077 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
8078 | && bgp_confederation_peers_check(bgp, p->as)) | |
8079 | json_object_boolean_true_add(json_neigh, | |
8080 | "nbrCommonAdmin"); | |
8081 | ||
8082 | /* Status. */ | |
8083 | json_object_string_add( | |
8084 | json_neigh, "bgpState", | |
8085 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
8086 | ||
8087 | if (p->status == Established) { | |
8088 | time_t uptime; | |
8089 | struct tm *tm; | |
8090 | ||
8091 | uptime = bgp_clock(); | |
8092 | uptime -= p->uptime; | |
8093 | tm = gmtime(&uptime); | |
8094 | epoch_tbuf = time(NULL) - uptime; | |
8095 | ||
8096 | json_object_int_add(json_neigh, "bgpTimerUp", | |
8097 | (tm->tm_sec * 1000) | |
8098 | + (tm->tm_min * 60000) | |
8099 | + (tm->tm_hour * 3600000)); | |
8100 | json_object_string_add(json_neigh, "bgpTimerUpString", | |
8101 | peer_uptime(p->uptime, timebuf, | |
8102 | BGP_UPTIME_LEN, 0, | |
8103 | NULL)); | |
8104 | json_object_int_add(json_neigh, | |
8105 | "bgpTimerUpEstablishedEpoch", | |
8106 | epoch_tbuf); | |
8107 | } | |
8108 | ||
8109 | else if (p->status == Active) { | |
8110 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
8111 | json_object_string_add(json_neigh, "bgpStateIs", | |
8112 | "passive"); | |
8113 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
8114 | json_object_string_add(json_neigh, "bgpStateIs", | |
8115 | "passiveNSF"); | |
8116 | } | |
8117 | ||
8118 | /* read timer */ | |
8119 | time_t uptime; | |
8120 | struct tm *tm; | |
8121 | ||
8122 | uptime = bgp_clock(); | |
8123 | uptime -= p->readtime; | |
8124 | tm = gmtime(&uptime); | |
8125 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
8126 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
8127 | + (tm->tm_hour * 3600000)); | |
8128 | ||
8129 | uptime = bgp_clock(); | |
8130 | uptime -= p->last_write; | |
8131 | tm = gmtime(&uptime); | |
8132 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
8133 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
8134 | + (tm->tm_hour * 3600000)); | |
8135 | ||
8136 | uptime = bgp_clock(); | |
8137 | uptime -= p->update_time; | |
8138 | tm = gmtime(&uptime); | |
8139 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
8140 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
8141 | + (tm->tm_hour * 3600000)); | |
8142 | ||
8143 | /* Configured timer values. */ | |
8144 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
8145 | p->v_holdtime * 1000); | |
8146 | json_object_int_add(json_neigh, | |
8147 | "bgpTimerKeepAliveIntervalMsecs", | |
8148 | p->v_keepalive * 1000); | |
8149 | ||
8150 | if (CHECK_FLAG(p->config, PEER_CONFIG_TIMER)) { | |
8151 | json_object_int_add(json_neigh, | |
8152 | "bgpTimerConfiguredHoldTimeMsecs", | |
8153 | p->holdtime * 1000); | |
8154 | json_object_int_add( | |
8155 | json_neigh, | |
8156 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
8157 | p->keepalive * 1000); | |
8158 | } | |
8159 | } else { | |
8160 | /* Administrative shutdown. */ | |
8161 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
8162 | vty_out(vty, " Administratively shut down\n"); | |
8163 | ||
8164 | /* BGP Version. */ | |
8165 | vty_out(vty, " BGP version 4"); | |
8166 | vty_out(vty, ", remote router ID %s\n", | |
8167 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
8168 | ||
8169 | /* Confederation */ | |
8170 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
8171 | && bgp_confederation_peers_check(bgp, p->as)) | |
8172 | vty_out(vty, | |
8173 | " Neighbor under common administration\n"); | |
8174 | ||
8175 | /* Status. */ | |
8176 | vty_out(vty, " BGP state = %s", | |
8177 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
8178 | ||
8179 | if (p->status == Established) | |
8180 | vty_out(vty, ", up for %8s", | |
8181 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
8182 | 0, NULL)); | |
8183 | ||
8184 | else if (p->status == Active) { | |
8185 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
8186 | vty_out(vty, " (passive)"); | |
8187 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
8188 | vty_out(vty, " (NSF passive)"); | |
8189 | } | |
8190 | vty_out(vty, "\n"); | |
8191 | ||
8192 | /* read timer */ | |
8193 | vty_out(vty, " Last read %s", | |
8194 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
8195 | NULL)); | |
8196 | vty_out(vty, ", Last write %s\n", | |
8197 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
8198 | NULL)); | |
8199 | ||
8200 | /* Configured timer values. */ | |
8201 | vty_out(vty, | |
8202 | " Hold time is %d, keepalive interval is %d seconds\n", | |
8203 | p->v_holdtime, p->v_keepalive); | |
8204 | if (CHECK_FLAG(p->config, PEER_CONFIG_TIMER)) { | |
8205 | vty_out(vty, " Configured hold time is %d", | |
8206 | p->holdtime); | |
8207 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
8208 | p->keepalive); | |
8209 | } | |
8210 | } | |
8211 | /* Capability. */ | |
8212 | if (p->status == Established) { | |
8213 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
8214 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
8215 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
8216 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
8217 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
8218 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
8219 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
8220 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
8221 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
8222 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
8223 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
8224 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
8225 | || p->afc_adv[AFI_IP][SAFI_ENCAP] | |
8226 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
8227 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] | |
8228 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
8229 | if (use_json) { | |
8230 | json_object *json_cap = NULL; | |
8231 | ||
8232 | json_cap = json_object_new_object(); | |
8233 | ||
8234 | /* AS4 */ | |
8235 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
8236 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
8237 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
8238 | && CHECK_FLAG(p->cap, | |
8239 | PEER_CAP_AS4_RCV)) | |
8240 | json_object_string_add( | |
8241 | json_cap, "4byteAs", | |
8242 | "advertisedAndReceived"); | |
8243 | else if (CHECK_FLAG(p->cap, | |
8244 | PEER_CAP_AS4_ADV)) | |
8245 | json_object_string_add( | |
8246 | json_cap, "4byteAs", | |
8247 | "advertised"); | |
8248 | else if (CHECK_FLAG(p->cap, | |
8249 | PEER_CAP_AS4_RCV)) | |
8250 | json_object_string_add( | |
8251 | json_cap, "4byteAs", | |
8252 | "received"); | |
8253 | } | |
8254 | ||
8255 | /* AddPath */ | |
8256 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
8257 | || CHECK_FLAG(p->cap, | |
8258 | PEER_CAP_ADDPATH_ADV)) { | |
8259 | json_object *json_add = NULL; | |
8260 | const char *print_store; | |
8261 | ||
8262 | json_add = json_object_new_object(); | |
8263 | ||
8264 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
8265 | for (safi = SAFI_UNICAST; | |
8266 | safi < SAFI_MAX; safi++) { | |
8267 | json_object *json_sub = | |
8268 | NULL; | |
8269 | json_sub = | |
8270 | json_object_new_object(); | |
8271 | print_store = | |
8272 | afi_safi_print( | |
8273 | afi, | |
8274 | safi); | |
8275 | ||
8276 | if (CHECK_FLAG( | |
8277 | p->af_cap | |
8278 | [afi] | |
8279 | [safi], | |
8280 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8281 | || CHECK_FLAG( | |
8282 | p->af_cap | |
8283 | [afi] | |
8284 | [safi], | |
8285 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
8286 | if (CHECK_FLAG( | |
8287 | p->af_cap | |
8288 | [afi] | |
8289 | [safi], | |
8290 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8291 | && CHECK_FLAG( | |
8292 | p->af_cap | |
8293 | [afi] | |
8294 | [safi], | |
8295 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8296 | json_object_boolean_true_add( | |
8297 | json_sub, | |
8298 | "txAdvertisedAndReceived"); | |
8299 | else if ( | |
8300 | CHECK_FLAG( | |
8301 | p->af_cap | |
8302 | [afi] | |
8303 | [safi], | |
8304 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
8305 | json_object_boolean_true_add( | |
8306 | json_sub, | |
8307 | "txAdvertised"); | |
8308 | else if ( | |
8309 | CHECK_FLAG( | |
8310 | p->af_cap | |
8311 | [afi] | |
8312 | [safi], | |
8313 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8314 | json_object_boolean_true_add( | |
8315 | json_sub, | |
8316 | "txReceived"); | |
8317 | } | |
8318 | ||
8319 | if (CHECK_FLAG( | |
8320 | p->af_cap | |
8321 | [afi] | |
8322 | [safi], | |
8323 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8324 | || CHECK_FLAG( | |
8325 | p->af_cap | |
8326 | [afi] | |
8327 | [safi], | |
8328 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
8329 | if (CHECK_FLAG( | |
8330 | p->af_cap | |
8331 | [afi] | |
8332 | [safi], | |
8333 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8334 | && CHECK_FLAG( | |
8335 | p->af_cap | |
8336 | [afi] | |
8337 | [safi], | |
8338 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8339 | json_object_boolean_true_add( | |
8340 | json_sub, | |
8341 | "rxAdvertisedAndReceived"); | |
8342 | else if ( | |
8343 | CHECK_FLAG( | |
8344 | p->af_cap | |
8345 | [afi] | |
8346 | [safi], | |
8347 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
8348 | json_object_boolean_true_add( | |
8349 | json_sub, | |
8350 | "rxAdvertised"); | |
8351 | else if ( | |
8352 | CHECK_FLAG( | |
8353 | p->af_cap | |
8354 | [afi] | |
8355 | [safi], | |
8356 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8357 | json_object_boolean_true_add( | |
8358 | json_sub, | |
8359 | "rxReceived"); | |
8360 | } | |
8361 | ||
8362 | if (CHECK_FLAG( | |
8363 | p->af_cap | |
8364 | [afi] | |
8365 | [safi], | |
8366 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8367 | || CHECK_FLAG( | |
8368 | p->af_cap | |
8369 | [afi] | |
8370 | [safi], | |
8371 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
8372 | || CHECK_FLAG( | |
8373 | p->af_cap | |
8374 | [afi] | |
8375 | [safi], | |
8376 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8377 | || CHECK_FLAG( | |
8378 | p->af_cap | |
8379 | [afi] | |
8380 | [safi], | |
8381 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8382 | json_object_object_add( | |
8383 | json_add, | |
8384 | print_store, | |
8385 | json_sub); | |
8386 | else | |
8387 | json_object_free( | |
8388 | json_sub); | |
8389 | } | |
8390 | ||
8391 | json_object_object_add( | |
8392 | json_cap, "addPath", json_add); | |
8393 | } | |
8394 | ||
8395 | /* Dynamic */ | |
8396 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
8397 | || CHECK_FLAG(p->cap, | |
8398 | PEER_CAP_DYNAMIC_ADV)) { | |
8399 | if (CHECK_FLAG(p->cap, | |
8400 | PEER_CAP_DYNAMIC_ADV) | |
8401 | && CHECK_FLAG(p->cap, | |
8402 | PEER_CAP_DYNAMIC_RCV)) | |
8403 | json_object_string_add( | |
8404 | json_cap, "dynamic", | |
8405 | "advertisedAndReceived"); | |
8406 | else if (CHECK_FLAG( | |
8407 | p->cap, | |
8408 | PEER_CAP_DYNAMIC_ADV)) | |
8409 | json_object_string_add( | |
8410 | json_cap, "dynamic", | |
8411 | "advertised"); | |
8412 | else if (CHECK_FLAG( | |
8413 | p->cap, | |
8414 | PEER_CAP_DYNAMIC_RCV)) | |
8415 | json_object_string_add( | |
8416 | json_cap, "dynamic", | |
8417 | "received"); | |
8418 | } | |
8419 | ||
8420 | /* Extended nexthop */ | |
8421 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
8422 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
8423 | json_object *json_nxt = NULL; | |
8424 | const char *print_store; | |
8425 | ||
8426 | ||
8427 | if (CHECK_FLAG(p->cap, | |
8428 | PEER_CAP_ENHE_ADV) | |
8429 | && CHECK_FLAG(p->cap, | |
8430 | PEER_CAP_ENHE_RCV)) | |
8431 | json_object_string_add( | |
8432 | json_cap, | |
8433 | "extendedNexthop", | |
8434 | "advertisedAndReceived"); | |
8435 | else if (CHECK_FLAG(p->cap, | |
8436 | PEER_CAP_ENHE_ADV)) | |
8437 | json_object_string_add( | |
8438 | json_cap, | |
8439 | "extendedNexthop", | |
8440 | "advertised"); | |
8441 | else if (CHECK_FLAG(p->cap, | |
8442 | PEER_CAP_ENHE_RCV)) | |
8443 | json_object_string_add( | |
8444 | json_cap, | |
8445 | "extendedNexthop", | |
8446 | "received"); | |
8447 | ||
8448 | if (CHECK_FLAG(p->cap, | |
8449 | PEER_CAP_ENHE_RCV)) { | |
8450 | json_nxt = | |
8451 | json_object_new_object(); | |
8452 | ||
8453 | for (safi = SAFI_UNICAST; | |
8454 | safi < SAFI_MAX; safi++) { | |
8455 | if (CHECK_FLAG( | |
8456 | p->af_cap | |
8457 | [AFI_IP] | |
8458 | [safi], | |
8459 | PEER_CAP_ENHE_AF_RCV)) { | |
8460 | print_store = afi_safi_print( | |
8461 | AFI_IP, | |
8462 | safi); | |
8463 | json_object_string_add( | |
8464 | json_nxt, | |
8465 | print_store, | |
8466 | "recieved"); | |
8467 | } | |
8468 | } | |
8469 | json_object_object_add( | |
8470 | json_cap, | |
8471 | "extendedNexthopFamililesByPeer", | |
8472 | json_nxt); | |
8473 | } | |
8474 | } | |
8475 | ||
8476 | /* Route Refresh */ | |
8477 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
8478 | || CHECK_FLAG(p->cap, | |
8479 | PEER_CAP_REFRESH_NEW_RCV) | |
8480 | || CHECK_FLAG(p->cap, | |
8481 | PEER_CAP_REFRESH_OLD_RCV)) { | |
8482 | if (CHECK_FLAG(p->cap, | |
8483 | PEER_CAP_REFRESH_ADV) | |
8484 | && (CHECK_FLAG( | |
8485 | p->cap, | |
8486 | PEER_CAP_REFRESH_NEW_RCV) | |
8487 | || CHECK_FLAG( | |
8488 | p->cap, | |
8489 | PEER_CAP_REFRESH_OLD_RCV))) { | |
8490 | if (CHECK_FLAG( | |
8491 | p->cap, | |
8492 | PEER_CAP_REFRESH_OLD_RCV) | |
8493 | && CHECK_FLAG( | |
8494 | p->cap, | |
8495 | PEER_CAP_REFRESH_NEW_RCV)) | |
8496 | json_object_string_add( | |
8497 | json_cap, | |
8498 | "routeRefresh", | |
8499 | "advertisedAndReceivedOldNew"); | |
8500 | else { | |
8501 | if (CHECK_FLAG( | |
8502 | p->cap, | |
8503 | PEER_CAP_REFRESH_OLD_RCV)) | |
8504 | json_object_string_add( | |
8505 | json_cap, | |
8506 | "routeRefresh", | |
8507 | "advertisedAndReceivedOld"); | |
8508 | else | |
8509 | json_object_string_add( | |
8510 | json_cap, | |
8511 | "routeRefresh", | |
8512 | "advertisedAndReceivedNew"); | |
8513 | } | |
8514 | } else if ( | |
8515 | CHECK_FLAG( | |
8516 | p->cap, | |
8517 | PEER_CAP_REFRESH_ADV)) | |
8518 | json_object_string_add( | |
8519 | json_cap, | |
8520 | "routeRefresh", | |
8521 | "advertised"); | |
8522 | else if ( | |
8523 | CHECK_FLAG( | |
8524 | p->cap, | |
8525 | PEER_CAP_REFRESH_NEW_RCV) | |
8526 | || CHECK_FLAG( | |
8527 | p->cap, | |
8528 | PEER_CAP_REFRESH_OLD_RCV)) | |
8529 | json_object_string_add( | |
8530 | json_cap, | |
8531 | "routeRefresh", | |
8532 | "received"); | |
8533 | } | |
8534 | ||
8535 | /* Multiprotocol Extensions */ | |
8536 | json_object *json_multi = NULL; | |
8537 | json_multi = json_object_new_object(); | |
8538 | ||
8539 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
8540 | for (safi = SAFI_UNICAST; | |
8541 | safi < SAFI_MAX; safi++) { | |
8542 | if (p->afc_adv[afi][safi] | |
8543 | || p->afc_recv[afi][safi]) { | |
8544 | json_object | |
8545 | *json_exten = | |
8546 | NULL; | |
8547 | json_exten = | |
8548 | json_object_new_object(); | |
8549 | ||
8550 | if (p->afc_adv[afi] | |
8551 | [safi] | |
8552 | && p->afc_recv | |
8553 | [afi] | |
8554 | [safi]) | |
8555 | json_object_boolean_true_add( | |
8556 | json_exten, | |
8557 | "advertisedAndReceived"); | |
8558 | else if (p->afc_adv | |
8559 | [afi] | |
8560 | [safi]) | |
8561 | json_object_boolean_true_add( | |
8562 | json_exten, | |
8563 | "advertised"); | |
8564 | else if (p->afc_recv | |
8565 | [afi] | |
8566 | [safi]) | |
8567 | json_object_boolean_true_add( | |
8568 | json_exten, | |
8569 | "received"); | |
8570 | ||
8571 | json_object_object_add( | |
8572 | json_multi, | |
8573 | afi_safi_print( | |
8574 | afi, | |
8575 | safi), | |
8576 | json_exten); | |
8577 | } | |
8578 | } | |
8579 | } | |
8580 | json_object_object_add( | |
8581 | json_cap, "multiprotocolExtensions", | |
8582 | json_multi); | |
8583 | ||
8584 | /* Gracefull Restart */ | |
8585 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
8586 | || CHECK_FLAG(p->cap, | |
8587 | PEER_CAP_RESTART_ADV)) { | |
8588 | if (CHECK_FLAG(p->cap, | |
8589 | PEER_CAP_RESTART_ADV) | |
8590 | && CHECK_FLAG(p->cap, | |
8591 | PEER_CAP_RESTART_RCV)) | |
8592 | json_object_string_add( | |
8593 | json_cap, | |
8594 | "gracefulRestart", | |
8595 | "advertisedAndReceived"); | |
8596 | else if (CHECK_FLAG( | |
8597 | p->cap, | |
8598 | PEER_CAP_RESTART_ADV)) | |
8599 | json_object_string_add( | |
8600 | json_cap, | |
8601 | "gracefulRestartCapability", | |
8602 | "advertised"); | |
8603 | else if (CHECK_FLAG( | |
8604 | p->cap, | |
8605 | PEER_CAP_RESTART_RCV)) | |
8606 | json_object_string_add( | |
8607 | json_cap, | |
8608 | "gracefulRestartCapability", | |
8609 | "received"); | |
8610 | ||
8611 | if (CHECK_FLAG(p->cap, | |
8612 | PEER_CAP_RESTART_RCV)) { | |
8613 | int restart_af_count = 0; | |
8614 | json_object *json_restart = | |
8615 | NULL; | |
8616 | json_restart = | |
8617 | json_object_new_object(); | |
8618 | ||
8619 | json_object_int_add( | |
8620 | json_cap, | |
8621 | "gracefulRestartRemoteTimerMsecs", | |
8622 | p->v_gr_restart * 1000); | |
8623 | ||
8624 | for (afi = AFI_IP; | |
8625 | afi < AFI_MAX; afi++) { | |
8626 | for (safi = SAFI_UNICAST; | |
8627 | safi < SAFI_MAX; | |
8628 | safi++) { | |
8629 | if (CHECK_FLAG( | |
8630 | p->af_cap | |
8631 | [afi] | |
8632 | [safi], | |
8633 | PEER_CAP_RESTART_AF_RCV)) { | |
8634 | json_object *json_sub = | |
8635 | NULL; | |
8636 | json_sub = | |
8637 | json_object_new_object(); | |
8638 | ||
8639 | if (CHECK_FLAG( | |
8640 | p->af_cap | |
8641 | [afi] | |
8642 | [safi], | |
8643 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) | |
8644 | json_object_boolean_true_add( | |
8645 | json_sub, | |
8646 | "preserved"); | |
8647 | restart_af_count++; | |
8648 | json_object_object_add( | |
8649 | json_restart, | |
8650 | afi_safi_print( | |
8651 | afi, | |
8652 | safi), | |
8653 | json_sub); | |
8654 | } | |
8655 | } | |
8656 | } | |
8657 | if (!restart_af_count) { | |
8658 | json_object_string_add( | |
8659 | json_cap, | |
8660 | "addressFamiliesByPeer", | |
8661 | "none"); | |
8662 | json_object_free( | |
8663 | json_restart); | |
8664 | } else | |
8665 | json_object_object_add( | |
8666 | json_cap, | |
8667 | "addressFamiliesByPeer", | |
8668 | json_restart); | |
8669 | } | |
8670 | } | |
8671 | json_object_object_add(json_neigh, | |
8672 | "neighborCapabilities", | |
8673 | json_cap); | |
8674 | } else { | |
8675 | vty_out(vty, " Neighbor capabilities:\n"); | |
8676 | ||
8677 | /* AS4 */ | |
8678 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
8679 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
8680 | vty_out(vty, " 4 Byte AS:"); | |
8681 | if (CHECK_FLAG(p->cap, | |
8682 | PEER_CAP_AS4_ADV)) | |
8683 | vty_out(vty, " advertised"); | |
8684 | if (CHECK_FLAG(p->cap, | |
8685 | PEER_CAP_AS4_RCV)) | |
8686 | vty_out(vty, " %sreceived", | |
8687 | CHECK_FLAG( | |
8688 | p->cap, | |
8689 | PEER_CAP_AS4_ADV) | |
8690 | ? "and " | |
8691 | : ""); | |
8692 | vty_out(vty, "\n"); | |
8693 | } | |
8694 | ||
8695 | /* AddPath */ | |
8696 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
8697 | || CHECK_FLAG(p->cap, | |
8698 | PEER_CAP_ADDPATH_ADV)) { | |
8699 | vty_out(vty, " AddPath:\n"); | |
8700 | ||
8701 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
8702 | for (safi = SAFI_UNICAST; | |
8703 | safi < SAFI_MAX; safi++) { | |
8704 | if (CHECK_FLAG( | |
8705 | p->af_cap | |
8706 | [afi] | |
8707 | [safi], | |
8708 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8709 | || CHECK_FLAG( | |
8710 | p->af_cap | |
8711 | [afi] | |
8712 | [safi], | |
8713 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
8714 | vty_out(vty, | |
8715 | " %s: TX ", | |
8716 | afi_safi_print( | |
8717 | afi, | |
8718 | safi)); | |
8719 | ||
8720 | if (CHECK_FLAG( | |
8721 | p->af_cap | |
8722 | [afi] | |
8723 | [safi], | |
8724 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
8725 | vty_out(vty, | |
8726 | "advertised %s", | |
8727 | afi_safi_print( | |
8728 | afi, | |
8729 | safi)); | |
8730 | ||
8731 | if (CHECK_FLAG( | |
8732 | p->af_cap | |
8733 | [afi] | |
8734 | [safi], | |
8735 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8736 | vty_out(vty, | |
8737 | "%sreceived", | |
8738 | CHECK_FLAG( | |
8739 | p->af_cap | |
8740 | [afi] | |
8741 | [safi], | |
8742 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8743 | ? " and " | |
8744 | : ""); | |
8745 | ||
8746 | vty_out(vty, | |
8747 | "\n"); | |
8748 | } | |
8749 | ||
8750 | if (CHECK_FLAG( | |
8751 | p->af_cap | |
8752 | [afi] | |
8753 | [safi], | |
8754 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8755 | || CHECK_FLAG( | |
8756 | p->af_cap | |
8757 | [afi] | |
8758 | [safi], | |
8759 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
8760 | vty_out(vty, | |
8761 | " %s: RX ", | |
8762 | afi_safi_print( | |
8763 | afi, | |
8764 | safi)); | |
8765 | ||
8766 | if (CHECK_FLAG( | |
8767 | p->af_cap | |
8768 | [afi] | |
8769 | [safi], | |
8770 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
8771 | vty_out(vty, | |
8772 | "advertised %s", | |
8773 | afi_safi_print( | |
8774 | afi, | |
8775 | safi)); | |
8776 | ||
8777 | if (CHECK_FLAG( | |
8778 | p->af_cap | |
8779 | [afi] | |
8780 | [safi], | |
8781 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8782 | vty_out(vty, | |
8783 | "%sreceived", | |
8784 | CHECK_FLAG( | |
8785 | p->af_cap | |
8786 | [afi] | |
8787 | [safi], | |
8788 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8789 | ? " and " | |
8790 | : ""); | |
8791 | ||
8792 | vty_out(vty, | |
8793 | "\n"); | |
8794 | } | |
8795 | } | |
8796 | } | |
8797 | ||
8798 | /* Dynamic */ | |
8799 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
8800 | || CHECK_FLAG(p->cap, | |
8801 | PEER_CAP_DYNAMIC_ADV)) { | |
8802 | vty_out(vty, " Dynamic:"); | |
8803 | if (CHECK_FLAG(p->cap, | |
8804 | PEER_CAP_DYNAMIC_ADV)) | |
8805 | vty_out(vty, " advertised"); | |
8806 | if (CHECK_FLAG(p->cap, | |
8807 | PEER_CAP_DYNAMIC_RCV)) | |
8808 | vty_out(vty, " %sreceived", | |
8809 | CHECK_FLAG( | |
8810 | p->cap, | |
8811 | PEER_CAP_DYNAMIC_ADV) | |
8812 | ? "and " | |
8813 | : ""); | |
8814 | vty_out(vty, "\n"); | |
8815 | } | |
8816 | ||
8817 | /* Extended nexthop */ | |
8818 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
8819 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
8820 | vty_out(vty, " Extended nexthop:"); | |
8821 | if (CHECK_FLAG(p->cap, | |
8822 | PEER_CAP_ENHE_ADV)) | |
8823 | vty_out(vty, " advertised"); | |
8824 | if (CHECK_FLAG(p->cap, | |
8825 | PEER_CAP_ENHE_RCV)) | |
8826 | vty_out(vty, " %sreceived", | |
8827 | CHECK_FLAG( | |
8828 | p->cap, | |
8829 | PEER_CAP_ENHE_ADV) | |
8830 | ? "and " | |
8831 | : ""); | |
8832 | vty_out(vty, "\n"); | |
8833 | ||
8834 | if (CHECK_FLAG(p->cap, | |
8835 | PEER_CAP_ENHE_RCV)) { | |
8836 | vty_out(vty, | |
8837 | " Address families by peer:\n "); | |
8838 | for (safi = SAFI_UNICAST; | |
8839 | safi < SAFI_MAX; safi++) | |
8840 | if (CHECK_FLAG( | |
8841 | p->af_cap | |
8842 | [AFI_IP] | |
8843 | [safi], | |
8844 | PEER_CAP_ENHE_AF_RCV)) | |
8845 | vty_out(vty, | |
8846 | " %s\n", | |
8847 | afi_safi_print( | |
8848 | AFI_IP, | |
8849 | safi)); | |
8850 | } | |
8851 | } | |
8852 | ||
8853 | /* Route Refresh */ | |
8854 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
8855 | || CHECK_FLAG(p->cap, | |
8856 | PEER_CAP_REFRESH_NEW_RCV) | |
8857 | || CHECK_FLAG(p->cap, | |
8858 | PEER_CAP_REFRESH_OLD_RCV)) { | |
8859 | vty_out(vty, " Route refresh:"); | |
8860 | if (CHECK_FLAG(p->cap, | |
8861 | PEER_CAP_REFRESH_ADV)) | |
8862 | vty_out(vty, " advertised"); | |
8863 | if (CHECK_FLAG(p->cap, | |
8864 | PEER_CAP_REFRESH_NEW_RCV) | |
8865 | || CHECK_FLAG( | |
8866 | p->cap, | |
8867 | PEER_CAP_REFRESH_OLD_RCV)) | |
8868 | vty_out(vty, " %sreceived(%s)", | |
8869 | CHECK_FLAG( | |
8870 | p->cap, | |
8871 | PEER_CAP_REFRESH_ADV) | |
8872 | ? "and " | |
8873 | : "", | |
8874 | (CHECK_FLAG( | |
8875 | p->cap, | |
8876 | PEER_CAP_REFRESH_OLD_RCV) | |
8877 | && CHECK_FLAG( | |
8878 | p->cap, | |
8879 | PEER_CAP_REFRESH_NEW_RCV)) | |
8880 | ? "old & new" | |
8881 | : CHECK_FLAG( | |
8882 | p->cap, | |
8883 | PEER_CAP_REFRESH_OLD_RCV) | |
8884 | ? "old" | |
8885 | : "new"); | |
8886 | ||
8887 | vty_out(vty, "\n"); | |
8888 | } | |
8889 | ||
8890 | /* Multiprotocol Extensions */ | |
8891 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
8892 | for (safi = SAFI_UNICAST; | |
8893 | safi < SAFI_MAX; safi++) | |
8894 | if (p->afc_adv[afi][safi] | |
8895 | || p->afc_recv[afi][safi]) { | |
8896 | vty_out(vty, | |
8897 | " Address Family %s:", | |
8898 | afi_safi_print( | |
8899 | afi, | |
8900 | safi)); | |
8901 | if (p->afc_adv[afi] | |
8902 | [safi]) | |
8903 | vty_out(vty, | |
8904 | " advertised"); | |
8905 | if (p->afc_recv[afi] | |
8906 | [safi]) | |
8907 | vty_out(vty, | |
8908 | " %sreceived", | |
8909 | p->afc_adv[afi] | |
8910 | [safi] | |
8911 | ? "and " | |
8912 | : ""); | |
8913 | vty_out(vty, "\n"); | |
8914 | } | |
8915 | ||
8916 | /* Hostname capability */ | |
8917 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV) | |
8918 | || CHECK_FLAG(p->cap, | |
8919 | PEER_CAP_HOSTNAME_RCV)) { | |
8920 | vty_out(vty, | |
8921 | " Hostname Capability:"); | |
8922 | if (CHECK_FLAG(p->cap, | |
8923 | PEER_CAP_HOSTNAME_ADV)) | |
8924 | vty_out(vty, " advertised"); | |
8925 | if (CHECK_FLAG(p->cap, | |
8926 | PEER_CAP_HOSTNAME_RCV)) | |
8927 | vty_out(vty, " %sreceived", | |
8928 | CHECK_FLAG( | |
8929 | p->cap, | |
8930 | PEER_CAP_HOSTNAME_ADV) | |
8931 | ? "and " | |
8932 | : ""); | |
8933 | vty_out(vty, "\n"); | |
8934 | } | |
8935 | ||
8936 | /* Gracefull Restart */ | |
8937 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
8938 | || CHECK_FLAG(p->cap, | |
8939 | PEER_CAP_RESTART_ADV)) { | |
8940 | vty_out(vty, | |
8941 | " Graceful Restart Capabilty:"); | |
8942 | if (CHECK_FLAG(p->cap, | |
8943 | PEER_CAP_RESTART_ADV)) | |
8944 | vty_out(vty, " advertised"); | |
8945 | if (CHECK_FLAG(p->cap, | |
8946 | PEER_CAP_RESTART_RCV)) | |
8947 | vty_out(vty, " %sreceived", | |
8948 | CHECK_FLAG( | |
8949 | p->cap, | |
8950 | PEER_CAP_RESTART_ADV) | |
8951 | ? "and " | |
8952 | : ""); | |
8953 | vty_out(vty, "\n"); | |
8954 | ||
8955 | if (CHECK_FLAG(p->cap, | |
8956 | PEER_CAP_RESTART_RCV)) { | |
8957 | int restart_af_count = 0; | |
8958 | ||
8959 | vty_out(vty, | |
8960 | " Remote Restart timer is %d seconds\n", | |
8961 | p->v_gr_restart); | |
8962 | vty_out(vty, | |
8963 | " Address families by peer:\n "); | |
8964 | ||
8965 | for (afi = AFI_IP; | |
8966 | afi < AFI_MAX; afi++) | |
8967 | for (safi = SAFI_UNICAST; | |
8968 | safi < SAFI_MAX; | |
8969 | safi++) | |
8970 | if (CHECK_FLAG( | |
8971 | p->af_cap | |
8972 | [afi] | |
8973 | [safi], | |
8974 | PEER_CAP_RESTART_AF_RCV)) { | |
8975 | vty_out(vty, | |
8976 | "%s%s(%s)", | |
8977 | restart_af_count | |
8978 | ? ", " | |
8979 | : "", | |
8980 | afi_safi_print( | |
8981 | afi, | |
8982 | safi), | |
8983 | CHECK_FLAG( | |
8984 | p->af_cap | |
8985 | [afi] | |
8986 | [safi], | |
8987 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
8988 | ? "preserved" | |
8989 | : "not preserved"); | |
8990 | restart_af_count++; | |
8991 | } | |
8992 | if (!restart_af_count) | |
8993 | vty_out(vty, "none"); | |
8994 | vty_out(vty, "\n"); | |
8995 | } | |
8996 | } | |
8997 | } | |
8998 | } | |
8999 | } | |
9000 | ||
9001 | /* graceful restart information */ | |
9002 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || p->t_gr_restart | |
9003 | || p->t_gr_stale) { | |
9004 | json_object *json_grace = NULL; | |
9005 | json_object *json_grace_send = NULL; | |
9006 | json_object *json_grace_recv = NULL; | |
9007 | int eor_send_af_count = 0; | |
9008 | int eor_receive_af_count = 0; | |
9009 | ||
9010 | if (use_json) { | |
9011 | json_grace = json_object_new_object(); | |
9012 | json_grace_send = json_object_new_object(); | |
9013 | json_grace_recv = json_object_new_object(); | |
9014 | ||
9015 | if (p->status == Established) { | |
9016 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9017 | for (safi = SAFI_UNICAST; | |
9018 | safi < SAFI_MAX; safi++) { | |
9019 | if (CHECK_FLAG( | |
9020 | p->af_sflags[afi] | |
9021 | [safi], | |
9022 | PEER_STATUS_EOR_SEND)) { | |
9023 | json_object_boolean_true_add( | |
9024 | json_grace_send, | |
9025 | afi_safi_print( | |
9026 | afi, | |
9027 | safi)); | |
9028 | eor_send_af_count++; | |
9029 | } | |
9030 | } | |
9031 | } | |
9032 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9033 | for (safi = SAFI_UNICAST; | |
9034 | safi < SAFI_MAX; safi++) { | |
9035 | if (CHECK_FLAG( | |
9036 | p->af_sflags[afi] | |
9037 | [safi], | |
9038 | PEER_STATUS_EOR_RECEIVED)) { | |
9039 | json_object_boolean_true_add( | |
9040 | json_grace_recv, | |
9041 | afi_safi_print( | |
9042 | afi, | |
9043 | safi)); | |
9044 | eor_receive_af_count++; | |
9045 | } | |
9046 | } | |
9047 | } | |
9048 | } | |
9049 | ||
9050 | json_object_object_add(json_grace, "endOfRibSend", | |
9051 | json_grace_send); | |
9052 | json_object_object_add(json_grace, "endOfRibRecv", | |
9053 | json_grace_recv); | |
9054 | ||
9055 | if (p->t_gr_restart) | |
9056 | json_object_int_add(json_grace, | |
9057 | "gracefulRestartTimerMsecs", | |
9058 | thread_timer_remain_second( | |
9059 | p->t_gr_restart) | |
9060 | * 1000); | |
9061 | ||
9062 | if (p->t_gr_stale) | |
9063 | json_object_int_add( | |
9064 | json_grace, | |
9065 | "gracefulStalepathTimerMsecs", | |
9066 | thread_timer_remain_second( | |
9067 | p->t_gr_stale) | |
9068 | * 1000); | |
9069 | ||
9070 | json_object_object_add( | |
9071 | json_neigh, "gracefulRestartInfo", json_grace); | |
9072 | } else { | |
9073 | vty_out(vty, " Graceful restart informations:\n"); | |
9074 | if (p->status == Established) { | |
9075 | vty_out(vty, " End-of-RIB send: "); | |
9076 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9077 | for (safi = SAFI_UNICAST; | |
9078 | safi < SAFI_MAX; safi++) { | |
9079 | if (CHECK_FLAG( | |
9080 | p->af_sflags[afi] | |
9081 | [safi], | |
9082 | PEER_STATUS_EOR_SEND)) { | |
9083 | vty_out(vty, "%s%s", | |
9084 | eor_send_af_count | |
9085 | ? ", " | |
9086 | : "", | |
9087 | afi_safi_print( | |
9088 | afi, | |
9089 | safi)); | |
9090 | eor_send_af_count++; | |
9091 | } | |
9092 | } | |
9093 | } | |
9094 | vty_out(vty, "\n"); | |
9095 | vty_out(vty, " End-of-RIB received: "); | |
9096 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9097 | for (safi = SAFI_UNICAST; | |
9098 | safi < SAFI_MAX; safi++) { | |
9099 | if (CHECK_FLAG( | |
9100 | p->af_sflags[afi] | |
9101 | [safi], | |
9102 | PEER_STATUS_EOR_RECEIVED)) { | |
9103 | vty_out(vty, "%s%s", | |
9104 | eor_receive_af_count | |
9105 | ? ", " | |
9106 | : "", | |
9107 | afi_safi_print( | |
9108 | afi, | |
9109 | safi)); | |
9110 | eor_receive_af_count++; | |
9111 | } | |
9112 | } | |
9113 | } | |
9114 | vty_out(vty, "\n"); | |
9115 | } | |
9116 | ||
9117 | if (p->t_gr_restart) | |
9118 | vty_out(vty, | |
9119 | " The remaining time of restart timer is %ld\n", | |
9120 | thread_timer_remain_second( | |
9121 | p->t_gr_restart)); | |
9122 | ||
9123 | if (p->t_gr_stale) | |
9124 | vty_out(vty, | |
9125 | " The remaining time of stalepath timer is %ld\n", | |
9126 | thread_timer_remain_second( | |
9127 | p->t_gr_stale)); | |
9128 | } | |
9129 | } | |
9130 | if (use_json) { | |
9131 | json_object *json_stat = NULL; | |
9132 | json_stat = json_object_new_object(); | |
9133 | /* Packet counts. */ | |
9134 | json_object_int_add(json_stat, "depthInq", 0); | |
9135 | json_object_int_add(json_stat, "depthOutq", | |
9136 | (unsigned long)p->obuf->count); | |
9137 | json_object_int_add(json_stat, "opensSent", p->open_out); | |
9138 | json_object_int_add(json_stat, "opensRecv", p->open_in); | |
9139 | json_object_int_add(json_stat, "notificationsSent", | |
9140 | p->notify_out); | |
9141 | json_object_int_add(json_stat, "notificationsRecv", | |
9142 | p->notify_in); | |
9143 | json_object_int_add(json_stat, "updatesSent", p->update_out); | |
9144 | json_object_int_add(json_stat, "updatesRecv", p->update_in); | |
9145 | json_object_int_add(json_stat, "keepalivesSent", | |
9146 | p->keepalive_out); | |
9147 | json_object_int_add(json_stat, "keepalivesRecv", | |
9148 | p->keepalive_in); | |
9149 | json_object_int_add(json_stat, "routeRefreshSent", | |
9150 | p->refresh_out); | |
9151 | json_object_int_add(json_stat, "routeRefreshRecv", | |
9152 | p->refresh_in); | |
9153 | json_object_int_add(json_stat, "capabilitySent", | |
9154 | p->dynamic_cap_out); | |
9155 | json_object_int_add(json_stat, "capabilityRecv", | |
9156 | p->dynamic_cap_in); | |
9157 | json_object_int_add(json_stat, "totalSent", | |
9158 | p->open_out + p->notify_out + p->update_out | |
9159 | + p->keepalive_out + p->refresh_out | |
9160 | + p->dynamic_cap_out); | |
9161 | json_object_int_add(json_stat, "totalRecv", | |
9162 | p->open_in + p->notify_in + p->update_in | |
9163 | + p->keepalive_in + p->refresh_in | |
9164 | + p->dynamic_cap_in); | |
9165 | json_object_object_add(json_neigh, "messageStats", json_stat); | |
9166 | } else { | |
9167 | /* Packet counts. */ | |
9168 | vty_out(vty, " Message statistics:\n"); | |
9169 | vty_out(vty, " Inq depth is 0\n"); | |
9170 | vty_out(vty, " Outq depth is %lu\n", | |
9171 | (unsigned long)p->obuf->count); | |
9172 | vty_out(vty, " Sent Rcvd\n"); | |
9173 | vty_out(vty, " Opens: %10d %10d\n", p->open_out, | |
9174 | p->open_in); | |
9175 | vty_out(vty, " Notifications: %10d %10d\n", p->notify_out, | |
9176 | p->notify_in); | |
9177 | vty_out(vty, " Updates: %10d %10d\n", p->update_out, | |
9178 | p->update_in); | |
9179 | vty_out(vty, " Keepalives: %10d %10d\n", p->keepalive_out, | |
9180 | p->keepalive_in); | |
9181 | vty_out(vty, " Route Refresh: %10d %10d\n", p->refresh_out, | |
9182 | p->refresh_in); | |
9183 | vty_out(vty, " Capability: %10d %10d\n", | |
9184 | p->dynamic_cap_out, p->dynamic_cap_in); | |
9185 | vty_out(vty, " Total: %10d %10d\n", | |
9186 | p->open_out + p->notify_out + p->update_out | |
9187 | + p->keepalive_out + p->refresh_out | |
9188 | + p->dynamic_cap_out, | |
9189 | p->open_in + p->notify_in + p->update_in | |
9190 | + p->keepalive_in + p->refresh_in | |
9191 | + p->dynamic_cap_in); | |
9192 | } | |
9193 | ||
9194 | if (use_json) { | |
9195 | /* advertisement-interval */ | |
9196 | json_object_int_add(json_neigh, | |
9197 | "minBtwnAdvertisementRunsTimerMsecs", | |
9198 | p->v_routeadv * 1000); | |
9199 | ||
9200 | /* Update-source. */ | |
9201 | if (p->update_if || p->update_source) { | |
9202 | if (p->update_if) | |
9203 | json_object_string_add(json_neigh, | |
9204 | "updateSource", | |
9205 | p->update_if); | |
9206 | else if (p->update_source) | |
9207 | json_object_string_add( | |
9208 | json_neigh, "updateSource", | |
9209 | sockunion2str(p->update_source, buf1, | |
9210 | SU_ADDRSTRLEN)); | |
9211 | } | |
9212 | } else { | |
9213 | /* advertisement-interval */ | |
9214 | vty_out(vty, | |
9215 | " Minimum time between advertisement runs is %d seconds\n", | |
9216 | p->v_routeadv); | |
9217 | ||
9218 | /* Update-source. */ | |
9219 | if (p->update_if || p->update_source) { | |
9220 | vty_out(vty, " Update source is "); | |
9221 | if (p->update_if) | |
9222 | vty_out(vty, "%s", p->update_if); | |
9223 | else if (p->update_source) | |
9224 | vty_out(vty, "%s", | |
9225 | sockunion2str(p->update_source, buf1, | |
9226 | SU_ADDRSTRLEN)); | |
9227 | vty_out(vty, "\n"); | |
9228 | } | |
9229 | ||
9230 | vty_out(vty, "\n"); | |
9231 | } | |
9232 | ||
9233 | /* Address Family Information */ | |
9234 | json_object *json_hold = NULL; | |
9235 | ||
9236 | if (use_json) | |
9237 | json_hold = json_object_new_object(); | |
9238 | ||
9239 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9240 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
9241 | if (p->afc[afi][safi]) | |
9242 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
9243 | json_hold); | |
9244 | ||
9245 | if (use_json) { | |
9246 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
9247 | json_hold); | |
9248 | json_object_int_add(json_neigh, "connectionsEstablished", | |
9249 | p->established); | |
9250 | json_object_int_add(json_neigh, "connectionsDropped", | |
9251 | p->dropped); | |
9252 | } else | |
9253 | vty_out(vty, " Connections established %d; dropped %d\n", | |
9254 | p->established, p->dropped); | |
9255 | ||
9256 | if (!p->last_reset) { | |
9257 | if (use_json) | |
9258 | json_object_string_add(json_neigh, "lastReset", | |
9259 | "never"); | |
9260 | else | |
9261 | vty_out(vty, " Last reset never\n"); | |
9262 | } else { | |
9263 | if (use_json) { | |
9264 | time_t uptime; | |
9265 | struct tm *tm; | |
9266 | ||
9267 | uptime = bgp_clock(); | |
9268 | uptime -= p->resettime; | |
9269 | tm = gmtime(&uptime); | |
9270 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
9271 | (tm->tm_sec * 1000) | |
9272 | + (tm->tm_min * 60000) | |
9273 | + (tm->tm_hour * 3600000)); | |
9274 | json_object_string_add( | |
9275 | json_neigh, "lastResetDueTo", | |
9276 | peer_down_str[(int)p->last_reset]); | |
9277 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
9278 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
9279 | char errorcodesubcode_hexstr[5]; | |
9280 | char errorcodesubcode_str[256]; | |
9281 | ||
9282 | code_str = bgp_notify_code_str(p->notify.code); | |
9283 | subcode_str = bgp_notify_subcode_str( | |
9284 | p->notify.code, p->notify.subcode); | |
9285 | ||
9286 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
9287 | p->notify.code, p->notify.subcode); | |
9288 | json_object_string_add(json_neigh, | |
9289 | "lastErrorCodeSubcode", | |
9290 | errorcodesubcode_hexstr); | |
9291 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
9292 | code_str, subcode_str); | |
9293 | json_object_string_add(json_neigh, | |
9294 | "lastNotificationReason", | |
9295 | errorcodesubcode_str); | |
9296 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
9297 | && p->notify.code == BGP_NOTIFY_CEASE | |
9298 | && (p->notify.subcode | |
9299 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
9300 | || p->notify.subcode | |
9301 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
9302 | && p->notify.length) { | |
9303 | char msgbuf[1024]; | |
9304 | const char *msg_str; | |
9305 | ||
9306 | msg_str = bgp_notify_admin_message( | |
9307 | msgbuf, sizeof(msgbuf), | |
9308 | (u_char *)p->notify.data, | |
9309 | p->notify.length); | |
9310 | if (msg_str) | |
9311 | json_object_string_add( | |
9312 | json_neigh, | |
9313 | "lastShutdownDescription", | |
9314 | msg_str); | |
9315 | } | |
9316 | } | |
9317 | } else { | |
9318 | vty_out(vty, " Last reset %s, ", | |
9319 | peer_uptime(p->resettime, timebuf, | |
9320 | BGP_UPTIME_LEN, 0, NULL)); | |
9321 | ||
9322 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
9323 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
9324 | code_str = bgp_notify_code_str(p->notify.code); | |
9325 | subcode_str = bgp_notify_subcode_str( | |
9326 | p->notify.code, p->notify.subcode); | |
9327 | vty_out(vty, "due to NOTIFICATION %s (%s%s)\n", | |
9328 | p->last_reset == PEER_DOWN_NOTIFY_SEND | |
9329 | ? "sent" | |
9330 | : "received", | |
9331 | code_str, subcode_str); | |
9332 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
9333 | && p->notify.code == BGP_NOTIFY_CEASE | |
9334 | && (p->notify.subcode | |
9335 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
9336 | || p->notify.subcode | |
9337 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
9338 | && p->notify.length) { | |
9339 | char msgbuf[1024]; | |
9340 | const char *msg_str; | |
9341 | ||
9342 | msg_str = bgp_notify_admin_message( | |
9343 | msgbuf, sizeof(msgbuf), | |
9344 | (u_char *)p->notify.data, | |
9345 | p->notify.length); | |
9346 | if (msg_str) | |
9347 | vty_out(vty, | |
9348 | " Message: \"%s\"\n", | |
9349 | msg_str); | |
9350 | } | |
9351 | } else { | |
9352 | vty_out(vty, "due to %s\n", | |
9353 | peer_down_str[(int)p->last_reset]); | |
9354 | } | |
9355 | ||
9356 | if (p->last_reset_cause_size) { | |
9357 | msg = p->last_reset_cause; | |
9358 | vty_out(vty, | |
9359 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
9360 | for (i = 1; i <= p->last_reset_cause_size; | |
9361 | i++) { | |
9362 | vty_out(vty, "%02X", *msg++); | |
9363 | ||
9364 | if (i != p->last_reset_cause_size) { | |
9365 | if (i % 16 == 0) { | |
9366 | vty_out(vty, "\n "); | |
9367 | } else if (i % 4 == 0) { | |
9368 | vty_out(vty, " "); | |
9369 | } | |
9370 | } | |
9371 | } | |
9372 | vty_out(vty, "\n"); | |
9373 | } | |
9374 | } | |
9375 | } | |
9376 | ||
9377 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
9378 | if (use_json) | |
9379 | json_object_boolean_true_add(json_neigh, | |
9380 | "prefixesConfigExceedMax"); | |
9381 | else | |
9382 | vty_out(vty, | |
9383 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
9384 | ||
9385 | if (p->t_pmax_restart) { | |
9386 | if (use_json) { | |
9387 | json_object_boolean_true_add( | |
9388 | json_neigh, "reducePrefixNumFrom"); | |
9389 | json_object_int_add(json_neigh, | |
9390 | "restartInTimerMsec", | |
9391 | thread_timer_remain_second( | |
9392 | p->t_pmax_restart) | |
9393 | * 1000); | |
9394 | } else | |
9395 | vty_out(vty, | |
9396 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
c14777c6 | 9397 | p->host, |
9398 | thread_timer_remain_second( | |
9399 | p->t_pmax_restart)); | |
d62a17ae | 9400 | } else { |
9401 | if (use_json) | |
9402 | json_object_boolean_true_add( | |
9403 | json_neigh, | |
9404 | "reducePrefixNumAndClearIpBgp"); | |
9405 | else | |
9406 | vty_out(vty, | |
9407 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
9408 | p->host); | |
9409 | } | |
9410 | } | |
9411 | ||
9412 | /* EBGP Multihop and GTSM */ | |
9413 | if (p->sort != BGP_PEER_IBGP) { | |
9414 | if (use_json) { | |
9415 | if (p->gtsm_hops > 0) | |
9416 | json_object_int_add(json_neigh, | |
9417 | "externalBgpNbrMaxHopsAway", | |
9418 | p->gtsm_hops); | |
9419 | else if (p->ttl > 1) | |
9420 | json_object_int_add(json_neigh, | |
9421 | "externalBgpNbrMaxHopsAway", | |
9422 | p->ttl); | |
9423 | } else { | |
9424 | if (p->gtsm_hops > 0) | |
9425 | vty_out(vty, | |
9426 | " External BGP neighbor may be up to %d hops away.\n", | |
9427 | p->gtsm_hops); | |
9428 | else if (p->ttl > 1) | |
9429 | vty_out(vty, | |
9430 | " External BGP neighbor may be up to %d hops away.\n", | |
9431 | p->ttl); | |
9432 | } | |
9433 | } else { | |
9434 | if (p->gtsm_hops > 0) { | |
9435 | if (use_json) | |
9436 | json_object_int_add(json_neigh, | |
9437 | "internalBgpNbrMaxHopsAway", | |
9438 | p->gtsm_hops); | |
9439 | else | |
9440 | vty_out(vty, | |
9441 | " Internal BGP neighbor may be up to %d hops away.\n", | |
9442 | p->gtsm_hops); | |
9443 | } | |
9444 | } | |
9445 | ||
9446 | /* Local address. */ | |
9447 | if (p->su_local) { | |
9448 | if (use_json) { | |
9449 | json_object_string_add(json_neigh, "hostLocal", | |
9450 | sockunion2str(p->su_local, buf1, | |
9451 | SU_ADDRSTRLEN)); | |
9452 | json_object_int_add(json_neigh, "portLocal", | |
9453 | ntohs(p->su_local->sin.sin_port)); | |
9454 | } else | |
9455 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
9456 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
9457 | ntohs(p->su_local->sin.sin_port)); | |
9458 | } | |
9459 | ||
9460 | /* Remote address. */ | |
9461 | if (p->su_remote) { | |
9462 | if (use_json) { | |
9463 | json_object_string_add(json_neigh, "hostForeign", | |
9464 | sockunion2str(p->su_remote, buf1, | |
9465 | SU_ADDRSTRLEN)); | |
9466 | json_object_int_add(json_neigh, "portForeign", | |
9467 | ntohs(p->su_remote->sin.sin_port)); | |
9468 | } else | |
9469 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
9470 | sockunion2str(p->su_remote, buf1, | |
9471 | SU_ADDRSTRLEN), | |
9472 | ntohs(p->su_remote->sin.sin_port)); | |
9473 | } | |
9474 | ||
9475 | /* Nexthop display. */ | |
9476 | if (p->su_local) { | |
9477 | if (use_json) { | |
9478 | json_object_string_add(json_neigh, "nexthop", | |
9479 | inet_ntop(AF_INET, | |
9480 | &p->nexthop.v4, buf1, | |
9481 | sizeof(buf1))); | |
9482 | json_object_string_add(json_neigh, "nexthopGlobal", | |
9483 | inet_ntop(AF_INET6, | |
9484 | &p->nexthop.v6_global, | |
9485 | buf1, sizeof(buf1))); | |
9486 | json_object_string_add(json_neigh, "nexthopLocal", | |
9487 | inet_ntop(AF_INET6, | |
9488 | &p->nexthop.v6_local, | |
9489 | buf1, sizeof(buf1))); | |
9490 | if (p->shared_network) | |
9491 | json_object_string_add(json_neigh, | |
9492 | "bgpConnection", | |
9493 | "sharedNetwork"); | |
9494 | else | |
9495 | json_object_string_add(json_neigh, | |
9496 | "bgpConnection", | |
9497 | "nonSharedNetwork"); | |
9498 | } else { | |
9499 | vty_out(vty, "Nexthop: %s\n", | |
9500 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
9501 | sizeof(buf1))); | |
9502 | vty_out(vty, "Nexthop global: %s\n", | |
9503 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
9504 | sizeof(buf1))); | |
9505 | vty_out(vty, "Nexthop local: %s\n", | |
9506 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
9507 | sizeof(buf1))); | |
9508 | vty_out(vty, "BGP connection: %s\n", | |
9509 | p->shared_network ? "shared network" | |
9510 | : "non shared network"); | |
9511 | } | |
9512 | } | |
9513 | ||
9514 | /* Timer information. */ | |
9515 | if (use_json) { | |
9516 | json_object_int_add(json_neigh, "connectRetryTimer", | |
9517 | p->v_connect); | |
9518 | if (p->status == Established && p->rtt) | |
9519 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
9520 | p->rtt); | |
9521 | if (p->t_start) | |
9522 | json_object_int_add( | |
9523 | json_neigh, "nextStartTimerDueInMsecs", | |
9524 | thread_timer_remain_second(p->t_start) * 1000); | |
9525 | if (p->t_connect) | |
9526 | json_object_int_add( | |
9527 | json_neigh, "nextConnectTimerDueInMsecs", | |
9528 | thread_timer_remain_second(p->t_connect) | |
9529 | * 1000); | |
9530 | if (p->t_routeadv) { | |
9531 | json_object_int_add(json_neigh, "mraiInterval", | |
9532 | p->v_routeadv); | |
9533 | json_object_int_add( | |
9534 | json_neigh, "mraiTimerExpireInMsecs", | |
9535 | thread_timer_remain_second(p->t_routeadv) | |
9536 | * 1000); | |
9537 | } | |
9538 | if (p->password) | |
9539 | json_object_int_add(json_neigh, "authenticationEnabled", | |
9540 | 1); | |
9541 | ||
9542 | if (p->t_read) | |
9543 | json_object_string_add(json_neigh, "readThread", "on"); | |
9544 | else | |
9545 | json_object_string_add(json_neigh, "readThread", "off"); | |
9546 | if (p->t_write) | |
9547 | json_object_string_add(json_neigh, "writeThread", "on"); | |
9548 | else | |
9549 | json_object_string_add(json_neigh, "writeThread", | |
9550 | "off"); | |
9551 | } else { | |
9552 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
9553 | p->v_connect); | |
9554 | if (p->status == Established && p->rtt) | |
9555 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
9556 | p->rtt); | |
9557 | if (p->t_start) | |
9558 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
9559 | thread_timer_remain_second(p->t_start)); | |
9560 | if (p->t_connect) | |
9561 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
9562 | thread_timer_remain_second(p->t_connect)); | |
9563 | if (p->t_routeadv) | |
9564 | vty_out(vty, | |
9565 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
9566 | p->v_routeadv, | |
9567 | thread_timer_remain_second(p->t_routeadv)); | |
9568 | if (p->password) | |
9569 | vty_out(vty, "Peer Authentication Enabled\n"); | |
9570 | ||
9571 | vty_out(vty, "Read thread: %s Write thread: %s\n", | |
9572 | p->t_read ? "on" : "off", p->t_write ? "on" : "off"); | |
9573 | } | |
9574 | ||
9575 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
9576 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
9577 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
9578 | ||
9579 | if (!use_json) | |
9580 | vty_out(vty, "\n"); | |
9581 | ||
9582 | /* BFD information. */ | |
9583 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
9584 | ||
9585 | if (use_json) { | |
9586 | if (p->conf_if) /* Configured interface name. */ | |
9587 | json_object_object_add(json, p->conf_if, json_neigh); | |
9588 | else /* Configured IP address. */ | |
9589 | json_object_object_add(json, p->host, json_neigh); | |
9590 | } | |
9591 | } | |
9592 | ||
9593 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, | |
9594 | enum show_type type, union sockunion *su, | |
9595 | const char *conf_if, u_char use_json, | |
9596 | json_object *json) | |
9597 | { | |
9598 | struct listnode *node, *nnode; | |
9599 | struct peer *peer; | |
9600 | int find = 0; | |
9601 | ||
9602 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
9603 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
9604 | continue; | |
9605 | ||
9606 | switch (type) { | |
9607 | case show_all: | |
9608 | bgp_show_peer(vty, peer, use_json, json); | |
9609 | break; | |
9610 | case show_peer: | |
9611 | if (conf_if) { | |
9612 | if ((peer->conf_if | |
9613 | && !strcmp(peer->conf_if, conf_if)) | |
9614 | || (peer->hostname | |
9615 | && !strcmp(peer->hostname, conf_if))) { | |
9616 | find = 1; | |
9617 | bgp_show_peer(vty, peer, use_json, | |
9618 | json); | |
9619 | } | |
9620 | } else { | |
9621 | if (sockunion_same(&peer->su, su)) { | |
9622 | find = 1; | |
9623 | bgp_show_peer(vty, peer, use_json, | |
9624 | json); | |
9625 | } | |
9626 | } | |
9627 | break; | |
9628 | } | |
9629 | } | |
9630 | ||
9631 | if (type == show_peer && !find) { | |
9632 | if (use_json) | |
9633 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
9634 | else | |
9635 | vty_out(vty, "%% No such neighbor\n"); | |
9636 | } | |
9637 | ||
9638 | if (use_json) { | |
c14777c6 | 9639 | vty_out(vty, "%s\n", |
9640 | json_object_to_json_string_ext( | |
9641 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9642 | json_object_free(json); |
9643 | } else { | |
9644 | vty_out(vty, "\n"); | |
9645 | } | |
9646 | ||
9647 | return CMD_SUCCESS; | |
9648 | } | |
9649 | ||
9650 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, | |
9651 | u_char use_json) | |
9652 | { | |
9653 | struct listnode *node, *nnode; | |
9654 | struct bgp *bgp; | |
9655 | json_object *json = NULL; | |
9656 | int is_first = 1; | |
9657 | ||
9658 | if (use_json) | |
9659 | vty_out(vty, "{\n"); | |
9660 | ||
9661 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9662 | if (use_json) { | |
9663 | if (!(json = json_object_new_object())) { | |
9664 | zlog_err( | |
9665 | "Unable to allocate memory for JSON object"); | |
9666 | vty_out(vty, | |
9667 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
9668 | return; | |
9669 | } | |
9670 | ||
9671 | json_object_int_add(json, "vrfId", | |
9672 | (bgp->vrf_id == VRF_UNKNOWN) | |
9673 | ? -1 | |
9674 | : bgp->vrf_id); | |
9675 | json_object_string_add( | |
9676 | json, "vrfName", | |
9677 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9678 | ? "Default" | |
9679 | : bgp->name); | |
9680 | ||
9681 | if (!is_first) | |
9682 | vty_out(vty, ",\n"); | |
9683 | else | |
9684 | is_first = 0; | |
9685 | ||
9686 | vty_out(vty, "\"%s\":", | |
9687 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9688 | ? "Default" | |
9689 | : bgp->name); | |
9690 | } else { | |
9691 | vty_out(vty, "\nInstance %s:\n", | |
9692 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9693 | ? "Default" | |
9694 | : bgp->name); | |
9695 | } | |
9696 | bgp_show_neighbor(vty, bgp, show_all, NULL, NULL, use_json, | |
9697 | json); | |
9698 | } | |
9699 | ||
9700 | if (use_json) | |
9701 | vty_out(vty, "}\n"); | |
9702 | } | |
9703 | ||
9704 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
9705 | enum show_type type, const char *ip_str, | |
9706 | u_char use_json) | |
9707 | { | |
9708 | int ret; | |
9709 | struct bgp *bgp; | |
9710 | union sockunion su; | |
9711 | json_object *json = NULL; | |
9712 | ||
9713 | if (name) { | |
9714 | if (strmatch(name, "all")) { | |
9715 | bgp_show_all_instances_neighbors_vty(vty, use_json); | |
9716 | return CMD_SUCCESS; | |
9717 | } else { | |
9718 | bgp = bgp_lookup_by_name(name); | |
9719 | if (!bgp) { | |
9720 | if (use_json) { | |
9721 | json = json_object_new_object(); | |
9722 | json_object_boolean_true_add( | |
9723 | json, "bgpNoSuchInstance"); | |
9724 | vty_out(vty, "%s\n", | |
9725 | json_object_to_json_string_ext( | |
9726 | json, | |
9727 | JSON_C_TO_STRING_PRETTY)); | |
9728 | json_object_free(json); | |
9729 | } else | |
9730 | vty_out(vty, | |
9731 | "%% No such BGP instance exist\n"); | |
9732 | ||
9733 | return CMD_WARNING; | |
9734 | } | |
9735 | } | |
9736 | } else { | |
9737 | bgp = bgp_get_default(); | |
9738 | } | |
9739 | ||
9740 | if (bgp) { | |
9741 | json = json_object_new_object(); | |
9742 | if (ip_str) { | |
9743 | ret = str2sockunion(ip_str, &su); | |
9744 | if (ret < 0) | |
9745 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
9746 | use_json, json); | |
9747 | else | |
9748 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
9749 | use_json, json); | |
9750 | } else { | |
9751 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
9752 | json); | |
9753 | } | |
9754 | json_object_free(json); | |
9755 | } | |
9756 | ||
9757 | return CMD_SUCCESS; | |
4fb25c53 DW |
9758 | } |
9759 | ||
716b2d8a | 9760 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 9761 | DEFUN (show_ip_bgp_neighbors, |
9762 | show_ip_bgp_neighbors_cmd, | |
18c57037 | 9763 | "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 | 9764 | SHOW_STR |
9765 | IP_STR | |
9766 | BGP_STR | |
f2a8972b | 9767 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
9768 | "Address Family\n" |
9769 | "Address Family\n" | |
91d37724 QY |
9770 | "Address Family\n" |
9771 | "Display information about all VPNv4 NLRIs\n" | |
9772 | "Display information for a route distinguisher\n" | |
9773 | "VPN Route Distinguisher\n" | |
718e3744 | 9774 | "Detailed information on TCP and BGP neighbor connections\n" |
9775 | "Neighbor to display information about\n" | |
a80beece | 9776 | "Neighbor to display information about\n" |
91d37724 | 9777 | "Neighbor on BGP configured interface\n" |
9973d184 | 9778 | JSON_STR) |
718e3744 | 9779 | { |
d62a17ae | 9780 | char *vrf = NULL; |
9781 | char *sh_arg = NULL; | |
9782 | enum show_type sh_type; | |
718e3744 | 9783 | |
d62a17ae | 9784 | u_char uj = use_json(argc, argv); |
718e3744 | 9785 | |
d62a17ae | 9786 | int idx = 0; |
718e3744 | 9787 | |
d62a17ae | 9788 | if (argv_find(argv, argc, "view", &idx) |
9789 | || argv_find(argv, argc, "vrf", &idx)) | |
9790 | vrf = argv[idx + 1]->arg; | |
718e3744 | 9791 | |
d62a17ae | 9792 | idx++; |
9793 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
9794 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
9795 | || argv_find(argv, argc, "WORD", &idx)) { | |
9796 | sh_type = show_peer; | |
9797 | sh_arg = argv[idx]->arg; | |
9798 | } else | |
9799 | sh_type = show_all; | |
856ca177 | 9800 | |
d62a17ae | 9801 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 9802 | } |
9803 | ||
716b2d8a | 9804 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 9805 | paths' and `show ip mbgp paths'. Those functions results are the |
9806 | same.*/ | |
f412b39a | 9807 | DEFUN (show_ip_bgp_paths, |
718e3744 | 9808 | show_ip_bgp_paths_cmd, |
46f296b4 | 9809 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 9810 | SHOW_STR |
9811 | IP_STR | |
9812 | BGP_STR | |
46f296b4 | 9813 | BGP_SAFI_HELP_STR |
718e3744 | 9814 | "Path information\n") |
9815 | { | |
d62a17ae | 9816 | vty_out(vty, "Address Refcnt Path\n"); |
9817 | aspath_print_all_vty(vty); | |
9818 | return CMD_SUCCESS; | |
718e3744 | 9819 | } |
9820 | ||
718e3744 | 9821 | #include "hash.h" |
9822 | ||
d62a17ae | 9823 | static void community_show_all_iterator(struct hash_backet *backet, |
9824 | struct vty *vty) | |
718e3744 | 9825 | { |
d62a17ae | 9826 | struct community *com; |
718e3744 | 9827 | |
d62a17ae | 9828 | com = (struct community *)backet->data; |
9829 | vty_out(vty, "[%p] (%ld) %s\n", (void *)backet, com->refcnt, | |
9830 | community_str(com)); | |
718e3744 | 9831 | } |
9832 | ||
9833 | /* Show BGP's community internal data. */ | |
f412b39a | 9834 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 9835 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 9836 | "show [ip] bgp community-info", |
718e3744 | 9837 | SHOW_STR |
9838 | IP_STR | |
9839 | BGP_STR | |
9840 | "List all bgp community information\n") | |
9841 | { | |
d62a17ae | 9842 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 9843 | |
d62a17ae | 9844 | hash_iterate(community_hash(), |
9845 | (void (*)(struct hash_backet *, | |
9846 | void *))community_show_all_iterator, | |
9847 | vty); | |
718e3744 | 9848 | |
d62a17ae | 9849 | return CMD_SUCCESS; |
718e3744 | 9850 | } |
9851 | ||
d62a17ae | 9852 | static void lcommunity_show_all_iterator(struct hash_backet *backet, |
9853 | struct vty *vty) | |
57d187bc | 9854 | { |
d62a17ae | 9855 | struct lcommunity *lcom; |
57d187bc | 9856 | |
d62a17ae | 9857 | lcom = (struct lcommunity *)backet->data; |
9858 | vty_out(vty, "[%p] (%ld) %s\n", (void *)backet, lcom->refcnt, | |
9859 | lcommunity_str(lcom)); | |
57d187bc JS |
9860 | } |
9861 | ||
9862 | /* Show BGP's community internal data. */ | |
9863 | DEFUN (show_ip_bgp_lcommunity_info, | |
9864 | show_ip_bgp_lcommunity_info_cmd, | |
9865 | "show ip bgp large-community-info", | |
9866 | SHOW_STR | |
9867 | IP_STR | |
9868 | BGP_STR | |
9869 | "List all bgp large-community information\n") | |
9870 | { | |
d62a17ae | 9871 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 9872 | |
d62a17ae | 9873 | hash_iterate(lcommunity_hash(), |
9874 | (void (*)(struct hash_backet *, | |
9875 | void *))lcommunity_show_all_iterator, | |
9876 | vty); | |
57d187bc | 9877 | |
d62a17ae | 9878 | return CMD_SUCCESS; |
57d187bc JS |
9879 | } |
9880 | ||
9881 | ||
f412b39a | 9882 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 9883 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 9884 | "show [ip] bgp attribute-info", |
718e3744 | 9885 | SHOW_STR |
9886 | IP_STR | |
9887 | BGP_STR | |
9888 | "List all bgp attribute information\n") | |
9889 | { | |
d62a17ae | 9890 | attr_show_all(vty); |
9891 | return CMD_SUCCESS; | |
718e3744 | 9892 | } |
6b0655a2 | 9893 | |
d62a17ae | 9894 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
9895 | safi_t safi) | |
f186de26 | 9896 | { |
d62a17ae | 9897 | struct listnode *node, *nnode; |
9898 | struct bgp *bgp; | |
f186de26 | 9899 | |
d62a17ae | 9900 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
9901 | vty_out(vty, "\nInstance %s:\n", | |
9902 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9903 | ? "Default" | |
9904 | : bgp->name); | |
9905 | update_group_show(bgp, afi, safi, vty, 0); | |
9906 | } | |
f186de26 | 9907 | } |
9908 | ||
d62a17ae | 9909 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
9910 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 9911 | { |
d62a17ae | 9912 | struct bgp *bgp; |
4fb25c53 | 9913 | |
d62a17ae | 9914 | if (name) { |
9915 | if (strmatch(name, "all")) { | |
9916 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
9917 | return CMD_SUCCESS; | |
9918 | } else { | |
9919 | bgp = bgp_lookup_by_name(name); | |
9920 | } | |
9921 | } else { | |
9922 | bgp = bgp_get_default(); | |
9923 | } | |
4fb25c53 | 9924 | |
d62a17ae | 9925 | if (bgp) |
9926 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
9927 | return CMD_SUCCESS; | |
4fb25c53 DW |
9928 | } |
9929 | ||
8fe8a7f6 DS |
9930 | DEFUN (show_ip_bgp_updgrps, |
9931 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 9932 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 9933 | SHOW_STR |
9934 | IP_STR | |
9935 | BGP_STR | |
9936 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 9937 | BGP_AFI_HELP_STR |
9bedbb1e | 9938 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
9939 | "Detailed info about dynamic update groups\n" |
9940 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 9941 | { |
d62a17ae | 9942 | char *vrf = NULL; |
9943 | afi_t afi = AFI_IP6; | |
9944 | safi_t safi = SAFI_UNICAST; | |
9945 | uint64_t subgrp_id = 0; | |
9946 | ||
9947 | int idx = 0; | |
9948 | ||
9949 | /* show [ip] bgp */ | |
9950 | if (argv_find(argv, argc, "ip", &idx)) | |
9951 | afi = AFI_IP; | |
9952 | /* [<view|vrf> VIEWVRFNAME] */ | |
9953 | if (argv_find(argv, argc, "view", &idx) | |
9954 | || argv_find(argv, argc, "vrf", &idx)) | |
9955 | vrf = argv[++idx]->arg; | |
9956 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
9957 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
9958 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
9959 | } | |
5bf15956 | 9960 | |
d62a17ae | 9961 | /* get subgroup id, if provided */ |
9962 | idx = argc - 1; | |
9963 | if (argv[idx]->type == VARIABLE_TKN) | |
9964 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 9965 | |
d62a17ae | 9966 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
9967 | } |
9968 | ||
f186de26 | 9969 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
9970 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 9971 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 9972 | SHOW_STR |
716b2d8a | 9973 | IP_STR |
f186de26 | 9974 | BGP_STR |
9975 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 9976 | "Detailed info about dynamic update groups\n") |
f186de26 | 9977 | { |
d62a17ae | 9978 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
9979 | return CMD_SUCCESS; | |
f186de26 | 9980 | } |
9981 | ||
5bf15956 DW |
9982 | DEFUN (show_bgp_updgrps_stats, |
9983 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 9984 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 9985 | SHOW_STR |
716b2d8a | 9986 | IP_STR |
3f9c7369 | 9987 | BGP_STR |
0c7b1b01 | 9988 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
9989 | "Statistics\n") |
9990 | { | |
d62a17ae | 9991 | struct bgp *bgp; |
3f9c7369 | 9992 | |
d62a17ae | 9993 | bgp = bgp_get_default(); |
9994 | if (bgp) | |
9995 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 9996 | |
d62a17ae | 9997 | return CMD_SUCCESS; |
3f9c7369 DS |
9998 | } |
9999 | ||
8386ac43 | 10000 | DEFUN (show_bgp_instance_updgrps_stats, |
10001 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 10002 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 10003 | SHOW_STR |
716b2d8a | 10004 | IP_STR |
8386ac43 | 10005 | BGP_STR |
10006 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10007 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10008 | "Statistics\n") |
10009 | { | |
d62a17ae | 10010 | int idx_word = 3; |
10011 | struct bgp *bgp; | |
8386ac43 | 10012 | |
d62a17ae | 10013 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
10014 | if (bgp) | |
10015 | update_group_show_stats(bgp, vty); | |
8386ac43 | 10016 | |
d62a17ae | 10017 | return CMD_SUCCESS; |
8386ac43 | 10018 | } |
10019 | ||
d62a17ae | 10020 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
10021 | afi_t afi, safi_t safi, | |
10022 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 10023 | { |
d62a17ae | 10024 | struct bgp *bgp; |
8386ac43 | 10025 | |
d62a17ae | 10026 | if (name) |
10027 | bgp = bgp_lookup_by_name(name); | |
10028 | else | |
10029 | bgp = bgp_get_default(); | |
8386ac43 | 10030 | |
d62a17ae | 10031 | if (bgp) { |
10032 | if (!strcmp(what, "advertise-queue")) | |
10033 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
10034 | subgrp_id); | |
10035 | else if (!strcmp(what, "advertised-routes")) | |
10036 | update_group_show_advertised(bgp, afi, safi, vty, | |
10037 | subgrp_id); | |
10038 | else if (!strcmp(what, "packet-queue")) | |
10039 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
10040 | subgrp_id); | |
10041 | } | |
3f9c7369 DS |
10042 | } |
10043 | ||
10044 | DEFUN (show_ip_bgp_updgrps_adj, | |
10045 | show_ip_bgp_updgrps_adj_cmd, | |
716b2d8a | 10046 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
10047 | SHOW_STR |
10048 | IP_STR | |
10049 | BGP_STR | |
0c7b1b01 | 10050 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
10051 | "Advertisement queue\n" |
10052 | "Announced routes\n" | |
10053 | "Packet queue\n") | |
10054 | { | |
d62a17ae | 10055 | int idx_type = 4; |
10056 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, | |
10057 | argv[idx_type]->arg, 0); | |
10058 | return CMD_SUCCESS; | |
8386ac43 | 10059 | } |
10060 | ||
10061 | DEFUN (show_ip_bgp_instance_updgrps_adj, | |
10062 | show_ip_bgp_instance_updgrps_adj_cmd, | |
18c57037 | 10063 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10064 | SHOW_STR |
10065 | IP_STR | |
10066 | BGP_STR | |
10067 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10068 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10069 | "Advertisement queue\n" |
10070 | "Announced routes\n" | |
10071 | "Packet queue\n") | |
8386ac43 | 10072 | { |
d62a17ae | 10073 | int idx_word = 4; |
10074 | int idx_type = 6; | |
10075 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, | |
10076 | SAFI_UNICAST, argv[idx_type]->arg, 0); | |
10077 | return CMD_SUCCESS; | |
3f9c7369 DS |
10078 | } |
10079 | ||
10080 | DEFUN (show_bgp_updgrps_afi_adj, | |
10081 | show_bgp_updgrps_afi_adj_cmd, | |
46f296b4 | 10082 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 10083 | SHOW_STR |
716b2d8a | 10084 | IP_STR |
3f9c7369 | 10085 | BGP_STR |
46f296b4 | 10086 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 10087 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
10088 | "Advertisement queue\n" |
10089 | "Announced routes\n" | |
7111c1a0 | 10090 | "Packet queue\n") |
3f9c7369 | 10091 | { |
d62a17ae | 10092 | int idx_afi = 2; |
10093 | int idx_safi = 3; | |
10094 | int idx_type = 5; | |
10095 | show_bgp_updgrps_adj_info_aux( | |
10096 | vty, NULL, bgp_vty_afi_from_str(argv[idx_afi]->text), | |
10097 | bgp_vty_safi_from_str(argv[idx_safi]->text), | |
10098 | argv[idx_type]->arg, 0); | |
10099 | return CMD_SUCCESS; | |
3f9c7369 DS |
10100 | } |
10101 | ||
10102 | DEFUN (show_bgp_updgrps_adj, | |
10103 | show_bgp_updgrps_adj_cmd, | |
716b2d8a | 10104 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 10105 | SHOW_STR |
716b2d8a | 10106 | IP_STR |
3f9c7369 | 10107 | BGP_STR |
0c7b1b01 | 10108 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
10109 | "Advertisement queue\n" |
10110 | "Announced routes\n" | |
10111 | "Packet queue\n") | |
10112 | { | |
d62a17ae | 10113 | int idx_type = 3; |
10114 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, | |
10115 | argv[idx_type]->arg, 0); | |
10116 | return CMD_SUCCESS; | |
8386ac43 | 10117 | } |
10118 | ||
10119 | DEFUN (show_bgp_instance_updgrps_adj, | |
10120 | show_bgp_instance_updgrps_adj_cmd, | |
18c57037 | 10121 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10122 | SHOW_STR |
716b2d8a | 10123 | IP_STR |
8386ac43 | 10124 | BGP_STR |
10125 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10126 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10127 | "Advertisement queue\n" |
10128 | "Announced routes\n" | |
10129 | "Packet queue\n") | |
10130 | { | |
d62a17ae | 10131 | int idx_word = 3; |
10132 | int idx_type = 5; | |
10133 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, | |
10134 | SAFI_UNICAST, argv[idx_type]->arg, 0); | |
10135 | return CMD_SUCCESS; | |
3f9c7369 DS |
10136 | } |
10137 | ||
10138 | DEFUN (show_ip_bgp_updgrps_adj_s, | |
8fe8a7f6 | 10139 | show_ip_bgp_updgrps_adj_s_cmd, |
716b2d8a | 10140 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
10141 | SHOW_STR |
10142 | IP_STR | |
10143 | BGP_STR | |
0c7b1b01 | 10144 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 10145 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
10146 | "Advertisement queue\n" |
10147 | "Announced routes\n" | |
10148 | "Packet queue\n") | |
3f9c7369 | 10149 | { |
d62a17ae | 10150 | int idx_subgroup_id = 4; |
10151 | int idx_type = 5; | |
10152 | uint64_t subgrp_id; | |
8fe8a7f6 | 10153 | |
d62a17ae | 10154 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8fe8a7f6 | 10155 | |
d62a17ae | 10156 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, |
10157 | argv[idx_type]->arg, subgrp_id); | |
10158 | return CMD_SUCCESS; | |
8386ac43 | 10159 | } |
10160 | ||
10161 | DEFUN (show_ip_bgp_instance_updgrps_adj_s, | |
10162 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
18c57037 | 10163 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10164 | SHOW_STR |
10165 | IP_STR | |
10166 | BGP_STR | |
10167 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10168 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10169 | "Specific subgroup to display info for\n" |
10170 | "Advertisement queue\n" | |
10171 | "Announced routes\n" | |
10172 | "Packet queue\n") | |
8386ac43 | 10173 | { |
d62a17ae | 10174 | int idx_vrf = 4; |
10175 | int idx_subgroup_id = 6; | |
10176 | int idx_type = 7; | |
10177 | uint64_t subgrp_id; | |
8386ac43 | 10178 | |
d62a17ae | 10179 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8386ac43 | 10180 | |
d62a17ae | 10181 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP, |
10182 | SAFI_UNICAST, argv[idx_type]->arg, | |
10183 | subgrp_id); | |
10184 | return CMD_SUCCESS; | |
3f9c7369 DS |
10185 | } |
10186 | ||
8fe8a7f6 DS |
10187 | DEFUN (show_bgp_updgrps_afi_adj_s, |
10188 | show_bgp_updgrps_afi_adj_s_cmd, | |
46f296b4 | 10189 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 10190 | SHOW_STR |
716b2d8a | 10191 | IP_STR |
3f9c7369 | 10192 | BGP_STR |
46f296b4 | 10193 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 10194 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 10195 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
10196 | "Advertisement queue\n" |
10197 | "Announced routes\n" | |
7111c1a0 | 10198 | "Packet queue\n") |
3f9c7369 | 10199 | { |
d62a17ae | 10200 | int idx_afi = 2; |
10201 | int idx_safi = 3; | |
10202 | int idx_subgroup_id = 5; | |
10203 | int idx_type = 6; | |
10204 | uint64_t subgrp_id; | |
3f9c7369 | 10205 | |
d62a17ae | 10206 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8fe8a7f6 | 10207 | |
d62a17ae | 10208 | show_bgp_updgrps_adj_info_aux( |
10209 | vty, NULL, bgp_vty_afi_from_str(argv[idx_afi]->text), | |
10210 | bgp_vty_safi_from_str(argv[idx_safi]->text), | |
10211 | argv[idx_type]->arg, subgrp_id); | |
10212 | return CMD_SUCCESS; | |
3f9c7369 DS |
10213 | } |
10214 | ||
8fe8a7f6 DS |
10215 | DEFUN (show_bgp_updgrps_adj_s, |
10216 | show_bgp_updgrps_adj_s_cmd, | |
716b2d8a | 10217 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8fe8a7f6 | 10218 | SHOW_STR |
716b2d8a | 10219 | IP_STR |
8fe8a7f6 | 10220 | BGP_STR |
0c7b1b01 | 10221 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 DS |
10222 | "Specific subgroup to display info for\n" |
10223 | "Advertisement queue\n" | |
10224 | "Announced routes\n" | |
10225 | "Packet queue\n") | |
10226 | { | |
d62a17ae | 10227 | int idx_subgroup_id = 3; |
10228 | int idx_type = 4; | |
10229 | uint64_t subgrp_id; | |
8fe8a7f6 | 10230 | |
d62a17ae | 10231 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8fe8a7f6 | 10232 | |
d62a17ae | 10233 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, |
10234 | argv[idx_type]->arg, subgrp_id); | |
10235 | return CMD_SUCCESS; | |
8fe8a7f6 DS |
10236 | } |
10237 | ||
8386ac43 | 10238 | DEFUN (show_bgp_instance_updgrps_adj_s, |
10239 | show_bgp_instance_updgrps_adj_s_cmd, | |
18c57037 | 10240 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10241 | SHOW_STR |
716b2d8a | 10242 | IP_STR |
8386ac43 | 10243 | BGP_STR |
10244 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10245 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10246 | "Specific subgroup to display info for\n" |
10247 | "Advertisement queue\n" | |
10248 | "Announced routes\n" | |
10249 | "Packet queue\n") | |
10250 | { | |
d62a17ae | 10251 | int idx_vrf = 3; |
10252 | int idx_subgroup_id = 5; | |
10253 | int idx_type = 6; | |
10254 | uint64_t subgrp_id; | |
10255 | ||
10256 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); | |
10257 | ||
10258 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP6, | |
10259 | SAFI_UNICAST, argv[idx_type]->arg, | |
10260 | subgrp_id); | |
10261 | return CMD_SUCCESS; | |
10262 | } | |
10263 | ||
10264 | ||
10265 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) | |
10266 | { | |
10267 | struct listnode *node, *nnode; | |
10268 | struct prefix *range; | |
10269 | struct peer *conf; | |
10270 | struct peer *peer; | |
10271 | char buf[PREFIX2STR_BUFFER]; | |
10272 | afi_t afi; | |
10273 | safi_t safi; | |
10274 | const char *peer_status; | |
10275 | const char *af_str; | |
10276 | int lr_count; | |
10277 | int dynamic; | |
10278 | int af_cfgd; | |
10279 | ||
10280 | conf = group->conf; | |
10281 | ||
10282 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
10283 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
10284 | conf->as); | |
10285 | } else if (conf->as_type == AS_INTERNAL) { | |
10286 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
10287 | group->bgp->as); | |
10288 | } else { | |
10289 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
10290 | } | |
f14e6fdb | 10291 | |
d62a17ae | 10292 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
10293 | vty_out(vty, " Peer-group type is internal\n"); | |
10294 | else | |
10295 | vty_out(vty, " Peer-group type is external\n"); | |
10296 | ||
10297 | /* Display AFs configured. */ | |
10298 | vty_out(vty, " Configured address-families:"); | |
10299 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
10300 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { | |
10301 | if (conf->afc[afi][safi]) { | |
10302 | af_cfgd = 1; | |
10303 | vty_out(vty, " %s;", afi_safi_print(afi, safi)); | |
10304 | } | |
10305 | } | |
10306 | if (!af_cfgd) | |
10307 | vty_out(vty, " none\n"); | |
10308 | else | |
10309 | vty_out(vty, "\n"); | |
10310 | ||
10311 | /* Display listen ranges (for dynamic neighbors), if any */ | |
10312 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
10313 | if (afi == AFI_IP) | |
10314 | af_str = "IPv4"; | |
10315 | else if (afi == AFI_IP6) | |
10316 | af_str = "IPv6"; | |
10317 | else | |
10318 | af_str = "???"; | |
10319 | lr_count = listcount(group->listen_range[afi]); | |
10320 | if (lr_count) { | |
10321 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
10322 | af_str); | |
10323 | ||
10324 | ||
10325 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
10326 | nnode, range)) { | |
10327 | prefix2str(range, buf, sizeof(buf)); | |
10328 | vty_out(vty, " %s\n", buf); | |
10329 | } | |
10330 | } | |
10331 | } | |
f14e6fdb | 10332 | |
d62a17ae | 10333 | /* Display group members and their status */ |
10334 | if (listcount(group->peer)) { | |
10335 | vty_out(vty, " Peer-group members:\n"); | |
10336 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
10337 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
10338 | peer_status = "Idle (Admin)"; | |
10339 | else if (CHECK_FLAG(peer->sflags, | |
10340 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10341 | peer_status = "Idle (PfxCt)"; | |
10342 | else | |
10343 | peer_status = lookup_msg(bgp_status_msg, | |
10344 | peer->status, NULL); | |
10345 | ||
10346 | dynamic = peer_dynamic_neighbor(peer); | |
10347 | vty_out(vty, " %s %s %s \n", peer->host, | |
10348 | dynamic ? "(dynamic)" : "", peer_status); | |
10349 | } | |
10350 | } | |
f14e6fdb | 10351 | |
d62a17ae | 10352 | return CMD_SUCCESS; |
10353 | } | |
10354 | ||
10355 | /* Show BGP peer group's information. */ | |
10356 | enum show_group_type { show_all_groups, show_peer_group }; | |
10357 | ||
10358 | static int bgp_show_peer_group(struct vty *vty, struct bgp *bgp, | |
10359 | enum show_group_type type, | |
10360 | const char *group_name) | |
10361 | { | |
10362 | struct listnode *node, *nnode; | |
10363 | struct peer_group *group; | |
10364 | int find = 0; | |
10365 | ||
10366 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
10367 | switch (type) { | |
10368 | case show_all_groups: | |
10369 | bgp_show_one_peer_group(vty, group); | |
10370 | break; | |
10371 | case show_peer_group: | |
10372 | if (group_name | |
10373 | && (strcmp(group->name, group_name) == 0)) { | |
10374 | find = 1; | |
10375 | bgp_show_one_peer_group(vty, group); | |
10376 | } | |
10377 | break; | |
10378 | } | |
f14e6fdb | 10379 | } |
f14e6fdb | 10380 | |
d62a17ae | 10381 | if (type == show_peer_group && !find) |
10382 | vty_out(vty, "%% No such peer-group\n"); | |
f14e6fdb | 10383 | |
d62a17ae | 10384 | return CMD_SUCCESS; |
f14e6fdb DS |
10385 | } |
10386 | ||
d62a17ae | 10387 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
10388 | enum show_group_type type, | |
10389 | const char *group_name) | |
f14e6fdb | 10390 | { |
d62a17ae | 10391 | struct bgp *bgp; |
10392 | int ret = CMD_SUCCESS; | |
f14e6fdb | 10393 | |
d62a17ae | 10394 | if (name) |
10395 | bgp = bgp_lookup_by_name(name); | |
10396 | else | |
10397 | bgp = bgp_get_default(); | |
f14e6fdb | 10398 | |
d62a17ae | 10399 | if (!bgp) { |
10400 | vty_out(vty, "%% No such BGP instance exist\n"); | |
10401 | return CMD_WARNING; | |
10402 | } | |
f14e6fdb | 10403 | |
d62a17ae | 10404 | ret = bgp_show_peer_group(vty, bgp, type, group_name); |
f14e6fdb | 10405 | |
d62a17ae | 10406 | return ret; |
f14e6fdb DS |
10407 | } |
10408 | ||
10409 | DEFUN (show_ip_bgp_peer_groups, | |
10410 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 10411 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
10412 | SHOW_STR |
10413 | IP_STR | |
10414 | BGP_STR | |
8386ac43 | 10415 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
10416 | "Detailed information on BGP peer groups\n" |
10417 | "Peer group name\n") | |
f14e6fdb | 10418 | { |
d62a17ae | 10419 | char *vrf, *pg; |
10420 | vrf = pg = NULL; | |
10421 | int idx = 0; | |
f14e6fdb | 10422 | |
d62a17ae | 10423 | vrf = argv_find(argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL; |
10424 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; | |
f14e6fdb | 10425 | |
d62a17ae | 10426 | return bgp_show_peer_group_vty(vty, vrf, show_all_groups, pg); |
f14e6fdb | 10427 | } |
3f9c7369 | 10428 | |
d6e3c605 | 10429 | |
718e3744 | 10430 | /* Redistribute VTY commands. */ |
10431 | ||
718e3744 | 10432 | DEFUN (bgp_redistribute_ipv4, |
10433 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 10434 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 10435 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10436 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 10437 | { |
d62a17ae | 10438 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10439 | int idx_protocol = 1; | |
10440 | int type; | |
718e3744 | 10441 | |
d62a17ae | 10442 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
10443 | if (type < 0) { | |
10444 | vty_out(vty, "%% Invalid route type\n"); | |
10445 | return CMD_WARNING_CONFIG_FAILED; | |
10446 | } | |
10447 | bgp_redist_add(bgp, AFI_IP, type, 0); | |
10448 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
718e3744 | 10449 | } |
10450 | ||
d62a17ae | 10451 | ALIAS_HIDDEN( |
10452 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
10453 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
10454 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 10455 | |
718e3744 | 10456 | DEFUN (bgp_redistribute_ipv4_rmap, |
10457 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 10458 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 10459 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10460 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10461 | "Route map reference\n" |
10462 | "Pointer to route-map entries\n") | |
10463 | { | |
d62a17ae | 10464 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10465 | int idx_protocol = 1; | |
10466 | int idx_word = 3; | |
10467 | int type; | |
10468 | struct bgp_redist *red; | |
718e3744 | 10469 | |
d62a17ae | 10470 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
10471 | if (type < 0) { | |
10472 | vty_out(vty, "%% Invalid route type\n"); | |
10473 | return CMD_WARNING_CONFIG_FAILED; | |
10474 | } | |
718e3744 | 10475 | |
d62a17ae | 10476 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
10477 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10478 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
718e3744 | 10479 | } |
10480 | ||
d62a17ae | 10481 | ALIAS_HIDDEN( |
10482 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
10483 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
10484 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10485 | "Route map reference\n" | |
10486 | "Pointer to route-map entries\n") | |
596c17ba | 10487 | |
718e3744 | 10488 | DEFUN (bgp_redistribute_ipv4_metric, |
10489 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 10490 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 10491 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10492 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10493 | "Metric for redistributed routes\n" |
10494 | "Default metric\n") | |
10495 | { | |
d62a17ae | 10496 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10497 | int idx_protocol = 1; | |
10498 | int idx_number = 3; | |
10499 | int type; | |
10500 | u_int32_t metric; | |
10501 | struct bgp_redist *red; | |
10502 | ||
10503 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
10504 | if (type < 0) { | |
10505 | vty_out(vty, "%% Invalid route type\n"); | |
10506 | return CMD_WARNING_CONFIG_FAILED; | |
10507 | } | |
10508 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
10509 | ||
10510 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
10511 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
10512 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
10513 | } | |
10514 | ||
10515 | ALIAS_HIDDEN( | |
10516 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
10517 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
10518 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10519 | "Metric for redistributed routes\n" | |
10520 | "Default metric\n") | |
596c17ba | 10521 | |
718e3744 | 10522 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
10523 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 10524 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 10525 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10526 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10527 | "Route map reference\n" |
10528 | "Pointer to route-map entries\n" | |
10529 | "Metric for redistributed routes\n" | |
10530 | "Default metric\n") | |
10531 | { | |
d62a17ae | 10532 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10533 | int idx_protocol = 1; | |
10534 | int idx_word = 3; | |
10535 | int idx_number = 5; | |
10536 | int type; | |
10537 | u_int32_t metric; | |
10538 | struct bgp_redist *red; | |
10539 | ||
10540 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
10541 | if (type < 0) { | |
10542 | vty_out(vty, "%% Invalid route type\n"); | |
10543 | return CMD_WARNING_CONFIG_FAILED; | |
10544 | } | |
10545 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
10546 | ||
10547 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
10548 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10549 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
10550 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
10551 | } | |
10552 | ||
10553 | ALIAS_HIDDEN( | |
10554 | bgp_redistribute_ipv4_rmap_metric, | |
10555 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
10556 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
10557 | " route-map WORD metric (0-4294967295)", | |
10558 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10559 | "Route map reference\n" | |
10560 | "Pointer to route-map entries\n" | |
10561 | "Metric for redistributed routes\n" | |
10562 | "Default metric\n") | |
596c17ba | 10563 | |
718e3744 | 10564 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
10565 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 10566 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 10567 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10568 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10569 | "Metric for redistributed routes\n" |
10570 | "Default metric\n" | |
10571 | "Route map reference\n" | |
10572 | "Pointer to route-map entries\n") | |
10573 | { | |
d62a17ae | 10574 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10575 | int idx_protocol = 1; | |
10576 | int idx_number = 3; | |
10577 | int idx_word = 5; | |
10578 | int type; | |
10579 | u_int32_t metric; | |
10580 | struct bgp_redist *red; | |
10581 | ||
10582 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
10583 | if (type < 0) { | |
10584 | vty_out(vty, "%% Invalid route type\n"); | |
10585 | return CMD_WARNING_CONFIG_FAILED; | |
10586 | } | |
10587 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
10588 | ||
10589 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
10590 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
10591 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10592 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
10593 | } | |
10594 | ||
10595 | ALIAS_HIDDEN( | |
10596 | bgp_redistribute_ipv4_metric_rmap, | |
10597 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
10598 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
10599 | " metric (0-4294967295) route-map WORD", | |
10600 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10601 | "Metric for redistributed routes\n" | |
10602 | "Default metric\n" | |
10603 | "Route map reference\n" | |
10604 | "Pointer to route-map entries\n") | |
596c17ba | 10605 | |
7c8ff89e DS |
10606 | DEFUN (bgp_redistribute_ipv4_ospf, |
10607 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 10608 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
10609 | "Redistribute information from another routing protocol\n" |
10610 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10611 | "Non-main Kernel Routing Table\n" |
10612 | "Instance ID/Table ID\n") | |
7c8ff89e | 10613 | { |
d62a17ae | 10614 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10615 | int idx_ospf_table = 1; | |
10616 | int idx_number = 2; | |
10617 | u_short instance; | |
10618 | u_short protocol; | |
7c8ff89e | 10619 | |
d62a17ae | 10620 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 10621 | |
d62a17ae | 10622 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
10623 | protocol = ZEBRA_ROUTE_OSPF; | |
10624 | else | |
10625 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 10626 | |
d62a17ae | 10627 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
10628 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
10629 | } |
10630 | ||
d62a17ae | 10631 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
10632 | "redistribute <ospf|table> (1-65535)", | |
10633 | "Redistribute information from another routing protocol\n" | |
10634 | "Open Shortest Path First (OSPFv2)\n" | |
10635 | "Non-main Kernel Routing Table\n" | |
10636 | "Instance ID/Table ID\n") | |
596c17ba | 10637 | |
7c8ff89e DS |
10638 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
10639 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 10640 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
10641 | "Redistribute information from another routing protocol\n" |
10642 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10643 | "Non-main Kernel Routing Table\n" |
10644 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10645 | "Route map reference\n" |
10646 | "Pointer to route-map entries\n") | |
10647 | { | |
d62a17ae | 10648 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10649 | int idx_ospf_table = 1; | |
10650 | int idx_number = 2; | |
10651 | int idx_word = 4; | |
10652 | struct bgp_redist *red; | |
10653 | u_short instance; | |
10654 | int protocol; | |
10655 | ||
10656 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10657 | protocol = ZEBRA_ROUTE_OSPF; | |
10658 | else | |
10659 | protocol = ZEBRA_ROUTE_TABLE; | |
10660 | ||
10661 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10662 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
10663 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10664 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
10665 | } | |
10666 | ||
10667 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
10668 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
10669 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
10670 | "Redistribute information from another routing protocol\n" | |
10671 | "Open Shortest Path First (OSPFv2)\n" | |
10672 | "Non-main Kernel Routing Table\n" | |
10673 | "Instance ID/Table ID\n" | |
10674 | "Route map reference\n" | |
10675 | "Pointer to route-map entries\n") | |
596c17ba | 10676 | |
7c8ff89e DS |
10677 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
10678 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 10679 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
10680 | "Redistribute information from another routing protocol\n" |
10681 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10682 | "Non-main Kernel Routing Table\n" |
10683 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10684 | "Metric for redistributed routes\n" |
10685 | "Default metric\n") | |
10686 | { | |
d62a17ae | 10687 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10688 | int idx_ospf_table = 1; | |
10689 | int idx_number = 2; | |
10690 | int idx_number_2 = 4; | |
10691 | u_int32_t metric; | |
10692 | struct bgp_redist *red; | |
10693 | u_short instance; | |
10694 | int protocol; | |
10695 | ||
10696 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10697 | protocol = ZEBRA_ROUTE_OSPF; | |
10698 | else | |
10699 | protocol = ZEBRA_ROUTE_TABLE; | |
10700 | ||
10701 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10702 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
10703 | ||
10704 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
10705 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
10706 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
10707 | } | |
10708 | ||
10709 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
10710 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
10711 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
10712 | "Redistribute information from another routing protocol\n" | |
10713 | "Open Shortest Path First (OSPFv2)\n" | |
10714 | "Non-main Kernel Routing Table\n" | |
10715 | "Instance ID/Table ID\n" | |
10716 | "Metric for redistributed routes\n" | |
10717 | "Default metric\n") | |
596c17ba | 10718 | |
7c8ff89e DS |
10719 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
10720 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 10721 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
10722 | "Redistribute information from another routing protocol\n" |
10723 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10724 | "Non-main Kernel Routing Table\n" |
10725 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10726 | "Route map reference\n" |
10727 | "Pointer to route-map entries\n" | |
10728 | "Metric for redistributed routes\n" | |
10729 | "Default metric\n") | |
10730 | { | |
d62a17ae | 10731 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10732 | int idx_ospf_table = 1; | |
10733 | int idx_number = 2; | |
10734 | int idx_word = 4; | |
10735 | int idx_number_2 = 6; | |
10736 | u_int32_t metric; | |
10737 | struct bgp_redist *red; | |
10738 | u_short instance; | |
10739 | int protocol; | |
10740 | ||
10741 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10742 | protocol = ZEBRA_ROUTE_OSPF; | |
10743 | else | |
10744 | protocol = ZEBRA_ROUTE_TABLE; | |
10745 | ||
10746 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10747 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
10748 | ||
10749 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
10750 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10751 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
10752 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
10753 | } | |
10754 | ||
10755 | ALIAS_HIDDEN( | |
10756 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
10757 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
10758 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
10759 | "Redistribute information from another routing protocol\n" | |
10760 | "Open Shortest Path First (OSPFv2)\n" | |
10761 | "Non-main Kernel Routing Table\n" | |
10762 | "Instance ID/Table ID\n" | |
10763 | "Route map reference\n" | |
10764 | "Pointer to route-map entries\n" | |
10765 | "Metric for redistributed routes\n" | |
10766 | "Default metric\n") | |
596c17ba | 10767 | |
7c8ff89e DS |
10768 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
10769 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 10770 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
10771 | "Redistribute information from another routing protocol\n" |
10772 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10773 | "Non-main Kernel Routing Table\n" |
10774 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10775 | "Metric for redistributed routes\n" |
10776 | "Default metric\n" | |
10777 | "Route map reference\n" | |
10778 | "Pointer to route-map entries\n") | |
10779 | { | |
d62a17ae | 10780 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10781 | int idx_ospf_table = 1; | |
10782 | int idx_number = 2; | |
10783 | int idx_number_2 = 4; | |
10784 | int idx_word = 6; | |
10785 | u_int32_t metric; | |
10786 | struct bgp_redist *red; | |
10787 | u_short instance; | |
10788 | int protocol; | |
10789 | ||
10790 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10791 | protocol = ZEBRA_ROUTE_OSPF; | |
10792 | else | |
10793 | protocol = ZEBRA_ROUTE_TABLE; | |
10794 | ||
10795 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10796 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
10797 | ||
10798 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
10799 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
10800 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10801 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
10802 | } | |
10803 | ||
10804 | ALIAS_HIDDEN( | |
10805 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
10806 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
10807 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
10808 | "Redistribute information from another routing protocol\n" | |
10809 | "Open Shortest Path First (OSPFv2)\n" | |
10810 | "Non-main Kernel Routing Table\n" | |
10811 | "Instance ID/Table ID\n" | |
10812 | "Metric for redistributed routes\n" | |
10813 | "Default metric\n" | |
10814 | "Route map reference\n" | |
10815 | "Pointer to route-map entries\n") | |
596c17ba | 10816 | |
7c8ff89e DS |
10817 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
10818 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 10819 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
10820 | NO_STR |
10821 | "Redistribute information from another routing protocol\n" | |
10822 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 10823 | "Non-main Kernel Routing Table\n" |
31500417 DW |
10824 | "Instance ID/Table ID\n" |
10825 | "Metric for redistributed routes\n" | |
10826 | "Default metric\n" | |
10827 | "Route map reference\n" | |
10828 | "Pointer to route-map entries\n") | |
7c8ff89e | 10829 | { |
d62a17ae | 10830 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10831 | int idx_ospf_table = 2; | |
10832 | int idx_number = 3; | |
10833 | u_short instance; | |
10834 | int protocol; | |
10835 | ||
10836 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10837 | protocol = ZEBRA_ROUTE_OSPF; | |
10838 | else | |
10839 | protocol = ZEBRA_ROUTE_TABLE; | |
10840 | ||
10841 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10842 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
10843 | } | |
10844 | ||
10845 | ALIAS_HIDDEN( | |
10846 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
10847 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", | |
10848 | NO_STR | |
10849 | "Redistribute information from another routing protocol\n" | |
10850 | "Open Shortest Path First (OSPFv2)\n" | |
10851 | "Non-main Kernel Routing Table\n" | |
10852 | "Instance ID/Table ID\n" | |
10853 | "Metric for redistributed routes\n" | |
10854 | "Default metric\n" | |
10855 | "Route map reference\n" | |
10856 | "Pointer to route-map entries\n") | |
596c17ba | 10857 | |
718e3744 | 10858 | DEFUN (no_bgp_redistribute_ipv4, |
10859 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 10860 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 10861 | NO_STR |
10862 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 10863 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
10864 | "Metric for redistributed routes\n" |
10865 | "Default metric\n" | |
10866 | "Route map reference\n" | |
10867 | "Pointer to route-map entries\n") | |
718e3744 | 10868 | { |
d62a17ae | 10869 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10870 | int idx_protocol = 2; | |
10871 | int type; | |
10872 | ||
10873 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
10874 | if (type < 0) { | |
10875 | vty_out(vty, "%% Invalid route type\n"); | |
10876 | return CMD_WARNING_CONFIG_FAILED; | |
10877 | } | |
10878 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
10879 | } | |
10880 | ||
10881 | ALIAS_HIDDEN( | |
10882 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
10883 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
10884 | " [metric (0-4294967295)] [route-map WORD]", | |
10885 | NO_STR | |
10886 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10887 | "Metric for redistributed routes\n" | |
10888 | "Default metric\n" | |
10889 | "Route map reference\n" | |
10890 | "Pointer to route-map entries\n") | |
596c17ba | 10891 | |
718e3744 | 10892 | DEFUN (bgp_redistribute_ipv6, |
10893 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 10894 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 10895 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10896 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 10897 | { |
d62a17ae | 10898 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10899 | int idx_protocol = 1; | |
10900 | int type; | |
718e3744 | 10901 | |
d62a17ae | 10902 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
10903 | if (type < 0) { | |
10904 | vty_out(vty, "%% Invalid route type\n"); | |
10905 | return CMD_WARNING_CONFIG_FAILED; | |
10906 | } | |
718e3744 | 10907 | |
d62a17ae | 10908 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
10909 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 10910 | } |
10911 | ||
10912 | DEFUN (bgp_redistribute_ipv6_rmap, | |
10913 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 10914 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 10915 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10916 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 10917 | "Route map reference\n" |
10918 | "Pointer to route-map entries\n") | |
10919 | { | |
d62a17ae | 10920 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10921 | int idx_protocol = 1; | |
10922 | int idx_word = 3; | |
10923 | int type; | |
10924 | struct bgp_redist *red; | |
718e3744 | 10925 | |
d62a17ae | 10926 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
10927 | if (type < 0) { | |
10928 | vty_out(vty, "%% Invalid route type\n"); | |
10929 | return CMD_WARNING_CONFIG_FAILED; | |
10930 | } | |
718e3744 | 10931 | |
d62a17ae | 10932 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
10933 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10934 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 10935 | } |
10936 | ||
10937 | DEFUN (bgp_redistribute_ipv6_metric, | |
10938 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 10939 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 10940 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10941 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 10942 | "Metric for redistributed routes\n" |
10943 | "Default metric\n") | |
10944 | { | |
d62a17ae | 10945 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10946 | int idx_protocol = 1; | |
10947 | int idx_number = 3; | |
10948 | int type; | |
10949 | u_int32_t metric; | |
10950 | struct bgp_redist *red; | |
10951 | ||
10952 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
10953 | if (type < 0) { | |
10954 | vty_out(vty, "%% Invalid route type\n"); | |
10955 | return CMD_WARNING_CONFIG_FAILED; | |
10956 | } | |
10957 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 10958 | |
d62a17ae | 10959 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
10960 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
10961 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 10962 | } |
10963 | ||
10964 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
10965 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 10966 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 10967 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10968 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 10969 | "Route map reference\n" |
10970 | "Pointer to route-map entries\n" | |
10971 | "Metric for redistributed routes\n" | |
10972 | "Default metric\n") | |
10973 | { | |
d62a17ae | 10974 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10975 | int idx_protocol = 1; | |
10976 | int idx_word = 3; | |
10977 | int idx_number = 5; | |
10978 | int type; | |
10979 | u_int32_t metric; | |
10980 | struct bgp_redist *red; | |
10981 | ||
10982 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
10983 | if (type < 0) { | |
10984 | vty_out(vty, "%% Invalid route type\n"); | |
10985 | return CMD_WARNING_CONFIG_FAILED; | |
10986 | } | |
10987 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 10988 | |
d62a17ae | 10989 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
10990 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10991 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
10992 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 10993 | } |
10994 | ||
10995 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
10996 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 10997 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 10998 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10999 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11000 | "Metric for redistributed routes\n" |
11001 | "Default metric\n" | |
11002 | "Route map reference\n" | |
11003 | "Pointer to route-map entries\n") | |
11004 | { | |
d62a17ae | 11005 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11006 | int idx_protocol = 1; | |
11007 | int idx_number = 3; | |
11008 | int idx_word = 5; | |
11009 | int type; | |
11010 | u_int32_t metric; | |
11011 | struct bgp_redist *red; | |
11012 | ||
11013 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
11014 | if (type < 0) { | |
11015 | vty_out(vty, "%% Invalid route type\n"); | |
11016 | return CMD_WARNING_CONFIG_FAILED; | |
11017 | } | |
11018 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 11019 | |
d62a17ae | 11020 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11021 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric); | |
11022 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11023 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11024 | } |
11025 | ||
11026 | DEFUN (no_bgp_redistribute_ipv6, | |
11027 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 11028 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 11029 | NO_STR |
11030 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 11031 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
11032 | "Metric for redistributed routes\n" |
11033 | "Default metric\n" | |
11034 | "Route map reference\n" | |
11035 | "Pointer to route-map entries\n") | |
718e3744 | 11036 | { |
d62a17ae | 11037 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11038 | int idx_protocol = 2; | |
11039 | int type; | |
718e3744 | 11040 | |
d62a17ae | 11041 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
11042 | if (type < 0) { | |
11043 | vty_out(vty, "%% Invalid route type\n"); | |
11044 | return CMD_WARNING_CONFIG_FAILED; | |
11045 | } | |
718e3744 | 11046 | |
d62a17ae | 11047 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
11048 | } | |
11049 | ||
11050 | int bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi, | |
11051 | safi_t safi, int *write) | |
11052 | { | |
11053 | int i; | |
11054 | ||
11055 | /* Unicast redistribution only. */ | |
11056 | if (safi != SAFI_UNICAST) | |
11057 | return 0; | |
11058 | ||
11059 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
11060 | /* Redistribute BGP does not make sense. */ | |
11061 | if (i != ZEBRA_ROUTE_BGP) { | |
11062 | struct list *red_list; | |
11063 | struct listnode *node; | |
11064 | struct bgp_redist *red; | |
11065 | ||
11066 | red_list = bgp->redist[afi][i]; | |
11067 | if (!red_list) | |
11068 | continue; | |
11069 | ||
11070 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
11071 | /* Display "address-family" when it is not yet | |
11072 | * diplayed. */ | |
11073 | bgp_config_write_family_header(vty, afi, safi, | |
11074 | write); | |
11075 | ||
11076 | /* "redistribute" configuration. */ | |
11077 | vty_out(vty, " redistribute %s", | |
11078 | zebra_route_string(i)); | |
11079 | if (red->instance) | |
11080 | vty_out(vty, " %d", red->instance); | |
11081 | if (red->redist_metric_flag) | |
11082 | vty_out(vty, " metric %u", | |
11083 | red->redist_metric); | |
11084 | if (red->rmap.name) | |
11085 | vty_out(vty, " route-map %s", | |
11086 | red->rmap.name); | |
11087 | vty_out(vty, "\n"); | |
11088 | } | |
11089 | } | |
11090 | } | |
11091 | return *write; | |
718e3744 | 11092 | } |
6b0655a2 | 11093 | |
718e3744 | 11094 | /* BGP node structure. */ |
d62a17ae | 11095 | static struct cmd_node bgp_node = { |
c14777c6 | 11096 | BGP_NODE, |
11097 | "%s(config-router)# ", | |
11098 | 1, | |
718e3744 | 11099 | }; |
11100 | ||
d62a17ae | 11101 | static struct cmd_node bgp_ipv4_unicast_node = { |
c14777c6 | 11102 | BGP_IPV4_NODE, |
11103 | "%s(config-router-af)# ", | |
11104 | 1, | |
718e3744 | 11105 | }; |
11106 | ||
d62a17ae | 11107 | static struct cmd_node bgp_ipv4_multicast_node = { |
c14777c6 | 11108 | BGP_IPV4M_NODE, |
11109 | "%s(config-router-af)# ", | |
11110 | 1, | |
718e3744 | 11111 | }; |
11112 | ||
d62a17ae | 11113 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
c14777c6 | 11114 | BGP_IPV4L_NODE, |
11115 | "%s(config-router-af)# ", | |
11116 | 1, | |
f51bae9c DS |
11117 | }; |
11118 | ||
d62a17ae | 11119 | static struct cmd_node bgp_ipv6_unicast_node = { |
c14777c6 | 11120 | BGP_IPV6_NODE, |
11121 | "%s(config-router-af)# ", | |
11122 | 1, | |
718e3744 | 11123 | }; |
11124 | ||
d62a17ae | 11125 | static struct cmd_node bgp_ipv6_multicast_node = { |
c14777c6 | 11126 | BGP_IPV6M_NODE, |
11127 | "%s(config-router-af)# ", | |
11128 | 1, | |
25ffbdc1 | 11129 | }; |
11130 | ||
d62a17ae | 11131 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
c14777c6 | 11132 | BGP_IPV6L_NODE, |
11133 | "%s(config-router-af)# ", | |
11134 | 1, | |
f51bae9c DS |
11135 | }; |
11136 | ||
d62a17ae | 11137 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
11138 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 11139 | |
d62a17ae | 11140 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
11141 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 11142 | |
d62a17ae | 11143 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
11144 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 11145 | |
d62a17ae | 11146 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
11147 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 11148 | |
d62a17ae | 11149 | static void community_list_vty(void); |
1f8ae70b | 11150 | |
d62a17ae | 11151 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 11152 | { |
d62a17ae | 11153 | struct bgp *bgp; |
11154 | struct peer *peer; | |
11155 | struct peer_group *group; | |
11156 | struct listnode *lnbgp, *lnpeer; | |
b8a815e5 | 11157 | |
d62a17ae | 11158 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
11159 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
11160 | /* only provide suggestions on the appropriate input | |
11161 | * token type, | |
11162 | * they'll otherwise show up multiple times */ | |
11163 | enum cmd_token_type match_type; | |
11164 | char *name = peer->host; | |
d48ed3e0 | 11165 | |
d62a17ae | 11166 | if (peer->conf_if) { |
11167 | match_type = VARIABLE_TKN; | |
11168 | name = peer->conf_if; | |
11169 | } else if (strchr(peer->host, ':')) | |
11170 | match_type = IPV6_TKN; | |
11171 | else | |
11172 | match_type = IPV4_TKN; | |
d48ed3e0 | 11173 | |
d62a17ae | 11174 | if (token->type != match_type) |
11175 | continue; | |
d48ed3e0 | 11176 | |
d62a17ae | 11177 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
11178 | } | |
d48ed3e0 | 11179 | |
d62a17ae | 11180 | if (token->type == VARIABLE_TKN) |
11181 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
11182 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
11183 | group->name)); | |
11184 | } | |
b8a815e5 DL |
11185 | } |
11186 | ||
11187 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 11188 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
11189 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
11190 | {.completions = NULL}}; | |
11191 | ||
11192 | void bgp_vty_init(void) | |
11193 | { | |
11194 | cmd_variable_handler_register(bgp_var_neighbor); | |
11195 | ||
11196 | /* Install bgp top node. */ | |
11197 | install_node(&bgp_node, bgp_config_write); | |
11198 | install_node(&bgp_ipv4_unicast_node, NULL); | |
11199 | install_node(&bgp_ipv4_multicast_node, NULL); | |
11200 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
11201 | install_node(&bgp_ipv6_unicast_node, NULL); | |
11202 | install_node(&bgp_ipv6_multicast_node, NULL); | |
11203 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
11204 | install_node(&bgp_vpnv4_node, NULL); | |
11205 | install_node(&bgp_vpnv6_node, NULL); | |
11206 | install_node(&bgp_evpn_node, NULL); | |
11207 | install_node(&bgp_evpn_vni_node, NULL); | |
11208 | ||
11209 | /* Install default VTY commands to new nodes. */ | |
11210 | install_default(BGP_NODE); | |
11211 | install_default(BGP_IPV4_NODE); | |
11212 | install_default(BGP_IPV4M_NODE); | |
11213 | install_default(BGP_IPV4L_NODE); | |
11214 | install_default(BGP_IPV6_NODE); | |
11215 | install_default(BGP_IPV6M_NODE); | |
11216 | install_default(BGP_IPV6L_NODE); | |
11217 | install_default(BGP_VPNV4_NODE); | |
11218 | install_default(BGP_VPNV6_NODE); | |
11219 | install_default(BGP_EVPN_NODE); | |
11220 | install_default(BGP_EVPN_VNI_NODE); | |
11221 | ||
11222 | /* "bgp multiple-instance" commands. */ | |
11223 | install_element(CONFIG_NODE, &bgp_multiple_instance_cmd); | |
11224 | install_element(CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
11225 | ||
11226 | /* "bgp config-type" commands. */ | |
11227 | install_element(CONFIG_NODE, &bgp_config_type_cmd); | |
11228 | install_element(CONFIG_NODE, &no_bgp_config_type_cmd); | |
11229 | ||
11230 | /* bgp route-map delay-timer commands. */ | |
11231 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
11232 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
11233 | ||
11234 | /* Dummy commands (Currently not supported) */ | |
11235 | install_element(BGP_NODE, &no_synchronization_cmd); | |
11236 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
11237 | ||
11238 | /* "router bgp" commands. */ | |
11239 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
11240 | ||
11241 | /* "no router bgp" commands. */ | |
11242 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
11243 | ||
11244 | /* "bgp router-id" commands. */ | |
11245 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
11246 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
11247 | ||
11248 | /* "bgp cluster-id" commands. */ | |
11249 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
11250 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
11251 | ||
11252 | /* "bgp confederation" commands. */ | |
11253 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
11254 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
11255 | ||
11256 | /* "bgp confederation peers" commands. */ | |
11257 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
11258 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
11259 | ||
11260 | /* bgp max-med command */ | |
11261 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
11262 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
11263 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
11264 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
11265 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
11266 | ||
11267 | /* bgp disable-ebgp-connected-nh-check */ | |
11268 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
11269 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
11270 | ||
11271 | /* bgp update-delay command */ | |
11272 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
11273 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
11274 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
11275 | ||
11276 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
11277 | install_element(BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
11278 | ||
11279 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
11280 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
11281 | ||
11282 | /* "maximum-paths" commands. */ | |
11283 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
11284 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
11285 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
11286 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
11287 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
11288 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
11289 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
11290 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
11291 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
11292 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
11293 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
11294 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
11295 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
11296 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
11297 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
11298 | ||
11299 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
11300 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
11301 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
11302 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
11303 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
11304 | ||
11305 | /* "timers bgp" commands. */ | |
11306 | install_element(BGP_NODE, &bgp_timers_cmd); | |
11307 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
11308 | ||
11309 | /* route-map delay-timer commands - per instance for backwards compat. | |
11310 | */ | |
11311 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
11312 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
11313 | ||
11314 | /* "bgp client-to-client reflection" commands */ | |
11315 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
11316 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
11317 | ||
11318 | /* "bgp always-compare-med" commands */ | |
11319 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
11320 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
11321 | ||
11322 | /* "bgp deterministic-med" commands */ | |
11323 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
11324 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
11325 | ||
11326 | /* "bgp graceful-restart" commands */ | |
11327 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); | |
11328 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
11329 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); | |
11330 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
11331 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
11332 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
11333 | ||
11334 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); | |
11335 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
11336 | ||
11337 | /* "bgp fast-external-failover" commands */ | |
11338 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
11339 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
11340 | ||
11341 | /* "bgp enforce-first-as" commands */ | |
11342 | install_element(BGP_NODE, &bgp_enforce_first_as_cmd); | |
11343 | install_element(BGP_NODE, &no_bgp_enforce_first_as_cmd); | |
11344 | ||
11345 | /* "bgp bestpath compare-routerid" commands */ | |
11346 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
11347 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
11348 | ||
11349 | /* "bgp bestpath as-path ignore" commands */ | |
11350 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
11351 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
11352 | ||
11353 | /* "bgp bestpath as-path confed" commands */ | |
11354 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
11355 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
11356 | ||
11357 | /* "bgp bestpath as-path multipath-relax" commands */ | |
11358 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
11359 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
11360 | ||
11361 | /* "bgp log-neighbor-changes" commands */ | |
11362 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
11363 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
11364 | ||
11365 | /* "bgp bestpath med" commands */ | |
11366 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
11367 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
11368 | ||
11369 | /* "no bgp default ipv4-unicast" commands. */ | |
11370 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
11371 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
11372 | ||
11373 | /* "bgp network import-check" commands. */ | |
11374 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
11375 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
11376 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
11377 | ||
11378 | /* "bgp default local-preference" commands. */ | |
11379 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
11380 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
11381 | ||
11382 | /* bgp default show-hostname */ | |
11383 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
11384 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
11385 | ||
11386 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
11387 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
11388 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
11389 | ||
11390 | /* bgp ibgp-allow-policy-mods command */ | |
11391 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
11392 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
11393 | ||
11394 | /* "bgp listen limit" commands. */ | |
11395 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
11396 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
11397 | ||
11398 | /* "bgp listen range" commands. */ | |
11399 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
11400 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
11401 | ||
11402 | /* "neighbor remote-as" commands. */ | |
11403 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
11404 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
11405 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
11406 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
11407 | install_element(BGP_NODE, | |
11408 | &neighbor_interface_v6only_config_remote_as_cmd); | |
11409 | install_element(BGP_NODE, &no_neighbor_cmd); | |
11410 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
11411 | ||
11412 | /* "neighbor peer-group" commands. */ | |
11413 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
11414 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
11415 | install_element(BGP_NODE, | |
11416 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
11417 | ||
11418 | /* "neighbor local-as" commands. */ | |
11419 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
11420 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
11421 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
11422 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
11423 | ||
11424 | /* "neighbor solo" commands. */ | |
11425 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
11426 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
11427 | ||
11428 | /* "neighbor password" commands. */ | |
11429 | install_element(BGP_NODE, &neighbor_password_cmd); | |
11430 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
11431 | ||
11432 | /* "neighbor activate" commands. */ | |
11433 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
11434 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
11435 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
11436 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
11437 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
11438 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
11439 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
11440 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
11441 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
11442 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); | |
11443 | ||
11444 | /* "no neighbor activate" commands. */ | |
11445 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
11446 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
11447 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
11448 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
11449 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
11450 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
11451 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
11452 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
11453 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
11454 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); | |
11455 | ||
11456 | /* "neighbor peer-group" set commands. */ | |
11457 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
11458 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11459 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11460 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11461 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11462 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11463 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11464 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11465 | ||
11466 | /* "no neighbor peer-group unset" commands. */ | |
11467 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
11468 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11469 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11470 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11471 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11472 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11473 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11474 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11475 | ||
11476 | /* "neighbor softreconfiguration inbound" commands.*/ | |
11477 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
11478 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
11479 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
11480 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11481 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
11482 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11483 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
11484 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11485 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
11486 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11487 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
11488 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11489 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
11490 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11491 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
11492 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11493 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
11494 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11495 | ||
11496 | /* "neighbor attribute-unchanged" commands. */ | |
11497 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
11498 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
11499 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
11500 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
11501 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
11502 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
11503 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
11504 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
11505 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
11506 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
11507 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
11508 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
11509 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
11510 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
11511 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
11512 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
11513 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
11514 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
11515 | ||
11516 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
11517 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
11518 | ||
11519 | /* "nexthop-local unchanged" commands */ | |
11520 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
11521 | install_element(BGP_IPV6_NODE, | |
11522 | &no_neighbor_nexthop_local_unchanged_cmd); | |
11523 | ||
11524 | /* "neighbor next-hop-self" commands. */ | |
11525 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
11526 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
11527 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
11528 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
11529 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
11530 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
11531 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
11532 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
11533 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
11534 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
11535 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
11536 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
11537 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
11538 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
11539 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
11540 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
11541 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
11542 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
11543 | ||
11544 | /* "neighbor next-hop-self force" commands. */ | |
11545 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
11546 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
11547 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
11548 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11549 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
11550 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11551 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); | |
11552 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11553 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
11554 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11555 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
11556 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11557 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); | |
11558 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11559 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
11560 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11561 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); | |
11562 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11563 | ||
11564 | /* "neighbor as-override" commands. */ | |
11565 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
11566 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
11567 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
11568 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
11569 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
11570 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
11571 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
11572 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
11573 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
11574 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
11575 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
11576 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
11577 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
11578 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
11579 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
11580 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
11581 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
11582 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
11583 | ||
11584 | /* "neighbor remove-private-AS" commands. */ | |
11585 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
11586 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
11587 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
11588 | install_element(BGP_NODE, | |
11589 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
11590 | install_element(BGP_NODE, | |
11591 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
11592 | install_element(BGP_NODE, | |
11593 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
11594 | install_element(BGP_NODE, | |
11595 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
11596 | install_element( | |
11597 | BGP_NODE, | |
11598 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
11599 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
11600 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
11601 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
11602 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11603 | install_element(BGP_IPV4_NODE, | |
11604 | &neighbor_remove_private_as_replace_as_cmd); | |
11605 | install_element(BGP_IPV4_NODE, | |
11606 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11607 | install_element(BGP_IPV4_NODE, | |
11608 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11609 | install_element(BGP_IPV4_NODE, | |
11610 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11611 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
11612 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
11613 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
11614 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11615 | install_element(BGP_IPV4M_NODE, | |
11616 | &neighbor_remove_private_as_replace_as_cmd); | |
11617 | install_element(BGP_IPV4M_NODE, | |
11618 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11619 | install_element(BGP_IPV4M_NODE, | |
11620 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11621 | install_element(BGP_IPV4M_NODE, | |
11622 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11623 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
11624 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
11625 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
11626 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11627 | install_element(BGP_IPV4L_NODE, | |
11628 | &neighbor_remove_private_as_replace_as_cmd); | |
11629 | install_element(BGP_IPV4L_NODE, | |
11630 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11631 | install_element(BGP_IPV4L_NODE, | |
11632 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11633 | install_element(BGP_IPV4L_NODE, | |
11634 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11635 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
11636 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
11637 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
11638 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11639 | install_element(BGP_IPV6_NODE, | |
11640 | &neighbor_remove_private_as_replace_as_cmd); | |
11641 | install_element(BGP_IPV6_NODE, | |
11642 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11643 | install_element(BGP_IPV6_NODE, | |
11644 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11645 | install_element(BGP_IPV6_NODE, | |
11646 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11647 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
11648 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
11649 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
11650 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11651 | install_element(BGP_IPV6M_NODE, | |
11652 | &neighbor_remove_private_as_replace_as_cmd); | |
11653 | install_element(BGP_IPV6M_NODE, | |
11654 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11655 | install_element(BGP_IPV6M_NODE, | |
11656 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11657 | install_element(BGP_IPV6M_NODE, | |
11658 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11659 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
11660 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
11661 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
11662 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11663 | install_element(BGP_IPV6L_NODE, | |
11664 | &neighbor_remove_private_as_replace_as_cmd); | |
11665 | install_element(BGP_IPV6L_NODE, | |
11666 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11667 | install_element(BGP_IPV6L_NODE, | |
11668 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11669 | install_element(BGP_IPV6L_NODE, | |
11670 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11671 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
11672 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
11673 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
11674 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11675 | install_element(BGP_VPNV4_NODE, | |
11676 | &neighbor_remove_private_as_replace_as_cmd); | |
11677 | install_element(BGP_VPNV4_NODE, | |
11678 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11679 | install_element(BGP_VPNV4_NODE, | |
11680 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11681 | install_element(BGP_VPNV4_NODE, | |
11682 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11683 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
11684 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
11685 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
11686 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11687 | install_element(BGP_VPNV6_NODE, | |
11688 | &neighbor_remove_private_as_replace_as_cmd); | |
11689 | install_element(BGP_VPNV6_NODE, | |
11690 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11691 | install_element(BGP_VPNV6_NODE, | |
11692 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11693 | install_element(BGP_VPNV6_NODE, | |
11694 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11695 | ||
11696 | /* "neighbor send-community" commands.*/ | |
11697 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
11698 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
11699 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
11700 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
11701 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
11702 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
11703 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
11704 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
11705 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
11706 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
11707 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
11708 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
11709 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
11710 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
11711 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
11712 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
11713 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
11714 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
11715 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
11716 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
11717 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
11718 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
11719 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
11720 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
11721 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
11722 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
11723 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
11724 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
11725 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
11726 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
11727 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
11728 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
11729 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
11730 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
11731 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
11732 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
11733 | ||
11734 | /* "neighbor route-reflector" commands.*/ | |
11735 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
11736 | install_element(BGP_NODE, | |
11737 | &no_neighbor_route_reflector_client_hidden_cmd); | |
11738 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
11739 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
11740 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
11741 | install_element(BGP_IPV4M_NODE, | |
11742 | &no_neighbor_route_reflector_client_cmd); | |
11743 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
11744 | install_element(BGP_IPV4L_NODE, | |
11745 | &no_neighbor_route_reflector_client_cmd); | |
11746 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
11747 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
11748 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
11749 | install_element(BGP_IPV6M_NODE, | |
11750 | &no_neighbor_route_reflector_client_cmd); | |
11751 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
11752 | install_element(BGP_IPV6L_NODE, | |
11753 | &no_neighbor_route_reflector_client_cmd); | |
11754 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
11755 | install_element(BGP_VPNV4_NODE, | |
11756 | &no_neighbor_route_reflector_client_cmd); | |
11757 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
11758 | install_element(BGP_VPNV6_NODE, | |
11759 | &no_neighbor_route_reflector_client_cmd); | |
11760 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); | |
11761 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
11762 | ||
11763 | /* "neighbor route-server" commands.*/ | |
11764 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
11765 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
11766 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
11767 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
11768 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
11769 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
11770 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
11771 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
11772 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
11773 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
11774 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
11775 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
11776 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
11777 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
11778 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
11779 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
11780 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
11781 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
11782 | ||
11783 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
11784 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
11785 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
11786 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11787 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11788 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11789 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11790 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11791 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11792 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11793 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11794 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11795 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11796 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11797 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11798 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11799 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11800 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11801 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11802 | ||
11803 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
11804 | install_element(BGP_NODE, | |
11805 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
11806 | install_element(BGP_NODE, | |
11807 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
11808 | install_element(BGP_IPV4_NODE, | |
11809 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11810 | install_element(BGP_IPV4_NODE, | |
11811 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11812 | install_element(BGP_IPV4M_NODE, | |
11813 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11814 | install_element(BGP_IPV4M_NODE, | |
11815 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11816 | install_element(BGP_IPV4L_NODE, | |
11817 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11818 | install_element(BGP_IPV4L_NODE, | |
11819 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11820 | install_element(BGP_IPV6_NODE, | |
11821 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11822 | install_element(BGP_IPV6_NODE, | |
11823 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11824 | install_element(BGP_IPV6M_NODE, | |
11825 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11826 | install_element(BGP_IPV6M_NODE, | |
11827 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11828 | install_element(BGP_IPV6L_NODE, | |
11829 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11830 | install_element(BGP_IPV6L_NODE, | |
11831 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11832 | install_element(BGP_VPNV4_NODE, | |
11833 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11834 | install_element(BGP_VPNV4_NODE, | |
11835 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11836 | install_element(BGP_VPNV6_NODE, | |
11837 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11838 | install_element(BGP_VPNV6_NODE, | |
11839 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11840 | ||
11841 | /* "neighbor passive" commands. */ | |
11842 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
11843 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
11844 | ||
11845 | ||
11846 | /* "neighbor shutdown" commands. */ | |
11847 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
11848 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
11849 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
11850 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
11851 | ||
11852 | /* "neighbor capability extended-nexthop" commands.*/ | |
11853 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
11854 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
11855 | ||
11856 | /* "neighbor capability orf prefix-list" commands.*/ | |
11857 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
11858 | install_element(BGP_NODE, | |
11859 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
11860 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
11861 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11862 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
11863 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11864 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
11865 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11866 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
11867 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11868 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
11869 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11870 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
11871 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11872 | ||
11873 | /* "neighbor capability dynamic" commands.*/ | |
11874 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
11875 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
11876 | ||
11877 | /* "neighbor dont-capability-negotiate" commands. */ | |
11878 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
11879 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
11880 | ||
11881 | /* "neighbor ebgp-multihop" commands. */ | |
11882 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
11883 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
11884 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
11885 | ||
11886 | /* "neighbor disable-connected-check" commands. */ | |
11887 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
11888 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
11889 | ||
11890 | /* "neighbor description" commands. */ | |
11891 | install_element(BGP_NODE, &neighbor_description_cmd); | |
11892 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
11893 | ||
11894 | /* "neighbor update-source" commands. "*/ | |
11895 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
11896 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
11897 | ||
11898 | /* "neighbor default-originate" commands. */ | |
11899 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
11900 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
11901 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
11902 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
11903 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
11904 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
11905 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
11906 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
11907 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
11908 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
11909 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
11910 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
11911 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
11912 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
11913 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
11914 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
11915 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
11916 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
11917 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
11918 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
11919 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
11920 | ||
11921 | /* "neighbor port" commands. */ | |
11922 | install_element(BGP_NODE, &neighbor_port_cmd); | |
11923 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
11924 | ||
11925 | /* "neighbor weight" commands. */ | |
11926 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
11927 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
11928 | ||
11929 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
11930 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
11931 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
11932 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
11933 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
11934 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
11935 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
11936 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
11937 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
11938 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
11939 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
11940 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
11941 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
11942 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
11943 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
11944 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
11945 | ||
11946 | /* "neighbor override-capability" commands. */ | |
11947 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
11948 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
11949 | ||
11950 | /* "neighbor strict-capability-match" commands. */ | |
11951 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
11952 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
11953 | ||
11954 | /* "neighbor timers" commands. */ | |
11955 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
11956 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
11957 | ||
11958 | /* "neighbor timers connect" commands. */ | |
11959 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
11960 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
11961 | ||
11962 | /* "neighbor advertisement-interval" commands. */ | |
11963 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
11964 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
11965 | ||
11966 | /* "neighbor interface" commands. */ | |
11967 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
11968 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
11969 | ||
11970 | /* "neighbor distribute" commands. */ | |
11971 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
11972 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
11973 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
11974 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
11975 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
11976 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
11977 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
11978 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
11979 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
11980 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
11981 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
11982 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
11983 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
11984 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
11985 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
11986 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
11987 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
11988 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
11989 | ||
11990 | /* "neighbor prefix-list" commands. */ | |
11991 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
11992 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
11993 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
11994 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
11995 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
11996 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
11997 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
11998 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
11999 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
12000 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
12001 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
12002 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
12003 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
12004 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
12005 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
12006 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
12007 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
12008 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
12009 | ||
12010 | /* "neighbor filter-list" commands. */ | |
12011 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
12012 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
12013 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
12014 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
12015 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
12016 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
12017 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
12018 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
12019 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
12020 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
12021 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
12022 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
12023 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
12024 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
12025 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
12026 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
12027 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
12028 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
12029 | ||
12030 | /* "neighbor route-map" commands. */ | |
12031 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
12032 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
12033 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
12034 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
12035 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
12036 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
12037 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
12038 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
12039 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
12040 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
12041 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
12042 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
12043 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
12044 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
12045 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
12046 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
12047 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
12048 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
12049 | ||
12050 | /* "neighbor unsuppress-map" commands. */ | |
12051 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
12052 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
12053 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
12054 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
12055 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
12056 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
12057 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
12058 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
12059 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
12060 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
12061 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
12062 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
12063 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
12064 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
12065 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
12066 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
12067 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
12068 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
12069 | ||
12070 | /* "neighbor maximum-prefix" commands. */ | |
12071 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
12072 | install_element(BGP_NODE, | |
12073 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
12074 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
12075 | install_element(BGP_NODE, | |
12076 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
12077 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
12078 | install_element(BGP_NODE, | |
12079 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
12080 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
12081 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
12082 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12083 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12084 | install_element(BGP_IPV4_NODE, | |
12085 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12086 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12087 | install_element(BGP_IPV4_NODE, | |
12088 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12089 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
12090 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
12091 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12092 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12093 | install_element(BGP_IPV4M_NODE, | |
12094 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12095 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12096 | install_element(BGP_IPV4M_NODE, | |
12097 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12098 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
12099 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
12100 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12101 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12102 | install_element(BGP_IPV4L_NODE, | |
12103 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12104 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12105 | install_element(BGP_IPV4L_NODE, | |
12106 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12107 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
12108 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
12109 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12110 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12111 | install_element(BGP_IPV6_NODE, | |
12112 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12113 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12114 | install_element(BGP_IPV6_NODE, | |
12115 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12116 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
12117 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
12118 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12119 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12120 | install_element(BGP_IPV6M_NODE, | |
12121 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12122 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12123 | install_element(BGP_IPV6M_NODE, | |
12124 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12125 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
12126 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
12127 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12128 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12129 | install_element(BGP_IPV6L_NODE, | |
12130 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12131 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12132 | install_element(BGP_IPV6L_NODE, | |
12133 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12134 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
12135 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
12136 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12137 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12138 | install_element(BGP_VPNV4_NODE, | |
12139 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12140 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12141 | install_element(BGP_VPNV4_NODE, | |
12142 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12143 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
12144 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
12145 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12146 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12147 | install_element(BGP_VPNV6_NODE, | |
12148 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12149 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12150 | install_element(BGP_VPNV6_NODE, | |
12151 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12152 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
12153 | ||
12154 | /* "neighbor allowas-in" */ | |
12155 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
12156 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
12157 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
12158 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
12159 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
12160 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
12161 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
12162 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
12163 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
12164 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
12165 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
12166 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
12167 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
12168 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
12169 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
12170 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
12171 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
12172 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
12173 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
12174 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
12175 | ||
12176 | /* address-family commands. */ | |
12177 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
12178 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 12179 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 12180 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
12181 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 12182 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 12183 | |
d62a17ae | 12184 | install_element(BGP_NODE, &address_family_evpn_cmd); |
12185 | ||
12186 | /* "exit-address-family" command. */ | |
12187 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
12188 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
12189 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
12190 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
12191 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
12192 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
12193 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
12194 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
12195 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); | |
12196 | ||
12197 | /* "clear ip bgp commands" */ | |
12198 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
12199 | ||
12200 | /* clear ip bgp prefix */ | |
12201 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
12202 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
12203 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
12204 | ||
12205 | /* "show [ip] bgp summary" commands. */ | |
12206 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
12207 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd); | |
12208 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); | |
12209 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); | |
12210 | install_element(VIEW_NODE, &show_bgp_updgrps_adj_cmd); | |
12211 | install_element(VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); | |
12212 | install_element(VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); | |
12213 | install_element(VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); | |
12214 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); | |
12215 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); | |
12216 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); | |
12217 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
12218 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); | |
12219 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); | |
12220 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); | |
12221 | ||
12222 | /* "show [ip] bgp neighbors" commands. */ | |
12223 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
12224 | ||
12225 | /* "show [ip] bgp peer-group" commands. */ | |
12226 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
12227 | ||
12228 | /* "show [ip] bgp paths" commands. */ | |
12229 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
12230 | ||
12231 | /* "show [ip] bgp community" commands. */ | |
12232 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
12233 | ||
12234 | /* "show ip bgp large-community" commands. */ | |
12235 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
12236 | /* "show [ip] bgp attribute-info" commands. */ | |
12237 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
12238 | ||
12239 | /* "redistribute" commands. */ | |
12240 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
12241 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
12242 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
12243 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
12244 | install_element(BGP_NODE, | |
12245 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
12246 | install_element(BGP_NODE, | |
12247 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
12248 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
12249 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
12250 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
12251 | install_element(BGP_NODE, | |
12252 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
12253 | install_element(BGP_NODE, | |
12254 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
12255 | install_element(BGP_NODE, | |
12256 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
12257 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
12258 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
12259 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
12260 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
12261 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
12262 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
12263 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
12264 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
12265 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
12266 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
12267 | install_element(BGP_IPV4_NODE, | |
12268 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
12269 | install_element(BGP_IPV4_NODE, | |
12270 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
12271 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
12272 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
12273 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
12274 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
12275 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
12276 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
12277 | ||
12278 | /* ttl_security commands */ | |
12279 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
12280 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
12281 | ||
12282 | /* "show [ip] bgp memory" commands. */ | |
12283 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
12284 | ||
12285 | /* "show [ip] bgp views" commands. */ | |
12286 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
12287 | ||
12288 | /* "show [ip] bgp vrfs" commands. */ | |
12289 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
12290 | ||
12291 | /* Community-list. */ | |
12292 | community_list_vty(); | |
718e3744 | 12293 | } |
6b0655a2 | 12294 | |
718e3744 | 12295 | #include "memory.h" |
12296 | #include "bgp_regex.h" | |
12297 | #include "bgp_clist.h" | |
12298 | #include "bgp_ecommunity.h" | |
12299 | ||
12300 | /* VTY functions. */ | |
12301 | ||
12302 | /* Direction value to string conversion. */ | |
d62a17ae | 12303 | static const char *community_direct_str(int direct) |
12304 | { | |
12305 | switch (direct) { | |
12306 | case COMMUNITY_DENY: | |
12307 | return "deny"; | |
12308 | case COMMUNITY_PERMIT: | |
12309 | return "permit"; | |
12310 | default: | |
12311 | return "unknown"; | |
12312 | } | |
718e3744 | 12313 | } |
12314 | ||
12315 | /* Display error string. */ | |
d62a17ae | 12316 | static void community_list_perror(struct vty *vty, int ret) |
12317 | { | |
12318 | switch (ret) { | |
12319 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
12320 | vty_out(vty, "%% Can't find community-list\n"); | |
12321 | break; | |
12322 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
12323 | vty_out(vty, "%% Malformed community-list value\n"); | |
12324 | break; | |
12325 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
12326 | vty_out(vty, | |
12327 | "%% Community name conflict, previously defined as standard community\n"); | |
12328 | break; | |
12329 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
12330 | vty_out(vty, | |
12331 | "%% Community name conflict, previously defined as expanded community\n"); | |
12332 | break; | |
12333 | } | |
718e3744 | 12334 | } |
12335 | ||
5bf15956 DW |
12336 | /* "community-list" keyword help string. */ |
12337 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
12338 | ||
5bf15956 | 12339 | /* ip community-list standard */ |
718e3744 | 12340 | DEFUN (ip_community_list_standard, |
12341 | ip_community_list_standard_cmd, | |
e961923c | 12342 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 12343 | IP_STR |
12344 | COMMUNITY_LIST_STR | |
12345 | "Community list number (standard)\n" | |
5bf15956 | 12346 | "Add an standard community-list entry\n" |
718e3744 | 12347 | "Community list name\n" |
12348 | "Specify community to reject\n" | |
12349 | "Specify community to accept\n" | |
12350 | COMMUNITY_VAL_STR) | |
12351 | { | |
d62a17ae | 12352 | char *cl_name_or_number = NULL; |
12353 | int direct = 0; | |
12354 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 12355 | |
d62a17ae | 12356 | int idx = 0; |
12357 | argv_find(argv, argc, "(1-99)", &idx); | |
12358 | argv_find(argv, argc, "WORD", &idx); | |
12359 | cl_name_or_number = argv[idx]->arg; | |
12360 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12361 | : COMMUNITY_DENY; | |
12362 | argv_find(argv, argc, "AA:NN", &idx); | |
12363 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12364 | |
d62a17ae | 12365 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
12366 | style); | |
42f914d4 | 12367 | |
d62a17ae | 12368 | XFREE(MTYPE_TMP, str); |
42f914d4 | 12369 | |
d62a17ae | 12370 | if (ret < 0) { |
12371 | /* Display error string. */ | |
12372 | community_list_perror(vty, ret); | |
12373 | return CMD_WARNING_CONFIG_FAILED; | |
12374 | } | |
42f914d4 | 12375 | |
d62a17ae | 12376 | return CMD_SUCCESS; |
718e3744 | 12377 | } |
12378 | ||
fee6e4e4 | 12379 | DEFUN (no_ip_community_list_standard_all, |
12380 | no_ip_community_list_standard_all_cmd, | |
e961923c | 12381 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 12382 | NO_STR |
12383 | IP_STR | |
12384 | COMMUNITY_LIST_STR | |
12385 | "Community list number (standard)\n" | |
5bf15956 DW |
12386 | "Add an standard community-list entry\n" |
12387 | "Community list name\n" | |
718e3744 | 12388 | "Specify community to reject\n" |
12389 | "Specify community to accept\n" | |
12390 | COMMUNITY_VAL_STR) | |
12391 | { | |
d62a17ae | 12392 | int delete_all = 0; |
42f914d4 | 12393 | |
d62a17ae | 12394 | char *cl_name_or_number = NULL; |
12395 | int direct = 0; | |
12396 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 12397 | |
d62a17ae | 12398 | int idx = 0; |
12399 | argv_find(argv, argc, "(1-99)", &idx); | |
12400 | argv_find(argv, argc, "WORD", &idx); | |
12401 | cl_name_or_number = argv[idx]->arg; | |
12402 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12403 | : COMMUNITY_DENY; | |
12404 | argv_find(argv, argc, "AA:NN", &idx); | |
12405 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12406 | |
d62a17ae | 12407 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
12408 | direct, style, delete_all); | |
42f914d4 | 12409 | |
d62a17ae | 12410 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 12411 | |
d62a17ae | 12412 | if (ret < 0) { |
12413 | community_list_perror(vty, ret); | |
12414 | return CMD_WARNING_CONFIG_FAILED; | |
12415 | } | |
42f914d4 | 12416 | |
d62a17ae | 12417 | return CMD_SUCCESS; |
718e3744 | 12418 | } |
12419 | ||
5bf15956 DW |
12420 | /* ip community-list expanded */ |
12421 | DEFUN (ip_community_list_expanded_all, | |
12422 | ip_community_list_expanded_all_cmd, | |
42f914d4 | 12423 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 12424 | IP_STR |
12425 | COMMUNITY_LIST_STR | |
12426 | "Community list number (expanded)\n" | |
5bf15956 | 12427 | "Add an expanded community-list entry\n" |
718e3744 | 12428 | "Community list name\n" |
12429 | "Specify community to reject\n" | |
12430 | "Specify community to accept\n" | |
12431 | COMMUNITY_VAL_STR) | |
12432 | { | |
d62a17ae | 12433 | char *cl_name_or_number = NULL; |
12434 | int direct = 0; | |
12435 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 12436 | |
d62a17ae | 12437 | int idx = 0; |
12438 | argv_find(argv, argc, "(100-500)", &idx); | |
12439 | argv_find(argv, argc, "WORD", &idx); | |
12440 | cl_name_or_number = argv[idx]->arg; | |
12441 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12442 | : COMMUNITY_DENY; | |
12443 | argv_find(argv, argc, "AA:NN", &idx); | |
12444 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12445 | |
d62a17ae | 12446 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
12447 | style); | |
42f914d4 | 12448 | |
d62a17ae | 12449 | XFREE(MTYPE_TMP, str); |
42f914d4 | 12450 | |
d62a17ae | 12451 | if (ret < 0) { |
12452 | /* Display error string. */ | |
12453 | community_list_perror(vty, ret); | |
12454 | return CMD_WARNING_CONFIG_FAILED; | |
12455 | } | |
42f914d4 | 12456 | |
d62a17ae | 12457 | return CMD_SUCCESS; |
718e3744 | 12458 | } |
12459 | ||
5bf15956 DW |
12460 | DEFUN (no_ip_community_list_expanded_all, |
12461 | no_ip_community_list_expanded_all_cmd, | |
42f914d4 | 12462 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 12463 | NO_STR |
12464 | IP_STR | |
12465 | COMMUNITY_LIST_STR | |
5bf15956 DW |
12466 | "Community list number (expanded)\n" |
12467 | "Add an expanded community-list entry\n" | |
718e3744 | 12468 | "Community list name\n" |
12469 | "Specify community to reject\n" | |
12470 | "Specify community to accept\n" | |
5bf15956 | 12471 | COMMUNITY_VAL_STR) |
718e3744 | 12472 | { |
d62a17ae | 12473 | int delete_all = 0; |
42f914d4 | 12474 | |
d62a17ae | 12475 | char *cl_name_or_number = NULL; |
12476 | int direct = 0; | |
12477 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 12478 | |
d62a17ae | 12479 | int idx = 0; |
12480 | argv_find(argv, argc, "(100-500)", &idx); | |
12481 | argv_find(argv, argc, "WORD", &idx); | |
12482 | cl_name_or_number = argv[idx]->arg; | |
12483 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12484 | : COMMUNITY_DENY; | |
12485 | argv_find(argv, argc, "AA:NN", &idx); | |
12486 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12487 | |
d62a17ae | 12488 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
12489 | direct, style, delete_all); | |
42f914d4 | 12490 | |
d62a17ae | 12491 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 12492 | |
d62a17ae | 12493 | if (ret < 0) { |
12494 | community_list_perror(vty, ret); | |
12495 | return CMD_WARNING_CONFIG_FAILED; | |
12496 | } | |
42f914d4 | 12497 | |
d62a17ae | 12498 | return CMD_SUCCESS; |
718e3744 | 12499 | } |
12500 | ||
d62a17ae | 12501 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 12502 | { |
d62a17ae | 12503 | struct community_entry *entry; |
718e3744 | 12504 | |
d62a17ae | 12505 | for (entry = list->head; entry; entry = entry->next) { |
12506 | if (entry == list->head) { | |
12507 | if (all_digit(list->name)) | |
12508 | vty_out(vty, "Community %s list %s\n", | |
12509 | entry->style == COMMUNITY_LIST_STANDARD | |
12510 | ? "standard" | |
12511 | : "(expanded) access", | |
12512 | list->name); | |
12513 | else | |
12514 | vty_out(vty, "Named Community %s list %s\n", | |
12515 | entry->style == COMMUNITY_LIST_STANDARD | |
12516 | ? "standard" | |
12517 | : "expanded", | |
12518 | list->name); | |
12519 | } | |
12520 | if (entry->any) | |
12521 | vty_out(vty, " %s\n", | |
12522 | community_direct_str(entry->direct)); | |
12523 | else | |
12524 | vty_out(vty, " %s %s\n", | |
12525 | community_direct_str(entry->direct), | |
12526 | entry->style == COMMUNITY_LIST_STANDARD | |
12527 | ? community_str(entry->u.com) | |
12528 | : entry->config); | |
12529 | } | |
718e3744 | 12530 | } |
12531 | ||
12532 | DEFUN (show_ip_community_list, | |
12533 | show_ip_community_list_cmd, | |
12534 | "show ip community-list", | |
12535 | SHOW_STR | |
12536 | IP_STR | |
12537 | "List community-list\n") | |
12538 | { | |
d62a17ae | 12539 | struct community_list *list; |
12540 | struct community_list_master *cm; | |
718e3744 | 12541 | |
d62a17ae | 12542 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
12543 | if (!cm) | |
12544 | return CMD_SUCCESS; | |
718e3744 | 12545 | |
d62a17ae | 12546 | for (list = cm->num.head; list; list = list->next) |
12547 | community_list_show(vty, list); | |
718e3744 | 12548 | |
d62a17ae | 12549 | for (list = cm->str.head; list; list = list->next) |
12550 | community_list_show(vty, list); | |
718e3744 | 12551 | |
d62a17ae | 12552 | return CMD_SUCCESS; |
718e3744 | 12553 | } |
12554 | ||
12555 | DEFUN (show_ip_community_list_arg, | |
12556 | show_ip_community_list_arg_cmd, | |
6147e2c6 | 12557 | "show ip community-list <(1-500)|WORD>", |
718e3744 | 12558 | SHOW_STR |
12559 | IP_STR | |
12560 | "List community-list\n" | |
12561 | "Community-list number\n" | |
12562 | "Community-list name\n") | |
12563 | { | |
d62a17ae | 12564 | int idx_comm_list = 3; |
12565 | struct community_list *list; | |
718e3744 | 12566 | |
d62a17ae | 12567 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
12568 | COMMUNITY_LIST_MASTER); | |
12569 | if (!list) { | |
12570 | vty_out(vty, "%% Can't find community-list\n"); | |
12571 | return CMD_WARNING; | |
12572 | } | |
718e3744 | 12573 | |
d62a17ae | 12574 | community_list_show(vty, list); |
718e3744 | 12575 | |
d62a17ae | 12576 | return CMD_SUCCESS; |
718e3744 | 12577 | } |
6b0655a2 | 12578 | |
57d187bc JS |
12579 | /* |
12580 | * Large Community code. | |
12581 | */ | |
d62a17ae | 12582 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
12583 | struct cmd_token **argv, int style, | |
12584 | int reject_all_digit_name) | |
12585 | { | |
12586 | int ret; | |
12587 | int direct; | |
12588 | char *str; | |
12589 | int idx = 0; | |
12590 | char *cl_name; | |
12591 | ||
12592 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12593 | : COMMUNITY_DENY; | |
12594 | ||
12595 | /* All digit name check. */ | |
12596 | idx = 0; | |
12597 | argv_find(argv, argc, "WORD", &idx); | |
12598 | argv_find(argv, argc, "(1-99)", &idx); | |
12599 | argv_find(argv, argc, "(100-500)", &idx); | |
12600 | cl_name = argv[idx]->arg; | |
12601 | if (reject_all_digit_name && all_digit(cl_name)) { | |
12602 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
12603 | return CMD_WARNING_CONFIG_FAILED; | |
12604 | } | |
12605 | ||
12606 | idx = 0; | |
12607 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
12608 | argv_find(argv, argc, "LINE", &idx); | |
12609 | /* Concat community string argument. */ | |
12610 | if (idx) | |
12611 | str = argv_concat(argv, argc, idx); | |
12612 | else | |
12613 | str = NULL; | |
12614 | ||
12615 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
12616 | ||
12617 | /* Free temporary community list string allocated by | |
12618 | argv_concat(). */ | |
12619 | if (str) | |
12620 | XFREE(MTYPE_TMP, str); | |
12621 | ||
12622 | if (ret < 0) { | |
12623 | community_list_perror(vty, ret); | |
12624 | return CMD_WARNING_CONFIG_FAILED; | |
12625 | } | |
12626 | return CMD_SUCCESS; | |
12627 | } | |
12628 | ||
12629 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
12630 | struct cmd_token **argv, int style) | |
12631 | { | |
12632 | int ret; | |
12633 | int direct = 0; | |
12634 | char *str = NULL; | |
12635 | int idx = 0; | |
12636 | ||
12637 | argv_find(argv, argc, "permit", &idx); | |
12638 | argv_find(argv, argc, "deny", &idx); | |
12639 | ||
12640 | if (idx) { | |
12641 | /* Check the list direct. */ | |
12642 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
12643 | direct = COMMUNITY_PERMIT; | |
12644 | else | |
12645 | direct = COMMUNITY_DENY; | |
12646 | ||
12647 | idx = 0; | |
12648 | argv_find(argv, argc, "LINE", &idx); | |
12649 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
12650 | /* Concat community string argument. */ | |
12651 | str = argv_concat(argv, argc, idx); | |
12652 | } | |
12653 | ||
12654 | idx = 0; | |
12655 | argv_find(argv, argc, "(1-99)", &idx); | |
12656 | argv_find(argv, argc, "(100-500)", &idx); | |
12657 | argv_find(argv, argc, "WORD", &idx); | |
12658 | ||
12659 | /* Unset community list. */ | |
12660 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
12661 | style); | |
12662 | ||
12663 | /* Free temporary community list string allocated by | |
12664 | argv_concat(). */ | |
12665 | if (str) | |
12666 | XFREE(MTYPE_TMP, str); | |
12667 | ||
12668 | if (ret < 0) { | |
12669 | community_list_perror(vty, ret); | |
12670 | return CMD_WARNING_CONFIG_FAILED; | |
12671 | } | |
12672 | ||
12673 | return CMD_SUCCESS; | |
57d187bc JS |
12674 | } |
12675 | ||
12676 | /* "large-community-list" keyword help string. */ | |
12677 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
12678 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
12679 | ||
12680 | DEFUN (ip_lcommunity_list_standard, | |
12681 | ip_lcommunity_list_standard_cmd, | |
52951b63 DS |
12682 | "ip large-community-list (1-99) <deny|permit>", |
12683 | IP_STR | |
12684 | LCOMMUNITY_LIST_STR | |
12685 | "Large Community list number (standard)\n" | |
12686 | "Specify large community to reject\n" | |
7111c1a0 | 12687 | "Specify large community to accept\n") |
52951b63 | 12688 | { |
d62a17ae | 12689 | return lcommunity_list_set_vty(vty, argc, argv, |
12690 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
12691 | } |
12692 | ||
12693 | DEFUN (ip_lcommunity_list_standard1, | |
12694 | ip_lcommunity_list_standard1_cmd, | |
12695 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
12696 | IP_STR |
12697 | LCOMMUNITY_LIST_STR | |
12698 | "Large Community list number (standard)\n" | |
12699 | "Specify large community to reject\n" | |
12700 | "Specify large community to accept\n" | |
12701 | LCOMMUNITY_VAL_STR) | |
12702 | { | |
d62a17ae | 12703 | return lcommunity_list_set_vty(vty, argc, argv, |
12704 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
57d187bc JS |
12705 | } |
12706 | ||
12707 | DEFUN (ip_lcommunity_list_expanded, | |
12708 | ip_lcommunity_list_expanded_cmd, | |
12709 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
12710 | IP_STR | |
12711 | LCOMMUNITY_LIST_STR | |
12712 | "Large Community list number (expanded)\n" | |
12713 | "Specify large community to reject\n" | |
12714 | "Specify large community to accept\n" | |
12715 | "An ordered list as a regular-expression\n") | |
12716 | { | |
d62a17ae | 12717 | return lcommunity_list_set_vty(vty, argc, argv, |
12718 | LARGE_COMMUNITY_LIST_EXPANDED, 0); | |
57d187bc JS |
12719 | } |
12720 | ||
12721 | DEFUN (ip_lcommunity_list_name_standard, | |
12722 | ip_lcommunity_list_name_standard_cmd, | |
52951b63 DS |
12723 | "ip large-community-list standard WORD <deny|permit>", |
12724 | IP_STR | |
12725 | LCOMMUNITY_LIST_STR | |
12726 | "Specify standard large-community-list\n" | |
12727 | "Large Community list name\n" | |
12728 | "Specify large community to reject\n" | |
12729 | "Specify large community to accept\n") | |
12730 | { | |
d62a17ae | 12731 | return lcommunity_list_set_vty(vty, argc, argv, |
12732 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
12733 | } |
12734 | ||
12735 | DEFUN (ip_lcommunity_list_name_standard1, | |
12736 | ip_lcommunity_list_name_standard1_cmd, | |
12737 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
12738 | IP_STR |
12739 | LCOMMUNITY_LIST_STR | |
12740 | "Specify standard large-community-list\n" | |
12741 | "Large Community list name\n" | |
12742 | "Specify large community to reject\n" | |
12743 | "Specify large community to accept\n" | |
12744 | LCOMMUNITY_VAL_STR) | |
12745 | { | |
d62a17ae | 12746 | return lcommunity_list_set_vty(vty, argc, argv, |
12747 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
57d187bc JS |
12748 | } |
12749 | ||
12750 | DEFUN (ip_lcommunity_list_name_expanded, | |
12751 | ip_lcommunity_list_name_expanded_cmd, | |
12752 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
12753 | IP_STR | |
12754 | LCOMMUNITY_LIST_STR | |
12755 | "Specify expanded large-community-list\n" | |
12756 | "Large Community list name\n" | |
12757 | "Specify large community to reject\n" | |
12758 | "Specify large community to accept\n" | |
12759 | "An ordered list as a regular-expression\n") | |
12760 | { | |
d62a17ae | 12761 | return lcommunity_list_set_vty(vty, argc, argv, |
12762 | LARGE_COMMUNITY_LIST_EXPANDED, 1); | |
57d187bc JS |
12763 | } |
12764 | ||
12765 | DEFUN (no_ip_lcommunity_list_standard_all, | |
12766 | no_ip_lcommunity_list_standard_all_cmd, | |
12767 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
12768 | NO_STR | |
12769 | IP_STR | |
12770 | LCOMMUNITY_LIST_STR | |
12771 | "Large Community list number (standard)\n" | |
12772 | "Large Community list number (expanded)\n" | |
12773 | "Large Community list name\n") | |
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_name_expanded_all, | |
12780 | no_ip_lcommunity_list_name_expanded_all_cmd, | |
12781 | "no ip large-community-list expanded WORD", | |
12782 | NO_STR | |
12783 | IP_STR | |
12784 | LCOMMUNITY_LIST_STR | |
12785 | "Specify expanded large-community-list\n" | |
12786 | "Large Community list name\n") | |
12787 | { | |
d62a17ae | 12788 | return lcommunity_list_unset_vty(vty, argc, argv, |
12789 | LARGE_COMMUNITY_LIST_EXPANDED); | |
57d187bc JS |
12790 | } |
12791 | ||
12792 | DEFUN (no_ip_lcommunity_list_standard, | |
12793 | no_ip_lcommunity_list_standard_cmd, | |
12794 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
12795 | NO_STR | |
12796 | IP_STR | |
12797 | LCOMMUNITY_LIST_STR | |
12798 | "Large Community list number (standard)\n" | |
12799 | "Specify large community to reject\n" | |
12800 | "Specify large community to accept\n" | |
12801 | LCOMMUNITY_VAL_STR) | |
12802 | { | |
d62a17ae | 12803 | return lcommunity_list_unset_vty(vty, argc, argv, |
12804 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
12805 | } |
12806 | ||
12807 | DEFUN (no_ip_lcommunity_list_expanded, | |
12808 | no_ip_lcommunity_list_expanded_cmd, | |
12809 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
12810 | NO_STR | |
12811 | IP_STR | |
12812 | LCOMMUNITY_LIST_STR | |
12813 | "Large Community list number (expanded)\n" | |
12814 | "Specify large community to reject\n" | |
12815 | "Specify large community to accept\n" | |
12816 | "An ordered list as a regular-expression\n") | |
12817 | { | |
d62a17ae | 12818 | return lcommunity_list_unset_vty(vty, argc, argv, |
12819 | LARGE_COMMUNITY_LIST_EXPANDED); | |
57d187bc JS |
12820 | } |
12821 | ||
12822 | DEFUN (no_ip_lcommunity_list_name_standard, | |
12823 | no_ip_lcommunity_list_name_standard_cmd, | |
12824 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
12825 | NO_STR | |
12826 | IP_STR | |
12827 | LCOMMUNITY_LIST_STR | |
12828 | "Specify standard large-community-list\n" | |
12829 | "Large Community list name\n" | |
12830 | "Specify large community to reject\n" | |
12831 | "Specify large community to accept\n" | |
12832 | LCOMMUNITY_VAL_STR) | |
12833 | { | |
d62a17ae | 12834 | return lcommunity_list_unset_vty(vty, argc, argv, |
12835 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
12836 | } |
12837 | ||
12838 | DEFUN (no_ip_lcommunity_list_name_expanded, | |
12839 | no_ip_lcommunity_list_name_expanded_cmd, | |
12840 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
12841 | NO_STR | |
12842 | IP_STR | |
12843 | LCOMMUNITY_LIST_STR | |
12844 | "Specify expanded large-community-list\n" | |
12845 | "Large community list name\n" | |
12846 | "Specify large community to reject\n" | |
12847 | "Specify large community to accept\n" | |
12848 | "An ordered list as a regular-expression\n") | |
12849 | { | |
d62a17ae | 12850 | return lcommunity_list_unset_vty(vty, argc, argv, |
12851 | LARGE_COMMUNITY_LIST_EXPANDED); | |
12852 | } | |
12853 | ||
12854 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) | |
12855 | { | |
12856 | struct community_entry *entry; | |
12857 | ||
12858 | for (entry = list->head; entry; entry = entry->next) { | |
12859 | if (entry == list->head) { | |
12860 | if (all_digit(list->name)) | |
12861 | vty_out(vty, "Large community %s list %s\n", | |
12862 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
12863 | ? "standard" | |
12864 | : "(expanded) access", | |
12865 | list->name); | |
12866 | else | |
12867 | vty_out(vty, | |
12868 | "Named large community %s list %s\n", | |
12869 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
12870 | ? "standard" | |
12871 | : "expanded", | |
12872 | list->name); | |
12873 | } | |
12874 | if (entry->any) | |
12875 | vty_out(vty, " %s\n", | |
12876 | community_direct_str(entry->direct)); | |
12877 | else | |
12878 | vty_out(vty, " %s %s\n", | |
12879 | community_direct_str(entry->direct), | |
12880 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
12881 | ? entry->u.ecom->str | |
12882 | : entry->config); | |
12883 | } | |
57d187bc JS |
12884 | } |
12885 | ||
12886 | DEFUN (show_ip_lcommunity_list, | |
12887 | show_ip_lcommunity_list_cmd, | |
12888 | "show ip large-community-list", | |
12889 | SHOW_STR | |
12890 | IP_STR | |
12891 | "List large-community list\n") | |
12892 | { | |
d62a17ae | 12893 | struct community_list *list; |
12894 | struct community_list_master *cm; | |
57d187bc | 12895 | |
d62a17ae | 12896 | cm = community_list_master_lookup(bgp_clist, |
12897 | LARGE_COMMUNITY_LIST_MASTER); | |
12898 | if (!cm) | |
12899 | return CMD_SUCCESS; | |
57d187bc | 12900 | |
d62a17ae | 12901 | for (list = cm->num.head; list; list = list->next) |
12902 | lcommunity_list_show(vty, list); | |
57d187bc | 12903 | |
d62a17ae | 12904 | for (list = cm->str.head; list; list = list->next) |
12905 | lcommunity_list_show(vty, list); | |
57d187bc | 12906 | |
d62a17ae | 12907 | return CMD_SUCCESS; |
57d187bc JS |
12908 | } |
12909 | ||
12910 | DEFUN (show_ip_lcommunity_list_arg, | |
12911 | show_ip_lcommunity_list_arg_cmd, | |
12912 | "show ip large-community-list <(1-500)|WORD>", | |
12913 | SHOW_STR | |
12914 | IP_STR | |
12915 | "List large-community list\n" | |
12916 | "large-community-list number\n" | |
12917 | "large-community-list name\n") | |
12918 | { | |
d62a17ae | 12919 | struct community_list *list; |
57d187bc | 12920 | |
d62a17ae | 12921 | list = community_list_lookup(bgp_clist, argv[3]->arg, |
12922 | LARGE_COMMUNITY_LIST_MASTER); | |
12923 | if (!list) { | |
12924 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
12925 | return CMD_WARNING; | |
12926 | } | |
57d187bc | 12927 | |
d62a17ae | 12928 | lcommunity_list_show(vty, list); |
57d187bc | 12929 | |
d62a17ae | 12930 | return CMD_SUCCESS; |
57d187bc JS |
12931 | } |
12932 | ||
718e3744 | 12933 | /* "extcommunity-list" keyword help string. */ |
12934 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
12935 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
12936 | ||
12937 | DEFUN (ip_extcommunity_list_standard, | |
12938 | ip_extcommunity_list_standard_cmd, | |
e961923c | 12939 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 12940 | IP_STR |
12941 | EXTCOMMUNITY_LIST_STR | |
12942 | "Extended Community list number (standard)\n" | |
718e3744 | 12943 | "Specify standard extcommunity-list\n" |
5bf15956 | 12944 | "Community list name\n" |
718e3744 | 12945 | "Specify community to reject\n" |
12946 | "Specify community to accept\n" | |
12947 | EXTCOMMUNITY_VAL_STR) | |
12948 | { | |
d62a17ae | 12949 | int style = EXTCOMMUNITY_LIST_STANDARD; |
12950 | int direct = 0; | |
12951 | char *cl_number_or_name = NULL; | |
42f914d4 | 12952 | |
d62a17ae | 12953 | int idx = 0; |
12954 | argv_find(argv, argc, "(1-99)", &idx); | |
12955 | argv_find(argv, argc, "WORD", &idx); | |
12956 | cl_number_or_name = argv[idx]->arg; | |
12957 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12958 | : COMMUNITY_DENY; | |
12959 | argv_find(argv, argc, "AA:NN", &idx); | |
12960 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12961 | |
d62a17ae | 12962 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
12963 | direct, style); | |
42f914d4 | 12964 | |
d62a17ae | 12965 | XFREE(MTYPE_TMP, str); |
42f914d4 | 12966 | |
d62a17ae | 12967 | if (ret < 0) { |
12968 | community_list_perror(vty, ret); | |
12969 | return CMD_WARNING_CONFIG_FAILED; | |
12970 | } | |
42f914d4 | 12971 | |
d62a17ae | 12972 | return CMD_SUCCESS; |
718e3744 | 12973 | } |
12974 | ||
718e3744 | 12975 | DEFUN (ip_extcommunity_list_name_expanded, |
12976 | ip_extcommunity_list_name_expanded_cmd, | |
e961923c | 12977 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 12978 | IP_STR |
12979 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 12980 | "Extended Community list number (expanded)\n" |
718e3744 | 12981 | "Specify expanded extcommunity-list\n" |
12982 | "Extended Community list name\n" | |
12983 | "Specify community to reject\n" | |
12984 | "Specify community to accept\n" | |
12985 | "An ordered list as a regular-expression\n") | |
12986 | { | |
d62a17ae | 12987 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
12988 | int direct = 0; | |
12989 | char *cl_number_or_name = NULL; | |
42f914d4 | 12990 | |
d62a17ae | 12991 | int idx = 0; |
12992 | argv_find(argv, argc, "(100-500)", &idx); | |
12993 | argv_find(argv, argc, "WORD", &idx); | |
12994 | cl_number_or_name = argv[idx]->arg; | |
12995 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12996 | : COMMUNITY_DENY; | |
12997 | argv_find(argv, argc, "LINE", &idx); | |
12998 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12999 | |
d62a17ae | 13000 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
13001 | direct, style); | |
42f914d4 | 13002 | |
d62a17ae | 13003 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13004 | |
d62a17ae | 13005 | if (ret < 0) { |
13006 | community_list_perror(vty, ret); | |
13007 | return CMD_WARNING_CONFIG_FAILED; | |
13008 | } | |
42f914d4 | 13009 | |
d62a17ae | 13010 | return CMD_SUCCESS; |
718e3744 | 13011 | } |
13012 | ||
fee6e4e4 | 13013 | DEFUN (no_ip_extcommunity_list_standard_all, |
13014 | no_ip_extcommunity_list_standard_all_cmd, | |
e961923c | 13015 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
813d4307 DW |
13016 | NO_STR |
13017 | IP_STR | |
13018 | EXTCOMMUNITY_LIST_STR | |
13019 | "Extended Community list number (standard)\n" | |
718e3744 | 13020 | "Specify standard extcommunity-list\n" |
5bf15956 | 13021 | "Community list name\n" |
718e3744 | 13022 | "Specify community to reject\n" |
13023 | "Specify community to accept\n" | |
13024 | EXTCOMMUNITY_VAL_STR) | |
13025 | { | |
d62a17ae | 13026 | int deleteall = 0; |
42f914d4 | 13027 | |
d62a17ae | 13028 | int style = EXTCOMMUNITY_LIST_STANDARD; |
13029 | int direct = 0; | |
13030 | char *cl_number_or_name = NULL; | |
42f914d4 | 13031 | |
d62a17ae | 13032 | int idx = 0; |
13033 | argv_find(argv, argc, "(1-99)", &idx); | |
13034 | argv_find(argv, argc, "WORD", &idx); | |
13035 | cl_number_or_name = argv[idx]->arg; | |
13036 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13037 | : COMMUNITY_DENY; | |
13038 | argv_find(argv, argc, "AA:NN", &idx); | |
13039 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13040 | |
d62a17ae | 13041 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
13042 | direct, style, deleteall); | |
42f914d4 | 13043 | |
d62a17ae | 13044 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13045 | |
d62a17ae | 13046 | if (ret < 0) { |
13047 | community_list_perror(vty, ret); | |
13048 | return CMD_WARNING_CONFIG_FAILED; | |
13049 | } | |
42f914d4 | 13050 | |
d62a17ae | 13051 | return CMD_SUCCESS; |
718e3744 | 13052 | } |
13053 | ||
5bf15956 DW |
13054 | DEFUN (no_ip_extcommunity_list_expanded_all, |
13055 | no_ip_extcommunity_list_expanded_all_cmd, | |
e961923c | 13056 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 13057 | NO_STR |
13058 | IP_STR | |
13059 | EXTCOMMUNITY_LIST_STR | |
13060 | "Extended Community list number (expanded)\n" | |
718e3744 | 13061 | "Specify expanded extcommunity-list\n" |
5bf15956 | 13062 | "Extended Community list name\n" |
718e3744 | 13063 | "Specify community to reject\n" |
13064 | "Specify community to accept\n" | |
13065 | "An ordered list as a regular-expression\n") | |
13066 | { | |
d62a17ae | 13067 | int deleteall = 0; |
42f914d4 | 13068 | |
d62a17ae | 13069 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
13070 | int direct = 0; | |
13071 | char *cl_number_or_name = NULL; | |
42f914d4 | 13072 | |
d62a17ae | 13073 | int idx = 0; |
13074 | argv_find(argv, argc, "(100-500)", &idx); | |
13075 | argv_find(argv, argc, "WORD", &idx); | |
13076 | cl_number_or_name = argv[idx]->arg; | |
13077 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13078 | : COMMUNITY_DENY; | |
13079 | argv_find(argv, argc, "LINE", &idx); | |
13080 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13081 | |
d62a17ae | 13082 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
13083 | direct, style, deleteall); | |
42f914d4 | 13084 | |
d62a17ae | 13085 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13086 | |
d62a17ae | 13087 | if (ret < 0) { |
13088 | community_list_perror(vty, ret); | |
13089 | return CMD_WARNING_CONFIG_FAILED; | |
13090 | } | |
42f914d4 | 13091 | |
d62a17ae | 13092 | return CMD_SUCCESS; |
718e3744 | 13093 | } |
13094 | ||
d62a17ae | 13095 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 13096 | { |
d62a17ae | 13097 | struct community_entry *entry; |
718e3744 | 13098 | |
d62a17ae | 13099 | for (entry = list->head; entry; entry = entry->next) { |
13100 | if (entry == list->head) { | |
13101 | if (all_digit(list->name)) | |
13102 | vty_out(vty, "Extended community %s list %s\n", | |
13103 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13104 | ? "standard" | |
13105 | : "(expanded) access", | |
13106 | list->name); | |
13107 | else | |
13108 | vty_out(vty, | |
13109 | "Named extended community %s list %s\n", | |
13110 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13111 | ? "standard" | |
13112 | : "expanded", | |
13113 | list->name); | |
13114 | } | |
13115 | if (entry->any) | |
13116 | vty_out(vty, " %s\n", | |
13117 | community_direct_str(entry->direct)); | |
13118 | else | |
13119 | vty_out(vty, " %s %s\n", | |
13120 | community_direct_str(entry->direct), | |
13121 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13122 | ? entry->u.ecom->str | |
13123 | : entry->config); | |
13124 | } | |
718e3744 | 13125 | } |
13126 | ||
13127 | DEFUN (show_ip_extcommunity_list, | |
13128 | show_ip_extcommunity_list_cmd, | |
13129 | "show ip extcommunity-list", | |
13130 | SHOW_STR | |
13131 | IP_STR | |
13132 | "List extended-community list\n") | |
13133 | { | |
d62a17ae | 13134 | struct community_list *list; |
13135 | struct community_list_master *cm; | |
718e3744 | 13136 | |
d62a17ae | 13137 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
13138 | if (!cm) | |
13139 | return CMD_SUCCESS; | |
718e3744 | 13140 | |
d62a17ae | 13141 | for (list = cm->num.head; list; list = list->next) |
13142 | extcommunity_list_show(vty, list); | |
718e3744 | 13143 | |
d62a17ae | 13144 | for (list = cm->str.head; list; list = list->next) |
13145 | extcommunity_list_show(vty, list); | |
718e3744 | 13146 | |
d62a17ae | 13147 | return CMD_SUCCESS; |
718e3744 | 13148 | } |
13149 | ||
13150 | DEFUN (show_ip_extcommunity_list_arg, | |
13151 | show_ip_extcommunity_list_arg_cmd, | |
6147e2c6 | 13152 | "show ip extcommunity-list <(1-500)|WORD>", |
718e3744 | 13153 | SHOW_STR |
13154 | IP_STR | |
13155 | "List extended-community list\n" | |
13156 | "Extcommunity-list number\n" | |
13157 | "Extcommunity-list name\n") | |
13158 | { | |
d62a17ae | 13159 | int idx_comm_list = 3; |
13160 | struct community_list *list; | |
718e3744 | 13161 | |
d62a17ae | 13162 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
13163 | EXTCOMMUNITY_LIST_MASTER); | |
13164 | if (!list) { | |
13165 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
13166 | return CMD_WARNING; | |
13167 | } | |
718e3744 | 13168 | |
d62a17ae | 13169 | extcommunity_list_show(vty, list); |
718e3744 | 13170 | |
d62a17ae | 13171 | return CMD_SUCCESS; |
718e3744 | 13172 | } |
6b0655a2 | 13173 | |
718e3744 | 13174 | /* Return configuration string of community-list entry. */ |
d62a17ae | 13175 | static const char *community_list_config_str(struct community_entry *entry) |
718e3744 | 13176 | { |
d62a17ae | 13177 | const char *str; |
718e3744 | 13178 | |
d62a17ae | 13179 | if (entry->any) |
13180 | str = ""; | |
13181 | else { | |
13182 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
13183 | str = community_str(entry->u.com); | |
13184 | else | |
13185 | str = entry->config; | |
13186 | } | |
13187 | return str; | |
718e3744 | 13188 | } |
13189 | ||
13190 | /* Display community-list and extcommunity-list configuration. */ | |
d62a17ae | 13191 | static int community_list_config_write(struct vty *vty) |
13192 | { | |
13193 | struct community_list *list; | |
13194 | struct community_entry *entry; | |
13195 | struct community_list_master *cm; | |
13196 | int write = 0; | |
13197 | ||
13198 | /* Community-list. */ | |
13199 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
13200 | ||
13201 | for (list = cm->num.head; list; list = list->next) | |
13202 | for (entry = list->head; entry; entry = entry->next) { | |
13203 | vty_out(vty, "ip community-list %s %s %s\n", list->name, | |
13204 | community_direct_str(entry->direct), | |
13205 | community_list_config_str(entry)); | |
13206 | write++; | |
13207 | } | |
13208 | for (list = cm->str.head; list; list = list->next) | |
13209 | for (entry = list->head; entry; entry = entry->next) { | |
13210 | vty_out(vty, "ip community-list %s %s %s %s\n", | |
13211 | entry->style == COMMUNITY_LIST_STANDARD | |
13212 | ? "standard" | |
13213 | : "expanded", | |
13214 | list->name, community_direct_str(entry->direct), | |
13215 | community_list_config_str(entry)); | |
13216 | write++; | |
13217 | } | |
13218 | ||
13219 | /* Extcommunity-list. */ | |
13220 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
13221 | ||
13222 | for (list = cm->num.head; list; list = list->next) | |
13223 | for (entry = list->head; entry; entry = entry->next) { | |
13224 | vty_out(vty, "ip extcommunity-list %s %s %s\n", | |
13225 | list->name, community_direct_str(entry->direct), | |
13226 | community_list_config_str(entry)); | |
13227 | write++; | |
13228 | } | |
13229 | for (list = cm->str.head; list; list = list->next) | |
13230 | for (entry = list->head; entry; entry = entry->next) { | |
13231 | vty_out(vty, "ip extcommunity-list %s %s %s %s\n", | |
13232 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13233 | ? "standard" | |
13234 | : "expanded", | |
13235 | list->name, community_direct_str(entry->direct), | |
13236 | community_list_config_str(entry)); | |
13237 | write++; | |
13238 | } | |
13239 | ||
13240 | ||
13241 | /* lcommunity-list. */ | |
13242 | cm = community_list_master_lookup(bgp_clist, | |
13243 | LARGE_COMMUNITY_LIST_MASTER); | |
13244 | ||
13245 | for (list = cm->num.head; list; list = list->next) | |
13246 | for (entry = list->head; entry; entry = entry->next) { | |
13247 | vty_out(vty, "ip large-community-list %s %s %s\n", | |
13248 | list->name, community_direct_str(entry->direct), | |
13249 | community_list_config_str(entry)); | |
13250 | write++; | |
13251 | } | |
13252 | for (list = cm->str.head; list; list = list->next) | |
13253 | for (entry = list->head; entry; entry = entry->next) { | |
13254 | vty_out(vty, "ip large-community-list %s %s %s %s\n", | |
13255 | entry->style == LARGE_COMMUNITY_LIST_STANDARD | |
13256 | ? "standard" | |
13257 | : "expanded", | |
13258 | list->name, community_direct_str(entry->direct), | |
13259 | community_list_config_str(entry)); | |
13260 | write++; | |
13261 | } | |
13262 | ||
13263 | return write; | |
13264 | } | |
13265 | ||
13266 | static struct cmd_node community_list_node = { | |
13267 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 13268 | }; |
13269 | ||
d62a17ae | 13270 | static void community_list_vty(void) |
13271 | { | |
13272 | install_node(&community_list_node, community_list_config_write); | |
13273 | ||
13274 | /* Community-list. */ | |
13275 | install_element(CONFIG_NODE, &ip_community_list_standard_cmd); | |
13276 | install_element(CONFIG_NODE, &ip_community_list_expanded_all_cmd); | |
13277 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_cmd); | |
13278 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); | |
13279 | install_element(VIEW_NODE, &show_ip_community_list_cmd); | |
13280 | install_element(VIEW_NODE, &show_ip_community_list_arg_cmd); | |
13281 | ||
13282 | /* Extcommunity-list. */ | |
13283 | install_element(CONFIG_NODE, &ip_extcommunity_list_standard_cmd); | |
13284 | install_element(CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); | |
13285 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); | |
13286 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
13287 | install_element(VIEW_NODE, &show_ip_extcommunity_list_cmd); | |
13288 | install_element(VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
13289 | ||
13290 | /* Large Community List */ | |
13291 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard_cmd); | |
13292 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); | |
13293 | install_element(CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); | |
13294 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
13295 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); | |
13296 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); | |
13297 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
13298 | install_element(CONFIG_NODE, | |
13299 | &no_ip_lcommunity_list_name_expanded_all_cmd); | |
13300 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
13301 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
13302 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
13303 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
13304 | install_element(VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
13305 | install_element(VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 13306 | } |