]>
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" |
555e09d4 | 60 | #include "bgpd/bgp_io.h" |
94c2f693 | 61 | #include "bgpd/bgp_evpn.h" |
718e3744 | 62 | |
d62a17ae | 63 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
64 | struct prefix *range, int exact); | |
65 | ||
66 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) | |
67 | { | |
68 | switch (afi) { | |
69 | case AFI_IP: | |
70 | switch (safi) { | |
71 | case SAFI_UNICAST: | |
72 | return BGP_IPV4_NODE; | |
73 | break; | |
74 | case SAFI_MULTICAST: | |
75 | return BGP_IPV4M_NODE; | |
76 | break; | |
77 | case SAFI_LABELED_UNICAST: | |
78 | return BGP_IPV4L_NODE; | |
79 | break; | |
80 | case SAFI_MPLS_VPN: | |
81 | return BGP_VPNV4_NODE; | |
82 | break; | |
5c525538 RW |
83 | default: |
84 | /* not expected */ | |
85 | return BGP_IPV4_NODE; | |
86 | break; | |
d62a17ae | 87 | } |
88 | break; | |
89 | case AFI_IP6: | |
90 | switch (safi) { | |
91 | case SAFI_UNICAST: | |
92 | return BGP_IPV6_NODE; | |
93 | break; | |
94 | case SAFI_MULTICAST: | |
95 | return BGP_IPV6M_NODE; | |
96 | break; | |
97 | case SAFI_LABELED_UNICAST: | |
98 | return BGP_IPV6L_NODE; | |
99 | break; | |
100 | case SAFI_MPLS_VPN: | |
101 | return BGP_VPNV6_NODE; | |
102 | break; | |
5c525538 RW |
103 | default: |
104 | /* not expected */ | |
105 | return BGP_IPV4_NODE; | |
106 | break; | |
d62a17ae | 107 | } |
108 | break; | |
109 | case AFI_L2VPN: | |
110 | return BGP_EVPN_NODE; | |
111 | break; | |
112 | case AFI_MAX: | |
113 | // We should never be here but to clarify the switch statement.. | |
114 | return BGP_IPV4_NODE; | |
115 | break; | |
116 | } | |
117 | ||
118 | // Impossible to happen | |
119 | return BGP_IPV4_NODE; | |
f51bae9c | 120 | } |
20eb8864 | 121 | |
718e3744 | 122 | /* Utility function to get address family from current node. */ |
d62a17ae | 123 | afi_t bgp_node_afi(struct vty *vty) |
124 | { | |
125 | afi_t afi; | |
126 | switch (vty->node) { | |
127 | case BGP_IPV6_NODE: | |
128 | case BGP_IPV6M_NODE: | |
129 | case BGP_IPV6L_NODE: | |
130 | case BGP_VPNV6_NODE: | |
131 | afi = AFI_IP6; | |
132 | break; | |
133 | case BGP_EVPN_NODE: | |
134 | afi = AFI_L2VPN; | |
135 | break; | |
136 | default: | |
137 | afi = AFI_IP; | |
138 | break; | |
139 | } | |
140 | return afi; | |
718e3744 | 141 | } |
142 | ||
143 | /* Utility function to get subsequent address family from current | |
144 | node. */ | |
d62a17ae | 145 | safi_t bgp_node_safi(struct vty *vty) |
146 | { | |
147 | safi_t safi; | |
148 | switch (vty->node) { | |
149 | case BGP_VPNV4_NODE: | |
150 | case BGP_VPNV6_NODE: | |
151 | safi = SAFI_MPLS_VPN; | |
152 | break; | |
153 | case BGP_IPV4M_NODE: | |
154 | case BGP_IPV6M_NODE: | |
155 | safi = SAFI_MULTICAST; | |
156 | break; | |
157 | case BGP_EVPN_NODE: | |
158 | safi = SAFI_EVPN; | |
159 | break; | |
160 | case BGP_IPV4L_NODE: | |
161 | case BGP_IPV6L_NODE: | |
162 | safi = SAFI_LABELED_UNICAST; | |
163 | break; | |
164 | default: | |
165 | safi = SAFI_UNICAST; | |
166 | break; | |
167 | } | |
168 | return safi; | |
718e3744 | 169 | } |
170 | ||
55f91488 QY |
171 | /** |
172 | * Converts an AFI in string form to afi_t | |
173 | * | |
174 | * @param afi string, one of | |
175 | * - "ipv4" | |
176 | * - "ipv6" | |
177 | * @return the corresponding afi_t | |
178 | */ | |
d62a17ae | 179 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
180 | { | |
181 | afi_t afi = AFI_MAX; /* unknown */ | |
182 | if (strmatch(afi_str, "ipv4")) | |
183 | afi = AFI_IP; | |
184 | else if (strmatch(afi_str, "ipv6")) | |
185 | afi = AFI_IP6; | |
186 | return afi; | |
187 | } | |
188 | ||
189 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
190 | afi_t *afi) | |
191 | { | |
192 | int ret = 0; | |
193 | if (argv_find(argv, argc, "ipv4", index)) { | |
194 | ret = 1; | |
195 | if (afi) | |
196 | *afi = AFI_IP; | |
197 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
198 | ret = 1; | |
199 | if (afi) | |
200 | *afi = AFI_IP6; | |
201 | } | |
202 | return ret; | |
46f296b4 LB |
203 | } |
204 | ||
375a2e67 | 205 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 206 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
207 | { | |
208 | safi_t safi = SAFI_MAX; /* unknown */ | |
209 | if (strmatch(safi_str, "multicast")) | |
210 | safi = SAFI_MULTICAST; | |
211 | else if (strmatch(safi_str, "unicast")) | |
212 | safi = SAFI_UNICAST; | |
213 | else if (strmatch(safi_str, "vpn")) | |
214 | safi = SAFI_MPLS_VPN; | |
215 | else if (strmatch(safi_str, "labeled-unicast")) | |
216 | safi = SAFI_LABELED_UNICAST; | |
217 | return safi; | |
218 | } | |
219 | ||
220 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
221 | safi_t *safi) | |
222 | { | |
223 | int ret = 0; | |
224 | if (argv_find(argv, argc, "unicast", index)) { | |
225 | ret = 1; | |
226 | if (safi) | |
227 | *safi = SAFI_UNICAST; | |
228 | } else if (argv_find(argv, argc, "multicast", index)) { | |
229 | ret = 1; | |
230 | if (safi) | |
231 | *safi = SAFI_MULTICAST; | |
232 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
233 | ret = 1; | |
234 | if (safi) | |
235 | *safi = SAFI_LABELED_UNICAST; | |
236 | } else if (argv_find(argv, argc, "vpn", index)) { | |
237 | ret = 1; | |
238 | if (safi) | |
239 | *safi = SAFI_MPLS_VPN; | |
240 | } | |
241 | return ret; | |
46f296b4 LB |
242 | } |
243 | ||
7eeee51e | 244 | /* |
f212a857 | 245 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 246 | * |
f212a857 DS |
247 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
248 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
249 | * to appropriate values for the calling function. This is to allow the |
250 | * calling function to make decisions appropriate for the show command | |
251 | * that is being parsed. | |
252 | * | |
253 | * The show commands are generally of the form: | |
d62a17ae | 254 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
255 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
256 | * |
257 | * Since we use argv_find if the show command in particular doesn't have: | |
258 | * [ip] | |
18c57037 | 259 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 260 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
261 | * The command parsing should still be ok. |
262 | * | |
263 | * vty -> The vty for the command so we can output some useful data in | |
264 | * the event of a parse error in the vrf. | |
265 | * argv -> The command tokens | |
266 | * argc -> How many command tokens we have | |
d62a17ae | 267 | * idx -> The current place in the command, generally should be 0 for this |
268 | * function | |
7eeee51e DS |
269 | * afi -> The parsed afi if it was included in the show command, returned here |
270 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 271 | * bgp -> Pointer to the bgp data structure we need to fill in. |
7eeee51e DS |
272 | * |
273 | * The function returns the correct location in the parse tree for the | |
274 | * last token found. | |
0e37c258 DS |
275 | * |
276 | * Returns 0 for failure to parse correctly, else the idx position of where | |
277 | * it found the last token. | |
7eeee51e | 278 | */ |
d62a17ae | 279 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
280 | struct cmd_token **argv, int argc, | |
281 | int *idx, afi_t *afi, safi_t *safi, | |
282 | struct bgp **bgp) | |
283 | { | |
284 | char *vrf_name = NULL; | |
285 | ||
286 | assert(afi); | |
287 | assert(safi); | |
288 | assert(bgp); | |
289 | ||
290 | if (argv_find(argv, argc, "ip", idx)) | |
291 | *afi = AFI_IP; | |
292 | ||
293 | if (argv_find(argv, argc, "view", idx) | |
294 | || argv_find(argv, argc, "vrf", idx)) { | |
295 | vrf_name = argv[*idx + 1]->arg; | |
296 | ||
297 | if (strmatch(vrf_name, "all")) | |
298 | *bgp = NULL; | |
299 | else { | |
300 | *bgp = bgp_lookup_by_name(vrf_name); | |
301 | if (!*bgp) { | |
302 | vty_out(vty, | |
303 | "View/Vrf specified is unknown: %s\n", | |
304 | vrf_name); | |
305 | *idx = 0; | |
306 | return 0; | |
307 | } | |
308 | } | |
309 | } else { | |
310 | *bgp = bgp_get_default(); | |
311 | if (!*bgp) { | |
312 | vty_out(vty, "Unable to find default BGP instance\n"); | |
313 | *idx = 0; | |
314 | return 0; | |
315 | } | |
316 | } | |
317 | ||
318 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
319 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
320 | ||
321 | *idx += 1; | |
322 | return *idx; | |
323 | } | |
324 | ||
325 | static int peer_address_self_check(struct bgp *bgp, union sockunion *su) | |
326 | { | |
327 | struct interface *ifp = NULL; | |
328 | ||
329 | if (su->sa.sa_family == AF_INET) | |
330 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
331 | else if (su->sa.sa_family == AF_INET6) | |
332 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
333 | su->sin6.sin6_scope_id, | |
334 | bgp->vrf_id); | |
335 | ||
336 | if (ifp) | |
337 | return 1; | |
338 | ||
339 | return 0; | |
718e3744 | 340 | } |
341 | ||
342 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
343 | /* This is used only for configuration, so disallow if attempted on |
344 | * a dynamic neighbor. | |
345 | */ | |
d62a17ae | 346 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
347 | { | |
348 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
349 | int ret; | |
350 | union sockunion su; | |
351 | struct peer *peer; | |
352 | ||
353 | if (!bgp) { | |
354 | return NULL; | |
355 | } | |
356 | ||
357 | ret = str2sockunion(ip_str, &su); | |
358 | if (ret < 0) { | |
359 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
360 | if (!peer) { | |
361 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
362 | == NULL) { | |
363 | vty_out(vty, | |
364 | "%% Malformed address or name: %s\n", | |
365 | ip_str); | |
366 | return NULL; | |
367 | } | |
368 | } | |
369 | } else { | |
370 | peer = peer_lookup(bgp, &su); | |
371 | if (!peer) { | |
372 | vty_out(vty, | |
373 | "%% Specify remote-as or peer-group commands first\n"); | |
374 | return NULL; | |
375 | } | |
376 | if (peer_dynamic_neighbor(peer)) { | |
377 | vty_out(vty, | |
378 | "%% Operation not allowed on a dynamic neighbor\n"); | |
379 | return NULL; | |
380 | } | |
381 | } | |
382 | return peer; | |
718e3744 | 383 | } |
384 | ||
385 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
386 | /* This is used only for configuration, so disallow if attempted on |
387 | * a dynamic neighbor. | |
388 | */ | |
d62a17ae | 389 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
390 | { | |
391 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
392 | int ret; | |
393 | union sockunion su; | |
394 | struct peer *peer = NULL; | |
395 | struct peer_group *group = NULL; | |
396 | ||
397 | if (!bgp) { | |
398 | return NULL; | |
399 | } | |
400 | ||
401 | ret = str2sockunion(peer_str, &su); | |
402 | if (ret == 0) { | |
403 | /* IP address, locate peer. */ | |
404 | peer = peer_lookup(bgp, &su); | |
405 | } else { | |
406 | /* Not IP, could match either peer configured on interface or a | |
407 | * group. */ | |
408 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
409 | if (!peer) | |
410 | group = peer_group_lookup(bgp, peer_str); | |
411 | } | |
412 | ||
413 | if (peer) { | |
414 | if (peer_dynamic_neighbor(peer)) { | |
415 | vty_out(vty, | |
416 | "%% Operation not allowed on a dynamic neighbor\n"); | |
417 | return NULL; | |
418 | } | |
419 | ||
420 | return peer; | |
421 | } | |
422 | ||
423 | if (group) | |
424 | return group->conf; | |
425 | ||
426 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
427 | ||
428 | return NULL; | |
429 | } | |
430 | ||
431 | int bgp_vty_return(struct vty *vty, int ret) | |
432 | { | |
433 | const char *str = NULL; | |
434 | ||
435 | switch (ret) { | |
436 | case BGP_ERR_INVALID_VALUE: | |
437 | str = "Invalid value"; | |
438 | break; | |
439 | case BGP_ERR_INVALID_FLAG: | |
440 | str = "Invalid flag"; | |
441 | break; | |
442 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
443 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
444 | break; | |
445 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
446 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
447 | break; | |
448 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
449 | str = "Specify remote-as or peer-group remote AS first"; | |
450 | break; | |
451 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
452 | str = "Cannot change the peer-group. Deconfigure first"; | |
453 | break; | |
454 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
455 | str = "Peer is not a member of this peer-group"; | |
456 | break; | |
457 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
458 | str = "Prefix/distribute list can not co-exist"; | |
459 | break; | |
460 | case BGP_ERR_NOT_INTERNAL_PEER: | |
461 | str = "Invalid command. Not an internal neighbor"; | |
462 | break; | |
463 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
464 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
465 | break; | |
466 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
467 | str = "Local-AS allowed only for EBGP peers"; | |
468 | break; | |
469 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
470 | str = "Cannot have local-as same as BGP AS number"; | |
471 | break; | |
472 | case BGP_ERR_TCPSIG_FAILED: | |
473 | str = "Error while applying TCP-Sig to session(s)"; | |
474 | break; | |
475 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
476 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
477 | break; | |
478 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
479 | str = "ttl-security only allowed for EBGP peers"; | |
480 | break; | |
481 | case BGP_ERR_AS_OVERRIDE: | |
482 | str = "as-override cannot be configured for IBGP peers"; | |
483 | break; | |
484 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
485 | str = "Invalid limit for number of dynamic neighbors"; | |
486 | break; | |
487 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
488 | str = "Dynamic neighbor listen range already exists"; | |
489 | break; | |
490 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
491 | str = "Operation not allowed on a dynamic neighbor"; | |
492 | break; | |
493 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
494 | str = "Operation not allowed on a directly connected neighbor"; | |
495 | break; | |
496 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
497 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; | |
498 | break; | |
499 | } | |
500 | if (str) { | |
501 | vty_out(vty, "%% %s\n", str); | |
502 | return CMD_WARNING_CONFIG_FAILED; | |
503 | } | |
504 | return CMD_SUCCESS; | |
718e3744 | 505 | } |
506 | ||
7aafcaca | 507 | /* BGP clear sort. */ |
d62a17ae | 508 | enum clear_sort { |
509 | clear_all, | |
510 | clear_peer, | |
511 | clear_group, | |
512 | clear_external, | |
513 | clear_as | |
7aafcaca DS |
514 | }; |
515 | ||
d62a17ae | 516 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
517 | safi_t safi, int error) | |
518 | { | |
519 | switch (error) { | |
520 | case BGP_ERR_AF_UNCONFIGURED: | |
521 | vty_out(vty, | |
522 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
523 | afi_safi_print(afi, safi), peer->host); | |
524 | break; | |
525 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
526 | vty_out(vty, | |
527 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
528 | peer->host); | |
529 | break; | |
530 | default: | |
531 | break; | |
532 | } | |
7aafcaca DS |
533 | } |
534 | ||
535 | /* `clear ip bgp' functions. */ | |
d62a17ae | 536 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
537 | enum clear_sort sort, enum bgp_clear_type stype, | |
538 | const char *arg) | |
539 | { | |
540 | int ret; | |
541 | struct peer *peer; | |
542 | struct listnode *node, *nnode; | |
543 | ||
544 | /* Clear all neighbors. */ | |
545 | /* | |
546 | * Pass along pointer to next node to peer_clear() when walking all | |
547 | * nodes | |
548 | * on the BGP instance as that may get freed if it is a doppelganger | |
549 | */ | |
550 | if (sort == clear_all) { | |
551 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
552 | if (stype == BGP_CLEAR_SOFT_NONE) | |
553 | ret = peer_clear(peer, &nnode); | |
554 | else if (peer->afc[afi][safi]) | |
555 | ret = peer_clear_soft(peer, afi, safi, stype); | |
556 | else | |
557 | ret = 0; | |
558 | ||
559 | if (ret < 0) | |
560 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
04b6bdc0 | 561 | } |
d62a17ae | 562 | |
563 | /* This is to apply read-only mode on this clear. */ | |
564 | if (stype == BGP_CLEAR_SOFT_NONE) | |
565 | bgp->update_delay_over = 0; | |
566 | ||
567 | return CMD_SUCCESS; | |
7aafcaca DS |
568 | } |
569 | ||
d62a17ae | 570 | /* Clear specified neighbors. */ |
571 | if (sort == clear_peer) { | |
572 | union sockunion su; | |
573 | int ret; | |
574 | ||
575 | /* Make sockunion for lookup. */ | |
576 | ret = str2sockunion(arg, &su); | |
577 | if (ret < 0) { | |
578 | peer = peer_lookup_by_conf_if(bgp, arg); | |
579 | if (!peer) { | |
580 | peer = peer_lookup_by_hostname(bgp, arg); | |
581 | if (!peer) { | |
582 | vty_out(vty, | |
583 | "Malformed address or name: %s\n", | |
584 | arg); | |
585 | return CMD_WARNING; | |
586 | } | |
587 | } | |
588 | } else { | |
589 | peer = peer_lookup(bgp, &su); | |
590 | if (!peer) { | |
591 | vty_out(vty, | |
592 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
593 | arg); | |
594 | return CMD_WARNING; | |
595 | } | |
596 | } | |
7aafcaca | 597 | |
d62a17ae | 598 | if (stype == BGP_CLEAR_SOFT_NONE) |
599 | ret = peer_clear(peer, NULL); | |
600 | else | |
601 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 602 | |
d62a17ae | 603 | if (ret < 0) |
604 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 605 | |
d62a17ae | 606 | return CMD_SUCCESS; |
7aafcaca | 607 | } |
7aafcaca | 608 | |
d62a17ae | 609 | /* Clear all peer-group members. */ |
610 | if (sort == clear_group) { | |
611 | struct peer_group *group; | |
7aafcaca | 612 | |
d62a17ae | 613 | group = peer_group_lookup(bgp, arg); |
614 | if (!group) { | |
615 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
616 | return CMD_WARNING; | |
617 | } | |
618 | ||
619 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
620 | if (stype == BGP_CLEAR_SOFT_NONE) { | |
621 | peer_clear(peer, NULL); | |
622 | continue; | |
623 | } | |
624 | ||
625 | if (!peer->afc[afi][safi]) | |
626 | continue; | |
627 | ||
628 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 629 | |
d62a17ae | 630 | if (ret < 0) |
631 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
632 | } | |
633 | return CMD_SUCCESS; | |
7aafcaca | 634 | } |
7aafcaca | 635 | |
d62a17ae | 636 | if (sort == clear_external) { |
637 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
638 | if (peer->sort == BGP_PEER_IBGP) | |
639 | continue; | |
7aafcaca | 640 | |
d62a17ae | 641 | if (stype == BGP_CLEAR_SOFT_NONE) |
642 | ret = peer_clear(peer, &nnode); | |
643 | else | |
644 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 645 | |
d62a17ae | 646 | if (ret < 0) |
647 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
648 | } | |
649 | return CMD_SUCCESS; | |
650 | } | |
651 | ||
652 | if (sort == clear_as) { | |
653 | as_t as; | |
654 | int find = 0; | |
655 | ||
656 | as = strtoul(arg, NULL, 10); | |
657 | ||
658 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
659 | if (peer->as != as) | |
660 | continue; | |
661 | ||
662 | find = 1; | |
663 | if (stype == BGP_CLEAR_SOFT_NONE) | |
664 | ret = peer_clear(peer, &nnode); | |
665 | else | |
666 | ret = peer_clear_soft(peer, afi, safi, stype); | |
667 | ||
668 | if (ret < 0) | |
669 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
670 | } | |
671 | if (!find) | |
672 | vty_out(vty, | |
673 | "%%BGP: No peer is configured with AS %s\n", | |
674 | arg); | |
675 | return CMD_SUCCESS; | |
676 | } | |
677 | ||
678 | return CMD_SUCCESS; | |
679 | } | |
680 | ||
681 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
682 | safi_t safi, enum clear_sort sort, | |
683 | enum bgp_clear_type stype, const char *arg) | |
684 | { | |
685 | struct bgp *bgp; | |
686 | ||
687 | /* BGP structure lookup. */ | |
688 | if (name) { | |
689 | bgp = bgp_lookup_by_name(name); | |
690 | if (bgp == NULL) { | |
691 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
692 | return CMD_WARNING; | |
693 | } | |
694 | } else { | |
695 | bgp = bgp_get_default(); | |
696 | if (bgp == NULL) { | |
697 | vty_out(vty, "No BGP process is configured\n"); | |
698 | return CMD_WARNING; | |
699 | } | |
700 | } | |
701 | ||
702 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
703 | } |
704 | ||
705 | /* clear soft inbound */ | |
d62a17ae | 706 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 707 | { |
d62a17ae | 708 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
709 | BGP_CLEAR_SOFT_IN, NULL); | |
710 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
711 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
712 | } |
713 | ||
714 | /* clear soft outbound */ | |
d62a17ae | 715 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 716 | { |
d62a17ae | 717 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
718 | BGP_CLEAR_SOFT_OUT, NULL); | |
719 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
720 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
721 | } |
722 | ||
723 | ||
f787d7a0 | 724 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 725 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
726 | #endif |
727 | ||
718e3744 | 728 | /* BGP global configuration. */ |
729 | ||
730 | DEFUN (bgp_multiple_instance_func, | |
731 | bgp_multiple_instance_cmd, | |
732 | "bgp multiple-instance", | |
733 | BGP_STR | |
734 | "Enable bgp multiple instance\n") | |
735 | { | |
d62a17ae | 736 | bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE); |
737 | return CMD_SUCCESS; | |
718e3744 | 738 | } |
739 | ||
740 | DEFUN (no_bgp_multiple_instance, | |
741 | no_bgp_multiple_instance_cmd, | |
742 | "no bgp multiple-instance", | |
743 | NO_STR | |
744 | BGP_STR | |
745 | "BGP multiple instance\n") | |
746 | { | |
d62a17ae | 747 | int ret; |
718e3744 | 748 | |
d62a17ae | 749 | ret = bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE); |
750 | if (ret < 0) { | |
751 | vty_out(vty, "%% There are more than two BGP instances\n"); | |
752 | return CMD_WARNING_CONFIG_FAILED; | |
753 | } | |
754 | return CMD_SUCCESS; | |
718e3744 | 755 | } |
756 | ||
757 | DEFUN (bgp_config_type, | |
758 | bgp_config_type_cmd, | |
6147e2c6 | 759 | "bgp config-type <cisco|zebra>", |
718e3744 | 760 | BGP_STR |
761 | "Configuration type\n" | |
762 | "cisco\n" | |
763 | "zebra\n") | |
764 | { | |
d62a17ae | 765 | int idx = 0; |
766 | if (argv_find(argv, argc, "cisco", &idx)) | |
767 | bgp_option_set(BGP_OPT_CONFIG_CISCO); | |
768 | else | |
769 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); | |
718e3744 | 770 | |
d62a17ae | 771 | return CMD_SUCCESS; |
718e3744 | 772 | } |
773 | ||
774 | DEFUN (no_bgp_config_type, | |
775 | no_bgp_config_type_cmd, | |
c7178fe7 | 776 | "no bgp config-type [<cisco|zebra>]", |
718e3744 | 777 | NO_STR |
778 | BGP_STR | |
838758ac DW |
779 | "Display configuration type\n" |
780 | "cisco\n" | |
781 | "zebra\n") | |
718e3744 | 782 | { |
d62a17ae | 783 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
784 | return CMD_SUCCESS; | |
718e3744 | 785 | } |
786 | ||
813d4307 | 787 | |
718e3744 | 788 | DEFUN (no_synchronization, |
789 | no_synchronization_cmd, | |
790 | "no synchronization", | |
791 | NO_STR | |
792 | "Perform IGP synchronization\n") | |
793 | { | |
d62a17ae | 794 | return CMD_SUCCESS; |
718e3744 | 795 | } |
796 | ||
797 | DEFUN (no_auto_summary, | |
798 | no_auto_summary_cmd, | |
799 | "no auto-summary", | |
800 | NO_STR | |
801 | "Enable automatic network number summarization\n") | |
802 | { | |
d62a17ae | 803 | return CMD_SUCCESS; |
718e3744 | 804 | } |
3d515fd9 | 805 | |
718e3744 | 806 | /* "router bgp" commands. */ |
505e5056 | 807 | DEFUN_NOSH (router_bgp, |
f412b39a | 808 | router_bgp_cmd, |
18c57037 | 809 | "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 810 | ROUTER_STR |
811 | BGP_STR | |
31500417 DW |
812 | AS_STR |
813 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 814 | { |
d62a17ae | 815 | int idx_asn = 2; |
816 | int idx_view_vrf = 3; | |
817 | int idx_vrf = 4; | |
818 | int ret; | |
819 | as_t as; | |
820 | struct bgp *bgp; | |
821 | const char *name = NULL; | |
822 | enum bgp_instance_type inst_type; | |
823 | ||
824 | // "router bgp" without an ASN | |
825 | if (argc == 2) { | |
826 | // Pending: Make VRF option available for ASN less config | |
827 | bgp = bgp_get_default(); | |
828 | ||
829 | if (bgp == NULL) { | |
830 | vty_out(vty, "%% No BGP process is configured\n"); | |
831 | return CMD_WARNING_CONFIG_FAILED; | |
832 | } | |
833 | ||
834 | if (listcount(bm->bgp) > 1) { | |
835 | vty_out(vty, | |
836 | "%% Multiple BGP processes are configured\n"); | |
837 | return CMD_WARNING_CONFIG_FAILED; | |
838 | } | |
839 | } | |
840 | ||
841 | // "router bgp X" | |
842 | else { | |
843 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
844 | ||
845 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
846 | if (argc > 3) { | |
847 | name = argv[idx_vrf]->arg; | |
848 | ||
849 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) | |
850 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
851 | else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
852 | inst_type = BGP_INSTANCE_TYPE_VIEW; | |
853 | } | |
854 | ||
855 | ret = bgp_get(&bgp, &as, name, inst_type); | |
856 | switch (ret) { | |
857 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
858 | vty_out(vty, | |
859 | "Please specify 'bgp multiple-instance' first\n"); | |
860 | return CMD_WARNING_CONFIG_FAILED; | |
861 | case BGP_ERR_AS_MISMATCH: | |
862 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
863 | return CMD_WARNING_CONFIG_FAILED; | |
864 | case BGP_ERR_INSTANCE_MISMATCH: | |
865 | vty_out(vty, | |
866 | "BGP instance name and AS number mismatch\n"); | |
867 | vty_out(vty, | |
868 | "BGP instance is already running; AS is %u\n", | |
869 | as); | |
870 | return CMD_WARNING_CONFIG_FAILED; | |
871 | } | |
872 | ||
873 | /* Pending: handle when user tries to change a view to vrf n vv. | |
874 | */ | |
875 | } | |
876 | ||
0b5131c9 MK |
877 | /* unset the auto created flag as the user config is now present */ |
878 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 879 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
880 | ||
881 | return CMD_SUCCESS; | |
718e3744 | 882 | } |
883 | ||
718e3744 | 884 | /* "no router bgp" commands. */ |
885 | DEFUN (no_router_bgp, | |
886 | no_router_bgp_cmd, | |
18c57037 | 887 | "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 888 | NO_STR |
889 | ROUTER_STR | |
890 | BGP_STR | |
31500417 DW |
891 | AS_STR |
892 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 893 | { |
d62a17ae | 894 | int idx_asn = 3; |
895 | int idx_vrf = 5; | |
896 | as_t as; | |
897 | struct bgp *bgp; | |
898 | const char *name = NULL; | |
718e3744 | 899 | |
d62a17ae | 900 | // "no router bgp" without an ASN |
901 | if (argc == 3) { | |
902 | // Pending: Make VRF option available for ASN less config | |
903 | bgp = bgp_get_default(); | |
718e3744 | 904 | |
d62a17ae | 905 | if (bgp == NULL) { |
906 | vty_out(vty, "%% No BGP process is configured\n"); | |
907 | return CMD_WARNING_CONFIG_FAILED; | |
908 | } | |
7fb21a9f | 909 | |
d62a17ae | 910 | if (listcount(bm->bgp) > 1) { |
911 | vty_out(vty, | |
912 | "%% Multiple BGP processes are configured\n"); | |
913 | return CMD_WARNING_CONFIG_FAILED; | |
914 | } | |
0b5131c9 MK |
915 | |
916 | if (bgp->l3vni) { | |
917 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
918 | bgp->l3vni); | |
919 | return CMD_WARNING_CONFIG_FAILED; | |
920 | } | |
d62a17ae | 921 | } else { |
922 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 923 | |
d62a17ae | 924 | if (argc > 4) |
925 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 926 | |
d62a17ae | 927 | /* Lookup bgp structure. */ |
928 | bgp = bgp_lookup(as, name); | |
929 | if (!bgp) { | |
930 | vty_out(vty, "%% Can't find BGP instance\n"); | |
931 | return CMD_WARNING_CONFIG_FAILED; | |
932 | } | |
0b5131c9 MK |
933 | |
934 | if (bgp->l3vni) { | |
935 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
936 | bgp->l3vni); | |
937 | return CMD_WARNING_CONFIG_FAILED; | |
938 | } | |
d62a17ae | 939 | } |
718e3744 | 940 | |
d62a17ae | 941 | bgp_delete(bgp); |
718e3744 | 942 | |
d62a17ae | 943 | return CMD_SUCCESS; |
718e3744 | 944 | } |
945 | ||
6b0655a2 | 946 | |
718e3744 | 947 | /* BGP router-id. */ |
948 | ||
f787d7a0 | 949 | DEFPY (bgp_router_id, |
718e3744 | 950 | bgp_router_id_cmd, |
951 | "bgp router-id A.B.C.D", | |
952 | BGP_STR | |
953 | "Override configured router identifier\n" | |
954 | "Manually configured router identifier\n") | |
955 | { | |
d62a17ae | 956 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
957 | bgp_router_id_static_set(bgp, router_id); | |
958 | return CMD_SUCCESS; | |
718e3744 | 959 | } |
960 | ||
f787d7a0 | 961 | DEFPY (no_bgp_router_id, |
718e3744 | 962 | no_bgp_router_id_cmd, |
31500417 | 963 | "no bgp router-id [A.B.C.D]", |
718e3744 | 964 | NO_STR |
965 | BGP_STR | |
31500417 DW |
966 | "Override configured router identifier\n" |
967 | "Manually configured router identifier\n") | |
718e3744 | 968 | { |
d62a17ae | 969 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 970 | |
d62a17ae | 971 | if (router_id_str) { |
972 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
973 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
974 | return CMD_WARNING_CONFIG_FAILED; | |
975 | } | |
e018c7cc | 976 | } |
718e3744 | 977 | |
d62a17ae | 978 | router_id.s_addr = 0; |
979 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 980 | |
d62a17ae | 981 | return CMD_SUCCESS; |
718e3744 | 982 | } |
983 | ||
6b0655a2 | 984 | |
718e3744 | 985 | /* BGP Cluster ID. */ |
718e3744 | 986 | DEFUN (bgp_cluster_id, |
987 | bgp_cluster_id_cmd, | |
838758ac | 988 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 989 | BGP_STR |
990 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
991 | "Route-Reflector Cluster-id in IP address format\n" |
992 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 993 | { |
d62a17ae | 994 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
995 | int idx_ipv4 = 2; | |
996 | int ret; | |
997 | struct in_addr cluster; | |
718e3744 | 998 | |
d62a17ae | 999 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1000 | if (!ret) { | |
1001 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1002 | return CMD_WARNING_CONFIG_FAILED; | |
1003 | } | |
718e3744 | 1004 | |
d62a17ae | 1005 | bgp_cluster_id_set(bgp, &cluster); |
1006 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1007 | |
d62a17ae | 1008 | return CMD_SUCCESS; |
718e3744 | 1009 | } |
1010 | ||
718e3744 | 1011 | DEFUN (no_bgp_cluster_id, |
1012 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1013 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1014 | NO_STR |
1015 | BGP_STR | |
838758ac DW |
1016 | "Configure Route-Reflector Cluster-id\n" |
1017 | "Route-Reflector Cluster-id in IP address format\n" | |
1018 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1019 | { |
d62a17ae | 1020 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1021 | bgp_cluster_id_unset(bgp); | |
1022 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1023 | |
d62a17ae | 1024 | return CMD_SUCCESS; |
718e3744 | 1025 | } |
1026 | ||
718e3744 | 1027 | DEFUN (bgp_confederation_identifier, |
1028 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1029 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1030 | "BGP specific commands\n" |
1031 | "AS confederation parameters\n" | |
1032 | "AS number\n" | |
1033 | "Set routing domain confederation AS\n") | |
1034 | { | |
d62a17ae | 1035 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1036 | int idx_number = 3; | |
1037 | as_t as; | |
718e3744 | 1038 | |
d62a17ae | 1039 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1040 | |
d62a17ae | 1041 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1042 | |
d62a17ae | 1043 | return CMD_SUCCESS; |
718e3744 | 1044 | } |
1045 | ||
1046 | DEFUN (no_bgp_confederation_identifier, | |
1047 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1048 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1049 | NO_STR |
1050 | "BGP specific commands\n" | |
1051 | "AS confederation parameters\n" | |
3a2d747c QY |
1052 | "AS number\n" |
1053 | "Set routing domain confederation AS\n") | |
718e3744 | 1054 | { |
d62a17ae | 1055 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1056 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1057 | |
d62a17ae | 1058 | return CMD_SUCCESS; |
718e3744 | 1059 | } |
1060 | ||
718e3744 | 1061 | DEFUN (bgp_confederation_peers, |
1062 | bgp_confederation_peers_cmd, | |
12dcf78e | 1063 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1064 | "BGP specific commands\n" |
1065 | "AS confederation parameters\n" | |
1066 | "Peer ASs in BGP confederation\n" | |
1067 | AS_STR) | |
1068 | { | |
d62a17ae | 1069 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1070 | int idx_asn = 3; | |
1071 | as_t as; | |
1072 | int i; | |
718e3744 | 1073 | |
d62a17ae | 1074 | for (i = idx_asn; i < argc; i++) { |
1075 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1076 | |
d62a17ae | 1077 | if (bgp->as == as) { |
1078 | vty_out(vty, | |
1079 | "%% Local member-AS not allowed in confed peer list\n"); | |
1080 | continue; | |
1081 | } | |
718e3744 | 1082 | |
d62a17ae | 1083 | bgp_confederation_peers_add(bgp, as); |
1084 | } | |
1085 | return CMD_SUCCESS; | |
718e3744 | 1086 | } |
1087 | ||
1088 | DEFUN (no_bgp_confederation_peers, | |
1089 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1090 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1091 | NO_STR |
1092 | "BGP specific commands\n" | |
1093 | "AS confederation parameters\n" | |
1094 | "Peer ASs in BGP confederation\n" | |
1095 | AS_STR) | |
1096 | { | |
d62a17ae | 1097 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1098 | int idx_asn = 4; | |
1099 | as_t as; | |
1100 | int i; | |
718e3744 | 1101 | |
d62a17ae | 1102 | for (i = idx_asn; i < argc; i++) { |
1103 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1104 | |
d62a17ae | 1105 | bgp_confederation_peers_remove(bgp, as); |
1106 | } | |
1107 | return CMD_SUCCESS; | |
718e3744 | 1108 | } |
6b0655a2 | 1109 | |
5e242b0d DS |
1110 | /** |
1111 | * Central routine for maximum-paths configuration. | |
1112 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1113 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1114 | */ | |
d62a17ae | 1115 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
1116 | const char *mpaths, u_int16_t options, | |
1117 | int set) | |
1118 | { | |
1119 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1120 | u_int16_t maxpaths = 0; | |
1121 | int ret; | |
1122 | afi_t afi; | |
1123 | safi_t safi; | |
1124 | ||
1125 | afi = bgp_node_afi(vty); | |
1126 | safi = bgp_node_safi(vty); | |
1127 | ||
1128 | if (set) { | |
1129 | maxpaths = strtol(mpaths, NULL, 10); | |
1130 | if (maxpaths > multipath_num) { | |
1131 | vty_out(vty, | |
1132 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1133 | maxpaths, multipath_num); | |
1134 | return CMD_WARNING_CONFIG_FAILED; | |
1135 | } | |
1136 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1137 | options); | |
1138 | } else | |
1139 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1140 | ||
1141 | if (ret < 0) { | |
1142 | vty_out(vty, | |
1143 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1144 | (set == 1) ? "" : "un", | |
1145 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1146 | maxpaths, afi, safi); | |
1147 | return CMD_WARNING_CONFIG_FAILED; | |
1148 | } | |
1149 | ||
1150 | bgp_recalculate_all_bestpaths(bgp); | |
1151 | ||
1152 | return CMD_SUCCESS; | |
165b5fff JB |
1153 | } |
1154 | ||
abc920f8 DS |
1155 | DEFUN (bgp_maxmed_admin, |
1156 | bgp_maxmed_admin_cmd, | |
1157 | "bgp max-med administrative ", | |
1158 | BGP_STR | |
1159 | "Advertise routes with max-med\n" | |
1160 | "Administratively applied, for an indefinite period\n") | |
1161 | { | |
d62a17ae | 1162 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1163 | |
d62a17ae | 1164 | bgp->v_maxmed_admin = 1; |
1165 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1166 | |
d62a17ae | 1167 | bgp_maxmed_update(bgp); |
abc920f8 | 1168 | |
d62a17ae | 1169 | return CMD_SUCCESS; |
abc920f8 DS |
1170 | } |
1171 | ||
1172 | DEFUN (bgp_maxmed_admin_medv, | |
1173 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1174 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1175 | BGP_STR |
1176 | "Advertise routes with max-med\n" | |
1177 | "Administratively applied, for an indefinite period\n" | |
1178 | "Max MED value to be used\n") | |
1179 | { | |
d62a17ae | 1180 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1181 | int idx_number = 3; | |
abc920f8 | 1182 | |
d62a17ae | 1183 | bgp->v_maxmed_admin = 1; |
1184 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1185 | |
d62a17ae | 1186 | bgp_maxmed_update(bgp); |
abc920f8 | 1187 | |
d62a17ae | 1188 | return CMD_SUCCESS; |
abc920f8 DS |
1189 | } |
1190 | ||
1191 | DEFUN (no_bgp_maxmed_admin, | |
1192 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1193 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1194 | NO_STR |
1195 | BGP_STR | |
1196 | "Advertise routes with max-med\n" | |
838758ac DW |
1197 | "Administratively applied, for an indefinite period\n" |
1198 | "Max MED value to be used\n") | |
abc920f8 | 1199 | { |
d62a17ae | 1200 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1201 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1202 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1203 | bgp_maxmed_update(bgp); | |
abc920f8 | 1204 | |
d62a17ae | 1205 | return CMD_SUCCESS; |
abc920f8 DS |
1206 | } |
1207 | ||
abc920f8 DS |
1208 | DEFUN (bgp_maxmed_onstartup, |
1209 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1210 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1211 | BGP_STR |
1212 | "Advertise routes with max-med\n" | |
1213 | "Effective on a startup\n" | |
1214 | "Time (seconds) period for max-med\n" | |
1215 | "Max MED value to be used\n") | |
1216 | { | |
d62a17ae | 1217 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1218 | int idx = 0; | |
4668a151 | 1219 | |
d62a17ae | 1220 | argv_find(argv, argc, "(5-86400)", &idx); |
1221 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1222 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1223 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1224 | else | |
1225 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1226 | |
d62a17ae | 1227 | bgp_maxmed_update(bgp); |
abc920f8 | 1228 | |
d62a17ae | 1229 | return CMD_SUCCESS; |
abc920f8 DS |
1230 | } |
1231 | ||
1232 | DEFUN (no_bgp_maxmed_onstartup, | |
1233 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1234 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1235 | NO_STR |
1236 | BGP_STR | |
1237 | "Advertise routes with max-med\n" | |
838758ac DW |
1238 | "Effective on a startup\n" |
1239 | "Time (seconds) period for max-med\n" | |
1240 | "Max MED value to be used\n") | |
abc920f8 | 1241 | { |
d62a17ae | 1242 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1243 | |
d62a17ae | 1244 | /* Cancel max-med onstartup if its on */ |
1245 | if (bgp->t_maxmed_onstartup) { | |
1246 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1247 | bgp->maxmed_onstartup_over = 1; | |
1248 | } | |
abc920f8 | 1249 | |
d62a17ae | 1250 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1251 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1252 | |
d62a17ae | 1253 | bgp_maxmed_update(bgp); |
abc920f8 | 1254 | |
d62a17ae | 1255 | return CMD_SUCCESS; |
abc920f8 DS |
1256 | } |
1257 | ||
d62a17ae | 1258 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1259 | const char *wait) | |
f188f2c4 | 1260 | { |
d62a17ae | 1261 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1262 | u_int16_t update_delay; | |
1263 | u_int16_t establish_wait; | |
f188f2c4 | 1264 | |
d62a17ae | 1265 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1266 | |
d62a17ae | 1267 | if (!wait) /* update-delay <delay> */ |
1268 | { | |
1269 | bgp->v_update_delay = update_delay; | |
1270 | bgp->v_establish_wait = bgp->v_update_delay; | |
1271 | return CMD_SUCCESS; | |
1272 | } | |
f188f2c4 | 1273 | |
d62a17ae | 1274 | /* update-delay <delay> <establish-wait> */ |
1275 | establish_wait = atoi(wait); | |
1276 | if (update_delay < establish_wait) { | |
1277 | vty_out(vty, | |
1278 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1279 | return CMD_WARNING_CONFIG_FAILED; | |
1280 | } | |
f188f2c4 | 1281 | |
d62a17ae | 1282 | bgp->v_update_delay = update_delay; |
1283 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1284 | |
d62a17ae | 1285 | return CMD_SUCCESS; |
f188f2c4 DS |
1286 | } |
1287 | ||
d62a17ae | 1288 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1289 | { |
d62a17ae | 1290 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1291 | |
d62a17ae | 1292 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1293 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1294 | |
d62a17ae | 1295 | return CMD_SUCCESS; |
f188f2c4 DS |
1296 | } |
1297 | ||
2b791107 | 1298 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1299 | { |
d62a17ae | 1300 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1301 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1302 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1303 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1304 | vty_out(vty, "\n"); | |
1305 | } | |
f188f2c4 DS |
1306 | } |
1307 | ||
1308 | ||
1309 | /* Update-delay configuration */ | |
1310 | DEFUN (bgp_update_delay, | |
1311 | bgp_update_delay_cmd, | |
6147e2c6 | 1312 | "update-delay (0-3600)", |
f188f2c4 DS |
1313 | "Force initial delay for best-path and updates\n" |
1314 | "Seconds\n") | |
1315 | { | |
d62a17ae | 1316 | int idx_number = 1; |
1317 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1318 | } |
1319 | ||
1320 | DEFUN (bgp_update_delay_establish_wait, | |
1321 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1322 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1323 | "Force initial delay for best-path and updates\n" |
1324 | "Seconds\n" | |
f188f2c4 DS |
1325 | "Seconds\n") |
1326 | { | |
d62a17ae | 1327 | int idx_number = 1; |
1328 | int idx_number_2 = 2; | |
1329 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1330 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1331 | } |
1332 | ||
1333 | /* Update-delay deconfiguration */ | |
1334 | DEFUN (no_bgp_update_delay, | |
1335 | no_bgp_update_delay_cmd, | |
838758ac DW |
1336 | "no update-delay [(0-3600) [(1-3600)]]", |
1337 | NO_STR | |
f188f2c4 | 1338 | "Force initial delay for best-path and updates\n" |
838758ac | 1339 | "Seconds\n" |
7111c1a0 | 1340 | "Seconds\n") |
f188f2c4 | 1341 | { |
d62a17ae | 1342 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1343 | } |
1344 | ||
5e242b0d | 1345 | |
d62a17ae | 1346 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, const char *num, |
1347 | char set) | |
cb1faec9 | 1348 | { |
d62a17ae | 1349 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1350 | |
555e09d4 QY |
1351 | if (set) { |
1352 | uint32_t quanta = strtoul(num, NULL, 10); | |
1353 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, | |
1354 | memory_order_relaxed); | |
1355 | } else { | |
1356 | atomic_store_explicit(&bgp->wpkt_quanta, BGP_WRITE_PACKET_MAX, | |
1357 | memory_order_relaxed); | |
1358 | } | |
1359 | ||
1360 | return CMD_SUCCESS; | |
1361 | } | |
1362 | ||
1363 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, const char *num, | |
1364 | char set) | |
1365 | { | |
1366 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1367 | ||
1368 | if (set) { | |
1369 | uint32_t quanta = strtoul(num, NULL, 10); | |
1370 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, | |
1371 | memory_order_relaxed); | |
1372 | } else { | |
1373 | atomic_store_explicit(&bgp->rpkt_quanta, BGP_READ_PACKET_MAX, | |
1374 | memory_order_relaxed); | |
1375 | } | |
cb1faec9 | 1376 | |
d62a17ae | 1377 | return CMD_SUCCESS; |
cb1faec9 DS |
1378 | } |
1379 | ||
2b791107 | 1380 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1381 | { |
555e09d4 QY |
1382 | uint32_t quanta = |
1383 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1384 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1385 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1386 | } |
1387 | ||
555e09d4 QY |
1388 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1389 | { | |
1390 | uint32_t quanta = | |
1391 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1392 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1393 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1394 | } |
cb1faec9 | 1395 | |
555e09d4 | 1396 | /* Packet quanta configuration */ |
cb1faec9 DS |
1397 | DEFUN (bgp_wpkt_quanta, |
1398 | bgp_wpkt_quanta_cmd, | |
555e09d4 | 1399 | "write-quanta (1-10)", |
cb1faec9 DS |
1400 | "How many packets to write to peer socket per run\n" |
1401 | "Number of packets\n") | |
1402 | { | |
d62a17ae | 1403 | int idx_number = 1; |
1404 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1405 | } |
1406 | ||
cb1faec9 DS |
1407 | DEFUN (no_bgp_wpkt_quanta, |
1408 | no_bgp_wpkt_quanta_cmd, | |
555e09d4 | 1409 | "no write-quanta (1-10)", |
d7fa34c1 | 1410 | NO_STR |
555e09d4 | 1411 | "How many packets to write to peer socket per I/O cycle\n" |
cb1faec9 DS |
1412 | "Number of packets\n") |
1413 | { | |
d62a17ae | 1414 | int idx_number = 2; |
1415 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1416 | } |
1417 | ||
555e09d4 QY |
1418 | DEFUN (bgp_rpkt_quanta, |
1419 | bgp_rpkt_quanta_cmd, | |
1420 | "read-quanta (1-10)", | |
1421 | "How many packets to read from peer socket per I/O cycle\n" | |
1422 | "Number of packets\n") | |
1423 | { | |
1424 | int idx_number = 1; | |
1425 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
1426 | } | |
1427 | ||
1428 | DEFUN (no_bgp_rpkt_quanta, | |
1429 | no_bgp_rpkt_quanta_cmd, | |
1430 | "no read-quanta (1-10)", | |
1431 | NO_STR | |
1432 | "How many packets to read from peer socket per I/O cycle\n" | |
1433 | "Number of packets\n") | |
1434 | { | |
1435 | int idx_number = 2; | |
1436 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
1437 | } | |
1438 | ||
2b791107 | 1439 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1440 | { |
37a333fe | 1441 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1442 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1443 | } |
1444 | ||
1445 | ||
1446 | DEFUN (bgp_coalesce_time, | |
1447 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1448 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1449 | "Subgroup coalesce timer\n" |
1450 | "Subgroup coalesce timer value (in ms)\n") | |
1451 | { | |
d62a17ae | 1452 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1453 | |
d62a17ae | 1454 | int idx = 0; |
1455 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1456 | bgp->heuristic_coalesce = false; |
d62a17ae | 1457 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1458 | return CMD_SUCCESS; | |
3f9c7369 DS |
1459 | } |
1460 | ||
1461 | DEFUN (no_bgp_coalesce_time, | |
1462 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1463 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1464 | NO_STR |
3f9c7369 DS |
1465 | "Subgroup coalesce timer\n" |
1466 | "Subgroup coalesce timer value (in ms)\n") | |
1467 | { | |
d62a17ae | 1468 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1469 | |
37a333fe | 1470 | bgp->heuristic_coalesce = true; |
d62a17ae | 1471 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1472 | return CMD_SUCCESS; | |
3f9c7369 DS |
1473 | } |
1474 | ||
5e242b0d DS |
1475 | /* Maximum-paths configuration */ |
1476 | DEFUN (bgp_maxpaths, | |
1477 | bgp_maxpaths_cmd, | |
6319fd63 | 1478 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1479 | "Forward packets over multiple paths\n" |
1480 | "Number of paths\n") | |
1481 | { | |
d62a17ae | 1482 | int idx_number = 1; |
1483 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1484 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1485 | } |
1486 | ||
d62a17ae | 1487 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1488 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1489 | "Forward packets over multiple paths\n" | |
1490 | "Number of paths\n") | |
596c17ba | 1491 | |
165b5fff JB |
1492 | DEFUN (bgp_maxpaths_ibgp, |
1493 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1494 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1495 | "Forward packets over multiple paths\n" |
1496 | "iBGP-multipath\n" | |
1497 | "Number of paths\n") | |
1498 | { | |
d62a17ae | 1499 | int idx_number = 2; |
1500 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1501 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1502 | } |
165b5fff | 1503 | |
d62a17ae | 1504 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1505 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1506 | "Forward packets over multiple paths\n" | |
1507 | "iBGP-multipath\n" | |
1508 | "Number of paths\n") | |
596c17ba | 1509 | |
5e242b0d DS |
1510 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1511 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1512 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1513 | "Forward packets over multiple paths\n" |
1514 | "iBGP-multipath\n" | |
1515 | "Number of paths\n" | |
1516 | "Match the cluster length\n") | |
1517 | { | |
d62a17ae | 1518 | int idx_number = 2; |
1519 | return bgp_maxpaths_config_vty( | |
1520 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1521 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1522 | } |
1523 | ||
d62a17ae | 1524 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1525 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1526 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1527 | "Forward packets over multiple paths\n" | |
1528 | "iBGP-multipath\n" | |
1529 | "Number of paths\n" | |
1530 | "Match the cluster length\n") | |
596c17ba | 1531 | |
165b5fff JB |
1532 | DEFUN (no_bgp_maxpaths, |
1533 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1534 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1535 | NO_STR |
1536 | "Forward packets over multiple paths\n" | |
1537 | "Number of paths\n") | |
1538 | { | |
d62a17ae | 1539 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1540 | } |
1541 | ||
d62a17ae | 1542 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
a4d82a8a PZ |
1543 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
1544 | NO_STR | |
d62a17ae | 1545 | "Forward packets over multiple paths\n" |
1546 | "Number of paths\n") | |
596c17ba | 1547 | |
165b5fff JB |
1548 | DEFUN (no_bgp_maxpaths_ibgp, |
1549 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1550 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1551 | NO_STR |
1552 | "Forward packets over multiple paths\n" | |
1553 | "iBGP-multipath\n" | |
838758ac DW |
1554 | "Number of paths\n" |
1555 | "Match the cluster length\n") | |
165b5fff | 1556 | { |
d62a17ae | 1557 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1558 | } |
1559 | ||
d62a17ae | 1560 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1561 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1562 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1563 | NO_STR | |
1564 | "Forward packets over multiple paths\n" | |
1565 | "iBGP-multipath\n" | |
1566 | "Number of paths\n" | |
1567 | "Match the cluster length\n") | |
596c17ba | 1568 | |
2b791107 | 1569 | void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 1570 | safi_t safi) |
165b5fff | 1571 | { |
d62a17ae | 1572 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1573 | vty_out(vty, " maximum-paths %d\n", |
1574 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1575 | } | |
165b5fff | 1576 | |
d62a17ae | 1577 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1578 | vty_out(vty, " maximum-paths ibgp %d", |
1579 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1580 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1581 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1582 | vty_out(vty, " equal-cluster-length"); | |
1583 | vty_out(vty, "\n"); | |
1584 | } | |
165b5fff | 1585 | } |
6b0655a2 | 1586 | |
718e3744 | 1587 | /* BGP timers. */ |
1588 | ||
1589 | DEFUN (bgp_timers, | |
1590 | bgp_timers_cmd, | |
6147e2c6 | 1591 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1592 | "Adjust routing timers\n" |
1593 | "BGP timers\n" | |
1594 | "Keepalive interval\n" | |
1595 | "Holdtime\n") | |
1596 | { | |
d62a17ae | 1597 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1598 | int idx_number = 2; | |
1599 | int idx_number_2 = 3; | |
1600 | unsigned long keepalive = 0; | |
1601 | unsigned long holdtime = 0; | |
718e3744 | 1602 | |
d62a17ae | 1603 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1604 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1605 | |
d62a17ae | 1606 | /* Holdtime value check. */ |
1607 | if (holdtime < 3 && holdtime != 0) { | |
1608 | vty_out(vty, | |
1609 | "%% hold time value must be either 0 or greater than 3\n"); | |
1610 | return CMD_WARNING_CONFIG_FAILED; | |
1611 | } | |
718e3744 | 1612 | |
d62a17ae | 1613 | bgp_timers_set(bgp, keepalive, holdtime); |
718e3744 | 1614 | |
d62a17ae | 1615 | return CMD_SUCCESS; |
718e3744 | 1616 | } |
1617 | ||
1618 | DEFUN (no_bgp_timers, | |
1619 | no_bgp_timers_cmd, | |
838758ac | 1620 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1621 | NO_STR |
1622 | "Adjust routing timers\n" | |
838758ac DW |
1623 | "BGP timers\n" |
1624 | "Keepalive interval\n" | |
1625 | "Holdtime\n") | |
718e3744 | 1626 | { |
d62a17ae | 1627 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1628 | bgp_timers_unset(bgp); | |
718e3744 | 1629 | |
d62a17ae | 1630 | return CMD_SUCCESS; |
718e3744 | 1631 | } |
1632 | ||
6b0655a2 | 1633 | |
718e3744 | 1634 | DEFUN (bgp_client_to_client_reflection, |
1635 | bgp_client_to_client_reflection_cmd, | |
1636 | "bgp client-to-client reflection", | |
1637 | "BGP specific commands\n" | |
1638 | "Configure client to client route reflection\n" | |
1639 | "reflection of routes allowed\n") | |
1640 | { | |
d62a17ae | 1641 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1642 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1643 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1644 | |
d62a17ae | 1645 | return CMD_SUCCESS; |
718e3744 | 1646 | } |
1647 | ||
1648 | DEFUN (no_bgp_client_to_client_reflection, | |
1649 | no_bgp_client_to_client_reflection_cmd, | |
1650 | "no bgp client-to-client reflection", | |
1651 | NO_STR | |
1652 | "BGP specific commands\n" | |
1653 | "Configure client to client route reflection\n" | |
1654 | "reflection of routes allowed\n") | |
1655 | { | |
d62a17ae | 1656 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1657 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1658 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1659 | |
d62a17ae | 1660 | return CMD_SUCCESS; |
718e3744 | 1661 | } |
1662 | ||
1663 | /* "bgp always-compare-med" configuration. */ | |
1664 | DEFUN (bgp_always_compare_med, | |
1665 | bgp_always_compare_med_cmd, | |
1666 | "bgp always-compare-med", | |
1667 | "BGP specific commands\n" | |
1668 | "Allow comparing MED from different neighbors\n") | |
1669 | { | |
d62a17ae | 1670 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1671 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1672 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1673 | |
d62a17ae | 1674 | return CMD_SUCCESS; |
718e3744 | 1675 | } |
1676 | ||
1677 | DEFUN (no_bgp_always_compare_med, | |
1678 | no_bgp_always_compare_med_cmd, | |
1679 | "no bgp always-compare-med", | |
1680 | NO_STR | |
1681 | "BGP specific commands\n" | |
1682 | "Allow comparing MED from different neighbors\n") | |
1683 | { | |
d62a17ae | 1684 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1685 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1686 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1687 | |
d62a17ae | 1688 | return CMD_SUCCESS; |
718e3744 | 1689 | } |
6b0655a2 | 1690 | |
718e3744 | 1691 | /* "bgp deterministic-med" configuration. */ |
1692 | DEFUN (bgp_deterministic_med, | |
1693 | bgp_deterministic_med_cmd, | |
1694 | "bgp deterministic-med", | |
1695 | "BGP specific commands\n" | |
1696 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1697 | { | |
d62a17ae | 1698 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 1699 | |
d62a17ae | 1700 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
1701 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1702 | bgp_recalculate_all_bestpaths(bgp); | |
1703 | } | |
7aafcaca | 1704 | |
d62a17ae | 1705 | return CMD_SUCCESS; |
718e3744 | 1706 | } |
1707 | ||
1708 | DEFUN (no_bgp_deterministic_med, | |
1709 | no_bgp_deterministic_med_cmd, | |
1710 | "no bgp deterministic-med", | |
1711 | NO_STR | |
1712 | "BGP specific commands\n" | |
1713 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1714 | { | |
d62a17ae | 1715 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1716 | int bestpath_per_as_used; | |
1717 | afi_t afi; | |
1718 | safi_t safi; | |
1719 | struct peer *peer; | |
1720 | struct listnode *node, *nnode; | |
1721 | ||
1722 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
1723 | bestpath_per_as_used = 0; | |
1724 | ||
1725 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc QY |
1726 | FOREACH_AFI_SAFI (afi, safi) |
1727 | if (CHECK_FLAG( | |
1728 | peer->af_flags[afi][safi], | |
1729 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) { | |
1730 | bestpath_per_as_used = 1; | |
1731 | break; | |
1732 | } | |
d62a17ae | 1733 | |
1734 | if (bestpath_per_as_used) | |
1735 | break; | |
1736 | } | |
1737 | ||
1738 | if (bestpath_per_as_used) { | |
1739 | vty_out(vty, | |
1740 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
1741 | return CMD_WARNING_CONFIG_FAILED; | |
1742 | } else { | |
1743 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1744 | bgp_recalculate_all_bestpaths(bgp); | |
1745 | } | |
1746 | } | |
1747 | ||
1748 | return CMD_SUCCESS; | |
718e3744 | 1749 | } |
538621f2 | 1750 | |
1751 | /* "bgp graceful-restart" configuration. */ | |
1752 | DEFUN (bgp_graceful_restart, | |
1753 | bgp_graceful_restart_cmd, | |
1754 | "bgp graceful-restart", | |
1755 | "BGP specific commands\n" | |
1756 | "Graceful restart capability parameters\n") | |
1757 | { | |
d62a17ae | 1758 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1759 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1760 | return CMD_SUCCESS; | |
538621f2 | 1761 | } |
1762 | ||
1763 | DEFUN (no_bgp_graceful_restart, | |
1764 | no_bgp_graceful_restart_cmd, | |
1765 | "no bgp graceful-restart", | |
1766 | NO_STR | |
1767 | "BGP specific commands\n" | |
1768 | "Graceful restart capability parameters\n") | |
1769 | { | |
d62a17ae | 1770 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1771 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1772 | return CMD_SUCCESS; | |
538621f2 | 1773 | } |
1774 | ||
93406d87 | 1775 | DEFUN (bgp_graceful_restart_stalepath_time, |
1776 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1777 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1778 | "BGP specific commands\n" |
1779 | "Graceful restart capability parameters\n" | |
1780 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1781 | "Delay value (seconds)\n") | |
1782 | { | |
d62a17ae | 1783 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1784 | int idx_number = 3; | |
1785 | u_int32_t stalepath; | |
93406d87 | 1786 | |
d62a17ae | 1787 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
1788 | bgp->stalepath_time = stalepath; | |
1789 | return CMD_SUCCESS; | |
93406d87 | 1790 | } |
1791 | ||
eb6f1b41 PG |
1792 | DEFUN (bgp_graceful_restart_restart_time, |
1793 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1794 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1795 | "BGP specific commands\n" |
1796 | "Graceful restart capability parameters\n" | |
1797 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1798 | "Delay value (seconds)\n") | |
1799 | { | |
d62a17ae | 1800 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1801 | int idx_number = 3; | |
1802 | u_int32_t restart; | |
eb6f1b41 | 1803 | |
d62a17ae | 1804 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
1805 | bgp->restart_time = restart; | |
1806 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1807 | } |
1808 | ||
93406d87 | 1809 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1810 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1811 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1812 | NO_STR |
1813 | "BGP specific commands\n" | |
1814 | "Graceful restart capability parameters\n" | |
838758ac DW |
1815 | "Set the max time to hold onto restarting peer's stale paths\n" |
1816 | "Delay value (seconds)\n") | |
93406d87 | 1817 | { |
d62a17ae | 1818 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1819 | |
d62a17ae | 1820 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
1821 | return CMD_SUCCESS; | |
93406d87 | 1822 | } |
1823 | ||
eb6f1b41 PG |
1824 | DEFUN (no_bgp_graceful_restart_restart_time, |
1825 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1826 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1827 | NO_STR |
1828 | "BGP specific commands\n" | |
1829 | "Graceful restart capability parameters\n" | |
838758ac DW |
1830 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1831 | "Delay value (seconds)\n") | |
eb6f1b41 | 1832 | { |
d62a17ae | 1833 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 1834 | |
d62a17ae | 1835 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
1836 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1837 | } |
1838 | ||
43fc21b3 JC |
1839 | DEFUN (bgp_graceful_restart_preserve_fw, |
1840 | bgp_graceful_restart_preserve_fw_cmd, | |
1841 | "bgp graceful-restart preserve-fw-state", | |
1842 | "BGP specific commands\n" | |
1843 | "Graceful restart capability parameters\n" | |
1844 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1845 | { | |
d62a17ae | 1846 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1847 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1848 | return CMD_SUCCESS; | |
43fc21b3 JC |
1849 | } |
1850 | ||
1851 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
1852 | no_bgp_graceful_restart_preserve_fw_cmd, | |
1853 | "no bgp graceful-restart preserve-fw-state", | |
1854 | NO_STR | |
1855 | "BGP specific commands\n" | |
1856 | "Graceful restart capability parameters\n" | |
1857 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1858 | { | |
d62a17ae | 1859 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1860 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1861 | return CMD_SUCCESS; | |
43fc21b3 JC |
1862 | } |
1863 | ||
7f323236 DW |
1864 | static void bgp_redistribute_redo(struct bgp *bgp) |
1865 | { | |
1866 | afi_t afi; | |
1867 | int i; | |
1868 | struct list *red_list; | |
1869 | struct listnode *node; | |
1870 | struct bgp_redist *red; | |
1871 | ||
a4d82a8a PZ |
1872 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { |
1873 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
7f323236 | 1874 | |
a4d82a8a PZ |
1875 | red_list = bgp->redist[afi][i]; |
1876 | if (!red_list) | |
1877 | continue; | |
7f323236 | 1878 | |
a4d82a8a | 1879 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { |
7f323236 DW |
1880 | bgp_redistribute_resend(bgp, afi, i, |
1881 | red->instance); | |
1882 | } | |
1883 | } | |
1884 | } | |
1885 | } | |
1886 | ||
1887 | /* "bgp graceful-shutdown" configuration */ | |
1888 | DEFUN (bgp_graceful_shutdown, | |
1889 | bgp_graceful_shutdown_cmd, | |
1890 | "bgp graceful-shutdown", | |
1891 | BGP_STR | |
1892 | "Graceful shutdown parameters\n") | |
1893 | { | |
1894 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1895 | ||
1896 | if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
1897 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
1898 | bgp_static_redo_import_check(bgp); | |
1899 | bgp_redistribute_redo(bgp); | |
1900 | bgp_clear_star_soft_out(vty, bgp->name); | |
1901 | bgp_clear_star_soft_in(vty, bgp->name); | |
1902 | } | |
1903 | ||
1904 | return CMD_SUCCESS; | |
1905 | } | |
1906 | ||
1907 | DEFUN (no_bgp_graceful_shutdown, | |
1908 | no_bgp_graceful_shutdown_cmd, | |
1909 | "no bgp graceful-shutdown", | |
1910 | NO_STR | |
1911 | BGP_STR | |
1912 | "Graceful shutdown parameters\n") | |
1913 | { | |
1914 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1915 | ||
1916 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
1917 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
1918 | bgp_static_redo_import_check(bgp); | |
1919 | bgp_redistribute_redo(bgp); | |
1920 | bgp_clear_star_soft_out(vty, bgp->name); | |
1921 | bgp_clear_star_soft_in(vty, bgp->name); | |
1922 | } | |
1923 | ||
1924 | return CMD_SUCCESS; | |
1925 | } | |
1926 | ||
718e3744 | 1927 | /* "bgp fast-external-failover" configuration. */ |
1928 | DEFUN (bgp_fast_external_failover, | |
1929 | bgp_fast_external_failover_cmd, | |
1930 | "bgp fast-external-failover", | |
1931 | BGP_STR | |
1932 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1933 | { | |
d62a17ae | 1934 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1935 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
1936 | return CMD_SUCCESS; | |
718e3744 | 1937 | } |
1938 | ||
1939 | DEFUN (no_bgp_fast_external_failover, | |
1940 | no_bgp_fast_external_failover_cmd, | |
1941 | "no bgp fast-external-failover", | |
1942 | NO_STR | |
1943 | BGP_STR | |
1944 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1945 | { | |
d62a17ae | 1946 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1947 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
1948 | return CMD_SUCCESS; | |
718e3744 | 1949 | } |
6b0655a2 | 1950 | |
718e3744 | 1951 | /* "bgp enforce-first-as" configuration. */ |
1952 | DEFUN (bgp_enforce_first_as, | |
1953 | bgp_enforce_first_as_cmd, | |
1954 | "bgp enforce-first-as", | |
1955 | BGP_STR | |
1956 | "Enforce the first AS for EBGP routes\n") | |
1957 | { | |
d62a17ae | 1958 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1959 | bgp_flag_set(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
1960 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 1961 | |
d62a17ae | 1962 | return CMD_SUCCESS; |
718e3744 | 1963 | } |
1964 | ||
1965 | DEFUN (no_bgp_enforce_first_as, | |
1966 | no_bgp_enforce_first_as_cmd, | |
1967 | "no bgp enforce-first-as", | |
1968 | NO_STR | |
1969 | BGP_STR | |
1970 | "Enforce the first AS for EBGP routes\n") | |
1971 | { | |
d62a17ae | 1972 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1973 | bgp_flag_unset(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
1974 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 1975 | |
d62a17ae | 1976 | return CMD_SUCCESS; |
718e3744 | 1977 | } |
6b0655a2 | 1978 | |
718e3744 | 1979 | /* "bgp bestpath compare-routerid" configuration. */ |
1980 | DEFUN (bgp_bestpath_compare_router_id, | |
1981 | bgp_bestpath_compare_router_id_cmd, | |
1982 | "bgp bestpath compare-routerid", | |
1983 | "BGP specific commands\n" | |
1984 | "Change the default bestpath selection\n" | |
1985 | "Compare router-id for identical EBGP paths\n") | |
1986 | { | |
d62a17ae | 1987 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1988 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
1989 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1990 | |
d62a17ae | 1991 | return CMD_SUCCESS; |
718e3744 | 1992 | } |
1993 | ||
1994 | DEFUN (no_bgp_bestpath_compare_router_id, | |
1995 | no_bgp_bestpath_compare_router_id_cmd, | |
1996 | "no bgp bestpath compare-routerid", | |
1997 | NO_STR | |
1998 | "BGP specific commands\n" | |
1999 | "Change the default bestpath selection\n" | |
2000 | "Compare router-id for identical EBGP paths\n") | |
2001 | { | |
d62a17ae | 2002 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2003 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2004 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2005 | |
d62a17ae | 2006 | return CMD_SUCCESS; |
718e3744 | 2007 | } |
6b0655a2 | 2008 | |
718e3744 | 2009 | /* "bgp bestpath as-path ignore" configuration. */ |
2010 | DEFUN (bgp_bestpath_aspath_ignore, | |
2011 | bgp_bestpath_aspath_ignore_cmd, | |
2012 | "bgp bestpath as-path ignore", | |
2013 | "BGP specific commands\n" | |
2014 | "Change the default bestpath selection\n" | |
2015 | "AS-path attribute\n" | |
2016 | "Ignore as-path length in selecting a route\n") | |
2017 | { | |
d62a17ae | 2018 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2019 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2020 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2021 | |
d62a17ae | 2022 | return CMD_SUCCESS; |
718e3744 | 2023 | } |
2024 | ||
2025 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2026 | no_bgp_bestpath_aspath_ignore_cmd, | |
2027 | "no bgp bestpath as-path ignore", | |
2028 | NO_STR | |
2029 | "BGP specific commands\n" | |
2030 | "Change the default bestpath selection\n" | |
2031 | "AS-path attribute\n" | |
2032 | "Ignore as-path length in selecting a route\n") | |
2033 | { | |
d62a17ae | 2034 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2035 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2036 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2037 | |
d62a17ae | 2038 | return CMD_SUCCESS; |
718e3744 | 2039 | } |
6b0655a2 | 2040 | |
6811845b | 2041 | /* "bgp bestpath as-path confed" configuration. */ |
2042 | DEFUN (bgp_bestpath_aspath_confed, | |
2043 | bgp_bestpath_aspath_confed_cmd, | |
2044 | "bgp bestpath as-path confed", | |
2045 | "BGP specific commands\n" | |
2046 | "Change the default bestpath selection\n" | |
2047 | "AS-path attribute\n" | |
2048 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2049 | { | |
d62a17ae | 2050 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2051 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
2052 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2053 | |
d62a17ae | 2054 | return CMD_SUCCESS; |
6811845b | 2055 | } |
2056 | ||
2057 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2058 | no_bgp_bestpath_aspath_confed_cmd, | |
2059 | "no bgp bestpath as-path confed", | |
2060 | NO_STR | |
2061 | "BGP specific commands\n" | |
2062 | "Change the default bestpath selection\n" | |
2063 | "AS-path attribute\n" | |
2064 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2065 | { | |
d62a17ae | 2066 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2067 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
2068 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2069 | |
d62a17ae | 2070 | return CMD_SUCCESS; |
6811845b | 2071 | } |
6b0655a2 | 2072 | |
2fdd455c PM |
2073 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2074 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2075 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2076 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2077 | "BGP specific commands\n" |
2078 | "Change the default bestpath selection\n" | |
2079 | "AS-path attribute\n" | |
2080 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2081 | "Generate an AS_SET\n" |
16fc1eec DS |
2082 | "Do not generate an AS_SET\n") |
2083 | { | |
d62a17ae | 2084 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2085 | int idx = 0; | |
2086 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 2087 | |
d62a17ae | 2088 | /* no-as-set is now the default behavior so we can silently |
2089 | * ignore it */ | |
2090 | if (argv_find(argv, argc, "as-set", &idx)) | |
2091 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2092 | else | |
2093 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 2094 | |
d62a17ae | 2095 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2096 | |
d62a17ae | 2097 | return CMD_SUCCESS; |
16fc1eec DS |
2098 | } |
2099 | ||
219178b6 DW |
2100 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2101 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2102 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2103 | NO_STR |
2104 | "BGP specific commands\n" | |
2105 | "Change the default bestpath selection\n" | |
2106 | "AS-path attribute\n" | |
2107 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2108 | "Generate an AS_SET\n" |
16fc1eec DS |
2109 | "Do not generate an AS_SET\n") |
2110 | { | |
d62a17ae | 2111 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2112 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
2113 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2114 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2115 | |
d62a17ae | 2116 | return CMD_SUCCESS; |
2fdd455c | 2117 | } |
6b0655a2 | 2118 | |
848973c7 | 2119 | /* "bgp log-neighbor-changes" configuration. */ |
2120 | DEFUN (bgp_log_neighbor_changes, | |
2121 | bgp_log_neighbor_changes_cmd, | |
2122 | "bgp log-neighbor-changes", | |
2123 | "BGP specific commands\n" | |
2124 | "Log neighbor up/down and reset reason\n") | |
2125 | { | |
d62a17ae | 2126 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2127 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2128 | return CMD_SUCCESS; | |
848973c7 | 2129 | } |
2130 | ||
2131 | DEFUN (no_bgp_log_neighbor_changes, | |
2132 | no_bgp_log_neighbor_changes_cmd, | |
2133 | "no bgp log-neighbor-changes", | |
2134 | NO_STR | |
2135 | "BGP specific commands\n" | |
2136 | "Log neighbor up/down and reset reason\n") | |
2137 | { | |
d62a17ae | 2138 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2139 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2140 | return CMD_SUCCESS; | |
848973c7 | 2141 | } |
6b0655a2 | 2142 | |
718e3744 | 2143 | /* "bgp bestpath med" configuration. */ |
2144 | DEFUN (bgp_bestpath_med, | |
2145 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2146 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2147 | "BGP specific commands\n" |
2148 | "Change the default bestpath selection\n" | |
2149 | "MED attribute\n" | |
2150 | "Compare MED among confederation paths\n" | |
838758ac DW |
2151 | "Treat missing MED as the least preferred one\n" |
2152 | "Treat missing MED as the least preferred one\n" | |
2153 | "Compare MED among confederation paths\n") | |
718e3744 | 2154 | { |
d62a17ae | 2155 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2156 | |
d62a17ae | 2157 | int idx = 0; |
2158 | if (argv_find(argv, argc, "confed", &idx)) | |
2159 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2160 | idx = 0; | |
2161 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2162 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2163 | |
d62a17ae | 2164 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2165 | |
d62a17ae | 2166 | return CMD_SUCCESS; |
718e3744 | 2167 | } |
2168 | ||
718e3744 | 2169 | DEFUN (no_bgp_bestpath_med, |
2170 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2171 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2172 | NO_STR |
2173 | "BGP specific commands\n" | |
2174 | "Change the default bestpath selection\n" | |
2175 | "MED attribute\n" | |
2176 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2177 | "Treat missing MED as the least preferred one\n" |
2178 | "Treat missing MED as the least preferred one\n" | |
2179 | "Compare MED among confederation paths\n") | |
718e3744 | 2180 | { |
d62a17ae | 2181 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2182 | |
d62a17ae | 2183 | int idx = 0; |
2184 | if (argv_find(argv, argc, "confed", &idx)) | |
2185 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2186 | idx = 0; | |
2187 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2188 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2189 | |
d62a17ae | 2190 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2191 | |
d62a17ae | 2192 | return CMD_SUCCESS; |
718e3744 | 2193 | } |
2194 | ||
718e3744 | 2195 | /* "no bgp default ipv4-unicast". */ |
2196 | DEFUN (no_bgp_default_ipv4_unicast, | |
2197 | no_bgp_default_ipv4_unicast_cmd, | |
2198 | "no bgp default ipv4-unicast", | |
2199 | NO_STR | |
2200 | "BGP specific commands\n" | |
2201 | "Configure BGP defaults\n" | |
2202 | "Activate ipv4-unicast for a peer by default\n") | |
2203 | { | |
d62a17ae | 2204 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2205 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2206 | return CMD_SUCCESS; | |
718e3744 | 2207 | } |
2208 | ||
2209 | DEFUN (bgp_default_ipv4_unicast, | |
2210 | bgp_default_ipv4_unicast_cmd, | |
2211 | "bgp default ipv4-unicast", | |
2212 | "BGP specific commands\n" | |
2213 | "Configure BGP defaults\n" | |
2214 | "Activate ipv4-unicast for a peer by default\n") | |
2215 | { | |
d62a17ae | 2216 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2217 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2218 | return CMD_SUCCESS; | |
718e3744 | 2219 | } |
6b0655a2 | 2220 | |
04b6bdc0 DW |
2221 | /* Display hostname in certain command outputs */ |
2222 | DEFUN (bgp_default_show_hostname, | |
2223 | bgp_default_show_hostname_cmd, | |
2224 | "bgp default show-hostname", | |
2225 | "BGP specific commands\n" | |
2226 | "Configure BGP defaults\n" | |
2227 | "Show hostname in certain command ouputs\n") | |
2228 | { | |
d62a17ae | 2229 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2230 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2231 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2232 | } |
2233 | ||
2234 | DEFUN (no_bgp_default_show_hostname, | |
2235 | no_bgp_default_show_hostname_cmd, | |
2236 | "no bgp default show-hostname", | |
2237 | NO_STR | |
2238 | "BGP specific commands\n" | |
2239 | "Configure BGP defaults\n" | |
2240 | "Show hostname in certain command ouputs\n") | |
2241 | { | |
d62a17ae | 2242 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2243 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2244 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2245 | } |
2246 | ||
8233ef81 | 2247 | /* "bgp network import-check" configuration. */ |
718e3744 | 2248 | DEFUN (bgp_network_import_check, |
2249 | bgp_network_import_check_cmd, | |
5623e905 | 2250 | "bgp network import-check", |
718e3744 | 2251 | "BGP specific commands\n" |
2252 | "BGP network command\n" | |
5623e905 | 2253 | "Check BGP network route exists in IGP\n") |
718e3744 | 2254 | { |
d62a17ae | 2255 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2256 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2257 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
2258 | bgp_static_redo_import_check(bgp); | |
2259 | } | |
078430f6 | 2260 | |
d62a17ae | 2261 | return CMD_SUCCESS; |
718e3744 | 2262 | } |
2263 | ||
d62a17ae | 2264 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
2265 | "bgp network import-check exact", | |
2266 | "BGP specific commands\n" | |
2267 | "BGP network command\n" | |
2268 | "Check BGP network route exists in IGP\n" | |
2269 | "Match route precisely\n") | |
8233ef81 | 2270 | |
718e3744 | 2271 | DEFUN (no_bgp_network_import_check, |
2272 | no_bgp_network_import_check_cmd, | |
5623e905 | 2273 | "no bgp network import-check", |
718e3744 | 2274 | NO_STR |
2275 | "BGP specific commands\n" | |
2276 | "BGP network command\n" | |
2277 | "Check BGP network route exists in IGP\n") | |
2278 | { | |
d62a17ae | 2279 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2280 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2281 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
2282 | bgp_static_redo_import_check(bgp); | |
2283 | } | |
5623e905 | 2284 | |
d62a17ae | 2285 | return CMD_SUCCESS; |
718e3744 | 2286 | } |
6b0655a2 | 2287 | |
718e3744 | 2288 | DEFUN (bgp_default_local_preference, |
2289 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2290 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2291 | "BGP specific commands\n" |
2292 | "Configure BGP defaults\n" | |
2293 | "local preference (higher=more preferred)\n" | |
2294 | "Configure default local preference value\n") | |
2295 | { | |
d62a17ae | 2296 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2297 | int idx_number = 3; | |
2298 | u_int32_t local_pref; | |
718e3744 | 2299 | |
d62a17ae | 2300 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2301 | |
d62a17ae | 2302 | bgp_default_local_preference_set(bgp, local_pref); |
2303 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 2304 | |
d62a17ae | 2305 | return CMD_SUCCESS; |
718e3744 | 2306 | } |
2307 | ||
2308 | DEFUN (no_bgp_default_local_preference, | |
2309 | no_bgp_default_local_preference_cmd, | |
838758ac | 2310 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2311 | NO_STR |
2312 | "BGP specific commands\n" | |
2313 | "Configure BGP defaults\n" | |
838758ac DW |
2314 | "local preference (higher=more preferred)\n" |
2315 | "Configure default local preference value\n") | |
718e3744 | 2316 | { |
d62a17ae | 2317 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2318 | bgp_default_local_preference_unset(bgp); | |
2319 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2320 | |
d62a17ae | 2321 | return CMD_SUCCESS; |
718e3744 | 2322 | } |
2323 | ||
6b0655a2 | 2324 | |
3f9c7369 DS |
2325 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2326 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2327 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2328 | "BGP specific commands\n" |
2329 | "Configure BGP defaults\n" | |
2330 | "subgroup-pkt-queue-max\n" | |
2331 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2332 | { |
d62a17ae | 2333 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2334 | int idx_number = 3; | |
2335 | u_int32_t max_size; | |
8bd9d948 | 2336 | |
d62a17ae | 2337 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 2338 | |
d62a17ae | 2339 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 2340 | |
d62a17ae | 2341 | return CMD_SUCCESS; |
3f9c7369 DS |
2342 | } |
2343 | ||
2344 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2345 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2346 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2347 | NO_STR |
2348 | "BGP specific commands\n" | |
2349 | "Configure BGP defaults\n" | |
838758ac DW |
2350 | "subgroup-pkt-queue-max\n" |
2351 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2352 | { |
d62a17ae | 2353 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2354 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
2355 | return CMD_SUCCESS; | |
8bd9d948 DS |
2356 | } |
2357 | ||
813d4307 | 2358 | |
8bd9d948 DS |
2359 | DEFUN (bgp_rr_allow_outbound_policy, |
2360 | bgp_rr_allow_outbound_policy_cmd, | |
2361 | "bgp route-reflector allow-outbound-policy", | |
2362 | "BGP specific commands\n" | |
2363 | "Allow modifications made by out route-map\n" | |
2364 | "on ibgp neighbors\n") | |
2365 | { | |
d62a17ae | 2366 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2367 | |
d62a17ae | 2368 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2369 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2370 | update_group_announce_rrclients(bgp); | |
2371 | bgp_clear_star_soft_out(vty, bgp->name); | |
2372 | } | |
8bd9d948 | 2373 | |
d62a17ae | 2374 | return CMD_SUCCESS; |
8bd9d948 DS |
2375 | } |
2376 | ||
2377 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2378 | no_bgp_rr_allow_outbound_policy_cmd, | |
2379 | "no bgp route-reflector allow-outbound-policy", | |
2380 | NO_STR | |
2381 | "BGP specific commands\n" | |
2382 | "Allow modifications made by out route-map\n" | |
2383 | "on ibgp neighbors\n") | |
2384 | { | |
d62a17ae | 2385 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2386 | |
d62a17ae | 2387 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2388 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2389 | update_group_announce_rrclients(bgp); | |
2390 | bgp_clear_star_soft_out(vty, bgp->name); | |
2391 | } | |
8bd9d948 | 2392 | |
d62a17ae | 2393 | return CMD_SUCCESS; |
8bd9d948 DS |
2394 | } |
2395 | ||
f14e6fdb DS |
2396 | DEFUN (bgp_listen_limit, |
2397 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2398 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2399 | "BGP specific commands\n" |
2400 | "Configure BGP defaults\n" | |
2401 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2402 | "Configure Dynamic Neighbors listen limit value\n") | |
2403 | { | |
d62a17ae | 2404 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2405 | int idx_number = 3; | |
2406 | int listen_limit; | |
f14e6fdb | 2407 | |
d62a17ae | 2408 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 2409 | |
d62a17ae | 2410 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 2411 | |
d62a17ae | 2412 | return CMD_SUCCESS; |
f14e6fdb DS |
2413 | } |
2414 | ||
2415 | DEFUN (no_bgp_listen_limit, | |
2416 | no_bgp_listen_limit_cmd, | |
838758ac | 2417 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2418 | "BGP specific commands\n" |
2419 | "Configure BGP defaults\n" | |
2420 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2421 | "Configure Dynamic Neighbors listen limit value to default\n" |
2422 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2423 | { |
d62a17ae | 2424 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2425 | bgp_listen_limit_unset(bgp); | |
2426 | return CMD_SUCCESS; | |
f14e6fdb DS |
2427 | } |
2428 | ||
2429 | ||
20eb8864 | 2430 | /* |
2431 | * Check if this listen range is already configured. Check for exact | |
2432 | * match or overlap based on input. | |
2433 | */ | |
d62a17ae | 2434 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
2435 | struct prefix *range, int exact) | |
2436 | { | |
2437 | struct listnode *node, *nnode; | |
2438 | struct listnode *node1, *nnode1; | |
2439 | struct peer_group *group; | |
2440 | struct prefix *lr; | |
2441 | afi_t afi; | |
2442 | int match; | |
2443 | ||
2444 | afi = family2afi(range->family); | |
2445 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2446 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
2447 | lr)) { | |
2448 | if (exact) | |
2449 | match = prefix_same(range, lr); | |
2450 | else | |
2451 | match = (prefix_match(range, lr) | |
2452 | || prefix_match(lr, range)); | |
2453 | if (match) | |
2454 | return group; | |
2455 | } | |
2456 | } | |
2457 | ||
2458 | return NULL; | |
20eb8864 | 2459 | } |
2460 | ||
f14e6fdb DS |
2461 | DEFUN (bgp_listen_range, |
2462 | bgp_listen_range_cmd, | |
9ccf14f7 | 2463 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2464 | "BGP specific commands\n" |
d7fa34c1 QY |
2465 | "Configure BGP dynamic neighbors listen range\n" |
2466 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2467 | NEIGHBOR_ADDR_STR |
2468 | "Member of the peer-group\n" | |
2469 | "Peer-group name\n") | |
f14e6fdb | 2470 | { |
d62a17ae | 2471 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2472 | struct prefix range; | |
2473 | struct peer_group *group, *existing_group; | |
2474 | afi_t afi; | |
2475 | int ret; | |
2476 | int idx = 0; | |
2477 | ||
2478 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2479 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2480 | char *prefix = argv[idx]->arg; | |
2481 | argv_find(argv, argc, "WORD", &idx); | |
2482 | char *peergroup = argv[idx]->arg; | |
2483 | ||
2484 | /* Convert IP prefix string to struct prefix. */ | |
2485 | ret = str2prefix(prefix, &range); | |
2486 | if (!ret) { | |
2487 | vty_out(vty, "%% Malformed listen range\n"); | |
2488 | return CMD_WARNING_CONFIG_FAILED; | |
2489 | } | |
2490 | ||
2491 | afi = family2afi(range.family); | |
2492 | ||
2493 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2494 | vty_out(vty, | |
2495 | "%% Malformed listen range (link-local address)\n"); | |
2496 | return CMD_WARNING_CONFIG_FAILED; | |
2497 | } | |
2498 | ||
2499 | apply_mask(&range); | |
2500 | ||
2501 | /* Check if same listen range is already configured. */ | |
2502 | existing_group = listen_range_exists(bgp, &range, 1); | |
2503 | if (existing_group) { | |
2504 | if (strcmp(existing_group->name, peergroup) == 0) | |
2505 | return CMD_SUCCESS; | |
2506 | else { | |
2507 | vty_out(vty, | |
2508 | "%% Same listen range is attached to peer-group %s\n", | |
2509 | existing_group->name); | |
2510 | return CMD_WARNING_CONFIG_FAILED; | |
2511 | } | |
2512 | } | |
2513 | ||
2514 | /* Check if an overlapping listen range exists. */ | |
2515 | if (listen_range_exists(bgp, &range, 0)) { | |
2516 | vty_out(vty, | |
2517 | "%% Listen range overlaps with existing listen range\n"); | |
2518 | return CMD_WARNING_CONFIG_FAILED; | |
2519 | } | |
2520 | ||
2521 | group = peer_group_lookup(bgp, peergroup); | |
2522 | if (!group) { | |
2523 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2524 | return CMD_WARNING_CONFIG_FAILED; | |
2525 | } | |
2526 | ||
2527 | ret = peer_group_listen_range_add(group, &range); | |
2528 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
2529 | } |
2530 | ||
2531 | DEFUN (no_bgp_listen_range, | |
2532 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2533 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2534 | NO_STR | |
f14e6fdb | 2535 | "BGP specific commands\n" |
d7fa34c1 QY |
2536 | "Unconfigure BGP dynamic neighbors listen range\n" |
2537 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2538 | NEIGHBOR_ADDR_STR | |
2539 | "Member of the peer-group\n" | |
2540 | "Peer-group name\n") | |
f14e6fdb | 2541 | { |
d62a17ae | 2542 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2543 | struct prefix range; | |
2544 | struct peer_group *group; | |
2545 | afi_t afi; | |
2546 | int ret; | |
2547 | int idx = 0; | |
2548 | ||
2549 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2550 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2551 | char *prefix = argv[idx]->arg; | |
2552 | argv_find(argv, argc, "WORD", &idx); | |
2553 | char *peergroup = argv[idx]->arg; | |
2554 | ||
2555 | /* Convert IP prefix string to struct prefix. */ | |
2556 | ret = str2prefix(prefix, &range); | |
2557 | if (!ret) { | |
2558 | vty_out(vty, "%% Malformed listen range\n"); | |
2559 | return CMD_WARNING_CONFIG_FAILED; | |
2560 | } | |
2561 | ||
2562 | afi = family2afi(range.family); | |
2563 | ||
2564 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2565 | vty_out(vty, | |
2566 | "%% Malformed listen range (link-local address)\n"); | |
2567 | return CMD_WARNING_CONFIG_FAILED; | |
2568 | } | |
2569 | ||
2570 | apply_mask(&range); | |
2571 | ||
2572 | group = peer_group_lookup(bgp, peergroup); | |
2573 | if (!group) { | |
2574 | vty_out(vty, "%% Peer-group does not exist\n"); | |
2575 | return CMD_WARNING_CONFIG_FAILED; | |
2576 | } | |
2577 | ||
2578 | ret = peer_group_listen_range_del(group, &range); | |
2579 | return bgp_vty_return(vty, ret); | |
2580 | } | |
2581 | ||
2b791107 | 2582 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 2583 | { |
2584 | struct peer_group *group; | |
2585 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2586 | struct prefix *range; | |
2587 | afi_t afi; | |
2588 | char buf[PREFIX2STR_BUFFER]; | |
2589 | ||
2590 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2591 | vty_out(vty, " bgp listen limit %d\n", | |
2592 | bgp->dynamic_neighbors_limit); | |
2593 | ||
2594 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2595 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
2596 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
2597 | nrnode, range)) { | |
2598 | prefix2str(range, buf, sizeof(buf)); | |
2599 | vty_out(vty, | |
2600 | " bgp listen range %s peer-group %s\n", | |
2601 | buf, group->name); | |
2602 | } | |
2603 | } | |
2604 | } | |
f14e6fdb DS |
2605 | } |
2606 | ||
2607 | ||
907f92c8 DS |
2608 | DEFUN (bgp_disable_connected_route_check, |
2609 | bgp_disable_connected_route_check_cmd, | |
2610 | "bgp disable-ebgp-connected-route-check", | |
2611 | "BGP specific commands\n" | |
2612 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2613 | { | |
d62a17ae | 2614 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2615 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2616 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2617 | |
d62a17ae | 2618 | return CMD_SUCCESS; |
907f92c8 DS |
2619 | } |
2620 | ||
2621 | DEFUN (no_bgp_disable_connected_route_check, | |
2622 | no_bgp_disable_connected_route_check_cmd, | |
2623 | "no bgp disable-ebgp-connected-route-check", | |
2624 | NO_STR | |
2625 | "BGP specific commands\n" | |
2626 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2627 | { | |
d62a17ae | 2628 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2629 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2630 | bgp_clear_star_soft_in(vty, bgp->name); | |
2631 | ||
2632 | return CMD_SUCCESS; | |
2633 | } | |
2634 | ||
2635 | ||
2636 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
2637 | const char *as_str, afi_t afi, safi_t safi) | |
2638 | { | |
2639 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2640 | int ret; | |
2641 | as_t as; | |
2642 | int as_type = AS_SPECIFIED; | |
2643 | union sockunion su; | |
2644 | ||
2645 | if (as_str[0] == 'i') { | |
2646 | as = 0; | |
2647 | as_type = AS_INTERNAL; | |
2648 | } else if (as_str[0] == 'e') { | |
2649 | as = 0; | |
2650 | as_type = AS_EXTERNAL; | |
2651 | } else { | |
2652 | /* Get AS number. */ | |
2653 | as = strtoul(as_str, NULL, 10); | |
2654 | } | |
2655 | ||
2656 | /* If peer is peer group, call proper function. */ | |
2657 | ret = str2sockunion(peer_str, &su); | |
2658 | if (ret < 0) { | |
2659 | /* Check for peer by interface */ | |
2660 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, | |
2661 | safi); | |
2662 | if (ret < 0) { | |
2663 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); | |
2664 | if (ret < 0) { | |
2665 | vty_out(vty, | |
2666 | "%% Create the peer-group or interface first\n"); | |
2667 | return CMD_WARNING_CONFIG_FAILED; | |
2668 | } | |
2669 | return CMD_SUCCESS; | |
2670 | } | |
2671 | } else { | |
2672 | if (peer_address_self_check(bgp, &su)) { | |
2673 | vty_out(vty, | |
2674 | "%% Can not configure the local system as neighbor\n"); | |
2675 | return CMD_WARNING_CONFIG_FAILED; | |
2676 | } | |
2677 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
2678 | } | |
2679 | ||
2680 | /* This peer belongs to peer group. */ | |
2681 | switch (ret) { | |
2682 | case BGP_ERR_PEER_GROUP_MEMBER: | |
2683 | vty_out(vty, | |
2684 | "%% Peer-group AS %u. Cannot configure remote-as for member\n", | |
2685 | as); | |
2686 | return CMD_WARNING_CONFIG_FAILED; | |
2687 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
2688 | vty_out(vty, | |
2689 | "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n", | |
2690 | as, as_str); | |
2691 | return CMD_WARNING_CONFIG_FAILED; | |
2692 | } | |
2693 | return bgp_vty_return(vty, ret); | |
718e3744 | 2694 | } |
2695 | ||
f26845f9 QY |
2696 | DEFUN (bgp_default_shutdown, |
2697 | bgp_default_shutdown_cmd, | |
2698 | "[no] bgp default shutdown", | |
2699 | NO_STR | |
2700 | BGP_STR | |
2701 | "Configure BGP defaults\n" | |
b012cbe2 | 2702 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
2703 | { |
2704 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2705 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
2706 | return CMD_SUCCESS; | |
2707 | } | |
2708 | ||
718e3744 | 2709 | DEFUN (neighbor_remote_as, |
2710 | neighbor_remote_as_cmd, | |
3a2d747c | 2711 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2712 | NEIGHBOR_STR |
2713 | NEIGHBOR_ADDR_STR2 | |
2714 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2715 | AS_STR |
3a2d747c QY |
2716 | "Internal BGP peer\n" |
2717 | "External BGP peer\n") | |
718e3744 | 2718 | { |
d62a17ae | 2719 | int idx_peer = 1; |
2720 | int idx_remote_as = 3; | |
2721 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
2722 | argv[idx_remote_as]->arg, AFI_IP, | |
2723 | SAFI_UNICAST); | |
2724 | } | |
2725 | ||
2726 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
2727 | afi_t afi, safi_t safi, int v6only, | |
2728 | const char *peer_group_name, | |
2729 | const char *as_str) | |
2730 | { | |
2731 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2732 | as_t as = 0; | |
2733 | int as_type = AS_UNSPECIFIED; | |
2734 | struct peer *peer; | |
2735 | struct peer_group *group; | |
2736 | int ret = 0; | |
2737 | union sockunion su; | |
2738 | ||
2739 | group = peer_group_lookup(bgp, conf_if); | |
2740 | ||
2741 | if (group) { | |
2742 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
2743 | return CMD_WARNING_CONFIG_FAILED; | |
2744 | } | |
2745 | ||
2746 | if (as_str) { | |
2747 | if (as_str[0] == 'i') { | |
2748 | as_type = AS_INTERNAL; | |
2749 | } else if (as_str[0] == 'e') { | |
2750 | as_type = AS_EXTERNAL; | |
2751 | } else { | |
2752 | /* Get AS number. */ | |
2753 | as = strtoul(as_str, NULL, 10); | |
2754 | as_type = AS_SPECIFIED; | |
2755 | } | |
2756 | } | |
2757 | ||
2758 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
2759 | if (peer) { | |
2760 | if (as_str) | |
2761 | ret = peer_remote_as(bgp, &su, conf_if, &as, as_type, | |
2762 | afi, safi); | |
2763 | } else { | |
2764 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2765 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
2766 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2767 | as_type, 0, 0, NULL); | |
2768 | else | |
2769 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2770 | as_type, afi, safi, NULL); | |
2771 | ||
2772 | if (!peer) { | |
2773 | vty_out(vty, "%% BGP failed to create peer\n"); | |
2774 | return CMD_WARNING_CONFIG_FAILED; | |
2775 | } | |
2776 | ||
2777 | if (v6only) | |
2778 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2779 | ||
2780 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
2781 | * this | |
2782 | * any unnumbered peer in order to not worry about run-time | |
2783 | * transitions | |
2784 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
2785 | * address | |
2786 | * gets deleted later etc.) | |
2787 | */ | |
2788 | if (peer->ifp) | |
2789 | bgp_zebra_initiate_radv(bgp, peer); | |
2790 | } | |
2791 | ||
2792 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
2793 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
2794 | if (v6only) | |
2795 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2796 | else | |
2797 | UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2798 | ||
2799 | /* v6only flag changed. Reset bgp seesion */ | |
2800 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2801 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2802 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2803 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2804 | } else | |
2805 | bgp_session_reset(peer); | |
2806 | } | |
2807 | ||
2808 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) | |
2809 | peer_flag_set(peer, PEER_FLAG_CAPABILITY_ENHE); | |
2810 | ||
2811 | if (peer_group_name) { | |
2812 | group = peer_group_lookup(bgp, peer_group_name); | |
2813 | if (!group) { | |
2814 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2815 | return CMD_WARNING_CONFIG_FAILED; | |
2816 | } | |
2817 | ||
2818 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
2819 | } | |
2820 | ||
2821 | return bgp_vty_return(vty, ret); | |
a80beece DS |
2822 | } |
2823 | ||
4c48cf63 DW |
2824 | DEFUN (neighbor_interface_config, |
2825 | neighbor_interface_config_cmd, | |
31500417 | 2826 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2827 | NEIGHBOR_STR |
2828 | "Interface name or neighbor tag\n" | |
31500417 DW |
2829 | "Enable BGP on interface\n" |
2830 | "Member of the peer-group\n" | |
16cedbb0 | 2831 | "Peer-group name\n") |
4c48cf63 | 2832 | { |
d62a17ae | 2833 | int idx_word = 1; |
2834 | int idx_peer_group_word = 4; | |
31500417 | 2835 | |
d62a17ae | 2836 | if (argc > idx_peer_group_word) |
2837 | return peer_conf_interface_get( | |
2838 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2839 | argv[idx_peer_group_word]->arg, NULL); | |
2840 | else | |
2841 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2842 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
2843 | } |
2844 | ||
4c48cf63 DW |
2845 | DEFUN (neighbor_interface_config_v6only, |
2846 | neighbor_interface_config_v6only_cmd, | |
31500417 | 2847 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
2848 | NEIGHBOR_STR |
2849 | "Interface name or neighbor tag\n" | |
2850 | "Enable BGP on interface\n" | |
31500417 DW |
2851 | "Enable BGP with v6 link-local only\n" |
2852 | "Member of the peer-group\n" | |
16cedbb0 | 2853 | "Peer-group name\n") |
4c48cf63 | 2854 | { |
d62a17ae | 2855 | int idx_word = 1; |
2856 | int idx_peer_group_word = 5; | |
31500417 | 2857 | |
d62a17ae | 2858 | if (argc > idx_peer_group_word) |
2859 | return peer_conf_interface_get( | |
2860 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2861 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 2862 | |
d62a17ae | 2863 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
2864 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
2865 | } |
2866 | ||
a80beece | 2867 | |
b3a39dc5 DD |
2868 | DEFUN (neighbor_interface_config_remote_as, |
2869 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2870 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2871 | NEIGHBOR_STR |
2872 | "Interface name or neighbor tag\n" | |
2873 | "Enable BGP on interface\n" | |
3a2d747c | 2874 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2875 | AS_STR |
3a2d747c QY |
2876 | "Internal BGP peer\n" |
2877 | "External BGP peer\n") | |
b3a39dc5 | 2878 | { |
d62a17ae | 2879 | int idx_word = 1; |
2880 | int idx_remote_as = 4; | |
2881 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2882 | SAFI_UNICAST, 0, NULL, | |
2883 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2884 | } |
2885 | ||
2886 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
2887 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 2888 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2889 | NEIGHBOR_STR |
2890 | "Interface name or neighbor tag\n" | |
3a2d747c | 2891 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 2892 | "Enable BGP on interface\n" |
3a2d747c | 2893 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2894 | AS_STR |
3a2d747c QY |
2895 | "Internal BGP peer\n" |
2896 | "External BGP peer\n") | |
b3a39dc5 | 2897 | { |
d62a17ae | 2898 | int idx_word = 1; |
2899 | int idx_remote_as = 5; | |
2900 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2901 | SAFI_UNICAST, 1, NULL, | |
2902 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2903 | } |
2904 | ||
718e3744 | 2905 | DEFUN (neighbor_peer_group, |
2906 | neighbor_peer_group_cmd, | |
2907 | "neighbor WORD peer-group", | |
2908 | NEIGHBOR_STR | |
a80beece | 2909 | "Interface name or neighbor tag\n" |
718e3744 | 2910 | "Configure peer-group\n") |
2911 | { | |
d62a17ae | 2912 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2913 | int idx_word = 1; | |
2914 | struct peer *peer; | |
2915 | struct peer_group *group; | |
718e3744 | 2916 | |
d62a17ae | 2917 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
2918 | if (peer) { | |
2919 | vty_out(vty, "%% Name conflict with interface: \n"); | |
2920 | return CMD_WARNING_CONFIG_FAILED; | |
2921 | } | |
718e3744 | 2922 | |
d62a17ae | 2923 | group = peer_group_get(bgp, argv[idx_word]->arg); |
2924 | if (!group) { | |
2925 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
2926 | return CMD_WARNING_CONFIG_FAILED; | |
2927 | } | |
718e3744 | 2928 | |
d62a17ae | 2929 | return CMD_SUCCESS; |
718e3744 | 2930 | } |
2931 | ||
2932 | DEFUN (no_neighbor, | |
2933 | no_neighbor_cmd, | |
dab8cd00 | 2934 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 2935 | NO_STR |
2936 | NEIGHBOR_STR | |
3a2d747c QY |
2937 | NEIGHBOR_ADDR_STR2 |
2938 | "Specify a BGP neighbor\n" | |
2939 | AS_STR | |
2940 | "Internal BGP peer\n" | |
2941 | "External BGP peer\n") | |
718e3744 | 2942 | { |
d62a17ae | 2943 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2944 | int idx_peer = 2; | |
2945 | int ret; | |
2946 | union sockunion su; | |
2947 | struct peer_group *group; | |
2948 | struct peer *peer; | |
2949 | struct peer *other; | |
2950 | ||
2951 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
2952 | if (ret < 0) { | |
2953 | /* look up for neighbor by interface name config. */ | |
2954 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
2955 | if (peer) { | |
2956 | /* Request zebra to terminate IPv6 RAs on this | |
2957 | * interface. */ | |
2958 | if (peer->ifp) | |
2959 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
2960 | peer_delete(peer); | |
2961 | return CMD_SUCCESS; | |
2962 | } | |
f14e6fdb | 2963 | |
d62a17ae | 2964 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
2965 | if (group) | |
2966 | peer_group_delete(group); | |
2967 | else { | |
2968 | vty_out(vty, "%% Create the peer-group first\n"); | |
2969 | return CMD_WARNING_CONFIG_FAILED; | |
2970 | } | |
2971 | } else { | |
2972 | peer = peer_lookup(bgp, &su); | |
2973 | if (peer) { | |
2974 | if (peer_dynamic_neighbor(peer)) { | |
2975 | vty_out(vty, | |
2976 | "%% Operation not allowed on a dynamic neighbor\n"); | |
2977 | return CMD_WARNING_CONFIG_FAILED; | |
2978 | } | |
2979 | ||
2980 | other = peer->doppelganger; | |
2981 | peer_delete(peer); | |
2982 | if (other && other->status != Deleted) | |
2983 | peer_delete(other); | |
2984 | } | |
1ff9a340 | 2985 | } |
718e3744 | 2986 | |
d62a17ae | 2987 | return CMD_SUCCESS; |
718e3744 | 2988 | } |
2989 | ||
a80beece DS |
2990 | DEFUN (no_neighbor_interface_config, |
2991 | no_neighbor_interface_config_cmd, | |
31500417 | 2992 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
2993 | NO_STR |
2994 | NEIGHBOR_STR | |
2995 | "Interface name\n" | |
31500417 DW |
2996 | "Configure BGP on interface\n" |
2997 | "Enable BGP with v6 link-local only\n" | |
2998 | "Member of the peer-group\n" | |
16cedbb0 | 2999 | "Peer-group name\n" |
3a2d747c QY |
3000 | "Specify a BGP neighbor\n" |
3001 | AS_STR | |
3002 | "Internal BGP peer\n" | |
3003 | "External BGP peer\n") | |
a80beece | 3004 | { |
d62a17ae | 3005 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3006 | int idx_word = 2; | |
3007 | struct peer *peer; | |
3008 | ||
3009 | /* look up for neighbor by interface name config. */ | |
3010 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3011 | if (peer) { | |
3012 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3013 | if (peer->ifp) | |
3014 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3015 | peer_delete(peer); | |
3016 | } else { | |
3017 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3018 | return CMD_WARNING_CONFIG_FAILED; | |
3019 | } | |
3020 | return CMD_SUCCESS; | |
a80beece DS |
3021 | } |
3022 | ||
718e3744 | 3023 | DEFUN (no_neighbor_peer_group, |
3024 | no_neighbor_peer_group_cmd, | |
3025 | "no neighbor WORD peer-group", | |
3026 | NO_STR | |
3027 | NEIGHBOR_STR | |
3028 | "Neighbor tag\n" | |
3029 | "Configure peer-group\n") | |
3030 | { | |
d62a17ae | 3031 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3032 | int idx_word = 2; | |
3033 | struct peer_group *group; | |
718e3744 | 3034 | |
d62a17ae | 3035 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
3036 | if (group) | |
3037 | peer_group_delete(group); | |
3038 | else { | |
3039 | vty_out(vty, "%% Create the peer-group first\n"); | |
3040 | return CMD_WARNING_CONFIG_FAILED; | |
3041 | } | |
3042 | return CMD_SUCCESS; | |
718e3744 | 3043 | } |
3044 | ||
a80beece DS |
3045 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3046 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3047 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3048 | NO_STR |
3049 | NEIGHBOR_STR | |
a80beece | 3050 | "Interface name or neighbor tag\n" |
718e3744 | 3051 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3052 | AS_STR |
3053 | "Internal BGP peer\n" | |
3054 | "External BGP peer\n") | |
718e3744 | 3055 | { |
d62a17ae | 3056 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3057 | int idx_word = 2; | |
3058 | struct peer_group *group; | |
3059 | struct peer *peer; | |
3060 | ||
3061 | /* look up for neighbor by interface name config. */ | |
3062 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3063 | if (peer) { | |
3064 | peer_as_change(peer, 0, AS_SPECIFIED); | |
3065 | return CMD_SUCCESS; | |
3066 | } | |
3067 | ||
3068 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3069 | if (group) | |
3070 | peer_group_remote_as_delete(group); | |
3071 | else { | |
3072 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3073 | return CMD_WARNING_CONFIG_FAILED; | |
3074 | } | |
3075 | return CMD_SUCCESS; | |
718e3744 | 3076 | } |
6b0655a2 | 3077 | |
718e3744 | 3078 | DEFUN (neighbor_local_as, |
3079 | neighbor_local_as_cmd, | |
9ccf14f7 | 3080 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3081 | NEIGHBOR_STR |
3082 | NEIGHBOR_ADDR_STR2 | |
3083 | "Specify a local-as number\n" | |
3084 | "AS number used as local AS\n") | |
3085 | { | |
d62a17ae | 3086 | int idx_peer = 1; |
3087 | int idx_number = 3; | |
3088 | struct peer *peer; | |
3089 | int ret; | |
3090 | as_t as; | |
718e3744 | 3091 | |
d62a17ae | 3092 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3093 | if (!peer) | |
3094 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3095 | |
d62a17ae | 3096 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3097 | ret = peer_local_as_set(peer, as, 0, 0); | |
3098 | return bgp_vty_return(vty, ret); | |
718e3744 | 3099 | } |
3100 | ||
3101 | DEFUN (neighbor_local_as_no_prepend, | |
3102 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3103 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3104 | NEIGHBOR_STR |
3105 | NEIGHBOR_ADDR_STR2 | |
3106 | "Specify a local-as number\n" | |
3107 | "AS number used as local AS\n" | |
3108 | "Do not prepend local-as to updates from ebgp peers\n") | |
3109 | { | |
d62a17ae | 3110 | int idx_peer = 1; |
3111 | int idx_number = 3; | |
3112 | struct peer *peer; | |
3113 | int ret; | |
3114 | as_t as; | |
718e3744 | 3115 | |
d62a17ae | 3116 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3117 | if (!peer) | |
3118 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3119 | |
d62a17ae | 3120 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3121 | ret = peer_local_as_set(peer, as, 1, 0); | |
3122 | return bgp_vty_return(vty, ret); | |
718e3744 | 3123 | } |
3124 | ||
9d3f9705 AC |
3125 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3126 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3127 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3128 | NEIGHBOR_STR |
3129 | NEIGHBOR_ADDR_STR2 | |
3130 | "Specify a local-as number\n" | |
3131 | "AS number used as local AS\n" | |
3132 | "Do not prepend local-as to updates from ebgp peers\n" | |
3133 | "Do not prepend local-as to updates from ibgp peers\n") | |
3134 | { | |
d62a17ae | 3135 | int idx_peer = 1; |
3136 | int idx_number = 3; | |
3137 | struct peer *peer; | |
3138 | int ret; | |
3139 | as_t as; | |
9d3f9705 | 3140 | |
d62a17ae | 3141 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3142 | if (!peer) | |
3143 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3144 | |
d62a17ae | 3145 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3146 | ret = peer_local_as_set(peer, as, 1, 1); | |
3147 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3148 | } |
3149 | ||
718e3744 | 3150 | DEFUN (no_neighbor_local_as, |
3151 | no_neighbor_local_as_cmd, | |
a636c635 | 3152 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3153 | NO_STR |
3154 | NEIGHBOR_STR | |
3155 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3156 | "Specify a local-as number\n" |
3157 | "AS number used as local AS\n" | |
3158 | "Do not prepend local-as to updates from ebgp peers\n" | |
3159 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3160 | { |
d62a17ae | 3161 | int idx_peer = 2; |
3162 | struct peer *peer; | |
3163 | int ret; | |
718e3744 | 3164 | |
d62a17ae | 3165 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3166 | if (!peer) | |
3167 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3168 | |
d62a17ae | 3169 | ret = peer_local_as_unset(peer); |
3170 | return bgp_vty_return(vty, ret); | |
718e3744 | 3171 | } |
3172 | ||
718e3744 | 3173 | |
3f9c7369 DS |
3174 | DEFUN (neighbor_solo, |
3175 | neighbor_solo_cmd, | |
9ccf14f7 | 3176 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3177 | NEIGHBOR_STR |
3178 | NEIGHBOR_ADDR_STR2 | |
3179 | "Solo peer - part of its own update group\n") | |
3180 | { | |
d62a17ae | 3181 | int idx_peer = 1; |
3182 | struct peer *peer; | |
3183 | int ret; | |
3f9c7369 | 3184 | |
d62a17ae | 3185 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3186 | if (!peer) | |
3187 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3188 | |
d62a17ae | 3189 | ret = update_group_adjust_soloness(peer, 1); |
3190 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3191 | } |
3192 | ||
3193 | DEFUN (no_neighbor_solo, | |
3194 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3195 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3196 | NO_STR |
3197 | NEIGHBOR_STR | |
3198 | NEIGHBOR_ADDR_STR2 | |
3199 | "Solo peer - part of its own update group\n") | |
3200 | { | |
d62a17ae | 3201 | int idx_peer = 2; |
3202 | struct peer *peer; | |
3203 | int ret; | |
3f9c7369 | 3204 | |
d62a17ae | 3205 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3206 | if (!peer) | |
3207 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3208 | |
d62a17ae | 3209 | ret = update_group_adjust_soloness(peer, 0); |
3210 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3211 | } |
3212 | ||
0df7c91f PJ |
3213 | DEFUN (neighbor_password, |
3214 | neighbor_password_cmd, | |
9ccf14f7 | 3215 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3216 | NEIGHBOR_STR |
3217 | NEIGHBOR_ADDR_STR2 | |
3218 | "Set a password\n" | |
3219 | "The password\n") | |
3220 | { | |
d62a17ae | 3221 | int idx_peer = 1; |
3222 | int idx_line = 3; | |
3223 | struct peer *peer; | |
3224 | int ret; | |
0df7c91f | 3225 | |
d62a17ae | 3226 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3227 | if (!peer) | |
3228 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3229 | |
d62a17ae | 3230 | ret = peer_password_set(peer, argv[idx_line]->arg); |
3231 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
3232 | } |
3233 | ||
3234 | DEFUN (no_neighbor_password, | |
3235 | no_neighbor_password_cmd, | |
a636c635 | 3236 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3237 | NO_STR |
3238 | NEIGHBOR_STR | |
3239 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3240 | "Set a password\n" |
3241 | "The password\n") | |
0df7c91f | 3242 | { |
d62a17ae | 3243 | int idx_peer = 2; |
3244 | struct peer *peer; | |
3245 | int ret; | |
0df7c91f | 3246 | |
d62a17ae | 3247 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3248 | if (!peer) | |
3249 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3250 | |
d62a17ae | 3251 | ret = peer_password_unset(peer); |
3252 | return bgp_vty_return(vty, ret); | |
0df7c91f | 3253 | } |
6b0655a2 | 3254 | |
718e3744 | 3255 | DEFUN (neighbor_activate, |
3256 | neighbor_activate_cmd, | |
9ccf14f7 | 3257 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3258 | NEIGHBOR_STR |
3259 | NEIGHBOR_ADDR_STR2 | |
3260 | "Enable the Address Family for this Neighbor\n") | |
3261 | { | |
d62a17ae | 3262 | int idx_peer = 1; |
3263 | int ret; | |
3264 | struct peer *peer; | |
718e3744 | 3265 | |
d62a17ae | 3266 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3267 | if (!peer) | |
3268 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3269 | |
d62a17ae | 3270 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3271 | return bgp_vty_return(vty, ret); | |
718e3744 | 3272 | } |
3273 | ||
d62a17ae | 3274 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
3275 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3276 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3277 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3278 | |
718e3744 | 3279 | DEFUN (no_neighbor_activate, |
3280 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3281 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3282 | NO_STR |
3283 | NEIGHBOR_STR | |
3284 | NEIGHBOR_ADDR_STR2 | |
3285 | "Enable the Address Family for this Neighbor\n") | |
3286 | { | |
d62a17ae | 3287 | int idx_peer = 2; |
3288 | int ret; | |
3289 | struct peer *peer; | |
718e3744 | 3290 | |
d62a17ae | 3291 | /* Lookup peer. */ |
3292 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3293 | if (!peer) | |
3294 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3295 | |
d62a17ae | 3296 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3297 | return bgp_vty_return(vty, ret); | |
718e3744 | 3298 | } |
6b0655a2 | 3299 | |
d62a17ae | 3300 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
3301 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3302 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3303 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3304 | |
718e3744 | 3305 | DEFUN (neighbor_set_peer_group, |
3306 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3307 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3308 | NEIGHBOR_STR |
a80beece | 3309 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3310 | "Member of the peer-group\n" |
16cedbb0 | 3311 | "Peer-group name\n") |
718e3744 | 3312 | { |
d62a17ae | 3313 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3314 | int idx_peer = 1; | |
3315 | int idx_word = 3; | |
3316 | int ret; | |
3317 | as_t as; | |
3318 | union sockunion su; | |
3319 | struct peer *peer; | |
3320 | struct peer_group *group; | |
3321 | ||
3322 | peer = NULL; | |
3323 | ||
3324 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3325 | if (ret < 0) { | |
3326 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3327 | if (!peer) { | |
3328 | vty_out(vty, "%% Malformed address or name: %s\n", | |
3329 | argv[idx_peer]->arg); | |
3330 | return CMD_WARNING_CONFIG_FAILED; | |
3331 | } | |
3332 | } else { | |
3333 | if (peer_address_self_check(bgp, &su)) { | |
3334 | vty_out(vty, | |
3335 | "%% Can not configure the local system as neighbor\n"); | |
3336 | return CMD_WARNING_CONFIG_FAILED; | |
3337 | } | |
3338 | ||
3339 | /* Disallow for dynamic neighbor. */ | |
3340 | peer = peer_lookup(bgp, &su); | |
3341 | if (peer && peer_dynamic_neighbor(peer)) { | |
3342 | vty_out(vty, | |
3343 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3344 | return CMD_WARNING_CONFIG_FAILED; | |
3345 | } | |
3346 | } | |
3347 | ||
3348 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3349 | if (!group) { | |
3350 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3351 | return CMD_WARNING_CONFIG_FAILED; | |
3352 | } | |
3353 | ||
3354 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3355 | ||
3356 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
3357 | vty_out(vty, | |
3358 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
3359 | as); | |
3360 | return CMD_WARNING_CONFIG_FAILED; | |
3361 | } | |
3362 | ||
3363 | return bgp_vty_return(vty, ret); | |
3364 | } | |
3365 | ||
3366 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
3367 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3368 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3369 | "Member of the peer-group\n" | |
3370 | "Peer-group name\n") | |
596c17ba | 3371 | |
718e3744 | 3372 | DEFUN (no_neighbor_set_peer_group, |
3373 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3374 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3375 | NO_STR |
3376 | NEIGHBOR_STR | |
a80beece | 3377 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3378 | "Member of the peer-group\n" |
16cedbb0 | 3379 | "Peer-group name\n") |
718e3744 | 3380 | { |
d62a17ae | 3381 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3382 | int idx_peer = 2; | |
3383 | int idx_word = 4; | |
3384 | int ret; | |
3385 | struct peer *peer; | |
3386 | struct peer_group *group; | |
3387 | ||
3388 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
3389 | if (!peer) | |
3390 | return CMD_WARNING_CONFIG_FAILED; | |
3391 | ||
3392 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3393 | if (!group) { | |
3394 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3395 | return CMD_WARNING_CONFIG_FAILED; | |
3396 | } | |
718e3744 | 3397 | |
827ed707 | 3398 | ret = peer_delete(peer); |
718e3744 | 3399 | |
d62a17ae | 3400 | return bgp_vty_return(vty, ret); |
718e3744 | 3401 | } |
6b0655a2 | 3402 | |
d62a17ae | 3403 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
3404 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3405 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3406 | "Member of the peer-group\n" | |
3407 | "Peer-group name\n") | |
596c17ba | 3408 | |
d62a17ae | 3409 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
3410 | u_int16_t flag, int set) | |
718e3744 | 3411 | { |
d62a17ae | 3412 | int ret; |
3413 | struct peer *peer; | |
718e3744 | 3414 | |
d62a17ae | 3415 | peer = peer_and_group_lookup_vty(vty, ip_str); |
3416 | if (!peer) | |
3417 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3418 | |
7ebe625c QY |
3419 | /* |
3420 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3421 | * we should not accept disable-connected-check. | |
3422 | */ | |
3423 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3424 | vty_out(vty, | |
3425 | "%s is directly connected peer, cannot accept disable-" | |
3426 | "connected-check\n", | |
3427 | ip_str); | |
3428 | return CMD_WARNING_CONFIG_FAILED; | |
3429 | } | |
3430 | ||
d62a17ae | 3431 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3432 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 3433 | |
d62a17ae | 3434 | if (set) |
3435 | ret = peer_flag_set(peer, flag); | |
3436 | else | |
3437 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 3438 | |
d62a17ae | 3439 | return bgp_vty_return(vty, ret); |
718e3744 | 3440 | } |
3441 | ||
d62a17ae | 3442 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, |
3443 | u_int16_t flag) | |
718e3744 | 3444 | { |
d62a17ae | 3445 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 3446 | } |
3447 | ||
d62a17ae | 3448 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
3449 | u_int16_t flag) | |
718e3744 | 3450 | { |
d62a17ae | 3451 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 3452 | } |
3453 | ||
3454 | /* neighbor passive. */ | |
3455 | DEFUN (neighbor_passive, | |
3456 | neighbor_passive_cmd, | |
9ccf14f7 | 3457 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3458 | NEIGHBOR_STR |
3459 | NEIGHBOR_ADDR_STR2 | |
3460 | "Don't send open messages to this neighbor\n") | |
3461 | { | |
d62a17ae | 3462 | int idx_peer = 1; |
3463 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3464 | } |
3465 | ||
3466 | DEFUN (no_neighbor_passive, | |
3467 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3468 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3469 | NO_STR |
3470 | NEIGHBOR_STR | |
3471 | NEIGHBOR_ADDR_STR2 | |
3472 | "Don't send open messages to this neighbor\n") | |
3473 | { | |
d62a17ae | 3474 | int idx_peer = 2; |
3475 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3476 | } |
6b0655a2 | 3477 | |
718e3744 | 3478 | /* neighbor shutdown. */ |
73d70fa6 DL |
3479 | DEFUN (neighbor_shutdown_msg, |
3480 | neighbor_shutdown_msg_cmd, | |
3481 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3482 | NEIGHBOR_STR |
3483 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3484 | "Administratively shut down this neighbor\n" |
3485 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3486 | "Shutdown message\n") | |
718e3744 | 3487 | { |
d62a17ae | 3488 | int idx_peer = 1; |
73d70fa6 | 3489 | |
d62a17ae | 3490 | if (argc >= 5) { |
3491 | struct peer *peer = | |
3492 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3493 | char *message; | |
73d70fa6 | 3494 | |
d62a17ae | 3495 | if (!peer) |
3496 | return CMD_WARNING_CONFIG_FAILED; | |
3497 | message = argv_concat(argv, argc, 4); | |
3498 | peer_tx_shutdown_message_set(peer, message); | |
3499 | XFREE(MTYPE_TMP, message); | |
3500 | } | |
73d70fa6 | 3501 | |
d62a17ae | 3502 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3503 | } |
3504 | ||
d62a17ae | 3505 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
3506 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3507 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3508 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3509 | |
3510 | DEFUN (no_neighbor_shutdown_msg, | |
3511 | no_neighbor_shutdown_msg_cmd, | |
3512 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3513 | NO_STR | |
3514 | NEIGHBOR_STR | |
3515 | NEIGHBOR_ADDR_STR2 | |
3516 | "Administratively shut down this neighbor\n" | |
3517 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3518 | "Shutdown message\n") | |
718e3744 | 3519 | { |
d62a17ae | 3520 | int idx_peer = 2; |
73d70fa6 | 3521 | |
d62a17ae | 3522 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
3523 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 3524 | } |
6b0655a2 | 3525 | |
d62a17ae | 3526 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
3527 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3528 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3529 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 3530 | |
718e3744 | 3531 | /* neighbor capability dynamic. */ |
3532 | DEFUN (neighbor_capability_dynamic, | |
3533 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3534 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3535 | NEIGHBOR_STR |
3536 | NEIGHBOR_ADDR_STR2 | |
3537 | "Advertise capability to the peer\n" | |
3538 | "Advertise dynamic capability to this neighbor\n") | |
3539 | { | |
d62a17ae | 3540 | int idx_peer = 1; |
3541 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3542 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3543 | } |
3544 | ||
3545 | DEFUN (no_neighbor_capability_dynamic, | |
3546 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3547 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3548 | NO_STR |
3549 | NEIGHBOR_STR | |
3550 | NEIGHBOR_ADDR_STR2 | |
3551 | "Advertise capability to the peer\n" | |
3552 | "Advertise dynamic capability to this neighbor\n") | |
3553 | { | |
d62a17ae | 3554 | int idx_peer = 2; |
3555 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3556 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3557 | } |
6b0655a2 | 3558 | |
718e3744 | 3559 | /* neighbor dont-capability-negotiate */ |
3560 | DEFUN (neighbor_dont_capability_negotiate, | |
3561 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3562 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3563 | NEIGHBOR_STR |
3564 | NEIGHBOR_ADDR_STR2 | |
3565 | "Do not perform capability negotiation\n") | |
3566 | { | |
d62a17ae | 3567 | int idx_peer = 1; |
3568 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3569 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3570 | } |
3571 | ||
3572 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3573 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3574 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3575 | NO_STR |
3576 | NEIGHBOR_STR | |
3577 | NEIGHBOR_ADDR_STR2 | |
3578 | "Do not perform capability negotiation\n") | |
3579 | { | |
d62a17ae | 3580 | int idx_peer = 2; |
3581 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3582 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3583 | } |
6b0655a2 | 3584 | |
8a92a8a0 DS |
3585 | /* neighbor capability extended next hop encoding */ |
3586 | DEFUN (neighbor_capability_enhe, | |
3587 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3588 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3589 | NEIGHBOR_STR |
3590 | NEIGHBOR_ADDR_STR2 | |
3591 | "Advertise capability to the peer\n" | |
3592 | "Advertise extended next-hop capability to the peer\n") | |
3593 | { | |
d62a17ae | 3594 | int idx_peer = 1; |
3595 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3596 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3597 | } |
3598 | ||
3599 | DEFUN (no_neighbor_capability_enhe, | |
3600 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3601 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3602 | NO_STR |
3603 | NEIGHBOR_STR | |
3604 | NEIGHBOR_ADDR_STR2 | |
3605 | "Advertise capability to the peer\n" | |
3606 | "Advertise extended next-hop capability to the peer\n") | |
3607 | { | |
d62a17ae | 3608 | int idx_peer = 2; |
3609 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3610 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3611 | } |
3612 | ||
d62a17ae | 3613 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
3614 | afi_t afi, safi_t safi, u_int32_t flag, | |
3615 | int set) | |
718e3744 | 3616 | { |
d62a17ae | 3617 | int ret; |
3618 | struct peer *peer; | |
718e3744 | 3619 | |
d62a17ae | 3620 | peer = peer_and_group_lookup_vty(vty, peer_str); |
3621 | if (!peer) | |
3622 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3623 | |
d62a17ae | 3624 | if (set) |
3625 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
3626 | else | |
3627 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 3628 | |
d62a17ae | 3629 | return bgp_vty_return(vty, ret); |
718e3744 | 3630 | } |
3631 | ||
d62a17ae | 3632 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
3633 | afi_t afi, safi_t safi, u_int32_t flag) | |
718e3744 | 3634 | { |
d62a17ae | 3635 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 3636 | } |
3637 | ||
d62a17ae | 3638 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
3639 | afi_t afi, safi_t safi, u_int32_t flag) | |
718e3744 | 3640 | { |
d62a17ae | 3641 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 3642 | } |
6b0655a2 | 3643 | |
718e3744 | 3644 | /* neighbor capability orf prefix-list. */ |
3645 | DEFUN (neighbor_capability_orf_prefix, | |
3646 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3647 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3648 | NEIGHBOR_STR |
3649 | NEIGHBOR_ADDR_STR2 | |
3650 | "Advertise capability to the peer\n" | |
3651 | "Advertise ORF capability to the peer\n" | |
3652 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3653 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3654 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3655 | "Capability to SEND the ORF to this neighbor\n") | |
3656 | { | |
d62a17ae | 3657 | int idx_peer = 1; |
3658 | int idx_send_recv = 5; | |
3659 | u_int16_t flag = 0; | |
3660 | ||
3661 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3662 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3663 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3664 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3665 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3666 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3667 | else { | |
3668 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3669 | return CMD_WARNING_CONFIG_FAILED; | |
3670 | } | |
3671 | ||
3672 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3673 | bgp_node_safi(vty), flag); | |
3674 | } | |
3675 | ||
3676 | ALIAS_HIDDEN( | |
3677 | neighbor_capability_orf_prefix, | |
3678 | neighbor_capability_orf_prefix_hidden_cmd, | |
3679 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3680 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3681 | "Advertise capability to the peer\n" | |
3682 | "Advertise ORF capability to the peer\n" | |
3683 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3684 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3685 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3686 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3687 | |
718e3744 | 3688 | DEFUN (no_neighbor_capability_orf_prefix, |
3689 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3690 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3691 | NO_STR |
3692 | NEIGHBOR_STR | |
3693 | NEIGHBOR_ADDR_STR2 | |
3694 | "Advertise capability to the peer\n" | |
3695 | "Advertise ORF capability to the peer\n" | |
3696 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3697 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3698 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3699 | "Capability to SEND the ORF to this neighbor\n") | |
3700 | { | |
d62a17ae | 3701 | int idx_peer = 2; |
3702 | int idx_send_recv = 6; | |
3703 | u_int16_t flag = 0; | |
3704 | ||
3705 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3706 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3707 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3708 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3709 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3710 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3711 | else { | |
3712 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3713 | return CMD_WARNING_CONFIG_FAILED; | |
3714 | } | |
3715 | ||
3716 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3717 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3718 | flag); | |
3719 | } | |
3720 | ||
3721 | ALIAS_HIDDEN( | |
3722 | no_neighbor_capability_orf_prefix, | |
3723 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
3724 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3725 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3726 | "Advertise capability to the peer\n" | |
3727 | "Advertise ORF capability to the peer\n" | |
3728 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3729 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3730 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3731 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3732 | |
718e3744 | 3733 | /* neighbor next-hop-self. */ |
3734 | DEFUN (neighbor_nexthop_self, | |
3735 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3736 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3737 | NEIGHBOR_STR |
3738 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3739 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 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), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 3744 | } |
9e7a53c1 | 3745 | |
d62a17ae | 3746 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
3747 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3748 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3749 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3750 | |
a538debe DS |
3751 | /* neighbor next-hop-self. */ |
3752 | DEFUN (neighbor_nexthop_self_force, | |
3753 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3754 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3755 | NEIGHBOR_STR |
3756 | NEIGHBOR_ADDR_STR2 | |
3757 | "Disable the next hop calculation for this neighbor\n" | |
3758 | "Set the next hop to self for reflected routes\n") | |
3759 | { | |
d62a17ae | 3760 | int idx_peer = 1; |
3761 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3762 | bgp_node_safi(vty), | |
3763 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 3764 | } |
3765 | ||
d62a17ae | 3766 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3767 | neighbor_nexthop_self_force_hidden_cmd, | |
3768 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3769 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3770 | "Disable the next hop calculation for this neighbor\n" | |
3771 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3772 | |
718e3744 | 3773 | DEFUN (no_neighbor_nexthop_self, |
3774 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3775 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3776 | NO_STR |
3777 | NEIGHBOR_STR | |
3778 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3779 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3780 | { |
d62a17ae | 3781 | int idx_peer = 2; |
3782 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3783 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3784 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 3785 | } |
6b0655a2 | 3786 | |
d62a17ae | 3787 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
3788 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3789 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3790 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3791 | |
88b8ed8d | 3792 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3793 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3794 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3795 | NO_STR |
3796 | NEIGHBOR_STR | |
3797 | NEIGHBOR_ADDR_STR2 | |
3798 | "Disable the next hop calculation for this neighbor\n" | |
3799 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3800 | { |
d62a17ae | 3801 | int idx_peer = 2; |
3802 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3803 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3804 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 3805 | } |
a538debe | 3806 | |
d62a17ae | 3807 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
3808 | no_neighbor_nexthop_self_force_hidden_cmd, | |
3809 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3810 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3811 | "Disable the next hop calculation for this neighbor\n" | |
3812 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3813 | |
c7122e14 DS |
3814 | /* neighbor as-override */ |
3815 | DEFUN (neighbor_as_override, | |
3816 | neighbor_as_override_cmd, | |
9ccf14f7 | 3817 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3818 | NEIGHBOR_STR |
3819 | NEIGHBOR_ADDR_STR2 | |
3820 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3821 | { | |
d62a17ae | 3822 | int idx_peer = 1; |
3823 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3824 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3825 | } |
3826 | ||
d62a17ae | 3827 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
3828 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3829 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3830 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3831 | |
c7122e14 DS |
3832 | DEFUN (no_neighbor_as_override, |
3833 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3834 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3835 | NO_STR |
3836 | NEIGHBOR_STR | |
3837 | NEIGHBOR_ADDR_STR2 | |
3838 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3839 | { | |
d62a17ae | 3840 | int idx_peer = 2; |
3841 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3842 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3843 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3844 | } |
3845 | ||
d62a17ae | 3846 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
3847 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3848 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3849 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3850 | |
718e3744 | 3851 | /* neighbor remove-private-AS. */ |
3852 | DEFUN (neighbor_remove_private_as, | |
3853 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3854 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3855 | NEIGHBOR_STR |
3856 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3857 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3858 | { |
d62a17ae | 3859 | int idx_peer = 1; |
3860 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3861 | bgp_node_safi(vty), | |
3862 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 3863 | } |
3864 | ||
d62a17ae | 3865 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
3866 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
3867 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3868 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 3869 | |
5000f21c DS |
3870 | DEFUN (neighbor_remove_private_as_all, |
3871 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 3872 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3873 | NEIGHBOR_STR |
3874 | NEIGHBOR_ADDR_STR2 | |
3875 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 3876 | "Apply to all AS numbers\n") |
5000f21c | 3877 | { |
d62a17ae | 3878 | int idx_peer = 1; |
3879 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3880 | bgp_node_safi(vty), | |
3881 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
3882 | } |
3883 | ||
d62a17ae | 3884 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
3885 | neighbor_remove_private_as_all_hidden_cmd, | |
3886 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
3887 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3888 | "Remove private ASNs in outbound updates\n" | |
3889 | "Apply to all AS numbers") | |
596c17ba | 3890 | |
5000f21c DS |
3891 | DEFUN (neighbor_remove_private_as_replace_as, |
3892 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 3893 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3894 | NEIGHBOR_STR |
3895 | NEIGHBOR_ADDR_STR2 | |
3896 | "Remove private ASNs in outbound updates\n" | |
3897 | "Replace private ASNs with our ASN in outbound updates\n") | |
3898 | { | |
d62a17ae | 3899 | int idx_peer = 1; |
3900 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3901 | bgp_node_safi(vty), | |
3902 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
3903 | } |
3904 | ||
d62a17ae | 3905 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
3906 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
3907 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
3908 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3909 | "Remove private ASNs in outbound updates\n" | |
3910 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3911 | |
5000f21c DS |
3912 | DEFUN (neighbor_remove_private_as_all_replace_as, |
3913 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 3914 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3915 | NEIGHBOR_STR |
3916 | NEIGHBOR_ADDR_STR2 | |
3917 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3918 | "Apply to all AS numbers\n" |
5000f21c DS |
3919 | "Replace private ASNs with our ASN in outbound updates\n") |
3920 | { | |
d62a17ae | 3921 | int idx_peer = 1; |
3922 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3923 | bgp_node_safi(vty), | |
3924 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
3925 | } |
3926 | ||
d62a17ae | 3927 | ALIAS_HIDDEN( |
3928 | neighbor_remove_private_as_all_replace_as, | |
3929 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
3930 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
3931 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3932 | "Remove private ASNs in outbound updates\n" | |
3933 | "Apply to all AS numbers\n" | |
3934 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3935 | |
718e3744 | 3936 | DEFUN (no_neighbor_remove_private_as, |
3937 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3938 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3939 | NO_STR |
3940 | NEIGHBOR_STR | |
3941 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3942 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3943 | { |
d62a17ae | 3944 | int idx_peer = 2; |
3945 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3946 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3947 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 3948 | } |
6b0655a2 | 3949 | |
d62a17ae | 3950 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
3951 | no_neighbor_remove_private_as_hidden_cmd, | |
3952 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
3953 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3954 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 3955 | |
88b8ed8d | 3956 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 3957 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 3958 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3959 | NO_STR |
3960 | NEIGHBOR_STR | |
3961 | NEIGHBOR_ADDR_STR2 | |
3962 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3963 | "Apply to all AS numbers\n") |
88b8ed8d | 3964 | { |
d62a17ae | 3965 | int idx_peer = 2; |
3966 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3967 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3968 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 3969 | } |
5000f21c | 3970 | |
d62a17ae | 3971 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
3972 | no_neighbor_remove_private_as_all_hidden_cmd, | |
3973 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
3974 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3975 | "Remove private ASNs in outbound updates\n" | |
3976 | "Apply to all AS numbers\n") | |
596c17ba | 3977 | |
88b8ed8d | 3978 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 3979 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 3980 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3981 | NO_STR |
3982 | NEIGHBOR_STR | |
3983 | NEIGHBOR_ADDR_STR2 | |
3984 | "Remove private ASNs in outbound updates\n" | |
3985 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 3986 | { |
d62a17ae | 3987 | int idx_peer = 2; |
3988 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3989 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3990 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 3991 | } |
5000f21c | 3992 | |
d62a17ae | 3993 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
3994 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
3995 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
3996 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3997 | "Remove private ASNs in outbound updates\n" | |
3998 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3999 | |
88b8ed8d | 4000 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4001 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4002 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4003 | NO_STR |
4004 | NEIGHBOR_STR | |
4005 | NEIGHBOR_ADDR_STR2 | |
4006 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4007 | "Apply to all AS numbers\n" |
5000f21c | 4008 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4009 | { |
d62a17ae | 4010 | int idx_peer = 2; |
4011 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4012 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4013 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4014 | } |
5000f21c | 4015 | |
d62a17ae | 4016 | ALIAS_HIDDEN( |
4017 | no_neighbor_remove_private_as_all_replace_as, | |
4018 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4019 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4020 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4021 | "Remove private ASNs in outbound updates\n" | |
4022 | "Apply to all AS numbers\n" | |
4023 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4024 | |
5000f21c | 4025 | |
718e3744 | 4026 | /* neighbor send-community. */ |
4027 | DEFUN (neighbor_send_community, | |
4028 | neighbor_send_community_cmd, | |
9ccf14f7 | 4029 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4030 | NEIGHBOR_STR |
4031 | NEIGHBOR_ADDR_STR2 | |
4032 | "Send Community attribute to this neighbor\n") | |
4033 | { | |
d62a17ae | 4034 | int idx_peer = 1; |
4035 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4036 | bgp_node_safi(vty), | |
4037 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4038 | } |
4039 | ||
d62a17ae | 4040 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4041 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4042 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4043 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4044 | |
718e3744 | 4045 | DEFUN (no_neighbor_send_community, |
4046 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4047 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4048 | NO_STR |
4049 | NEIGHBOR_STR | |
4050 | NEIGHBOR_ADDR_STR2 | |
4051 | "Send Community attribute to this neighbor\n") | |
4052 | { | |
d62a17ae | 4053 | int idx_peer = 2; |
4054 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4055 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4056 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4057 | } |
6b0655a2 | 4058 | |
d62a17ae | 4059 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4060 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4061 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4062 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4063 | |
718e3744 | 4064 | /* neighbor send-community extended. */ |
4065 | DEFUN (neighbor_send_community_type, | |
4066 | neighbor_send_community_type_cmd, | |
57d187bc | 4067 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4068 | NEIGHBOR_STR |
4069 | NEIGHBOR_ADDR_STR2 | |
4070 | "Send Community attribute to this neighbor\n" | |
4071 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4072 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4073 | "Send Extended Community attributes\n" |
57d187bc JS |
4074 | "Send Standard Community attributes\n" |
4075 | "Send Large Community attributes\n") | |
718e3744 | 4076 | { |
d62a17ae | 4077 | int idx = 0; |
4078 | u_int32_t flag = 0; | |
4079 | ||
4080 | char *peer = argv[1]->arg; | |
4081 | ||
4082 | if (argv_find(argv, argc, "standard", &idx)) | |
4083 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4084 | else if (argv_find(argv, argc, "extended", &idx)) | |
4085 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4086 | else if (argv_find(argv, argc, "large", &idx)) | |
4087 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4088 | else if (argv_find(argv, argc, "both", &idx)) { | |
4089 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4090 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4091 | } else { | |
4092 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4093 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4094 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4095 | } | |
4096 | ||
4097 | return peer_af_flag_set_vty(vty, peer, bgp_node_afi(vty), | |
4098 | bgp_node_safi(vty), flag); | |
4099 | } | |
4100 | ||
4101 | ALIAS_HIDDEN( | |
4102 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4103 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4104 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4105 | "Send Community attribute to this neighbor\n" | |
4106 | "Send Standard and Extended Community attributes\n" | |
4107 | "Send Standard, Large and Extended Community attributes\n" | |
4108 | "Send Extended Community attributes\n" | |
4109 | "Send Standard Community attributes\n" | |
4110 | "Send Large Community attributes\n") | |
596c17ba | 4111 | |
718e3744 | 4112 | DEFUN (no_neighbor_send_community_type, |
4113 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4114 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4115 | NO_STR |
4116 | NEIGHBOR_STR | |
4117 | NEIGHBOR_ADDR_STR2 | |
4118 | "Send Community attribute to this neighbor\n" | |
4119 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4120 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4121 | "Send Extended Community attributes\n" |
57d187bc JS |
4122 | "Send Standard Community attributes\n" |
4123 | "Send Large Community attributes\n") | |
718e3744 | 4124 | { |
d62a17ae | 4125 | int idx_peer = 2; |
4126 | ||
4127 | const char *type = argv[argc - 1]->text; | |
4128 | ||
4129 | if (strmatch(type, "standard")) | |
4130 | return peer_af_flag_unset_vty( | |
4131 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4132 | bgp_node_safi(vty), PEER_FLAG_SEND_COMMUNITY); | |
4133 | if (strmatch(type, "extended")) | |
4134 | return peer_af_flag_unset_vty( | |
4135 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4136 | bgp_node_safi(vty), PEER_FLAG_SEND_EXT_COMMUNITY); | |
4137 | if (strmatch(type, "large")) | |
4138 | return peer_af_flag_unset_vty( | |
4139 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4140 | bgp_node_safi(vty), PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4141 | if (strmatch(type, "both")) | |
4142 | return peer_af_flag_unset_vty( | |
4143 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4144 | bgp_node_safi(vty), | |
4145 | PEER_FLAG_SEND_COMMUNITY | |
4146 | | PEER_FLAG_SEND_EXT_COMMUNITY); | |
4147 | ||
4148 | /* if (strmatch (type, "all")) */ | |
4149 | return peer_af_flag_unset_vty( | |
4150 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4151 | (PEER_FLAG_SEND_COMMUNITY | PEER_FLAG_SEND_EXT_COMMUNITY | |
4152 | | PEER_FLAG_SEND_LARGE_COMMUNITY)); | |
4153 | } | |
4154 | ||
4155 | ALIAS_HIDDEN( | |
4156 | no_neighbor_send_community_type, | |
4157 | no_neighbor_send_community_type_hidden_cmd, | |
4158 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4159 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4160 | "Send Community attribute to this neighbor\n" | |
4161 | "Send Standard and Extended Community attributes\n" | |
4162 | "Send Standard, Large and Extended Community attributes\n" | |
4163 | "Send Extended Community attributes\n" | |
4164 | "Send Standard Community attributes\n" | |
4165 | "Send Large Community attributes\n") | |
596c17ba | 4166 | |
718e3744 | 4167 | /* neighbor soft-reconfig. */ |
4168 | DEFUN (neighbor_soft_reconfiguration, | |
4169 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4170 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4171 | NEIGHBOR_STR |
4172 | NEIGHBOR_ADDR_STR2 | |
4173 | "Per neighbor soft reconfiguration\n" | |
4174 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4175 | { | |
d62a17ae | 4176 | int idx_peer = 1; |
4177 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4178 | bgp_node_safi(vty), | |
4179 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4180 | } |
4181 | ||
d62a17ae | 4182 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4183 | neighbor_soft_reconfiguration_hidden_cmd, | |
4184 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4185 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4186 | "Per neighbor soft reconfiguration\n" | |
4187 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4188 | |
718e3744 | 4189 | DEFUN (no_neighbor_soft_reconfiguration, |
4190 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4191 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4192 | NO_STR |
4193 | NEIGHBOR_STR | |
4194 | NEIGHBOR_ADDR_STR2 | |
4195 | "Per neighbor soft reconfiguration\n" | |
4196 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4197 | { | |
d62a17ae | 4198 | int idx_peer = 2; |
4199 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4200 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4201 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4202 | } |
6b0655a2 | 4203 | |
d62a17ae | 4204 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
4205 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4206 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4207 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4208 | "Per neighbor soft reconfiguration\n" | |
4209 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4210 | |
718e3744 | 4211 | DEFUN (neighbor_route_reflector_client, |
4212 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4213 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4214 | NEIGHBOR_STR |
4215 | NEIGHBOR_ADDR_STR2 | |
4216 | "Configure a neighbor as Route Reflector client\n") | |
4217 | { | |
d62a17ae | 4218 | int idx_peer = 1; |
4219 | struct peer *peer; | |
718e3744 | 4220 | |
4221 | ||
d62a17ae | 4222 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4223 | if (!peer) | |
4224 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4225 | |
d62a17ae | 4226 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4227 | bgp_node_safi(vty), | |
4228 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4229 | } |
4230 | ||
d62a17ae | 4231 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
4232 | neighbor_route_reflector_client_hidden_cmd, | |
4233 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4234 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4235 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4236 | |
718e3744 | 4237 | DEFUN (no_neighbor_route_reflector_client, |
4238 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4239 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4240 | NO_STR |
4241 | NEIGHBOR_STR | |
4242 | NEIGHBOR_ADDR_STR2 | |
4243 | "Configure a neighbor as Route Reflector client\n") | |
4244 | { | |
d62a17ae | 4245 | int idx_peer = 2; |
4246 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4247 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4248 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4249 | } |
6b0655a2 | 4250 | |
d62a17ae | 4251 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
4252 | no_neighbor_route_reflector_client_hidden_cmd, | |
4253 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4254 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4255 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4256 | |
718e3744 | 4257 | /* neighbor route-server-client. */ |
4258 | DEFUN (neighbor_route_server_client, | |
4259 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4260 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4261 | NEIGHBOR_STR |
4262 | NEIGHBOR_ADDR_STR2 | |
4263 | "Configure a neighbor as Route Server client\n") | |
4264 | { | |
d62a17ae | 4265 | int idx_peer = 1; |
4266 | struct peer *peer; | |
2a3d5731 | 4267 | |
d62a17ae | 4268 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4269 | if (!peer) | |
4270 | return CMD_WARNING_CONFIG_FAILED; | |
4271 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4272 | bgp_node_safi(vty), | |
4273 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4274 | } |
4275 | ||
d62a17ae | 4276 | ALIAS_HIDDEN(neighbor_route_server_client, |
4277 | neighbor_route_server_client_hidden_cmd, | |
4278 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4279 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4280 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4281 | |
718e3744 | 4282 | DEFUN (no_neighbor_route_server_client, |
4283 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4284 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4285 | NO_STR |
4286 | NEIGHBOR_STR | |
4287 | NEIGHBOR_ADDR_STR2 | |
4288 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4289 | { |
d62a17ae | 4290 | int idx_peer = 2; |
4291 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4292 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4293 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4294 | } |
6b0655a2 | 4295 | |
d62a17ae | 4296 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
4297 | no_neighbor_route_server_client_hidden_cmd, | |
4298 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4299 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4300 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4301 | |
fee0f4c6 | 4302 | DEFUN (neighbor_nexthop_local_unchanged, |
4303 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4304 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4305 | NEIGHBOR_STR |
4306 | NEIGHBOR_ADDR_STR2 | |
4307 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4308 | "Leave link-local nexthop unchanged for this peer\n") | |
4309 | { | |
d62a17ae | 4310 | int idx_peer = 1; |
4311 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4312 | bgp_node_safi(vty), | |
4313 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 4314 | } |
6b0655a2 | 4315 | |
fee0f4c6 | 4316 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4317 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4318 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4319 | NO_STR |
4320 | NEIGHBOR_STR | |
4321 | NEIGHBOR_ADDR_STR2 | |
4322 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4323 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4324 | { |
d62a17ae | 4325 | int idx_peer = 2; |
4326 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4327 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4328 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 4329 | } |
6b0655a2 | 4330 | |
718e3744 | 4331 | DEFUN (neighbor_attr_unchanged, |
4332 | neighbor_attr_unchanged_cmd, | |
a8206004 | 4333 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 4334 | NEIGHBOR_STR |
4335 | NEIGHBOR_ADDR_STR2 | |
4336 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4337 | "As-path attribute\n" | |
4338 | "Nexthop attribute\n" | |
a8206004 | 4339 | "Med attribute\n") |
718e3744 | 4340 | { |
d62a17ae | 4341 | int idx = 0; |
8eeb0335 DW |
4342 | char *peer_str = argv[1]->arg; |
4343 | struct peer *peer; | |
d62a17ae | 4344 | u_int16_t flags = 0; |
8eeb0335 DW |
4345 | afi_t afi = bgp_node_afi(vty); |
4346 | safi_t safi = bgp_node_safi(vty); | |
4347 | ||
4348 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4349 | if (!peer) | |
4350 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4351 | |
4352 | if (argv_find(argv, argc, "as-path", &idx)) | |
4353 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4354 | idx = 0; | |
4355 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4356 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4357 | idx = 0; | |
4358 | if (argv_find(argv, argc, "med", &idx)) | |
4359 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4360 | ||
8eeb0335 DW |
4361 | /* no flags means all of them! */ |
4362 | if (!flags) { | |
d62a17ae | 4363 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
4364 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4365 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 4366 | } else { |
a4d82a8a PZ |
4367 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
4368 | && peer_af_flag_check(peer, afi, safi, | |
4369 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
4370 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4371 | PEER_FLAG_AS_PATH_UNCHANGED); | |
4372 | } | |
4373 | ||
a4d82a8a PZ |
4374 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
4375 | && peer_af_flag_check(peer, afi, safi, | |
4376 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
4377 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4378 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
4379 | } | |
4380 | ||
a4d82a8a PZ |
4381 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
4382 | && peer_af_flag_check(peer, afi, safi, | |
4383 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
4384 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4385 | PEER_FLAG_MED_UNCHANGED); | |
4386 | } | |
d62a17ae | 4387 | } |
4388 | ||
8eeb0335 | 4389 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 4390 | } |
4391 | ||
4392 | ALIAS_HIDDEN( | |
4393 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
4394 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4395 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4396 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4397 | "As-path attribute\n" | |
4398 | "Nexthop attribute\n" | |
4399 | "Med attribute\n") | |
596c17ba | 4400 | |
718e3744 | 4401 | DEFUN (no_neighbor_attr_unchanged, |
4402 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 4403 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 4404 | NO_STR |
718e3744 | 4405 | NEIGHBOR_STR |
4406 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4407 | "BGP attribute is propagated unchanged to this neighbor\n" |
4408 | "As-path attribute\n" | |
40e718b5 | 4409 | "Nexthop attribute\n" |
a8206004 | 4410 | "Med attribute\n") |
718e3744 | 4411 | { |
d62a17ae | 4412 | int idx = 0; |
4413 | char *peer = argv[2]->arg; | |
4414 | u_int16_t flags = 0; | |
4415 | ||
4416 | if (argv_find(argv, argc, "as-path", &idx)) | |
4417 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4418 | idx = 0; | |
4419 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4420 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4421 | idx = 0; | |
4422 | if (argv_find(argv, argc, "med", &idx)) | |
4423 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4424 | ||
4425 | if (!flags) // no flags means all of them! | |
4426 | { | |
4427 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4428 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4429 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4430 | } | |
4431 | ||
4432 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
4433 | bgp_node_safi(vty), flags); | |
4434 | } | |
4435 | ||
4436 | ALIAS_HIDDEN( | |
4437 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
4438 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4439 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4440 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4441 | "As-path attribute\n" | |
4442 | "Nexthop attribute\n" | |
4443 | "Med attribute\n") | |
718e3744 | 4444 | |
718e3744 | 4445 | /* EBGP multihop configuration. */ |
d62a17ae | 4446 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
4447 | const char *ttl_str) | |
718e3744 | 4448 | { |
d62a17ae | 4449 | struct peer *peer; |
4450 | unsigned int ttl; | |
718e3744 | 4451 | |
d62a17ae | 4452 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4453 | if (!peer) | |
4454 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4455 | |
d62a17ae | 4456 | if (peer->conf_if) |
4457 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 4458 | |
d62a17ae | 4459 | if (!ttl_str) |
4460 | ttl = MAXTTL; | |
4461 | else | |
4462 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 4463 | |
d62a17ae | 4464 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 4465 | } |
4466 | ||
d62a17ae | 4467 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4468 | { |
d62a17ae | 4469 | struct peer *peer; |
718e3744 | 4470 | |
d62a17ae | 4471 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4472 | if (!peer) | |
4473 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4474 | |
d62a17ae | 4475 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 4476 | } |
4477 | ||
4478 | /* neighbor ebgp-multihop. */ | |
4479 | DEFUN (neighbor_ebgp_multihop, | |
4480 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4481 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4482 | NEIGHBOR_STR |
4483 | NEIGHBOR_ADDR_STR2 | |
4484 | "Allow EBGP neighbors not on directly connected networks\n") | |
4485 | { | |
d62a17ae | 4486 | int idx_peer = 1; |
4487 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4488 | } |
4489 | ||
4490 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4491 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4492 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4493 | NEIGHBOR_STR |
4494 | NEIGHBOR_ADDR_STR2 | |
4495 | "Allow EBGP neighbors not on directly connected networks\n" | |
4496 | "maximum hop count\n") | |
4497 | { | |
d62a17ae | 4498 | int idx_peer = 1; |
4499 | int idx_number = 3; | |
4500 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
4501 | argv[idx_number]->arg); | |
718e3744 | 4502 | } |
4503 | ||
4504 | DEFUN (no_neighbor_ebgp_multihop, | |
4505 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4506 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4507 | NO_STR |
4508 | NEIGHBOR_STR | |
4509 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4510 | "Allow EBGP neighbors not on directly connected networks\n" |
4511 | "maximum hop count\n") | |
718e3744 | 4512 | { |
d62a17ae | 4513 | int idx_peer = 2; |
4514 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4515 | } |
4516 | ||
6b0655a2 | 4517 | |
6ffd2079 | 4518 | /* disable-connected-check */ |
4519 | DEFUN (neighbor_disable_connected_check, | |
4520 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 4521 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4522 | NEIGHBOR_STR |
7ebe625c | 4523 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4524 | "one-hop away EBGP peer using loopback address\n" |
4525 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4526 | { |
d62a17ae | 4527 | int idx_peer = 1; |
4528 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4529 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4530 | } |
4531 | ||
4532 | DEFUN (no_neighbor_disable_connected_check, | |
4533 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 4534 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4535 | NO_STR |
4536 | NEIGHBOR_STR | |
7ebe625c | 4537 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4538 | "one-hop away EBGP peer using loopback address\n" |
4539 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4540 | { |
d62a17ae | 4541 | int idx_peer = 2; |
4542 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4543 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4544 | } |
4545 | ||
718e3744 | 4546 | DEFUN (neighbor_description, |
4547 | neighbor_description_cmd, | |
e961923c | 4548 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4549 | NEIGHBOR_STR |
4550 | NEIGHBOR_ADDR_STR2 | |
4551 | "Neighbor specific description\n" | |
4552 | "Up to 80 characters describing this neighbor\n") | |
4553 | { | |
d62a17ae | 4554 | int idx_peer = 1; |
4555 | int idx_line = 3; | |
4556 | struct peer *peer; | |
4557 | char *str; | |
718e3744 | 4558 | |
d62a17ae | 4559 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4560 | if (!peer) | |
4561 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4562 | |
d62a17ae | 4563 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4564 | |
d62a17ae | 4565 | peer_description_set(peer, str); |
718e3744 | 4566 | |
d62a17ae | 4567 | XFREE(MTYPE_TMP, str); |
718e3744 | 4568 | |
d62a17ae | 4569 | return CMD_SUCCESS; |
718e3744 | 4570 | } |
4571 | ||
4572 | DEFUN (no_neighbor_description, | |
4573 | no_neighbor_description_cmd, | |
a636c635 | 4574 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]", |
718e3744 | 4575 | NO_STR |
4576 | NEIGHBOR_STR | |
4577 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4578 | "Neighbor specific description\n" |
4579 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 4580 | { |
d62a17ae | 4581 | int idx_peer = 2; |
4582 | struct peer *peer; | |
718e3744 | 4583 | |
d62a17ae | 4584 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4585 | if (!peer) | |
4586 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4587 | |
d62a17ae | 4588 | peer_description_unset(peer); |
718e3744 | 4589 | |
d62a17ae | 4590 | return CMD_SUCCESS; |
718e3744 | 4591 | } |
4592 | ||
6b0655a2 | 4593 | |
718e3744 | 4594 | /* Neighbor update-source. */ |
d62a17ae | 4595 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
4596 | const char *source_str) | |
4597 | { | |
4598 | struct peer *peer; | |
4599 | struct prefix p; | |
4600 | ||
4601 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4602 | if (!peer) | |
4603 | return CMD_WARNING_CONFIG_FAILED; | |
4604 | ||
4605 | if (peer->conf_if) | |
4606 | return CMD_WARNING; | |
4607 | ||
4608 | if (source_str) { | |
4609 | union sockunion su; | |
4610 | int ret = str2sockunion(source_str, &su); | |
4611 | ||
4612 | if (ret == 0) | |
4613 | peer_update_source_addr_set(peer, &su); | |
4614 | else { | |
4615 | if (str2prefix(source_str, &p)) { | |
4616 | vty_out(vty, | |
4617 | "%% Invalid update-source, remove prefix length \n"); | |
4618 | return CMD_WARNING_CONFIG_FAILED; | |
4619 | } else | |
4620 | peer_update_source_if_set(peer, source_str); | |
4621 | } | |
4622 | } else | |
4623 | peer_update_source_unset(peer); | |
4624 | ||
4625 | return CMD_SUCCESS; | |
4626 | } | |
4627 | ||
4628 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
4629 | "IPv4 address\n" \ | |
4630 | "IPv6 address\n" \ | |
4631 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4632 | |
718e3744 | 4633 | DEFUN (neighbor_update_source, |
4634 | neighbor_update_source_cmd, | |
9ccf14f7 | 4635 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4636 | NEIGHBOR_STR |
4637 | NEIGHBOR_ADDR_STR2 | |
4638 | "Source of routing updates\n" | |
369688c0 | 4639 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4640 | { |
d62a17ae | 4641 | int idx_peer = 1; |
4642 | int idx_peer_2 = 3; | |
4643 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
4644 | argv[idx_peer_2]->arg); | |
718e3744 | 4645 | } |
4646 | ||
4647 | DEFUN (no_neighbor_update_source, | |
4648 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4649 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4650 | NO_STR |
4651 | NEIGHBOR_STR | |
4652 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4653 | "Source of routing updates\n" |
4654 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4655 | { |
d62a17ae | 4656 | int idx_peer = 2; |
4657 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4658 | } |
6b0655a2 | 4659 | |
d62a17ae | 4660 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
4661 | afi_t afi, safi_t safi, | |
4662 | const char *rmap, int set) | |
718e3744 | 4663 | { |
d62a17ae | 4664 | int ret; |
4665 | struct peer *peer; | |
718e3744 | 4666 | |
d62a17ae | 4667 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4668 | if (!peer) | |
4669 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4670 | |
d62a17ae | 4671 | if (set) |
4672 | ret = peer_default_originate_set(peer, afi, safi, rmap); | |
4673 | else | |
4674 | ret = peer_default_originate_unset(peer, afi, safi); | |
718e3744 | 4675 | |
d62a17ae | 4676 | return bgp_vty_return(vty, ret); |
718e3744 | 4677 | } |
4678 | ||
4679 | /* neighbor default-originate. */ | |
4680 | DEFUN (neighbor_default_originate, | |
4681 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4682 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4683 | NEIGHBOR_STR |
4684 | NEIGHBOR_ADDR_STR2 | |
4685 | "Originate default route to this neighbor\n") | |
4686 | { | |
d62a17ae | 4687 | int idx_peer = 1; |
4688 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4689 | bgp_node_afi(vty), | |
4690 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 4691 | } |
4692 | ||
d62a17ae | 4693 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
4694 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
4695 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4696 | "Originate default route to this neighbor\n") | |
596c17ba | 4697 | |
718e3744 | 4698 | DEFUN (neighbor_default_originate_rmap, |
4699 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4700 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4701 | NEIGHBOR_STR |
4702 | NEIGHBOR_ADDR_STR2 | |
4703 | "Originate default route to this neighbor\n" | |
4704 | "Route-map to specify criteria to originate default\n" | |
4705 | "route-map name\n") | |
4706 | { | |
d62a17ae | 4707 | int idx_peer = 1; |
4708 | int idx_word = 4; | |
4709 | return peer_default_originate_set_vty( | |
4710 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4711 | argv[idx_word]->arg, 1); | |
718e3744 | 4712 | } |
4713 | ||
d62a17ae | 4714 | ALIAS_HIDDEN( |
4715 | neighbor_default_originate_rmap, | |
4716 | neighbor_default_originate_rmap_hidden_cmd, | |
4717 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
4718 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4719 | "Originate default route to this neighbor\n" | |
4720 | "Route-map to specify criteria to originate default\n" | |
4721 | "route-map name\n") | |
596c17ba | 4722 | |
718e3744 | 4723 | DEFUN (no_neighbor_default_originate, |
4724 | no_neighbor_default_originate_cmd, | |
a636c635 | 4725 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4726 | NO_STR |
4727 | NEIGHBOR_STR | |
4728 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4729 | "Originate default route to this neighbor\n" |
4730 | "Route-map to specify criteria to originate default\n" | |
4731 | "route-map name\n") | |
718e3744 | 4732 | { |
d62a17ae | 4733 | int idx_peer = 2; |
4734 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4735 | bgp_node_afi(vty), | |
4736 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 4737 | } |
4738 | ||
d62a17ae | 4739 | ALIAS_HIDDEN( |
4740 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
4741 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
4742 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4743 | "Originate default route to this neighbor\n" | |
4744 | "Route-map to specify criteria to originate default\n" | |
4745 | "route-map name\n") | |
596c17ba | 4746 | |
6b0655a2 | 4747 | |
718e3744 | 4748 | /* Set neighbor's BGP port. */ |
d62a17ae | 4749 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
4750 | const char *port_str) | |
4751 | { | |
4752 | struct peer *peer; | |
4753 | u_int16_t port; | |
4754 | struct servent *sp; | |
4755 | ||
4756 | peer = peer_lookup_vty(vty, ip_str); | |
4757 | if (!peer) | |
4758 | return CMD_WARNING_CONFIG_FAILED; | |
4759 | ||
4760 | if (!port_str) { | |
4761 | sp = getservbyname("bgp", "tcp"); | |
4762 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
4763 | } else { | |
4764 | port = strtoul(port_str, NULL, 10); | |
4765 | } | |
718e3744 | 4766 | |
d62a17ae | 4767 | peer_port_set(peer, port); |
718e3744 | 4768 | |
d62a17ae | 4769 | return CMD_SUCCESS; |
718e3744 | 4770 | } |
4771 | ||
f418446b | 4772 | /* Set specified peer's BGP port. */ |
718e3744 | 4773 | DEFUN (neighbor_port, |
4774 | neighbor_port_cmd, | |
9ccf14f7 | 4775 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4776 | NEIGHBOR_STR |
4777 | NEIGHBOR_ADDR_STR | |
4778 | "Neighbor's BGP port\n" | |
4779 | "TCP port number\n") | |
4780 | { | |
d62a17ae | 4781 | int idx_ip = 1; |
4782 | int idx_number = 3; | |
4783 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
4784 | argv[idx_number]->arg); | |
718e3744 | 4785 | } |
4786 | ||
4787 | DEFUN (no_neighbor_port, | |
4788 | no_neighbor_port_cmd, | |
9ccf14f7 | 4789 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4790 | NO_STR |
4791 | NEIGHBOR_STR | |
4792 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4793 | "Neighbor's BGP port\n" |
4794 | "TCP port number\n") | |
718e3744 | 4795 | { |
d62a17ae | 4796 | int idx_ip = 2; |
4797 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4798 | } |
4799 | ||
6b0655a2 | 4800 | |
718e3744 | 4801 | /* neighbor weight. */ |
d62a17ae | 4802 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4803 | safi_t safi, const char *weight_str) | |
718e3744 | 4804 | { |
d62a17ae | 4805 | int ret; |
4806 | struct peer *peer; | |
4807 | unsigned long weight; | |
718e3744 | 4808 | |
d62a17ae | 4809 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4810 | if (!peer) | |
4811 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4812 | |
d62a17ae | 4813 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 4814 | |
d62a17ae | 4815 | ret = peer_weight_set(peer, afi, safi, weight); |
4816 | return bgp_vty_return(vty, ret); | |
718e3744 | 4817 | } |
4818 | ||
d62a17ae | 4819 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4820 | safi_t safi) | |
718e3744 | 4821 | { |
d62a17ae | 4822 | int ret; |
4823 | struct peer *peer; | |
718e3744 | 4824 | |
d62a17ae | 4825 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4826 | if (!peer) | |
4827 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4828 | |
d62a17ae | 4829 | ret = peer_weight_unset(peer, afi, safi); |
4830 | return bgp_vty_return(vty, ret); | |
718e3744 | 4831 | } |
4832 | ||
4833 | DEFUN (neighbor_weight, | |
4834 | neighbor_weight_cmd, | |
9ccf14f7 | 4835 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 4836 | NEIGHBOR_STR |
4837 | NEIGHBOR_ADDR_STR2 | |
4838 | "Set default weight for routes from this neighbor\n" | |
4839 | "default weight\n") | |
4840 | { | |
d62a17ae | 4841 | int idx_peer = 1; |
4842 | int idx_number = 3; | |
4843 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4844 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 4845 | } |
4846 | ||
d62a17ae | 4847 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
4848 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
4849 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4850 | "Set default weight for routes from this neighbor\n" | |
4851 | "default weight\n") | |
596c17ba | 4852 | |
718e3744 | 4853 | DEFUN (no_neighbor_weight, |
4854 | no_neighbor_weight_cmd, | |
9ccf14f7 | 4855 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 4856 | NO_STR |
4857 | NEIGHBOR_STR | |
4858 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4859 | "Set default weight for routes from this neighbor\n" |
4860 | "default weight\n") | |
718e3744 | 4861 | { |
d62a17ae | 4862 | int idx_peer = 2; |
4863 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
4864 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 4865 | } |
4866 | ||
d62a17ae | 4867 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
4868 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
4869 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4870 | "Set default weight for routes from this neighbor\n" | |
4871 | "default weight\n") | |
596c17ba | 4872 | |
6b0655a2 | 4873 | |
718e3744 | 4874 | /* Override capability negotiation. */ |
4875 | DEFUN (neighbor_override_capability, | |
4876 | neighbor_override_capability_cmd, | |
9ccf14f7 | 4877 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4878 | NEIGHBOR_STR |
4879 | NEIGHBOR_ADDR_STR2 | |
4880 | "Override capability negotiation result\n") | |
4881 | { | |
d62a17ae | 4882 | int idx_peer = 1; |
4883 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4884 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4885 | } |
4886 | ||
4887 | DEFUN (no_neighbor_override_capability, | |
4888 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 4889 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4890 | NO_STR |
4891 | NEIGHBOR_STR | |
4892 | NEIGHBOR_ADDR_STR2 | |
4893 | "Override capability negotiation result\n") | |
4894 | { | |
d62a17ae | 4895 | int idx_peer = 2; |
4896 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4897 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4898 | } |
6b0655a2 | 4899 | |
718e3744 | 4900 | DEFUN (neighbor_strict_capability, |
4901 | neighbor_strict_capability_cmd, | |
9ccf14f7 | 4902 | "neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4903 | NEIGHBOR_STR |
4904 | NEIGHBOR_ADDR_STR | |
4905 | "Strict capability negotiation match\n") | |
4906 | { | |
d62a17ae | 4907 | int idx_ip = 1; |
4908 | return peer_flag_set_vty(vty, argv[idx_ip]->arg, | |
4909 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4910 | } |
4911 | ||
4912 | DEFUN (no_neighbor_strict_capability, | |
4913 | no_neighbor_strict_capability_cmd, | |
9ccf14f7 | 4914 | "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4915 | NO_STR |
4916 | NEIGHBOR_STR | |
4917 | NEIGHBOR_ADDR_STR | |
4918 | "Strict capability negotiation match\n") | |
4919 | { | |
d62a17ae | 4920 | int idx_ip = 2; |
4921 | return peer_flag_unset_vty(vty, argv[idx_ip]->arg, | |
4922 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4923 | } |
6b0655a2 | 4924 | |
d62a17ae | 4925 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
4926 | const char *keep_str, const char *hold_str) | |
718e3744 | 4927 | { |
d62a17ae | 4928 | int ret; |
4929 | struct peer *peer; | |
4930 | u_int32_t keepalive; | |
4931 | u_int32_t holdtime; | |
718e3744 | 4932 | |
d62a17ae | 4933 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4934 | if (!peer) | |
4935 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4936 | |
d62a17ae | 4937 | keepalive = strtoul(keep_str, NULL, 10); |
4938 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 4939 | |
d62a17ae | 4940 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 4941 | |
d62a17ae | 4942 | return bgp_vty_return(vty, ret); |
718e3744 | 4943 | } |
6b0655a2 | 4944 | |
d62a17ae | 4945 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4946 | { |
d62a17ae | 4947 | int ret; |
4948 | struct peer *peer; | |
718e3744 | 4949 | |
d62a17ae | 4950 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4951 | if (!peer) | |
4952 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4953 | |
d62a17ae | 4954 | ret = peer_timers_unset(peer); |
718e3744 | 4955 | |
d62a17ae | 4956 | return bgp_vty_return(vty, ret); |
718e3744 | 4957 | } |
4958 | ||
4959 | DEFUN (neighbor_timers, | |
4960 | neighbor_timers_cmd, | |
9ccf14f7 | 4961 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 4962 | NEIGHBOR_STR |
4963 | NEIGHBOR_ADDR_STR2 | |
4964 | "BGP per neighbor timers\n" | |
4965 | "Keepalive interval\n" | |
4966 | "Holdtime\n") | |
4967 | { | |
d62a17ae | 4968 | int idx_peer = 1; |
4969 | int idx_number = 3; | |
4970 | int idx_number_2 = 4; | |
4971 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
4972 | argv[idx_number]->arg, | |
4973 | argv[idx_number_2]->arg); | |
718e3744 | 4974 | } |
4975 | ||
4976 | DEFUN (no_neighbor_timers, | |
4977 | no_neighbor_timers_cmd, | |
9ccf14f7 | 4978 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 4979 | NO_STR |
4980 | NEIGHBOR_STR | |
4981 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4982 | "BGP per neighbor timers\n" |
4983 | "Keepalive interval\n" | |
4984 | "Holdtime\n") | |
718e3744 | 4985 | { |
d62a17ae | 4986 | int idx_peer = 2; |
4987 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4988 | } |
6b0655a2 | 4989 | |
813d4307 | 4990 | |
d62a17ae | 4991 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
4992 | const char *time_str) | |
718e3744 | 4993 | { |
d62a17ae | 4994 | int ret; |
4995 | struct peer *peer; | |
4996 | u_int32_t connect; | |
718e3744 | 4997 | |
d62a17ae | 4998 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4999 | if (!peer) | |
5000 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5001 | |
d62a17ae | 5002 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5003 | |
d62a17ae | 5004 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5005 | |
d62a17ae | 5006 | return bgp_vty_return(vty, ret); |
718e3744 | 5007 | } |
5008 | ||
d62a17ae | 5009 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5010 | { |
d62a17ae | 5011 | int ret; |
5012 | struct peer *peer; | |
718e3744 | 5013 | |
d62a17ae | 5014 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5015 | if (!peer) | |
5016 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5017 | |
d62a17ae | 5018 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5019 | |
d62a17ae | 5020 | return bgp_vty_return(vty, ret); |
718e3744 | 5021 | } |
5022 | ||
5023 | DEFUN (neighbor_timers_connect, | |
5024 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5025 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5026 | NEIGHBOR_STR |
966f821c | 5027 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5028 | "BGP per neighbor timers\n" |
5029 | "BGP connect timer\n" | |
5030 | "Connect timer\n") | |
5031 | { | |
d62a17ae | 5032 | int idx_peer = 1; |
5033 | int idx_number = 4; | |
5034 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5035 | argv[idx_number]->arg); | |
718e3744 | 5036 | } |
5037 | ||
5038 | DEFUN (no_neighbor_timers_connect, | |
5039 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5040 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5041 | NO_STR |
5042 | NEIGHBOR_STR | |
966f821c | 5043 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5044 | "BGP per neighbor timers\n" |
8334fd5a DW |
5045 | "BGP connect timer\n" |
5046 | "Connect timer\n") | |
718e3744 | 5047 | { |
d62a17ae | 5048 | int idx_peer = 2; |
5049 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5050 | } |
5051 | ||
6b0655a2 | 5052 | |
d62a17ae | 5053 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5054 | const char *time_str, int set) | |
718e3744 | 5055 | { |
d62a17ae | 5056 | int ret; |
5057 | struct peer *peer; | |
5058 | u_int32_t routeadv = 0; | |
718e3744 | 5059 | |
d62a17ae | 5060 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5061 | if (!peer) | |
5062 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5063 | |
d62a17ae | 5064 | if (time_str) |
5065 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5066 | |
d62a17ae | 5067 | if (set) |
5068 | ret = peer_advertise_interval_set(peer, routeadv); | |
5069 | else | |
5070 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5071 | |
d62a17ae | 5072 | return bgp_vty_return(vty, ret); |
718e3744 | 5073 | } |
5074 | ||
5075 | DEFUN (neighbor_advertise_interval, | |
5076 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5077 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5078 | NEIGHBOR_STR |
966f821c | 5079 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5080 | "Minimum interval between sending BGP routing updates\n" |
5081 | "time in seconds\n") | |
5082 | { | |
d62a17ae | 5083 | int idx_peer = 1; |
5084 | int idx_number = 3; | |
5085 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5086 | argv[idx_number]->arg, 1); | |
718e3744 | 5087 | } |
5088 | ||
5089 | DEFUN (no_neighbor_advertise_interval, | |
5090 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5091 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5092 | NO_STR |
5093 | NEIGHBOR_STR | |
966f821c | 5094 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5095 | "Minimum interval between sending BGP routing updates\n" |
5096 | "time in seconds\n") | |
718e3744 | 5097 | { |
d62a17ae | 5098 | int idx_peer = 2; |
5099 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5100 | } |
5101 | ||
6b0655a2 | 5102 | |
518f0eb1 DS |
5103 | /* Time to wait before processing route-map updates */ |
5104 | DEFUN (bgp_set_route_map_delay_timer, | |
5105 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5106 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5107 | SET_STR |
5108 | "BGP route-map delay timer\n" | |
5109 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5110 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5111 | { |
d62a17ae | 5112 | int idx_number = 3; |
5113 | u_int32_t rmap_delay_timer; | |
5114 | ||
5115 | if (argv[idx_number]->arg) { | |
5116 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
5117 | bm->rmap_update_timer = rmap_delay_timer; | |
5118 | ||
5119 | /* if the dynamic update handling is being disabled, and a timer | |
5120 | * is | |
5121 | * running, stop the timer and act as if the timer has already | |
5122 | * fired. | |
5123 | */ | |
5124 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
5125 | BGP_TIMER_OFF(bm->t_rmap_update); | |
5126 | thread_execute(bm->master, bgp_route_map_update_timer, | |
5127 | NULL, 0); | |
5128 | } | |
5129 | return CMD_SUCCESS; | |
5130 | } else { | |
5131 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5132 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5133 | } |
518f0eb1 DS |
5134 | } |
5135 | ||
5136 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5137 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5138 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5139 | NO_STR |
3a2d747c | 5140 | BGP_STR |
518f0eb1 | 5141 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5142 | "Reset to default time to wait for processing route-map changes\n" |
5143 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5144 | { |
518f0eb1 | 5145 | |
d62a17ae | 5146 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 5147 | |
d62a17ae | 5148 | return CMD_SUCCESS; |
518f0eb1 DS |
5149 | } |
5150 | ||
f414725f | 5151 | |
718e3744 | 5152 | /* neighbor interface */ |
d62a17ae | 5153 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
5154 | const char *str) | |
718e3744 | 5155 | { |
d62a17ae | 5156 | struct peer *peer; |
718e3744 | 5157 | |
d62a17ae | 5158 | peer = peer_lookup_vty(vty, ip_str); |
5159 | if (!peer || peer->conf_if) { | |
5160 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
5161 | return CMD_WARNING_CONFIG_FAILED; | |
5162 | } | |
718e3744 | 5163 | |
d62a17ae | 5164 | if (str) |
5165 | peer_interface_set(peer, str); | |
5166 | else | |
5167 | peer_interface_unset(peer); | |
718e3744 | 5168 | |
d62a17ae | 5169 | return CMD_SUCCESS; |
718e3744 | 5170 | } |
5171 | ||
5172 | DEFUN (neighbor_interface, | |
5173 | neighbor_interface_cmd, | |
9ccf14f7 | 5174 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5175 | NEIGHBOR_STR |
5176 | NEIGHBOR_ADDR_STR | |
5177 | "Interface\n" | |
5178 | "Interface name\n") | |
5179 | { | |
d62a17ae | 5180 | int idx_ip = 1; |
5181 | int idx_word = 3; | |
5182 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 5183 | } |
5184 | ||
5185 | DEFUN (no_neighbor_interface, | |
5186 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5187 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5188 | NO_STR |
5189 | NEIGHBOR_STR | |
16cedbb0 | 5190 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5191 | "Interface\n" |
5192 | "Interface name\n") | |
5193 | { | |
d62a17ae | 5194 | int idx_peer = 2; |
5195 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5196 | } |
6b0655a2 | 5197 | |
718e3744 | 5198 | DEFUN (neighbor_distribute_list, |
5199 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5200 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5201 | NEIGHBOR_STR |
5202 | NEIGHBOR_ADDR_STR2 | |
5203 | "Filter updates to/from this neighbor\n" | |
5204 | "IP access-list number\n" | |
5205 | "IP access-list number (expanded range)\n" | |
5206 | "IP Access-list name\n" | |
5207 | "Filter incoming updates\n" | |
5208 | "Filter outgoing updates\n") | |
5209 | { | |
d62a17ae | 5210 | int idx_peer = 1; |
5211 | int idx_acl = 3; | |
5212 | int direct, ret; | |
5213 | struct peer *peer; | |
a8206004 | 5214 | |
d62a17ae | 5215 | const char *pstr = argv[idx_peer]->arg; |
5216 | const char *acl = argv[idx_acl]->arg; | |
5217 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5218 | |
d62a17ae | 5219 | peer = peer_and_group_lookup_vty(vty, pstr); |
5220 | if (!peer) | |
5221 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5222 | |
d62a17ae | 5223 | /* Check filter direction. */ |
5224 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5225 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5226 | direct, acl); | |
a8206004 | 5227 | |
d62a17ae | 5228 | return bgp_vty_return(vty, ret); |
718e3744 | 5229 | } |
5230 | ||
d62a17ae | 5231 | ALIAS_HIDDEN( |
5232 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
5233 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5234 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5235 | "Filter updates to/from this neighbor\n" | |
5236 | "IP access-list number\n" | |
5237 | "IP access-list number (expanded range)\n" | |
5238 | "IP Access-list name\n" | |
5239 | "Filter incoming updates\n" | |
5240 | "Filter outgoing updates\n") | |
596c17ba | 5241 | |
718e3744 | 5242 | DEFUN (no_neighbor_distribute_list, |
5243 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5244 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5245 | NO_STR |
5246 | NEIGHBOR_STR | |
5247 | NEIGHBOR_ADDR_STR2 | |
5248 | "Filter updates to/from this neighbor\n" | |
5249 | "IP access-list number\n" | |
5250 | "IP access-list number (expanded range)\n" | |
5251 | "IP Access-list name\n" | |
5252 | "Filter incoming updates\n" | |
5253 | "Filter outgoing updates\n") | |
5254 | { | |
d62a17ae | 5255 | int idx_peer = 2; |
5256 | int direct, ret; | |
5257 | struct peer *peer; | |
a8206004 | 5258 | |
d62a17ae | 5259 | const char *pstr = argv[idx_peer]->arg; |
5260 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5261 | |
d62a17ae | 5262 | peer = peer_and_group_lookup_vty(vty, pstr); |
5263 | if (!peer) | |
5264 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5265 | |
d62a17ae | 5266 | /* Check filter direction. */ |
5267 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5268 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5269 | direct); | |
a8206004 | 5270 | |
d62a17ae | 5271 | return bgp_vty_return(vty, ret); |
718e3744 | 5272 | } |
6b0655a2 | 5273 | |
d62a17ae | 5274 | ALIAS_HIDDEN( |
5275 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
5276 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5277 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5278 | "Filter updates to/from this neighbor\n" | |
5279 | "IP access-list number\n" | |
5280 | "IP access-list number (expanded range)\n" | |
5281 | "IP Access-list name\n" | |
5282 | "Filter incoming updates\n" | |
5283 | "Filter outgoing updates\n") | |
596c17ba | 5284 | |
718e3744 | 5285 | /* Set prefix list to the peer. */ |
d62a17ae | 5286 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
5287 | afi_t afi, safi_t safi, | |
5288 | const char *name_str, | |
5289 | const char *direct_str) | |
718e3744 | 5290 | { |
d62a17ae | 5291 | int ret; |
5292 | struct peer *peer; | |
5293 | int direct = FILTER_IN; | |
718e3744 | 5294 | |
d62a17ae | 5295 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5296 | if (!peer) | |
5297 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5298 | |
d62a17ae | 5299 | /* Check filter direction. */ |
5300 | if (strncmp(direct_str, "i", 1) == 0) | |
5301 | direct = FILTER_IN; | |
5302 | else if (strncmp(direct_str, "o", 1) == 0) | |
5303 | direct = FILTER_OUT; | |
718e3744 | 5304 | |
d62a17ae | 5305 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 5306 | |
d62a17ae | 5307 | return bgp_vty_return(vty, ret); |
718e3744 | 5308 | } |
5309 | ||
d62a17ae | 5310 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
5311 | afi_t afi, safi_t safi, | |
5312 | const char *direct_str) | |
718e3744 | 5313 | { |
d62a17ae | 5314 | int ret; |
5315 | struct peer *peer; | |
5316 | int direct = FILTER_IN; | |
718e3744 | 5317 | |
d62a17ae | 5318 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5319 | if (!peer) | |
5320 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 5321 | |
d62a17ae | 5322 | /* Check filter direction. */ |
5323 | if (strncmp(direct_str, "i", 1) == 0) | |
5324 | direct = FILTER_IN; | |
5325 | else if (strncmp(direct_str, "o", 1) == 0) | |
5326 | direct = FILTER_OUT; | |
718e3744 | 5327 | |
d62a17ae | 5328 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 5329 | |
d62a17ae | 5330 | return bgp_vty_return(vty, ret); |
718e3744 | 5331 | } |
5332 | ||
5333 | DEFUN (neighbor_prefix_list, | |
5334 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5335 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5336 | NEIGHBOR_STR |
5337 | NEIGHBOR_ADDR_STR2 | |
5338 | "Filter updates to/from this neighbor\n" | |
5339 | "Name of a prefix list\n" | |
5340 | "Filter incoming updates\n" | |
5341 | "Filter outgoing updates\n") | |
5342 | { | |
d62a17ae | 5343 | int idx_peer = 1; |
5344 | int idx_word = 3; | |
5345 | int idx_in_out = 4; | |
5346 | return peer_prefix_list_set_vty( | |
5347 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5348 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5349 | } |
5350 | ||
d62a17ae | 5351 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
5352 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5353 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5354 | "Filter updates to/from this neighbor\n" | |
5355 | "Name of a prefix list\n" | |
5356 | "Filter incoming updates\n" | |
5357 | "Filter outgoing updates\n") | |
596c17ba | 5358 | |
718e3744 | 5359 | DEFUN (no_neighbor_prefix_list, |
5360 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5361 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5362 | NO_STR |
5363 | NEIGHBOR_STR | |
5364 | NEIGHBOR_ADDR_STR2 | |
5365 | "Filter updates to/from this neighbor\n" | |
5366 | "Name of a prefix list\n" | |
5367 | "Filter incoming updates\n" | |
5368 | "Filter outgoing updates\n") | |
5369 | { | |
d62a17ae | 5370 | int idx_peer = 2; |
5371 | int idx_in_out = 5; | |
5372 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
5373 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5374 | argv[idx_in_out]->arg); | |
718e3744 | 5375 | } |
6b0655a2 | 5376 | |
d62a17ae | 5377 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
5378 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5379 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5380 | "Filter updates to/from this neighbor\n" | |
5381 | "Name of a prefix list\n" | |
5382 | "Filter incoming updates\n" | |
5383 | "Filter outgoing updates\n") | |
596c17ba | 5384 | |
d62a17ae | 5385 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5386 | safi_t safi, const char *name_str, | |
5387 | const char *direct_str) | |
718e3744 | 5388 | { |
d62a17ae | 5389 | int ret; |
5390 | struct peer *peer; | |
5391 | int direct = FILTER_IN; | |
718e3744 | 5392 | |
d62a17ae | 5393 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5394 | if (!peer) | |
5395 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5396 | |
d62a17ae | 5397 | /* Check filter direction. */ |
5398 | if (strncmp(direct_str, "i", 1) == 0) | |
5399 | direct = FILTER_IN; | |
5400 | else if (strncmp(direct_str, "o", 1) == 0) | |
5401 | direct = FILTER_OUT; | |
718e3744 | 5402 | |
d62a17ae | 5403 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 5404 | |
d62a17ae | 5405 | return bgp_vty_return(vty, ret); |
718e3744 | 5406 | } |
5407 | ||
d62a17ae | 5408 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5409 | safi_t safi, const char *direct_str) | |
718e3744 | 5410 | { |
d62a17ae | 5411 | int ret; |
5412 | struct peer *peer; | |
5413 | int direct = FILTER_IN; | |
718e3744 | 5414 | |
d62a17ae | 5415 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5416 | if (!peer) | |
5417 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5418 | |
d62a17ae | 5419 | /* Check filter direction. */ |
5420 | if (strncmp(direct_str, "i", 1) == 0) | |
5421 | direct = FILTER_IN; | |
5422 | else if (strncmp(direct_str, "o", 1) == 0) | |
5423 | direct = FILTER_OUT; | |
718e3744 | 5424 | |
d62a17ae | 5425 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 5426 | |
d62a17ae | 5427 | return bgp_vty_return(vty, ret); |
718e3744 | 5428 | } |
5429 | ||
5430 | DEFUN (neighbor_filter_list, | |
5431 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5432 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5433 | NEIGHBOR_STR |
5434 | NEIGHBOR_ADDR_STR2 | |
5435 | "Establish BGP filters\n" | |
5436 | "AS path access-list name\n" | |
5437 | "Filter incoming routes\n" | |
5438 | "Filter outgoing routes\n") | |
5439 | { | |
d62a17ae | 5440 | int idx_peer = 1; |
5441 | int idx_word = 3; | |
5442 | int idx_in_out = 4; | |
5443 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5444 | bgp_node_safi(vty), argv[idx_word]->arg, | |
5445 | argv[idx_in_out]->arg); | |
718e3744 | 5446 | } |
5447 | ||
d62a17ae | 5448 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
5449 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5450 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5451 | "Establish BGP filters\n" | |
5452 | "AS path access-list name\n" | |
5453 | "Filter incoming routes\n" | |
5454 | "Filter outgoing routes\n") | |
596c17ba | 5455 | |
718e3744 | 5456 | DEFUN (no_neighbor_filter_list, |
5457 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5458 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5459 | NO_STR |
5460 | NEIGHBOR_STR | |
5461 | NEIGHBOR_ADDR_STR2 | |
5462 | "Establish BGP filters\n" | |
5463 | "AS path access-list name\n" | |
5464 | "Filter incoming routes\n" | |
5465 | "Filter outgoing routes\n") | |
5466 | { | |
d62a17ae | 5467 | int idx_peer = 2; |
5468 | int idx_in_out = 5; | |
5469 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
5470 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5471 | argv[idx_in_out]->arg); | |
718e3744 | 5472 | } |
6b0655a2 | 5473 | |
d62a17ae | 5474 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
5475 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5476 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5477 | "Establish BGP filters\n" | |
5478 | "AS path access-list name\n" | |
5479 | "Filter incoming routes\n" | |
5480 | "Filter outgoing routes\n") | |
596c17ba | 5481 | |
718e3744 | 5482 | /* Set route-map to the peer. */ |
d62a17ae | 5483 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
5484 | afi_t afi, safi_t safi, const char *name_str, | |
5485 | const char *direct_str) | |
718e3744 | 5486 | { |
d62a17ae | 5487 | int ret; |
5488 | struct peer *peer; | |
5489 | int direct = RMAP_IN; | |
718e3744 | 5490 | |
d62a17ae | 5491 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5492 | if (!peer) | |
5493 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5494 | |
d62a17ae | 5495 | /* Check filter direction. */ |
5496 | if (strncmp(direct_str, "in", 2) == 0) | |
5497 | direct = RMAP_IN; | |
5498 | else if (strncmp(direct_str, "o", 1) == 0) | |
5499 | direct = RMAP_OUT; | |
718e3744 | 5500 | |
d62a17ae | 5501 | ret = peer_route_map_set(peer, afi, safi, direct, name_str); |
718e3744 | 5502 | |
d62a17ae | 5503 | return bgp_vty_return(vty, ret); |
718e3744 | 5504 | } |
5505 | ||
d62a17ae | 5506 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
5507 | afi_t afi, safi_t safi, | |
5508 | const char *direct_str) | |
718e3744 | 5509 | { |
d62a17ae | 5510 | int ret; |
5511 | struct peer *peer; | |
5512 | int direct = RMAP_IN; | |
718e3744 | 5513 | |
d62a17ae | 5514 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5515 | if (!peer) | |
5516 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5517 | |
d62a17ae | 5518 | /* Check filter direction. */ |
5519 | if (strncmp(direct_str, "in", 2) == 0) | |
5520 | direct = RMAP_IN; | |
5521 | else if (strncmp(direct_str, "o", 1) == 0) | |
5522 | direct = RMAP_OUT; | |
718e3744 | 5523 | |
d62a17ae | 5524 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 5525 | |
d62a17ae | 5526 | return bgp_vty_return(vty, ret); |
718e3744 | 5527 | } |
5528 | ||
5529 | DEFUN (neighbor_route_map, | |
5530 | neighbor_route_map_cmd, | |
9ccf14f7 | 5531 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5532 | NEIGHBOR_STR |
5533 | NEIGHBOR_ADDR_STR2 | |
5534 | "Apply route map to neighbor\n" | |
5535 | "Name of route map\n" | |
5536 | "Apply map to incoming routes\n" | |
2a3d5731 | 5537 | "Apply map to outbound routes\n") |
718e3744 | 5538 | { |
d62a17ae | 5539 | int idx_peer = 1; |
5540 | int idx_word = 3; | |
5541 | int idx_in_out = 4; | |
5542 | return peer_route_map_set_vty( | |
5543 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5544 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5545 | } |
5546 | ||
d62a17ae | 5547 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
5548 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5549 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5550 | "Apply route map to neighbor\n" | |
5551 | "Name of route map\n" | |
5552 | "Apply map to incoming routes\n" | |
5553 | "Apply map to outbound routes\n") | |
596c17ba | 5554 | |
718e3744 | 5555 | DEFUN (no_neighbor_route_map, |
5556 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5557 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5558 | NO_STR |
5559 | NEIGHBOR_STR | |
5560 | NEIGHBOR_ADDR_STR2 | |
5561 | "Apply route map to neighbor\n" | |
5562 | "Name of route map\n" | |
5563 | "Apply map to incoming routes\n" | |
2a3d5731 | 5564 | "Apply map to outbound routes\n") |
718e3744 | 5565 | { |
d62a17ae | 5566 | int idx_peer = 2; |
5567 | int idx_in_out = 5; | |
5568 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
5569 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5570 | argv[idx_in_out]->arg); | |
718e3744 | 5571 | } |
6b0655a2 | 5572 | |
d62a17ae | 5573 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
5574 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5575 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5576 | "Apply route map to neighbor\n" | |
5577 | "Name of route map\n" | |
5578 | "Apply map to incoming routes\n" | |
5579 | "Apply map to outbound routes\n") | |
596c17ba | 5580 | |
718e3744 | 5581 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 5582 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
5583 | afi_t afi, safi_t safi, | |
5584 | const char *name_str) | |
718e3744 | 5585 | { |
d62a17ae | 5586 | int ret; |
5587 | struct peer *peer; | |
718e3744 | 5588 | |
d62a17ae | 5589 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5590 | if (!peer) | |
5591 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5592 | |
d62a17ae | 5593 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str); |
718e3744 | 5594 | |
d62a17ae | 5595 | return bgp_vty_return(vty, ret); |
718e3744 | 5596 | } |
5597 | ||
5598 | /* Unset route-map from the peer. */ | |
d62a17ae | 5599 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
5600 | afi_t afi, safi_t safi) | |
718e3744 | 5601 | { |
d62a17ae | 5602 | int ret; |
5603 | struct peer *peer; | |
718e3744 | 5604 | |
d62a17ae | 5605 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5606 | if (!peer) | |
5607 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5608 | |
d62a17ae | 5609 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 5610 | |
d62a17ae | 5611 | return bgp_vty_return(vty, ret); |
718e3744 | 5612 | } |
5613 | ||
5614 | DEFUN (neighbor_unsuppress_map, | |
5615 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5616 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5617 | NEIGHBOR_STR |
5618 | NEIGHBOR_ADDR_STR2 | |
5619 | "Route-map to selectively unsuppress suppressed routes\n" | |
5620 | "Name of route map\n") | |
5621 | { | |
d62a17ae | 5622 | int idx_peer = 1; |
5623 | int idx_word = 3; | |
5624 | return peer_unsuppress_map_set_vty( | |
5625 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5626 | argv[idx_word]->arg); | |
718e3744 | 5627 | } |
5628 | ||
d62a17ae | 5629 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
5630 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5631 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5632 | "Route-map to selectively unsuppress suppressed routes\n" | |
5633 | "Name of route map\n") | |
596c17ba | 5634 | |
718e3744 | 5635 | DEFUN (no_neighbor_unsuppress_map, |
5636 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5637 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5638 | NO_STR |
5639 | NEIGHBOR_STR | |
5640 | NEIGHBOR_ADDR_STR2 | |
5641 | "Route-map to selectively unsuppress suppressed routes\n" | |
5642 | "Name of route map\n") | |
5643 | { | |
d62a17ae | 5644 | int idx_peer = 2; |
5645 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
5646 | bgp_node_afi(vty), | |
5647 | bgp_node_safi(vty)); | |
718e3744 | 5648 | } |
6b0655a2 | 5649 | |
d62a17ae | 5650 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
5651 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5652 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5653 | "Route-map to selectively unsuppress suppressed routes\n" | |
5654 | "Name of route map\n") | |
596c17ba | 5655 | |
d62a17ae | 5656 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
5657 | afi_t afi, safi_t safi, | |
5658 | const char *num_str, | |
5659 | const char *threshold_str, int warning, | |
5660 | const char *restart_str) | |
718e3744 | 5661 | { |
d62a17ae | 5662 | int ret; |
5663 | struct peer *peer; | |
5664 | u_int32_t max; | |
5665 | u_char threshold; | |
5666 | u_int16_t restart; | |
718e3744 | 5667 | |
d62a17ae | 5668 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5669 | if (!peer) | |
5670 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5671 | |
d62a17ae | 5672 | max = strtoul(num_str, NULL, 10); |
5673 | if (threshold_str) | |
5674 | threshold = atoi(threshold_str); | |
5675 | else | |
5676 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5677 | |
d62a17ae | 5678 | if (restart_str) |
5679 | restart = atoi(restart_str); | |
5680 | else | |
5681 | restart = 0; | |
0a486e5f | 5682 | |
d62a17ae | 5683 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
5684 | restart); | |
718e3744 | 5685 | |
d62a17ae | 5686 | return bgp_vty_return(vty, ret); |
718e3744 | 5687 | } |
5688 | ||
d62a17ae | 5689 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
5690 | afi_t afi, safi_t safi) | |
718e3744 | 5691 | { |
d62a17ae | 5692 | int ret; |
5693 | struct peer *peer; | |
718e3744 | 5694 | |
d62a17ae | 5695 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5696 | if (!peer) | |
5697 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5698 | |
d62a17ae | 5699 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 5700 | |
d62a17ae | 5701 | return bgp_vty_return(vty, ret); |
718e3744 | 5702 | } |
5703 | ||
5704 | /* Maximum number of prefix configuration. prefix count is different | |
5705 | for each peer configuration. So this configuration can be set for | |
5706 | each peer configuration. */ | |
5707 | DEFUN (neighbor_maximum_prefix, | |
5708 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5709 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5710 | NEIGHBOR_STR |
5711 | NEIGHBOR_ADDR_STR2 | |
5712 | "Maximum number of prefix accept from this peer\n" | |
5713 | "maximum no. of prefix limit\n") | |
5714 | { | |
d62a17ae | 5715 | int idx_peer = 1; |
5716 | int idx_number = 3; | |
5717 | return peer_maximum_prefix_set_vty( | |
5718 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5719 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 5720 | } |
5721 | ||
d62a17ae | 5722 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
5723 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
5724 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5725 | "Maximum number of prefix accept from this peer\n" | |
5726 | "maximum no. of prefix limit\n") | |
596c17ba | 5727 | |
e0701b79 | 5728 | DEFUN (neighbor_maximum_prefix_threshold, |
5729 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5730 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5731 | NEIGHBOR_STR |
5732 | NEIGHBOR_ADDR_STR2 | |
5733 | "Maximum number of prefix accept from this peer\n" | |
5734 | "maximum no. of prefix limit\n" | |
5735 | "Threshold value (%) at which to generate a warning msg\n") | |
5736 | { | |
d62a17ae | 5737 | int idx_peer = 1; |
5738 | int idx_number = 3; | |
5739 | int idx_number_2 = 4; | |
5740 | return peer_maximum_prefix_set_vty( | |
5741 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5742 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 5743 | } |
e0701b79 | 5744 | |
d62a17ae | 5745 | ALIAS_HIDDEN( |
5746 | neighbor_maximum_prefix_threshold, | |
5747 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
5748 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
5749 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5750 | "Maximum number of prefix accept from this peer\n" | |
5751 | "maximum no. of prefix limit\n" | |
5752 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 5753 | |
718e3744 | 5754 | DEFUN (neighbor_maximum_prefix_warning, |
5755 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5756 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5757 | NEIGHBOR_STR |
5758 | NEIGHBOR_ADDR_STR2 | |
5759 | "Maximum number of prefix accept from this peer\n" | |
5760 | "maximum no. of prefix limit\n" | |
5761 | "Only give warning message when limit is exceeded\n") | |
5762 | { | |
d62a17ae | 5763 | int idx_peer = 1; |
5764 | int idx_number = 3; | |
5765 | return peer_maximum_prefix_set_vty( | |
5766 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5767 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 5768 | } |
5769 | ||
d62a17ae | 5770 | ALIAS_HIDDEN( |
5771 | neighbor_maximum_prefix_warning, | |
5772 | neighbor_maximum_prefix_warning_hidden_cmd, | |
5773 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
5774 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5775 | "Maximum number of prefix accept from this peer\n" | |
5776 | "maximum no. of prefix limit\n" | |
5777 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5778 | |
e0701b79 | 5779 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5780 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5781 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5782 | NEIGHBOR_STR |
5783 | NEIGHBOR_ADDR_STR2 | |
5784 | "Maximum number of prefix accept from this peer\n" | |
5785 | "maximum no. of prefix limit\n" | |
5786 | "Threshold value (%) at which to generate a warning msg\n" | |
5787 | "Only give warning message when limit is exceeded\n") | |
5788 | { | |
d62a17ae | 5789 | int idx_peer = 1; |
5790 | int idx_number = 3; | |
5791 | int idx_number_2 = 4; | |
5792 | return peer_maximum_prefix_set_vty( | |
5793 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5794 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5795 | } |
5796 | ||
d62a17ae | 5797 | ALIAS_HIDDEN( |
5798 | neighbor_maximum_prefix_threshold_warning, | |
5799 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
5800 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
5801 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5802 | "Maximum number of prefix accept from this peer\n" | |
5803 | "maximum no. of prefix limit\n" | |
5804 | "Threshold value (%) at which to generate a warning msg\n" | |
5805 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5806 | |
0a486e5f | 5807 | DEFUN (neighbor_maximum_prefix_restart, |
5808 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5809 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 5810 | NEIGHBOR_STR |
5811 | NEIGHBOR_ADDR_STR2 | |
5812 | "Maximum number of prefix accept from this peer\n" | |
5813 | "maximum no. of prefix limit\n" | |
5814 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 5815 | "Restart interval in minutes\n") |
0a486e5f | 5816 | { |
d62a17ae | 5817 | int idx_peer = 1; |
5818 | int idx_number = 3; | |
5819 | int idx_number_2 = 5; | |
5820 | return peer_maximum_prefix_set_vty( | |
5821 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5822 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 5823 | } |
5824 | ||
d62a17ae | 5825 | ALIAS_HIDDEN( |
5826 | neighbor_maximum_prefix_restart, | |
5827 | neighbor_maximum_prefix_restart_hidden_cmd, | |
5828 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
5829 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5830 | "Maximum number of prefix accept from this peer\n" | |
5831 | "maximum no. of prefix limit\n" | |
5832 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 5833 | "Restart interval in minutes\n") |
596c17ba | 5834 | |
0a486e5f | 5835 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
5836 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 5837 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 5838 | NEIGHBOR_STR |
5839 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5840 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 5841 | "maximum no. of prefix limit\n" |
5842 | "Threshold value (%) at which to generate a warning msg\n" | |
5843 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5844 | "Restart interval in minutes\n") |
0a486e5f | 5845 | { |
d62a17ae | 5846 | int idx_peer = 1; |
5847 | int idx_number = 3; | |
5848 | int idx_number_2 = 4; | |
5849 | int idx_number_3 = 6; | |
5850 | return peer_maximum_prefix_set_vty( | |
5851 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5852 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
5853 | argv[idx_number_3]->arg); | |
5854 | } | |
5855 | ||
5856 | ALIAS_HIDDEN( | |
5857 | neighbor_maximum_prefix_threshold_restart, | |
5858 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
5859 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
5860 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5861 | "Maximum number of prefixes to accept from this peer\n" | |
5862 | "maximum no. of prefix limit\n" | |
5863 | "Threshold value (%) at which to generate a warning msg\n" | |
5864 | "Restart bgp connection after limit is exceeded\n" | |
5865 | "Restart interval in minutes\n") | |
596c17ba | 5866 | |
718e3744 | 5867 | DEFUN (no_neighbor_maximum_prefix, |
5868 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 5869 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 5870 | NO_STR |
5871 | NEIGHBOR_STR | |
5872 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5873 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
5874 | "maximum no. of prefix limit\n" |
5875 | "Threshold value (%) at which to generate a warning msg\n" | |
5876 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5877 | "Restart interval in minutes\n" |
31500417 | 5878 | "Only give warning message when limit is exceeded\n") |
718e3744 | 5879 | { |
d62a17ae | 5880 | int idx_peer = 2; |
5881 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
5882 | bgp_node_afi(vty), | |
5883 | bgp_node_safi(vty)); | |
718e3744 | 5884 | } |
e52702f2 | 5885 | |
d62a17ae | 5886 | ALIAS_HIDDEN( |
5887 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
5888 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
5889 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5890 | "Maximum number of prefixes to accept from this peer\n" | |
5891 | "maximum no. of prefix limit\n" | |
5892 | "Threshold value (%) at which to generate a warning msg\n" | |
5893 | "Restart bgp connection after limit is exceeded\n" | |
5894 | "Restart interval in minutes\n" | |
5895 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5896 | |
718e3744 | 5897 | |
718e3744 | 5898 | /* "neighbor allowas-in" */ |
5899 | DEFUN (neighbor_allowas_in, | |
5900 | neighbor_allowas_in_cmd, | |
fd8503f5 | 5901 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5902 | NEIGHBOR_STR |
5903 | NEIGHBOR_ADDR_STR2 | |
31500417 | 5904 | "Accept as-path with my AS present in it\n" |
fd8503f5 QY |
5905 | "Number of occurances of AS number\n" |
5906 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5907 | { |
d62a17ae | 5908 | int idx_peer = 1; |
5909 | int idx_number_origin = 3; | |
5910 | int ret; | |
5911 | int origin = 0; | |
5912 | struct peer *peer; | |
5913 | int allow_num = 0; | |
5914 | ||
5915 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5916 | if (!peer) | |
5917 | return CMD_WARNING_CONFIG_FAILED; | |
5918 | ||
5919 | if (argc <= idx_number_origin) | |
5920 | allow_num = 3; | |
5921 | else { | |
5922 | if (argv[idx_number_origin]->type == WORD_TKN) | |
5923 | origin = 1; | |
5924 | else | |
5925 | allow_num = atoi(argv[idx_number_origin]->arg); | |
5926 | } | |
5927 | ||
5928 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5929 | allow_num, origin); | |
5930 | ||
5931 | return bgp_vty_return(vty, ret); | |
5932 | } | |
5933 | ||
5934 | ALIAS_HIDDEN( | |
5935 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
5936 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
5937 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5938 | "Accept as-path with my AS present in it\n" | |
5939 | "Number of occurances of AS number\n" | |
5940 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
596c17ba | 5941 | |
718e3744 | 5942 | DEFUN (no_neighbor_allowas_in, |
5943 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 5944 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5945 | NO_STR |
5946 | NEIGHBOR_STR | |
5947 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 5948 | "allow local ASN appears in aspath attribute\n" |
fd8503f5 QY |
5949 | "Number of occurances of AS number\n" |
5950 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5951 | { |
d62a17ae | 5952 | int idx_peer = 2; |
5953 | int ret; | |
5954 | struct peer *peer; | |
718e3744 | 5955 | |
d62a17ae | 5956 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5957 | if (!peer) | |
5958 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5959 | |
d62a17ae | 5960 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
5961 | bgp_node_safi(vty)); | |
718e3744 | 5962 | |
d62a17ae | 5963 | return bgp_vty_return(vty, ret); |
718e3744 | 5964 | } |
6b0655a2 | 5965 | |
d62a17ae | 5966 | ALIAS_HIDDEN( |
5967 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
5968 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
5969 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5970 | "allow local ASN appears in aspath attribute\n" | |
5971 | "Number of occurances of AS number\n" | |
5972 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
596c17ba | 5973 | |
fa411a21 NH |
5974 | DEFUN (neighbor_ttl_security, |
5975 | neighbor_ttl_security_cmd, | |
7ebe625c | 5976 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 5977 | NEIGHBOR_STR |
7ebe625c | 5978 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 5979 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
5980 | "Specify the maximum number of hops to the BGP peer\n" |
5981 | "Number of hops to BGP peer\n") | |
fa411a21 | 5982 | { |
d62a17ae | 5983 | int idx_peer = 1; |
5984 | int idx_number = 4; | |
5985 | struct peer *peer; | |
5986 | int gtsm_hops; | |
5987 | ||
5988 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5989 | if (!peer) | |
5990 | return CMD_WARNING_CONFIG_FAILED; | |
5991 | ||
5992 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
5993 | ||
7ebe625c QY |
5994 | /* |
5995 | * If 'neighbor swpX', then this is for directly connected peers, | |
5996 | * we should not accept a ttl-security hops value greater than 1. | |
5997 | */ | |
5998 | if (peer->conf_if && (gtsm_hops > 1)) { | |
5999 | vty_out(vty, | |
6000 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6001 | argv[idx_peer]->arg); | |
6002 | return CMD_WARNING_CONFIG_FAILED; | |
6003 | } | |
6004 | ||
d62a17ae | 6005 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6006 | } |
6007 | ||
6008 | DEFUN (no_neighbor_ttl_security, | |
6009 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6010 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6011 | NO_STR |
6012 | NEIGHBOR_STR | |
7ebe625c | 6013 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6014 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6015 | "Specify the maximum number of hops to the BGP peer\n" |
6016 | "Number of hops to BGP peer\n") | |
fa411a21 | 6017 | { |
d62a17ae | 6018 | int idx_peer = 2; |
6019 | struct peer *peer; | |
fa411a21 | 6020 | |
d62a17ae | 6021 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6022 | if (!peer) | |
6023 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6024 | |
d62a17ae | 6025 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6026 | } |
6b0655a2 | 6027 | |
adbac85e DW |
6028 | DEFUN (neighbor_addpath_tx_all_paths, |
6029 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6030 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6031 | NEIGHBOR_STR |
6032 | NEIGHBOR_ADDR_STR2 | |
6033 | "Use addpath to advertise all paths to a neighbor\n") | |
6034 | { | |
d62a17ae | 6035 | int idx_peer = 1; |
6036 | struct peer *peer; | |
adbac85e | 6037 | |
d62a17ae | 6038 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6039 | if (!peer) | |
6040 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6041 | |
d62a17ae | 6042 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6043 | bgp_node_safi(vty), | |
6044 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
adbac85e DW |
6045 | } |
6046 | ||
d62a17ae | 6047 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6048 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6049 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6050 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6051 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6052 | |
adbac85e DW |
6053 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6054 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6055 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6056 | NO_STR |
6057 | NEIGHBOR_STR | |
6058 | NEIGHBOR_ADDR_STR2 | |
6059 | "Use addpath to advertise all paths to a neighbor\n") | |
6060 | { | |
d62a17ae | 6061 | int idx_peer = 2; |
6062 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6063 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6064 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
adbac85e DW |
6065 | } |
6066 | ||
d62a17ae | 6067 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6068 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6069 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6070 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6071 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6072 | |
06370dac DW |
6073 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6074 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6075 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6076 | NEIGHBOR_STR |
6077 | NEIGHBOR_ADDR_STR2 | |
6078 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6079 | { | |
d62a17ae | 6080 | int idx_peer = 1; |
6081 | struct peer *peer; | |
06370dac | 6082 | |
d62a17ae | 6083 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6084 | if (!peer) | |
6085 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 6086 | |
d62a17ae | 6087 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6088 | bgp_node_safi(vty), | |
6089 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
06370dac DW |
6090 | } |
6091 | ||
d62a17ae | 6092 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
6093 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6094 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6095 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6096 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6097 | |
06370dac DW |
6098 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
6099 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6100 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6101 | NO_STR |
6102 | NEIGHBOR_STR | |
6103 | NEIGHBOR_ADDR_STR2 | |
6104 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6105 | { | |
d62a17ae | 6106 | int idx_peer = 2; |
6107 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6108 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6109 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
06370dac DW |
6110 | } |
6111 | ||
d62a17ae | 6112 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
6113 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6114 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6115 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6116 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6117 | |
505e5056 | 6118 | DEFUN_NOSH (address_family_ipv4_safi, |
718e3744 | 6119 | address_family_ipv4_safi_cmd, |
5b1f0f29 | 6120 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast>]", |
718e3744 | 6121 | "Enter Address Family command mode\n" |
8c3deaae | 6122 | "Address Family\n" |
b6ab5a3a | 6123 | BGP_SAFI_WITH_LABEL_HELP_STR) |
718e3744 | 6124 | { |
f51bae9c | 6125 | |
d62a17ae | 6126 | if (argc == 3) { |
2131d5cf | 6127 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 6128 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
6129 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
6130 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 6131 | && safi != SAFI_EVPN) { |
31947174 MK |
6132 | vty_out(vty, |
6133 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
6134 | return CMD_WARNING_CONFIG_FAILED; |
6135 | } | |
d62a17ae | 6136 | vty->node = bgp_node_type(AFI_IP, safi); |
6137 | } else | |
6138 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 6139 | |
d62a17ae | 6140 | return CMD_SUCCESS; |
718e3744 | 6141 | } |
6142 | ||
505e5056 | 6143 | DEFUN_NOSH (address_family_ipv6_safi, |
25ffbdc1 | 6144 | address_family_ipv6_safi_cmd, |
5b1f0f29 | 6145 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast>]", |
718e3744 | 6146 | "Enter Address Family command mode\n" |
8c3deaae | 6147 | "Address Family\n" |
b6ab5a3a | 6148 | BGP_SAFI_WITH_LABEL_HELP_STR) |
25ffbdc1 | 6149 | { |
d62a17ae | 6150 | if (argc == 3) { |
2131d5cf | 6151 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 6152 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
6153 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
6154 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 6155 | && safi != SAFI_EVPN) { |
31947174 MK |
6156 | vty_out(vty, |
6157 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
6158 | return CMD_WARNING_CONFIG_FAILED; |
6159 | } | |
d62a17ae | 6160 | vty->node = bgp_node_type(AFI_IP6, safi); |
6161 | } else | |
6162 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 6163 | |
d62a17ae | 6164 | return CMD_SUCCESS; |
25ffbdc1 | 6165 | } |
718e3744 | 6166 | |
d6902373 | 6167 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 6168 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 6169 | address_family_vpnv4_cmd, |
8334fd5a | 6170 | "address-family vpnv4 [unicast]", |
718e3744 | 6171 | "Enter Address Family command mode\n" |
8c3deaae | 6172 | "Address Family\n" |
3a2d747c | 6173 | "Address Family modifier\n") |
718e3744 | 6174 | { |
d62a17ae | 6175 | vty->node = BGP_VPNV4_NODE; |
6176 | return CMD_SUCCESS; | |
718e3744 | 6177 | } |
6178 | ||
505e5056 | 6179 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 6180 | address_family_vpnv6_cmd, |
8334fd5a | 6181 | "address-family vpnv6 [unicast]", |
8ecd3266 | 6182 | "Enter Address Family command mode\n" |
8c3deaae | 6183 | "Address Family\n" |
3a2d747c | 6184 | "Address Family modifier\n") |
8ecd3266 | 6185 | { |
d62a17ae | 6186 | vty->node = BGP_VPNV6_NODE; |
6187 | return CMD_SUCCESS; | |
8ecd3266 | 6188 | } |
c016b6c7 | 6189 | #endif |
d6902373 | 6190 | |
505e5056 | 6191 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 6192 | address_family_evpn_cmd, |
7111c1a0 | 6193 | "address-family l2vpn evpn", |
4e0b7b6d | 6194 | "Enter Address Family command mode\n" |
7111c1a0 QY |
6195 | "Address Family\n" |
6196 | "Address Family modifier\n") | |
4e0b7b6d | 6197 | { |
2131d5cf | 6198 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 6199 | vty->node = BGP_EVPN_NODE; |
6200 | return CMD_SUCCESS; | |
4e0b7b6d PG |
6201 | } |
6202 | ||
505e5056 | 6203 | DEFUN_NOSH (exit_address_family, |
718e3744 | 6204 | exit_address_family_cmd, |
6205 | "exit-address-family", | |
6206 | "Exit from Address Family configuration mode\n") | |
6207 | { | |
d62a17ae | 6208 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
6209 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
6210 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
6211 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
6212 | || vty->node == BGP_EVPN_NODE) | |
6213 | vty->node = BGP_NODE; | |
6214 | return CMD_SUCCESS; | |
718e3744 | 6215 | } |
6b0655a2 | 6216 | |
8ad7271d | 6217 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 6218 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
6219 | const char *ip_str, afi_t afi, safi_t safi, | |
6220 | struct prefix_rd *prd) | |
6221 | { | |
6222 | int ret; | |
6223 | struct prefix match; | |
6224 | struct bgp_node *rn; | |
6225 | struct bgp_node *rm; | |
6226 | struct bgp *bgp; | |
6227 | struct bgp_table *table; | |
6228 | struct bgp_table *rib; | |
6229 | ||
6230 | /* BGP structure lookup. */ | |
6231 | if (view_name) { | |
6232 | bgp = bgp_lookup_by_name(view_name); | |
6233 | if (bgp == NULL) { | |
6234 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
6235 | view_name); | |
6236 | return CMD_WARNING; | |
6237 | } | |
6238 | } else { | |
6239 | bgp = bgp_get_default(); | |
6240 | if (bgp == NULL) { | |
6241 | vty_out(vty, "%% No BGP process is configured\n"); | |
6242 | return CMD_WARNING; | |
6243 | } | |
6244 | } | |
6245 | ||
6246 | /* Check IP address argument. */ | |
6247 | ret = str2prefix(ip_str, &match); | |
6248 | if (!ret) { | |
6249 | vty_out(vty, "%% address is malformed\n"); | |
6250 | return CMD_WARNING; | |
6251 | } | |
6252 | ||
6253 | match.family = afi2family(afi); | |
6254 | rib = bgp->rib[afi][safi]; | |
6255 | ||
6256 | if (safi == SAFI_MPLS_VPN) { | |
6257 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
6258 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
6259 | continue; | |
6260 | ||
6261 | if ((table = rn->info) != NULL) { | |
6262 | if ((rm = bgp_node_match(table, &match)) | |
6263 | != NULL) { | |
6264 | if (rm->p.prefixlen | |
6265 | == match.prefixlen) { | |
6266 | SET_FLAG(rn->flags, | |
6267 | BGP_NODE_USER_CLEAR); | |
6268 | bgp_process(bgp, rm, afi, safi); | |
6269 | } | |
6270 | bgp_unlock_node(rm); | |
6271 | } | |
6272 | } | |
6273 | } | |
6274 | } else { | |
6275 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
6276 | if (rn->p.prefixlen == match.prefixlen) { | |
6277 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
6278 | bgp_process(bgp, rn, afi, safi); | |
6279 | } | |
6280 | bgp_unlock_node(rn); | |
6281 | } | |
6282 | } | |
6283 | ||
6284 | return CMD_SUCCESS; | |
8ad7271d DS |
6285 | } |
6286 | ||
b09b5ae0 | 6287 | /* one clear bgp command to rule them all */ |
718e3744 | 6288 | DEFUN (clear_ip_bgp_all, |
6289 | clear_ip_bgp_all_cmd, | |
c1a44e43 | 6290 | "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 | 6291 | CLEAR_STR |
6292 | IP_STR | |
6293 | BGP_STR | |
838758ac | 6294 | BGP_INSTANCE_HELP_STR |
510afcd6 DS |
6295 | BGP_AFI_HELP_STR |
6296 | BGP_SAFI_WITH_LABEL_HELP_STR | |
b09b5ae0 DW |
6297 | "Clear all peers\n" |
6298 | "BGP neighbor address to clear\n" | |
a80beece | 6299 | "BGP IPv6 neighbor to clear\n" |
838758ac | 6300 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
6301 | "Clear peers with the AS number\n" |
6302 | "Clear all external peers\n" | |
718e3744 | 6303 | "Clear all members of peer-group\n" |
b09b5ae0 | 6304 | "BGP peer-group name\n" |
b09b5ae0 DW |
6305 | BGP_SOFT_STR |
6306 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
6307 | BGP_SOFT_OUT_STR |
6308 | BGP_SOFT_IN_STR | |
6309 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 6310 | BGP_SOFT_OUT_STR) |
718e3744 | 6311 | { |
d62a17ae | 6312 | char *vrf = NULL; |
6313 | ||
6314 | afi_t afi = AFI_IP6; | |
6315 | safi_t safi = SAFI_UNICAST; | |
6316 | enum clear_sort clr_sort = clear_peer; | |
6317 | enum bgp_clear_type clr_type; | |
6318 | char *clr_arg = NULL; | |
6319 | ||
6320 | int idx = 0; | |
6321 | ||
6322 | /* clear [ip] bgp */ | |
6323 | if (argv_find(argv, argc, "ip", &idx)) | |
6324 | afi = AFI_IP; | |
6325 | ||
6326 | /* [<view|vrf> VIEWVRFNAME] */ | |
6327 | if (argv_find(argv, argc, "view", &idx) | |
6328 | || argv_find(argv, argc, "vrf", &idx)) { | |
6329 | vrf = argv[idx + 1]->arg; | |
6330 | idx += 2; | |
6331 | } | |
6332 | ||
6333 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
6334 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
6335 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
6336 | ||
6337 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ | |
6338 | if (argv_find(argv, argc, "*", &idx)) { | |
6339 | clr_sort = clear_all; | |
6340 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
6341 | clr_sort = clear_peer; | |
6342 | clr_arg = argv[idx]->arg; | |
6343 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
6344 | clr_sort = clear_peer; | |
6345 | clr_arg = argv[idx]->arg; | |
6346 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
6347 | clr_sort = clear_group; | |
6348 | idx++; | |
6349 | clr_arg = argv[idx]->arg; | |
6350 | } else if (argv_find(argv, argc, "WORD", &idx)) { | |
6351 | clr_sort = clear_peer; | |
6352 | clr_arg = argv[idx]->arg; | |
6353 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { | |
6354 | clr_sort = clear_as; | |
6355 | clr_arg = argv[idx]->arg; | |
6356 | } else if (argv_find(argv, argc, "external", &idx)) { | |
6357 | clr_sort = clear_external; | |
6358 | } | |
6359 | ||
6360 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
6361 | if (argv_find(argv, argc, "soft", &idx)) { | |
6362 | if (argv_find(argv, argc, "in", &idx) | |
6363 | || argv_find(argv, argc, "out", &idx)) | |
6364 | clr_type = strmatch(argv[idx]->text, "in") | |
6365 | ? BGP_CLEAR_SOFT_IN | |
6366 | : BGP_CLEAR_SOFT_OUT; | |
6367 | else | |
6368 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
6369 | } else if (argv_find(argv, argc, "in", &idx)) { | |
6370 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
6371 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
6372 | : BGP_CLEAR_SOFT_IN; | |
6373 | } else if (argv_find(argv, argc, "out", &idx)) { | |
6374 | clr_type = BGP_CLEAR_SOFT_OUT; | |
6375 | } else | |
6376 | clr_type = BGP_CLEAR_SOFT_NONE; | |
6377 | ||
6378 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 6379 | } |
01080f7c | 6380 | |
8ad7271d DS |
6381 | DEFUN (clear_ip_bgp_prefix, |
6382 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 6383 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
6384 | CLEAR_STR |
6385 | IP_STR | |
6386 | BGP_STR | |
838758ac | 6387 | BGP_INSTANCE_HELP_STR |
8ad7271d | 6388 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6389 | "IPv4 prefix\n") |
8ad7271d | 6390 | { |
d62a17ae | 6391 | char *vrf = NULL; |
6392 | char *prefix = NULL; | |
8ad7271d | 6393 | |
d62a17ae | 6394 | int idx = 0; |
01080f7c | 6395 | |
d62a17ae | 6396 | /* [<view|vrf> VIEWVRFNAME] */ |
1d35f218 | 6397 | if (argv_find(argv, argc, "VIEWVRFNAME", &idx)) |
d62a17ae | 6398 | vrf = argv[idx]->arg; |
0c7b1b01 | 6399 | |
d62a17ae | 6400 | prefix = argv[argc - 1]->arg; |
8ad7271d | 6401 | |
d62a17ae | 6402 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 6403 | } |
8ad7271d | 6404 | |
b09b5ae0 DW |
6405 | DEFUN (clear_bgp_ipv6_safi_prefix, |
6406 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 6407 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6408 | CLEAR_STR |
3a2d747c | 6409 | IP_STR |
718e3744 | 6410 | BGP_STR |
8c3deaae | 6411 | "Address Family\n" |
46f296b4 | 6412 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6413 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6414 | "IPv6 prefix\n") |
718e3744 | 6415 | { |
d62a17ae | 6416 | int idx_safi = 3; |
6417 | int idx_ipv6_prefixlen = 5; | |
6418 | return bgp_clear_prefix( | |
6419 | vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, | |
6420 | bgp_vty_safi_from_str(argv[idx_safi]->text), NULL); | |
838758ac | 6421 | } |
01080f7c | 6422 | |
b09b5ae0 DW |
6423 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
6424 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 6425 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6426 | CLEAR_STR |
3a2d747c | 6427 | IP_STR |
718e3744 | 6428 | BGP_STR |
838758ac | 6429 | BGP_INSTANCE_HELP_STR |
8c3deaae | 6430 | "Address Family\n" |
46f296b4 | 6431 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6432 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6433 | "IPv6 prefix\n") |
718e3744 | 6434 | { |
d62a17ae | 6435 | int idx_word = 3; |
6436 | int idx_safi = 5; | |
6437 | int idx_ipv6_prefixlen = 7; | |
6438 | return bgp_clear_prefix( | |
6439 | vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, | |
6440 | AFI_IP6, bgp_vty_safi_from_str(argv[idx_safi]->text), NULL); | |
718e3744 | 6441 | } |
6442 | ||
b09b5ae0 DW |
6443 | DEFUN (show_bgp_views, |
6444 | show_bgp_views_cmd, | |
d6e3c605 | 6445 | "show [ip] bgp views", |
b09b5ae0 | 6446 | SHOW_STR |
d6e3c605 | 6447 | IP_STR |
01080f7c | 6448 | BGP_STR |
b09b5ae0 | 6449 | "Show the defined BGP views\n") |
01080f7c | 6450 | { |
d62a17ae | 6451 | struct list *inst = bm->bgp; |
6452 | struct listnode *node; | |
6453 | struct bgp *bgp; | |
01080f7c | 6454 | |
d62a17ae | 6455 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { |
6456 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
6457 | return CMD_WARNING; | |
6458 | } | |
e52702f2 | 6459 | |
d62a17ae | 6460 | vty_out(vty, "Defined BGP views:\n"); |
6461 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
6462 | /* Skip VRFs. */ | |
6463 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
6464 | continue; | |
6465 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
6466 | bgp->as); | |
6467 | } | |
e52702f2 | 6468 | |
d62a17ae | 6469 | return CMD_SUCCESS; |
e0081f70 ML |
6470 | } |
6471 | ||
8386ac43 | 6472 | DEFUN (show_bgp_vrfs, |
6473 | show_bgp_vrfs_cmd, | |
d6e3c605 | 6474 | "show [ip] bgp vrfs [json]", |
8386ac43 | 6475 | SHOW_STR |
d6e3c605 | 6476 | IP_STR |
8386ac43 | 6477 | BGP_STR |
6478 | "Show BGP VRFs\n" | |
9973d184 | 6479 | JSON_STR) |
8386ac43 | 6480 | { |
fe1dc5a3 | 6481 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 6482 | struct list *inst = bm->bgp; |
6483 | struct listnode *node; | |
6484 | struct bgp *bgp; | |
6485 | u_char uj = use_json(argc, argv); | |
6486 | json_object *json = NULL; | |
6487 | json_object *json_vrfs = NULL; | |
6488 | int count = 0; | |
d62a17ae | 6489 | |
6490 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { | |
6491 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
6492 | return CMD_WARNING; | |
6493 | } | |
6494 | ||
6495 | if (uj) { | |
6496 | json = json_object_new_object(); | |
6497 | json_vrfs = json_object_new_object(); | |
6498 | } | |
6499 | ||
6500 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
6501 | const char *name, *type; | |
6502 | struct peer *peer; | |
6503 | struct listnode *node, *nnode; | |
6504 | int peers_cfg, peers_estb; | |
6505 | json_object *json_vrf = NULL; | |
d62a17ae | 6506 | |
6507 | /* Skip Views. */ | |
6508 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
6509 | continue; | |
6510 | ||
6511 | count++; | |
6512 | if (!uj && count == 1) | |
fe1dc5a3 MK |
6513 | vty_out(vty, |
6514 | "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n", | |
a4d82a8a PZ |
6515 | "Type", "Id", "routerId", "#PeersVfg", |
6516 | "#PeersEstb", "Name", "L3-VNI", "Rmac"); | |
d62a17ae | 6517 | |
6518 | peers_cfg = peers_estb = 0; | |
6519 | if (uj) | |
6520 | json_vrf = json_object_new_object(); | |
6521 | ||
6522 | ||
6523 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
6524 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6525 | continue; | |
6526 | peers_cfg++; | |
6527 | if (peer->status == Established) | |
6528 | peers_estb++; | |
6529 | } | |
6530 | ||
6531 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
6532 | name = "Default"; | |
6533 | type = "DFLT"; | |
6534 | } else { | |
6535 | name = bgp->name; | |
6536 | type = "VRF"; | |
6537 | } | |
6538 | ||
a8bf7d9c | 6539 | |
d62a17ae | 6540 | if (uj) { |
a4d82a8a PZ |
6541 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
6542 | ? -1 | |
6543 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 6544 | json_object_string_add(json_vrf, "type", type); |
6545 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
6546 | json_object_string_add(json_vrf, "routerId", | |
6547 | inet_ntoa(bgp->router_id)); | |
6548 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
6549 | peers_cfg); | |
6550 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
6551 | peers_estb); | |
6552 | ||
fe1dc5a3 | 6553 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
6554 | json_object_string_add( |
6555 | json_vrf, "rmac", | |
6556 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
d62a17ae | 6557 | json_object_object_add(json_vrfs, name, json_vrf); |
6558 | } else | |
fe1dc5a3 MK |
6559 | vty_out(vty, |
6560 | "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n", | |
a4d82a8a PZ |
6561 | type, |
6562 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
6563 | : (int)bgp->vrf_id, | |
6564 | inet_ntoa(bgp->router_id), peers_cfg, | |
6565 | peers_estb, name, bgp->l3vni, | |
fe1dc5a3 | 6566 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); |
d62a17ae | 6567 | } |
6568 | ||
6569 | if (uj) { | |
6570 | json_object_object_add(json, "vrfs", json_vrfs); | |
6571 | ||
6572 | json_object_int_add(json, "totalVrfs", count); | |
6573 | ||
a4d82a8a PZ |
6574 | vty_out(vty, "%s\n", |
6575 | json_object_to_json_string_ext( | |
6576 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 6577 | json_object_free(json); |
6578 | } else { | |
6579 | if (count) | |
6580 | vty_out(vty, | |
6581 | "\nTotal number of VRFs (including default): %d\n", | |
6582 | count); | |
6583 | } | |
6584 | ||
6585 | return CMD_SUCCESS; | |
8386ac43 | 6586 | } |
6587 | ||
acf71666 MK |
6588 | static void show_address_entry(struct hash_backet *backet, void *args) |
6589 | { | |
60466a63 QY |
6590 | struct vty *vty = (struct vty *)args; |
6591 | struct bgp_addr *addr = (struct bgp_addr *)backet->data; | |
acf71666 | 6592 | |
60466a63 | 6593 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(addr->addr), |
acf71666 MK |
6594 | addr->refcnt); |
6595 | } | |
6596 | ||
6597 | static void show_tip_entry(struct hash_backet *backet, void *args) | |
6598 | { | |
0291c246 | 6599 | struct vty *vty = (struct vty *)args; |
60466a63 | 6600 | struct tip_addr *tip = (struct tip_addr *)backet->data; |
acf71666 | 6601 | |
60466a63 | 6602 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
6603 | tip->refcnt); |
6604 | } | |
6605 | ||
6606 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
6607 | { | |
6608 | vty_out(vty, "self nexthop database:\n"); | |
6609 | hash_iterate(bgp->address_hash, | |
6610 | (void (*)(struct hash_backet *, void *))show_address_entry, | |
6611 | vty); | |
6612 | ||
6613 | vty_out(vty, "Tunnel-ip database:\n"); | |
6614 | hash_iterate(bgp->tip_hash, | |
6615 | (void (*)(struct hash_backet *, void *))show_tip_entry, | |
6616 | vty); | |
6617 | } | |
6618 | ||
15c81ca4 DS |
6619 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
6620 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
6621 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
6622 | "martian next-hops\n" |
6623 | "martian next-hop database\n") | |
acf71666 | 6624 | { |
0291c246 | 6625 | struct bgp *bgp = NULL; |
15c81ca4 DS |
6626 | int idx = 0; |
6627 | ||
6628 | if (argv_find(argv, argc, "view", &idx) | |
6629 | || argv_find(argv, argc, "vrf", &idx)) | |
6630 | bgp = bgp_lookup_by_name(argv[idx + 1]->arg); | |
6631 | else | |
6632 | bgp = bgp_get_default(); | |
acf71666 | 6633 | |
acf71666 MK |
6634 | if (!bgp) { |
6635 | vty_out(vty, "%% No BGP process is configured\n"); | |
6636 | return CMD_WARNING; | |
6637 | } | |
6638 | bgp_show_martian_nexthops(vty, bgp); | |
6639 | ||
6640 | return CMD_SUCCESS; | |
6641 | } | |
6642 | ||
f412b39a | 6643 | DEFUN (show_bgp_memory, |
4bf6a362 | 6644 | show_bgp_memory_cmd, |
7fa12b13 | 6645 | "show [ip] bgp memory", |
4bf6a362 | 6646 | SHOW_STR |
3a2d747c | 6647 | IP_STR |
4bf6a362 PJ |
6648 | BGP_STR |
6649 | "Global BGP memory statistics\n") | |
6650 | { | |
d62a17ae | 6651 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
6652 | unsigned long count; | |
6653 | ||
6654 | /* RIB related usage stats */ | |
6655 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
6656 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
6657 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6658 | count * sizeof(struct bgp_node))); | |
6659 | ||
6660 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
6661 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
6662 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6663 | count * sizeof(struct bgp_info))); | |
6664 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) | |
6665 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
6666 | count, | |
6667 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6668 | count * sizeof(struct bgp_info_extra))); | |
6669 | ||
6670 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
6671 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
6672 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6673 | count * sizeof(struct bgp_static))); | |
6674 | ||
6675 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
6676 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
6677 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6678 | count * sizeof(struct bpacket))); | |
6679 | ||
6680 | /* Adj-In/Out */ | |
6681 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
6682 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
6683 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6684 | count * sizeof(struct bgp_adj_in))); | |
6685 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
6686 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
6687 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6688 | count * sizeof(struct bgp_adj_out))); | |
6689 | ||
6690 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
6691 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
6692 | count, | |
6693 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6694 | count * sizeof(struct bgp_nexthop_cache))); | |
6695 | ||
6696 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
6697 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
6698 | count, | |
6699 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6700 | count * sizeof(struct bgp_damp_info))); | |
6701 | ||
6702 | /* Attributes */ | |
6703 | count = attr_count(); | |
6704 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
6705 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6706 | count * sizeof(struct attr))); | |
6707 | ||
6708 | if ((count = attr_unknown_count())) | |
6709 | vty_out(vty, "%ld unknown attributes\n", count); | |
6710 | ||
6711 | /* AS_PATH attributes */ | |
6712 | count = aspath_count(); | |
6713 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
6714 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6715 | count * sizeof(struct aspath))); | |
6716 | ||
6717 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
6718 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
6719 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6720 | count * sizeof(struct assegment))); | |
6721 | ||
6722 | /* Other attributes */ | |
6723 | if ((count = community_count())) | |
6724 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
a4d82a8a PZ |
6725 | count, |
6726 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6727 | count * sizeof(struct community))); | |
d62a17ae | 6728 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
6729 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
a4d82a8a PZ |
6730 | count, |
6731 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6732 | count * sizeof(struct ecommunity))); | |
d62a17ae | 6733 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
6734 | vty_out(vty, | |
6735 | "%ld BGP large-community entries, using %s of memory\n", | |
a4d82a8a PZ |
6736 | count, |
6737 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6738 | count * sizeof(struct lcommunity))); | |
d62a17ae | 6739 | |
6740 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
6741 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
6742 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6743 | count * sizeof(struct cluster_list))); | |
6744 | ||
6745 | /* Peer related usage */ | |
6746 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
6747 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
6748 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6749 | count * sizeof(struct peer))); | |
6750 | ||
6751 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
6752 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
6753 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6754 | count * sizeof(struct peer_group))); | |
6755 | ||
6756 | /* Other */ | |
6757 | if ((count = mtype_stats_alloc(MTYPE_HASH))) | |
6758 | vty_out(vty, "%ld hash tables, using %s of memory\n", count, | |
6759 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6760 | count * sizeof(struct hash))); | |
6761 | if ((count = mtype_stats_alloc(MTYPE_HASH_BACKET))) | |
6762 | vty_out(vty, "%ld hash buckets, using %s of memory\n", count, | |
6763 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6764 | count * sizeof(struct hash_backet))); | |
6765 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) | |
6766 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
a4d82a8a PZ |
6767 | count, |
6768 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6769 | count * sizeof(regex_t))); | |
d62a17ae | 6770 | return CMD_SUCCESS; |
4bf6a362 | 6771 | } |
fee0f4c6 | 6772 | |
57a9c8a8 DS |
6773 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
6774 | { | |
6775 | json_object *bestpath = json_object_new_object(); | |
6776 | ||
6777 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
6778 | json_object_string_add(bestpath, "asPath", "ignore"); | |
6779 | ||
6780 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
6781 | json_object_string_add(bestpath, "asPath", "confed"); | |
6782 | ||
6783 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
a4d82a8a PZ |
6784 | if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) |
6785 | json_object_string_add(bestpath, "multiPathRelax", | |
57a9c8a8 DS |
6786 | "as-set"); |
6787 | else | |
a4d82a8a | 6788 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
6789 | "true"); |
6790 | } else | |
a4d82a8a | 6791 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 DS |
6792 | |
6793 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
6794 | json_object_string_add(bestpath, "compareRouterId", "true"); | |
6795 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
6796 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
6797 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 6798 | json_object_string_add(bestpath, "med", "confed"); |
57a9c8a8 DS |
6799 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
6800 | json_object_string_add(bestpath, "med", | |
6801 | "missing-as-worst"); | |
6802 | else | |
6803 | json_object_string_add(bestpath, "med", "true"); | |
6804 | } | |
6805 | ||
6806 | json_object_object_add(json, "bestPath", bestpath); | |
6807 | } | |
6808 | ||
718e3744 | 6809 | /* Show BGP peer's summary information. */ |
d62a17ae | 6810 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
6811 | u_char use_json, json_object *json) | |
6812 | { | |
6813 | struct peer *peer; | |
6814 | struct listnode *node, *nnode; | |
6815 | unsigned int count = 0, dn_count = 0; | |
6816 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
6817 | char neighbor_buf[VTY_BUFSIZ]; | |
6818 | int neighbor_col_default_width = 16; | |
6819 | int len; | |
6820 | int max_neighbor_width = 0; | |
6821 | int pfx_rcd_safi; | |
6822 | json_object *json_peer = NULL; | |
6823 | json_object *json_peers = NULL; | |
6824 | ||
6825 | /* labeled-unicast routes are installed in the unicast table so in order | |
6826 | * to | |
6827 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
6828 | */ | |
6829 | if (safi == SAFI_LABELED_UNICAST) | |
6830 | pfx_rcd_safi = SAFI_UNICAST; | |
6831 | else | |
6832 | pfx_rcd_safi = safi; | |
6833 | ||
6834 | if (use_json) { | |
6835 | if (json == NULL) | |
6836 | json = json_object_new_object(); | |
6837 | ||
6838 | json_peers = json_object_new_object(); | |
6839 | } else { | |
6840 | /* Loop over all neighbors that will be displayed to determine | |
6841 | * how many | |
6842 | * characters are needed for the Neighbor column | |
6843 | */ | |
6844 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
6845 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6846 | continue; | |
6847 | ||
6848 | if (peer->afc[afi][safi]) { | |
6849 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
6850 | if (peer_dynamic_neighbor(peer)) | |
6851 | dn_flag[0] = '*'; | |
6852 | ||
6853 | if (peer->hostname | |
6854 | && bgp_flag_check(bgp, | |
6855 | BGP_FLAG_SHOW_HOSTNAME)) | |
6856 | sprintf(neighbor_buf, "%s%s(%s) ", | |
6857 | dn_flag, peer->hostname, | |
6858 | peer->host); | |
6859 | else | |
6860 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
6861 | peer->host); | |
6862 | ||
6863 | len = strlen(neighbor_buf); | |
6864 | ||
6865 | if (len > max_neighbor_width) | |
6866 | max_neighbor_width = len; | |
6867 | } | |
6868 | } | |
f933309e | 6869 | |
d62a17ae | 6870 | /* Originally we displayed the Neighbor column as 16 |
6871 | * characters wide so make that the default | |
6872 | */ | |
6873 | if (max_neighbor_width < neighbor_col_default_width) | |
6874 | max_neighbor_width = neighbor_col_default_width; | |
6875 | } | |
f933309e | 6876 | |
d62a17ae | 6877 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
6878 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6879 | continue; | |
6880 | ||
ea47320b DL |
6881 | if (!peer->afc[afi][safi]) |
6882 | continue; | |
d62a17ae | 6883 | |
ea47320b DL |
6884 | if (!count) { |
6885 | unsigned long ents; | |
6886 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 6887 | int64_t vrf_id_ui; |
d62a17ae | 6888 | |
a4d82a8a PZ |
6889 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
6890 | ? -1 | |
6891 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
6892 | |
6893 | /* Usage summary and header */ | |
6894 | if (use_json) { | |
6895 | json_object_string_add( | |
6896 | json, "routerId", | |
6897 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
6898 | json_object_int_add(json, "as", bgp->as); |
6899 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
6900 | json_object_string_add( |
6901 | json, "vrfName", | |
6902 | (bgp->inst_type | |
6903 | == BGP_INSTANCE_TYPE_DEFAULT) | |
6904 | ? "Default" | |
6905 | : bgp->name); | |
6906 | } else { | |
6907 | vty_out(vty, | |
6908 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 6909 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
6910 | bgp->vrf_id == VRF_UNKNOWN |
6911 | ? -1 | |
6912 | : (int)bgp->vrf_id); | |
ea47320b DL |
6913 | vty_out(vty, "\n"); |
6914 | } | |
d62a17ae | 6915 | |
ea47320b | 6916 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 6917 | if (use_json) { |
ea47320b | 6918 | json_object_int_add( |
60466a63 | 6919 | json, "updateDelayLimit", |
ea47320b | 6920 | bgp->v_update_delay); |
d62a17ae | 6921 | |
ea47320b DL |
6922 | if (bgp->v_update_delay |
6923 | != bgp->v_establish_wait) | |
d62a17ae | 6924 | json_object_int_add( |
6925 | json, | |
ea47320b DL |
6926 | "updateDelayEstablishWait", |
6927 | bgp->v_establish_wait); | |
d62a17ae | 6928 | |
60466a63 | 6929 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
6930 | json_object_string_add( |
6931 | json, | |
6932 | "updateDelayFirstNeighbor", | |
6933 | bgp->update_delay_begin_time); | |
6934 | json_object_boolean_true_add( | |
6935 | json, | |
6936 | "updateDelayInProgress"); | |
6937 | } else { | |
6938 | if (bgp->update_delay_over) { | |
d62a17ae | 6939 | json_object_string_add( |
6940 | json, | |
6941 | "updateDelayFirstNeighbor", | |
6942 | bgp->update_delay_begin_time); | |
ea47320b | 6943 | json_object_string_add( |
d62a17ae | 6944 | json, |
ea47320b DL |
6945 | "updateDelayBestpathResumed", |
6946 | bgp->update_delay_end_time); | |
6947 | json_object_string_add( | |
d62a17ae | 6948 | json, |
ea47320b DL |
6949 | "updateDelayZebraUpdateResume", |
6950 | bgp->update_delay_zebra_resume_time); | |
6951 | json_object_string_add( | |
6952 | json, | |
6953 | "updateDelayPeerUpdateResume", | |
6954 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 6955 | } |
ea47320b DL |
6956 | } |
6957 | } else { | |
6958 | vty_out(vty, | |
6959 | "Read-only mode update-delay limit: %d seconds\n", | |
6960 | bgp->v_update_delay); | |
6961 | if (bgp->v_update_delay | |
6962 | != bgp->v_establish_wait) | |
d62a17ae | 6963 | vty_out(vty, |
ea47320b DL |
6964 | " Establish wait: %d seconds\n", |
6965 | bgp->v_establish_wait); | |
d62a17ae | 6966 | |
60466a63 | 6967 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
6968 | vty_out(vty, |
6969 | " First neighbor established: %s\n", | |
6970 | bgp->update_delay_begin_time); | |
6971 | vty_out(vty, | |
6972 | " Delay in progress\n"); | |
6973 | } else { | |
6974 | if (bgp->update_delay_over) { | |
d62a17ae | 6975 | vty_out(vty, |
6976 | " First neighbor established: %s\n", | |
6977 | bgp->update_delay_begin_time); | |
6978 | vty_out(vty, | |
ea47320b DL |
6979 | " Best-paths resumed: %s\n", |
6980 | bgp->update_delay_end_time); | |
6981 | vty_out(vty, | |
6982 | " zebra update resumed: %s\n", | |
6983 | bgp->update_delay_zebra_resume_time); | |
6984 | vty_out(vty, | |
6985 | " peers update resumed: %s\n", | |
6986 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 6987 | } |
6988 | } | |
6989 | } | |
ea47320b | 6990 | } |
d62a17ae | 6991 | |
ea47320b DL |
6992 | if (use_json) { |
6993 | if (bgp_maxmed_onstartup_configured(bgp) | |
6994 | && bgp->maxmed_active) | |
6995 | json_object_boolean_true_add( | |
60466a63 | 6996 | json, "maxMedOnStartup"); |
ea47320b DL |
6997 | if (bgp->v_maxmed_admin) |
6998 | json_object_boolean_true_add( | |
60466a63 | 6999 | json, "maxMedAdministrative"); |
d62a17ae | 7000 | |
ea47320b DL |
7001 | json_object_int_add( |
7002 | json, "tableVersion", | |
60466a63 | 7003 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 7004 | |
60466a63 QY |
7005 | ents = bgp_table_count(bgp->rib[afi][safi]); |
7006 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
7007 | json_object_int_add( |
7008 | json, "ribMemory", | |
7009 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 7010 | |
ea47320b | 7011 | ents = listcount(bgp->peer); |
60466a63 QY |
7012 | json_object_int_add(json, "peerCount", ents); |
7013 | json_object_int_add(json, "peerMemory", | |
7014 | ents * sizeof(struct peer)); | |
d62a17ae | 7015 | |
ea47320b DL |
7016 | if ((ents = listcount(bgp->group))) { |
7017 | json_object_int_add( | |
60466a63 | 7018 | json, "peerGroupCount", ents); |
ea47320b DL |
7019 | json_object_int_add( |
7020 | json, "peerGroupMemory", | |
a4d82a8a PZ |
7021 | ents |
7022 | * sizeof(struct | |
7023 | peer_group)); | |
ea47320b | 7024 | } |
d62a17ae | 7025 | |
ea47320b DL |
7026 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
7027 | BGP_CONFIG_DAMPENING)) | |
7028 | json_object_boolean_true_add( | |
60466a63 | 7029 | json, "dampeningEnabled"); |
ea47320b DL |
7030 | } else { |
7031 | if (bgp_maxmed_onstartup_configured(bgp) | |
7032 | && bgp->maxmed_active) | |
d62a17ae | 7033 | vty_out(vty, |
ea47320b DL |
7034 | "Max-med on-startup active\n"); |
7035 | if (bgp->v_maxmed_admin) | |
d62a17ae | 7036 | vty_out(vty, |
ea47320b | 7037 | "Max-med administrative active\n"); |
d62a17ae | 7038 | |
60466a63 QY |
7039 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
7040 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 7041 | |
60466a63 | 7042 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
7043 | vty_out(vty, |
7044 | "RIB entries %ld, using %s of memory\n", | |
7045 | ents, | |
a4d82a8a PZ |
7046 | mtype_memstr( |
7047 | memstrbuf, sizeof(memstrbuf), | |
7048 | ents | |
7049 | * sizeof(struct | |
7050 | bgp_node))); | |
ea47320b DL |
7051 | |
7052 | /* Peer related usage */ | |
7053 | ents = listcount(bgp->peer); | |
60466a63 | 7054 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
7055 | ents, |
7056 | mtype_memstr( | |
60466a63 QY |
7057 | memstrbuf, sizeof(memstrbuf), |
7058 | ents * sizeof(struct peer))); | |
ea47320b DL |
7059 | |
7060 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 7061 | vty_out(vty, |
ea47320b | 7062 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 7063 | ents, |
7064 | mtype_memstr( | |
7065 | memstrbuf, | |
7066 | sizeof(memstrbuf), | |
a4d82a8a PZ |
7067 | ents |
7068 | * sizeof(struct | |
7069 | peer_group))); | |
d62a17ae | 7070 | |
ea47320b DL |
7071 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
7072 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 7073 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 7074 | vty_out(vty, "\n"); |
d62a17ae | 7075 | |
ea47320b DL |
7076 | /* Subtract 8 here because 'Neighbor' is |
7077 | * 8 characters */ | |
7078 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
7079 | vty_out(vty, "%*s", max_neighbor_width - 8, |
7080 | " "); | |
ea47320b DL |
7081 | vty_out(vty, |
7082 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); | |
d62a17ae | 7083 | } |
ea47320b | 7084 | } |
d62a17ae | 7085 | |
ea47320b | 7086 | count++; |
d62a17ae | 7087 | |
ea47320b DL |
7088 | if (use_json) { |
7089 | json_peer = json_object_new_object(); | |
d62a17ae | 7090 | |
ea47320b | 7091 | if (peer_dynamic_neighbor(peer)) |
60466a63 QY |
7092 | json_object_boolean_true_add(json_peer, |
7093 | "dynamicPeer"); | |
d62a17ae | 7094 | |
ea47320b | 7095 | if (peer->hostname) |
60466a63 | 7096 | json_object_string_add(json_peer, "hostname", |
ea47320b | 7097 | peer->hostname); |
d62a17ae | 7098 | |
ea47320b | 7099 | if (peer->domainname) |
60466a63 QY |
7100 | json_object_string_add(json_peer, "domainname", |
7101 | peer->domainname); | |
d62a17ae | 7102 | |
60466a63 | 7103 | json_object_int_add(json_peer, "remoteAs", peer->as); |
ea47320b | 7104 | json_object_int_add(json_peer, "version", 4); |
60466a63 | 7105 | json_object_int_add(json_peer, "msgRcvd", |
0112e9e0 | 7106 | PEER_TOTAL_RX(peer)); |
60466a63 | 7107 | json_object_int_add(json_peer, "msgSent", |
0112e9e0 | 7108 | PEER_TOTAL_TX(peer)); |
ea47320b DL |
7109 | |
7110 | json_object_int_add(json_peer, "tableVersion", | |
7111 | peer->version[afi][safi]); | |
7112 | json_object_int_add(json_peer, "outq", | |
7113 | peer->obuf->count); | |
7114 | json_object_int_add(json_peer, "inq", 0); | |
60466a63 QY |
7115 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
7116 | use_json, json_peer); | |
7117 | json_object_int_add(json_peer, "prefixReceivedCount", | |
7118 | peer->pcount[afi][pfx_rcd_safi]); | |
d62a17ae | 7119 | |
ea47320b | 7120 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
60466a63 | 7121 | json_object_string_add(json_peer, "state", |
ea47320b | 7122 | "Idle (Admin)"); |
60466a63 QY |
7123 | else if (CHECK_FLAG(peer->sflags, |
7124 | PEER_STATUS_PREFIX_OVERFLOW)) | |
7125 | json_object_string_add(json_peer, "state", | |
ea47320b DL |
7126 | "Idle (PfxCt)"); |
7127 | else | |
7128 | json_object_string_add( | |
7129 | json_peer, "state", | |
60466a63 QY |
7130 | lookup_msg(bgp_status_msg, peer->status, |
7131 | NULL)); | |
ea47320b DL |
7132 | |
7133 | if (peer->conf_if) | |
60466a63 | 7134 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
7135 | "interface"); |
7136 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
7137 | json_object_string_add(json_peer, "idType", |
7138 | "ipv4"); | |
ea47320b | 7139 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
7140 | json_object_string_add(json_peer, "idType", |
7141 | "ipv6"); | |
d62a17ae | 7142 | |
ea47320b DL |
7143 | json_object_object_add(json_peers, peer->host, |
7144 | json_peer); | |
7145 | } else { | |
7146 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7147 | if (peer_dynamic_neighbor(peer)) { | |
7148 | dn_count++; | |
7149 | dn_flag[0] = '*'; | |
7150 | } | |
d62a17ae | 7151 | |
ea47320b | 7152 | if (peer->hostname |
60466a63 | 7153 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
ea47320b | 7154 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
60466a63 | 7155 | peer->hostname, peer->host); |
ea47320b | 7156 | else |
60466a63 | 7157 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
ea47320b DL |
7158 | |
7159 | /* pad the neighbor column with spaces */ | |
7160 | if (len < max_neighbor_width) | |
60466a63 QY |
7161 | vty_out(vty, "%*s", max_neighbor_width - len, |
7162 | " "); | |
ea47320b | 7163 | |
86a55b99 | 7164 | vty_out(vty, "4 %10u %7u %7u %8" PRIu64 " %4d %4zd %8s", |
0112e9e0 QY |
7165 | peer->as, PEER_TOTAL_RX(peer), |
7166 | PEER_TOTAL_TX(peer), peer->version[afi][safi], | |
7167 | 0, peer->obuf->count, | |
d62a17ae | 7168 | peer_uptime(peer->uptime, timebuf, |
ea47320b | 7169 | BGP_UPTIME_LEN, 0, NULL)); |
d62a17ae | 7170 | |
ea47320b | 7171 | if (peer->status == Established) |
95077abf DW |
7172 | if (peer->afc_recv[afi][pfx_rcd_safi]) |
7173 | vty_out(vty, " %12ld", | |
a4d82a8a PZ |
7174 | peer->pcount[afi] |
7175 | [pfx_rcd_safi]); | |
95077abf DW |
7176 | else |
7177 | vty_out(vty, " NoNeg"); | |
ea47320b | 7178 | else { |
60466a63 | 7179 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
ea47320b | 7180 | vty_out(vty, " Idle (Admin)"); |
60466a63 QY |
7181 | else if (CHECK_FLAG( |
7182 | peer->sflags, | |
7183 | PEER_STATUS_PREFIX_OVERFLOW)) | |
ea47320b | 7184 | vty_out(vty, " Idle (PfxCt)"); |
d62a17ae | 7185 | else |
ea47320b | 7186 | vty_out(vty, " %12s", |
60466a63 QY |
7187 | lookup_msg(bgp_status_msg, |
7188 | peer->status, NULL)); | |
d62a17ae | 7189 | } |
ea47320b | 7190 | vty_out(vty, "\n"); |
d62a17ae | 7191 | } |
7192 | } | |
f933309e | 7193 | |
d62a17ae | 7194 | if (use_json) { |
7195 | json_object_object_add(json, "peers", json_peers); | |
7196 | ||
7197 | json_object_int_add(json, "totalPeers", count); | |
7198 | json_object_int_add(json, "dynamicPeers", dn_count); | |
7199 | ||
57a9c8a8 DS |
7200 | bgp_show_bestpath_json(bgp, json); |
7201 | ||
a4d82a8a PZ |
7202 | vty_out(vty, "%s\n", |
7203 | json_object_to_json_string_ext( | |
7204 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 7205 | json_object_free(json); |
7206 | } else { | |
7207 | if (count) | |
7208 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
7209 | else { | |
7210 | if (use_json) | |
7211 | vty_out(vty, | |
7212 | "{\"error\": {\"message\": \"No %s neighbor configured\"}}\n", | |
7213 | afi_safi_print(afi, safi)); | |
7214 | else | |
7215 | vty_out(vty, "No %s neighbor is configured\n", | |
7216 | afi_safi_print(afi, safi)); | |
7217 | } | |
b05a1c8b | 7218 | |
d62a17ae | 7219 | if (dn_count && !use_json) { |
7220 | vty_out(vty, "* - dynamic neighbor\n"); | |
7221 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
7222 | dn_count, bgp->dynamic_neighbors_limit); | |
7223 | } | |
7224 | } | |
1ff9a340 | 7225 | |
d62a17ae | 7226 | return CMD_SUCCESS; |
718e3744 | 7227 | } |
7228 | ||
d62a17ae | 7229 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
7230 | int safi, u_char use_json, | |
7231 | json_object *json) | |
7232 | { | |
7233 | int is_first = 1; | |
7234 | int afi_wildcard = (afi == AFI_MAX); | |
7235 | int safi_wildcard = (safi == SAFI_MAX); | |
7236 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
7237 | bool json_output = false; | |
7238 | ||
7239 | if (use_json && is_wildcard) | |
7240 | vty_out(vty, "{\n"); | |
7241 | if (afi_wildcard) | |
7242 | afi = 1; /* AFI_IP */ | |
7243 | while (afi < AFI_MAX) { | |
7244 | if (safi_wildcard) | |
7245 | safi = 1; /* SAFI_UNICAST */ | |
7246 | while (safi < SAFI_MAX) { | |
318cac96 | 7247 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
d62a17ae | 7248 | json_output = true; |
7249 | if (is_wildcard) { | |
7250 | /* | |
7251 | * So limit output to those afi/safi | |
7252 | * pairs that | |
7253 | * actualy have something interesting in | |
7254 | * them | |
7255 | */ | |
7256 | if (use_json) { | |
7257 | json = json_object_new_object(); | |
7258 | ||
7259 | if (!is_first) | |
7260 | vty_out(vty, ",\n"); | |
7261 | else | |
7262 | is_first = 0; | |
7263 | ||
7264 | vty_out(vty, "\"%s\":", | |
7265 | afi_safi_json(afi, | |
7266 | safi)); | |
7267 | } else { | |
7268 | vty_out(vty, "\n%s Summary:\n", | |
7269 | afi_safi_print(afi, | |
7270 | safi)); | |
7271 | } | |
7272 | } | |
7273 | bgp_show_summary(vty, bgp, afi, safi, use_json, | |
7274 | json); | |
7275 | } | |
7276 | safi++; | |
d62a17ae | 7277 | if (!safi_wildcard) |
7278 | safi = SAFI_MAX; | |
7279 | } | |
7280 | afi++; | |
ee851c8c | 7281 | if (!afi_wildcard) |
d62a17ae | 7282 | afi = AFI_MAX; |
7283 | } | |
7284 | ||
7285 | if (use_json && is_wildcard) | |
7286 | vty_out(vty, "}\n"); | |
7287 | else if (use_json && !json_output) | |
7288 | vty_out(vty, "{}\n"); | |
7289 | } | |
7290 | ||
7291 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
7292 | safi_t safi, u_char use_json) | |
7293 | { | |
7294 | struct listnode *node, *nnode; | |
7295 | struct bgp *bgp; | |
7296 | json_object *json = NULL; | |
7297 | int is_first = 1; | |
7298 | ||
7299 | if (use_json) | |
7300 | vty_out(vty, "{\n"); | |
7301 | ||
7302 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
7303 | if (use_json) { | |
7304 | json = json_object_new_object(); | |
7305 | ||
7306 | if (!is_first) | |
7307 | vty_out(vty, ",\n"); | |
7308 | else | |
7309 | is_first = 0; | |
7310 | ||
7311 | vty_out(vty, "\"%s\":", | |
7312 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7313 | ? "Default" | |
7314 | : bgp->name); | |
7315 | } else { | |
7316 | vty_out(vty, "\nInstance %s:\n", | |
7317 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7318 | ? "Default" | |
7319 | : bgp->name); | |
7320 | } | |
7321 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, json); | |
7322 | } | |
7323 | ||
7324 | if (use_json) | |
7325 | vty_out(vty, "}\n"); | |
7326 | } | |
7327 | ||
7328 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
7329 | safi_t safi, u_char use_json) | |
7330 | { | |
7331 | struct bgp *bgp; | |
7332 | ||
7333 | if (name) { | |
7334 | if (strmatch(name, "all")) { | |
7335 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
7336 | use_json); | |
7337 | return CMD_SUCCESS; | |
7338 | } else { | |
7339 | bgp = bgp_lookup_by_name(name); | |
7340 | ||
7341 | if (!bgp) { | |
7342 | if (use_json) | |
7343 | vty_out(vty, "{}\n"); | |
7344 | else | |
7345 | vty_out(vty, | |
7346 | "%% No such BGP instance exist\n"); | |
7347 | return CMD_WARNING; | |
7348 | } | |
7349 | ||
7350 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, | |
7351 | NULL); | |
7352 | return CMD_SUCCESS; | |
7353 | } | |
7354 | } | |
7355 | ||
7356 | bgp = bgp_get_default(); | |
7357 | ||
7358 | if (bgp) | |
7359 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, NULL); | |
7360 | ||
7361 | return CMD_SUCCESS; | |
4fb25c53 DW |
7362 | } |
7363 | ||
716b2d8a | 7364 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 7365 | DEFUN (show_ip_bgp_summary, |
718e3744 | 7366 | show_ip_bgp_summary_cmd, |
dd6bd0f1 | 7367 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [json]", |
718e3744 | 7368 | SHOW_STR |
7369 | IP_STR | |
7370 | BGP_STR | |
8386ac43 | 7371 | BGP_INSTANCE_HELP_STR |
46f296b4 | 7372 | BGP_AFI_HELP_STR |
dd6bd0f1 | 7373 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 7374 | "Summary of BGP neighbor status\n" |
9973d184 | 7375 | JSON_STR) |
718e3744 | 7376 | { |
d62a17ae | 7377 | char *vrf = NULL; |
7378 | afi_t afi = AFI_MAX; | |
7379 | safi_t safi = SAFI_MAX; | |
7380 | ||
7381 | int idx = 0; | |
7382 | ||
7383 | /* show [ip] bgp */ | |
7384 | if (argv_find(argv, argc, "ip", &idx)) | |
7385 | afi = AFI_IP; | |
7386 | /* [<view|vrf> VIEWVRFNAME] */ | |
7387 | if (argv_find(argv, argc, "view", &idx) | |
7388 | || argv_find(argv, argc, "vrf", &idx)) | |
7389 | vrf = argv[++idx]->arg; | |
7390 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
7391 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
7392 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
7393 | } | |
7394 | ||
7395 | int uj = use_json(argc, argv); | |
7396 | ||
7397 | return bgp_show_summary_vty(vty, vrf, afi, safi, uj); | |
7398 | } | |
7399 | ||
7400 | const char *afi_safi_print(afi_t afi, safi_t safi) | |
7401 | { | |
7402 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
7403 | return "IPv4 Unicast"; | |
7404 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
7405 | return "IPv4 Multicast"; | |
7406 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
7407 | return "IPv4 Labeled Unicast"; | |
7408 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
7409 | return "IPv4 VPN"; | |
7410 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
7411 | return "IPv4 Encap"; | |
7412 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
7413 | return "IPv6 Unicast"; | |
7414 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
7415 | return "IPv6 Multicast"; | |
7416 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
7417 | return "IPv6 Labeled Unicast"; | |
7418 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
7419 | return "IPv6 VPN"; | |
7420 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
7421 | return "IPv6 Encap"; | |
7422 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
7423 | return "L2VPN EVPN"; | |
7424 | else | |
7425 | return "Unknown"; | |
538621f2 | 7426 | } |
7427 | ||
b9f77ec8 DS |
7428 | /* |
7429 | * Please note that we have intentionally camelCased | |
7430 | * the return strings here. So if you want | |
7431 | * to use this function, please ensure you | |
7432 | * are doing this within json output | |
7433 | */ | |
d62a17ae | 7434 | const char *afi_safi_json(afi_t afi, safi_t safi) |
7435 | { | |
7436 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
7437 | return "ipv4Unicast"; | |
7438 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
7439 | return "ipv4Multicast"; | |
7440 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
7441 | return "ipv4LabeledUnicast"; | |
7442 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
7443 | return "ipv4Vpn"; | |
7444 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
7445 | return "ipv4Encap"; | |
7446 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
7447 | return "ipv6Unicast"; | |
7448 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
7449 | return "ipv6Multicast"; | |
7450 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
7451 | return "ipv6LabeledUnicast"; | |
7452 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
7453 | return "ipv6Vpn"; | |
7454 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
7455 | return "ipv6Encap"; | |
7456 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
7457 | return "l2VpnEvpn"; | |
7458 | else | |
7459 | return "Unknown"; | |
27162734 LB |
7460 | } |
7461 | ||
718e3744 | 7462 | /* Show BGP peer's information. */ |
d62a17ae | 7463 | enum show_type { show_all, show_peer }; |
7464 | ||
7465 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
7466 | afi_t afi, safi_t safi, | |
7467 | u_int16_t adv_smcap, u_int16_t adv_rmcap, | |
7468 | u_int16_t rcv_smcap, u_int16_t rcv_rmcap, | |
7469 | u_char use_json, json_object *json_pref) | |
7470 | { | |
7471 | /* Send-Mode */ | |
7472 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
7473 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
7474 | if (use_json) { | |
7475 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
7476 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
7477 | json_object_string_add(json_pref, "sendMode", | |
7478 | "advertisedAndReceived"); | |
7479 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
7480 | json_object_string_add(json_pref, "sendMode", | |
7481 | "advertised"); | |
7482 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
7483 | json_object_string_add(json_pref, "sendMode", | |
7484 | "received"); | |
7485 | } else { | |
7486 | vty_out(vty, " Send-mode: "); | |
7487 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
7488 | vty_out(vty, "advertised"); | |
7489 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
7490 | vty_out(vty, "%sreceived", | |
7491 | CHECK_FLAG(p->af_cap[afi][safi], | |
7492 | adv_smcap) | |
7493 | ? ", " | |
7494 | : ""); | |
7495 | vty_out(vty, "\n"); | |
7496 | } | |
7497 | } | |
7498 | ||
7499 | /* Receive-Mode */ | |
7500 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
7501 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
7502 | if (use_json) { | |
7503 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
7504 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
7505 | json_object_string_add(json_pref, "recvMode", | |
7506 | "advertisedAndReceived"); | |
7507 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
7508 | json_object_string_add(json_pref, "recvMode", | |
7509 | "advertised"); | |
7510 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
7511 | json_object_string_add(json_pref, "recvMode", | |
7512 | "received"); | |
7513 | } else { | |
7514 | vty_out(vty, " Receive-mode: "); | |
7515 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
7516 | vty_out(vty, "advertised"); | |
7517 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
7518 | vty_out(vty, "%sreceived", | |
7519 | CHECK_FLAG(p->af_cap[afi][safi], | |
7520 | adv_rmcap) | |
7521 | ? ", " | |
7522 | : ""); | |
7523 | vty_out(vty, "\n"); | |
7524 | } | |
7525 | } | |
7526 | } | |
7527 | ||
7528 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, | |
7529 | safi_t safi, u_char use_json, | |
7530 | json_object *json_neigh) | |
7531 | { | |
0291c246 MK |
7532 | struct bgp_filter *filter; |
7533 | struct peer_af *paf; | |
7534 | char orf_pfx_name[BUFSIZ]; | |
7535 | int orf_pfx_count; | |
7536 | json_object *json_af = NULL; | |
7537 | json_object *json_prefA = NULL; | |
7538 | json_object *json_prefB = NULL; | |
7539 | json_object *json_addr = NULL; | |
d62a17ae | 7540 | |
7541 | if (use_json) { | |
7542 | json_addr = json_object_new_object(); | |
7543 | json_af = json_object_new_object(); | |
7544 | filter = &p->filter[afi][safi]; | |
7545 | ||
7546 | if (peer_group_active(p)) | |
7547 | json_object_string_add(json_addr, "peerGroupMember", | |
7548 | p->group->name); | |
7549 | ||
7550 | paf = peer_af_find(p, afi, safi); | |
7551 | if (paf && PAF_SUBGRP(paf)) { | |
7552 | json_object_int_add(json_addr, "updateGroupId", | |
7553 | PAF_UPDGRP(paf)->id); | |
7554 | json_object_int_add(json_addr, "subGroupId", | |
7555 | PAF_SUBGRP(paf)->id); | |
7556 | json_object_int_add(json_addr, "packetQueueLength", | |
7557 | bpacket_queue_virtual_length(paf)); | |
7558 | } | |
7559 | ||
7560 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7561 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7562 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7563 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7564 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7565 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7566 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
7567 | json_object_int_add(json_af, "orfType", | |
7568 | ORF_TYPE_PREFIX); | |
7569 | json_prefA = json_object_new_object(); | |
7570 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
7571 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7572 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7573 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7574 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
7575 | use_json, json_prefA); | |
7576 | json_object_object_add(json_af, "orfPrefixList", | |
7577 | json_prefA); | |
7578 | } | |
7579 | ||
7580 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7581 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7582 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7583 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7584 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7585 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7586 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
7587 | json_object_int_add(json_af, "orfOldType", | |
7588 | ORF_TYPE_PREFIX_OLD); | |
7589 | json_prefB = json_object_new_object(); | |
7590 | bgp_show_peer_afi_orf_cap( | |
7591 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
7592 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7593 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7594 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
7595 | json_prefB); | |
7596 | json_object_object_add(json_af, "orfOldPrefixList", | |
7597 | json_prefB); | |
7598 | } | |
7599 | ||
7600 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7601 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7602 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7603 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7604 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7605 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7606 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7607 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7608 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
7609 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7610 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7611 | json_object_object_add(json_addr, "afDependentCap", | |
7612 | json_af); | |
7613 | else | |
7614 | json_object_free(json_af); | |
7615 | ||
7616 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
7617 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
7618 | NULL, afi, orf_pfx_name, use_json); | |
7619 | ||
7620 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7621 | PEER_STATUS_ORF_PREFIX_SEND) | |
7622 | || orf_pfx_count) { | |
7623 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7624 | PEER_STATUS_ORF_PREFIX_SEND)) | |
7625 | json_object_boolean_true_add(json_neigh, | |
7626 | "orfSent"); | |
7627 | if (orf_pfx_count) | |
7628 | json_object_int_add(json_addr, "orfRecvCounter", | |
7629 | orf_pfx_count); | |
7630 | } | |
7631 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7632 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
7633 | json_object_string_add( | |
7634 | json_addr, "orfFirstUpdate", | |
7635 | "deferredUntilORFOrRouteRefreshRecvd"); | |
7636 | ||
7637 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7638 | PEER_FLAG_REFLECTOR_CLIENT)) | |
7639 | json_object_boolean_true_add(json_addr, | |
7640 | "routeReflectorClient"); | |
7641 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7642 | PEER_FLAG_RSERVER_CLIENT)) | |
7643 | json_object_boolean_true_add(json_addr, | |
7644 | "routeServerClient"); | |
7645 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7646 | json_object_boolean_true_add(json_addr, | |
7647 | "inboundSoftConfigPermit"); | |
7648 | ||
7649 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7650 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
7651 | json_object_boolean_true_add( | |
7652 | json_addr, | |
7653 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
7654 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7655 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
7656 | json_object_boolean_true_add( | |
7657 | json_addr, | |
7658 | "privateAsNumsReplacedInUpdatesToNbr"); | |
7659 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7660 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
7661 | json_object_boolean_true_add( | |
7662 | json_addr, | |
7663 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
7664 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7665 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
7666 | json_object_boolean_true_add( | |
7667 | json_addr, | |
7668 | "privateAsNumsRemovedInUpdatesToNbr"); | |
7669 | ||
7670 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7671 | PEER_FLAG_ADDPATH_TX_ALL_PATHS)) | |
7672 | json_object_boolean_true_add(json_addr, | |
7673 | "addpathTxAllPaths"); | |
7674 | ||
7675 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7676 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
7677 | json_object_boolean_true_add(json_addr, | |
7678 | "addpathTxBestpathPerAS"); | |
7679 | ||
7680 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
7681 | json_object_string_add(json_addr, | |
7682 | "overrideASNsInOutboundUpdates", | |
7683 | "ifAspathEqualRemoteAs"); | |
7684 | ||
7685 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
7686 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7687 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7688 | json_object_boolean_true_add(json_addr, | |
7689 | "routerAlwaysNextHop"); | |
7690 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7691 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
7692 | json_object_boolean_true_add( | |
7693 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
7694 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7695 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7696 | json_object_boolean_true_add( | |
7697 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
7698 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7699 | json_object_boolean_true_add( | |
7700 | json_addr, "unchangedMedPropogatedToNbr"); | |
7701 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7702 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7703 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
7704 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7705 | PEER_FLAG_SEND_COMMUNITY) | |
7706 | && CHECK_FLAG(p->af_flags[afi][safi], | |
7707 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7708 | json_object_string_add(json_addr, | |
7709 | "commAttriSentToNbr", | |
7710 | "extendedAndStandard"); | |
7711 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7712 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7713 | json_object_string_add(json_addr, | |
7714 | "commAttriSentToNbr", | |
7715 | "extended"); | |
7716 | else | |
7717 | json_object_string_add(json_addr, | |
7718 | "commAttriSentToNbr", | |
7719 | "standard"); | |
7720 | } | |
7721 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7722 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
7723 | if (p->default_rmap[afi][safi].name) | |
7724 | json_object_string_add( | |
7725 | json_addr, "defaultRouteMap", | |
7726 | p->default_rmap[afi][safi].name); | |
7727 | ||
7728 | if (paf && PAF_SUBGRP(paf) | |
7729 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
7730 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7731 | json_object_boolean_true_add(json_addr, | |
7732 | "defaultSent"); | |
7733 | else | |
7734 | json_object_boolean_true_add(json_addr, | |
7735 | "defaultNotSent"); | |
7736 | } | |
7737 | ||
dff8f48d | 7738 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 7739 | if (is_evpn_enabled()) |
60466a63 QY |
7740 | json_object_boolean_true_add( |
7741 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
7742 | } |
7743 | ||
d62a17ae | 7744 | if (filter->plist[FILTER_IN].name |
7745 | || filter->dlist[FILTER_IN].name | |
7746 | || filter->aslist[FILTER_IN].name | |
7747 | || filter->map[RMAP_IN].name) | |
7748 | json_object_boolean_true_add(json_addr, | |
7749 | "inboundPathPolicyConfig"); | |
7750 | if (filter->plist[FILTER_OUT].name | |
7751 | || filter->dlist[FILTER_OUT].name | |
7752 | || filter->aslist[FILTER_OUT].name | |
7753 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
7754 | json_object_boolean_true_add( | |
7755 | json_addr, "outboundPathPolicyConfig"); | |
7756 | ||
7757 | /* prefix-list */ | |
7758 | if (filter->plist[FILTER_IN].name) | |
7759 | json_object_string_add(json_addr, | |
7760 | "incomingUpdatePrefixFilterList", | |
7761 | filter->plist[FILTER_IN].name); | |
7762 | if (filter->plist[FILTER_OUT].name) | |
7763 | json_object_string_add(json_addr, | |
7764 | "outgoingUpdatePrefixFilterList", | |
7765 | filter->plist[FILTER_OUT].name); | |
7766 | ||
7767 | /* distribute-list */ | |
7768 | if (filter->dlist[FILTER_IN].name) | |
7769 | json_object_string_add( | |
7770 | json_addr, "incomingUpdateNetworkFilterList", | |
7771 | filter->dlist[FILTER_IN].name); | |
7772 | if (filter->dlist[FILTER_OUT].name) | |
7773 | json_object_string_add( | |
7774 | json_addr, "outgoingUpdateNetworkFilterList", | |
7775 | filter->dlist[FILTER_OUT].name); | |
7776 | ||
7777 | /* filter-list. */ | |
7778 | if (filter->aslist[FILTER_IN].name) | |
7779 | json_object_string_add(json_addr, | |
7780 | "incomingUpdateAsPathFilterList", | |
7781 | filter->aslist[FILTER_IN].name); | |
7782 | if (filter->aslist[FILTER_OUT].name) | |
7783 | json_object_string_add(json_addr, | |
7784 | "outgoingUpdateAsPathFilterList", | |
7785 | filter->aslist[FILTER_OUT].name); | |
7786 | ||
7787 | /* route-map. */ | |
7788 | if (filter->map[RMAP_IN].name) | |
7789 | json_object_string_add( | |
7790 | json_addr, "routeMapForIncomingAdvertisements", | |
7791 | filter->map[RMAP_IN].name); | |
7792 | if (filter->map[RMAP_OUT].name) | |
7793 | json_object_string_add( | |
7794 | json_addr, "routeMapForOutgoingAdvertisements", | |
7795 | filter->map[RMAP_OUT].name); | |
7796 | ||
7797 | /* unsuppress-map */ | |
7798 | if (filter->usmap.name) | |
7799 | json_object_string_add(json_addr, | |
7800 | "selectiveUnsuppressRouteMap", | |
7801 | filter->usmap.name); | |
7802 | ||
7803 | /* Receive prefix count */ | |
7804 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
7805 | p->pcount[afi][safi]); | |
7806 | ||
7807 | /* Maximum prefix */ | |
7808 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
7809 | json_object_int_add(json_addr, "prefixAllowedMax", | |
7810 | p->pmax[afi][safi]); | |
7811 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7812 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
7813 | json_object_boolean_true_add( | |
7814 | json_addr, "prefixAllowedMaxWarning"); | |
7815 | json_object_int_add(json_addr, | |
7816 | "prefixAllowedWarningThresh", | |
7817 | p->pmax_threshold[afi][safi]); | |
7818 | if (p->pmax_restart[afi][safi]) | |
7819 | json_object_int_add( | |
7820 | json_addr, | |
7821 | "prefixAllowedRestartIntervalMsecs", | |
7822 | p->pmax_restart[afi][safi] * 60000); | |
7823 | } | |
7824 | json_object_object_add(json_neigh, afi_safi_print(afi, safi), | |
7825 | json_addr); | |
7826 | ||
7827 | } else { | |
7828 | filter = &p->filter[afi][safi]; | |
7829 | ||
7830 | vty_out(vty, " For address family: %s\n", | |
7831 | afi_safi_print(afi, safi)); | |
7832 | ||
7833 | if (peer_group_active(p)) | |
7834 | vty_out(vty, " %s peer-group member\n", | |
7835 | p->group->name); | |
7836 | ||
7837 | paf = peer_af_find(p, afi, safi); | |
7838 | if (paf && PAF_SUBGRP(paf)) { | |
a4d82a8a PZ |
7839 | vty_out(vty, |
7840 | " Update group %" PRIu64 ", subgroup %" PRIu64 | |
7841 | "\n", | |
d62a17ae | 7842 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
7843 | vty_out(vty, " Packet Queue length %d\n", | |
7844 | bpacket_queue_virtual_length(paf)); | |
7845 | } else { | |
7846 | vty_out(vty, " Not part of any update group\n"); | |
7847 | } | |
7848 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7849 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7850 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7851 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7852 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7853 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7854 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7855 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7856 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
7857 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7858 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7859 | vty_out(vty, " AF-dependant capabilities:\n"); | |
7860 | ||
7861 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7862 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7863 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7864 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7865 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7866 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7867 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
7868 | vty_out(vty, | |
7869 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
7870 | ORF_TYPE_PREFIX); | |
7871 | bgp_show_peer_afi_orf_cap( | |
7872 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
7873 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7874 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7875 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
7876 | } | |
7877 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7878 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7879 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7880 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7881 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7882 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7883 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
7884 | vty_out(vty, | |
7885 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
7886 | ORF_TYPE_PREFIX_OLD); | |
7887 | bgp_show_peer_afi_orf_cap( | |
7888 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
7889 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7890 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7891 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
7892 | } | |
7893 | ||
7894 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
7895 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
7896 | NULL, afi, orf_pfx_name, use_json); | |
7897 | ||
7898 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7899 | PEER_STATUS_ORF_PREFIX_SEND) | |
7900 | || orf_pfx_count) { | |
7901 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
7902 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7903 | PEER_STATUS_ORF_PREFIX_SEND)) | |
7904 | vty_out(vty, " sent;"); | |
7905 | if (orf_pfx_count) | |
7906 | vty_out(vty, " received (%d entries)", | |
7907 | orf_pfx_count); | |
7908 | vty_out(vty, "\n"); | |
7909 | } | |
7910 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7911 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
7912 | vty_out(vty, | |
7913 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
7914 | ||
7915 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7916 | PEER_FLAG_REFLECTOR_CLIENT)) | |
7917 | vty_out(vty, " Route-Reflector Client\n"); | |
7918 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7919 | PEER_FLAG_RSERVER_CLIENT)) | |
7920 | vty_out(vty, " Route-Server Client\n"); | |
7921 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7922 | vty_out(vty, | |
7923 | " Inbound soft reconfiguration allowed\n"); | |
7924 | ||
7925 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7926 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
7927 | vty_out(vty, | |
7928 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
7929 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7930 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
7931 | vty_out(vty, | |
7932 | " Private AS numbers replaced in updates to this neighbor\n"); | |
7933 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7934 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
7935 | vty_out(vty, | |
7936 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
7937 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7938 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
7939 | vty_out(vty, | |
7940 | " Private AS numbers removed in updates to this neighbor\n"); | |
7941 | ||
7942 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7943 | PEER_FLAG_ADDPATH_TX_ALL_PATHS)) | |
7944 | vty_out(vty, " Advertise all paths via addpath\n"); | |
7945 | ||
7946 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7947 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
7948 | vty_out(vty, | |
7949 | " Advertise bestpath per AS via addpath\n"); | |
7950 | ||
7951 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
7952 | vty_out(vty, | |
7953 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
7954 | ||
7955 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
7956 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7957 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7958 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
7959 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7960 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
7961 | vty_out(vty, | |
7962 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
7963 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7964 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7965 | vty_out(vty, | |
7966 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
7967 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7968 | vty_out(vty, | |
7969 | " MED is propagated unchanged to this neighbor\n"); | |
7970 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7971 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7972 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
7973 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7974 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
7975 | vty_out(vty, | |
7976 | " Community attribute sent to this neighbor"); | |
7977 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7978 | PEER_FLAG_SEND_COMMUNITY) | |
7979 | && CHECK_FLAG(p->af_flags[afi][safi], | |
7980 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
7981 | && CHECK_FLAG(p->af_flags[afi][safi], | |
7982 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7983 | vty_out(vty, "(all)\n"); | |
7984 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7985 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7986 | vty_out(vty, "(large)\n"); | |
7987 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7988 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7989 | vty_out(vty, "(extended)\n"); | |
7990 | else | |
7991 | vty_out(vty, "(standard)\n"); | |
7992 | } | |
7993 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7994 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
7995 | vty_out(vty, " Default information originate,"); | |
7996 | ||
7997 | if (p->default_rmap[afi][safi].name) | |
7998 | vty_out(vty, " default route-map %s%s,", | |
7999 | p->default_rmap[afi][safi].map ? "*" | |
8000 | : "", | |
8001 | p->default_rmap[afi][safi].name); | |
8002 | if (paf && PAF_SUBGRP(paf) | |
8003 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
8004 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
8005 | vty_out(vty, " default sent\n"); | |
8006 | else | |
8007 | vty_out(vty, " default not sent\n"); | |
8008 | } | |
8009 | ||
dff8f48d MK |
8010 | /* advertise-vni-all */ |
8011 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 8012 | if (is_evpn_enabled()) |
dff8f48d MK |
8013 | vty_out(vty, " advertise-all-vni\n"); |
8014 | } | |
8015 | ||
d62a17ae | 8016 | if (filter->plist[FILTER_IN].name |
8017 | || filter->dlist[FILTER_IN].name | |
8018 | || filter->aslist[FILTER_IN].name | |
8019 | || filter->map[RMAP_IN].name) | |
8020 | vty_out(vty, " Inbound path policy configured\n"); | |
8021 | if (filter->plist[FILTER_OUT].name | |
8022 | || filter->dlist[FILTER_OUT].name | |
8023 | || filter->aslist[FILTER_OUT].name | |
8024 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
8025 | vty_out(vty, " Outbound path policy configured\n"); | |
8026 | ||
8027 | /* prefix-list */ | |
8028 | if (filter->plist[FILTER_IN].name) | |
8029 | vty_out(vty, | |
8030 | " Incoming update prefix filter list is %s%s\n", | |
8031 | filter->plist[FILTER_IN].plist ? "*" : "", | |
8032 | filter->plist[FILTER_IN].name); | |
8033 | if (filter->plist[FILTER_OUT].name) | |
8034 | vty_out(vty, | |
8035 | " Outgoing update prefix filter list is %s%s\n", | |
8036 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
8037 | filter->plist[FILTER_OUT].name); | |
8038 | ||
8039 | /* distribute-list */ | |
8040 | if (filter->dlist[FILTER_IN].name) | |
8041 | vty_out(vty, | |
8042 | " Incoming update network filter list is %s%s\n", | |
8043 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
8044 | filter->dlist[FILTER_IN].name); | |
8045 | if (filter->dlist[FILTER_OUT].name) | |
8046 | vty_out(vty, | |
8047 | " Outgoing update network filter list is %s%s\n", | |
8048 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
8049 | filter->dlist[FILTER_OUT].name); | |
8050 | ||
8051 | /* filter-list. */ | |
8052 | if (filter->aslist[FILTER_IN].name) | |
8053 | vty_out(vty, | |
8054 | " Incoming update AS path filter list is %s%s\n", | |
8055 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
8056 | filter->aslist[FILTER_IN].name); | |
8057 | if (filter->aslist[FILTER_OUT].name) | |
8058 | vty_out(vty, | |
8059 | " Outgoing update AS path filter list is %s%s\n", | |
8060 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
8061 | filter->aslist[FILTER_OUT].name); | |
8062 | ||
8063 | /* route-map. */ | |
8064 | if (filter->map[RMAP_IN].name) | |
8065 | vty_out(vty, | |
8066 | " Route map for incoming advertisements is %s%s\n", | |
8067 | filter->map[RMAP_IN].map ? "*" : "", | |
8068 | filter->map[RMAP_IN].name); | |
8069 | if (filter->map[RMAP_OUT].name) | |
8070 | vty_out(vty, | |
8071 | " Route map for outgoing advertisements is %s%s\n", | |
8072 | filter->map[RMAP_OUT].map ? "*" : "", | |
8073 | filter->map[RMAP_OUT].name); | |
8074 | ||
8075 | /* unsuppress-map */ | |
8076 | if (filter->usmap.name) | |
8077 | vty_out(vty, | |
8078 | " Route map for selective unsuppress is %s%s\n", | |
8079 | filter->usmap.map ? "*" : "", | |
8080 | filter->usmap.name); | |
8081 | ||
8082 | /* Receive prefix count */ | |
8083 | vty_out(vty, " %ld accepted prefixes\n", p->pcount[afi][safi]); | |
8084 | ||
8085 | /* Maximum prefix */ | |
8086 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
8087 | vty_out(vty, " Maximum prefixes allowed %ld%s\n", | |
8088 | p->pmax[afi][safi], | |
8089 | CHECK_FLAG(p->af_flags[afi][safi], | |
8090 | PEER_FLAG_MAX_PREFIX_WARNING) | |
8091 | ? " (warning-only)" | |
8092 | : ""); | |
8093 | vty_out(vty, " Threshold for warning message %d%%", | |
8094 | p->pmax_threshold[afi][safi]); | |
8095 | if (p->pmax_restart[afi][safi]) | |
8096 | vty_out(vty, ", restart interval %d min", | |
8097 | p->pmax_restart[afi][safi]); | |
8098 | vty_out(vty, "\n"); | |
8099 | } | |
8100 | ||
8101 | vty_out(vty, "\n"); | |
8102 | } | |
8103 | } | |
8104 | ||
8105 | static void bgp_show_peer(struct vty *vty, struct peer *p, u_char use_json, | |
8106 | json_object *json) | |
718e3744 | 8107 | { |
d62a17ae | 8108 | struct bgp *bgp; |
8109 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
8110 | char timebuf[BGP_UPTIME_LEN]; | |
8111 | char dn_flag[2]; | |
8112 | const char *subcode_str; | |
8113 | const char *code_str; | |
8114 | afi_t afi; | |
8115 | safi_t safi; | |
8116 | u_int16_t i; | |
8117 | u_char *msg; | |
8118 | json_object *json_neigh = NULL; | |
8119 | time_t epoch_tbuf; | |
718e3744 | 8120 | |
d62a17ae | 8121 | bgp = p->bgp; |
8122 | ||
8123 | if (use_json) | |
8124 | json_neigh = json_object_new_object(); | |
8125 | ||
8126 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8127 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
8128 | dn_flag[0] = '*'; | |
8129 | ||
8130 | if (!use_json) { | |
8131 | if (p->conf_if) /* Configured interface name. */ | |
8132 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
8133 | BGP_PEER_SU_UNSPEC(p) | |
8134 | ? "None" | |
8135 | : sockunion2str(&p->su, buf, | |
8136 | SU_ADDRSTRLEN)); | |
8137 | else /* Configured IP address. */ | |
8138 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
8139 | p->host); | |
8140 | } | |
8141 | ||
8142 | if (use_json) { | |
8143 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
8144 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
8145 | "none"); | |
8146 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
8147 | json_object_string_add( | |
8148 | json_neigh, "bgpNeighborAddr", | |
8149 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
8150 | ||
8151 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
8152 | ||
8153 | if (p->change_local_as) | |
8154 | json_object_int_add(json_neigh, "localAs", | |
8155 | p->change_local_as); | |
8156 | else | |
8157 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
8158 | ||
8159 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
8160 | json_object_boolean_true_add(json_neigh, | |
8161 | "localAsNoPrepend"); | |
8162 | ||
8163 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
8164 | json_object_boolean_true_add(json_neigh, | |
8165 | "localAsReplaceAs"); | |
8166 | } else { | |
8167 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
8168 | || (p->as_type == AS_INTERNAL)) | |
8169 | vty_out(vty, "remote AS %u, ", p->as); | |
8170 | else | |
8171 | vty_out(vty, "remote AS Unspecified, "); | |
8172 | vty_out(vty, "local AS %u%s%s, ", | |
8173 | p->change_local_as ? p->change_local_as : p->local_as, | |
8174 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
8175 | ? " no-prepend" | |
8176 | : "", | |
8177 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
8178 | ? " replace-as" | |
8179 | : ""); | |
8180 | } | |
8181 | /* peer type internal, external, confed-internal or confed-external */ | |
8182 | if (p->as == p->local_as) { | |
8183 | if (use_json) { | |
8184 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
8185 | json_object_boolean_true_add( | |
8186 | json_neigh, "nbrConfedInternalLink"); | |
8187 | else | |
8188 | json_object_boolean_true_add(json_neigh, | |
8189 | "nbrInternalLink"); | |
8190 | } else { | |
8191 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
8192 | vty_out(vty, "confed-internal link\n"); | |
8193 | else | |
8194 | vty_out(vty, "internal link\n"); | |
8195 | } | |
8196 | } else { | |
8197 | if (use_json) { | |
8198 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
8199 | json_object_boolean_true_add( | |
8200 | json_neigh, "nbrConfedExternalLink"); | |
8201 | else | |
8202 | json_object_boolean_true_add(json_neigh, | |
8203 | "nbrExternalLink"); | |
8204 | } else { | |
8205 | if (bgp_confederation_peers_check(bgp, p->as)) | |
8206 | vty_out(vty, "confed-external link\n"); | |
8207 | else | |
8208 | vty_out(vty, "external link\n"); | |
8209 | } | |
8210 | } | |
8211 | ||
8212 | /* Description. */ | |
8213 | if (p->desc) { | |
8214 | if (use_json) | |
8215 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
8216 | else | |
8217 | vty_out(vty, " Description: %s\n", p->desc); | |
8218 | } | |
8219 | ||
8220 | if (p->hostname) { | |
8221 | if (use_json) { | |
8222 | if (p->hostname) | |
8223 | json_object_string_add(json_neigh, "hostname", | |
8224 | p->hostname); | |
8225 | ||
8226 | if (p->domainname) | |
8227 | json_object_string_add(json_neigh, "domainname", | |
8228 | p->domainname); | |
8229 | } else { | |
8230 | if (p->domainname && (p->domainname[0] != '\0')) | |
8231 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
8232 | p->domainname); | |
8233 | else | |
8234 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
8235 | } | |
8236 | } | |
8237 | ||
8238 | /* Peer-group */ | |
8239 | if (p->group) { | |
8240 | if (use_json) { | |
8241 | json_object_string_add(json_neigh, "peerGroup", | |
8242 | p->group->name); | |
8243 | ||
8244 | if (dn_flag[0]) { | |
8245 | struct prefix prefix, *range = NULL; | |
8246 | ||
8247 | sockunion2hostprefix(&(p->su), &prefix); | |
8248 | range = peer_group_lookup_dynamic_neighbor_range( | |
8249 | p->group, &prefix); | |
8250 | ||
8251 | if (range) { | |
8252 | prefix2str(range, buf1, sizeof(buf1)); | |
8253 | json_object_string_add( | |
8254 | json_neigh, | |
8255 | "peerSubnetRangeGroup", buf1); | |
8256 | } | |
8257 | } | |
8258 | } else { | |
8259 | vty_out(vty, | |
8260 | " Member of peer-group %s for session parameters\n", | |
8261 | p->group->name); | |
8262 | ||
8263 | if (dn_flag[0]) { | |
8264 | struct prefix prefix, *range = NULL; | |
8265 | ||
8266 | sockunion2hostprefix(&(p->su), &prefix); | |
8267 | range = peer_group_lookup_dynamic_neighbor_range( | |
8268 | p->group, &prefix); | |
8269 | ||
8270 | if (range) { | |
8271 | prefix2str(range, buf1, sizeof(buf1)); | |
8272 | vty_out(vty, | |
8273 | " Belongs to the subnet range group: %s\n", | |
8274 | buf1); | |
8275 | } | |
8276 | } | |
8277 | } | |
8278 | } | |
8279 | ||
8280 | if (use_json) { | |
8281 | /* Administrative shutdown. */ | |
8282 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
8283 | json_object_boolean_true_add(json_neigh, | |
8284 | "adminShutDown"); | |
8285 | ||
8286 | /* BGP Version. */ | |
8287 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
8288 | json_object_string_add( | |
8289 | json_neigh, "remoteRouterId", | |
8290 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
8291 | ||
8292 | /* Confederation */ | |
8293 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
8294 | && bgp_confederation_peers_check(bgp, p->as)) | |
8295 | json_object_boolean_true_add(json_neigh, | |
8296 | "nbrCommonAdmin"); | |
8297 | ||
8298 | /* Status. */ | |
8299 | json_object_string_add( | |
8300 | json_neigh, "bgpState", | |
8301 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
8302 | ||
8303 | if (p->status == Established) { | |
8304 | time_t uptime; | |
d62a17ae | 8305 | |
8306 | uptime = bgp_clock(); | |
8307 | uptime -= p->uptime; | |
d62a17ae | 8308 | epoch_tbuf = time(NULL) - uptime; |
8309 | ||
d3c7efed | 8310 | #if CONFDATE > 20200101 |
a4d82a8a PZ |
8311 | CPP_NOTICE( |
8312 | "bgpTimerUp should be deprecated and can be removed now"); | |
d3c7efed DS |
8313 | #endif |
8314 | /* | |
8315 | * bgpTimerUp was miliseconds that was accurate | |
8316 | * up to 1 day, then the value returned | |
8317 | * became garbage. So in order to provide | |
8318 | * some level of backwards compatability, | |
8319 | * we still provde the data, but now | |
8320 | * we are returning the correct value | |
8321 | * and also adding a new bgpTimerUpMsec | |
8322 | * which will allow us to deprecate | |
8323 | * this eventually | |
8324 | */ | |
d62a17ae | 8325 | json_object_int_add(json_neigh, "bgpTimerUp", |
e0330274 | 8326 | uptime * 1000); |
d3c7efed DS |
8327 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
8328 | uptime * 1000); | |
d62a17ae | 8329 | json_object_string_add(json_neigh, "bgpTimerUpString", |
8330 | peer_uptime(p->uptime, timebuf, | |
8331 | BGP_UPTIME_LEN, 0, | |
8332 | NULL)); | |
8333 | json_object_int_add(json_neigh, | |
8334 | "bgpTimerUpEstablishedEpoch", | |
8335 | epoch_tbuf); | |
8336 | } | |
8337 | ||
8338 | else if (p->status == Active) { | |
8339 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
8340 | json_object_string_add(json_neigh, "bgpStateIs", | |
8341 | "passive"); | |
8342 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
8343 | json_object_string_add(json_neigh, "bgpStateIs", | |
8344 | "passiveNSF"); | |
8345 | } | |
8346 | ||
8347 | /* read timer */ | |
8348 | time_t uptime; | |
8349 | struct tm *tm; | |
8350 | ||
8351 | uptime = bgp_clock(); | |
8352 | uptime -= p->readtime; | |
8353 | tm = gmtime(&uptime); | |
8354 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
8355 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
8356 | + (tm->tm_hour * 3600000)); | |
8357 | ||
8358 | uptime = bgp_clock(); | |
8359 | uptime -= p->last_write; | |
8360 | tm = gmtime(&uptime); | |
8361 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
8362 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
8363 | + (tm->tm_hour * 3600000)); | |
8364 | ||
8365 | uptime = bgp_clock(); | |
8366 | uptime -= p->update_time; | |
8367 | tm = gmtime(&uptime); | |
8368 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
8369 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
8370 | + (tm->tm_hour * 3600000)); | |
8371 | ||
8372 | /* Configured timer values. */ | |
8373 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
8374 | p->v_holdtime * 1000); | |
8375 | json_object_int_add(json_neigh, | |
8376 | "bgpTimerKeepAliveIntervalMsecs", | |
8377 | p->v_keepalive * 1000); | |
8378 | ||
d25e4efc | 8379 | if (PEER_OR_GROUP_TIMER_SET(p)) { |
d62a17ae | 8380 | json_object_int_add(json_neigh, |
8381 | "bgpTimerConfiguredHoldTimeMsecs", | |
8382 | p->holdtime * 1000); | |
8383 | json_object_int_add( | |
8384 | json_neigh, | |
8385 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
8386 | p->keepalive * 1000); | |
d25e4efc | 8387 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
8388 | || (bgp->default_keepalive |
8389 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
8390 | json_object_int_add(json_neigh, |
8391 | "bgpTimerConfiguredHoldTimeMsecs", | |
8392 | bgp->default_holdtime); | |
8393 | json_object_int_add( | |
8394 | json_neigh, | |
8395 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
8396 | bgp->default_keepalive); | |
d62a17ae | 8397 | } |
8398 | } else { | |
8399 | /* Administrative shutdown. */ | |
8400 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
8401 | vty_out(vty, " Administratively shut down\n"); | |
8402 | ||
8403 | /* BGP Version. */ | |
8404 | vty_out(vty, " BGP version 4"); | |
8405 | vty_out(vty, ", remote router ID %s\n", | |
8406 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
8407 | ||
8408 | /* Confederation */ | |
8409 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
8410 | && bgp_confederation_peers_check(bgp, p->as)) | |
8411 | vty_out(vty, | |
8412 | " Neighbor under common administration\n"); | |
8413 | ||
8414 | /* Status. */ | |
8415 | vty_out(vty, " BGP state = %s", | |
8416 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
8417 | ||
8418 | if (p->status == Established) | |
8419 | vty_out(vty, ", up for %8s", | |
8420 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
8421 | 0, NULL)); | |
8422 | ||
8423 | else if (p->status == Active) { | |
8424 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
8425 | vty_out(vty, " (passive)"); | |
8426 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
8427 | vty_out(vty, " (NSF passive)"); | |
8428 | } | |
8429 | vty_out(vty, "\n"); | |
8430 | ||
8431 | /* read timer */ | |
8432 | vty_out(vty, " Last read %s", | |
8433 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
8434 | NULL)); | |
8435 | vty_out(vty, ", Last write %s\n", | |
8436 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
8437 | NULL)); | |
8438 | ||
8439 | /* Configured timer values. */ | |
8440 | vty_out(vty, | |
8441 | " Hold time is %d, keepalive interval is %d seconds\n", | |
8442 | p->v_holdtime, p->v_keepalive); | |
d25e4efc | 8443 | if (PEER_OR_GROUP_TIMER_SET(p)) { |
d62a17ae | 8444 | vty_out(vty, " Configured hold time is %d", |
8445 | p->holdtime); | |
8446 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
8447 | p->keepalive); | |
d25e4efc | 8448 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
8449 | || (bgp->default_keepalive |
8450 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
8451 | vty_out(vty, " Configured hold time is %d", |
8452 | bgp->default_holdtime); | |
8453 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
8454 | bgp->default_keepalive); | |
d62a17ae | 8455 | } |
8456 | } | |
8457 | /* Capability. */ | |
8458 | if (p->status == Established) { | |
8459 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
8460 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
8461 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
8462 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
8463 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
8464 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
8465 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
8466 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
8467 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
8468 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
8469 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
8470 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
8471 | || p->afc_adv[AFI_IP][SAFI_ENCAP] | |
8472 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
8473 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] | |
8474 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
8475 | if (use_json) { | |
8476 | json_object *json_cap = NULL; | |
8477 | ||
8478 | json_cap = json_object_new_object(); | |
8479 | ||
8480 | /* AS4 */ | |
8481 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
8482 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
8483 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
8484 | && CHECK_FLAG(p->cap, | |
8485 | PEER_CAP_AS4_RCV)) | |
8486 | json_object_string_add( | |
8487 | json_cap, "4byteAs", | |
8488 | "advertisedAndReceived"); | |
8489 | else if (CHECK_FLAG(p->cap, | |
8490 | PEER_CAP_AS4_ADV)) | |
8491 | json_object_string_add( | |
8492 | json_cap, "4byteAs", | |
8493 | "advertised"); | |
8494 | else if (CHECK_FLAG(p->cap, | |
8495 | PEER_CAP_AS4_RCV)) | |
8496 | json_object_string_add( | |
8497 | json_cap, "4byteAs", | |
8498 | "received"); | |
8499 | } | |
8500 | ||
8501 | /* AddPath */ | |
8502 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
8503 | || CHECK_FLAG(p->cap, | |
8504 | PEER_CAP_ADDPATH_ADV)) { | |
8505 | json_object *json_add = NULL; | |
8506 | const char *print_store; | |
8507 | ||
8508 | json_add = json_object_new_object(); | |
8509 | ||
05c7a1cc QY |
8510 | FOREACH_AFI_SAFI (afi, safi) { |
8511 | json_object *json_sub = NULL; | |
8512 | json_sub = | |
8513 | json_object_new_object(); | |
8514 | print_store = afi_safi_print( | |
8515 | afi, safi); | |
d62a17ae | 8516 | |
05c7a1cc QY |
8517 | if (CHECK_FLAG( |
8518 | p->af_cap[afi] | |
8519 | [safi], | |
8520 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8521 | || CHECK_FLAG( | |
8522 | p->af_cap[afi] | |
8523 | [safi], | |
8524 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 8525 | if (CHECK_FLAG( |
8526 | p->af_cap | |
8527 | [afi] | |
8528 | [safi], | |
8529 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 8530 | && CHECK_FLAG( |
d62a17ae | 8531 | p->af_cap |
8532 | [afi] | |
8533 | [safi], | |
05c7a1cc QY |
8534 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
8535 | json_object_boolean_true_add( | |
8536 | json_sub, | |
8537 | "txAdvertisedAndReceived"); | |
8538 | else if ( | |
8539 | CHECK_FLAG( | |
8540 | p->af_cap | |
8541 | [afi] | |
8542 | [safi], | |
8543 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
8544 | json_object_boolean_true_add( | |
8545 | json_sub, | |
8546 | "txAdvertised"); | |
8547 | else if ( | |
8548 | CHECK_FLAG( | |
8549 | p->af_cap | |
8550 | [afi] | |
8551 | [safi], | |
8552 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8553 | json_object_boolean_true_add( | |
8554 | json_sub, | |
8555 | "txReceived"); | |
8556 | } | |
d62a17ae | 8557 | |
05c7a1cc QY |
8558 | if (CHECK_FLAG( |
8559 | p->af_cap[afi] | |
8560 | [safi], | |
8561 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8562 | || CHECK_FLAG( | |
8563 | p->af_cap[afi] | |
8564 | [safi], | |
8565 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 8566 | if (CHECK_FLAG( |
8567 | p->af_cap | |
8568 | [afi] | |
8569 | [safi], | |
8570 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 8571 | && CHECK_FLAG( |
d62a17ae | 8572 | p->af_cap |
8573 | [afi] | |
8574 | [safi], | |
8575 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
8576 | json_object_boolean_true_add( |
8577 | json_sub, | |
8578 | "rxAdvertisedAndReceived"); | |
8579 | else if ( | |
8580 | CHECK_FLAG( | |
8581 | p->af_cap | |
8582 | [afi] | |
8583 | [safi], | |
8584 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
8585 | json_object_boolean_true_add( | |
8586 | json_sub, | |
8587 | "rxAdvertised"); | |
8588 | else if ( | |
8589 | CHECK_FLAG( | |
8590 | p->af_cap | |
8591 | [afi] | |
8592 | [safi], | |
8593 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8594 | json_object_boolean_true_add( | |
8595 | json_sub, | |
8596 | "rxReceived"); | |
d62a17ae | 8597 | } |
8598 | ||
05c7a1cc QY |
8599 | if (CHECK_FLAG( |
8600 | p->af_cap[afi] | |
8601 | [safi], | |
8602 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8603 | || CHECK_FLAG( | |
8604 | p->af_cap[afi] | |
8605 | [safi], | |
8606 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
8607 | || CHECK_FLAG( | |
8608 | p->af_cap[afi] | |
8609 | [safi], | |
8610 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8611 | || CHECK_FLAG( | |
8612 | p->af_cap[afi] | |
8613 | [safi], | |
8614 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8615 | json_object_object_add( | |
8616 | json_add, | |
8617 | print_store, | |
8618 | json_sub); | |
8619 | else | |
8620 | json_object_free( | |
8621 | json_sub); | |
8622 | } | |
8623 | ||
d62a17ae | 8624 | json_object_object_add( |
8625 | json_cap, "addPath", json_add); | |
8626 | } | |
8627 | ||
8628 | /* Dynamic */ | |
8629 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
8630 | || CHECK_FLAG(p->cap, | |
8631 | PEER_CAP_DYNAMIC_ADV)) { | |
8632 | if (CHECK_FLAG(p->cap, | |
8633 | PEER_CAP_DYNAMIC_ADV) | |
8634 | && CHECK_FLAG(p->cap, | |
8635 | PEER_CAP_DYNAMIC_RCV)) | |
8636 | json_object_string_add( | |
8637 | json_cap, "dynamic", | |
8638 | "advertisedAndReceived"); | |
8639 | else if (CHECK_FLAG( | |
8640 | p->cap, | |
8641 | PEER_CAP_DYNAMIC_ADV)) | |
8642 | json_object_string_add( | |
8643 | json_cap, "dynamic", | |
8644 | "advertised"); | |
8645 | else if (CHECK_FLAG( | |
8646 | p->cap, | |
8647 | PEER_CAP_DYNAMIC_RCV)) | |
8648 | json_object_string_add( | |
8649 | json_cap, "dynamic", | |
8650 | "received"); | |
8651 | } | |
8652 | ||
8653 | /* Extended nexthop */ | |
8654 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
8655 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
8656 | json_object *json_nxt = NULL; | |
8657 | const char *print_store; | |
8658 | ||
8659 | ||
8660 | if (CHECK_FLAG(p->cap, | |
8661 | PEER_CAP_ENHE_ADV) | |
8662 | && CHECK_FLAG(p->cap, | |
8663 | PEER_CAP_ENHE_RCV)) | |
8664 | json_object_string_add( | |
8665 | json_cap, | |
8666 | "extendedNexthop", | |
8667 | "advertisedAndReceived"); | |
8668 | else if (CHECK_FLAG(p->cap, | |
8669 | PEER_CAP_ENHE_ADV)) | |
8670 | json_object_string_add( | |
8671 | json_cap, | |
8672 | "extendedNexthop", | |
8673 | "advertised"); | |
8674 | else if (CHECK_FLAG(p->cap, | |
8675 | PEER_CAP_ENHE_RCV)) | |
8676 | json_object_string_add( | |
8677 | json_cap, | |
8678 | "extendedNexthop", | |
8679 | "received"); | |
8680 | ||
8681 | if (CHECK_FLAG(p->cap, | |
8682 | PEER_CAP_ENHE_RCV)) { | |
8683 | json_nxt = | |
8684 | json_object_new_object(); | |
8685 | ||
8686 | for (safi = SAFI_UNICAST; | |
8687 | safi < SAFI_MAX; safi++) { | |
8688 | if (CHECK_FLAG( | |
8689 | p->af_cap | |
8690 | [AFI_IP] | |
8691 | [safi], | |
8692 | PEER_CAP_ENHE_AF_RCV)) { | |
8693 | print_store = afi_safi_print( | |
8694 | AFI_IP, | |
8695 | safi); | |
8696 | json_object_string_add( | |
8697 | json_nxt, | |
8698 | print_store, | |
8699 | "recieved"); | |
8700 | } | |
8701 | } | |
8702 | json_object_object_add( | |
8703 | json_cap, | |
8704 | "extendedNexthopFamililesByPeer", | |
8705 | json_nxt); | |
8706 | } | |
8707 | } | |
8708 | ||
8709 | /* Route Refresh */ | |
8710 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
8711 | || CHECK_FLAG(p->cap, | |
8712 | PEER_CAP_REFRESH_NEW_RCV) | |
8713 | || CHECK_FLAG(p->cap, | |
8714 | PEER_CAP_REFRESH_OLD_RCV)) { | |
8715 | if (CHECK_FLAG(p->cap, | |
8716 | PEER_CAP_REFRESH_ADV) | |
8717 | && (CHECK_FLAG( | |
8718 | p->cap, | |
8719 | PEER_CAP_REFRESH_NEW_RCV) | |
8720 | || CHECK_FLAG( | |
8721 | p->cap, | |
8722 | PEER_CAP_REFRESH_OLD_RCV))) { | |
8723 | if (CHECK_FLAG( | |
8724 | p->cap, | |
8725 | PEER_CAP_REFRESH_OLD_RCV) | |
8726 | && CHECK_FLAG( | |
8727 | p->cap, | |
8728 | PEER_CAP_REFRESH_NEW_RCV)) | |
8729 | json_object_string_add( | |
8730 | json_cap, | |
8731 | "routeRefresh", | |
8732 | "advertisedAndReceivedOldNew"); | |
8733 | else { | |
8734 | if (CHECK_FLAG( | |
8735 | p->cap, | |
8736 | PEER_CAP_REFRESH_OLD_RCV)) | |
8737 | json_object_string_add( | |
8738 | json_cap, | |
8739 | "routeRefresh", | |
8740 | "advertisedAndReceivedOld"); | |
8741 | else | |
8742 | json_object_string_add( | |
8743 | json_cap, | |
8744 | "routeRefresh", | |
8745 | "advertisedAndReceivedNew"); | |
8746 | } | |
8747 | } else if ( | |
8748 | CHECK_FLAG( | |
8749 | p->cap, | |
8750 | PEER_CAP_REFRESH_ADV)) | |
8751 | json_object_string_add( | |
8752 | json_cap, | |
8753 | "routeRefresh", | |
8754 | "advertised"); | |
8755 | else if ( | |
8756 | CHECK_FLAG( | |
8757 | p->cap, | |
8758 | PEER_CAP_REFRESH_NEW_RCV) | |
8759 | || CHECK_FLAG( | |
8760 | p->cap, | |
8761 | PEER_CAP_REFRESH_OLD_RCV)) | |
8762 | json_object_string_add( | |
8763 | json_cap, | |
8764 | "routeRefresh", | |
8765 | "received"); | |
8766 | } | |
8767 | ||
8768 | /* Multiprotocol Extensions */ | |
8769 | json_object *json_multi = NULL; | |
8770 | json_multi = json_object_new_object(); | |
8771 | ||
05c7a1cc QY |
8772 | FOREACH_AFI_SAFI (afi, safi) { |
8773 | if (p->afc_adv[afi][safi] | |
8774 | || p->afc_recv[afi][safi]) { | |
8775 | json_object *json_exten = NULL; | |
8776 | json_exten = | |
8777 | json_object_new_object(); | |
8778 | ||
d62a17ae | 8779 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
8780 | && p->afc_recv[afi][safi]) |
8781 | json_object_boolean_true_add( | |
8782 | json_exten, | |
8783 | "advertisedAndReceived"); | |
8784 | else if (p->afc_adv[afi][safi]) | |
8785 | json_object_boolean_true_add( | |
8786 | json_exten, | |
8787 | "advertised"); | |
8788 | else if (p->afc_recv[afi][safi]) | |
8789 | json_object_boolean_true_add( | |
8790 | json_exten, | |
8791 | "received"); | |
d62a17ae | 8792 | |
05c7a1cc QY |
8793 | json_object_object_add( |
8794 | json_multi, | |
8795 | afi_safi_print(afi, | |
8796 | safi), | |
8797 | json_exten); | |
d62a17ae | 8798 | } |
8799 | } | |
8800 | json_object_object_add( | |
8801 | json_cap, "multiprotocolExtensions", | |
8802 | json_multi); | |
8803 | ||
d77114b7 | 8804 | /* Hostname capabilities */ |
60466a63 | 8805 | json_object *json_hname = NULL; |
d77114b7 MK |
8806 | |
8807 | json_hname = json_object_new_object(); | |
8808 | ||
8809 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
8810 | json_object_string_add( | |
60466a63 QY |
8811 | json_hname, "advHostName", |
8812 | bgp->peer_self->hostname | |
8813 | ? bgp->peer_self | |
8814 | ->hostname | |
d77114b7 MK |
8815 | : "n/a"); |
8816 | json_object_string_add( | |
60466a63 QY |
8817 | json_hname, "advDomainName", |
8818 | bgp->peer_self->domainname | |
8819 | ? bgp->peer_self | |
8820 | ->domainname | |
d77114b7 MK |
8821 | : "n/a"); |
8822 | } | |
8823 | ||
8824 | ||
8825 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
8826 | json_object_string_add( | |
60466a63 QY |
8827 | json_hname, "rcvHostName", |
8828 | p->hostname ? p->hostname | |
8829 | : "n/a"); | |
d77114b7 | 8830 | json_object_string_add( |
60466a63 QY |
8831 | json_hname, "rcvDomainName", |
8832 | p->domainname ? p->domainname | |
8833 | : "n/a"); | |
d77114b7 MK |
8834 | } |
8835 | ||
60466a63 | 8836 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
8837 | json_hname); |
8838 | ||
d62a17ae | 8839 | /* Gracefull Restart */ |
8840 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
8841 | || CHECK_FLAG(p->cap, | |
8842 | PEER_CAP_RESTART_ADV)) { | |
8843 | if (CHECK_FLAG(p->cap, | |
8844 | PEER_CAP_RESTART_ADV) | |
8845 | && CHECK_FLAG(p->cap, | |
8846 | PEER_CAP_RESTART_RCV)) | |
8847 | json_object_string_add( | |
8848 | json_cap, | |
8849 | "gracefulRestart", | |
8850 | "advertisedAndReceived"); | |
8851 | else if (CHECK_FLAG( | |
8852 | p->cap, | |
8853 | PEER_CAP_RESTART_ADV)) | |
8854 | json_object_string_add( | |
8855 | json_cap, | |
8856 | "gracefulRestartCapability", | |
8857 | "advertised"); | |
8858 | else if (CHECK_FLAG( | |
8859 | p->cap, | |
8860 | PEER_CAP_RESTART_RCV)) | |
8861 | json_object_string_add( | |
8862 | json_cap, | |
8863 | "gracefulRestartCapability", | |
8864 | "received"); | |
8865 | ||
8866 | if (CHECK_FLAG(p->cap, | |
8867 | PEER_CAP_RESTART_RCV)) { | |
8868 | int restart_af_count = 0; | |
8869 | json_object *json_restart = | |
8870 | NULL; | |
8871 | json_restart = | |
8872 | json_object_new_object(); | |
8873 | ||
8874 | json_object_int_add( | |
8875 | json_cap, | |
8876 | "gracefulRestartRemoteTimerMsecs", | |
8877 | p->v_gr_restart * 1000); | |
8878 | ||
05c7a1cc QY |
8879 | FOREACH_AFI_SAFI (afi, safi) { |
8880 | if (CHECK_FLAG( | |
8881 | p->af_cap | |
8882 | [afi] | |
8883 | [safi], | |
8884 | PEER_CAP_RESTART_AF_RCV)) { | |
8885 | json_object * | |
8886 | json_sub = | |
8887 | NULL; | |
8888 | json_sub = | |
8889 | json_object_new_object(); | |
8890 | ||
d62a17ae | 8891 | if (CHECK_FLAG( |
8892 | p->af_cap | |
8893 | [afi] | |
8894 | [safi], | |
05c7a1cc QY |
8895 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
8896 | json_object_boolean_true_add( | |
8897 | json_sub, | |
8898 | "preserved"); | |
8899 | restart_af_count++; | |
8900 | json_object_object_add( | |
8901 | json_restart, | |
8902 | afi_safi_print( | |
8903 | afi, | |
8904 | safi), | |
8905 | json_sub); | |
d62a17ae | 8906 | } |
8907 | } | |
8908 | if (!restart_af_count) { | |
8909 | json_object_string_add( | |
8910 | json_cap, | |
8911 | "addressFamiliesByPeer", | |
8912 | "none"); | |
8913 | json_object_free( | |
8914 | json_restart); | |
8915 | } else | |
8916 | json_object_object_add( | |
8917 | json_cap, | |
8918 | "addressFamiliesByPeer", | |
8919 | json_restart); | |
8920 | } | |
8921 | } | |
8922 | json_object_object_add(json_neigh, | |
8923 | "neighborCapabilities", | |
8924 | json_cap); | |
8925 | } else { | |
8926 | vty_out(vty, " Neighbor capabilities:\n"); | |
8927 | ||
8928 | /* AS4 */ | |
8929 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
8930 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
8931 | vty_out(vty, " 4 Byte AS:"); | |
8932 | if (CHECK_FLAG(p->cap, | |
8933 | PEER_CAP_AS4_ADV)) | |
8934 | vty_out(vty, " advertised"); | |
8935 | if (CHECK_FLAG(p->cap, | |
8936 | PEER_CAP_AS4_RCV)) | |
8937 | vty_out(vty, " %sreceived", | |
8938 | CHECK_FLAG( | |
8939 | p->cap, | |
8940 | PEER_CAP_AS4_ADV) | |
8941 | ? "and " | |
8942 | : ""); | |
8943 | vty_out(vty, "\n"); | |
8944 | } | |
8945 | ||
8946 | /* AddPath */ | |
8947 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
8948 | || CHECK_FLAG(p->cap, | |
8949 | PEER_CAP_ADDPATH_ADV)) { | |
8950 | vty_out(vty, " AddPath:\n"); | |
8951 | ||
05c7a1cc QY |
8952 | FOREACH_AFI_SAFI (afi, safi) { |
8953 | if (CHECK_FLAG( | |
8954 | p->af_cap[afi] | |
8955 | [safi], | |
8956 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8957 | || CHECK_FLAG( | |
8958 | p->af_cap[afi] | |
8959 | [safi], | |
8960 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
8961 | vty_out(vty, | |
8962 | " %s: TX ", | |
8963 | afi_safi_print( | |
8964 | afi, | |
8965 | safi)); | |
8966 | ||
d62a17ae | 8967 | if (CHECK_FLAG( |
8968 | p->af_cap | |
8969 | [afi] | |
8970 | [safi], | |
05c7a1cc | 8971 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 8972 | vty_out(vty, |
05c7a1cc | 8973 | "advertised %s", |
d62a17ae | 8974 | afi_safi_print( |
8975 | afi, | |
8976 | safi)); | |
8977 | ||
05c7a1cc QY |
8978 | if (CHECK_FLAG( |
8979 | p->af_cap | |
8980 | [afi] | |
8981 | [safi], | |
8982 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8983 | vty_out(vty, | |
8984 | "%sreceived", | |
8985 | CHECK_FLAG( | |
8986 | p->af_cap | |
8987 | [afi] | |
8988 | [safi], | |
8989 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8990 | ? " and " | |
8991 | : ""); | |
d62a17ae | 8992 | |
05c7a1cc QY |
8993 | vty_out(vty, "\n"); |
8994 | } | |
d62a17ae | 8995 | |
05c7a1cc QY |
8996 | if (CHECK_FLAG( |
8997 | p->af_cap[afi] | |
8998 | [safi], | |
8999 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9000 | || CHECK_FLAG( | |
9001 | p->af_cap[afi] | |
9002 | [safi], | |
9003 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
9004 | vty_out(vty, | |
9005 | " %s: RX ", | |
9006 | afi_safi_print( | |
9007 | afi, | |
9008 | safi)); | |
d62a17ae | 9009 | |
9010 | if (CHECK_FLAG( | |
9011 | p->af_cap | |
9012 | [afi] | |
9013 | [safi], | |
05c7a1cc | 9014 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 9015 | vty_out(vty, |
05c7a1cc | 9016 | "advertised %s", |
d62a17ae | 9017 | afi_safi_print( |
9018 | afi, | |
9019 | safi)); | |
9020 | ||
05c7a1cc QY |
9021 | if (CHECK_FLAG( |
9022 | p->af_cap | |
9023 | [afi] | |
9024 | [safi], | |
9025 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 9026 | vty_out(vty, |
05c7a1cc QY |
9027 | "%sreceived", |
9028 | CHECK_FLAG( | |
9029 | p->af_cap | |
9030 | [afi] | |
9031 | [safi], | |
9032 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9033 | ? " and " | |
9034 | : ""); | |
9035 | ||
9036 | vty_out(vty, "\n"); | |
d62a17ae | 9037 | } |
05c7a1cc | 9038 | } |
d62a17ae | 9039 | } |
9040 | ||
9041 | /* Dynamic */ | |
9042 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
9043 | || CHECK_FLAG(p->cap, | |
9044 | PEER_CAP_DYNAMIC_ADV)) { | |
9045 | vty_out(vty, " Dynamic:"); | |
9046 | if (CHECK_FLAG(p->cap, | |
9047 | PEER_CAP_DYNAMIC_ADV)) | |
9048 | vty_out(vty, " advertised"); | |
9049 | if (CHECK_FLAG(p->cap, | |
9050 | PEER_CAP_DYNAMIC_RCV)) | |
9051 | vty_out(vty, " %sreceived", | |
9052 | CHECK_FLAG( | |
9053 | p->cap, | |
9054 | PEER_CAP_DYNAMIC_ADV) | |
9055 | ? "and " | |
9056 | : ""); | |
9057 | vty_out(vty, "\n"); | |
9058 | } | |
9059 | ||
9060 | /* Extended nexthop */ | |
9061 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
9062 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
9063 | vty_out(vty, " Extended nexthop:"); | |
9064 | if (CHECK_FLAG(p->cap, | |
9065 | PEER_CAP_ENHE_ADV)) | |
9066 | vty_out(vty, " advertised"); | |
9067 | if (CHECK_FLAG(p->cap, | |
9068 | PEER_CAP_ENHE_RCV)) | |
9069 | vty_out(vty, " %sreceived", | |
9070 | CHECK_FLAG( | |
9071 | p->cap, | |
9072 | PEER_CAP_ENHE_ADV) | |
9073 | ? "and " | |
9074 | : ""); | |
9075 | vty_out(vty, "\n"); | |
9076 | ||
9077 | if (CHECK_FLAG(p->cap, | |
9078 | PEER_CAP_ENHE_RCV)) { | |
9079 | vty_out(vty, | |
9080 | " Address families by peer:\n "); | |
9081 | for (safi = SAFI_UNICAST; | |
9082 | safi < SAFI_MAX; safi++) | |
9083 | if (CHECK_FLAG( | |
9084 | p->af_cap | |
9085 | [AFI_IP] | |
9086 | [safi], | |
9087 | PEER_CAP_ENHE_AF_RCV)) | |
9088 | vty_out(vty, | |
9089 | " %s\n", | |
9090 | afi_safi_print( | |
9091 | AFI_IP, | |
9092 | safi)); | |
9093 | } | |
9094 | } | |
9095 | ||
9096 | /* Route Refresh */ | |
9097 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
9098 | || CHECK_FLAG(p->cap, | |
9099 | PEER_CAP_REFRESH_NEW_RCV) | |
9100 | || CHECK_FLAG(p->cap, | |
9101 | PEER_CAP_REFRESH_OLD_RCV)) { | |
9102 | vty_out(vty, " Route refresh:"); | |
9103 | if (CHECK_FLAG(p->cap, | |
9104 | PEER_CAP_REFRESH_ADV)) | |
9105 | vty_out(vty, " advertised"); | |
9106 | if (CHECK_FLAG(p->cap, | |
9107 | PEER_CAP_REFRESH_NEW_RCV) | |
9108 | || CHECK_FLAG( | |
9109 | p->cap, | |
9110 | PEER_CAP_REFRESH_OLD_RCV)) | |
9111 | vty_out(vty, " %sreceived(%s)", | |
9112 | CHECK_FLAG( | |
9113 | p->cap, | |
9114 | PEER_CAP_REFRESH_ADV) | |
9115 | ? "and " | |
9116 | : "", | |
9117 | (CHECK_FLAG( | |
9118 | p->cap, | |
9119 | PEER_CAP_REFRESH_OLD_RCV) | |
9120 | && CHECK_FLAG( | |
9121 | p->cap, | |
9122 | PEER_CAP_REFRESH_NEW_RCV)) | |
9123 | ? "old & new" | |
9124 | : CHECK_FLAG( | |
9125 | p->cap, | |
9126 | PEER_CAP_REFRESH_OLD_RCV) | |
9127 | ? "old" | |
9128 | : "new"); | |
9129 | ||
9130 | vty_out(vty, "\n"); | |
9131 | } | |
9132 | ||
9133 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
9134 | FOREACH_AFI_SAFI (afi, safi) |
9135 | if (p->afc_adv[afi][safi] | |
9136 | || p->afc_recv[afi][safi]) { | |
9137 | vty_out(vty, | |
9138 | " Address Family %s:", | |
9139 | afi_safi_print(afi, | |
9140 | safi)); | |
9141 | if (p->afc_adv[afi][safi]) | |
d62a17ae | 9142 | vty_out(vty, |
05c7a1cc QY |
9143 | " advertised"); |
9144 | if (p->afc_recv[afi][safi]) | |
9145 | vty_out(vty, | |
9146 | " %sreceived", | |
9147 | p->afc_adv[afi] | |
9148 | [safi] | |
9149 | ? "and " | |
9150 | : ""); | |
9151 | vty_out(vty, "\n"); | |
9152 | } | |
d62a17ae | 9153 | |
9154 | /* Hostname capability */ | |
60466a63 | 9155 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
9156 | |
9157 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
9158 | vty_out(vty, |
9159 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
9160 | bgp->peer_self->hostname |
9161 | ? bgp->peer_self | |
9162 | ->hostname | |
d77114b7 | 9163 | : "n/a", |
60466a63 QY |
9164 | bgp->peer_self->domainname |
9165 | ? bgp->peer_self | |
9166 | ->domainname | |
d77114b7 MK |
9167 | : "n/a"); |
9168 | } else { | |
9169 | vty_out(vty, " not advertised"); | |
d62a17ae | 9170 | } |
9171 | ||
d77114b7 | 9172 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
9173 | vty_out(vty, |
9174 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
9175 | p->hostname ? p->hostname |
9176 | : "n/a", | |
9177 | p->domainname ? p->domainname | |
9178 | : "n/a"); | |
d77114b7 MK |
9179 | } else { |
9180 | vty_out(vty, " not received"); | |
9181 | } | |
9182 | ||
9183 | vty_out(vty, "\n"); | |
9184 | ||
d62a17ae | 9185 | /* Gracefull Restart */ |
9186 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
9187 | || CHECK_FLAG(p->cap, | |
9188 | PEER_CAP_RESTART_ADV)) { | |
9189 | vty_out(vty, | |
9190 | " Graceful Restart Capabilty:"); | |
9191 | if (CHECK_FLAG(p->cap, | |
9192 | PEER_CAP_RESTART_ADV)) | |
9193 | vty_out(vty, " advertised"); | |
9194 | if (CHECK_FLAG(p->cap, | |
9195 | PEER_CAP_RESTART_RCV)) | |
9196 | vty_out(vty, " %sreceived", | |
9197 | CHECK_FLAG( | |
9198 | p->cap, | |
9199 | PEER_CAP_RESTART_ADV) | |
9200 | ? "and " | |
9201 | : ""); | |
9202 | vty_out(vty, "\n"); | |
9203 | ||
9204 | if (CHECK_FLAG(p->cap, | |
9205 | PEER_CAP_RESTART_RCV)) { | |
9206 | int restart_af_count = 0; | |
9207 | ||
9208 | vty_out(vty, | |
9209 | " Remote Restart timer is %d seconds\n", | |
9210 | p->v_gr_restart); | |
9211 | vty_out(vty, | |
9212 | " Address families by peer:\n "); | |
9213 | ||
05c7a1cc QY |
9214 | FOREACH_AFI_SAFI (afi, safi) |
9215 | if (CHECK_FLAG( | |
9216 | p->af_cap | |
9217 | [afi] | |
9218 | [safi], | |
9219 | PEER_CAP_RESTART_AF_RCV)) { | |
9220 | vty_out(vty, | |
9221 | "%s%s(%s)", | |
9222 | restart_af_count | |
9223 | ? ", " | |
9224 | : "", | |
9225 | afi_safi_print( | |
9226 | afi, | |
9227 | safi), | |
9228 | CHECK_FLAG( | |
9229 | p->af_cap | |
9230 | [afi] | |
9231 | [safi], | |
9232 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
9233 | ? "preserved" | |
9234 | : "not preserved"); | |
9235 | restart_af_count++; | |
9236 | } | |
d62a17ae | 9237 | if (!restart_af_count) |
9238 | vty_out(vty, "none"); | |
9239 | vty_out(vty, "\n"); | |
9240 | } | |
9241 | } | |
9242 | } | |
9243 | } | |
9244 | } | |
9245 | ||
9246 | /* graceful restart information */ | |
9247 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || p->t_gr_restart | |
9248 | || p->t_gr_stale) { | |
9249 | json_object *json_grace = NULL; | |
9250 | json_object *json_grace_send = NULL; | |
9251 | json_object *json_grace_recv = NULL; | |
9252 | int eor_send_af_count = 0; | |
9253 | int eor_receive_af_count = 0; | |
9254 | ||
9255 | if (use_json) { | |
9256 | json_grace = json_object_new_object(); | |
9257 | json_grace_send = json_object_new_object(); | |
9258 | json_grace_recv = json_object_new_object(); | |
9259 | ||
9260 | if (p->status == Established) { | |
05c7a1cc QY |
9261 | FOREACH_AFI_SAFI (afi, safi) { |
9262 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9263 | PEER_STATUS_EOR_SEND)) { | |
9264 | json_object_boolean_true_add( | |
9265 | json_grace_send, | |
9266 | afi_safi_print(afi, | |
9267 | safi)); | |
9268 | eor_send_af_count++; | |
d62a17ae | 9269 | } |
9270 | } | |
05c7a1cc QY |
9271 | FOREACH_AFI_SAFI (afi, safi) { |
9272 | if (CHECK_FLAG( | |
9273 | p->af_sflags[afi][safi], | |
9274 | PEER_STATUS_EOR_RECEIVED)) { | |
9275 | json_object_boolean_true_add( | |
9276 | json_grace_recv, | |
9277 | afi_safi_print(afi, | |
9278 | safi)); | |
9279 | eor_receive_af_count++; | |
d62a17ae | 9280 | } |
9281 | } | |
9282 | } | |
9283 | ||
9284 | json_object_object_add(json_grace, "endOfRibSend", | |
9285 | json_grace_send); | |
9286 | json_object_object_add(json_grace, "endOfRibRecv", | |
9287 | json_grace_recv); | |
9288 | ||
9289 | if (p->t_gr_restart) | |
9290 | json_object_int_add(json_grace, | |
9291 | "gracefulRestartTimerMsecs", | |
9292 | thread_timer_remain_second( | |
9293 | p->t_gr_restart) | |
9294 | * 1000); | |
9295 | ||
9296 | if (p->t_gr_stale) | |
9297 | json_object_int_add( | |
9298 | json_grace, | |
9299 | "gracefulStalepathTimerMsecs", | |
9300 | thread_timer_remain_second( | |
9301 | p->t_gr_stale) | |
9302 | * 1000); | |
9303 | ||
9304 | json_object_object_add( | |
9305 | json_neigh, "gracefulRestartInfo", json_grace); | |
9306 | } else { | |
9307 | vty_out(vty, " Graceful restart informations:\n"); | |
9308 | if (p->status == Established) { | |
9309 | vty_out(vty, " End-of-RIB send: "); | |
05c7a1cc QY |
9310 | FOREACH_AFI_SAFI (afi, safi) { |
9311 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9312 | PEER_STATUS_EOR_SEND)) { | |
9313 | vty_out(vty, "%s%s", | |
9314 | eor_send_af_count ? ", " | |
9315 | : "", | |
9316 | afi_safi_print(afi, | |
9317 | safi)); | |
9318 | eor_send_af_count++; | |
d62a17ae | 9319 | } |
9320 | } | |
9321 | vty_out(vty, "\n"); | |
9322 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
9323 | FOREACH_AFI_SAFI (afi, safi) { |
9324 | if (CHECK_FLAG( | |
9325 | p->af_sflags[afi][safi], | |
9326 | PEER_STATUS_EOR_RECEIVED)) { | |
9327 | vty_out(vty, "%s%s", | |
9328 | eor_receive_af_count | |
9329 | ? ", " | |
9330 | : "", | |
9331 | afi_safi_print(afi, | |
9332 | safi)); | |
9333 | eor_receive_af_count++; | |
d62a17ae | 9334 | } |
9335 | } | |
9336 | vty_out(vty, "\n"); | |
9337 | } | |
9338 | ||
9339 | if (p->t_gr_restart) | |
9340 | vty_out(vty, | |
9341 | " The remaining time of restart timer is %ld\n", | |
9342 | thread_timer_remain_second( | |
9343 | p->t_gr_restart)); | |
9344 | ||
9345 | if (p->t_gr_stale) | |
9346 | vty_out(vty, | |
9347 | " The remaining time of stalepath timer is %ld\n", | |
9348 | thread_timer_remain_second( | |
9349 | p->t_gr_stale)); | |
9350 | } | |
9351 | } | |
9352 | if (use_json) { | |
9353 | json_object *json_stat = NULL; | |
9354 | json_stat = json_object_new_object(); | |
9355 | /* Packet counts. */ | |
9356 | json_object_int_add(json_stat, "depthInq", 0); | |
9357 | json_object_int_add(json_stat, "depthOutq", | |
9358 | (unsigned long)p->obuf->count); | |
0112e9e0 QY |
9359 | json_object_int_add(json_stat, "opensSent", |
9360 | atomic_load_explicit(&p->open_out, | |
9361 | memory_order_relaxed)); | |
9362 | json_object_int_add(json_stat, "opensRecv", | |
9363 | atomic_load_explicit(&p->open_in, | |
9364 | memory_order_relaxed)); | |
d62a17ae | 9365 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
9366 | atomic_load_explicit(&p->notify_out, |
9367 | memory_order_relaxed)); | |
d62a17ae | 9368 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
9369 | atomic_load_explicit(&p->notify_in, |
9370 | memory_order_relaxed)); | |
9371 | json_object_int_add(json_stat, "updatesSent", | |
9372 | atomic_load_explicit(&p->update_out, | |
9373 | memory_order_relaxed)); | |
9374 | json_object_int_add(json_stat, "updatesRecv", | |
9375 | atomic_load_explicit(&p->update_in, | |
9376 | memory_order_relaxed)); | |
d62a17ae | 9377 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
9378 | atomic_load_explicit(&p->keepalive_out, |
9379 | memory_order_relaxed)); | |
d62a17ae | 9380 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
9381 | atomic_load_explicit(&p->keepalive_in, |
9382 | memory_order_relaxed)); | |
d62a17ae | 9383 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
9384 | atomic_load_explicit(&p->refresh_out, |
9385 | memory_order_relaxed)); | |
d62a17ae | 9386 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
9387 | atomic_load_explicit(&p->refresh_in, |
9388 | memory_order_relaxed)); | |
d62a17ae | 9389 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
9390 | atomic_load_explicit(&p->dynamic_cap_out, |
9391 | memory_order_relaxed)); | |
d62a17ae | 9392 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
9393 | atomic_load_explicit(&p->dynamic_cap_in, |
9394 | memory_order_relaxed)); | |
9395 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
9396 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 9397 | json_object_object_add(json_neigh, "messageStats", json_stat); |
9398 | } else { | |
9399 | /* Packet counts. */ | |
9400 | vty_out(vty, " Message statistics:\n"); | |
9401 | vty_out(vty, " Inq depth is 0\n"); | |
9402 | vty_out(vty, " Outq depth is %lu\n", | |
9403 | (unsigned long)p->obuf->count); | |
9404 | vty_out(vty, " Sent Rcvd\n"); | |
0112e9e0 QY |
9405 | vty_out(vty, " Opens: %10d %10d\n", |
9406 | atomic_load_explicit(&p->open_out, | |
9407 | memory_order_relaxed), | |
9408 | atomic_load_explicit(&p->open_in, | |
9409 | memory_order_relaxed)); | |
9410 | vty_out(vty, " Notifications: %10d %10d\n", | |
9411 | atomic_load_explicit(&p->notify_out, | |
9412 | memory_order_relaxed), | |
9413 | atomic_load_explicit(&p->notify_in, | |
9414 | memory_order_relaxed)); | |
9415 | vty_out(vty, " Updates: %10d %10d\n", | |
9416 | atomic_load_explicit(&p->update_out, | |
9417 | memory_order_relaxed), | |
9418 | atomic_load_explicit(&p->update_in, | |
9419 | memory_order_relaxed)); | |
9420 | vty_out(vty, " Keepalives: %10d %10d\n", | |
9421 | atomic_load_explicit(&p->keepalive_out, | |
9422 | memory_order_relaxed), | |
9423 | atomic_load_explicit(&p->keepalive_in, | |
9424 | memory_order_relaxed)); | |
9425 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
9426 | atomic_load_explicit(&p->refresh_out, | |
9427 | memory_order_relaxed), | |
9428 | atomic_load_explicit(&p->refresh_in, | |
9429 | memory_order_relaxed)); | |
d62a17ae | 9430 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
9431 | atomic_load_explicit(&p->dynamic_cap_out, |
9432 | memory_order_relaxed), | |
9433 | atomic_load_explicit(&p->dynamic_cap_in, | |
9434 | memory_order_relaxed)); | |
9435 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
9436 | PEER_TOTAL_RX(p)); | |
d62a17ae | 9437 | } |
9438 | ||
9439 | if (use_json) { | |
9440 | /* advertisement-interval */ | |
9441 | json_object_int_add(json_neigh, | |
9442 | "minBtwnAdvertisementRunsTimerMsecs", | |
9443 | p->v_routeadv * 1000); | |
9444 | ||
9445 | /* Update-source. */ | |
9446 | if (p->update_if || p->update_source) { | |
9447 | if (p->update_if) | |
9448 | json_object_string_add(json_neigh, | |
9449 | "updateSource", | |
9450 | p->update_if); | |
9451 | else if (p->update_source) | |
9452 | json_object_string_add( | |
9453 | json_neigh, "updateSource", | |
9454 | sockunion2str(p->update_source, buf1, | |
9455 | SU_ADDRSTRLEN)); | |
9456 | } | |
9457 | } else { | |
9458 | /* advertisement-interval */ | |
9459 | vty_out(vty, | |
9460 | " Minimum time between advertisement runs is %d seconds\n", | |
9461 | p->v_routeadv); | |
9462 | ||
9463 | /* Update-source. */ | |
9464 | if (p->update_if || p->update_source) { | |
9465 | vty_out(vty, " Update source is "); | |
9466 | if (p->update_if) | |
9467 | vty_out(vty, "%s", p->update_if); | |
9468 | else if (p->update_source) | |
9469 | vty_out(vty, "%s", | |
9470 | sockunion2str(p->update_source, buf1, | |
9471 | SU_ADDRSTRLEN)); | |
9472 | vty_out(vty, "\n"); | |
9473 | } | |
9474 | ||
9475 | vty_out(vty, "\n"); | |
9476 | } | |
9477 | ||
9478 | /* Address Family Information */ | |
9479 | json_object *json_hold = NULL; | |
9480 | ||
9481 | if (use_json) | |
9482 | json_hold = json_object_new_object(); | |
9483 | ||
05c7a1cc QY |
9484 | FOREACH_AFI_SAFI (afi, safi) |
9485 | if (p->afc[afi][safi]) | |
9486 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
9487 | json_hold); | |
d62a17ae | 9488 | |
9489 | if (use_json) { | |
9490 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
9491 | json_hold); | |
9492 | json_object_int_add(json_neigh, "connectionsEstablished", | |
9493 | p->established); | |
9494 | json_object_int_add(json_neigh, "connectionsDropped", | |
9495 | p->dropped); | |
9496 | } else | |
9497 | vty_out(vty, " Connections established %d; dropped %d\n", | |
9498 | p->established, p->dropped); | |
9499 | ||
9500 | if (!p->last_reset) { | |
9501 | if (use_json) | |
9502 | json_object_string_add(json_neigh, "lastReset", | |
9503 | "never"); | |
9504 | else | |
9505 | vty_out(vty, " Last reset never\n"); | |
9506 | } else { | |
9507 | if (use_json) { | |
9508 | time_t uptime; | |
9509 | struct tm *tm; | |
9510 | ||
9511 | uptime = bgp_clock(); | |
9512 | uptime -= p->resettime; | |
9513 | tm = gmtime(&uptime); | |
9514 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
9515 | (tm->tm_sec * 1000) | |
9516 | + (tm->tm_min * 60000) | |
9517 | + (tm->tm_hour * 3600000)); | |
9518 | json_object_string_add( | |
9519 | json_neigh, "lastResetDueTo", | |
9520 | peer_down_str[(int)p->last_reset]); | |
9521 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
9522 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
9523 | char errorcodesubcode_hexstr[5]; | |
9524 | char errorcodesubcode_str[256]; | |
9525 | ||
9526 | code_str = bgp_notify_code_str(p->notify.code); | |
9527 | subcode_str = bgp_notify_subcode_str( | |
9528 | p->notify.code, p->notify.subcode); | |
9529 | ||
9530 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
9531 | p->notify.code, p->notify.subcode); | |
9532 | json_object_string_add(json_neigh, | |
9533 | "lastErrorCodeSubcode", | |
9534 | errorcodesubcode_hexstr); | |
9535 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
9536 | code_str, subcode_str); | |
9537 | json_object_string_add(json_neigh, | |
9538 | "lastNotificationReason", | |
9539 | errorcodesubcode_str); | |
9540 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
9541 | && p->notify.code == BGP_NOTIFY_CEASE | |
9542 | && (p->notify.subcode | |
9543 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
9544 | || p->notify.subcode | |
9545 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
9546 | && p->notify.length) { | |
9547 | char msgbuf[1024]; | |
9548 | const char *msg_str; | |
9549 | ||
9550 | msg_str = bgp_notify_admin_message( | |
9551 | msgbuf, sizeof(msgbuf), | |
9552 | (u_char *)p->notify.data, | |
9553 | p->notify.length); | |
9554 | if (msg_str) | |
9555 | json_object_string_add( | |
9556 | json_neigh, | |
9557 | "lastShutdownDescription", | |
9558 | msg_str); | |
9559 | } | |
9560 | } | |
9561 | } else { | |
9562 | vty_out(vty, " Last reset %s, ", | |
9563 | peer_uptime(p->resettime, timebuf, | |
9564 | BGP_UPTIME_LEN, 0, NULL)); | |
9565 | ||
9566 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
9567 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
9568 | code_str = bgp_notify_code_str(p->notify.code); | |
9569 | subcode_str = bgp_notify_subcode_str( | |
9570 | p->notify.code, p->notify.subcode); | |
9571 | vty_out(vty, "due to NOTIFICATION %s (%s%s)\n", | |
9572 | p->last_reset == PEER_DOWN_NOTIFY_SEND | |
9573 | ? "sent" | |
9574 | : "received", | |
9575 | code_str, subcode_str); | |
9576 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
9577 | && p->notify.code == BGP_NOTIFY_CEASE | |
9578 | && (p->notify.subcode | |
9579 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
9580 | || p->notify.subcode | |
9581 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
9582 | && p->notify.length) { | |
9583 | char msgbuf[1024]; | |
9584 | const char *msg_str; | |
9585 | ||
9586 | msg_str = bgp_notify_admin_message( | |
9587 | msgbuf, sizeof(msgbuf), | |
9588 | (u_char *)p->notify.data, | |
9589 | p->notify.length); | |
9590 | if (msg_str) | |
9591 | vty_out(vty, | |
9592 | " Message: \"%s\"\n", | |
9593 | msg_str); | |
9594 | } | |
9595 | } else { | |
9596 | vty_out(vty, "due to %s\n", | |
9597 | peer_down_str[(int)p->last_reset]); | |
9598 | } | |
9599 | ||
9600 | if (p->last_reset_cause_size) { | |
9601 | msg = p->last_reset_cause; | |
9602 | vty_out(vty, | |
9603 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
9604 | for (i = 1; i <= p->last_reset_cause_size; | |
9605 | i++) { | |
9606 | vty_out(vty, "%02X", *msg++); | |
9607 | ||
9608 | if (i != p->last_reset_cause_size) { | |
9609 | if (i % 16 == 0) { | |
9610 | vty_out(vty, "\n "); | |
9611 | } else if (i % 4 == 0) { | |
9612 | vty_out(vty, " "); | |
9613 | } | |
9614 | } | |
9615 | } | |
9616 | vty_out(vty, "\n"); | |
9617 | } | |
9618 | } | |
9619 | } | |
9620 | ||
9621 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
9622 | if (use_json) | |
9623 | json_object_boolean_true_add(json_neigh, | |
9624 | "prefixesConfigExceedMax"); | |
9625 | else | |
9626 | vty_out(vty, | |
9627 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
9628 | ||
9629 | if (p->t_pmax_restart) { | |
9630 | if (use_json) { | |
9631 | json_object_boolean_true_add( | |
9632 | json_neigh, "reducePrefixNumFrom"); | |
9633 | json_object_int_add(json_neigh, | |
9634 | "restartInTimerMsec", | |
9635 | thread_timer_remain_second( | |
9636 | p->t_pmax_restart) | |
9637 | * 1000); | |
9638 | } else | |
9639 | vty_out(vty, | |
9640 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
a4d82a8a PZ |
9641 | p->host, |
9642 | thread_timer_remain_second( | |
9643 | p->t_pmax_restart)); | |
d62a17ae | 9644 | } else { |
9645 | if (use_json) | |
9646 | json_object_boolean_true_add( | |
9647 | json_neigh, | |
9648 | "reducePrefixNumAndClearIpBgp"); | |
9649 | else | |
9650 | vty_out(vty, | |
9651 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
9652 | p->host); | |
9653 | } | |
9654 | } | |
9655 | ||
9656 | /* EBGP Multihop and GTSM */ | |
9657 | if (p->sort != BGP_PEER_IBGP) { | |
9658 | if (use_json) { | |
9659 | if (p->gtsm_hops > 0) | |
9660 | json_object_int_add(json_neigh, | |
9661 | "externalBgpNbrMaxHopsAway", | |
9662 | p->gtsm_hops); | |
9663 | else if (p->ttl > 1) | |
9664 | json_object_int_add(json_neigh, | |
9665 | "externalBgpNbrMaxHopsAway", | |
9666 | p->ttl); | |
9667 | } else { | |
9668 | if (p->gtsm_hops > 0) | |
9669 | vty_out(vty, | |
9670 | " External BGP neighbor may be up to %d hops away.\n", | |
9671 | p->gtsm_hops); | |
9672 | else if (p->ttl > 1) | |
9673 | vty_out(vty, | |
9674 | " External BGP neighbor may be up to %d hops away.\n", | |
9675 | p->ttl); | |
9676 | } | |
9677 | } else { | |
9678 | if (p->gtsm_hops > 0) { | |
9679 | if (use_json) | |
9680 | json_object_int_add(json_neigh, | |
9681 | "internalBgpNbrMaxHopsAway", | |
9682 | p->gtsm_hops); | |
9683 | else | |
9684 | vty_out(vty, | |
9685 | " Internal BGP neighbor may be up to %d hops away.\n", | |
9686 | p->gtsm_hops); | |
9687 | } | |
9688 | } | |
9689 | ||
9690 | /* Local address. */ | |
9691 | if (p->su_local) { | |
9692 | if (use_json) { | |
9693 | json_object_string_add(json_neigh, "hostLocal", | |
9694 | sockunion2str(p->su_local, buf1, | |
9695 | SU_ADDRSTRLEN)); | |
9696 | json_object_int_add(json_neigh, "portLocal", | |
9697 | ntohs(p->su_local->sin.sin_port)); | |
9698 | } else | |
9699 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
9700 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
9701 | ntohs(p->su_local->sin.sin_port)); | |
9702 | } | |
9703 | ||
9704 | /* Remote address. */ | |
9705 | if (p->su_remote) { | |
9706 | if (use_json) { | |
9707 | json_object_string_add(json_neigh, "hostForeign", | |
9708 | sockunion2str(p->su_remote, buf1, | |
9709 | SU_ADDRSTRLEN)); | |
9710 | json_object_int_add(json_neigh, "portForeign", | |
9711 | ntohs(p->su_remote->sin.sin_port)); | |
9712 | } else | |
9713 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
9714 | sockunion2str(p->su_remote, buf1, | |
9715 | SU_ADDRSTRLEN), | |
9716 | ntohs(p->su_remote->sin.sin_port)); | |
9717 | } | |
9718 | ||
9719 | /* Nexthop display. */ | |
9720 | if (p->su_local) { | |
9721 | if (use_json) { | |
9722 | json_object_string_add(json_neigh, "nexthop", | |
9723 | inet_ntop(AF_INET, | |
9724 | &p->nexthop.v4, buf1, | |
9725 | sizeof(buf1))); | |
9726 | json_object_string_add(json_neigh, "nexthopGlobal", | |
9727 | inet_ntop(AF_INET6, | |
9728 | &p->nexthop.v6_global, | |
9729 | buf1, sizeof(buf1))); | |
9730 | json_object_string_add(json_neigh, "nexthopLocal", | |
9731 | inet_ntop(AF_INET6, | |
9732 | &p->nexthop.v6_local, | |
9733 | buf1, sizeof(buf1))); | |
9734 | if (p->shared_network) | |
9735 | json_object_string_add(json_neigh, | |
9736 | "bgpConnection", | |
9737 | "sharedNetwork"); | |
9738 | else | |
9739 | json_object_string_add(json_neigh, | |
9740 | "bgpConnection", | |
9741 | "nonSharedNetwork"); | |
9742 | } else { | |
9743 | vty_out(vty, "Nexthop: %s\n", | |
9744 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
9745 | sizeof(buf1))); | |
9746 | vty_out(vty, "Nexthop global: %s\n", | |
9747 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
9748 | sizeof(buf1))); | |
9749 | vty_out(vty, "Nexthop local: %s\n", | |
9750 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
9751 | sizeof(buf1))); | |
9752 | vty_out(vty, "BGP connection: %s\n", | |
9753 | p->shared_network ? "shared network" | |
9754 | : "non shared network"); | |
9755 | } | |
9756 | } | |
9757 | ||
9758 | /* Timer information. */ | |
9759 | if (use_json) { | |
9760 | json_object_int_add(json_neigh, "connectRetryTimer", | |
9761 | p->v_connect); | |
9762 | if (p->status == Established && p->rtt) | |
9763 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
9764 | p->rtt); | |
9765 | if (p->t_start) | |
9766 | json_object_int_add( | |
9767 | json_neigh, "nextStartTimerDueInMsecs", | |
9768 | thread_timer_remain_second(p->t_start) * 1000); | |
9769 | if (p->t_connect) | |
9770 | json_object_int_add( | |
9771 | json_neigh, "nextConnectTimerDueInMsecs", | |
9772 | thread_timer_remain_second(p->t_connect) | |
9773 | * 1000); | |
9774 | if (p->t_routeadv) { | |
9775 | json_object_int_add(json_neigh, "mraiInterval", | |
9776 | p->v_routeadv); | |
9777 | json_object_int_add( | |
9778 | json_neigh, "mraiTimerExpireInMsecs", | |
9779 | thread_timer_remain_second(p->t_routeadv) | |
9780 | * 1000); | |
9781 | } | |
9782 | if (p->password) | |
9783 | json_object_int_add(json_neigh, "authenticationEnabled", | |
9784 | 1); | |
9785 | ||
9786 | if (p->t_read) | |
9787 | json_object_string_add(json_neigh, "readThread", "on"); | |
9788 | else | |
9789 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
9790 | |
9791 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 9792 | json_object_string_add(json_neigh, "writeThread", "on"); |
9793 | else | |
9794 | json_object_string_add(json_neigh, "writeThread", | |
9795 | "off"); | |
9796 | } else { | |
9797 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
9798 | p->v_connect); | |
9799 | if (p->status == Established && p->rtt) | |
9800 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
9801 | p->rtt); | |
9802 | if (p->t_start) | |
9803 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
9804 | thread_timer_remain_second(p->t_start)); | |
9805 | if (p->t_connect) | |
9806 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
9807 | thread_timer_remain_second(p->t_connect)); | |
9808 | if (p->t_routeadv) | |
9809 | vty_out(vty, | |
9810 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
9811 | p->v_routeadv, | |
9812 | thread_timer_remain_second(p->t_routeadv)); | |
9813 | if (p->password) | |
9814 | vty_out(vty, "Peer Authentication Enabled\n"); | |
9815 | ||
9816 | vty_out(vty, "Read thread: %s Write thread: %s\n", | |
49507a6f QY |
9817 | p->t_read ? "on" : "off", |
9818 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
9819 | ? "on" | |
9820 | : "off"); | |
d62a17ae | 9821 | } |
9822 | ||
9823 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
9824 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
9825 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
9826 | ||
9827 | if (!use_json) | |
9828 | vty_out(vty, "\n"); | |
9829 | ||
9830 | /* BFD information. */ | |
9831 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
9832 | ||
9833 | if (use_json) { | |
9834 | if (p->conf_if) /* Configured interface name. */ | |
9835 | json_object_object_add(json, p->conf_if, json_neigh); | |
9836 | else /* Configured IP address. */ | |
9837 | json_object_object_add(json, p->host, json_neigh); | |
9838 | } | |
9839 | } | |
9840 | ||
9841 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, | |
9842 | enum show_type type, union sockunion *su, | |
9843 | const char *conf_if, u_char use_json, | |
9844 | json_object *json) | |
9845 | { | |
9846 | struct listnode *node, *nnode; | |
9847 | struct peer *peer; | |
9848 | int find = 0; | |
9849 | ||
9850 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
9851 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
9852 | continue; | |
9853 | ||
9854 | switch (type) { | |
9855 | case show_all: | |
9856 | bgp_show_peer(vty, peer, use_json, json); | |
9857 | break; | |
9858 | case show_peer: | |
9859 | if (conf_if) { | |
9860 | if ((peer->conf_if | |
9861 | && !strcmp(peer->conf_if, conf_if)) | |
9862 | || (peer->hostname | |
9863 | && !strcmp(peer->hostname, conf_if))) { | |
9864 | find = 1; | |
9865 | bgp_show_peer(vty, peer, use_json, | |
9866 | json); | |
9867 | } | |
9868 | } else { | |
9869 | if (sockunion_same(&peer->su, su)) { | |
9870 | find = 1; | |
9871 | bgp_show_peer(vty, peer, use_json, | |
9872 | json); | |
9873 | } | |
9874 | } | |
9875 | break; | |
9876 | } | |
9877 | } | |
9878 | ||
9879 | if (type == show_peer && !find) { | |
9880 | if (use_json) | |
9881 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
9882 | else | |
9883 | vty_out(vty, "%% No such neighbor\n"); | |
9884 | } | |
9885 | ||
9886 | if (use_json) { | |
a4d82a8a PZ |
9887 | vty_out(vty, "%s\n", |
9888 | json_object_to_json_string_ext( | |
9889 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9890 | json_object_free(json); |
9891 | } else { | |
9892 | vty_out(vty, "\n"); | |
9893 | } | |
9894 | ||
9895 | return CMD_SUCCESS; | |
9896 | } | |
9897 | ||
9898 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, | |
71aedaa3 DS |
9899 | enum show_type type, |
9900 | const char *ip_str, | |
d62a17ae | 9901 | u_char use_json) |
9902 | { | |
0291c246 MK |
9903 | struct listnode *node, *nnode; |
9904 | struct bgp *bgp; | |
71aedaa3 | 9905 | union sockunion su; |
0291c246 | 9906 | json_object *json = NULL; |
71aedaa3 | 9907 | int ret, is_first = 1; |
d62a17ae | 9908 | |
9909 | if (use_json) | |
9910 | vty_out(vty, "{\n"); | |
9911 | ||
9912 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9913 | if (use_json) { | |
9914 | if (!(json = json_object_new_object())) { | |
9915 | zlog_err( | |
9916 | "Unable to allocate memory for JSON object"); | |
9917 | vty_out(vty, | |
9918 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
9919 | return; | |
9920 | } | |
9921 | ||
9922 | json_object_int_add(json, "vrfId", | |
9923 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
9924 | ? -1 |
9925 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 9926 | json_object_string_add( |
9927 | json, "vrfName", | |
9928 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9929 | ? "Default" | |
9930 | : bgp->name); | |
9931 | ||
9932 | if (!is_first) | |
9933 | vty_out(vty, ",\n"); | |
9934 | else | |
9935 | is_first = 0; | |
9936 | ||
9937 | vty_out(vty, "\"%s\":", | |
9938 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9939 | ? "Default" | |
9940 | : bgp->name); | |
9941 | } else { | |
9942 | vty_out(vty, "\nInstance %s:\n", | |
9943 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9944 | ? "Default" | |
9945 | : bgp->name); | |
9946 | } | |
71aedaa3 DS |
9947 | |
9948 | if (type == show_peer) { | |
9949 | ret = str2sockunion(ip_str, &su); | |
9950 | if (ret < 0) | |
9951 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
9952 | use_json, json); | |
9953 | else | |
9954 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
9955 | use_json, json); | |
9956 | } else { | |
9957 | bgp_show_neighbor(vty, bgp, show_all, NULL, NULL, | |
9958 | use_json, json); | |
9959 | } | |
d62a17ae | 9960 | } |
9961 | ||
9962 | if (use_json) | |
9963 | vty_out(vty, "}\n"); | |
9964 | } | |
9965 | ||
9966 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
9967 | enum show_type type, const char *ip_str, | |
9968 | u_char use_json) | |
9969 | { | |
9970 | int ret; | |
9971 | struct bgp *bgp; | |
9972 | union sockunion su; | |
9973 | json_object *json = NULL; | |
9974 | ||
9975 | if (name) { | |
9976 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
9977 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
9978 | use_json); | |
d62a17ae | 9979 | return CMD_SUCCESS; |
9980 | } else { | |
9981 | bgp = bgp_lookup_by_name(name); | |
9982 | if (!bgp) { | |
9983 | if (use_json) { | |
9984 | json = json_object_new_object(); | |
9985 | json_object_boolean_true_add( | |
9986 | json, "bgpNoSuchInstance"); | |
9987 | vty_out(vty, "%s\n", | |
9988 | json_object_to_json_string_ext( | |
9989 | json, | |
9990 | JSON_C_TO_STRING_PRETTY)); | |
9991 | json_object_free(json); | |
9992 | } else | |
9993 | vty_out(vty, | |
9994 | "%% No such BGP instance exist\n"); | |
9995 | ||
9996 | return CMD_WARNING; | |
9997 | } | |
9998 | } | |
9999 | } else { | |
10000 | bgp = bgp_get_default(); | |
10001 | } | |
10002 | ||
10003 | if (bgp) { | |
10004 | json = json_object_new_object(); | |
10005 | if (ip_str) { | |
10006 | ret = str2sockunion(ip_str, &su); | |
10007 | if (ret < 0) | |
10008 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
10009 | use_json, json); | |
10010 | else | |
10011 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
10012 | use_json, json); | |
10013 | } else { | |
10014 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
10015 | json); | |
10016 | } | |
10017 | json_object_free(json); | |
10018 | } | |
10019 | ||
10020 | return CMD_SUCCESS; | |
4fb25c53 DW |
10021 | } |
10022 | ||
716b2d8a | 10023 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 10024 | DEFUN (show_ip_bgp_neighbors, |
10025 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 10026 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 10027 | SHOW_STR |
10028 | IP_STR | |
10029 | BGP_STR | |
f2a8972b | 10030 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
10031 | "Address Family\n" |
10032 | "Address Family\n" | |
718e3744 | 10033 | "Detailed information on TCP and BGP neighbor connections\n" |
10034 | "Neighbor to display information about\n" | |
a80beece | 10035 | "Neighbor to display information about\n" |
91d37724 | 10036 | "Neighbor on BGP configured interface\n" |
9973d184 | 10037 | JSON_STR) |
718e3744 | 10038 | { |
d62a17ae | 10039 | char *vrf = NULL; |
10040 | char *sh_arg = NULL; | |
10041 | enum show_type sh_type; | |
718e3744 | 10042 | |
d62a17ae | 10043 | u_char uj = use_json(argc, argv); |
718e3744 | 10044 | |
d62a17ae | 10045 | int idx = 0; |
718e3744 | 10046 | |
d62a17ae | 10047 | if (argv_find(argv, argc, "view", &idx) |
10048 | || argv_find(argv, argc, "vrf", &idx)) | |
10049 | vrf = argv[idx + 1]->arg; | |
718e3744 | 10050 | |
d62a17ae | 10051 | idx++; |
10052 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
10053 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
10054 | || argv_find(argv, argc, "WORD", &idx)) { | |
10055 | sh_type = show_peer; | |
10056 | sh_arg = argv[idx]->arg; | |
10057 | } else | |
10058 | sh_type = show_all; | |
856ca177 | 10059 | |
d62a17ae | 10060 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 10061 | } |
10062 | ||
716b2d8a | 10063 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 10064 | paths' and `show ip mbgp paths'. Those functions results are the |
10065 | same.*/ | |
f412b39a | 10066 | DEFUN (show_ip_bgp_paths, |
718e3744 | 10067 | show_ip_bgp_paths_cmd, |
46f296b4 | 10068 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 10069 | SHOW_STR |
10070 | IP_STR | |
10071 | BGP_STR | |
46f296b4 | 10072 | BGP_SAFI_HELP_STR |
718e3744 | 10073 | "Path information\n") |
10074 | { | |
d62a17ae | 10075 | vty_out(vty, "Address Refcnt Path\n"); |
10076 | aspath_print_all_vty(vty); | |
10077 | return CMD_SUCCESS; | |
718e3744 | 10078 | } |
10079 | ||
718e3744 | 10080 | #include "hash.h" |
10081 | ||
d62a17ae | 10082 | static void community_show_all_iterator(struct hash_backet *backet, |
10083 | struct vty *vty) | |
718e3744 | 10084 | { |
d62a17ae | 10085 | struct community *com; |
718e3744 | 10086 | |
d62a17ae | 10087 | com = (struct community *)backet->data; |
3f65c5b1 | 10088 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 10089 | community_str(com, false)); |
718e3744 | 10090 | } |
10091 | ||
10092 | /* Show BGP's community internal data. */ | |
f412b39a | 10093 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 10094 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 10095 | "show [ip] bgp community-info", |
718e3744 | 10096 | SHOW_STR |
10097 | IP_STR | |
10098 | BGP_STR | |
10099 | "List all bgp community information\n") | |
10100 | { | |
d62a17ae | 10101 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 10102 | |
d62a17ae | 10103 | hash_iterate(community_hash(), |
10104 | (void (*)(struct hash_backet *, | |
10105 | void *))community_show_all_iterator, | |
10106 | vty); | |
718e3744 | 10107 | |
d62a17ae | 10108 | return CMD_SUCCESS; |
718e3744 | 10109 | } |
10110 | ||
d62a17ae | 10111 | static void lcommunity_show_all_iterator(struct hash_backet *backet, |
10112 | struct vty *vty) | |
57d187bc | 10113 | { |
d62a17ae | 10114 | struct lcommunity *lcom; |
57d187bc | 10115 | |
d62a17ae | 10116 | lcom = (struct lcommunity *)backet->data; |
3f65c5b1 | 10117 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
d62a17ae | 10118 | lcommunity_str(lcom)); |
57d187bc JS |
10119 | } |
10120 | ||
10121 | /* Show BGP's community internal data. */ | |
10122 | DEFUN (show_ip_bgp_lcommunity_info, | |
10123 | show_ip_bgp_lcommunity_info_cmd, | |
10124 | "show ip bgp large-community-info", | |
10125 | SHOW_STR | |
10126 | IP_STR | |
10127 | BGP_STR | |
10128 | "List all bgp large-community information\n") | |
10129 | { | |
d62a17ae | 10130 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 10131 | |
d62a17ae | 10132 | hash_iterate(lcommunity_hash(), |
10133 | (void (*)(struct hash_backet *, | |
10134 | void *))lcommunity_show_all_iterator, | |
10135 | vty); | |
57d187bc | 10136 | |
d62a17ae | 10137 | return CMD_SUCCESS; |
57d187bc JS |
10138 | } |
10139 | ||
10140 | ||
f412b39a | 10141 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 10142 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 10143 | "show [ip] bgp attribute-info", |
718e3744 | 10144 | SHOW_STR |
10145 | IP_STR | |
10146 | BGP_STR | |
10147 | "List all bgp attribute information\n") | |
10148 | { | |
d62a17ae | 10149 | attr_show_all(vty); |
10150 | return CMD_SUCCESS; | |
718e3744 | 10151 | } |
6b0655a2 | 10152 | |
d62a17ae | 10153 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
10154 | safi_t safi) | |
f186de26 | 10155 | { |
d62a17ae | 10156 | struct listnode *node, *nnode; |
10157 | struct bgp *bgp; | |
f186de26 | 10158 | |
d62a17ae | 10159 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
10160 | vty_out(vty, "\nInstance %s:\n", | |
10161 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
10162 | ? "Default" | |
10163 | : bgp->name); | |
10164 | update_group_show(bgp, afi, safi, vty, 0); | |
10165 | } | |
f186de26 | 10166 | } |
10167 | ||
d62a17ae | 10168 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
10169 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 10170 | { |
d62a17ae | 10171 | struct bgp *bgp; |
4fb25c53 | 10172 | |
d62a17ae | 10173 | if (name) { |
10174 | if (strmatch(name, "all")) { | |
10175 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
10176 | return CMD_SUCCESS; | |
10177 | } else { | |
10178 | bgp = bgp_lookup_by_name(name); | |
10179 | } | |
10180 | } else { | |
10181 | bgp = bgp_get_default(); | |
10182 | } | |
4fb25c53 | 10183 | |
d62a17ae | 10184 | if (bgp) |
10185 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
10186 | return CMD_SUCCESS; | |
4fb25c53 DW |
10187 | } |
10188 | ||
8fe8a7f6 DS |
10189 | DEFUN (show_ip_bgp_updgrps, |
10190 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 10191 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 10192 | SHOW_STR |
10193 | IP_STR | |
10194 | BGP_STR | |
10195 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 10196 | BGP_AFI_HELP_STR |
9bedbb1e | 10197 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
10198 | "Detailed info about dynamic update groups\n" |
10199 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 10200 | { |
d62a17ae | 10201 | char *vrf = NULL; |
10202 | afi_t afi = AFI_IP6; | |
10203 | safi_t safi = SAFI_UNICAST; | |
10204 | uint64_t subgrp_id = 0; | |
10205 | ||
10206 | int idx = 0; | |
10207 | ||
10208 | /* show [ip] bgp */ | |
10209 | if (argv_find(argv, argc, "ip", &idx)) | |
10210 | afi = AFI_IP; | |
10211 | /* [<view|vrf> VIEWVRFNAME] */ | |
10212 | if (argv_find(argv, argc, "view", &idx) | |
10213 | || argv_find(argv, argc, "vrf", &idx)) | |
10214 | vrf = argv[++idx]->arg; | |
10215 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
10216 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
10217 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
10218 | } | |
5bf15956 | 10219 | |
d62a17ae | 10220 | /* get subgroup id, if provided */ |
10221 | idx = argc - 1; | |
10222 | if (argv[idx]->type == VARIABLE_TKN) | |
10223 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 10224 | |
d62a17ae | 10225 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
10226 | } |
10227 | ||
f186de26 | 10228 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
10229 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 10230 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 10231 | SHOW_STR |
716b2d8a | 10232 | IP_STR |
f186de26 | 10233 | BGP_STR |
10234 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 10235 | "Detailed info about dynamic update groups\n") |
f186de26 | 10236 | { |
d62a17ae | 10237 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
10238 | return CMD_SUCCESS; | |
f186de26 | 10239 | } |
10240 | ||
5bf15956 DW |
10241 | DEFUN (show_bgp_updgrps_stats, |
10242 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 10243 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 10244 | SHOW_STR |
716b2d8a | 10245 | IP_STR |
3f9c7369 | 10246 | BGP_STR |
0c7b1b01 | 10247 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
10248 | "Statistics\n") |
10249 | { | |
d62a17ae | 10250 | struct bgp *bgp; |
3f9c7369 | 10251 | |
d62a17ae | 10252 | bgp = bgp_get_default(); |
10253 | if (bgp) | |
10254 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 10255 | |
d62a17ae | 10256 | return CMD_SUCCESS; |
3f9c7369 DS |
10257 | } |
10258 | ||
8386ac43 | 10259 | DEFUN (show_bgp_instance_updgrps_stats, |
10260 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 10261 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 10262 | SHOW_STR |
716b2d8a | 10263 | IP_STR |
8386ac43 | 10264 | BGP_STR |
10265 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10266 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10267 | "Statistics\n") |
10268 | { | |
d62a17ae | 10269 | int idx_word = 3; |
10270 | struct bgp *bgp; | |
8386ac43 | 10271 | |
d62a17ae | 10272 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
10273 | if (bgp) | |
10274 | update_group_show_stats(bgp, vty); | |
8386ac43 | 10275 | |
d62a17ae | 10276 | return CMD_SUCCESS; |
8386ac43 | 10277 | } |
10278 | ||
d62a17ae | 10279 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
10280 | afi_t afi, safi_t safi, | |
10281 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 10282 | { |
d62a17ae | 10283 | struct bgp *bgp; |
8386ac43 | 10284 | |
d62a17ae | 10285 | if (name) |
10286 | bgp = bgp_lookup_by_name(name); | |
10287 | else | |
10288 | bgp = bgp_get_default(); | |
8386ac43 | 10289 | |
d62a17ae | 10290 | if (bgp) { |
10291 | if (!strcmp(what, "advertise-queue")) | |
10292 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
10293 | subgrp_id); | |
10294 | else if (!strcmp(what, "advertised-routes")) | |
10295 | update_group_show_advertised(bgp, afi, safi, vty, | |
10296 | subgrp_id); | |
10297 | else if (!strcmp(what, "packet-queue")) | |
10298 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
10299 | subgrp_id); | |
10300 | } | |
3f9c7369 DS |
10301 | } |
10302 | ||
10303 | DEFUN (show_ip_bgp_updgrps_adj, | |
10304 | show_ip_bgp_updgrps_adj_cmd, | |
716b2d8a | 10305 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
10306 | SHOW_STR |
10307 | IP_STR | |
10308 | BGP_STR | |
0c7b1b01 | 10309 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
10310 | "Advertisement queue\n" |
10311 | "Announced routes\n" | |
10312 | "Packet queue\n") | |
10313 | { | |
d62a17ae | 10314 | int idx_type = 4; |
10315 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, | |
10316 | argv[idx_type]->arg, 0); | |
10317 | return CMD_SUCCESS; | |
8386ac43 | 10318 | } |
10319 | ||
10320 | DEFUN (show_ip_bgp_instance_updgrps_adj, | |
10321 | show_ip_bgp_instance_updgrps_adj_cmd, | |
18c57037 | 10322 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10323 | SHOW_STR |
10324 | IP_STR | |
10325 | BGP_STR | |
10326 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10327 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10328 | "Advertisement queue\n" |
10329 | "Announced routes\n" | |
10330 | "Packet queue\n") | |
8386ac43 | 10331 | { |
d62a17ae | 10332 | int idx_word = 4; |
10333 | int idx_type = 6; | |
10334 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, | |
10335 | SAFI_UNICAST, argv[idx_type]->arg, 0); | |
10336 | return CMD_SUCCESS; | |
3f9c7369 DS |
10337 | } |
10338 | ||
10339 | DEFUN (show_bgp_updgrps_afi_adj, | |
10340 | show_bgp_updgrps_afi_adj_cmd, | |
46f296b4 | 10341 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 10342 | SHOW_STR |
716b2d8a | 10343 | IP_STR |
3f9c7369 | 10344 | BGP_STR |
46f296b4 | 10345 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 10346 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
10347 | "Advertisement queue\n" |
10348 | "Announced routes\n" | |
7111c1a0 | 10349 | "Packet queue\n") |
3f9c7369 | 10350 | { |
d62a17ae | 10351 | int idx_afi = 2; |
10352 | int idx_safi = 3; | |
10353 | int idx_type = 5; | |
10354 | show_bgp_updgrps_adj_info_aux( | |
10355 | vty, NULL, bgp_vty_afi_from_str(argv[idx_afi]->text), | |
10356 | bgp_vty_safi_from_str(argv[idx_safi]->text), | |
10357 | argv[idx_type]->arg, 0); | |
10358 | return CMD_SUCCESS; | |
3f9c7369 DS |
10359 | } |
10360 | ||
10361 | DEFUN (show_bgp_updgrps_adj, | |
10362 | show_bgp_updgrps_adj_cmd, | |
716b2d8a | 10363 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 10364 | SHOW_STR |
716b2d8a | 10365 | IP_STR |
3f9c7369 | 10366 | BGP_STR |
0c7b1b01 | 10367 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
10368 | "Advertisement queue\n" |
10369 | "Announced routes\n" | |
10370 | "Packet queue\n") | |
10371 | { | |
d62a17ae | 10372 | int idx_type = 3; |
10373 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, | |
10374 | argv[idx_type]->arg, 0); | |
10375 | return CMD_SUCCESS; | |
8386ac43 | 10376 | } |
10377 | ||
10378 | DEFUN (show_bgp_instance_updgrps_adj, | |
10379 | show_bgp_instance_updgrps_adj_cmd, | |
18c57037 | 10380 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10381 | SHOW_STR |
716b2d8a | 10382 | IP_STR |
8386ac43 | 10383 | BGP_STR |
10384 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10385 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10386 | "Advertisement queue\n" |
10387 | "Announced routes\n" | |
10388 | "Packet queue\n") | |
10389 | { | |
d62a17ae | 10390 | int idx_word = 3; |
10391 | int idx_type = 5; | |
10392 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, | |
10393 | SAFI_UNICAST, argv[idx_type]->arg, 0); | |
10394 | return CMD_SUCCESS; | |
3f9c7369 DS |
10395 | } |
10396 | ||
10397 | DEFUN (show_ip_bgp_updgrps_adj_s, | |
8fe8a7f6 | 10398 | show_ip_bgp_updgrps_adj_s_cmd, |
716b2d8a | 10399 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
10400 | SHOW_STR |
10401 | IP_STR | |
10402 | BGP_STR | |
0c7b1b01 | 10403 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 10404 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
10405 | "Advertisement queue\n" |
10406 | "Announced routes\n" | |
10407 | "Packet queue\n") | |
3f9c7369 | 10408 | { |
d62a17ae | 10409 | int idx_subgroup_id = 4; |
10410 | int idx_type = 5; | |
10411 | uint64_t subgrp_id; | |
8fe8a7f6 | 10412 | |
d62a17ae | 10413 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8fe8a7f6 | 10414 | |
d62a17ae | 10415 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, |
10416 | argv[idx_type]->arg, subgrp_id); | |
10417 | return CMD_SUCCESS; | |
8386ac43 | 10418 | } |
10419 | ||
10420 | DEFUN (show_ip_bgp_instance_updgrps_adj_s, | |
10421 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
18c57037 | 10422 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10423 | SHOW_STR |
10424 | IP_STR | |
10425 | BGP_STR | |
10426 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10427 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10428 | "Specific subgroup to display info for\n" |
10429 | "Advertisement queue\n" | |
10430 | "Announced routes\n" | |
10431 | "Packet queue\n") | |
8386ac43 | 10432 | { |
d62a17ae | 10433 | int idx_vrf = 4; |
10434 | int idx_subgroup_id = 6; | |
10435 | int idx_type = 7; | |
10436 | uint64_t subgrp_id; | |
8386ac43 | 10437 | |
d62a17ae | 10438 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8386ac43 | 10439 | |
d62a17ae | 10440 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP, |
10441 | SAFI_UNICAST, argv[idx_type]->arg, | |
10442 | subgrp_id); | |
10443 | return CMD_SUCCESS; | |
3f9c7369 DS |
10444 | } |
10445 | ||
8fe8a7f6 DS |
10446 | DEFUN (show_bgp_updgrps_afi_adj_s, |
10447 | show_bgp_updgrps_afi_adj_s_cmd, | |
46f296b4 | 10448 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 10449 | SHOW_STR |
716b2d8a | 10450 | IP_STR |
3f9c7369 | 10451 | BGP_STR |
46f296b4 | 10452 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 10453 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 10454 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
10455 | "Advertisement queue\n" |
10456 | "Announced routes\n" | |
7111c1a0 | 10457 | "Packet queue\n") |
3f9c7369 | 10458 | { |
d62a17ae | 10459 | int idx_afi = 2; |
10460 | int idx_safi = 3; | |
10461 | int idx_subgroup_id = 5; | |
10462 | int idx_type = 6; | |
10463 | uint64_t subgrp_id; | |
3f9c7369 | 10464 | |
d62a17ae | 10465 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8fe8a7f6 | 10466 | |
d62a17ae | 10467 | show_bgp_updgrps_adj_info_aux( |
10468 | vty, NULL, bgp_vty_afi_from_str(argv[idx_afi]->text), | |
10469 | bgp_vty_safi_from_str(argv[idx_safi]->text), | |
10470 | argv[idx_type]->arg, subgrp_id); | |
10471 | return CMD_SUCCESS; | |
3f9c7369 DS |
10472 | } |
10473 | ||
8fe8a7f6 DS |
10474 | DEFUN (show_bgp_updgrps_adj_s, |
10475 | show_bgp_updgrps_adj_s_cmd, | |
716b2d8a | 10476 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8fe8a7f6 | 10477 | SHOW_STR |
716b2d8a | 10478 | IP_STR |
8fe8a7f6 | 10479 | BGP_STR |
0c7b1b01 | 10480 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 DS |
10481 | "Specific subgroup to display info for\n" |
10482 | "Advertisement queue\n" | |
10483 | "Announced routes\n" | |
10484 | "Packet queue\n") | |
10485 | { | |
d62a17ae | 10486 | int idx_subgroup_id = 3; |
10487 | int idx_type = 4; | |
10488 | uint64_t subgrp_id; | |
8fe8a7f6 | 10489 | |
d62a17ae | 10490 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8fe8a7f6 | 10491 | |
d62a17ae | 10492 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, |
10493 | argv[idx_type]->arg, subgrp_id); | |
10494 | return CMD_SUCCESS; | |
8fe8a7f6 DS |
10495 | } |
10496 | ||
8386ac43 | 10497 | DEFUN (show_bgp_instance_updgrps_adj_s, |
10498 | show_bgp_instance_updgrps_adj_s_cmd, | |
18c57037 | 10499 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10500 | SHOW_STR |
716b2d8a | 10501 | IP_STR |
8386ac43 | 10502 | BGP_STR |
10503 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10504 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10505 | "Specific subgroup to display info for\n" |
10506 | "Advertisement queue\n" | |
10507 | "Announced routes\n" | |
10508 | "Packet queue\n") | |
10509 | { | |
d62a17ae | 10510 | int idx_vrf = 3; |
10511 | int idx_subgroup_id = 5; | |
10512 | int idx_type = 6; | |
10513 | uint64_t subgrp_id; | |
10514 | ||
10515 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); | |
10516 | ||
10517 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP6, | |
10518 | SAFI_UNICAST, argv[idx_type]->arg, | |
10519 | subgrp_id); | |
10520 | return CMD_SUCCESS; | |
10521 | } | |
10522 | ||
10523 | ||
10524 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) | |
10525 | { | |
10526 | struct listnode *node, *nnode; | |
10527 | struct prefix *range; | |
10528 | struct peer *conf; | |
10529 | struct peer *peer; | |
10530 | char buf[PREFIX2STR_BUFFER]; | |
10531 | afi_t afi; | |
10532 | safi_t safi; | |
10533 | const char *peer_status; | |
10534 | const char *af_str; | |
10535 | int lr_count; | |
10536 | int dynamic; | |
10537 | int af_cfgd; | |
10538 | ||
10539 | conf = group->conf; | |
10540 | ||
10541 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
10542 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
10543 | conf->as); | |
10544 | } else if (conf->as_type == AS_INTERNAL) { | |
10545 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
10546 | group->bgp->as); | |
10547 | } else { | |
10548 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
10549 | } | |
f14e6fdb | 10550 | |
d62a17ae | 10551 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
10552 | vty_out(vty, " Peer-group type is internal\n"); | |
10553 | else | |
10554 | vty_out(vty, " Peer-group type is external\n"); | |
10555 | ||
10556 | /* Display AFs configured. */ | |
10557 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
10558 | FOREACH_AFI_SAFI (afi, safi) { |
10559 | if (conf->afc[afi][safi]) { | |
10560 | af_cfgd = 1; | |
10561 | vty_out(vty, " %s;", afi_safi_print(afi, safi)); | |
d62a17ae | 10562 | } |
05c7a1cc | 10563 | } |
d62a17ae | 10564 | if (!af_cfgd) |
10565 | vty_out(vty, " none\n"); | |
10566 | else | |
10567 | vty_out(vty, "\n"); | |
10568 | ||
10569 | /* Display listen ranges (for dynamic neighbors), if any */ | |
10570 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
10571 | if (afi == AFI_IP) | |
10572 | af_str = "IPv4"; | |
10573 | else if (afi == AFI_IP6) | |
10574 | af_str = "IPv6"; | |
10575 | else | |
10576 | af_str = "???"; | |
10577 | lr_count = listcount(group->listen_range[afi]); | |
10578 | if (lr_count) { | |
10579 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
10580 | af_str); | |
10581 | ||
10582 | ||
10583 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
10584 | nnode, range)) { | |
10585 | prefix2str(range, buf, sizeof(buf)); | |
10586 | vty_out(vty, " %s\n", buf); | |
10587 | } | |
10588 | } | |
10589 | } | |
f14e6fdb | 10590 | |
d62a17ae | 10591 | /* Display group members and their status */ |
10592 | if (listcount(group->peer)) { | |
10593 | vty_out(vty, " Peer-group members:\n"); | |
10594 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
10595 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
10596 | peer_status = "Idle (Admin)"; | |
10597 | else if (CHECK_FLAG(peer->sflags, | |
10598 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10599 | peer_status = "Idle (PfxCt)"; | |
10600 | else | |
10601 | peer_status = lookup_msg(bgp_status_msg, | |
10602 | peer->status, NULL); | |
10603 | ||
10604 | dynamic = peer_dynamic_neighbor(peer); | |
10605 | vty_out(vty, " %s %s %s \n", peer->host, | |
10606 | dynamic ? "(dynamic)" : "", peer_status); | |
10607 | } | |
10608 | } | |
f14e6fdb | 10609 | |
d62a17ae | 10610 | return CMD_SUCCESS; |
10611 | } | |
10612 | ||
ff9959b0 QY |
10613 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
10614 | const char *group_name) | |
d62a17ae | 10615 | { |
ff9959b0 | 10616 | struct bgp *bgp; |
d62a17ae | 10617 | struct listnode *node, *nnode; |
10618 | struct peer_group *group; | |
ff9959b0 QY |
10619 | bool found = false; |
10620 | ||
10621 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
10622 | ||
10623 | if (!bgp) { | |
10624 | vty_out(vty, "%% No such BGP instance exists\n"); | |
10625 | return CMD_WARNING; | |
10626 | } | |
d62a17ae | 10627 | |
10628 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
10629 | if (group_name) { |
10630 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 10631 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
10632 | found = true; |
10633 | break; | |
d62a17ae | 10634 | } |
ff9959b0 QY |
10635 | } else { |
10636 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 10637 | } |
f14e6fdb | 10638 | } |
f14e6fdb | 10639 | |
ff9959b0 | 10640 | if (group_name && !found) |
d62a17ae | 10641 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 10642 | |
d62a17ae | 10643 | return CMD_SUCCESS; |
f14e6fdb DS |
10644 | } |
10645 | ||
f14e6fdb DS |
10646 | DEFUN (show_ip_bgp_peer_groups, |
10647 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 10648 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
10649 | SHOW_STR |
10650 | IP_STR | |
10651 | BGP_STR | |
8386ac43 | 10652 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
10653 | "Detailed information on BGP peer groups\n" |
10654 | "Peer group name\n") | |
f14e6fdb | 10655 | { |
d62a17ae | 10656 | char *vrf, *pg; |
10657 | vrf = pg = NULL; | |
10658 | int idx = 0; | |
f14e6fdb | 10659 | |
a4d82a8a PZ |
10660 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
10661 | : NULL; | |
d62a17ae | 10662 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 10663 | |
ff9959b0 | 10664 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 10665 | } |
3f9c7369 | 10666 | |
d6e3c605 | 10667 | |
718e3744 | 10668 | /* Redistribute VTY commands. */ |
10669 | ||
718e3744 | 10670 | DEFUN (bgp_redistribute_ipv4, |
10671 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 10672 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 10673 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10674 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 10675 | { |
d62a17ae | 10676 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10677 | int idx_protocol = 1; | |
10678 | int type; | |
718e3744 | 10679 | |
d62a17ae | 10680 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
10681 | if (type < 0) { | |
10682 | vty_out(vty, "%% Invalid route type\n"); | |
10683 | return CMD_WARNING_CONFIG_FAILED; | |
10684 | } | |
7f323236 | 10685 | |
d62a17ae | 10686 | bgp_redist_add(bgp, AFI_IP, type, 0); |
10687 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
718e3744 | 10688 | } |
10689 | ||
d62a17ae | 10690 | ALIAS_HIDDEN( |
10691 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
10692 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
10693 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 10694 | |
718e3744 | 10695 | DEFUN (bgp_redistribute_ipv4_rmap, |
10696 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 10697 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 10698 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10699 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10700 | "Route map reference\n" |
10701 | "Pointer to route-map entries\n") | |
10702 | { | |
d62a17ae | 10703 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10704 | int idx_protocol = 1; | |
10705 | int idx_word = 3; | |
10706 | int type; | |
10707 | struct bgp_redist *red; | |
718e3744 | 10708 | |
d62a17ae | 10709 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
10710 | if (type < 0) { | |
10711 | vty_out(vty, "%% Invalid route type\n"); | |
10712 | return CMD_WARNING_CONFIG_FAILED; | |
10713 | } | |
718e3744 | 10714 | |
d62a17ae | 10715 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
10716 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10717 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
718e3744 | 10718 | } |
10719 | ||
d62a17ae | 10720 | ALIAS_HIDDEN( |
10721 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
10722 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
10723 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10724 | "Route map reference\n" | |
10725 | "Pointer to route-map entries\n") | |
596c17ba | 10726 | |
718e3744 | 10727 | DEFUN (bgp_redistribute_ipv4_metric, |
10728 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 10729 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 10730 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10731 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10732 | "Metric for redistributed routes\n" |
10733 | "Default metric\n") | |
10734 | { | |
d62a17ae | 10735 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10736 | int idx_protocol = 1; | |
10737 | int idx_number = 3; | |
10738 | int type; | |
10739 | u_int32_t metric; | |
10740 | struct bgp_redist *red; | |
10741 | ||
10742 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
10743 | if (type < 0) { | |
10744 | vty_out(vty, "%% Invalid route type\n"); | |
10745 | return CMD_WARNING_CONFIG_FAILED; | |
10746 | } | |
10747 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
10748 | ||
10749 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
10750 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
10751 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
10752 | } | |
10753 | ||
10754 | ALIAS_HIDDEN( | |
10755 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
10756 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
10757 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10758 | "Metric for redistributed routes\n" | |
10759 | "Default metric\n") | |
596c17ba | 10760 | |
718e3744 | 10761 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
10762 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 10763 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 10764 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10765 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10766 | "Route map reference\n" |
10767 | "Pointer to route-map entries\n" | |
10768 | "Metric for redistributed routes\n" | |
10769 | "Default metric\n") | |
10770 | { | |
d62a17ae | 10771 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10772 | int idx_protocol = 1; | |
10773 | int idx_word = 3; | |
10774 | int idx_number = 5; | |
10775 | int type; | |
10776 | u_int32_t metric; | |
10777 | struct bgp_redist *red; | |
10778 | ||
10779 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
10780 | if (type < 0) { | |
10781 | vty_out(vty, "%% Invalid route type\n"); | |
10782 | return CMD_WARNING_CONFIG_FAILED; | |
10783 | } | |
10784 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
10785 | ||
10786 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
10787 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10788 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
10789 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
10790 | } | |
10791 | ||
10792 | ALIAS_HIDDEN( | |
10793 | bgp_redistribute_ipv4_rmap_metric, | |
10794 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
10795 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
10796 | " route-map WORD metric (0-4294967295)", | |
10797 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10798 | "Route map reference\n" | |
10799 | "Pointer to route-map entries\n" | |
10800 | "Metric for redistributed routes\n" | |
10801 | "Default metric\n") | |
596c17ba | 10802 | |
718e3744 | 10803 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
10804 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 10805 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 10806 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10807 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10808 | "Metric for redistributed routes\n" |
10809 | "Default metric\n" | |
10810 | "Route map reference\n" | |
10811 | "Pointer to route-map entries\n") | |
10812 | { | |
d62a17ae | 10813 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10814 | int idx_protocol = 1; | |
10815 | int idx_number = 3; | |
10816 | int idx_word = 5; | |
10817 | int type; | |
10818 | u_int32_t metric; | |
10819 | struct bgp_redist *red; | |
10820 | ||
10821 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
10822 | if (type < 0) { | |
10823 | vty_out(vty, "%% Invalid route type\n"); | |
10824 | return CMD_WARNING_CONFIG_FAILED; | |
10825 | } | |
10826 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
10827 | ||
10828 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
10829 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
10830 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10831 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
10832 | } | |
10833 | ||
10834 | ALIAS_HIDDEN( | |
10835 | bgp_redistribute_ipv4_metric_rmap, | |
10836 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
10837 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
10838 | " metric (0-4294967295) route-map WORD", | |
10839 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10840 | "Metric for redistributed routes\n" | |
10841 | "Default metric\n" | |
10842 | "Route map reference\n" | |
10843 | "Pointer to route-map entries\n") | |
596c17ba | 10844 | |
7c8ff89e DS |
10845 | DEFUN (bgp_redistribute_ipv4_ospf, |
10846 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 10847 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
10848 | "Redistribute information from another routing protocol\n" |
10849 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10850 | "Non-main Kernel Routing Table\n" |
10851 | "Instance ID/Table ID\n") | |
7c8ff89e | 10852 | { |
d62a17ae | 10853 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10854 | int idx_ospf_table = 1; | |
10855 | int idx_number = 2; | |
10856 | u_short instance; | |
10857 | u_short protocol; | |
7c8ff89e | 10858 | |
d62a17ae | 10859 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 10860 | |
d62a17ae | 10861 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
10862 | protocol = ZEBRA_ROUTE_OSPF; | |
10863 | else | |
10864 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 10865 | |
d62a17ae | 10866 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
10867 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
10868 | } |
10869 | ||
d62a17ae | 10870 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
10871 | "redistribute <ospf|table> (1-65535)", | |
10872 | "Redistribute information from another routing protocol\n" | |
10873 | "Open Shortest Path First (OSPFv2)\n" | |
10874 | "Non-main Kernel Routing Table\n" | |
10875 | "Instance ID/Table ID\n") | |
596c17ba | 10876 | |
7c8ff89e DS |
10877 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
10878 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 10879 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
10880 | "Redistribute information from another routing protocol\n" |
10881 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10882 | "Non-main Kernel Routing Table\n" |
10883 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10884 | "Route map reference\n" |
10885 | "Pointer to route-map entries\n") | |
10886 | { | |
d62a17ae | 10887 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10888 | int idx_ospf_table = 1; | |
10889 | int idx_number = 2; | |
10890 | int idx_word = 4; | |
10891 | struct bgp_redist *red; | |
10892 | u_short instance; | |
10893 | int protocol; | |
10894 | ||
10895 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10896 | protocol = ZEBRA_ROUTE_OSPF; | |
10897 | else | |
10898 | protocol = ZEBRA_ROUTE_TABLE; | |
10899 | ||
10900 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10901 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
10902 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10903 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
10904 | } | |
10905 | ||
10906 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
10907 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
10908 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
10909 | "Redistribute information from another routing protocol\n" | |
10910 | "Open Shortest Path First (OSPFv2)\n" | |
10911 | "Non-main Kernel Routing Table\n" | |
10912 | "Instance ID/Table ID\n" | |
10913 | "Route map reference\n" | |
10914 | "Pointer to route-map entries\n") | |
596c17ba | 10915 | |
7c8ff89e DS |
10916 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
10917 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 10918 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
10919 | "Redistribute information from another routing protocol\n" |
10920 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10921 | "Non-main Kernel Routing Table\n" |
10922 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10923 | "Metric for redistributed routes\n" |
10924 | "Default metric\n") | |
10925 | { | |
d62a17ae | 10926 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10927 | int idx_ospf_table = 1; | |
10928 | int idx_number = 2; | |
10929 | int idx_number_2 = 4; | |
10930 | u_int32_t metric; | |
10931 | struct bgp_redist *red; | |
10932 | u_short instance; | |
10933 | int protocol; | |
10934 | ||
10935 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10936 | protocol = ZEBRA_ROUTE_OSPF; | |
10937 | else | |
10938 | protocol = ZEBRA_ROUTE_TABLE; | |
10939 | ||
10940 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10941 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
10942 | ||
10943 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
10944 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
10945 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
10946 | } | |
10947 | ||
10948 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
10949 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
10950 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
10951 | "Redistribute information from another routing protocol\n" | |
10952 | "Open Shortest Path First (OSPFv2)\n" | |
10953 | "Non-main Kernel Routing Table\n" | |
10954 | "Instance ID/Table ID\n" | |
10955 | "Metric for redistributed routes\n" | |
10956 | "Default metric\n") | |
596c17ba | 10957 | |
7c8ff89e DS |
10958 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
10959 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 10960 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
10961 | "Redistribute information from another routing protocol\n" |
10962 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10963 | "Non-main Kernel Routing Table\n" |
10964 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10965 | "Route map reference\n" |
10966 | "Pointer to route-map entries\n" | |
10967 | "Metric for redistributed routes\n" | |
10968 | "Default metric\n") | |
10969 | { | |
d62a17ae | 10970 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10971 | int idx_ospf_table = 1; | |
10972 | int idx_number = 2; | |
10973 | int idx_word = 4; | |
10974 | int idx_number_2 = 6; | |
10975 | u_int32_t metric; | |
10976 | struct bgp_redist *red; | |
10977 | u_short instance; | |
10978 | int protocol; | |
10979 | ||
10980 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10981 | protocol = ZEBRA_ROUTE_OSPF; | |
10982 | else | |
10983 | protocol = ZEBRA_ROUTE_TABLE; | |
10984 | ||
10985 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10986 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
10987 | ||
10988 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
10989 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10990 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
10991 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
10992 | } | |
10993 | ||
10994 | ALIAS_HIDDEN( | |
10995 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
10996 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
10997 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
10998 | "Redistribute information from another routing protocol\n" | |
10999 | "Open Shortest Path First (OSPFv2)\n" | |
11000 | "Non-main Kernel Routing Table\n" | |
11001 | "Instance ID/Table ID\n" | |
11002 | "Route map reference\n" | |
11003 | "Pointer to route-map entries\n" | |
11004 | "Metric for redistributed routes\n" | |
11005 | "Default metric\n") | |
596c17ba | 11006 | |
7c8ff89e DS |
11007 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
11008 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 11009 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
11010 | "Redistribute information from another routing protocol\n" |
11011 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11012 | "Non-main Kernel Routing Table\n" |
11013 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
11014 | "Metric for redistributed routes\n" |
11015 | "Default metric\n" | |
11016 | "Route map reference\n" | |
11017 | "Pointer to route-map entries\n") | |
11018 | { | |
d62a17ae | 11019 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11020 | int idx_ospf_table = 1; | |
11021 | int idx_number = 2; | |
11022 | int idx_number_2 = 4; | |
11023 | int idx_word = 6; | |
11024 | u_int32_t metric; | |
11025 | struct bgp_redist *red; | |
11026 | u_short instance; | |
11027 | int protocol; | |
11028 | ||
11029 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11030 | protocol = ZEBRA_ROUTE_OSPF; | |
11031 | else | |
11032 | protocol = ZEBRA_ROUTE_TABLE; | |
11033 | ||
11034 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11035 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
11036 | ||
11037 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
11038 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
11039 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11040 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
11041 | } | |
11042 | ||
11043 | ALIAS_HIDDEN( | |
11044 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
11045 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
11046 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
11047 | "Redistribute information from another routing protocol\n" | |
11048 | "Open Shortest Path First (OSPFv2)\n" | |
11049 | "Non-main Kernel Routing Table\n" | |
11050 | "Instance ID/Table ID\n" | |
11051 | "Metric for redistributed routes\n" | |
11052 | "Default metric\n" | |
11053 | "Route map reference\n" | |
11054 | "Pointer to route-map entries\n") | |
596c17ba | 11055 | |
7c8ff89e DS |
11056 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
11057 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 11058 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
11059 | NO_STR |
11060 | "Redistribute information from another routing protocol\n" | |
11061 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 11062 | "Non-main Kernel Routing Table\n" |
31500417 DW |
11063 | "Instance ID/Table ID\n" |
11064 | "Metric for redistributed routes\n" | |
11065 | "Default metric\n" | |
11066 | "Route map reference\n" | |
11067 | "Pointer to route-map entries\n") | |
7c8ff89e | 11068 | { |
d62a17ae | 11069 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11070 | int idx_ospf_table = 2; | |
11071 | int idx_number = 3; | |
11072 | u_short instance; | |
11073 | int protocol; | |
11074 | ||
11075 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11076 | protocol = ZEBRA_ROUTE_OSPF; | |
11077 | else | |
11078 | protocol = ZEBRA_ROUTE_TABLE; | |
11079 | ||
11080 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11081 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
11082 | } | |
11083 | ||
11084 | ALIAS_HIDDEN( | |
11085 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
11086 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", | |
11087 | NO_STR | |
11088 | "Redistribute information from another routing protocol\n" | |
11089 | "Open Shortest Path First (OSPFv2)\n" | |
11090 | "Non-main Kernel Routing Table\n" | |
11091 | "Instance ID/Table ID\n" | |
11092 | "Metric for redistributed routes\n" | |
11093 | "Default metric\n" | |
11094 | "Route map reference\n" | |
11095 | "Pointer to route-map entries\n") | |
596c17ba | 11096 | |
718e3744 | 11097 | DEFUN (no_bgp_redistribute_ipv4, |
11098 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 11099 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 11100 | NO_STR |
11101 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 11102 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
11103 | "Metric for redistributed routes\n" |
11104 | "Default metric\n" | |
11105 | "Route map reference\n" | |
11106 | "Pointer to route-map entries\n") | |
718e3744 | 11107 | { |
d62a17ae | 11108 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11109 | int idx_protocol = 2; | |
11110 | int type; | |
11111 | ||
11112 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11113 | if (type < 0) { | |
11114 | vty_out(vty, "%% Invalid route type\n"); | |
11115 | return CMD_WARNING_CONFIG_FAILED; | |
11116 | } | |
11117 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
11118 | } | |
11119 | ||
11120 | ALIAS_HIDDEN( | |
11121 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
11122 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
11123 | " [metric (0-4294967295)] [route-map WORD]", | |
11124 | NO_STR | |
11125 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11126 | "Metric for redistributed routes\n" | |
11127 | "Default metric\n" | |
11128 | "Route map reference\n" | |
11129 | "Pointer to route-map entries\n") | |
596c17ba | 11130 | |
718e3744 | 11131 | DEFUN (bgp_redistribute_ipv6, |
11132 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 11133 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 11134 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11135 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 11136 | { |
d62a17ae | 11137 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11138 | int idx_protocol = 1; | |
11139 | int type; | |
718e3744 | 11140 | |
d62a17ae | 11141 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
11142 | if (type < 0) { | |
11143 | vty_out(vty, "%% Invalid route type\n"); | |
11144 | return CMD_WARNING_CONFIG_FAILED; | |
11145 | } | |
718e3744 | 11146 | |
d62a17ae | 11147 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
11148 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11149 | } |
11150 | ||
11151 | DEFUN (bgp_redistribute_ipv6_rmap, | |
11152 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 11153 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 11154 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11155 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11156 | "Route map reference\n" |
11157 | "Pointer to route-map entries\n") | |
11158 | { | |
d62a17ae | 11159 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11160 | int idx_protocol = 1; | |
11161 | int idx_word = 3; | |
11162 | int type; | |
11163 | struct bgp_redist *red; | |
718e3744 | 11164 | |
d62a17ae | 11165 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
11166 | if (type < 0) { | |
11167 | vty_out(vty, "%% Invalid route type\n"); | |
11168 | return CMD_WARNING_CONFIG_FAILED; | |
11169 | } | |
718e3744 | 11170 | |
d62a17ae | 11171 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11172 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11173 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11174 | } |
11175 | ||
11176 | DEFUN (bgp_redistribute_ipv6_metric, | |
11177 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 11178 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 11179 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11180 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11181 | "Metric for redistributed routes\n" |
11182 | "Default metric\n") | |
11183 | { | |
d62a17ae | 11184 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11185 | int idx_protocol = 1; | |
11186 | int idx_number = 3; | |
11187 | int type; | |
11188 | u_int32_t metric; | |
11189 | struct bgp_redist *red; | |
11190 | ||
11191 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
11192 | if (type < 0) { | |
11193 | vty_out(vty, "%% Invalid route type\n"); | |
11194 | return CMD_WARNING_CONFIG_FAILED; | |
11195 | } | |
11196 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 11197 | |
d62a17ae | 11198 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11199 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
11200 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11201 | } |
11202 | ||
11203 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
11204 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 11205 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 11206 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11207 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11208 | "Route map reference\n" |
11209 | "Pointer to route-map entries\n" | |
11210 | "Metric for redistributed routes\n" | |
11211 | "Default metric\n") | |
11212 | { | |
d62a17ae | 11213 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11214 | int idx_protocol = 1; | |
11215 | int idx_word = 3; | |
11216 | int idx_number = 5; | |
11217 | int type; | |
11218 | u_int32_t metric; | |
11219 | struct bgp_redist *red; | |
11220 | ||
11221 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
11222 | if (type < 0) { | |
11223 | vty_out(vty, "%% Invalid route type\n"); | |
11224 | return CMD_WARNING_CONFIG_FAILED; | |
11225 | } | |
11226 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 11227 | |
d62a17ae | 11228 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11229 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11230 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
11231 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11232 | } |
11233 | ||
11234 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
11235 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 11236 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 11237 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11238 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11239 | "Metric for redistributed routes\n" |
11240 | "Default metric\n" | |
11241 | "Route map reference\n" | |
11242 | "Pointer to route-map entries\n") | |
11243 | { | |
d62a17ae | 11244 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11245 | int idx_protocol = 1; | |
11246 | int idx_number = 3; | |
11247 | int idx_word = 5; | |
11248 | int type; | |
11249 | u_int32_t metric; | |
11250 | struct bgp_redist *red; | |
11251 | ||
11252 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
11253 | if (type < 0) { | |
11254 | vty_out(vty, "%% Invalid route type\n"); | |
11255 | return CMD_WARNING_CONFIG_FAILED; | |
11256 | } | |
11257 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 11258 | |
d62a17ae | 11259 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11260 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric); | |
11261 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11262 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11263 | } |
11264 | ||
11265 | DEFUN (no_bgp_redistribute_ipv6, | |
11266 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 11267 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 11268 | NO_STR |
11269 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 11270 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
11271 | "Metric for redistributed routes\n" |
11272 | "Default metric\n" | |
11273 | "Route map reference\n" | |
11274 | "Pointer to route-map entries\n") | |
718e3744 | 11275 | { |
d62a17ae | 11276 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11277 | int idx_protocol = 2; | |
11278 | int type; | |
718e3744 | 11279 | |
d62a17ae | 11280 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
11281 | if (type < 0) { | |
11282 | vty_out(vty, "%% Invalid route type\n"); | |
11283 | return CMD_WARNING_CONFIG_FAILED; | |
11284 | } | |
718e3744 | 11285 | |
d62a17ae | 11286 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
11287 | } | |
11288 | ||
2b791107 | 11289 | void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 11290 | safi_t safi) |
d62a17ae | 11291 | { |
11292 | int i; | |
11293 | ||
11294 | /* Unicast redistribution only. */ | |
11295 | if (safi != SAFI_UNICAST) | |
2b791107 | 11296 | return; |
d62a17ae | 11297 | |
11298 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
11299 | /* Redistribute BGP does not make sense. */ | |
11300 | if (i != ZEBRA_ROUTE_BGP) { | |
11301 | struct list *red_list; | |
11302 | struct listnode *node; | |
11303 | struct bgp_redist *red; | |
11304 | ||
11305 | red_list = bgp->redist[afi][i]; | |
11306 | if (!red_list) | |
11307 | continue; | |
11308 | ||
11309 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 11310 | /* "redistribute" configuration. */ |
11311 | vty_out(vty, " redistribute %s", | |
11312 | zebra_route_string(i)); | |
11313 | if (red->instance) | |
11314 | vty_out(vty, " %d", red->instance); | |
11315 | if (red->redist_metric_flag) | |
11316 | vty_out(vty, " metric %u", | |
11317 | red->redist_metric); | |
11318 | if (red->rmap.name) | |
11319 | vty_out(vty, " route-map %s", | |
11320 | red->rmap.name); | |
11321 | vty_out(vty, "\n"); | |
11322 | } | |
11323 | } | |
11324 | } | |
718e3744 | 11325 | } |
6b0655a2 | 11326 | |
718e3744 | 11327 | /* BGP node structure. */ |
d62a17ae | 11328 | static struct cmd_node bgp_node = { |
9d303b37 | 11329 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 11330 | }; |
11331 | ||
d62a17ae | 11332 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 11333 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 11334 | }; |
11335 | ||
d62a17ae | 11336 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 11337 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 11338 | }; |
11339 | ||
d62a17ae | 11340 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 11341 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
11342 | }; |
11343 | ||
d62a17ae | 11344 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 11345 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 11346 | }; |
11347 | ||
d62a17ae | 11348 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 11349 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 11350 | }; |
11351 | ||
d62a17ae | 11352 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 11353 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
11354 | }; |
11355 | ||
d62a17ae | 11356 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
11357 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 11358 | |
d62a17ae | 11359 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
11360 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 11361 | |
d62a17ae | 11362 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
11363 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 11364 | |
d62a17ae | 11365 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
11366 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 11367 | |
d62a17ae | 11368 | static void community_list_vty(void); |
1f8ae70b | 11369 | |
d62a17ae | 11370 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 11371 | { |
d62a17ae | 11372 | struct bgp *bgp; |
11373 | struct peer *peer; | |
11374 | struct peer_group *group; | |
11375 | struct listnode *lnbgp, *lnpeer; | |
b8a815e5 | 11376 | |
d62a17ae | 11377 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
11378 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
11379 | /* only provide suggestions on the appropriate input | |
11380 | * token type, | |
11381 | * they'll otherwise show up multiple times */ | |
11382 | enum cmd_token_type match_type; | |
11383 | char *name = peer->host; | |
d48ed3e0 | 11384 | |
d62a17ae | 11385 | if (peer->conf_if) { |
11386 | match_type = VARIABLE_TKN; | |
11387 | name = peer->conf_if; | |
11388 | } else if (strchr(peer->host, ':')) | |
11389 | match_type = IPV6_TKN; | |
11390 | else | |
11391 | match_type = IPV4_TKN; | |
d48ed3e0 | 11392 | |
d62a17ae | 11393 | if (token->type != match_type) |
11394 | continue; | |
d48ed3e0 | 11395 | |
d62a17ae | 11396 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
11397 | } | |
d48ed3e0 | 11398 | |
d62a17ae | 11399 | if (token->type == VARIABLE_TKN) |
11400 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
11401 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
11402 | group->name)); | |
11403 | } | |
b8a815e5 DL |
11404 | } |
11405 | ||
11406 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 11407 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
11408 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 11409 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 11410 | {.completions = NULL}}; |
11411 | ||
11412 | void bgp_vty_init(void) | |
11413 | { | |
11414 | cmd_variable_handler_register(bgp_var_neighbor); | |
11415 | ||
11416 | /* Install bgp top node. */ | |
11417 | install_node(&bgp_node, bgp_config_write); | |
11418 | install_node(&bgp_ipv4_unicast_node, NULL); | |
11419 | install_node(&bgp_ipv4_multicast_node, NULL); | |
11420 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
11421 | install_node(&bgp_ipv6_unicast_node, NULL); | |
11422 | install_node(&bgp_ipv6_multicast_node, NULL); | |
11423 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
11424 | install_node(&bgp_vpnv4_node, NULL); | |
11425 | install_node(&bgp_vpnv6_node, NULL); | |
11426 | install_node(&bgp_evpn_node, NULL); | |
11427 | install_node(&bgp_evpn_vni_node, NULL); | |
11428 | ||
11429 | /* Install default VTY commands to new nodes. */ | |
11430 | install_default(BGP_NODE); | |
11431 | install_default(BGP_IPV4_NODE); | |
11432 | install_default(BGP_IPV4M_NODE); | |
11433 | install_default(BGP_IPV4L_NODE); | |
11434 | install_default(BGP_IPV6_NODE); | |
11435 | install_default(BGP_IPV6M_NODE); | |
11436 | install_default(BGP_IPV6L_NODE); | |
11437 | install_default(BGP_VPNV4_NODE); | |
11438 | install_default(BGP_VPNV6_NODE); | |
11439 | install_default(BGP_EVPN_NODE); | |
11440 | install_default(BGP_EVPN_VNI_NODE); | |
11441 | ||
11442 | /* "bgp multiple-instance" commands. */ | |
11443 | install_element(CONFIG_NODE, &bgp_multiple_instance_cmd); | |
11444 | install_element(CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
11445 | ||
11446 | /* "bgp config-type" commands. */ | |
11447 | install_element(CONFIG_NODE, &bgp_config_type_cmd); | |
11448 | install_element(CONFIG_NODE, &no_bgp_config_type_cmd); | |
11449 | ||
11450 | /* bgp route-map delay-timer commands. */ | |
11451 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
11452 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
11453 | ||
11454 | /* Dummy commands (Currently not supported) */ | |
11455 | install_element(BGP_NODE, &no_synchronization_cmd); | |
11456 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
11457 | ||
11458 | /* "router bgp" commands. */ | |
11459 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
11460 | ||
11461 | /* "no router bgp" commands. */ | |
11462 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
11463 | ||
11464 | /* "bgp router-id" commands. */ | |
11465 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
11466 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
11467 | ||
11468 | /* "bgp cluster-id" commands. */ | |
11469 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
11470 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
11471 | ||
11472 | /* "bgp confederation" commands. */ | |
11473 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
11474 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
11475 | ||
11476 | /* "bgp confederation peers" commands. */ | |
11477 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
11478 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
11479 | ||
11480 | /* bgp max-med command */ | |
11481 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
11482 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
11483 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
11484 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
11485 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
11486 | ||
11487 | /* bgp disable-ebgp-connected-nh-check */ | |
11488 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
11489 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
11490 | ||
11491 | /* bgp update-delay command */ | |
11492 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
11493 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
11494 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
11495 | ||
11496 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
11497 | install_element(BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
555e09d4 QY |
11498 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
11499 | install_element(BGP_NODE, &no_bgp_rpkt_quanta_cmd); | |
d62a17ae | 11500 | |
11501 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
11502 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
11503 | ||
11504 | /* "maximum-paths" commands. */ | |
11505 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
11506 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
11507 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
11508 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
11509 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
11510 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
11511 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
11512 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
11513 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
11514 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
11515 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
11516 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
11517 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
11518 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
11519 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
11520 | ||
11521 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
11522 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
11523 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
11524 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
11525 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
11526 | ||
11527 | /* "timers bgp" commands. */ | |
11528 | install_element(BGP_NODE, &bgp_timers_cmd); | |
11529 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
11530 | ||
11531 | /* route-map delay-timer commands - per instance for backwards compat. | |
11532 | */ | |
11533 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
11534 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
11535 | ||
11536 | /* "bgp client-to-client reflection" commands */ | |
11537 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
11538 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
11539 | ||
11540 | /* "bgp always-compare-med" commands */ | |
11541 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
11542 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
11543 | ||
11544 | /* "bgp deterministic-med" commands */ | |
11545 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
11546 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
11547 | ||
11548 | /* "bgp graceful-restart" commands */ | |
11549 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); | |
11550 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
11551 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); | |
11552 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
11553 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
11554 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
11555 | ||
11556 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); | |
11557 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
11558 | ||
7f323236 DW |
11559 | /* "bgp graceful-shutdown" commands */ |
11560 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
11561 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
11562 | ||
d62a17ae | 11563 | /* "bgp fast-external-failover" commands */ |
11564 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
11565 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
11566 | ||
11567 | /* "bgp enforce-first-as" commands */ | |
11568 | install_element(BGP_NODE, &bgp_enforce_first_as_cmd); | |
11569 | install_element(BGP_NODE, &no_bgp_enforce_first_as_cmd); | |
11570 | ||
11571 | /* "bgp bestpath compare-routerid" commands */ | |
11572 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
11573 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
11574 | ||
11575 | /* "bgp bestpath as-path ignore" commands */ | |
11576 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
11577 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
11578 | ||
11579 | /* "bgp bestpath as-path confed" commands */ | |
11580 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
11581 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
11582 | ||
11583 | /* "bgp bestpath as-path multipath-relax" commands */ | |
11584 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
11585 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
11586 | ||
11587 | /* "bgp log-neighbor-changes" commands */ | |
11588 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
11589 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
11590 | ||
11591 | /* "bgp bestpath med" commands */ | |
11592 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
11593 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
11594 | ||
11595 | /* "no bgp default ipv4-unicast" commands. */ | |
11596 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
11597 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
11598 | ||
11599 | /* "bgp network import-check" commands. */ | |
11600 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
11601 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
11602 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
11603 | ||
11604 | /* "bgp default local-preference" commands. */ | |
11605 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
11606 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
11607 | ||
11608 | /* bgp default show-hostname */ | |
11609 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
11610 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
11611 | ||
11612 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
11613 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
11614 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
11615 | ||
11616 | /* bgp ibgp-allow-policy-mods command */ | |
11617 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
11618 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
11619 | ||
11620 | /* "bgp listen limit" commands. */ | |
11621 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
11622 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
11623 | ||
11624 | /* "bgp listen range" commands. */ | |
11625 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
11626 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
11627 | ||
8175f54a | 11628 | /* "bgp default shutdown" command */ |
f26845f9 QY |
11629 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
11630 | ||
d62a17ae | 11631 | /* "neighbor remote-as" commands. */ |
11632 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
11633 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
11634 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
11635 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
11636 | install_element(BGP_NODE, | |
11637 | &neighbor_interface_v6only_config_remote_as_cmd); | |
11638 | install_element(BGP_NODE, &no_neighbor_cmd); | |
11639 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
11640 | ||
11641 | /* "neighbor peer-group" commands. */ | |
11642 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
11643 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
11644 | install_element(BGP_NODE, | |
11645 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
11646 | ||
11647 | /* "neighbor local-as" commands. */ | |
11648 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
11649 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
11650 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
11651 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
11652 | ||
11653 | /* "neighbor solo" commands. */ | |
11654 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
11655 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
11656 | ||
11657 | /* "neighbor password" commands. */ | |
11658 | install_element(BGP_NODE, &neighbor_password_cmd); | |
11659 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
11660 | ||
11661 | /* "neighbor activate" commands. */ | |
11662 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
11663 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
11664 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
11665 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
11666 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
11667 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
11668 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
11669 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
11670 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
11671 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); | |
11672 | ||
11673 | /* "no neighbor activate" commands. */ | |
11674 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
11675 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
11676 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
11677 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
11678 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
11679 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
11680 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
11681 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
11682 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
11683 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); | |
11684 | ||
11685 | /* "neighbor peer-group" set commands. */ | |
11686 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
11687 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11688 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11689 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11690 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11691 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11692 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11693 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11694 | ||
11695 | /* "no neighbor peer-group unset" commands. */ | |
11696 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
11697 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11698 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11699 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11700 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11701 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11702 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11703 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11704 | ||
11705 | /* "neighbor softreconfiguration inbound" commands.*/ | |
11706 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
11707 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
11708 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
11709 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11710 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
11711 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11712 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
11713 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11714 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
11715 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11716 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
11717 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11718 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
11719 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11720 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
11721 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11722 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
11723 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11724 | ||
11725 | /* "neighbor attribute-unchanged" commands. */ | |
11726 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
11727 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
11728 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
11729 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
11730 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
11731 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
11732 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
11733 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
11734 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
11735 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
11736 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
11737 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
11738 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
11739 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
11740 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
11741 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
11742 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
11743 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
11744 | ||
11745 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
11746 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
11747 | ||
11748 | /* "nexthop-local unchanged" commands */ | |
11749 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
11750 | install_element(BGP_IPV6_NODE, | |
11751 | &no_neighbor_nexthop_local_unchanged_cmd); | |
11752 | ||
11753 | /* "neighbor next-hop-self" commands. */ | |
11754 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
11755 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
11756 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
11757 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
11758 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
11759 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
11760 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
11761 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
11762 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
11763 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
11764 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
11765 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
11766 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
11767 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
11768 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
11769 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
11770 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
11771 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
11772 | ||
11773 | /* "neighbor next-hop-self force" commands. */ | |
11774 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
11775 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
11776 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
11777 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11778 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
11779 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11780 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); | |
11781 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11782 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
11783 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11784 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
11785 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11786 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); | |
11787 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11788 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
11789 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11790 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); | |
11791 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11792 | ||
11793 | /* "neighbor as-override" commands. */ | |
11794 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
11795 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
11796 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
11797 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
11798 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
11799 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
11800 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
11801 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
11802 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
11803 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
11804 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
11805 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
11806 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
11807 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
11808 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
11809 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
11810 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
11811 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
11812 | ||
11813 | /* "neighbor remove-private-AS" commands. */ | |
11814 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
11815 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
11816 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
11817 | install_element(BGP_NODE, | |
11818 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
11819 | install_element(BGP_NODE, | |
11820 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
11821 | install_element(BGP_NODE, | |
11822 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
11823 | install_element(BGP_NODE, | |
11824 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
11825 | install_element( | |
11826 | BGP_NODE, | |
11827 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
11828 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
11829 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
11830 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
11831 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11832 | install_element(BGP_IPV4_NODE, | |
11833 | &neighbor_remove_private_as_replace_as_cmd); | |
11834 | install_element(BGP_IPV4_NODE, | |
11835 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11836 | install_element(BGP_IPV4_NODE, | |
11837 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11838 | install_element(BGP_IPV4_NODE, | |
11839 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11840 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
11841 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
11842 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
11843 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11844 | install_element(BGP_IPV4M_NODE, | |
11845 | &neighbor_remove_private_as_replace_as_cmd); | |
11846 | install_element(BGP_IPV4M_NODE, | |
11847 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11848 | install_element(BGP_IPV4M_NODE, | |
11849 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11850 | install_element(BGP_IPV4M_NODE, | |
11851 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11852 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
11853 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
11854 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
11855 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11856 | install_element(BGP_IPV4L_NODE, | |
11857 | &neighbor_remove_private_as_replace_as_cmd); | |
11858 | install_element(BGP_IPV4L_NODE, | |
11859 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11860 | install_element(BGP_IPV4L_NODE, | |
11861 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11862 | install_element(BGP_IPV4L_NODE, | |
11863 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11864 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
11865 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
11866 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
11867 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11868 | install_element(BGP_IPV6_NODE, | |
11869 | &neighbor_remove_private_as_replace_as_cmd); | |
11870 | install_element(BGP_IPV6_NODE, | |
11871 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11872 | install_element(BGP_IPV6_NODE, | |
11873 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11874 | install_element(BGP_IPV6_NODE, | |
11875 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11876 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
11877 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
11878 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
11879 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11880 | install_element(BGP_IPV6M_NODE, | |
11881 | &neighbor_remove_private_as_replace_as_cmd); | |
11882 | install_element(BGP_IPV6M_NODE, | |
11883 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11884 | install_element(BGP_IPV6M_NODE, | |
11885 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11886 | install_element(BGP_IPV6M_NODE, | |
11887 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11888 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
11889 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
11890 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
11891 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11892 | install_element(BGP_IPV6L_NODE, | |
11893 | &neighbor_remove_private_as_replace_as_cmd); | |
11894 | install_element(BGP_IPV6L_NODE, | |
11895 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11896 | install_element(BGP_IPV6L_NODE, | |
11897 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11898 | install_element(BGP_IPV6L_NODE, | |
11899 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11900 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
11901 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
11902 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
11903 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11904 | install_element(BGP_VPNV4_NODE, | |
11905 | &neighbor_remove_private_as_replace_as_cmd); | |
11906 | install_element(BGP_VPNV4_NODE, | |
11907 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11908 | install_element(BGP_VPNV4_NODE, | |
11909 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11910 | install_element(BGP_VPNV4_NODE, | |
11911 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11912 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
11913 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
11914 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
11915 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11916 | install_element(BGP_VPNV6_NODE, | |
11917 | &neighbor_remove_private_as_replace_as_cmd); | |
11918 | install_element(BGP_VPNV6_NODE, | |
11919 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11920 | install_element(BGP_VPNV6_NODE, | |
11921 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11922 | install_element(BGP_VPNV6_NODE, | |
11923 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11924 | ||
11925 | /* "neighbor send-community" commands.*/ | |
11926 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
11927 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
11928 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
11929 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
11930 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
11931 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
11932 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
11933 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
11934 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
11935 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
11936 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
11937 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
11938 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
11939 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
11940 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
11941 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
11942 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
11943 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
11944 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
11945 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
11946 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
11947 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
11948 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
11949 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
11950 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
11951 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
11952 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
11953 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
11954 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
11955 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
11956 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
11957 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
11958 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
11959 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
11960 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
11961 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
11962 | ||
11963 | /* "neighbor route-reflector" commands.*/ | |
11964 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
11965 | install_element(BGP_NODE, | |
11966 | &no_neighbor_route_reflector_client_hidden_cmd); | |
11967 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
11968 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
11969 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
11970 | install_element(BGP_IPV4M_NODE, | |
11971 | &no_neighbor_route_reflector_client_cmd); | |
11972 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
11973 | install_element(BGP_IPV4L_NODE, | |
11974 | &no_neighbor_route_reflector_client_cmd); | |
11975 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
11976 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
11977 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
11978 | install_element(BGP_IPV6M_NODE, | |
11979 | &no_neighbor_route_reflector_client_cmd); | |
11980 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
11981 | install_element(BGP_IPV6L_NODE, | |
11982 | &no_neighbor_route_reflector_client_cmd); | |
11983 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
11984 | install_element(BGP_VPNV4_NODE, | |
11985 | &no_neighbor_route_reflector_client_cmd); | |
11986 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
11987 | install_element(BGP_VPNV6_NODE, | |
11988 | &no_neighbor_route_reflector_client_cmd); | |
11989 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); | |
11990 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
11991 | ||
11992 | /* "neighbor route-server" commands.*/ | |
11993 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
11994 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
11995 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
11996 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
11997 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
11998 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
11999 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
12000 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
12001 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
12002 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
12003 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
12004 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
12005 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
12006 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
12007 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
12008 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
12009 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
12010 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
12011 | ||
12012 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
12013 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
12014 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
12015 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12016 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12017 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12018 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12019 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12020 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12021 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12022 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12023 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12024 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12025 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12026 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12027 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12028 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12029 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12030 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12031 | ||
12032 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
12033 | install_element(BGP_NODE, | |
12034 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
12035 | install_element(BGP_NODE, | |
12036 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
12037 | install_element(BGP_IPV4_NODE, | |
12038 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12039 | install_element(BGP_IPV4_NODE, | |
12040 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12041 | install_element(BGP_IPV4M_NODE, | |
12042 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12043 | install_element(BGP_IPV4M_NODE, | |
12044 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12045 | install_element(BGP_IPV4L_NODE, | |
12046 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12047 | install_element(BGP_IPV4L_NODE, | |
12048 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12049 | install_element(BGP_IPV6_NODE, | |
12050 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12051 | install_element(BGP_IPV6_NODE, | |
12052 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12053 | install_element(BGP_IPV6M_NODE, | |
12054 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12055 | install_element(BGP_IPV6M_NODE, | |
12056 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12057 | install_element(BGP_IPV6L_NODE, | |
12058 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12059 | install_element(BGP_IPV6L_NODE, | |
12060 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12061 | install_element(BGP_VPNV4_NODE, | |
12062 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12063 | install_element(BGP_VPNV4_NODE, | |
12064 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12065 | install_element(BGP_VPNV6_NODE, | |
12066 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12067 | install_element(BGP_VPNV6_NODE, | |
12068 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12069 | ||
12070 | /* "neighbor passive" commands. */ | |
12071 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
12072 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
12073 | ||
12074 | ||
12075 | /* "neighbor shutdown" commands. */ | |
12076 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
12077 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
12078 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
12079 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
12080 | ||
12081 | /* "neighbor capability extended-nexthop" commands.*/ | |
12082 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
12083 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
12084 | ||
12085 | /* "neighbor capability orf prefix-list" commands.*/ | |
12086 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
12087 | install_element(BGP_NODE, | |
12088 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
12089 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
12090 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
12091 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
12092 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
12093 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
12094 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
12095 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
12096 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
12097 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
12098 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
12099 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
12100 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
12101 | ||
12102 | /* "neighbor capability dynamic" commands.*/ | |
12103 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
12104 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
12105 | ||
12106 | /* "neighbor dont-capability-negotiate" commands. */ | |
12107 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
12108 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
12109 | ||
12110 | /* "neighbor ebgp-multihop" commands. */ | |
12111 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
12112 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
12113 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
12114 | ||
12115 | /* "neighbor disable-connected-check" commands. */ | |
12116 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
12117 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
12118 | ||
12119 | /* "neighbor description" commands. */ | |
12120 | install_element(BGP_NODE, &neighbor_description_cmd); | |
12121 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
12122 | ||
12123 | /* "neighbor update-source" commands. "*/ | |
12124 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
12125 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
12126 | ||
12127 | /* "neighbor default-originate" commands. */ | |
12128 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
12129 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
12130 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
12131 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
12132 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
12133 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
12134 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
12135 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
12136 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
12137 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
12138 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
12139 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
12140 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
12141 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
12142 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
12143 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
12144 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
12145 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
12146 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
12147 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
12148 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
12149 | ||
12150 | /* "neighbor port" commands. */ | |
12151 | install_element(BGP_NODE, &neighbor_port_cmd); | |
12152 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
12153 | ||
12154 | /* "neighbor weight" commands. */ | |
12155 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
12156 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
12157 | ||
12158 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
12159 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
12160 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
12161 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
12162 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
12163 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
12164 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
12165 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
12166 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
12167 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
12168 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
12169 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
12170 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
12171 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
12172 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
12173 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
12174 | ||
12175 | /* "neighbor override-capability" commands. */ | |
12176 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
12177 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
12178 | ||
12179 | /* "neighbor strict-capability-match" commands. */ | |
12180 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
12181 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
12182 | ||
12183 | /* "neighbor timers" commands. */ | |
12184 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
12185 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
12186 | ||
12187 | /* "neighbor timers connect" commands. */ | |
12188 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
12189 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
12190 | ||
12191 | /* "neighbor advertisement-interval" commands. */ | |
12192 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
12193 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
12194 | ||
12195 | /* "neighbor interface" commands. */ | |
12196 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
12197 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
12198 | ||
12199 | /* "neighbor distribute" commands. */ | |
12200 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
12201 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
12202 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
12203 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
12204 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
12205 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
12206 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
12207 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
12208 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
12209 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
12210 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
12211 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
12212 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
12213 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
12214 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
12215 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
12216 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
12217 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
12218 | ||
12219 | /* "neighbor prefix-list" commands. */ | |
12220 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
12221 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
12222 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
12223 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
12224 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
12225 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
12226 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
12227 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
12228 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
12229 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
12230 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
12231 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
12232 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
12233 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
12234 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
12235 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
12236 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
12237 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
12238 | ||
12239 | /* "neighbor filter-list" commands. */ | |
12240 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
12241 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
12242 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
12243 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
12244 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
12245 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
12246 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
12247 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
12248 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
12249 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
12250 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
12251 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
12252 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
12253 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
12254 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
12255 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
12256 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
12257 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
12258 | ||
12259 | /* "neighbor route-map" commands. */ | |
12260 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
12261 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
12262 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
12263 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
12264 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
12265 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
12266 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
12267 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
12268 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
12269 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
12270 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
12271 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
12272 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
12273 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
12274 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
12275 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
12276 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
12277 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
12278 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
12279 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 12280 | |
12281 | /* "neighbor unsuppress-map" commands. */ | |
12282 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
12283 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
12284 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
12285 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
12286 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
12287 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
12288 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
12289 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
12290 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
12291 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
12292 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
12293 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
12294 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
12295 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
12296 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
12297 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
12298 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
12299 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
12300 | ||
12301 | /* "neighbor maximum-prefix" commands. */ | |
12302 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
12303 | install_element(BGP_NODE, | |
12304 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
12305 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
12306 | install_element(BGP_NODE, | |
12307 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
12308 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
12309 | install_element(BGP_NODE, | |
12310 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
12311 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
12312 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
12313 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12314 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12315 | install_element(BGP_IPV4_NODE, | |
12316 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12317 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12318 | install_element(BGP_IPV4_NODE, | |
12319 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12320 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
12321 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
12322 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12323 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12324 | install_element(BGP_IPV4M_NODE, | |
12325 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12326 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12327 | install_element(BGP_IPV4M_NODE, | |
12328 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12329 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
12330 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
12331 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12332 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12333 | install_element(BGP_IPV4L_NODE, | |
12334 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12335 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12336 | install_element(BGP_IPV4L_NODE, | |
12337 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12338 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
12339 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
12340 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12341 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12342 | install_element(BGP_IPV6_NODE, | |
12343 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12344 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12345 | install_element(BGP_IPV6_NODE, | |
12346 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12347 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
12348 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
12349 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12350 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12351 | install_element(BGP_IPV6M_NODE, | |
12352 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12353 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12354 | install_element(BGP_IPV6M_NODE, | |
12355 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12356 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
12357 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
12358 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12359 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12360 | install_element(BGP_IPV6L_NODE, | |
12361 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12362 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12363 | install_element(BGP_IPV6L_NODE, | |
12364 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12365 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
12366 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
12367 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12368 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12369 | install_element(BGP_VPNV4_NODE, | |
12370 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12371 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12372 | install_element(BGP_VPNV4_NODE, | |
12373 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12374 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
12375 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
12376 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12377 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12378 | install_element(BGP_VPNV6_NODE, | |
12379 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12380 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12381 | install_element(BGP_VPNV6_NODE, | |
12382 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12383 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
12384 | ||
12385 | /* "neighbor allowas-in" */ | |
12386 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
12387 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
12388 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
12389 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
12390 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
12391 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
12392 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
12393 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
12394 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
12395 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
12396 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
12397 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
12398 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
12399 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
12400 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
12401 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
12402 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
12403 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
12404 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
12405 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
12406 | ||
12407 | /* address-family commands. */ | |
12408 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
12409 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 12410 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 12411 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
12412 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 12413 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 12414 | |
d62a17ae | 12415 | install_element(BGP_NODE, &address_family_evpn_cmd); |
12416 | ||
12417 | /* "exit-address-family" command. */ | |
12418 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
12419 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
12420 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
12421 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
12422 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
12423 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
12424 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
12425 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
12426 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); | |
12427 | ||
12428 | /* "clear ip bgp commands" */ | |
12429 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
12430 | ||
12431 | /* clear ip bgp prefix */ | |
12432 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
12433 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
12434 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
12435 | ||
12436 | /* "show [ip] bgp summary" commands. */ | |
12437 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
12438 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd); | |
12439 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); | |
12440 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); | |
12441 | install_element(VIEW_NODE, &show_bgp_updgrps_adj_cmd); | |
12442 | install_element(VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); | |
12443 | install_element(VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); | |
12444 | install_element(VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); | |
12445 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); | |
12446 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); | |
12447 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); | |
12448 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
12449 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); | |
12450 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); | |
12451 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); | |
12452 | ||
12453 | /* "show [ip] bgp neighbors" commands. */ | |
12454 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
12455 | ||
12456 | /* "show [ip] bgp peer-group" commands. */ | |
12457 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
12458 | ||
12459 | /* "show [ip] bgp paths" commands. */ | |
12460 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
12461 | ||
12462 | /* "show [ip] bgp community" commands. */ | |
12463 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
12464 | ||
12465 | /* "show ip bgp large-community" commands. */ | |
12466 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
12467 | /* "show [ip] bgp attribute-info" commands. */ | |
12468 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
12469 | ||
12470 | /* "redistribute" commands. */ | |
12471 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
12472 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
12473 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
12474 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
12475 | install_element(BGP_NODE, | |
12476 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
12477 | install_element(BGP_NODE, | |
12478 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
12479 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
12480 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
12481 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
12482 | install_element(BGP_NODE, | |
12483 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
12484 | install_element(BGP_NODE, | |
12485 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
12486 | install_element(BGP_NODE, | |
12487 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
12488 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
12489 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
12490 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
12491 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
12492 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
12493 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
12494 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
12495 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
12496 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
12497 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
12498 | install_element(BGP_IPV4_NODE, | |
12499 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
12500 | install_element(BGP_IPV4_NODE, | |
12501 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
12502 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
12503 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
12504 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
12505 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
12506 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
12507 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
12508 | ||
12509 | /* ttl_security commands */ | |
12510 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
12511 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
12512 | ||
12513 | /* "show [ip] bgp memory" commands. */ | |
12514 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
12515 | ||
acf71666 MK |
12516 | /* "show bgp martian next-hop" */ |
12517 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
12518 | ||
d62a17ae | 12519 | /* "show [ip] bgp views" commands. */ |
12520 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
12521 | ||
12522 | /* "show [ip] bgp vrfs" commands. */ | |
12523 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
12524 | ||
12525 | /* Community-list. */ | |
12526 | community_list_vty(); | |
718e3744 | 12527 | } |
6b0655a2 | 12528 | |
718e3744 | 12529 | #include "memory.h" |
12530 | #include "bgp_regex.h" | |
12531 | #include "bgp_clist.h" | |
12532 | #include "bgp_ecommunity.h" | |
12533 | ||
12534 | /* VTY functions. */ | |
12535 | ||
12536 | /* Direction value to string conversion. */ | |
d62a17ae | 12537 | static const char *community_direct_str(int direct) |
12538 | { | |
12539 | switch (direct) { | |
12540 | case COMMUNITY_DENY: | |
12541 | return "deny"; | |
12542 | case COMMUNITY_PERMIT: | |
12543 | return "permit"; | |
12544 | default: | |
12545 | return "unknown"; | |
12546 | } | |
718e3744 | 12547 | } |
12548 | ||
12549 | /* Display error string. */ | |
d62a17ae | 12550 | static void community_list_perror(struct vty *vty, int ret) |
12551 | { | |
12552 | switch (ret) { | |
12553 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
12554 | vty_out(vty, "%% Can't find community-list\n"); | |
12555 | break; | |
12556 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
12557 | vty_out(vty, "%% Malformed community-list value\n"); | |
12558 | break; | |
12559 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
12560 | vty_out(vty, | |
12561 | "%% Community name conflict, previously defined as standard community\n"); | |
12562 | break; | |
12563 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
12564 | vty_out(vty, | |
12565 | "%% Community name conflict, previously defined as expanded community\n"); | |
12566 | break; | |
12567 | } | |
718e3744 | 12568 | } |
12569 | ||
5bf15956 DW |
12570 | /* "community-list" keyword help string. */ |
12571 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
12572 | ||
5bf15956 | 12573 | /* ip community-list standard */ |
718e3744 | 12574 | DEFUN (ip_community_list_standard, |
12575 | ip_community_list_standard_cmd, | |
e961923c | 12576 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 12577 | IP_STR |
12578 | COMMUNITY_LIST_STR | |
12579 | "Community list number (standard)\n" | |
5bf15956 | 12580 | "Add an standard community-list entry\n" |
718e3744 | 12581 | "Community list name\n" |
12582 | "Specify community to reject\n" | |
12583 | "Specify community to accept\n" | |
12584 | COMMUNITY_VAL_STR) | |
12585 | { | |
d62a17ae | 12586 | char *cl_name_or_number = NULL; |
12587 | int direct = 0; | |
12588 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 12589 | |
d62a17ae | 12590 | int idx = 0; |
12591 | argv_find(argv, argc, "(1-99)", &idx); | |
12592 | argv_find(argv, argc, "WORD", &idx); | |
12593 | cl_name_or_number = argv[idx]->arg; | |
12594 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12595 | : COMMUNITY_DENY; | |
12596 | argv_find(argv, argc, "AA:NN", &idx); | |
12597 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12598 | |
d62a17ae | 12599 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
12600 | style); | |
42f914d4 | 12601 | |
d62a17ae | 12602 | XFREE(MTYPE_TMP, str); |
42f914d4 | 12603 | |
d62a17ae | 12604 | if (ret < 0) { |
12605 | /* Display error string. */ | |
12606 | community_list_perror(vty, ret); | |
12607 | return CMD_WARNING_CONFIG_FAILED; | |
12608 | } | |
42f914d4 | 12609 | |
d62a17ae | 12610 | return CMD_SUCCESS; |
718e3744 | 12611 | } |
12612 | ||
fee6e4e4 | 12613 | DEFUN (no_ip_community_list_standard_all, |
12614 | no_ip_community_list_standard_all_cmd, | |
e961923c | 12615 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 12616 | NO_STR |
12617 | IP_STR | |
12618 | COMMUNITY_LIST_STR | |
12619 | "Community list number (standard)\n" | |
5bf15956 DW |
12620 | "Add an standard community-list entry\n" |
12621 | "Community list name\n" | |
718e3744 | 12622 | "Specify community to reject\n" |
12623 | "Specify community to accept\n" | |
12624 | COMMUNITY_VAL_STR) | |
12625 | { | |
d62a17ae | 12626 | int delete_all = 0; |
42f914d4 | 12627 | |
d62a17ae | 12628 | char *cl_name_or_number = NULL; |
12629 | int direct = 0; | |
12630 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 12631 | |
d62a17ae | 12632 | int idx = 0; |
12633 | argv_find(argv, argc, "(1-99)", &idx); | |
12634 | argv_find(argv, argc, "WORD", &idx); | |
12635 | cl_name_or_number = argv[idx]->arg; | |
12636 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12637 | : COMMUNITY_DENY; | |
12638 | argv_find(argv, argc, "AA:NN", &idx); | |
12639 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12640 | |
d62a17ae | 12641 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
12642 | direct, style, delete_all); | |
42f914d4 | 12643 | |
d62a17ae | 12644 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 12645 | |
d62a17ae | 12646 | if (ret < 0) { |
12647 | community_list_perror(vty, ret); | |
12648 | return CMD_WARNING_CONFIG_FAILED; | |
12649 | } | |
42f914d4 | 12650 | |
d62a17ae | 12651 | return CMD_SUCCESS; |
718e3744 | 12652 | } |
12653 | ||
5bf15956 DW |
12654 | /* ip community-list expanded */ |
12655 | DEFUN (ip_community_list_expanded_all, | |
12656 | ip_community_list_expanded_all_cmd, | |
42f914d4 | 12657 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 12658 | IP_STR |
12659 | COMMUNITY_LIST_STR | |
12660 | "Community list number (expanded)\n" | |
5bf15956 | 12661 | "Add an expanded community-list entry\n" |
718e3744 | 12662 | "Community list name\n" |
12663 | "Specify community to reject\n" | |
12664 | "Specify community to accept\n" | |
12665 | COMMUNITY_VAL_STR) | |
12666 | { | |
d62a17ae | 12667 | char *cl_name_or_number = NULL; |
12668 | int direct = 0; | |
12669 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 12670 | |
d62a17ae | 12671 | int idx = 0; |
12672 | argv_find(argv, argc, "(100-500)", &idx); | |
12673 | argv_find(argv, argc, "WORD", &idx); | |
12674 | cl_name_or_number = argv[idx]->arg; | |
12675 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12676 | : COMMUNITY_DENY; | |
12677 | argv_find(argv, argc, "AA:NN", &idx); | |
12678 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12679 | |
d62a17ae | 12680 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
12681 | style); | |
42f914d4 | 12682 | |
d62a17ae | 12683 | XFREE(MTYPE_TMP, str); |
42f914d4 | 12684 | |
d62a17ae | 12685 | if (ret < 0) { |
12686 | /* Display error string. */ | |
12687 | community_list_perror(vty, ret); | |
12688 | return CMD_WARNING_CONFIG_FAILED; | |
12689 | } | |
42f914d4 | 12690 | |
d62a17ae | 12691 | return CMD_SUCCESS; |
718e3744 | 12692 | } |
12693 | ||
5bf15956 DW |
12694 | DEFUN (no_ip_community_list_expanded_all, |
12695 | no_ip_community_list_expanded_all_cmd, | |
42f914d4 | 12696 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 12697 | NO_STR |
12698 | IP_STR | |
12699 | COMMUNITY_LIST_STR | |
5bf15956 DW |
12700 | "Community list number (expanded)\n" |
12701 | "Add an expanded community-list entry\n" | |
718e3744 | 12702 | "Community list name\n" |
12703 | "Specify community to reject\n" | |
12704 | "Specify community to accept\n" | |
5bf15956 | 12705 | COMMUNITY_VAL_STR) |
718e3744 | 12706 | { |
d62a17ae | 12707 | int delete_all = 0; |
42f914d4 | 12708 | |
d62a17ae | 12709 | char *cl_name_or_number = NULL; |
12710 | int direct = 0; | |
12711 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 12712 | |
d62a17ae | 12713 | int idx = 0; |
12714 | argv_find(argv, argc, "(100-500)", &idx); | |
12715 | argv_find(argv, argc, "WORD", &idx); | |
12716 | cl_name_or_number = argv[idx]->arg; | |
12717 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12718 | : COMMUNITY_DENY; | |
12719 | argv_find(argv, argc, "AA:NN", &idx); | |
12720 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12721 | |
d62a17ae | 12722 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
12723 | direct, style, delete_all); | |
42f914d4 | 12724 | |
d62a17ae | 12725 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 12726 | |
d62a17ae | 12727 | if (ret < 0) { |
12728 | community_list_perror(vty, ret); | |
12729 | return CMD_WARNING_CONFIG_FAILED; | |
12730 | } | |
42f914d4 | 12731 | |
d62a17ae | 12732 | return CMD_SUCCESS; |
718e3744 | 12733 | } |
12734 | ||
d62a17ae | 12735 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 12736 | { |
d62a17ae | 12737 | struct community_entry *entry; |
718e3744 | 12738 | |
d62a17ae | 12739 | for (entry = list->head; entry; entry = entry->next) { |
12740 | if (entry == list->head) { | |
12741 | if (all_digit(list->name)) | |
12742 | vty_out(vty, "Community %s list %s\n", | |
12743 | entry->style == COMMUNITY_LIST_STANDARD | |
12744 | ? "standard" | |
12745 | : "(expanded) access", | |
12746 | list->name); | |
12747 | else | |
12748 | vty_out(vty, "Named Community %s list %s\n", | |
12749 | entry->style == COMMUNITY_LIST_STANDARD | |
12750 | ? "standard" | |
12751 | : "expanded", | |
12752 | list->name); | |
12753 | } | |
12754 | if (entry->any) | |
12755 | vty_out(vty, " %s\n", | |
12756 | community_direct_str(entry->direct)); | |
12757 | else | |
12758 | vty_out(vty, " %s %s\n", | |
12759 | community_direct_str(entry->direct), | |
12760 | entry->style == COMMUNITY_LIST_STANDARD | |
a69ea8ae | 12761 | ? community_str(entry->u.com, false) |
d62a17ae | 12762 | : entry->config); |
12763 | } | |
718e3744 | 12764 | } |
12765 | ||
12766 | DEFUN (show_ip_community_list, | |
12767 | show_ip_community_list_cmd, | |
12768 | "show ip community-list", | |
12769 | SHOW_STR | |
12770 | IP_STR | |
12771 | "List community-list\n") | |
12772 | { | |
d62a17ae | 12773 | struct community_list *list; |
12774 | struct community_list_master *cm; | |
718e3744 | 12775 | |
d62a17ae | 12776 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
12777 | if (!cm) | |
12778 | return CMD_SUCCESS; | |
718e3744 | 12779 | |
d62a17ae | 12780 | for (list = cm->num.head; list; list = list->next) |
12781 | community_list_show(vty, list); | |
718e3744 | 12782 | |
d62a17ae | 12783 | for (list = cm->str.head; list; list = list->next) |
12784 | community_list_show(vty, list); | |
718e3744 | 12785 | |
d62a17ae | 12786 | return CMD_SUCCESS; |
718e3744 | 12787 | } |
12788 | ||
12789 | DEFUN (show_ip_community_list_arg, | |
12790 | show_ip_community_list_arg_cmd, | |
6147e2c6 | 12791 | "show ip community-list <(1-500)|WORD>", |
718e3744 | 12792 | SHOW_STR |
12793 | IP_STR | |
12794 | "List community-list\n" | |
12795 | "Community-list number\n" | |
12796 | "Community-list name\n") | |
12797 | { | |
d62a17ae | 12798 | int idx_comm_list = 3; |
12799 | struct community_list *list; | |
718e3744 | 12800 | |
d62a17ae | 12801 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
12802 | COMMUNITY_LIST_MASTER); | |
12803 | if (!list) { | |
12804 | vty_out(vty, "%% Can't find community-list\n"); | |
12805 | return CMD_WARNING; | |
12806 | } | |
718e3744 | 12807 | |
d62a17ae | 12808 | community_list_show(vty, list); |
718e3744 | 12809 | |
d62a17ae | 12810 | return CMD_SUCCESS; |
718e3744 | 12811 | } |
6b0655a2 | 12812 | |
57d187bc JS |
12813 | /* |
12814 | * Large Community code. | |
12815 | */ | |
d62a17ae | 12816 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
12817 | struct cmd_token **argv, int style, | |
12818 | int reject_all_digit_name) | |
12819 | { | |
12820 | int ret; | |
12821 | int direct; | |
12822 | char *str; | |
12823 | int idx = 0; | |
12824 | char *cl_name; | |
12825 | ||
12826 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12827 | : COMMUNITY_DENY; | |
12828 | ||
12829 | /* All digit name check. */ | |
12830 | idx = 0; | |
12831 | argv_find(argv, argc, "WORD", &idx); | |
12832 | argv_find(argv, argc, "(1-99)", &idx); | |
12833 | argv_find(argv, argc, "(100-500)", &idx); | |
12834 | cl_name = argv[idx]->arg; | |
12835 | if (reject_all_digit_name && all_digit(cl_name)) { | |
12836 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
12837 | return CMD_WARNING_CONFIG_FAILED; | |
12838 | } | |
12839 | ||
12840 | idx = 0; | |
12841 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
12842 | argv_find(argv, argc, "LINE", &idx); | |
12843 | /* Concat community string argument. */ | |
12844 | if (idx) | |
12845 | str = argv_concat(argv, argc, idx); | |
12846 | else | |
12847 | str = NULL; | |
12848 | ||
12849 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
12850 | ||
12851 | /* Free temporary community list string allocated by | |
12852 | argv_concat(). */ | |
12853 | if (str) | |
12854 | XFREE(MTYPE_TMP, str); | |
12855 | ||
12856 | if (ret < 0) { | |
12857 | community_list_perror(vty, ret); | |
12858 | return CMD_WARNING_CONFIG_FAILED; | |
12859 | } | |
12860 | return CMD_SUCCESS; | |
12861 | } | |
12862 | ||
12863 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
12864 | struct cmd_token **argv, int style) | |
12865 | { | |
12866 | int ret; | |
12867 | int direct = 0; | |
12868 | char *str = NULL; | |
12869 | int idx = 0; | |
12870 | ||
12871 | argv_find(argv, argc, "permit", &idx); | |
12872 | argv_find(argv, argc, "deny", &idx); | |
12873 | ||
12874 | if (idx) { | |
12875 | /* Check the list direct. */ | |
12876 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
12877 | direct = COMMUNITY_PERMIT; | |
12878 | else | |
12879 | direct = COMMUNITY_DENY; | |
12880 | ||
12881 | idx = 0; | |
12882 | argv_find(argv, argc, "LINE", &idx); | |
12883 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
12884 | /* Concat community string argument. */ | |
12885 | str = argv_concat(argv, argc, idx); | |
12886 | } | |
12887 | ||
12888 | idx = 0; | |
12889 | argv_find(argv, argc, "(1-99)", &idx); | |
12890 | argv_find(argv, argc, "(100-500)", &idx); | |
12891 | argv_find(argv, argc, "WORD", &idx); | |
12892 | ||
12893 | /* Unset community list. */ | |
12894 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
12895 | style); | |
12896 | ||
12897 | /* Free temporary community list string allocated by | |
12898 | argv_concat(). */ | |
12899 | if (str) | |
12900 | XFREE(MTYPE_TMP, str); | |
12901 | ||
12902 | if (ret < 0) { | |
12903 | community_list_perror(vty, ret); | |
12904 | return CMD_WARNING_CONFIG_FAILED; | |
12905 | } | |
12906 | ||
12907 | return CMD_SUCCESS; | |
57d187bc JS |
12908 | } |
12909 | ||
12910 | /* "large-community-list" keyword help string. */ | |
12911 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
12912 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
12913 | ||
12914 | DEFUN (ip_lcommunity_list_standard, | |
12915 | ip_lcommunity_list_standard_cmd, | |
52951b63 DS |
12916 | "ip large-community-list (1-99) <deny|permit>", |
12917 | IP_STR | |
12918 | LCOMMUNITY_LIST_STR | |
12919 | "Large Community list number (standard)\n" | |
12920 | "Specify large community to reject\n" | |
7111c1a0 | 12921 | "Specify large community to accept\n") |
52951b63 | 12922 | { |
d62a17ae | 12923 | return lcommunity_list_set_vty(vty, argc, argv, |
12924 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
12925 | } |
12926 | ||
12927 | DEFUN (ip_lcommunity_list_standard1, | |
12928 | ip_lcommunity_list_standard1_cmd, | |
12929 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
12930 | IP_STR |
12931 | LCOMMUNITY_LIST_STR | |
12932 | "Large Community list number (standard)\n" | |
12933 | "Specify large community to reject\n" | |
12934 | "Specify large community to accept\n" | |
12935 | LCOMMUNITY_VAL_STR) | |
12936 | { | |
d62a17ae | 12937 | return lcommunity_list_set_vty(vty, argc, argv, |
12938 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
57d187bc JS |
12939 | } |
12940 | ||
12941 | DEFUN (ip_lcommunity_list_expanded, | |
12942 | ip_lcommunity_list_expanded_cmd, | |
12943 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
12944 | IP_STR | |
12945 | LCOMMUNITY_LIST_STR | |
12946 | "Large Community list number (expanded)\n" | |
12947 | "Specify large community to reject\n" | |
12948 | "Specify large community to accept\n" | |
12949 | "An ordered list as a regular-expression\n") | |
12950 | { | |
d62a17ae | 12951 | return lcommunity_list_set_vty(vty, argc, argv, |
12952 | LARGE_COMMUNITY_LIST_EXPANDED, 0); | |
57d187bc JS |
12953 | } |
12954 | ||
12955 | DEFUN (ip_lcommunity_list_name_standard, | |
12956 | ip_lcommunity_list_name_standard_cmd, | |
52951b63 DS |
12957 | "ip large-community-list standard WORD <deny|permit>", |
12958 | IP_STR | |
12959 | LCOMMUNITY_LIST_STR | |
12960 | "Specify standard large-community-list\n" | |
12961 | "Large Community list name\n" | |
12962 | "Specify large community to reject\n" | |
12963 | "Specify large community to accept\n") | |
12964 | { | |
d62a17ae | 12965 | return lcommunity_list_set_vty(vty, argc, argv, |
12966 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
12967 | } |
12968 | ||
12969 | DEFUN (ip_lcommunity_list_name_standard1, | |
12970 | ip_lcommunity_list_name_standard1_cmd, | |
12971 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
12972 | IP_STR |
12973 | LCOMMUNITY_LIST_STR | |
12974 | "Specify standard large-community-list\n" | |
12975 | "Large Community list name\n" | |
12976 | "Specify large community to reject\n" | |
12977 | "Specify large community to accept\n" | |
12978 | LCOMMUNITY_VAL_STR) | |
12979 | { | |
d62a17ae | 12980 | return lcommunity_list_set_vty(vty, argc, argv, |
12981 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
57d187bc JS |
12982 | } |
12983 | ||
12984 | DEFUN (ip_lcommunity_list_name_expanded, | |
12985 | ip_lcommunity_list_name_expanded_cmd, | |
12986 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
12987 | IP_STR | |
12988 | LCOMMUNITY_LIST_STR | |
12989 | "Specify expanded large-community-list\n" | |
12990 | "Large Community list name\n" | |
12991 | "Specify large community to reject\n" | |
12992 | "Specify large community to accept\n" | |
12993 | "An ordered list as a regular-expression\n") | |
12994 | { | |
d62a17ae | 12995 | return lcommunity_list_set_vty(vty, argc, argv, |
12996 | LARGE_COMMUNITY_LIST_EXPANDED, 1); | |
57d187bc JS |
12997 | } |
12998 | ||
12999 | DEFUN (no_ip_lcommunity_list_standard_all, | |
13000 | no_ip_lcommunity_list_standard_all_cmd, | |
13001 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
13002 | NO_STR | |
13003 | IP_STR | |
13004 | LCOMMUNITY_LIST_STR | |
13005 | "Large Community list number (standard)\n" | |
13006 | "Large Community list number (expanded)\n" | |
13007 | "Large Community list name\n") | |
13008 | { | |
d62a17ae | 13009 | return lcommunity_list_unset_vty(vty, argc, argv, |
13010 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
13011 | } |
13012 | ||
13013 | DEFUN (no_ip_lcommunity_list_name_expanded_all, | |
13014 | no_ip_lcommunity_list_name_expanded_all_cmd, | |
13015 | "no ip large-community-list expanded WORD", | |
13016 | NO_STR | |
13017 | IP_STR | |
13018 | LCOMMUNITY_LIST_STR | |
13019 | "Specify expanded large-community-list\n" | |
13020 | "Large Community list name\n") | |
13021 | { | |
d62a17ae | 13022 | return lcommunity_list_unset_vty(vty, argc, argv, |
13023 | LARGE_COMMUNITY_LIST_EXPANDED); | |
57d187bc JS |
13024 | } |
13025 | ||
13026 | DEFUN (no_ip_lcommunity_list_standard, | |
13027 | no_ip_lcommunity_list_standard_cmd, | |
13028 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
13029 | NO_STR | |
13030 | IP_STR | |
13031 | LCOMMUNITY_LIST_STR | |
13032 | "Large Community list number (standard)\n" | |
13033 | "Specify large community to reject\n" | |
13034 | "Specify large community to accept\n" | |
13035 | LCOMMUNITY_VAL_STR) | |
13036 | { | |
d62a17ae | 13037 | return lcommunity_list_unset_vty(vty, argc, argv, |
13038 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
13039 | } |
13040 | ||
13041 | DEFUN (no_ip_lcommunity_list_expanded, | |
13042 | no_ip_lcommunity_list_expanded_cmd, | |
13043 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
13044 | NO_STR | |
13045 | IP_STR | |
13046 | LCOMMUNITY_LIST_STR | |
13047 | "Large Community list number (expanded)\n" | |
13048 | "Specify large community to reject\n" | |
13049 | "Specify large community to accept\n" | |
13050 | "An ordered list as a regular-expression\n") | |
13051 | { | |
d62a17ae | 13052 | return lcommunity_list_unset_vty(vty, argc, argv, |
13053 | LARGE_COMMUNITY_LIST_EXPANDED); | |
57d187bc JS |
13054 | } |
13055 | ||
13056 | DEFUN (no_ip_lcommunity_list_name_standard, | |
13057 | no_ip_lcommunity_list_name_standard_cmd, | |
13058 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
13059 | NO_STR | |
13060 | IP_STR | |
13061 | LCOMMUNITY_LIST_STR | |
13062 | "Specify standard large-community-list\n" | |
13063 | "Large Community list name\n" | |
13064 | "Specify large community to reject\n" | |
13065 | "Specify large community to accept\n" | |
13066 | LCOMMUNITY_VAL_STR) | |
13067 | { | |
d62a17ae | 13068 | return lcommunity_list_unset_vty(vty, argc, argv, |
13069 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
13070 | } |
13071 | ||
13072 | DEFUN (no_ip_lcommunity_list_name_expanded, | |
13073 | no_ip_lcommunity_list_name_expanded_cmd, | |
13074 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
13075 | NO_STR | |
13076 | IP_STR | |
13077 | LCOMMUNITY_LIST_STR | |
13078 | "Specify expanded large-community-list\n" | |
13079 | "Large community list name\n" | |
13080 | "Specify large community to reject\n" | |
13081 | "Specify large community to accept\n" | |
13082 | "An ordered list as a regular-expression\n") | |
13083 | { | |
d62a17ae | 13084 | return lcommunity_list_unset_vty(vty, argc, argv, |
13085 | LARGE_COMMUNITY_LIST_EXPANDED); | |
13086 | } | |
13087 | ||
13088 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) | |
13089 | { | |
13090 | struct community_entry *entry; | |
13091 | ||
13092 | for (entry = list->head; entry; entry = entry->next) { | |
13093 | if (entry == list->head) { | |
13094 | if (all_digit(list->name)) | |
13095 | vty_out(vty, "Large community %s list %s\n", | |
13096 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13097 | ? "standard" | |
13098 | : "(expanded) access", | |
13099 | list->name); | |
13100 | else | |
13101 | vty_out(vty, | |
13102 | "Named large community %s list %s\n", | |
13103 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13104 | ? "standard" | |
13105 | : "expanded", | |
13106 | list->name); | |
13107 | } | |
13108 | if (entry->any) | |
13109 | vty_out(vty, " %s\n", | |
13110 | community_direct_str(entry->direct)); | |
13111 | else | |
13112 | vty_out(vty, " %s %s\n", | |
13113 | community_direct_str(entry->direct), | |
13114 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13115 | ? entry->u.ecom->str | |
13116 | : entry->config); | |
13117 | } | |
57d187bc JS |
13118 | } |
13119 | ||
13120 | DEFUN (show_ip_lcommunity_list, | |
13121 | show_ip_lcommunity_list_cmd, | |
13122 | "show ip large-community-list", | |
13123 | SHOW_STR | |
13124 | IP_STR | |
13125 | "List large-community list\n") | |
13126 | { | |
d62a17ae | 13127 | struct community_list *list; |
13128 | struct community_list_master *cm; | |
57d187bc | 13129 | |
d62a17ae | 13130 | cm = community_list_master_lookup(bgp_clist, |
13131 | LARGE_COMMUNITY_LIST_MASTER); | |
13132 | if (!cm) | |
13133 | return CMD_SUCCESS; | |
57d187bc | 13134 | |
d62a17ae | 13135 | for (list = cm->num.head; list; list = list->next) |
13136 | lcommunity_list_show(vty, list); | |
57d187bc | 13137 | |
d62a17ae | 13138 | for (list = cm->str.head; list; list = list->next) |
13139 | lcommunity_list_show(vty, list); | |
57d187bc | 13140 | |
d62a17ae | 13141 | return CMD_SUCCESS; |
57d187bc JS |
13142 | } |
13143 | ||
13144 | DEFUN (show_ip_lcommunity_list_arg, | |
13145 | show_ip_lcommunity_list_arg_cmd, | |
13146 | "show ip large-community-list <(1-500)|WORD>", | |
13147 | SHOW_STR | |
13148 | IP_STR | |
13149 | "List large-community list\n" | |
13150 | "large-community-list number\n" | |
13151 | "large-community-list name\n") | |
13152 | { | |
d62a17ae | 13153 | struct community_list *list; |
57d187bc | 13154 | |
d62a17ae | 13155 | list = community_list_lookup(bgp_clist, argv[3]->arg, |
13156 | LARGE_COMMUNITY_LIST_MASTER); | |
13157 | if (!list) { | |
13158 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
13159 | return CMD_WARNING; | |
13160 | } | |
57d187bc | 13161 | |
d62a17ae | 13162 | lcommunity_list_show(vty, list); |
57d187bc | 13163 | |
d62a17ae | 13164 | return CMD_SUCCESS; |
57d187bc JS |
13165 | } |
13166 | ||
718e3744 | 13167 | /* "extcommunity-list" keyword help string. */ |
13168 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
13169 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
13170 | ||
13171 | DEFUN (ip_extcommunity_list_standard, | |
13172 | ip_extcommunity_list_standard_cmd, | |
e961923c | 13173 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 13174 | IP_STR |
13175 | EXTCOMMUNITY_LIST_STR | |
13176 | "Extended Community list number (standard)\n" | |
718e3744 | 13177 | "Specify standard extcommunity-list\n" |
5bf15956 | 13178 | "Community list name\n" |
718e3744 | 13179 | "Specify community to reject\n" |
13180 | "Specify community to accept\n" | |
13181 | EXTCOMMUNITY_VAL_STR) | |
13182 | { | |
d62a17ae | 13183 | int style = EXTCOMMUNITY_LIST_STANDARD; |
13184 | int direct = 0; | |
13185 | char *cl_number_or_name = NULL; | |
42f914d4 | 13186 | |
d62a17ae | 13187 | int idx = 0; |
13188 | argv_find(argv, argc, "(1-99)", &idx); | |
13189 | argv_find(argv, argc, "WORD", &idx); | |
13190 | cl_number_or_name = argv[idx]->arg; | |
13191 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13192 | : COMMUNITY_DENY; | |
13193 | argv_find(argv, argc, "AA:NN", &idx); | |
13194 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13195 | |
d62a17ae | 13196 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
13197 | direct, style); | |
42f914d4 | 13198 | |
d62a17ae | 13199 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13200 | |
d62a17ae | 13201 | if (ret < 0) { |
13202 | community_list_perror(vty, ret); | |
13203 | return CMD_WARNING_CONFIG_FAILED; | |
13204 | } | |
42f914d4 | 13205 | |
d62a17ae | 13206 | return CMD_SUCCESS; |
718e3744 | 13207 | } |
13208 | ||
718e3744 | 13209 | DEFUN (ip_extcommunity_list_name_expanded, |
13210 | ip_extcommunity_list_name_expanded_cmd, | |
e961923c | 13211 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 13212 | IP_STR |
13213 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 13214 | "Extended Community list number (expanded)\n" |
718e3744 | 13215 | "Specify expanded extcommunity-list\n" |
13216 | "Extended Community list name\n" | |
13217 | "Specify community to reject\n" | |
13218 | "Specify community to accept\n" | |
13219 | "An ordered list as a regular-expression\n") | |
13220 | { | |
d62a17ae | 13221 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
13222 | int direct = 0; | |
13223 | char *cl_number_or_name = NULL; | |
42f914d4 | 13224 | |
d62a17ae | 13225 | int idx = 0; |
13226 | argv_find(argv, argc, "(100-500)", &idx); | |
13227 | argv_find(argv, argc, "WORD", &idx); | |
13228 | cl_number_or_name = argv[idx]->arg; | |
13229 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13230 | : COMMUNITY_DENY; | |
13231 | argv_find(argv, argc, "LINE", &idx); | |
13232 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13233 | |
d62a17ae | 13234 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
13235 | direct, style); | |
42f914d4 | 13236 | |
d62a17ae | 13237 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13238 | |
d62a17ae | 13239 | if (ret < 0) { |
13240 | community_list_perror(vty, ret); | |
13241 | return CMD_WARNING_CONFIG_FAILED; | |
13242 | } | |
42f914d4 | 13243 | |
d62a17ae | 13244 | return CMD_SUCCESS; |
718e3744 | 13245 | } |
13246 | ||
fee6e4e4 | 13247 | DEFUN (no_ip_extcommunity_list_standard_all, |
13248 | no_ip_extcommunity_list_standard_all_cmd, | |
e961923c | 13249 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
813d4307 DW |
13250 | NO_STR |
13251 | IP_STR | |
13252 | EXTCOMMUNITY_LIST_STR | |
13253 | "Extended Community list number (standard)\n" | |
718e3744 | 13254 | "Specify standard extcommunity-list\n" |
5bf15956 | 13255 | "Community list name\n" |
718e3744 | 13256 | "Specify community to reject\n" |
13257 | "Specify community to accept\n" | |
13258 | EXTCOMMUNITY_VAL_STR) | |
13259 | { | |
d62a17ae | 13260 | int deleteall = 0; |
42f914d4 | 13261 | |
d62a17ae | 13262 | int style = EXTCOMMUNITY_LIST_STANDARD; |
13263 | int direct = 0; | |
13264 | char *cl_number_or_name = NULL; | |
42f914d4 | 13265 | |
d62a17ae | 13266 | int idx = 0; |
13267 | argv_find(argv, argc, "(1-99)", &idx); | |
13268 | argv_find(argv, argc, "WORD", &idx); | |
13269 | cl_number_or_name = argv[idx]->arg; | |
13270 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13271 | : COMMUNITY_DENY; | |
13272 | argv_find(argv, argc, "AA:NN", &idx); | |
13273 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13274 | |
d62a17ae | 13275 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
13276 | direct, style, deleteall); | |
42f914d4 | 13277 | |
d62a17ae | 13278 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13279 | |
d62a17ae | 13280 | if (ret < 0) { |
13281 | community_list_perror(vty, ret); | |
13282 | return CMD_WARNING_CONFIG_FAILED; | |
13283 | } | |
42f914d4 | 13284 | |
d62a17ae | 13285 | return CMD_SUCCESS; |
718e3744 | 13286 | } |
13287 | ||
5bf15956 DW |
13288 | DEFUN (no_ip_extcommunity_list_expanded_all, |
13289 | no_ip_extcommunity_list_expanded_all_cmd, | |
e961923c | 13290 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 13291 | NO_STR |
13292 | IP_STR | |
13293 | EXTCOMMUNITY_LIST_STR | |
13294 | "Extended Community list number (expanded)\n" | |
718e3744 | 13295 | "Specify expanded extcommunity-list\n" |
5bf15956 | 13296 | "Extended Community list name\n" |
718e3744 | 13297 | "Specify community to reject\n" |
13298 | "Specify community to accept\n" | |
13299 | "An ordered list as a regular-expression\n") | |
13300 | { | |
d62a17ae | 13301 | int deleteall = 0; |
42f914d4 | 13302 | |
d62a17ae | 13303 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
13304 | int direct = 0; | |
13305 | char *cl_number_or_name = NULL; | |
42f914d4 | 13306 | |
d62a17ae | 13307 | int idx = 0; |
13308 | argv_find(argv, argc, "(100-500)", &idx); | |
13309 | argv_find(argv, argc, "WORD", &idx); | |
13310 | cl_number_or_name = argv[idx]->arg; | |
13311 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13312 | : COMMUNITY_DENY; | |
13313 | argv_find(argv, argc, "LINE", &idx); | |
13314 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13315 | |
d62a17ae | 13316 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
13317 | direct, style, deleteall); | |
42f914d4 | 13318 | |
d62a17ae | 13319 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13320 | |
d62a17ae | 13321 | if (ret < 0) { |
13322 | community_list_perror(vty, ret); | |
13323 | return CMD_WARNING_CONFIG_FAILED; | |
13324 | } | |
42f914d4 | 13325 | |
d62a17ae | 13326 | return CMD_SUCCESS; |
718e3744 | 13327 | } |
13328 | ||
d62a17ae | 13329 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 13330 | { |
d62a17ae | 13331 | struct community_entry *entry; |
718e3744 | 13332 | |
d62a17ae | 13333 | for (entry = list->head; entry; entry = entry->next) { |
13334 | if (entry == list->head) { | |
13335 | if (all_digit(list->name)) | |
13336 | vty_out(vty, "Extended community %s list %s\n", | |
13337 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13338 | ? "standard" | |
13339 | : "(expanded) access", | |
13340 | list->name); | |
13341 | else | |
13342 | vty_out(vty, | |
13343 | "Named extended community %s list %s\n", | |
13344 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13345 | ? "standard" | |
13346 | : "expanded", | |
13347 | list->name); | |
13348 | } | |
13349 | if (entry->any) | |
13350 | vty_out(vty, " %s\n", | |
13351 | community_direct_str(entry->direct)); | |
13352 | else | |
13353 | vty_out(vty, " %s %s\n", | |
13354 | community_direct_str(entry->direct), | |
13355 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13356 | ? entry->u.ecom->str | |
13357 | : entry->config); | |
13358 | } | |
718e3744 | 13359 | } |
13360 | ||
13361 | DEFUN (show_ip_extcommunity_list, | |
13362 | show_ip_extcommunity_list_cmd, | |
13363 | "show ip extcommunity-list", | |
13364 | SHOW_STR | |
13365 | IP_STR | |
13366 | "List extended-community list\n") | |
13367 | { | |
d62a17ae | 13368 | struct community_list *list; |
13369 | struct community_list_master *cm; | |
718e3744 | 13370 | |
d62a17ae | 13371 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
13372 | if (!cm) | |
13373 | return CMD_SUCCESS; | |
718e3744 | 13374 | |
d62a17ae | 13375 | for (list = cm->num.head; list; list = list->next) |
13376 | extcommunity_list_show(vty, list); | |
718e3744 | 13377 | |
d62a17ae | 13378 | for (list = cm->str.head; list; list = list->next) |
13379 | extcommunity_list_show(vty, list); | |
718e3744 | 13380 | |
d62a17ae | 13381 | return CMD_SUCCESS; |
718e3744 | 13382 | } |
13383 | ||
13384 | DEFUN (show_ip_extcommunity_list_arg, | |
13385 | show_ip_extcommunity_list_arg_cmd, | |
6147e2c6 | 13386 | "show ip extcommunity-list <(1-500)|WORD>", |
718e3744 | 13387 | SHOW_STR |
13388 | IP_STR | |
13389 | "List extended-community list\n" | |
13390 | "Extcommunity-list number\n" | |
13391 | "Extcommunity-list name\n") | |
13392 | { | |
d62a17ae | 13393 | int idx_comm_list = 3; |
13394 | struct community_list *list; | |
718e3744 | 13395 | |
d62a17ae | 13396 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
13397 | EXTCOMMUNITY_LIST_MASTER); | |
13398 | if (!list) { | |
13399 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
13400 | return CMD_WARNING; | |
13401 | } | |
718e3744 | 13402 | |
d62a17ae | 13403 | extcommunity_list_show(vty, list); |
718e3744 | 13404 | |
d62a17ae | 13405 | return CMD_SUCCESS; |
718e3744 | 13406 | } |
6b0655a2 | 13407 | |
718e3744 | 13408 | /* Return configuration string of community-list entry. */ |
d62a17ae | 13409 | static const char *community_list_config_str(struct community_entry *entry) |
718e3744 | 13410 | { |
d62a17ae | 13411 | const char *str; |
718e3744 | 13412 | |
d62a17ae | 13413 | if (entry->any) |
13414 | str = ""; | |
13415 | else { | |
13416 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
a69ea8ae | 13417 | str = community_str(entry->u.com, false); |
d62a17ae | 13418 | else |
13419 | str = entry->config; | |
13420 | } | |
13421 | return str; | |
718e3744 | 13422 | } |
13423 | ||
13424 | /* Display community-list and extcommunity-list configuration. */ | |
d62a17ae | 13425 | static int community_list_config_write(struct vty *vty) |
13426 | { | |
13427 | struct community_list *list; | |
13428 | struct community_entry *entry; | |
13429 | struct community_list_master *cm; | |
13430 | int write = 0; | |
13431 | ||
13432 | /* Community-list. */ | |
13433 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
13434 | ||
13435 | for (list = cm->num.head; list; list = list->next) | |
13436 | for (entry = list->head; entry; entry = entry->next) { | |
13437 | vty_out(vty, "ip community-list %s %s %s\n", list->name, | |
13438 | community_direct_str(entry->direct), | |
13439 | community_list_config_str(entry)); | |
13440 | write++; | |
13441 | } | |
13442 | for (list = cm->str.head; list; list = list->next) | |
13443 | for (entry = list->head; entry; entry = entry->next) { | |
13444 | vty_out(vty, "ip community-list %s %s %s %s\n", | |
13445 | entry->style == COMMUNITY_LIST_STANDARD | |
13446 | ? "standard" | |
13447 | : "expanded", | |
13448 | list->name, community_direct_str(entry->direct), | |
13449 | community_list_config_str(entry)); | |
13450 | write++; | |
13451 | } | |
13452 | ||
13453 | /* Extcommunity-list. */ | |
13454 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
13455 | ||
13456 | for (list = cm->num.head; list; list = list->next) | |
13457 | for (entry = list->head; entry; entry = entry->next) { | |
13458 | vty_out(vty, "ip extcommunity-list %s %s %s\n", | |
13459 | list->name, community_direct_str(entry->direct), | |
13460 | community_list_config_str(entry)); | |
13461 | write++; | |
13462 | } | |
13463 | for (list = cm->str.head; list; list = list->next) | |
13464 | for (entry = list->head; entry; entry = entry->next) { | |
13465 | vty_out(vty, "ip extcommunity-list %s %s %s %s\n", | |
13466 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13467 | ? "standard" | |
13468 | : "expanded", | |
13469 | list->name, community_direct_str(entry->direct), | |
13470 | community_list_config_str(entry)); | |
13471 | write++; | |
13472 | } | |
13473 | ||
13474 | ||
13475 | /* lcommunity-list. */ | |
13476 | cm = community_list_master_lookup(bgp_clist, | |
13477 | LARGE_COMMUNITY_LIST_MASTER); | |
13478 | ||
13479 | for (list = cm->num.head; list; list = list->next) | |
13480 | for (entry = list->head; entry; entry = entry->next) { | |
13481 | vty_out(vty, "ip large-community-list %s %s %s\n", | |
13482 | list->name, community_direct_str(entry->direct), | |
13483 | community_list_config_str(entry)); | |
13484 | write++; | |
13485 | } | |
13486 | for (list = cm->str.head; list; list = list->next) | |
13487 | for (entry = list->head; entry; entry = entry->next) { | |
13488 | vty_out(vty, "ip large-community-list %s %s %s %s\n", | |
13489 | entry->style == LARGE_COMMUNITY_LIST_STANDARD | |
13490 | ? "standard" | |
13491 | : "expanded", | |
13492 | list->name, community_direct_str(entry->direct), | |
13493 | community_list_config_str(entry)); | |
13494 | write++; | |
13495 | } | |
13496 | ||
13497 | return write; | |
13498 | } | |
13499 | ||
13500 | static struct cmd_node community_list_node = { | |
13501 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 13502 | }; |
13503 | ||
d62a17ae | 13504 | static void community_list_vty(void) |
13505 | { | |
13506 | install_node(&community_list_node, community_list_config_write); | |
13507 | ||
13508 | /* Community-list. */ | |
13509 | install_element(CONFIG_NODE, &ip_community_list_standard_cmd); | |
13510 | install_element(CONFIG_NODE, &ip_community_list_expanded_all_cmd); | |
13511 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_cmd); | |
13512 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); | |
13513 | install_element(VIEW_NODE, &show_ip_community_list_cmd); | |
13514 | install_element(VIEW_NODE, &show_ip_community_list_arg_cmd); | |
13515 | ||
13516 | /* Extcommunity-list. */ | |
13517 | install_element(CONFIG_NODE, &ip_extcommunity_list_standard_cmd); | |
13518 | install_element(CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); | |
13519 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); | |
13520 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
13521 | install_element(VIEW_NODE, &show_ip_extcommunity_list_cmd); | |
13522 | install_element(VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
13523 | ||
13524 | /* Large Community List */ | |
13525 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard_cmd); | |
13526 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); | |
13527 | install_element(CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); | |
13528 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
13529 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); | |
13530 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); | |
13531 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
13532 | install_element(CONFIG_NODE, | |
13533 | &no_ip_lcommunity_list_name_expanded_all_cmd); | |
13534 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
13535 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
13536 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
13537 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
13538 | install_element(VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
13539 | install_element(VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 13540 | } |