]>
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" |
718e3744 | 61 | |
d62a17ae | 62 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
63 | struct prefix *range, int exact); | |
64 | ||
65 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) | |
66 | { | |
67 | switch (afi) { | |
68 | case AFI_IP: | |
69 | switch (safi) { | |
70 | case SAFI_UNICAST: | |
71 | return BGP_IPV4_NODE; | |
72 | break; | |
73 | case SAFI_MULTICAST: | |
74 | return BGP_IPV4M_NODE; | |
75 | break; | |
76 | case SAFI_LABELED_UNICAST: | |
77 | return BGP_IPV4L_NODE; | |
78 | break; | |
79 | case SAFI_MPLS_VPN: | |
80 | return BGP_VPNV4_NODE; | |
81 | break; | |
5c525538 RW |
82 | default: |
83 | /* not expected */ | |
84 | return BGP_IPV4_NODE; | |
85 | break; | |
d62a17ae | 86 | } |
87 | break; | |
88 | case AFI_IP6: | |
89 | switch (safi) { | |
90 | case SAFI_UNICAST: | |
91 | return BGP_IPV6_NODE; | |
92 | break; | |
93 | case SAFI_MULTICAST: | |
94 | return BGP_IPV6M_NODE; | |
95 | break; | |
96 | case SAFI_LABELED_UNICAST: | |
97 | return BGP_IPV6L_NODE; | |
98 | break; | |
99 | case SAFI_MPLS_VPN: | |
100 | return BGP_VPNV6_NODE; | |
101 | break; | |
5c525538 RW |
102 | default: |
103 | /* not expected */ | |
104 | return BGP_IPV4_NODE; | |
105 | break; | |
d62a17ae | 106 | } |
107 | break; | |
108 | case AFI_L2VPN: | |
109 | return BGP_EVPN_NODE; | |
110 | break; | |
111 | case AFI_MAX: | |
112 | // We should never be here but to clarify the switch statement.. | |
113 | return BGP_IPV4_NODE; | |
114 | break; | |
115 | } | |
116 | ||
117 | // Impossible to happen | |
118 | return BGP_IPV4_NODE; | |
f51bae9c | 119 | } |
20eb8864 | 120 | |
718e3744 | 121 | /* Utility function to get address family from current node. */ |
d62a17ae | 122 | afi_t bgp_node_afi(struct vty *vty) |
123 | { | |
124 | afi_t afi; | |
125 | switch (vty->node) { | |
126 | case BGP_IPV6_NODE: | |
127 | case BGP_IPV6M_NODE: | |
128 | case BGP_IPV6L_NODE: | |
129 | case BGP_VPNV6_NODE: | |
130 | afi = AFI_IP6; | |
131 | break; | |
132 | case BGP_EVPN_NODE: | |
133 | afi = AFI_L2VPN; | |
134 | break; | |
135 | default: | |
136 | afi = AFI_IP; | |
137 | break; | |
138 | } | |
139 | return afi; | |
718e3744 | 140 | } |
141 | ||
142 | /* Utility function to get subsequent address family from current | |
143 | node. */ | |
d62a17ae | 144 | safi_t bgp_node_safi(struct vty *vty) |
145 | { | |
146 | safi_t safi; | |
147 | switch (vty->node) { | |
148 | case BGP_VPNV4_NODE: | |
149 | case BGP_VPNV6_NODE: | |
150 | safi = SAFI_MPLS_VPN; | |
151 | break; | |
152 | case BGP_IPV4M_NODE: | |
153 | case BGP_IPV6M_NODE: | |
154 | safi = SAFI_MULTICAST; | |
155 | break; | |
156 | case BGP_EVPN_NODE: | |
157 | safi = SAFI_EVPN; | |
158 | break; | |
159 | case BGP_IPV4L_NODE: | |
160 | case BGP_IPV6L_NODE: | |
161 | safi = SAFI_LABELED_UNICAST; | |
162 | break; | |
163 | default: | |
164 | safi = SAFI_UNICAST; | |
165 | break; | |
166 | } | |
167 | return safi; | |
718e3744 | 168 | } |
169 | ||
55f91488 QY |
170 | /** |
171 | * Converts an AFI in string form to afi_t | |
172 | * | |
173 | * @param afi string, one of | |
174 | * - "ipv4" | |
175 | * - "ipv6" | |
176 | * @return the corresponding afi_t | |
177 | */ | |
d62a17ae | 178 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
179 | { | |
180 | afi_t afi = AFI_MAX; /* unknown */ | |
181 | if (strmatch(afi_str, "ipv4")) | |
182 | afi = AFI_IP; | |
183 | else if (strmatch(afi_str, "ipv6")) | |
184 | afi = AFI_IP6; | |
185 | return afi; | |
186 | } | |
187 | ||
188 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
189 | afi_t *afi) | |
190 | { | |
191 | int ret = 0; | |
192 | if (argv_find(argv, argc, "ipv4", index)) { | |
193 | ret = 1; | |
194 | if (afi) | |
195 | *afi = AFI_IP; | |
196 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
197 | ret = 1; | |
198 | if (afi) | |
199 | *afi = AFI_IP6; | |
200 | } | |
201 | return ret; | |
46f296b4 LB |
202 | } |
203 | ||
375a2e67 | 204 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 205 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
206 | { | |
207 | safi_t safi = SAFI_MAX; /* unknown */ | |
208 | if (strmatch(safi_str, "multicast")) | |
209 | safi = SAFI_MULTICAST; | |
210 | else if (strmatch(safi_str, "unicast")) | |
211 | safi = SAFI_UNICAST; | |
212 | else if (strmatch(safi_str, "vpn")) | |
213 | safi = SAFI_MPLS_VPN; | |
214 | else if (strmatch(safi_str, "labeled-unicast")) | |
215 | safi = SAFI_LABELED_UNICAST; | |
216 | return safi; | |
217 | } | |
218 | ||
219 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
220 | safi_t *safi) | |
221 | { | |
222 | int ret = 0; | |
223 | if (argv_find(argv, argc, "unicast", index)) { | |
224 | ret = 1; | |
225 | if (safi) | |
226 | *safi = SAFI_UNICAST; | |
227 | } else if (argv_find(argv, argc, "multicast", index)) { | |
228 | ret = 1; | |
229 | if (safi) | |
230 | *safi = SAFI_MULTICAST; | |
231 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
232 | ret = 1; | |
233 | if (safi) | |
234 | *safi = SAFI_LABELED_UNICAST; | |
235 | } else if (argv_find(argv, argc, "vpn", index)) { | |
236 | ret = 1; | |
237 | if (safi) | |
238 | *safi = SAFI_MPLS_VPN; | |
239 | } | |
240 | return ret; | |
46f296b4 LB |
241 | } |
242 | ||
7eeee51e | 243 | /* |
f212a857 | 244 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 245 | * |
f212a857 DS |
246 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
247 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
248 | * to appropriate values for the calling function. This is to allow the |
249 | * calling function to make decisions appropriate for the show command | |
250 | * that is being parsed. | |
251 | * | |
252 | * The show commands are generally of the form: | |
d62a17ae | 253 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
254 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
255 | * |
256 | * Since we use argv_find if the show command in particular doesn't have: | |
257 | * [ip] | |
18c57037 | 258 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 259 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
260 | * The command parsing should still be ok. |
261 | * | |
262 | * vty -> The vty for the command so we can output some useful data in | |
263 | * the event of a parse error in the vrf. | |
264 | * argv -> The command tokens | |
265 | * argc -> How many command tokens we have | |
d62a17ae | 266 | * idx -> The current place in the command, generally should be 0 for this |
267 | * function | |
7eeee51e DS |
268 | * afi -> The parsed afi if it was included in the show command, returned here |
269 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 270 | * bgp -> Pointer to the bgp data structure we need to fill in. |
7eeee51e DS |
271 | * |
272 | * The function returns the correct location in the parse tree for the | |
273 | * last token found. | |
0e37c258 DS |
274 | * |
275 | * Returns 0 for failure to parse correctly, else the idx position of where | |
276 | * it found the last token. | |
7eeee51e | 277 | */ |
d62a17ae | 278 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
279 | struct cmd_token **argv, int argc, | |
280 | int *idx, afi_t *afi, safi_t *safi, | |
281 | struct bgp **bgp) | |
282 | { | |
283 | char *vrf_name = NULL; | |
284 | ||
285 | assert(afi); | |
286 | assert(safi); | |
287 | assert(bgp); | |
288 | ||
289 | if (argv_find(argv, argc, "ip", idx)) | |
290 | *afi = AFI_IP; | |
291 | ||
292 | if (argv_find(argv, argc, "view", idx) | |
293 | || argv_find(argv, argc, "vrf", idx)) { | |
294 | vrf_name = argv[*idx + 1]->arg; | |
295 | ||
296 | if (strmatch(vrf_name, "all")) | |
297 | *bgp = NULL; | |
298 | else { | |
299 | *bgp = bgp_lookup_by_name(vrf_name); | |
300 | if (!*bgp) { | |
301 | vty_out(vty, | |
302 | "View/Vrf specified is unknown: %s\n", | |
303 | vrf_name); | |
304 | *idx = 0; | |
305 | return 0; | |
306 | } | |
307 | } | |
308 | } else { | |
309 | *bgp = bgp_get_default(); | |
310 | if (!*bgp) { | |
311 | vty_out(vty, "Unable to find default BGP instance\n"); | |
312 | *idx = 0; | |
313 | return 0; | |
314 | } | |
315 | } | |
316 | ||
317 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
318 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
319 | ||
320 | *idx += 1; | |
321 | return *idx; | |
322 | } | |
323 | ||
324 | static int peer_address_self_check(struct bgp *bgp, union sockunion *su) | |
325 | { | |
326 | struct interface *ifp = NULL; | |
327 | ||
328 | if (su->sa.sa_family == AF_INET) | |
329 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
330 | else if (su->sa.sa_family == AF_INET6) | |
331 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
332 | su->sin6.sin6_scope_id, | |
333 | bgp->vrf_id); | |
334 | ||
335 | if (ifp) | |
336 | return 1; | |
337 | ||
338 | return 0; | |
718e3744 | 339 | } |
340 | ||
341 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
342 | /* This is used only for configuration, so disallow if attempted on |
343 | * a dynamic neighbor. | |
344 | */ | |
d62a17ae | 345 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
346 | { | |
347 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
348 | int ret; | |
349 | union sockunion su; | |
350 | struct peer *peer; | |
351 | ||
352 | if (!bgp) { | |
353 | return NULL; | |
354 | } | |
355 | ||
356 | ret = str2sockunion(ip_str, &su); | |
357 | if (ret < 0) { | |
358 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
359 | if (!peer) { | |
360 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
361 | == NULL) { | |
362 | vty_out(vty, | |
363 | "%% Malformed address or name: %s\n", | |
364 | ip_str); | |
365 | return NULL; | |
366 | } | |
367 | } | |
368 | } else { | |
369 | peer = peer_lookup(bgp, &su); | |
370 | if (!peer) { | |
371 | vty_out(vty, | |
372 | "%% Specify remote-as or peer-group commands first\n"); | |
373 | return NULL; | |
374 | } | |
375 | if (peer_dynamic_neighbor(peer)) { | |
376 | vty_out(vty, | |
377 | "%% Operation not allowed on a dynamic neighbor\n"); | |
378 | return NULL; | |
379 | } | |
380 | } | |
381 | return peer; | |
718e3744 | 382 | } |
383 | ||
384 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
385 | /* This is used only for configuration, so disallow if attempted on |
386 | * a dynamic neighbor. | |
387 | */ | |
d62a17ae | 388 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
389 | { | |
390 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
391 | int ret; | |
392 | union sockunion su; | |
393 | struct peer *peer = NULL; | |
394 | struct peer_group *group = NULL; | |
395 | ||
396 | if (!bgp) { | |
397 | return NULL; | |
398 | } | |
399 | ||
400 | ret = str2sockunion(peer_str, &su); | |
401 | if (ret == 0) { | |
402 | /* IP address, locate peer. */ | |
403 | peer = peer_lookup(bgp, &su); | |
404 | } else { | |
405 | /* Not IP, could match either peer configured on interface or a | |
406 | * group. */ | |
407 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
408 | if (!peer) | |
409 | group = peer_group_lookup(bgp, peer_str); | |
410 | } | |
411 | ||
412 | if (peer) { | |
413 | if (peer_dynamic_neighbor(peer)) { | |
414 | vty_out(vty, | |
415 | "%% Operation not allowed on a dynamic neighbor\n"); | |
416 | return NULL; | |
417 | } | |
418 | ||
419 | return peer; | |
420 | } | |
421 | ||
422 | if (group) | |
423 | return group->conf; | |
424 | ||
425 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
426 | ||
427 | return NULL; | |
428 | } | |
429 | ||
430 | int bgp_vty_return(struct vty *vty, int ret) | |
431 | { | |
432 | const char *str = NULL; | |
433 | ||
434 | switch (ret) { | |
435 | case BGP_ERR_INVALID_VALUE: | |
436 | str = "Invalid value"; | |
437 | break; | |
438 | case BGP_ERR_INVALID_FLAG: | |
439 | str = "Invalid flag"; | |
440 | break; | |
441 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
442 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
443 | break; | |
444 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
445 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
446 | break; | |
447 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
448 | str = "Specify remote-as or peer-group remote AS first"; | |
449 | break; | |
450 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
451 | str = "Cannot change the peer-group. Deconfigure first"; | |
452 | break; | |
453 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
454 | str = "Peer is not a member of this peer-group"; | |
455 | break; | |
456 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
457 | str = "Prefix/distribute list can not co-exist"; | |
458 | break; | |
459 | case BGP_ERR_NOT_INTERNAL_PEER: | |
460 | str = "Invalid command. Not an internal neighbor"; | |
461 | break; | |
462 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
463 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
464 | break; | |
465 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
466 | str = "Local-AS allowed only for EBGP peers"; | |
467 | break; | |
468 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
469 | str = "Cannot have local-as same as BGP AS number"; | |
470 | break; | |
471 | case BGP_ERR_TCPSIG_FAILED: | |
472 | str = "Error while applying TCP-Sig to session(s)"; | |
473 | break; | |
474 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
475 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
476 | break; | |
477 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
478 | str = "ttl-security only allowed for EBGP peers"; | |
479 | break; | |
480 | case BGP_ERR_AS_OVERRIDE: | |
481 | str = "as-override cannot be configured for IBGP peers"; | |
482 | break; | |
483 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
484 | str = "Invalid limit for number of dynamic neighbors"; | |
485 | break; | |
486 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
487 | str = "Dynamic neighbor listen range already exists"; | |
488 | break; | |
489 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
490 | str = "Operation not allowed on a dynamic neighbor"; | |
491 | break; | |
492 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
493 | str = "Operation not allowed on a directly connected neighbor"; | |
494 | break; | |
495 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
496 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; | |
497 | break; | |
498 | } | |
499 | if (str) { | |
500 | vty_out(vty, "%% %s\n", str); | |
501 | return CMD_WARNING_CONFIG_FAILED; | |
502 | } | |
503 | return CMD_SUCCESS; | |
718e3744 | 504 | } |
505 | ||
7aafcaca | 506 | /* BGP clear sort. */ |
d62a17ae | 507 | enum clear_sort { |
508 | clear_all, | |
509 | clear_peer, | |
510 | clear_group, | |
511 | clear_external, | |
512 | clear_as | |
7aafcaca DS |
513 | }; |
514 | ||
d62a17ae | 515 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
516 | safi_t safi, int error) | |
517 | { | |
518 | switch (error) { | |
519 | case BGP_ERR_AF_UNCONFIGURED: | |
520 | vty_out(vty, | |
521 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
522 | afi_safi_print(afi, safi), peer->host); | |
523 | break; | |
524 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
525 | vty_out(vty, | |
526 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
527 | peer->host); | |
528 | break; | |
529 | default: | |
530 | break; | |
531 | } | |
7aafcaca DS |
532 | } |
533 | ||
534 | /* `clear ip bgp' functions. */ | |
d62a17ae | 535 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
536 | enum clear_sort sort, enum bgp_clear_type stype, | |
537 | const char *arg) | |
538 | { | |
539 | int ret; | |
540 | struct peer *peer; | |
541 | struct listnode *node, *nnode; | |
542 | ||
543 | /* Clear all neighbors. */ | |
544 | /* | |
545 | * Pass along pointer to next node to peer_clear() when walking all | |
546 | * nodes | |
547 | * on the BGP instance as that may get freed if it is a doppelganger | |
548 | */ | |
549 | if (sort == clear_all) { | |
550 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
551 | if (stype == BGP_CLEAR_SOFT_NONE) | |
552 | ret = peer_clear(peer, &nnode); | |
553 | else if (peer->afc[afi][safi]) | |
554 | ret = peer_clear_soft(peer, afi, safi, stype); | |
555 | else | |
556 | ret = 0; | |
557 | ||
558 | if (ret < 0) | |
559 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
04b6bdc0 | 560 | } |
d62a17ae | 561 | |
562 | /* This is to apply read-only mode on this clear. */ | |
563 | if (stype == BGP_CLEAR_SOFT_NONE) | |
564 | bgp->update_delay_over = 0; | |
565 | ||
566 | return CMD_SUCCESS; | |
7aafcaca DS |
567 | } |
568 | ||
d62a17ae | 569 | /* Clear specified neighbors. */ |
570 | if (sort == clear_peer) { | |
571 | union sockunion su; | |
572 | int ret; | |
573 | ||
574 | /* Make sockunion for lookup. */ | |
575 | ret = str2sockunion(arg, &su); | |
576 | if (ret < 0) { | |
577 | peer = peer_lookup_by_conf_if(bgp, arg); | |
578 | if (!peer) { | |
579 | peer = peer_lookup_by_hostname(bgp, arg); | |
580 | if (!peer) { | |
581 | vty_out(vty, | |
582 | "Malformed address or name: %s\n", | |
583 | arg); | |
584 | return CMD_WARNING; | |
585 | } | |
586 | } | |
587 | } else { | |
588 | peer = peer_lookup(bgp, &su); | |
589 | if (!peer) { | |
590 | vty_out(vty, | |
591 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
592 | arg); | |
593 | return CMD_WARNING; | |
594 | } | |
595 | } | |
7aafcaca | 596 | |
d62a17ae | 597 | if (stype == BGP_CLEAR_SOFT_NONE) |
598 | ret = peer_clear(peer, NULL); | |
599 | else | |
600 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 601 | |
d62a17ae | 602 | if (ret < 0) |
603 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 604 | |
d62a17ae | 605 | return CMD_SUCCESS; |
7aafcaca | 606 | } |
7aafcaca | 607 | |
d62a17ae | 608 | /* Clear all peer-group members. */ |
609 | if (sort == clear_group) { | |
610 | struct peer_group *group; | |
7aafcaca | 611 | |
d62a17ae | 612 | group = peer_group_lookup(bgp, arg); |
613 | if (!group) { | |
614 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
615 | return CMD_WARNING; | |
616 | } | |
617 | ||
618 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
619 | if (stype == BGP_CLEAR_SOFT_NONE) { | |
620 | peer_clear(peer, NULL); | |
621 | continue; | |
622 | } | |
623 | ||
624 | if (!peer->afc[afi][safi]) | |
625 | continue; | |
626 | ||
627 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 628 | |
d62a17ae | 629 | if (ret < 0) |
630 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
631 | } | |
632 | return CMD_SUCCESS; | |
7aafcaca | 633 | } |
7aafcaca | 634 | |
d62a17ae | 635 | if (sort == clear_external) { |
636 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
637 | if (peer->sort == BGP_PEER_IBGP) | |
638 | continue; | |
7aafcaca | 639 | |
d62a17ae | 640 | if (stype == BGP_CLEAR_SOFT_NONE) |
641 | ret = peer_clear(peer, &nnode); | |
642 | else | |
643 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 644 | |
d62a17ae | 645 | if (ret < 0) |
646 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
647 | } | |
648 | return CMD_SUCCESS; | |
649 | } | |
650 | ||
651 | if (sort == clear_as) { | |
652 | as_t as; | |
653 | int find = 0; | |
654 | ||
655 | as = strtoul(arg, NULL, 10); | |
656 | ||
657 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
658 | if (peer->as != as) | |
659 | continue; | |
660 | ||
661 | find = 1; | |
662 | if (stype == BGP_CLEAR_SOFT_NONE) | |
663 | ret = peer_clear(peer, &nnode); | |
664 | else | |
665 | ret = peer_clear_soft(peer, afi, safi, stype); | |
666 | ||
667 | if (ret < 0) | |
668 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
669 | } | |
670 | if (!find) | |
671 | vty_out(vty, | |
672 | "%%BGP: No peer is configured with AS %s\n", | |
673 | arg); | |
674 | return CMD_SUCCESS; | |
675 | } | |
676 | ||
677 | return CMD_SUCCESS; | |
678 | } | |
679 | ||
680 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
681 | safi_t safi, enum clear_sort sort, | |
682 | enum bgp_clear_type stype, const char *arg) | |
683 | { | |
684 | struct bgp *bgp; | |
685 | ||
686 | /* BGP structure lookup. */ | |
687 | if (name) { | |
688 | bgp = bgp_lookup_by_name(name); | |
689 | if (bgp == NULL) { | |
690 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
691 | return CMD_WARNING; | |
692 | } | |
693 | } else { | |
694 | bgp = bgp_get_default(); | |
695 | if (bgp == NULL) { | |
696 | vty_out(vty, "No BGP process is configured\n"); | |
697 | return CMD_WARNING; | |
698 | } | |
699 | } | |
700 | ||
701 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
702 | } |
703 | ||
704 | /* clear soft inbound */ | |
d62a17ae | 705 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 706 | { |
d62a17ae | 707 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
708 | BGP_CLEAR_SOFT_IN, NULL); | |
709 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
710 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
711 | } |
712 | ||
713 | /* clear soft outbound */ | |
d62a17ae | 714 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 715 | { |
d62a17ae | 716 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
717 | BGP_CLEAR_SOFT_OUT, NULL); | |
718 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
719 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
720 | } |
721 | ||
722 | ||
f787d7a0 | 723 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 724 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
725 | #endif |
726 | ||
718e3744 | 727 | /* BGP global configuration. */ |
728 | ||
729 | DEFUN (bgp_multiple_instance_func, | |
730 | bgp_multiple_instance_cmd, | |
731 | "bgp multiple-instance", | |
732 | BGP_STR | |
733 | "Enable bgp multiple instance\n") | |
734 | { | |
d62a17ae | 735 | bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE); |
736 | return CMD_SUCCESS; | |
718e3744 | 737 | } |
738 | ||
739 | DEFUN (no_bgp_multiple_instance, | |
740 | no_bgp_multiple_instance_cmd, | |
741 | "no bgp multiple-instance", | |
742 | NO_STR | |
743 | BGP_STR | |
744 | "BGP multiple instance\n") | |
745 | { | |
d62a17ae | 746 | int ret; |
718e3744 | 747 | |
d62a17ae | 748 | ret = bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE); |
749 | if (ret < 0) { | |
750 | vty_out(vty, "%% There are more than two BGP instances\n"); | |
751 | return CMD_WARNING_CONFIG_FAILED; | |
752 | } | |
753 | return CMD_SUCCESS; | |
718e3744 | 754 | } |
755 | ||
756 | DEFUN (bgp_config_type, | |
757 | bgp_config_type_cmd, | |
6147e2c6 | 758 | "bgp config-type <cisco|zebra>", |
718e3744 | 759 | BGP_STR |
760 | "Configuration type\n" | |
761 | "cisco\n" | |
762 | "zebra\n") | |
763 | { | |
d62a17ae | 764 | int idx = 0; |
765 | if (argv_find(argv, argc, "cisco", &idx)) | |
766 | bgp_option_set(BGP_OPT_CONFIG_CISCO); | |
767 | else | |
768 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); | |
718e3744 | 769 | |
d62a17ae | 770 | return CMD_SUCCESS; |
718e3744 | 771 | } |
772 | ||
773 | DEFUN (no_bgp_config_type, | |
774 | no_bgp_config_type_cmd, | |
c7178fe7 | 775 | "no bgp config-type [<cisco|zebra>]", |
718e3744 | 776 | NO_STR |
777 | BGP_STR | |
838758ac DW |
778 | "Display configuration type\n" |
779 | "cisco\n" | |
780 | "zebra\n") | |
718e3744 | 781 | { |
d62a17ae | 782 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
783 | return CMD_SUCCESS; | |
718e3744 | 784 | } |
785 | ||
813d4307 | 786 | |
718e3744 | 787 | DEFUN (no_synchronization, |
788 | no_synchronization_cmd, | |
789 | "no synchronization", | |
790 | NO_STR | |
791 | "Perform IGP synchronization\n") | |
792 | { | |
d62a17ae | 793 | return CMD_SUCCESS; |
718e3744 | 794 | } |
795 | ||
796 | DEFUN (no_auto_summary, | |
797 | no_auto_summary_cmd, | |
798 | "no auto-summary", | |
799 | NO_STR | |
800 | "Enable automatic network number summarization\n") | |
801 | { | |
d62a17ae | 802 | return CMD_SUCCESS; |
718e3744 | 803 | } |
3d515fd9 | 804 | |
718e3744 | 805 | /* "router bgp" commands. */ |
505e5056 | 806 | DEFUN_NOSH (router_bgp, |
f412b39a | 807 | router_bgp_cmd, |
18c57037 | 808 | "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 809 | ROUTER_STR |
810 | BGP_STR | |
31500417 DW |
811 | AS_STR |
812 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 813 | { |
d62a17ae | 814 | int idx_asn = 2; |
815 | int idx_view_vrf = 3; | |
816 | int idx_vrf = 4; | |
817 | int ret; | |
818 | as_t as; | |
819 | struct bgp *bgp; | |
820 | const char *name = NULL; | |
821 | enum bgp_instance_type inst_type; | |
822 | ||
823 | // "router bgp" without an ASN | |
824 | if (argc == 2) { | |
825 | // Pending: Make VRF option available for ASN less config | |
826 | bgp = bgp_get_default(); | |
827 | ||
828 | if (bgp == NULL) { | |
829 | vty_out(vty, "%% No BGP process is configured\n"); | |
830 | return CMD_WARNING_CONFIG_FAILED; | |
831 | } | |
832 | ||
833 | if (listcount(bm->bgp) > 1) { | |
834 | vty_out(vty, | |
835 | "%% Multiple BGP processes are configured\n"); | |
836 | return CMD_WARNING_CONFIG_FAILED; | |
837 | } | |
838 | } | |
839 | ||
840 | // "router bgp X" | |
841 | else { | |
842 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
843 | ||
844 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
845 | if (argc > 3) { | |
846 | name = argv[idx_vrf]->arg; | |
847 | ||
848 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) | |
849 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
850 | else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
851 | inst_type = BGP_INSTANCE_TYPE_VIEW; | |
852 | } | |
853 | ||
854 | ret = bgp_get(&bgp, &as, name, inst_type); | |
855 | switch (ret) { | |
856 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
857 | vty_out(vty, | |
858 | "Please specify 'bgp multiple-instance' first\n"); | |
859 | return CMD_WARNING_CONFIG_FAILED; | |
860 | case BGP_ERR_AS_MISMATCH: | |
861 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
862 | return CMD_WARNING_CONFIG_FAILED; | |
863 | case BGP_ERR_INSTANCE_MISMATCH: | |
864 | vty_out(vty, | |
865 | "BGP instance name and AS number mismatch\n"); | |
866 | vty_out(vty, | |
867 | "BGP instance is already running; AS is %u\n", | |
868 | as); | |
869 | return CMD_WARNING_CONFIG_FAILED; | |
870 | } | |
871 | ||
872 | /* Pending: handle when user tries to change a view to vrf n vv. | |
873 | */ | |
874 | } | |
875 | ||
876 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
877 | ||
878 | return CMD_SUCCESS; | |
718e3744 | 879 | } |
880 | ||
718e3744 | 881 | /* "no router bgp" commands. */ |
882 | DEFUN (no_router_bgp, | |
883 | no_router_bgp_cmd, | |
18c57037 | 884 | "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 885 | NO_STR |
886 | ROUTER_STR | |
887 | BGP_STR | |
31500417 DW |
888 | AS_STR |
889 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 890 | { |
d62a17ae | 891 | int idx_asn = 3; |
892 | int idx_vrf = 5; | |
893 | as_t as; | |
894 | struct bgp *bgp; | |
895 | const char *name = NULL; | |
718e3744 | 896 | |
d62a17ae | 897 | // "no router bgp" without an ASN |
898 | if (argc == 3) { | |
899 | // Pending: Make VRF option available for ASN less config | |
900 | bgp = bgp_get_default(); | |
718e3744 | 901 | |
d62a17ae | 902 | if (bgp == NULL) { |
903 | vty_out(vty, "%% No BGP process is configured\n"); | |
904 | return CMD_WARNING_CONFIG_FAILED; | |
905 | } | |
7fb21a9f | 906 | |
d62a17ae | 907 | if (listcount(bm->bgp) > 1) { |
908 | vty_out(vty, | |
909 | "%% Multiple BGP processes are configured\n"); | |
910 | return CMD_WARNING_CONFIG_FAILED; | |
911 | } | |
912 | } else { | |
913 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 914 | |
d62a17ae | 915 | if (argc > 4) |
916 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 917 | |
d62a17ae | 918 | /* Lookup bgp structure. */ |
919 | bgp = bgp_lookup(as, name); | |
920 | if (!bgp) { | |
921 | vty_out(vty, "%% Can't find BGP instance\n"); | |
922 | return CMD_WARNING_CONFIG_FAILED; | |
923 | } | |
924 | } | |
718e3744 | 925 | |
d62a17ae | 926 | bgp_delete(bgp); |
718e3744 | 927 | |
d62a17ae | 928 | return CMD_SUCCESS; |
718e3744 | 929 | } |
930 | ||
6b0655a2 | 931 | |
718e3744 | 932 | /* BGP router-id. */ |
933 | ||
f787d7a0 | 934 | DEFPY (bgp_router_id, |
718e3744 | 935 | bgp_router_id_cmd, |
936 | "bgp router-id A.B.C.D", | |
937 | BGP_STR | |
938 | "Override configured router identifier\n" | |
939 | "Manually configured router identifier\n") | |
940 | { | |
d62a17ae | 941 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
942 | bgp_router_id_static_set(bgp, router_id); | |
943 | return CMD_SUCCESS; | |
718e3744 | 944 | } |
945 | ||
f787d7a0 | 946 | DEFPY (no_bgp_router_id, |
718e3744 | 947 | no_bgp_router_id_cmd, |
31500417 | 948 | "no bgp router-id [A.B.C.D]", |
718e3744 | 949 | NO_STR |
950 | BGP_STR | |
31500417 DW |
951 | "Override configured router identifier\n" |
952 | "Manually configured router identifier\n") | |
718e3744 | 953 | { |
d62a17ae | 954 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 955 | |
d62a17ae | 956 | if (router_id_str) { |
957 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
958 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
959 | return CMD_WARNING_CONFIG_FAILED; | |
960 | } | |
e018c7cc | 961 | } |
718e3744 | 962 | |
d62a17ae | 963 | router_id.s_addr = 0; |
964 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 965 | |
d62a17ae | 966 | return CMD_SUCCESS; |
718e3744 | 967 | } |
968 | ||
6b0655a2 | 969 | |
718e3744 | 970 | /* BGP Cluster ID. */ |
718e3744 | 971 | DEFUN (bgp_cluster_id, |
972 | bgp_cluster_id_cmd, | |
838758ac | 973 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 974 | BGP_STR |
975 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
976 | "Route-Reflector Cluster-id in IP address format\n" |
977 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 978 | { |
d62a17ae | 979 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
980 | int idx_ipv4 = 2; | |
981 | int ret; | |
982 | struct in_addr cluster; | |
718e3744 | 983 | |
d62a17ae | 984 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
985 | if (!ret) { | |
986 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
987 | return CMD_WARNING_CONFIG_FAILED; | |
988 | } | |
718e3744 | 989 | |
d62a17ae | 990 | bgp_cluster_id_set(bgp, &cluster); |
991 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 992 | |
d62a17ae | 993 | return CMD_SUCCESS; |
718e3744 | 994 | } |
995 | ||
718e3744 | 996 | DEFUN (no_bgp_cluster_id, |
997 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 998 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 999 | NO_STR |
1000 | BGP_STR | |
838758ac DW |
1001 | "Configure Route-Reflector Cluster-id\n" |
1002 | "Route-Reflector Cluster-id in IP address format\n" | |
1003 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1004 | { |
d62a17ae | 1005 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1006 | bgp_cluster_id_unset(bgp); | |
1007 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1008 | |
d62a17ae | 1009 | return CMD_SUCCESS; |
718e3744 | 1010 | } |
1011 | ||
718e3744 | 1012 | DEFUN (bgp_confederation_identifier, |
1013 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1014 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1015 | "BGP specific commands\n" |
1016 | "AS confederation parameters\n" | |
1017 | "AS number\n" | |
1018 | "Set routing domain confederation AS\n") | |
1019 | { | |
d62a17ae | 1020 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1021 | int idx_number = 3; | |
1022 | as_t as; | |
718e3744 | 1023 | |
d62a17ae | 1024 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1025 | |
d62a17ae | 1026 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1027 | |
d62a17ae | 1028 | return CMD_SUCCESS; |
718e3744 | 1029 | } |
1030 | ||
1031 | DEFUN (no_bgp_confederation_identifier, | |
1032 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1033 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1034 | NO_STR |
1035 | "BGP specific commands\n" | |
1036 | "AS confederation parameters\n" | |
3a2d747c QY |
1037 | "AS number\n" |
1038 | "Set routing domain confederation AS\n") | |
718e3744 | 1039 | { |
d62a17ae | 1040 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1041 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1042 | |
d62a17ae | 1043 | return CMD_SUCCESS; |
718e3744 | 1044 | } |
1045 | ||
718e3744 | 1046 | DEFUN (bgp_confederation_peers, |
1047 | bgp_confederation_peers_cmd, | |
12dcf78e | 1048 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1049 | "BGP specific commands\n" |
1050 | "AS confederation parameters\n" | |
1051 | "Peer ASs in BGP confederation\n" | |
1052 | AS_STR) | |
1053 | { | |
d62a17ae | 1054 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1055 | int idx_asn = 3; | |
1056 | as_t as; | |
1057 | int i; | |
718e3744 | 1058 | |
d62a17ae | 1059 | for (i = idx_asn; i < argc; i++) { |
1060 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1061 | |
d62a17ae | 1062 | if (bgp->as == as) { |
1063 | vty_out(vty, | |
1064 | "%% Local member-AS not allowed in confed peer list\n"); | |
1065 | continue; | |
1066 | } | |
718e3744 | 1067 | |
d62a17ae | 1068 | bgp_confederation_peers_add(bgp, as); |
1069 | } | |
1070 | return CMD_SUCCESS; | |
718e3744 | 1071 | } |
1072 | ||
1073 | DEFUN (no_bgp_confederation_peers, | |
1074 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1075 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1076 | NO_STR |
1077 | "BGP specific commands\n" | |
1078 | "AS confederation parameters\n" | |
1079 | "Peer ASs in BGP confederation\n" | |
1080 | AS_STR) | |
1081 | { | |
d62a17ae | 1082 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1083 | int idx_asn = 4; | |
1084 | as_t as; | |
1085 | int i; | |
718e3744 | 1086 | |
d62a17ae | 1087 | for (i = idx_asn; i < argc; i++) { |
1088 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1089 | |
d62a17ae | 1090 | bgp_confederation_peers_remove(bgp, as); |
1091 | } | |
1092 | return CMD_SUCCESS; | |
718e3744 | 1093 | } |
6b0655a2 | 1094 | |
5e242b0d DS |
1095 | /** |
1096 | * Central routine for maximum-paths configuration. | |
1097 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1098 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1099 | */ | |
d62a17ae | 1100 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
1101 | const char *mpaths, u_int16_t options, | |
1102 | int set) | |
1103 | { | |
1104 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1105 | u_int16_t maxpaths = 0; | |
1106 | int ret; | |
1107 | afi_t afi; | |
1108 | safi_t safi; | |
1109 | ||
1110 | afi = bgp_node_afi(vty); | |
1111 | safi = bgp_node_safi(vty); | |
1112 | ||
1113 | if (set) { | |
1114 | maxpaths = strtol(mpaths, NULL, 10); | |
1115 | if (maxpaths > multipath_num) { | |
1116 | vty_out(vty, | |
1117 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1118 | maxpaths, multipath_num); | |
1119 | return CMD_WARNING_CONFIG_FAILED; | |
1120 | } | |
1121 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1122 | options); | |
1123 | } else | |
1124 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1125 | ||
1126 | if (ret < 0) { | |
1127 | vty_out(vty, | |
1128 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1129 | (set == 1) ? "" : "un", | |
1130 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1131 | maxpaths, afi, safi); | |
1132 | return CMD_WARNING_CONFIG_FAILED; | |
1133 | } | |
1134 | ||
1135 | bgp_recalculate_all_bestpaths(bgp); | |
1136 | ||
1137 | return CMD_SUCCESS; | |
165b5fff JB |
1138 | } |
1139 | ||
abc920f8 DS |
1140 | DEFUN (bgp_maxmed_admin, |
1141 | bgp_maxmed_admin_cmd, | |
1142 | "bgp max-med administrative ", | |
1143 | BGP_STR | |
1144 | "Advertise routes with max-med\n" | |
1145 | "Administratively applied, for an indefinite period\n") | |
1146 | { | |
d62a17ae | 1147 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1148 | |
d62a17ae | 1149 | bgp->v_maxmed_admin = 1; |
1150 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1151 | |
d62a17ae | 1152 | bgp_maxmed_update(bgp); |
abc920f8 | 1153 | |
d62a17ae | 1154 | return CMD_SUCCESS; |
abc920f8 DS |
1155 | } |
1156 | ||
1157 | DEFUN (bgp_maxmed_admin_medv, | |
1158 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1159 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1160 | BGP_STR |
1161 | "Advertise routes with max-med\n" | |
1162 | "Administratively applied, for an indefinite period\n" | |
1163 | "Max MED value to be used\n") | |
1164 | { | |
d62a17ae | 1165 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1166 | int idx_number = 3; | |
abc920f8 | 1167 | |
d62a17ae | 1168 | bgp->v_maxmed_admin = 1; |
1169 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1170 | |
d62a17ae | 1171 | bgp_maxmed_update(bgp); |
abc920f8 | 1172 | |
d62a17ae | 1173 | return CMD_SUCCESS; |
abc920f8 DS |
1174 | } |
1175 | ||
1176 | DEFUN (no_bgp_maxmed_admin, | |
1177 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1178 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1179 | NO_STR |
1180 | BGP_STR | |
1181 | "Advertise routes with max-med\n" | |
838758ac DW |
1182 | "Administratively applied, for an indefinite period\n" |
1183 | "Max MED value to be used\n") | |
abc920f8 | 1184 | { |
d62a17ae | 1185 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1186 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1187 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1188 | bgp_maxmed_update(bgp); | |
abc920f8 | 1189 | |
d62a17ae | 1190 | return CMD_SUCCESS; |
abc920f8 DS |
1191 | } |
1192 | ||
abc920f8 DS |
1193 | DEFUN (bgp_maxmed_onstartup, |
1194 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1195 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1196 | BGP_STR |
1197 | "Advertise routes with max-med\n" | |
1198 | "Effective on a startup\n" | |
1199 | "Time (seconds) period for max-med\n" | |
1200 | "Max MED value to be used\n") | |
1201 | { | |
d62a17ae | 1202 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1203 | int idx = 0; | |
4668a151 | 1204 | |
d62a17ae | 1205 | argv_find(argv, argc, "(5-86400)", &idx); |
1206 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1207 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1208 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1209 | else | |
1210 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1211 | |
d62a17ae | 1212 | bgp_maxmed_update(bgp); |
abc920f8 | 1213 | |
d62a17ae | 1214 | return CMD_SUCCESS; |
abc920f8 DS |
1215 | } |
1216 | ||
1217 | DEFUN (no_bgp_maxmed_onstartup, | |
1218 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1219 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1220 | NO_STR |
1221 | BGP_STR | |
1222 | "Advertise routes with max-med\n" | |
838758ac DW |
1223 | "Effective on a startup\n" |
1224 | "Time (seconds) period for max-med\n" | |
1225 | "Max MED value to be used\n") | |
abc920f8 | 1226 | { |
d62a17ae | 1227 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1228 | |
d62a17ae | 1229 | /* Cancel max-med onstartup if its on */ |
1230 | if (bgp->t_maxmed_onstartup) { | |
1231 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1232 | bgp->maxmed_onstartup_over = 1; | |
1233 | } | |
abc920f8 | 1234 | |
d62a17ae | 1235 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1236 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1237 | |
d62a17ae | 1238 | bgp_maxmed_update(bgp); |
abc920f8 | 1239 | |
d62a17ae | 1240 | return CMD_SUCCESS; |
abc920f8 DS |
1241 | } |
1242 | ||
d62a17ae | 1243 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1244 | const char *wait) | |
f188f2c4 | 1245 | { |
d62a17ae | 1246 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1247 | u_int16_t update_delay; | |
1248 | u_int16_t establish_wait; | |
f188f2c4 | 1249 | |
d62a17ae | 1250 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1251 | |
d62a17ae | 1252 | if (!wait) /* update-delay <delay> */ |
1253 | { | |
1254 | bgp->v_update_delay = update_delay; | |
1255 | bgp->v_establish_wait = bgp->v_update_delay; | |
1256 | return CMD_SUCCESS; | |
1257 | } | |
f188f2c4 | 1258 | |
d62a17ae | 1259 | /* update-delay <delay> <establish-wait> */ |
1260 | establish_wait = atoi(wait); | |
1261 | if (update_delay < establish_wait) { | |
1262 | vty_out(vty, | |
1263 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1264 | return CMD_WARNING_CONFIG_FAILED; | |
1265 | } | |
f188f2c4 | 1266 | |
d62a17ae | 1267 | bgp->v_update_delay = update_delay; |
1268 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1269 | |
d62a17ae | 1270 | return CMD_SUCCESS; |
f188f2c4 DS |
1271 | } |
1272 | ||
d62a17ae | 1273 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1274 | { |
d62a17ae | 1275 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1276 | |
d62a17ae | 1277 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1278 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1279 | |
d62a17ae | 1280 | return CMD_SUCCESS; |
f188f2c4 DS |
1281 | } |
1282 | ||
2b791107 | 1283 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1284 | { |
d62a17ae | 1285 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1286 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1287 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1288 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1289 | vty_out(vty, "\n"); | |
1290 | } | |
f188f2c4 DS |
1291 | } |
1292 | ||
1293 | ||
1294 | /* Update-delay configuration */ | |
1295 | DEFUN (bgp_update_delay, | |
1296 | bgp_update_delay_cmd, | |
6147e2c6 | 1297 | "update-delay (0-3600)", |
f188f2c4 DS |
1298 | "Force initial delay for best-path and updates\n" |
1299 | "Seconds\n") | |
1300 | { | |
d62a17ae | 1301 | int idx_number = 1; |
1302 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1303 | } |
1304 | ||
1305 | DEFUN (bgp_update_delay_establish_wait, | |
1306 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1307 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1308 | "Force initial delay for best-path and updates\n" |
1309 | "Seconds\n" | |
f188f2c4 DS |
1310 | "Seconds\n") |
1311 | { | |
d62a17ae | 1312 | int idx_number = 1; |
1313 | int idx_number_2 = 2; | |
1314 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1315 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1316 | } |
1317 | ||
1318 | /* Update-delay deconfiguration */ | |
1319 | DEFUN (no_bgp_update_delay, | |
1320 | no_bgp_update_delay_cmd, | |
838758ac DW |
1321 | "no update-delay [(0-3600) [(1-3600)]]", |
1322 | NO_STR | |
f188f2c4 | 1323 | "Force initial delay for best-path and updates\n" |
838758ac | 1324 | "Seconds\n" |
7111c1a0 | 1325 | "Seconds\n") |
f188f2c4 | 1326 | { |
d62a17ae | 1327 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1328 | } |
1329 | ||
5e242b0d | 1330 | |
d62a17ae | 1331 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, const char *num, |
1332 | char set) | |
cb1faec9 | 1333 | { |
d62a17ae | 1334 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1335 | |
555e09d4 QY |
1336 | if (set) { |
1337 | uint32_t quanta = strtoul(num, NULL, 10); | |
1338 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, | |
1339 | memory_order_relaxed); | |
1340 | } else { | |
1341 | atomic_store_explicit(&bgp->wpkt_quanta, BGP_WRITE_PACKET_MAX, | |
1342 | memory_order_relaxed); | |
1343 | } | |
1344 | ||
1345 | return CMD_SUCCESS; | |
1346 | } | |
1347 | ||
1348 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, const char *num, | |
1349 | char set) | |
1350 | { | |
1351 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1352 | ||
1353 | if (set) { | |
1354 | uint32_t quanta = strtoul(num, NULL, 10); | |
1355 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, | |
1356 | memory_order_relaxed); | |
1357 | } else { | |
1358 | atomic_store_explicit(&bgp->rpkt_quanta, BGP_READ_PACKET_MAX, | |
1359 | memory_order_relaxed); | |
1360 | } | |
cb1faec9 | 1361 | |
d62a17ae | 1362 | return CMD_SUCCESS; |
cb1faec9 DS |
1363 | } |
1364 | ||
2b791107 | 1365 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1366 | { |
555e09d4 QY |
1367 | uint32_t quanta = |
1368 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1369 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1370 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1371 | } |
1372 | ||
555e09d4 QY |
1373 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1374 | { | |
1375 | uint32_t quanta = | |
1376 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1377 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1378 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1379 | } |
cb1faec9 | 1380 | |
555e09d4 | 1381 | /* Packet quanta configuration */ |
cb1faec9 DS |
1382 | DEFUN (bgp_wpkt_quanta, |
1383 | bgp_wpkt_quanta_cmd, | |
555e09d4 | 1384 | "write-quanta (1-10)", |
cb1faec9 DS |
1385 | "How many packets to write to peer socket per run\n" |
1386 | "Number of packets\n") | |
1387 | { | |
d62a17ae | 1388 | int idx_number = 1; |
1389 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1390 | } |
1391 | ||
cb1faec9 DS |
1392 | DEFUN (no_bgp_wpkt_quanta, |
1393 | no_bgp_wpkt_quanta_cmd, | |
555e09d4 | 1394 | "no write-quanta (1-10)", |
d7fa34c1 | 1395 | NO_STR |
555e09d4 | 1396 | "How many packets to write to peer socket per I/O cycle\n" |
cb1faec9 DS |
1397 | "Number of packets\n") |
1398 | { | |
d62a17ae | 1399 | int idx_number = 2; |
1400 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1401 | } |
1402 | ||
555e09d4 QY |
1403 | DEFUN (bgp_rpkt_quanta, |
1404 | bgp_rpkt_quanta_cmd, | |
1405 | "read-quanta (1-10)", | |
1406 | "How many packets to read from peer socket per I/O cycle\n" | |
1407 | "Number of packets\n") | |
1408 | { | |
1409 | int idx_number = 1; | |
1410 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
1411 | } | |
1412 | ||
1413 | DEFUN (no_bgp_rpkt_quanta, | |
1414 | no_bgp_rpkt_quanta_cmd, | |
1415 | "no read-quanta (1-10)", | |
1416 | NO_STR | |
1417 | "How many packets to read from peer socket per I/O cycle\n" | |
1418 | "Number of packets\n") | |
1419 | { | |
1420 | int idx_number = 2; | |
1421 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
1422 | } | |
1423 | ||
2b791107 | 1424 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1425 | { |
14b8641a QY |
1426 | if (bgp->v_coalesce_time) |
1427 | vty_out(vty, " coalesce-time %u\n", bgp->v_coalesce_time); | |
3f9c7369 DS |
1428 | } |
1429 | ||
1430 | ||
1431 | DEFUN (bgp_coalesce_time, | |
1432 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1433 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1434 | "Subgroup coalesce timer\n" |
1435 | "Subgroup coalesce timer value (in ms)\n") | |
1436 | { | |
d62a17ae | 1437 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1438 | |
d62a17ae | 1439 | int idx = 0; |
1440 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
14b8641a QY |
1441 | bgp->coalesce_time = bgp->v_coalesce_time = |
1442 | strtoul(argv[idx]->arg, NULL, 10); | |
d62a17ae | 1443 | return CMD_SUCCESS; |
3f9c7369 DS |
1444 | } |
1445 | ||
1446 | DEFUN (no_bgp_coalesce_time, | |
1447 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1448 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1449 | NO_STR |
3f9c7369 DS |
1450 | "Subgroup coalesce timer\n" |
1451 | "Subgroup coalesce timer value (in ms)\n") | |
1452 | { | |
d62a17ae | 1453 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1454 | |
14b8641a | 1455 | bgp->v_coalesce_time = 0; |
d62a17ae | 1456 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1457 | return CMD_SUCCESS; | |
3f9c7369 DS |
1458 | } |
1459 | ||
5e242b0d DS |
1460 | /* Maximum-paths configuration */ |
1461 | DEFUN (bgp_maxpaths, | |
1462 | bgp_maxpaths_cmd, | |
6319fd63 | 1463 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1464 | "Forward packets over multiple paths\n" |
1465 | "Number of paths\n") | |
1466 | { | |
d62a17ae | 1467 | int idx_number = 1; |
1468 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1469 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1470 | } |
1471 | ||
d62a17ae | 1472 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1473 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1474 | "Forward packets over multiple paths\n" | |
1475 | "Number of paths\n") | |
596c17ba | 1476 | |
165b5fff JB |
1477 | DEFUN (bgp_maxpaths_ibgp, |
1478 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1479 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1480 | "Forward packets over multiple paths\n" |
1481 | "iBGP-multipath\n" | |
1482 | "Number of paths\n") | |
1483 | { | |
d62a17ae | 1484 | int idx_number = 2; |
1485 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1486 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1487 | } |
165b5fff | 1488 | |
d62a17ae | 1489 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1490 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1491 | "Forward packets over multiple paths\n" | |
1492 | "iBGP-multipath\n" | |
1493 | "Number of paths\n") | |
596c17ba | 1494 | |
5e242b0d DS |
1495 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1496 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1497 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1498 | "Forward packets over multiple paths\n" |
1499 | "iBGP-multipath\n" | |
1500 | "Number of paths\n" | |
1501 | "Match the cluster length\n") | |
1502 | { | |
d62a17ae | 1503 | int idx_number = 2; |
1504 | return bgp_maxpaths_config_vty( | |
1505 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1506 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1507 | } |
1508 | ||
d62a17ae | 1509 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1510 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1511 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1512 | "Forward packets over multiple paths\n" | |
1513 | "iBGP-multipath\n" | |
1514 | "Number of paths\n" | |
1515 | "Match the cluster length\n") | |
596c17ba | 1516 | |
165b5fff JB |
1517 | DEFUN (no_bgp_maxpaths, |
1518 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1519 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1520 | NO_STR |
1521 | "Forward packets over multiple paths\n" | |
1522 | "Number of paths\n") | |
1523 | { | |
d62a17ae | 1524 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1525 | } |
1526 | ||
d62a17ae | 1527 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
9d303b37 | 1528 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1529 | "Forward packets over multiple paths\n" |
1530 | "Number of paths\n") | |
596c17ba | 1531 | |
165b5fff JB |
1532 | DEFUN (no_bgp_maxpaths_ibgp, |
1533 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1534 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1535 | NO_STR |
1536 | "Forward packets over multiple paths\n" | |
1537 | "iBGP-multipath\n" | |
838758ac DW |
1538 | "Number of paths\n" |
1539 | "Match the cluster length\n") | |
165b5fff | 1540 | { |
d62a17ae | 1541 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1542 | } |
1543 | ||
d62a17ae | 1544 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1545 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1546 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1547 | NO_STR | |
1548 | "Forward packets over multiple paths\n" | |
1549 | "iBGP-multipath\n" | |
1550 | "Number of paths\n" | |
1551 | "Match the cluster length\n") | |
596c17ba | 1552 | |
2b791107 | 1553 | void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 1554 | safi_t safi) |
165b5fff | 1555 | { |
d62a17ae | 1556 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1557 | vty_out(vty, " maximum-paths %d\n", |
1558 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1559 | } | |
165b5fff | 1560 | |
d62a17ae | 1561 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1562 | vty_out(vty, " maximum-paths ibgp %d", |
1563 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1564 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1565 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1566 | vty_out(vty, " equal-cluster-length"); | |
1567 | vty_out(vty, "\n"); | |
1568 | } | |
165b5fff | 1569 | } |
6b0655a2 | 1570 | |
718e3744 | 1571 | /* BGP timers. */ |
1572 | ||
1573 | DEFUN (bgp_timers, | |
1574 | bgp_timers_cmd, | |
6147e2c6 | 1575 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1576 | "Adjust routing timers\n" |
1577 | "BGP timers\n" | |
1578 | "Keepalive interval\n" | |
1579 | "Holdtime\n") | |
1580 | { | |
d62a17ae | 1581 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1582 | int idx_number = 2; | |
1583 | int idx_number_2 = 3; | |
1584 | unsigned long keepalive = 0; | |
1585 | unsigned long holdtime = 0; | |
718e3744 | 1586 | |
d62a17ae | 1587 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1588 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1589 | |
d62a17ae | 1590 | /* Holdtime value check. */ |
1591 | if (holdtime < 3 && holdtime != 0) { | |
1592 | vty_out(vty, | |
1593 | "%% hold time value must be either 0 or greater than 3\n"); | |
1594 | return CMD_WARNING_CONFIG_FAILED; | |
1595 | } | |
718e3744 | 1596 | |
d62a17ae | 1597 | bgp_timers_set(bgp, keepalive, holdtime); |
718e3744 | 1598 | |
d62a17ae | 1599 | return CMD_SUCCESS; |
718e3744 | 1600 | } |
1601 | ||
1602 | DEFUN (no_bgp_timers, | |
1603 | no_bgp_timers_cmd, | |
838758ac | 1604 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1605 | NO_STR |
1606 | "Adjust routing timers\n" | |
838758ac DW |
1607 | "BGP timers\n" |
1608 | "Keepalive interval\n" | |
1609 | "Holdtime\n") | |
718e3744 | 1610 | { |
d62a17ae | 1611 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1612 | bgp_timers_unset(bgp); | |
718e3744 | 1613 | |
d62a17ae | 1614 | return CMD_SUCCESS; |
718e3744 | 1615 | } |
1616 | ||
6b0655a2 | 1617 | |
718e3744 | 1618 | DEFUN (bgp_client_to_client_reflection, |
1619 | bgp_client_to_client_reflection_cmd, | |
1620 | "bgp client-to-client reflection", | |
1621 | "BGP specific commands\n" | |
1622 | "Configure client to client route reflection\n" | |
1623 | "reflection of routes allowed\n") | |
1624 | { | |
d62a17ae | 1625 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1626 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1627 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1628 | |
d62a17ae | 1629 | return CMD_SUCCESS; |
718e3744 | 1630 | } |
1631 | ||
1632 | DEFUN (no_bgp_client_to_client_reflection, | |
1633 | no_bgp_client_to_client_reflection_cmd, | |
1634 | "no bgp client-to-client reflection", | |
1635 | NO_STR | |
1636 | "BGP specific commands\n" | |
1637 | "Configure client to client route reflection\n" | |
1638 | "reflection of routes allowed\n") | |
1639 | { | |
d62a17ae | 1640 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1641 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1642 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1643 | |
d62a17ae | 1644 | return CMD_SUCCESS; |
718e3744 | 1645 | } |
1646 | ||
1647 | /* "bgp always-compare-med" configuration. */ | |
1648 | DEFUN (bgp_always_compare_med, | |
1649 | bgp_always_compare_med_cmd, | |
1650 | "bgp always-compare-med", | |
1651 | "BGP specific commands\n" | |
1652 | "Allow comparing MED from different neighbors\n") | |
1653 | { | |
d62a17ae | 1654 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1655 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1656 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1657 | |
d62a17ae | 1658 | return CMD_SUCCESS; |
718e3744 | 1659 | } |
1660 | ||
1661 | DEFUN (no_bgp_always_compare_med, | |
1662 | no_bgp_always_compare_med_cmd, | |
1663 | "no bgp always-compare-med", | |
1664 | NO_STR | |
1665 | "BGP specific commands\n" | |
1666 | "Allow comparing MED from different neighbors\n") | |
1667 | { | |
d62a17ae | 1668 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1669 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1670 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1671 | |
d62a17ae | 1672 | return CMD_SUCCESS; |
718e3744 | 1673 | } |
6b0655a2 | 1674 | |
718e3744 | 1675 | /* "bgp deterministic-med" configuration. */ |
1676 | DEFUN (bgp_deterministic_med, | |
1677 | bgp_deterministic_med_cmd, | |
1678 | "bgp deterministic-med", | |
1679 | "BGP specific commands\n" | |
1680 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1681 | { | |
d62a17ae | 1682 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 1683 | |
d62a17ae | 1684 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
1685 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1686 | bgp_recalculate_all_bestpaths(bgp); | |
1687 | } | |
7aafcaca | 1688 | |
d62a17ae | 1689 | return CMD_SUCCESS; |
718e3744 | 1690 | } |
1691 | ||
1692 | DEFUN (no_bgp_deterministic_med, | |
1693 | no_bgp_deterministic_med_cmd, | |
1694 | "no bgp deterministic-med", | |
1695 | NO_STR | |
1696 | "BGP specific commands\n" | |
1697 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1698 | { | |
d62a17ae | 1699 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1700 | int bestpath_per_as_used; | |
1701 | afi_t afi; | |
1702 | safi_t safi; | |
1703 | struct peer *peer; | |
1704 | struct listnode *node, *nnode; | |
1705 | ||
1706 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
1707 | bestpath_per_as_used = 0; | |
1708 | ||
1709 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc QY |
1710 | FOREACH_AFI_SAFI (afi, safi) |
1711 | if (CHECK_FLAG( | |
1712 | peer->af_flags[afi][safi], | |
1713 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) { | |
1714 | bestpath_per_as_used = 1; | |
1715 | break; | |
1716 | } | |
d62a17ae | 1717 | |
1718 | if (bestpath_per_as_used) | |
1719 | break; | |
1720 | } | |
1721 | ||
1722 | if (bestpath_per_as_used) { | |
1723 | vty_out(vty, | |
1724 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
1725 | return CMD_WARNING_CONFIG_FAILED; | |
1726 | } else { | |
1727 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1728 | bgp_recalculate_all_bestpaths(bgp); | |
1729 | } | |
1730 | } | |
1731 | ||
1732 | return CMD_SUCCESS; | |
718e3744 | 1733 | } |
538621f2 | 1734 | |
1735 | /* "bgp graceful-restart" configuration. */ | |
1736 | DEFUN (bgp_graceful_restart, | |
1737 | bgp_graceful_restart_cmd, | |
1738 | "bgp graceful-restart", | |
1739 | "BGP specific commands\n" | |
1740 | "Graceful restart capability parameters\n") | |
1741 | { | |
d62a17ae | 1742 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1743 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1744 | return CMD_SUCCESS; | |
538621f2 | 1745 | } |
1746 | ||
1747 | DEFUN (no_bgp_graceful_restart, | |
1748 | no_bgp_graceful_restart_cmd, | |
1749 | "no bgp graceful-restart", | |
1750 | NO_STR | |
1751 | "BGP specific commands\n" | |
1752 | "Graceful restart capability parameters\n") | |
1753 | { | |
d62a17ae | 1754 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1755 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1756 | return CMD_SUCCESS; | |
538621f2 | 1757 | } |
1758 | ||
93406d87 | 1759 | DEFUN (bgp_graceful_restart_stalepath_time, |
1760 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1761 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1762 | "BGP specific commands\n" |
1763 | "Graceful restart capability parameters\n" | |
1764 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1765 | "Delay value (seconds)\n") | |
1766 | { | |
d62a17ae | 1767 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1768 | int idx_number = 3; | |
1769 | u_int32_t stalepath; | |
93406d87 | 1770 | |
d62a17ae | 1771 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
1772 | bgp->stalepath_time = stalepath; | |
1773 | return CMD_SUCCESS; | |
93406d87 | 1774 | } |
1775 | ||
eb6f1b41 PG |
1776 | DEFUN (bgp_graceful_restart_restart_time, |
1777 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1778 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1779 | "BGP specific commands\n" |
1780 | "Graceful restart capability parameters\n" | |
1781 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1782 | "Delay value (seconds)\n") | |
1783 | { | |
d62a17ae | 1784 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1785 | int idx_number = 3; | |
1786 | u_int32_t restart; | |
eb6f1b41 | 1787 | |
d62a17ae | 1788 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
1789 | bgp->restart_time = restart; | |
1790 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1791 | } |
1792 | ||
93406d87 | 1793 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1794 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1795 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1796 | NO_STR |
1797 | "BGP specific commands\n" | |
1798 | "Graceful restart capability parameters\n" | |
838758ac DW |
1799 | "Set the max time to hold onto restarting peer's stale paths\n" |
1800 | "Delay value (seconds)\n") | |
93406d87 | 1801 | { |
d62a17ae | 1802 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1803 | |
d62a17ae | 1804 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
1805 | return CMD_SUCCESS; | |
93406d87 | 1806 | } |
1807 | ||
eb6f1b41 PG |
1808 | DEFUN (no_bgp_graceful_restart_restart_time, |
1809 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1810 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1811 | NO_STR |
1812 | "BGP specific commands\n" | |
1813 | "Graceful restart capability parameters\n" | |
838758ac DW |
1814 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1815 | "Delay value (seconds)\n") | |
eb6f1b41 | 1816 | { |
d62a17ae | 1817 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 1818 | |
d62a17ae | 1819 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
1820 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1821 | } |
1822 | ||
43fc21b3 JC |
1823 | DEFUN (bgp_graceful_restart_preserve_fw, |
1824 | bgp_graceful_restart_preserve_fw_cmd, | |
1825 | "bgp graceful-restart preserve-fw-state", | |
1826 | "BGP specific commands\n" | |
1827 | "Graceful restart capability parameters\n" | |
1828 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1829 | { | |
d62a17ae | 1830 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1831 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1832 | return CMD_SUCCESS; | |
43fc21b3 JC |
1833 | } |
1834 | ||
1835 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
1836 | no_bgp_graceful_restart_preserve_fw_cmd, | |
1837 | "no bgp graceful-restart preserve-fw-state", | |
1838 | NO_STR | |
1839 | "BGP specific commands\n" | |
1840 | "Graceful restart capability parameters\n" | |
1841 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1842 | { | |
d62a17ae | 1843 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1844 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1845 | return CMD_SUCCESS; | |
43fc21b3 JC |
1846 | } |
1847 | ||
7f323236 DW |
1848 | static void bgp_redistribute_redo(struct bgp *bgp) |
1849 | { | |
1850 | afi_t afi; | |
1851 | int i; | |
1852 | struct list *red_list; | |
1853 | struct listnode *node; | |
1854 | struct bgp_redist *red; | |
1855 | ||
1856 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
1857 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
1858 | ||
1859 | red_list = bgp->redist[afi][i]; | |
1860 | if (!red_list) | |
1861 | continue; | |
1862 | ||
1863 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
1864 | bgp_redistribute_resend(bgp, afi, i, | |
1865 | red->instance); | |
1866 | } | |
1867 | } | |
1868 | } | |
1869 | } | |
1870 | ||
1871 | /* "bgp graceful-shutdown" configuration */ | |
1872 | DEFUN (bgp_graceful_shutdown, | |
1873 | bgp_graceful_shutdown_cmd, | |
1874 | "bgp graceful-shutdown", | |
1875 | BGP_STR | |
1876 | "Graceful shutdown parameters\n") | |
1877 | { | |
1878 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1879 | ||
1880 | if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
1881 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
1882 | bgp_static_redo_import_check(bgp); | |
1883 | bgp_redistribute_redo(bgp); | |
1884 | bgp_clear_star_soft_out(vty, bgp->name); | |
1885 | bgp_clear_star_soft_in(vty, bgp->name); | |
1886 | } | |
1887 | ||
1888 | return CMD_SUCCESS; | |
1889 | } | |
1890 | ||
1891 | DEFUN (no_bgp_graceful_shutdown, | |
1892 | no_bgp_graceful_shutdown_cmd, | |
1893 | "no bgp graceful-shutdown", | |
1894 | NO_STR | |
1895 | BGP_STR | |
1896 | "Graceful shutdown parameters\n") | |
1897 | { | |
1898 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1899 | ||
1900 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
1901 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
1902 | bgp_static_redo_import_check(bgp); | |
1903 | bgp_redistribute_redo(bgp); | |
1904 | bgp_clear_star_soft_out(vty, bgp->name); | |
1905 | bgp_clear_star_soft_in(vty, bgp->name); | |
1906 | } | |
1907 | ||
1908 | return CMD_SUCCESS; | |
1909 | } | |
1910 | ||
718e3744 | 1911 | /* "bgp fast-external-failover" configuration. */ |
1912 | DEFUN (bgp_fast_external_failover, | |
1913 | bgp_fast_external_failover_cmd, | |
1914 | "bgp fast-external-failover", | |
1915 | BGP_STR | |
1916 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1917 | { | |
d62a17ae | 1918 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1919 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
1920 | return CMD_SUCCESS; | |
718e3744 | 1921 | } |
1922 | ||
1923 | DEFUN (no_bgp_fast_external_failover, | |
1924 | no_bgp_fast_external_failover_cmd, | |
1925 | "no bgp fast-external-failover", | |
1926 | NO_STR | |
1927 | BGP_STR | |
1928 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1929 | { | |
d62a17ae | 1930 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1931 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
1932 | return CMD_SUCCESS; | |
718e3744 | 1933 | } |
6b0655a2 | 1934 | |
718e3744 | 1935 | /* "bgp enforce-first-as" configuration. */ |
1936 | DEFUN (bgp_enforce_first_as, | |
1937 | bgp_enforce_first_as_cmd, | |
1938 | "bgp enforce-first-as", | |
1939 | BGP_STR | |
1940 | "Enforce the first AS for EBGP routes\n") | |
1941 | { | |
d62a17ae | 1942 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1943 | bgp_flag_set(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
1944 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 1945 | |
d62a17ae | 1946 | return CMD_SUCCESS; |
718e3744 | 1947 | } |
1948 | ||
1949 | DEFUN (no_bgp_enforce_first_as, | |
1950 | no_bgp_enforce_first_as_cmd, | |
1951 | "no bgp enforce-first-as", | |
1952 | NO_STR | |
1953 | BGP_STR | |
1954 | "Enforce the first AS for EBGP routes\n") | |
1955 | { | |
d62a17ae | 1956 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1957 | bgp_flag_unset(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
1958 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 1959 | |
d62a17ae | 1960 | return CMD_SUCCESS; |
718e3744 | 1961 | } |
6b0655a2 | 1962 | |
718e3744 | 1963 | /* "bgp bestpath compare-routerid" configuration. */ |
1964 | DEFUN (bgp_bestpath_compare_router_id, | |
1965 | bgp_bestpath_compare_router_id_cmd, | |
1966 | "bgp bestpath compare-routerid", | |
1967 | "BGP specific commands\n" | |
1968 | "Change the default bestpath selection\n" | |
1969 | "Compare router-id for identical EBGP paths\n") | |
1970 | { | |
d62a17ae | 1971 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1972 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
1973 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1974 | |
d62a17ae | 1975 | return CMD_SUCCESS; |
718e3744 | 1976 | } |
1977 | ||
1978 | DEFUN (no_bgp_bestpath_compare_router_id, | |
1979 | no_bgp_bestpath_compare_router_id_cmd, | |
1980 | "no bgp bestpath compare-routerid", | |
1981 | NO_STR | |
1982 | "BGP specific commands\n" | |
1983 | "Change the default bestpath selection\n" | |
1984 | "Compare router-id for identical EBGP paths\n") | |
1985 | { | |
d62a17ae | 1986 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1987 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
1988 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1989 | |
d62a17ae | 1990 | return CMD_SUCCESS; |
718e3744 | 1991 | } |
6b0655a2 | 1992 | |
718e3744 | 1993 | /* "bgp bestpath as-path ignore" configuration. */ |
1994 | DEFUN (bgp_bestpath_aspath_ignore, | |
1995 | bgp_bestpath_aspath_ignore_cmd, | |
1996 | "bgp bestpath as-path ignore", | |
1997 | "BGP specific commands\n" | |
1998 | "Change the default bestpath selection\n" | |
1999 | "AS-path attribute\n" | |
2000 | "Ignore as-path length in selecting a route\n") | |
2001 | { | |
d62a17ae | 2002 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2003 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2004 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2005 | |
d62a17ae | 2006 | return CMD_SUCCESS; |
718e3744 | 2007 | } |
2008 | ||
2009 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2010 | no_bgp_bestpath_aspath_ignore_cmd, | |
2011 | "no bgp bestpath as-path ignore", | |
2012 | NO_STR | |
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_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2020 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2021 | |
d62a17ae | 2022 | return CMD_SUCCESS; |
718e3744 | 2023 | } |
6b0655a2 | 2024 | |
6811845b | 2025 | /* "bgp bestpath as-path confed" configuration. */ |
2026 | DEFUN (bgp_bestpath_aspath_confed, | |
2027 | bgp_bestpath_aspath_confed_cmd, | |
2028 | "bgp bestpath as-path confed", | |
2029 | "BGP specific commands\n" | |
2030 | "Change the default bestpath selection\n" | |
2031 | "AS-path attribute\n" | |
2032 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2033 | { | |
d62a17ae | 2034 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2035 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
2036 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2037 | |
d62a17ae | 2038 | return CMD_SUCCESS; |
6811845b | 2039 | } |
2040 | ||
2041 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2042 | no_bgp_bestpath_aspath_confed_cmd, | |
2043 | "no bgp bestpath as-path confed", | |
2044 | NO_STR | |
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_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
2052 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2053 | |
d62a17ae | 2054 | return CMD_SUCCESS; |
6811845b | 2055 | } |
6b0655a2 | 2056 | |
2fdd455c PM |
2057 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2058 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2059 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2060 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2061 | "BGP specific commands\n" |
2062 | "Change the default bestpath selection\n" | |
2063 | "AS-path attribute\n" | |
2064 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2065 | "Generate an AS_SET\n" |
16fc1eec DS |
2066 | "Do not generate an AS_SET\n") |
2067 | { | |
d62a17ae | 2068 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2069 | int idx = 0; | |
2070 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 2071 | |
d62a17ae | 2072 | /* no-as-set is now the default behavior so we can silently |
2073 | * ignore it */ | |
2074 | if (argv_find(argv, argc, "as-set", &idx)) | |
2075 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2076 | else | |
2077 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 2078 | |
d62a17ae | 2079 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2080 | |
d62a17ae | 2081 | return CMD_SUCCESS; |
16fc1eec DS |
2082 | } |
2083 | ||
219178b6 DW |
2084 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2085 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2086 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2087 | NO_STR |
2088 | "BGP specific commands\n" | |
2089 | "Change the default bestpath selection\n" | |
2090 | "AS-path attribute\n" | |
2091 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2092 | "Generate an AS_SET\n" |
16fc1eec DS |
2093 | "Do not generate an AS_SET\n") |
2094 | { | |
d62a17ae | 2095 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2096 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
2097 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2098 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2099 | |
d62a17ae | 2100 | return CMD_SUCCESS; |
2fdd455c | 2101 | } |
6b0655a2 | 2102 | |
848973c7 | 2103 | /* "bgp log-neighbor-changes" configuration. */ |
2104 | DEFUN (bgp_log_neighbor_changes, | |
2105 | bgp_log_neighbor_changes_cmd, | |
2106 | "bgp log-neighbor-changes", | |
2107 | "BGP specific commands\n" | |
2108 | "Log neighbor up/down and reset reason\n") | |
2109 | { | |
d62a17ae | 2110 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2111 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2112 | return CMD_SUCCESS; | |
848973c7 | 2113 | } |
2114 | ||
2115 | DEFUN (no_bgp_log_neighbor_changes, | |
2116 | no_bgp_log_neighbor_changes_cmd, | |
2117 | "no bgp log-neighbor-changes", | |
2118 | NO_STR | |
2119 | "BGP specific commands\n" | |
2120 | "Log neighbor up/down and reset reason\n") | |
2121 | { | |
d62a17ae | 2122 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2123 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2124 | return CMD_SUCCESS; | |
848973c7 | 2125 | } |
6b0655a2 | 2126 | |
718e3744 | 2127 | /* "bgp bestpath med" configuration. */ |
2128 | DEFUN (bgp_bestpath_med, | |
2129 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2130 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2131 | "BGP specific commands\n" |
2132 | "Change the default bestpath selection\n" | |
2133 | "MED attribute\n" | |
2134 | "Compare MED among confederation paths\n" | |
838758ac DW |
2135 | "Treat missing MED as the least preferred one\n" |
2136 | "Treat missing MED as the least preferred one\n" | |
2137 | "Compare MED among confederation paths\n") | |
718e3744 | 2138 | { |
d62a17ae | 2139 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2140 | |
d62a17ae | 2141 | int idx = 0; |
2142 | if (argv_find(argv, argc, "confed", &idx)) | |
2143 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2144 | idx = 0; | |
2145 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2146 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2147 | |
d62a17ae | 2148 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2149 | |
d62a17ae | 2150 | return CMD_SUCCESS; |
718e3744 | 2151 | } |
2152 | ||
718e3744 | 2153 | DEFUN (no_bgp_bestpath_med, |
2154 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2155 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2156 | NO_STR |
2157 | "BGP specific commands\n" | |
2158 | "Change the default bestpath selection\n" | |
2159 | "MED attribute\n" | |
2160 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2161 | "Treat missing MED as the least preferred one\n" |
2162 | "Treat missing MED as the least preferred one\n" | |
2163 | "Compare MED among confederation paths\n") | |
718e3744 | 2164 | { |
d62a17ae | 2165 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2166 | |
d62a17ae | 2167 | int idx = 0; |
2168 | if (argv_find(argv, argc, "confed", &idx)) | |
2169 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2170 | idx = 0; | |
2171 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2172 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2173 | |
d62a17ae | 2174 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2175 | |
d62a17ae | 2176 | return CMD_SUCCESS; |
718e3744 | 2177 | } |
2178 | ||
718e3744 | 2179 | /* "no bgp default ipv4-unicast". */ |
2180 | DEFUN (no_bgp_default_ipv4_unicast, | |
2181 | no_bgp_default_ipv4_unicast_cmd, | |
2182 | "no bgp default ipv4-unicast", | |
2183 | NO_STR | |
2184 | "BGP specific commands\n" | |
2185 | "Configure BGP defaults\n" | |
2186 | "Activate ipv4-unicast for a peer by default\n") | |
2187 | { | |
d62a17ae | 2188 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2189 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2190 | return CMD_SUCCESS; | |
718e3744 | 2191 | } |
2192 | ||
2193 | DEFUN (bgp_default_ipv4_unicast, | |
2194 | bgp_default_ipv4_unicast_cmd, | |
2195 | "bgp default ipv4-unicast", | |
2196 | "BGP specific commands\n" | |
2197 | "Configure BGP defaults\n" | |
2198 | "Activate ipv4-unicast for a peer by default\n") | |
2199 | { | |
d62a17ae | 2200 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2201 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2202 | return CMD_SUCCESS; | |
718e3744 | 2203 | } |
6b0655a2 | 2204 | |
04b6bdc0 DW |
2205 | /* Display hostname in certain command outputs */ |
2206 | DEFUN (bgp_default_show_hostname, | |
2207 | bgp_default_show_hostname_cmd, | |
2208 | "bgp default show-hostname", | |
2209 | "BGP specific commands\n" | |
2210 | "Configure BGP defaults\n" | |
2211 | "Show hostname in certain command ouputs\n") | |
2212 | { | |
d62a17ae | 2213 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2214 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2215 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2216 | } |
2217 | ||
2218 | DEFUN (no_bgp_default_show_hostname, | |
2219 | no_bgp_default_show_hostname_cmd, | |
2220 | "no bgp default show-hostname", | |
2221 | NO_STR | |
2222 | "BGP specific commands\n" | |
2223 | "Configure BGP defaults\n" | |
2224 | "Show hostname in certain command ouputs\n") | |
2225 | { | |
d62a17ae | 2226 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2227 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2228 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2229 | } |
2230 | ||
8233ef81 | 2231 | /* "bgp network import-check" configuration. */ |
718e3744 | 2232 | DEFUN (bgp_network_import_check, |
2233 | bgp_network_import_check_cmd, | |
5623e905 | 2234 | "bgp network import-check", |
718e3744 | 2235 | "BGP specific commands\n" |
2236 | "BGP network command\n" | |
5623e905 | 2237 | "Check BGP network route exists in IGP\n") |
718e3744 | 2238 | { |
d62a17ae | 2239 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2240 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2241 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
2242 | bgp_static_redo_import_check(bgp); | |
2243 | } | |
078430f6 | 2244 | |
d62a17ae | 2245 | return CMD_SUCCESS; |
718e3744 | 2246 | } |
2247 | ||
d62a17ae | 2248 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
2249 | "bgp network import-check exact", | |
2250 | "BGP specific commands\n" | |
2251 | "BGP network command\n" | |
2252 | "Check BGP network route exists in IGP\n" | |
2253 | "Match route precisely\n") | |
8233ef81 | 2254 | |
718e3744 | 2255 | DEFUN (no_bgp_network_import_check, |
2256 | no_bgp_network_import_check_cmd, | |
5623e905 | 2257 | "no bgp network import-check", |
718e3744 | 2258 | NO_STR |
2259 | "BGP specific commands\n" | |
2260 | "BGP network command\n" | |
2261 | "Check BGP network route exists in IGP\n") | |
2262 | { | |
d62a17ae | 2263 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2264 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2265 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
2266 | bgp_static_redo_import_check(bgp); | |
2267 | } | |
5623e905 | 2268 | |
d62a17ae | 2269 | return CMD_SUCCESS; |
718e3744 | 2270 | } |
6b0655a2 | 2271 | |
718e3744 | 2272 | DEFUN (bgp_default_local_preference, |
2273 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2274 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2275 | "BGP specific commands\n" |
2276 | "Configure BGP defaults\n" | |
2277 | "local preference (higher=more preferred)\n" | |
2278 | "Configure default local preference value\n") | |
2279 | { | |
d62a17ae | 2280 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2281 | int idx_number = 3; | |
2282 | u_int32_t local_pref; | |
718e3744 | 2283 | |
d62a17ae | 2284 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2285 | |
d62a17ae | 2286 | bgp_default_local_preference_set(bgp, local_pref); |
2287 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 2288 | |
d62a17ae | 2289 | return CMD_SUCCESS; |
718e3744 | 2290 | } |
2291 | ||
2292 | DEFUN (no_bgp_default_local_preference, | |
2293 | no_bgp_default_local_preference_cmd, | |
838758ac | 2294 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2295 | NO_STR |
2296 | "BGP specific commands\n" | |
2297 | "Configure BGP defaults\n" | |
838758ac DW |
2298 | "local preference (higher=more preferred)\n" |
2299 | "Configure default local preference value\n") | |
718e3744 | 2300 | { |
d62a17ae | 2301 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2302 | bgp_default_local_preference_unset(bgp); | |
2303 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2304 | |
d62a17ae | 2305 | return CMD_SUCCESS; |
718e3744 | 2306 | } |
2307 | ||
6b0655a2 | 2308 | |
3f9c7369 DS |
2309 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2310 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2311 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2312 | "BGP specific commands\n" |
2313 | "Configure BGP defaults\n" | |
2314 | "subgroup-pkt-queue-max\n" | |
2315 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2316 | { |
d62a17ae | 2317 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2318 | int idx_number = 3; | |
2319 | u_int32_t max_size; | |
8bd9d948 | 2320 | |
d62a17ae | 2321 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 2322 | |
d62a17ae | 2323 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 2324 | |
d62a17ae | 2325 | return CMD_SUCCESS; |
3f9c7369 DS |
2326 | } |
2327 | ||
2328 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2329 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2330 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2331 | NO_STR |
2332 | "BGP specific commands\n" | |
2333 | "Configure BGP defaults\n" | |
838758ac DW |
2334 | "subgroup-pkt-queue-max\n" |
2335 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2336 | { |
d62a17ae | 2337 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2338 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
2339 | return CMD_SUCCESS; | |
8bd9d948 DS |
2340 | } |
2341 | ||
813d4307 | 2342 | |
8bd9d948 DS |
2343 | DEFUN (bgp_rr_allow_outbound_policy, |
2344 | bgp_rr_allow_outbound_policy_cmd, | |
2345 | "bgp route-reflector allow-outbound-policy", | |
2346 | "BGP specific commands\n" | |
2347 | "Allow modifications made by out route-map\n" | |
2348 | "on ibgp neighbors\n") | |
2349 | { | |
d62a17ae | 2350 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2351 | |
d62a17ae | 2352 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2353 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2354 | update_group_announce_rrclients(bgp); | |
2355 | bgp_clear_star_soft_out(vty, bgp->name); | |
2356 | } | |
8bd9d948 | 2357 | |
d62a17ae | 2358 | return CMD_SUCCESS; |
8bd9d948 DS |
2359 | } |
2360 | ||
2361 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2362 | no_bgp_rr_allow_outbound_policy_cmd, | |
2363 | "no bgp route-reflector allow-outbound-policy", | |
2364 | NO_STR | |
2365 | "BGP specific commands\n" | |
2366 | "Allow modifications made by out route-map\n" | |
2367 | "on ibgp neighbors\n") | |
2368 | { | |
d62a17ae | 2369 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2370 | |
d62a17ae | 2371 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2372 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2373 | update_group_announce_rrclients(bgp); | |
2374 | bgp_clear_star_soft_out(vty, bgp->name); | |
2375 | } | |
8bd9d948 | 2376 | |
d62a17ae | 2377 | return CMD_SUCCESS; |
8bd9d948 DS |
2378 | } |
2379 | ||
f14e6fdb DS |
2380 | DEFUN (bgp_listen_limit, |
2381 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2382 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2383 | "BGP specific commands\n" |
2384 | "Configure BGP defaults\n" | |
2385 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2386 | "Configure Dynamic Neighbors listen limit value\n") | |
2387 | { | |
d62a17ae | 2388 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2389 | int idx_number = 3; | |
2390 | int listen_limit; | |
f14e6fdb | 2391 | |
d62a17ae | 2392 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 2393 | |
d62a17ae | 2394 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 2395 | |
d62a17ae | 2396 | return CMD_SUCCESS; |
f14e6fdb DS |
2397 | } |
2398 | ||
2399 | DEFUN (no_bgp_listen_limit, | |
2400 | no_bgp_listen_limit_cmd, | |
838758ac | 2401 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2402 | "BGP specific commands\n" |
2403 | "Configure BGP defaults\n" | |
2404 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2405 | "Configure Dynamic Neighbors listen limit value to default\n" |
2406 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2407 | { |
d62a17ae | 2408 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2409 | bgp_listen_limit_unset(bgp); | |
2410 | return CMD_SUCCESS; | |
f14e6fdb DS |
2411 | } |
2412 | ||
2413 | ||
20eb8864 | 2414 | /* |
2415 | * Check if this listen range is already configured. Check for exact | |
2416 | * match or overlap based on input. | |
2417 | */ | |
d62a17ae | 2418 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
2419 | struct prefix *range, int exact) | |
2420 | { | |
2421 | struct listnode *node, *nnode; | |
2422 | struct listnode *node1, *nnode1; | |
2423 | struct peer_group *group; | |
2424 | struct prefix *lr; | |
2425 | afi_t afi; | |
2426 | int match; | |
2427 | ||
2428 | afi = family2afi(range->family); | |
2429 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2430 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
2431 | lr)) { | |
2432 | if (exact) | |
2433 | match = prefix_same(range, lr); | |
2434 | else | |
2435 | match = (prefix_match(range, lr) | |
2436 | || prefix_match(lr, range)); | |
2437 | if (match) | |
2438 | return group; | |
2439 | } | |
2440 | } | |
2441 | ||
2442 | return NULL; | |
20eb8864 | 2443 | } |
2444 | ||
f14e6fdb DS |
2445 | DEFUN (bgp_listen_range, |
2446 | bgp_listen_range_cmd, | |
9ccf14f7 | 2447 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2448 | "BGP specific commands\n" |
d7fa34c1 QY |
2449 | "Configure BGP dynamic neighbors listen range\n" |
2450 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2451 | NEIGHBOR_ADDR_STR |
2452 | "Member of the peer-group\n" | |
2453 | "Peer-group name\n") | |
f14e6fdb | 2454 | { |
d62a17ae | 2455 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2456 | struct prefix range; | |
2457 | struct peer_group *group, *existing_group; | |
2458 | afi_t afi; | |
2459 | int ret; | |
2460 | int idx = 0; | |
2461 | ||
2462 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2463 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2464 | char *prefix = argv[idx]->arg; | |
2465 | argv_find(argv, argc, "WORD", &idx); | |
2466 | char *peergroup = argv[idx]->arg; | |
2467 | ||
2468 | /* Convert IP prefix string to struct prefix. */ | |
2469 | ret = str2prefix(prefix, &range); | |
2470 | if (!ret) { | |
2471 | vty_out(vty, "%% Malformed listen range\n"); | |
2472 | return CMD_WARNING_CONFIG_FAILED; | |
2473 | } | |
2474 | ||
2475 | afi = family2afi(range.family); | |
2476 | ||
2477 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2478 | vty_out(vty, | |
2479 | "%% Malformed listen range (link-local address)\n"); | |
2480 | return CMD_WARNING_CONFIG_FAILED; | |
2481 | } | |
2482 | ||
2483 | apply_mask(&range); | |
2484 | ||
2485 | /* Check if same listen range is already configured. */ | |
2486 | existing_group = listen_range_exists(bgp, &range, 1); | |
2487 | if (existing_group) { | |
2488 | if (strcmp(existing_group->name, peergroup) == 0) | |
2489 | return CMD_SUCCESS; | |
2490 | else { | |
2491 | vty_out(vty, | |
2492 | "%% Same listen range is attached to peer-group %s\n", | |
2493 | existing_group->name); | |
2494 | return CMD_WARNING_CONFIG_FAILED; | |
2495 | } | |
2496 | } | |
2497 | ||
2498 | /* Check if an overlapping listen range exists. */ | |
2499 | if (listen_range_exists(bgp, &range, 0)) { | |
2500 | vty_out(vty, | |
2501 | "%% Listen range overlaps with existing listen range\n"); | |
2502 | return CMD_WARNING_CONFIG_FAILED; | |
2503 | } | |
2504 | ||
2505 | group = peer_group_lookup(bgp, peergroup); | |
2506 | if (!group) { | |
2507 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2508 | return CMD_WARNING_CONFIG_FAILED; | |
2509 | } | |
2510 | ||
2511 | ret = peer_group_listen_range_add(group, &range); | |
2512 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
2513 | } |
2514 | ||
2515 | DEFUN (no_bgp_listen_range, | |
2516 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2517 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2518 | NO_STR | |
f14e6fdb | 2519 | "BGP specific commands\n" |
d7fa34c1 QY |
2520 | "Unconfigure BGP dynamic neighbors listen range\n" |
2521 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2522 | NEIGHBOR_ADDR_STR | |
2523 | "Member of the peer-group\n" | |
2524 | "Peer-group name\n") | |
f14e6fdb | 2525 | { |
d62a17ae | 2526 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2527 | struct prefix range; | |
2528 | struct peer_group *group; | |
2529 | afi_t afi; | |
2530 | int ret; | |
2531 | int idx = 0; | |
2532 | ||
2533 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2534 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2535 | char *prefix = argv[idx]->arg; | |
2536 | argv_find(argv, argc, "WORD", &idx); | |
2537 | char *peergroup = argv[idx]->arg; | |
2538 | ||
2539 | /* Convert IP prefix string to struct prefix. */ | |
2540 | ret = str2prefix(prefix, &range); | |
2541 | if (!ret) { | |
2542 | vty_out(vty, "%% Malformed listen range\n"); | |
2543 | return CMD_WARNING_CONFIG_FAILED; | |
2544 | } | |
2545 | ||
2546 | afi = family2afi(range.family); | |
2547 | ||
2548 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2549 | vty_out(vty, | |
2550 | "%% Malformed listen range (link-local address)\n"); | |
2551 | return CMD_WARNING_CONFIG_FAILED; | |
2552 | } | |
2553 | ||
2554 | apply_mask(&range); | |
2555 | ||
2556 | group = peer_group_lookup(bgp, peergroup); | |
2557 | if (!group) { | |
2558 | vty_out(vty, "%% Peer-group does not exist\n"); | |
2559 | return CMD_WARNING_CONFIG_FAILED; | |
2560 | } | |
2561 | ||
2562 | ret = peer_group_listen_range_del(group, &range); | |
2563 | return bgp_vty_return(vty, ret); | |
2564 | } | |
2565 | ||
2b791107 | 2566 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 2567 | { |
2568 | struct peer_group *group; | |
2569 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2570 | struct prefix *range; | |
2571 | afi_t afi; | |
2572 | char buf[PREFIX2STR_BUFFER]; | |
2573 | ||
2574 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2575 | vty_out(vty, " bgp listen limit %d\n", | |
2576 | bgp->dynamic_neighbors_limit); | |
2577 | ||
2578 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2579 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
2580 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
2581 | nrnode, range)) { | |
2582 | prefix2str(range, buf, sizeof(buf)); | |
2583 | vty_out(vty, | |
2584 | " bgp listen range %s peer-group %s\n", | |
2585 | buf, group->name); | |
2586 | } | |
2587 | } | |
2588 | } | |
f14e6fdb DS |
2589 | } |
2590 | ||
2591 | ||
907f92c8 DS |
2592 | DEFUN (bgp_disable_connected_route_check, |
2593 | bgp_disable_connected_route_check_cmd, | |
2594 | "bgp disable-ebgp-connected-route-check", | |
2595 | "BGP specific commands\n" | |
2596 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2597 | { | |
d62a17ae | 2598 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2599 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2600 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2601 | |
d62a17ae | 2602 | return CMD_SUCCESS; |
907f92c8 DS |
2603 | } |
2604 | ||
2605 | DEFUN (no_bgp_disable_connected_route_check, | |
2606 | no_bgp_disable_connected_route_check_cmd, | |
2607 | "no bgp disable-ebgp-connected-route-check", | |
2608 | NO_STR | |
2609 | "BGP specific commands\n" | |
2610 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2611 | { | |
d62a17ae | 2612 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2613 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2614 | bgp_clear_star_soft_in(vty, bgp->name); | |
2615 | ||
2616 | return CMD_SUCCESS; | |
2617 | } | |
2618 | ||
2619 | ||
2620 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
2621 | const char *as_str, afi_t afi, safi_t safi) | |
2622 | { | |
2623 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2624 | int ret; | |
2625 | as_t as; | |
2626 | int as_type = AS_SPECIFIED; | |
2627 | union sockunion su; | |
2628 | ||
2629 | if (as_str[0] == 'i') { | |
2630 | as = 0; | |
2631 | as_type = AS_INTERNAL; | |
2632 | } else if (as_str[0] == 'e') { | |
2633 | as = 0; | |
2634 | as_type = AS_EXTERNAL; | |
2635 | } else { | |
2636 | /* Get AS number. */ | |
2637 | as = strtoul(as_str, NULL, 10); | |
2638 | } | |
2639 | ||
2640 | /* If peer is peer group, call proper function. */ | |
2641 | ret = str2sockunion(peer_str, &su); | |
2642 | if (ret < 0) { | |
2643 | /* Check for peer by interface */ | |
2644 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, | |
2645 | safi); | |
2646 | if (ret < 0) { | |
2647 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); | |
2648 | if (ret < 0) { | |
2649 | vty_out(vty, | |
2650 | "%% Create the peer-group or interface first\n"); | |
2651 | return CMD_WARNING_CONFIG_FAILED; | |
2652 | } | |
2653 | return CMD_SUCCESS; | |
2654 | } | |
2655 | } else { | |
2656 | if (peer_address_self_check(bgp, &su)) { | |
2657 | vty_out(vty, | |
2658 | "%% Can not configure the local system as neighbor\n"); | |
2659 | return CMD_WARNING_CONFIG_FAILED; | |
2660 | } | |
2661 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
2662 | } | |
2663 | ||
2664 | /* This peer belongs to peer group. */ | |
2665 | switch (ret) { | |
2666 | case BGP_ERR_PEER_GROUP_MEMBER: | |
2667 | vty_out(vty, | |
2668 | "%% Peer-group AS %u. Cannot configure remote-as for member\n", | |
2669 | as); | |
2670 | return CMD_WARNING_CONFIG_FAILED; | |
2671 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
2672 | vty_out(vty, | |
2673 | "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n", | |
2674 | as, as_str); | |
2675 | return CMD_WARNING_CONFIG_FAILED; | |
2676 | } | |
2677 | return bgp_vty_return(vty, ret); | |
718e3744 | 2678 | } |
2679 | ||
2680 | DEFUN (neighbor_remote_as, | |
2681 | neighbor_remote_as_cmd, | |
3a2d747c | 2682 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2683 | NEIGHBOR_STR |
2684 | NEIGHBOR_ADDR_STR2 | |
2685 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2686 | AS_STR |
3a2d747c QY |
2687 | "Internal BGP peer\n" |
2688 | "External BGP peer\n") | |
718e3744 | 2689 | { |
d62a17ae | 2690 | int idx_peer = 1; |
2691 | int idx_remote_as = 3; | |
2692 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
2693 | argv[idx_remote_as]->arg, AFI_IP, | |
2694 | SAFI_UNICAST); | |
2695 | } | |
2696 | ||
2697 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
2698 | afi_t afi, safi_t safi, int v6only, | |
2699 | const char *peer_group_name, | |
2700 | const char *as_str) | |
2701 | { | |
2702 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2703 | as_t as = 0; | |
2704 | int as_type = AS_UNSPECIFIED; | |
2705 | struct peer *peer; | |
2706 | struct peer_group *group; | |
2707 | int ret = 0; | |
2708 | union sockunion su; | |
2709 | ||
2710 | group = peer_group_lookup(bgp, conf_if); | |
2711 | ||
2712 | if (group) { | |
2713 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
2714 | return CMD_WARNING_CONFIG_FAILED; | |
2715 | } | |
2716 | ||
2717 | if (as_str) { | |
2718 | if (as_str[0] == 'i') { | |
2719 | as_type = AS_INTERNAL; | |
2720 | } else if (as_str[0] == 'e') { | |
2721 | as_type = AS_EXTERNAL; | |
2722 | } else { | |
2723 | /* Get AS number. */ | |
2724 | as = strtoul(as_str, NULL, 10); | |
2725 | as_type = AS_SPECIFIED; | |
2726 | } | |
2727 | } | |
2728 | ||
2729 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
2730 | if (peer) { | |
2731 | if (as_str) | |
2732 | ret = peer_remote_as(bgp, &su, conf_if, &as, as_type, | |
2733 | afi, safi); | |
2734 | } else { | |
2735 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2736 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
2737 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2738 | as_type, 0, 0, NULL); | |
2739 | else | |
2740 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2741 | as_type, afi, safi, NULL); | |
2742 | ||
2743 | if (!peer) { | |
2744 | vty_out(vty, "%% BGP failed to create peer\n"); | |
2745 | return CMD_WARNING_CONFIG_FAILED; | |
2746 | } | |
2747 | ||
2748 | if (v6only) | |
2749 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2750 | ||
2751 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
2752 | * this | |
2753 | * any unnumbered peer in order to not worry about run-time | |
2754 | * transitions | |
2755 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
2756 | * address | |
2757 | * gets deleted later etc.) | |
2758 | */ | |
2759 | if (peer->ifp) | |
2760 | bgp_zebra_initiate_radv(bgp, peer); | |
2761 | } | |
2762 | ||
2763 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
2764 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
2765 | if (v6only) | |
2766 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2767 | else | |
2768 | UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2769 | ||
2770 | /* v6only flag changed. Reset bgp seesion */ | |
2771 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2772 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2773 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2774 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2775 | } else | |
2776 | bgp_session_reset(peer); | |
2777 | } | |
2778 | ||
2779 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) | |
2780 | peer_flag_set(peer, PEER_FLAG_CAPABILITY_ENHE); | |
2781 | ||
2782 | if (peer_group_name) { | |
2783 | group = peer_group_lookup(bgp, peer_group_name); | |
2784 | if (!group) { | |
2785 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2786 | return CMD_WARNING_CONFIG_FAILED; | |
2787 | } | |
2788 | ||
2789 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
2790 | } | |
2791 | ||
2792 | return bgp_vty_return(vty, ret); | |
a80beece DS |
2793 | } |
2794 | ||
4c48cf63 DW |
2795 | DEFUN (neighbor_interface_config, |
2796 | neighbor_interface_config_cmd, | |
31500417 | 2797 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2798 | NEIGHBOR_STR |
2799 | "Interface name or neighbor tag\n" | |
31500417 DW |
2800 | "Enable BGP on interface\n" |
2801 | "Member of the peer-group\n" | |
16cedbb0 | 2802 | "Peer-group name\n") |
4c48cf63 | 2803 | { |
d62a17ae | 2804 | int idx_word = 1; |
2805 | int idx_peer_group_word = 4; | |
31500417 | 2806 | |
d62a17ae | 2807 | if (argc > idx_peer_group_word) |
2808 | return peer_conf_interface_get( | |
2809 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2810 | argv[idx_peer_group_word]->arg, NULL); | |
2811 | else | |
2812 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2813 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
2814 | } |
2815 | ||
4c48cf63 DW |
2816 | DEFUN (neighbor_interface_config_v6only, |
2817 | neighbor_interface_config_v6only_cmd, | |
31500417 | 2818 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
2819 | NEIGHBOR_STR |
2820 | "Interface name or neighbor tag\n" | |
2821 | "Enable BGP on interface\n" | |
31500417 DW |
2822 | "Enable BGP with v6 link-local only\n" |
2823 | "Member of the peer-group\n" | |
16cedbb0 | 2824 | "Peer-group name\n") |
4c48cf63 | 2825 | { |
d62a17ae | 2826 | int idx_word = 1; |
2827 | int idx_peer_group_word = 5; | |
31500417 | 2828 | |
d62a17ae | 2829 | if (argc > idx_peer_group_word) |
2830 | return peer_conf_interface_get( | |
2831 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2832 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 2833 | |
d62a17ae | 2834 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
2835 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
2836 | } |
2837 | ||
a80beece | 2838 | |
b3a39dc5 DD |
2839 | DEFUN (neighbor_interface_config_remote_as, |
2840 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2841 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2842 | NEIGHBOR_STR |
2843 | "Interface name or neighbor tag\n" | |
2844 | "Enable BGP on interface\n" | |
3a2d747c | 2845 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2846 | AS_STR |
3a2d747c QY |
2847 | "Internal BGP peer\n" |
2848 | "External BGP peer\n") | |
b3a39dc5 | 2849 | { |
d62a17ae | 2850 | int idx_word = 1; |
2851 | int idx_remote_as = 4; | |
2852 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2853 | SAFI_UNICAST, 0, NULL, | |
2854 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2855 | } |
2856 | ||
2857 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
2858 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 2859 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2860 | NEIGHBOR_STR |
2861 | "Interface name or neighbor tag\n" | |
3a2d747c | 2862 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 2863 | "Enable BGP on interface\n" |
3a2d747c | 2864 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2865 | AS_STR |
3a2d747c QY |
2866 | "Internal BGP peer\n" |
2867 | "External BGP peer\n") | |
b3a39dc5 | 2868 | { |
d62a17ae | 2869 | int idx_word = 1; |
2870 | int idx_remote_as = 5; | |
2871 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2872 | SAFI_UNICAST, 1, NULL, | |
2873 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2874 | } |
2875 | ||
718e3744 | 2876 | DEFUN (neighbor_peer_group, |
2877 | neighbor_peer_group_cmd, | |
2878 | "neighbor WORD peer-group", | |
2879 | NEIGHBOR_STR | |
a80beece | 2880 | "Interface name or neighbor tag\n" |
718e3744 | 2881 | "Configure peer-group\n") |
2882 | { | |
d62a17ae | 2883 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2884 | int idx_word = 1; | |
2885 | struct peer *peer; | |
2886 | struct peer_group *group; | |
718e3744 | 2887 | |
d62a17ae | 2888 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
2889 | if (peer) { | |
2890 | vty_out(vty, "%% Name conflict with interface: \n"); | |
2891 | return CMD_WARNING_CONFIG_FAILED; | |
2892 | } | |
718e3744 | 2893 | |
d62a17ae | 2894 | group = peer_group_get(bgp, argv[idx_word]->arg); |
2895 | if (!group) { | |
2896 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
2897 | return CMD_WARNING_CONFIG_FAILED; | |
2898 | } | |
718e3744 | 2899 | |
d62a17ae | 2900 | return CMD_SUCCESS; |
718e3744 | 2901 | } |
2902 | ||
2903 | DEFUN (no_neighbor, | |
2904 | no_neighbor_cmd, | |
dab8cd00 | 2905 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 2906 | NO_STR |
2907 | NEIGHBOR_STR | |
3a2d747c QY |
2908 | NEIGHBOR_ADDR_STR2 |
2909 | "Specify a BGP neighbor\n" | |
2910 | AS_STR | |
2911 | "Internal BGP peer\n" | |
2912 | "External BGP peer\n") | |
718e3744 | 2913 | { |
d62a17ae | 2914 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2915 | int idx_peer = 2; | |
2916 | int ret; | |
2917 | union sockunion su; | |
2918 | struct peer_group *group; | |
2919 | struct peer *peer; | |
2920 | struct peer *other; | |
2921 | ||
2922 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
2923 | if (ret < 0) { | |
2924 | /* look up for neighbor by interface name config. */ | |
2925 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
2926 | if (peer) { | |
2927 | /* Request zebra to terminate IPv6 RAs on this | |
2928 | * interface. */ | |
2929 | if (peer->ifp) | |
2930 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
2931 | peer_delete(peer); | |
2932 | return CMD_SUCCESS; | |
2933 | } | |
f14e6fdb | 2934 | |
d62a17ae | 2935 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
2936 | if (group) | |
2937 | peer_group_delete(group); | |
2938 | else { | |
2939 | vty_out(vty, "%% Create the peer-group first\n"); | |
2940 | return CMD_WARNING_CONFIG_FAILED; | |
2941 | } | |
2942 | } else { | |
2943 | peer = peer_lookup(bgp, &su); | |
2944 | if (peer) { | |
2945 | if (peer_dynamic_neighbor(peer)) { | |
2946 | vty_out(vty, | |
2947 | "%% Operation not allowed on a dynamic neighbor\n"); | |
2948 | return CMD_WARNING_CONFIG_FAILED; | |
2949 | } | |
2950 | ||
2951 | other = peer->doppelganger; | |
2952 | peer_delete(peer); | |
2953 | if (other && other->status != Deleted) | |
2954 | peer_delete(other); | |
2955 | } | |
1ff9a340 | 2956 | } |
718e3744 | 2957 | |
d62a17ae | 2958 | return CMD_SUCCESS; |
718e3744 | 2959 | } |
2960 | ||
a80beece DS |
2961 | DEFUN (no_neighbor_interface_config, |
2962 | no_neighbor_interface_config_cmd, | |
31500417 | 2963 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
2964 | NO_STR |
2965 | NEIGHBOR_STR | |
2966 | "Interface name\n" | |
31500417 DW |
2967 | "Configure BGP on interface\n" |
2968 | "Enable BGP with v6 link-local only\n" | |
2969 | "Member of the peer-group\n" | |
16cedbb0 | 2970 | "Peer-group name\n" |
3a2d747c QY |
2971 | "Specify a BGP neighbor\n" |
2972 | AS_STR | |
2973 | "Internal BGP peer\n" | |
2974 | "External BGP peer\n") | |
a80beece | 2975 | { |
d62a17ae | 2976 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2977 | int idx_word = 2; | |
2978 | struct peer *peer; | |
2979 | ||
2980 | /* look up for neighbor by interface name config. */ | |
2981 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
2982 | if (peer) { | |
2983 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
2984 | if (peer->ifp) | |
2985 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
2986 | peer_delete(peer); | |
2987 | } else { | |
2988 | vty_out(vty, "%% Create the bgp interface first\n"); | |
2989 | return CMD_WARNING_CONFIG_FAILED; | |
2990 | } | |
2991 | return CMD_SUCCESS; | |
a80beece DS |
2992 | } |
2993 | ||
718e3744 | 2994 | DEFUN (no_neighbor_peer_group, |
2995 | no_neighbor_peer_group_cmd, | |
2996 | "no neighbor WORD peer-group", | |
2997 | NO_STR | |
2998 | NEIGHBOR_STR | |
2999 | "Neighbor tag\n" | |
3000 | "Configure peer-group\n") | |
3001 | { | |
d62a17ae | 3002 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3003 | int idx_word = 2; | |
3004 | struct peer_group *group; | |
718e3744 | 3005 | |
d62a17ae | 3006 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
3007 | if (group) | |
3008 | peer_group_delete(group); | |
3009 | else { | |
3010 | vty_out(vty, "%% Create the peer-group first\n"); | |
3011 | return CMD_WARNING_CONFIG_FAILED; | |
3012 | } | |
3013 | return CMD_SUCCESS; | |
718e3744 | 3014 | } |
3015 | ||
a80beece DS |
3016 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3017 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3018 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3019 | NO_STR |
3020 | NEIGHBOR_STR | |
a80beece | 3021 | "Interface name or neighbor tag\n" |
718e3744 | 3022 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3023 | AS_STR |
3024 | "Internal BGP peer\n" | |
3025 | "External BGP peer\n") | |
718e3744 | 3026 | { |
d62a17ae | 3027 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3028 | int idx_word = 2; | |
3029 | struct peer_group *group; | |
3030 | struct peer *peer; | |
3031 | ||
3032 | /* look up for neighbor by interface name config. */ | |
3033 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3034 | if (peer) { | |
3035 | peer_as_change(peer, 0, AS_SPECIFIED); | |
3036 | return CMD_SUCCESS; | |
3037 | } | |
3038 | ||
3039 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3040 | if (group) | |
3041 | peer_group_remote_as_delete(group); | |
3042 | else { | |
3043 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3044 | return CMD_WARNING_CONFIG_FAILED; | |
3045 | } | |
3046 | return CMD_SUCCESS; | |
718e3744 | 3047 | } |
6b0655a2 | 3048 | |
718e3744 | 3049 | DEFUN (neighbor_local_as, |
3050 | neighbor_local_as_cmd, | |
9ccf14f7 | 3051 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3052 | NEIGHBOR_STR |
3053 | NEIGHBOR_ADDR_STR2 | |
3054 | "Specify a local-as number\n" | |
3055 | "AS number used as local AS\n") | |
3056 | { | |
d62a17ae | 3057 | int idx_peer = 1; |
3058 | int idx_number = 3; | |
3059 | struct peer *peer; | |
3060 | int ret; | |
3061 | as_t as; | |
718e3744 | 3062 | |
d62a17ae | 3063 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3064 | if (!peer) | |
3065 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3066 | |
d62a17ae | 3067 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3068 | ret = peer_local_as_set(peer, as, 0, 0); | |
3069 | return bgp_vty_return(vty, ret); | |
718e3744 | 3070 | } |
3071 | ||
3072 | DEFUN (neighbor_local_as_no_prepend, | |
3073 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3074 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3075 | NEIGHBOR_STR |
3076 | NEIGHBOR_ADDR_STR2 | |
3077 | "Specify a local-as number\n" | |
3078 | "AS number used as local AS\n" | |
3079 | "Do not prepend local-as to updates from ebgp peers\n") | |
3080 | { | |
d62a17ae | 3081 | int idx_peer = 1; |
3082 | int idx_number = 3; | |
3083 | struct peer *peer; | |
3084 | int ret; | |
3085 | as_t as; | |
718e3744 | 3086 | |
d62a17ae | 3087 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3088 | if (!peer) | |
3089 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3090 | |
d62a17ae | 3091 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3092 | ret = peer_local_as_set(peer, as, 1, 0); | |
3093 | return bgp_vty_return(vty, ret); | |
718e3744 | 3094 | } |
3095 | ||
9d3f9705 AC |
3096 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3097 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3098 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3099 | NEIGHBOR_STR |
3100 | NEIGHBOR_ADDR_STR2 | |
3101 | "Specify a local-as number\n" | |
3102 | "AS number used as local AS\n" | |
3103 | "Do not prepend local-as to updates from ebgp peers\n" | |
3104 | "Do not prepend local-as to updates from ibgp peers\n") | |
3105 | { | |
d62a17ae | 3106 | int idx_peer = 1; |
3107 | int idx_number = 3; | |
3108 | struct peer *peer; | |
3109 | int ret; | |
3110 | as_t as; | |
9d3f9705 | 3111 | |
d62a17ae | 3112 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3113 | if (!peer) | |
3114 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3115 | |
d62a17ae | 3116 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3117 | ret = peer_local_as_set(peer, as, 1, 1); | |
3118 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3119 | } |
3120 | ||
718e3744 | 3121 | DEFUN (no_neighbor_local_as, |
3122 | no_neighbor_local_as_cmd, | |
a636c635 | 3123 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3124 | NO_STR |
3125 | NEIGHBOR_STR | |
3126 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3127 | "Specify a local-as number\n" |
3128 | "AS number used as local AS\n" | |
3129 | "Do not prepend local-as to updates from ebgp peers\n" | |
3130 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3131 | { |
d62a17ae | 3132 | int idx_peer = 2; |
3133 | struct peer *peer; | |
3134 | int ret; | |
718e3744 | 3135 | |
d62a17ae | 3136 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3137 | if (!peer) | |
3138 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3139 | |
d62a17ae | 3140 | ret = peer_local_as_unset(peer); |
3141 | return bgp_vty_return(vty, ret); | |
718e3744 | 3142 | } |
3143 | ||
718e3744 | 3144 | |
3f9c7369 DS |
3145 | DEFUN (neighbor_solo, |
3146 | neighbor_solo_cmd, | |
9ccf14f7 | 3147 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3148 | NEIGHBOR_STR |
3149 | NEIGHBOR_ADDR_STR2 | |
3150 | "Solo peer - part of its own update group\n") | |
3151 | { | |
d62a17ae | 3152 | int idx_peer = 1; |
3153 | struct peer *peer; | |
3154 | int ret; | |
3f9c7369 | 3155 | |
d62a17ae | 3156 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3157 | if (!peer) | |
3158 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3159 | |
d62a17ae | 3160 | ret = update_group_adjust_soloness(peer, 1); |
3161 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3162 | } |
3163 | ||
3164 | DEFUN (no_neighbor_solo, | |
3165 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3166 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3167 | NO_STR |
3168 | NEIGHBOR_STR | |
3169 | NEIGHBOR_ADDR_STR2 | |
3170 | "Solo peer - part of its own update group\n") | |
3171 | { | |
d62a17ae | 3172 | int idx_peer = 2; |
3173 | struct peer *peer; | |
3174 | int ret; | |
3f9c7369 | 3175 | |
d62a17ae | 3176 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3177 | if (!peer) | |
3178 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3179 | |
d62a17ae | 3180 | ret = update_group_adjust_soloness(peer, 0); |
3181 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3182 | } |
3183 | ||
0df7c91f PJ |
3184 | DEFUN (neighbor_password, |
3185 | neighbor_password_cmd, | |
9ccf14f7 | 3186 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3187 | NEIGHBOR_STR |
3188 | NEIGHBOR_ADDR_STR2 | |
3189 | "Set a password\n" | |
3190 | "The password\n") | |
3191 | { | |
d62a17ae | 3192 | int idx_peer = 1; |
3193 | int idx_line = 3; | |
3194 | struct peer *peer; | |
3195 | int ret; | |
0df7c91f | 3196 | |
d62a17ae | 3197 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3198 | if (!peer) | |
3199 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3200 | |
d62a17ae | 3201 | ret = peer_password_set(peer, argv[idx_line]->arg); |
3202 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
3203 | } |
3204 | ||
3205 | DEFUN (no_neighbor_password, | |
3206 | no_neighbor_password_cmd, | |
a636c635 | 3207 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3208 | NO_STR |
3209 | NEIGHBOR_STR | |
3210 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3211 | "Set a password\n" |
3212 | "The password\n") | |
0df7c91f | 3213 | { |
d62a17ae | 3214 | int idx_peer = 2; |
3215 | struct peer *peer; | |
3216 | int ret; | |
0df7c91f | 3217 | |
d62a17ae | 3218 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3219 | if (!peer) | |
3220 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3221 | |
d62a17ae | 3222 | ret = peer_password_unset(peer); |
3223 | return bgp_vty_return(vty, ret); | |
0df7c91f | 3224 | } |
6b0655a2 | 3225 | |
813d4307 | 3226 | |
718e3744 | 3227 | DEFUN (neighbor_activate, |
3228 | neighbor_activate_cmd, | |
9ccf14f7 | 3229 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3230 | NEIGHBOR_STR |
3231 | NEIGHBOR_ADDR_STR2 | |
3232 | "Enable the Address Family for this Neighbor\n") | |
3233 | { | |
d62a17ae | 3234 | int idx_peer = 1; |
3235 | int ret; | |
3236 | struct peer *peer; | |
718e3744 | 3237 | |
d62a17ae | 3238 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3239 | if (!peer) | |
3240 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3241 | |
d62a17ae | 3242 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3243 | return bgp_vty_return(vty, ret); | |
718e3744 | 3244 | } |
3245 | ||
d62a17ae | 3246 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
3247 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3248 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3249 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3250 | |
718e3744 | 3251 | DEFUN (no_neighbor_activate, |
3252 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3253 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3254 | NO_STR |
3255 | NEIGHBOR_STR | |
3256 | NEIGHBOR_ADDR_STR2 | |
3257 | "Enable the Address Family for this Neighbor\n") | |
3258 | { | |
d62a17ae | 3259 | int idx_peer = 2; |
3260 | int ret; | |
3261 | struct peer *peer; | |
718e3744 | 3262 | |
d62a17ae | 3263 | /* Lookup peer. */ |
3264 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3265 | if (!peer) | |
3266 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3267 | |
d62a17ae | 3268 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3269 | return bgp_vty_return(vty, ret); | |
718e3744 | 3270 | } |
6b0655a2 | 3271 | |
d62a17ae | 3272 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
3273 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3274 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3275 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3276 | |
718e3744 | 3277 | DEFUN (neighbor_set_peer_group, |
3278 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3279 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3280 | NEIGHBOR_STR |
a80beece | 3281 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3282 | "Member of the peer-group\n" |
16cedbb0 | 3283 | "Peer-group name\n") |
718e3744 | 3284 | { |
d62a17ae | 3285 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3286 | int idx_peer = 1; | |
3287 | int idx_word = 3; | |
3288 | int ret; | |
3289 | as_t as; | |
3290 | union sockunion su; | |
3291 | struct peer *peer; | |
3292 | struct peer_group *group; | |
3293 | ||
3294 | peer = NULL; | |
3295 | ||
3296 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3297 | if (ret < 0) { | |
3298 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3299 | if (!peer) { | |
3300 | vty_out(vty, "%% Malformed address or name: %s\n", | |
3301 | argv[idx_peer]->arg); | |
3302 | return CMD_WARNING_CONFIG_FAILED; | |
3303 | } | |
3304 | } else { | |
3305 | if (peer_address_self_check(bgp, &su)) { | |
3306 | vty_out(vty, | |
3307 | "%% Can not configure the local system as neighbor\n"); | |
3308 | return CMD_WARNING_CONFIG_FAILED; | |
3309 | } | |
3310 | ||
3311 | /* Disallow for dynamic neighbor. */ | |
3312 | peer = peer_lookup(bgp, &su); | |
3313 | if (peer && peer_dynamic_neighbor(peer)) { | |
3314 | vty_out(vty, | |
3315 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3316 | return CMD_WARNING_CONFIG_FAILED; | |
3317 | } | |
3318 | } | |
3319 | ||
3320 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3321 | if (!group) { | |
3322 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3323 | return CMD_WARNING_CONFIG_FAILED; | |
3324 | } | |
3325 | ||
3326 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3327 | ||
3328 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
3329 | vty_out(vty, | |
3330 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
3331 | as); | |
3332 | return CMD_WARNING_CONFIG_FAILED; | |
3333 | } | |
3334 | ||
3335 | return bgp_vty_return(vty, ret); | |
3336 | } | |
3337 | ||
3338 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
3339 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3340 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3341 | "Member of the peer-group\n" | |
3342 | "Peer-group name\n") | |
596c17ba | 3343 | |
718e3744 | 3344 | DEFUN (no_neighbor_set_peer_group, |
3345 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3346 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3347 | NO_STR |
3348 | NEIGHBOR_STR | |
a80beece | 3349 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3350 | "Member of the peer-group\n" |
16cedbb0 | 3351 | "Peer-group name\n") |
718e3744 | 3352 | { |
d62a17ae | 3353 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3354 | int idx_peer = 2; | |
3355 | int idx_word = 4; | |
3356 | int ret; | |
3357 | struct peer *peer; | |
3358 | struct peer_group *group; | |
3359 | ||
3360 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
3361 | if (!peer) | |
3362 | return CMD_WARNING_CONFIG_FAILED; | |
3363 | ||
3364 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3365 | if (!group) { | |
3366 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3367 | return CMD_WARNING_CONFIG_FAILED; | |
3368 | } | |
718e3744 | 3369 | |
d62a17ae | 3370 | ret = peer_group_unbind(bgp, peer, group); |
718e3744 | 3371 | |
d62a17ae | 3372 | return bgp_vty_return(vty, ret); |
718e3744 | 3373 | } |
6b0655a2 | 3374 | |
d62a17ae | 3375 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
3376 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3377 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3378 | "Member of the peer-group\n" | |
3379 | "Peer-group name\n") | |
596c17ba | 3380 | |
d62a17ae | 3381 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
3382 | u_int16_t flag, int set) | |
718e3744 | 3383 | { |
d62a17ae | 3384 | int ret; |
3385 | struct peer *peer; | |
718e3744 | 3386 | |
d62a17ae | 3387 | peer = peer_and_group_lookup_vty(vty, ip_str); |
3388 | if (!peer) | |
3389 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3390 | |
d62a17ae | 3391 | /* |
3392 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3393 | * we should not accept disable-connected-check. | |
3394 | */ | |
3395 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3396 | vty_out(vty, | |
3397 | "%s is directly connected peer, cannot accept disable-" | |
3398 | "connected-check\n", | |
3399 | ip_str); | |
3400 | return CMD_WARNING_CONFIG_FAILED; | |
3401 | } | |
8cdabf90 | 3402 | |
d62a17ae | 3403 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3404 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 3405 | |
d62a17ae | 3406 | if (set) |
3407 | ret = peer_flag_set(peer, flag); | |
3408 | else | |
3409 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 3410 | |
d62a17ae | 3411 | return bgp_vty_return(vty, ret); |
718e3744 | 3412 | } |
3413 | ||
d62a17ae | 3414 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, |
3415 | u_int16_t flag) | |
718e3744 | 3416 | { |
d62a17ae | 3417 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 3418 | } |
3419 | ||
d62a17ae | 3420 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
3421 | u_int16_t flag) | |
718e3744 | 3422 | { |
d62a17ae | 3423 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 3424 | } |
3425 | ||
3426 | /* neighbor passive. */ | |
3427 | DEFUN (neighbor_passive, | |
3428 | neighbor_passive_cmd, | |
9ccf14f7 | 3429 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3430 | NEIGHBOR_STR |
3431 | NEIGHBOR_ADDR_STR2 | |
3432 | "Don't send open messages to this neighbor\n") | |
3433 | { | |
d62a17ae | 3434 | int idx_peer = 1; |
3435 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3436 | } |
3437 | ||
3438 | DEFUN (no_neighbor_passive, | |
3439 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3440 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3441 | NO_STR |
3442 | NEIGHBOR_STR | |
3443 | NEIGHBOR_ADDR_STR2 | |
3444 | "Don't send open messages to this neighbor\n") | |
3445 | { | |
d62a17ae | 3446 | int idx_peer = 2; |
3447 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3448 | } |
6b0655a2 | 3449 | |
718e3744 | 3450 | /* neighbor shutdown. */ |
73d70fa6 DL |
3451 | DEFUN (neighbor_shutdown_msg, |
3452 | neighbor_shutdown_msg_cmd, | |
3453 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3454 | NEIGHBOR_STR |
3455 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3456 | "Administratively shut down this neighbor\n" |
3457 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3458 | "Shutdown message\n") | |
718e3744 | 3459 | { |
d62a17ae | 3460 | int idx_peer = 1; |
73d70fa6 | 3461 | |
d62a17ae | 3462 | if (argc >= 5) { |
3463 | struct peer *peer = | |
3464 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3465 | char *message; | |
73d70fa6 | 3466 | |
d62a17ae | 3467 | if (!peer) |
3468 | return CMD_WARNING_CONFIG_FAILED; | |
3469 | message = argv_concat(argv, argc, 4); | |
3470 | peer_tx_shutdown_message_set(peer, message); | |
3471 | XFREE(MTYPE_TMP, message); | |
3472 | } | |
73d70fa6 | 3473 | |
d62a17ae | 3474 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3475 | } |
3476 | ||
d62a17ae | 3477 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
3478 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3479 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3480 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3481 | |
3482 | DEFUN (no_neighbor_shutdown_msg, | |
3483 | no_neighbor_shutdown_msg_cmd, | |
3484 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3485 | NO_STR | |
3486 | NEIGHBOR_STR | |
3487 | NEIGHBOR_ADDR_STR2 | |
3488 | "Administratively shut down this neighbor\n" | |
3489 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3490 | "Shutdown message\n") | |
718e3744 | 3491 | { |
d62a17ae | 3492 | int idx_peer = 2; |
73d70fa6 | 3493 | |
d62a17ae | 3494 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
3495 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 3496 | } |
6b0655a2 | 3497 | |
d62a17ae | 3498 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
3499 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3500 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3501 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 3502 | |
718e3744 | 3503 | /* neighbor capability dynamic. */ |
3504 | DEFUN (neighbor_capability_dynamic, | |
3505 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3506 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3507 | NEIGHBOR_STR |
3508 | NEIGHBOR_ADDR_STR2 | |
3509 | "Advertise capability to the peer\n" | |
3510 | "Advertise dynamic capability to this neighbor\n") | |
3511 | { | |
d62a17ae | 3512 | int idx_peer = 1; |
3513 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3514 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3515 | } |
3516 | ||
3517 | DEFUN (no_neighbor_capability_dynamic, | |
3518 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3519 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3520 | NO_STR |
3521 | NEIGHBOR_STR | |
3522 | NEIGHBOR_ADDR_STR2 | |
3523 | "Advertise capability to the peer\n" | |
3524 | "Advertise dynamic capability to this neighbor\n") | |
3525 | { | |
d62a17ae | 3526 | int idx_peer = 2; |
3527 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3528 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3529 | } |
6b0655a2 | 3530 | |
718e3744 | 3531 | /* neighbor dont-capability-negotiate */ |
3532 | DEFUN (neighbor_dont_capability_negotiate, | |
3533 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3534 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3535 | NEIGHBOR_STR |
3536 | NEIGHBOR_ADDR_STR2 | |
3537 | "Do not perform capability negotiation\n") | |
3538 | { | |
d62a17ae | 3539 | int idx_peer = 1; |
3540 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3541 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3542 | } |
3543 | ||
3544 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3545 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3546 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3547 | NO_STR |
3548 | NEIGHBOR_STR | |
3549 | NEIGHBOR_ADDR_STR2 | |
3550 | "Do not perform capability negotiation\n") | |
3551 | { | |
d62a17ae | 3552 | int idx_peer = 2; |
3553 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3554 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3555 | } |
6b0655a2 | 3556 | |
8a92a8a0 DS |
3557 | /* neighbor capability extended next hop encoding */ |
3558 | DEFUN (neighbor_capability_enhe, | |
3559 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3560 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3561 | NEIGHBOR_STR |
3562 | NEIGHBOR_ADDR_STR2 | |
3563 | "Advertise capability to the peer\n" | |
3564 | "Advertise extended next-hop capability to the peer\n") | |
3565 | { | |
d62a17ae | 3566 | int idx_peer = 1; |
3567 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3568 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3569 | } |
3570 | ||
3571 | DEFUN (no_neighbor_capability_enhe, | |
3572 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3573 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3574 | NO_STR |
3575 | NEIGHBOR_STR | |
3576 | NEIGHBOR_ADDR_STR2 | |
3577 | "Advertise capability to the peer\n" | |
3578 | "Advertise extended next-hop capability to the peer\n") | |
3579 | { | |
d62a17ae | 3580 | int idx_peer = 2; |
3581 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3582 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3583 | } |
3584 | ||
d62a17ae | 3585 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
3586 | afi_t afi, safi_t safi, u_int32_t flag, | |
3587 | int set) | |
718e3744 | 3588 | { |
d62a17ae | 3589 | int ret; |
3590 | struct peer *peer; | |
718e3744 | 3591 | |
d62a17ae | 3592 | peer = peer_and_group_lookup_vty(vty, peer_str); |
3593 | if (!peer) | |
3594 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3595 | |
d62a17ae | 3596 | if (set) |
3597 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
3598 | else | |
3599 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 3600 | |
d62a17ae | 3601 | return bgp_vty_return(vty, ret); |
718e3744 | 3602 | } |
3603 | ||
d62a17ae | 3604 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
3605 | afi_t afi, safi_t safi, u_int32_t flag) | |
718e3744 | 3606 | { |
d62a17ae | 3607 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 3608 | } |
3609 | ||
d62a17ae | 3610 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
3611 | afi_t afi, safi_t safi, u_int32_t flag) | |
718e3744 | 3612 | { |
d62a17ae | 3613 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 3614 | } |
6b0655a2 | 3615 | |
718e3744 | 3616 | /* neighbor capability orf prefix-list. */ |
3617 | DEFUN (neighbor_capability_orf_prefix, | |
3618 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3619 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3620 | NEIGHBOR_STR |
3621 | NEIGHBOR_ADDR_STR2 | |
3622 | "Advertise capability to the peer\n" | |
3623 | "Advertise ORF capability to the peer\n" | |
3624 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3625 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3626 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3627 | "Capability to SEND the ORF to this neighbor\n") | |
3628 | { | |
d62a17ae | 3629 | int idx_peer = 1; |
3630 | int idx_send_recv = 5; | |
3631 | u_int16_t flag = 0; | |
3632 | ||
3633 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3634 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3635 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3636 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3637 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3638 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3639 | else { | |
3640 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3641 | return CMD_WARNING_CONFIG_FAILED; | |
3642 | } | |
3643 | ||
3644 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3645 | bgp_node_safi(vty), flag); | |
3646 | } | |
3647 | ||
3648 | ALIAS_HIDDEN( | |
3649 | neighbor_capability_orf_prefix, | |
3650 | neighbor_capability_orf_prefix_hidden_cmd, | |
3651 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3652 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3653 | "Advertise capability to the peer\n" | |
3654 | "Advertise ORF capability to the peer\n" | |
3655 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3656 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3657 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3658 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3659 | |
718e3744 | 3660 | DEFUN (no_neighbor_capability_orf_prefix, |
3661 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3662 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3663 | NO_STR |
3664 | NEIGHBOR_STR | |
3665 | NEIGHBOR_ADDR_STR2 | |
3666 | "Advertise capability to the peer\n" | |
3667 | "Advertise ORF capability to the peer\n" | |
3668 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3669 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3670 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3671 | "Capability to SEND the ORF to this neighbor\n") | |
3672 | { | |
d62a17ae | 3673 | int idx_peer = 2; |
3674 | int idx_send_recv = 6; | |
3675 | u_int16_t flag = 0; | |
3676 | ||
3677 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3678 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3679 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3680 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3681 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3682 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3683 | else { | |
3684 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3685 | return CMD_WARNING_CONFIG_FAILED; | |
3686 | } | |
3687 | ||
3688 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3689 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3690 | flag); | |
3691 | } | |
3692 | ||
3693 | ALIAS_HIDDEN( | |
3694 | no_neighbor_capability_orf_prefix, | |
3695 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
3696 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3697 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3698 | "Advertise capability to the peer\n" | |
3699 | "Advertise ORF capability to the peer\n" | |
3700 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3701 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3702 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3703 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3704 | |
718e3744 | 3705 | /* neighbor next-hop-self. */ |
3706 | DEFUN (neighbor_nexthop_self, | |
3707 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3708 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3709 | NEIGHBOR_STR |
3710 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3711 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3712 | { |
d62a17ae | 3713 | int idx_peer = 1; |
3714 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3715 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 3716 | } |
9e7a53c1 | 3717 | |
d62a17ae | 3718 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
3719 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3720 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3721 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3722 | |
a538debe DS |
3723 | /* neighbor next-hop-self. */ |
3724 | DEFUN (neighbor_nexthop_self_force, | |
3725 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3726 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3727 | NEIGHBOR_STR |
3728 | NEIGHBOR_ADDR_STR2 | |
3729 | "Disable the next hop calculation for this neighbor\n" | |
3730 | "Set the next hop to self for reflected routes\n") | |
3731 | { | |
d62a17ae | 3732 | int idx_peer = 1; |
3733 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3734 | bgp_node_safi(vty), | |
3735 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 3736 | } |
3737 | ||
d62a17ae | 3738 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3739 | neighbor_nexthop_self_force_hidden_cmd, | |
3740 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3741 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3742 | "Disable the next hop calculation for this neighbor\n" | |
3743 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3744 | |
718e3744 | 3745 | DEFUN (no_neighbor_nexthop_self, |
3746 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3747 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3748 | NO_STR |
3749 | NEIGHBOR_STR | |
3750 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3751 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3752 | { |
d62a17ae | 3753 | int idx_peer = 2; |
3754 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3755 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3756 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 3757 | } |
6b0655a2 | 3758 | |
d62a17ae | 3759 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
3760 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3761 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3762 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3763 | |
88b8ed8d | 3764 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3765 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3766 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3767 | NO_STR |
3768 | NEIGHBOR_STR | |
3769 | NEIGHBOR_ADDR_STR2 | |
3770 | "Disable the next hop calculation for this neighbor\n" | |
3771 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3772 | { |
d62a17ae | 3773 | int idx_peer = 2; |
3774 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3775 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3776 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 3777 | } |
a538debe | 3778 | |
d62a17ae | 3779 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
3780 | no_neighbor_nexthop_self_force_hidden_cmd, | |
3781 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3782 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3783 | "Disable the next hop calculation for this neighbor\n" | |
3784 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3785 | |
c7122e14 DS |
3786 | /* neighbor as-override */ |
3787 | DEFUN (neighbor_as_override, | |
3788 | neighbor_as_override_cmd, | |
9ccf14f7 | 3789 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3790 | NEIGHBOR_STR |
3791 | NEIGHBOR_ADDR_STR2 | |
3792 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3793 | { | |
d62a17ae | 3794 | int idx_peer = 1; |
3795 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3796 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3797 | } |
3798 | ||
d62a17ae | 3799 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
3800 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3801 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3802 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3803 | |
c7122e14 DS |
3804 | DEFUN (no_neighbor_as_override, |
3805 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3806 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3807 | NO_STR |
3808 | NEIGHBOR_STR | |
3809 | NEIGHBOR_ADDR_STR2 | |
3810 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3811 | { | |
d62a17ae | 3812 | int idx_peer = 2; |
3813 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3814 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3815 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3816 | } |
3817 | ||
d62a17ae | 3818 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
3819 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3820 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3821 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3822 | |
718e3744 | 3823 | /* neighbor remove-private-AS. */ |
3824 | DEFUN (neighbor_remove_private_as, | |
3825 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3826 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3827 | NEIGHBOR_STR |
3828 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3829 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3830 | { |
d62a17ae | 3831 | int idx_peer = 1; |
3832 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3833 | bgp_node_safi(vty), | |
3834 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 3835 | } |
3836 | ||
d62a17ae | 3837 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
3838 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
3839 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3840 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 3841 | |
5000f21c DS |
3842 | DEFUN (neighbor_remove_private_as_all, |
3843 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 3844 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3845 | NEIGHBOR_STR |
3846 | NEIGHBOR_ADDR_STR2 | |
3847 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 3848 | "Apply to all AS numbers\n") |
5000f21c | 3849 | { |
d62a17ae | 3850 | int idx_peer = 1; |
3851 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3852 | bgp_node_safi(vty), | |
3853 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
3854 | } |
3855 | ||
d62a17ae | 3856 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
3857 | neighbor_remove_private_as_all_hidden_cmd, | |
3858 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
3859 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3860 | "Remove private ASNs in outbound updates\n" | |
3861 | "Apply to all AS numbers") | |
596c17ba | 3862 | |
5000f21c DS |
3863 | DEFUN (neighbor_remove_private_as_replace_as, |
3864 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 3865 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3866 | NEIGHBOR_STR |
3867 | NEIGHBOR_ADDR_STR2 | |
3868 | "Remove private ASNs in outbound updates\n" | |
3869 | "Replace private ASNs with our ASN in outbound updates\n") | |
3870 | { | |
d62a17ae | 3871 | int idx_peer = 1; |
3872 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3873 | bgp_node_safi(vty), | |
3874 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
3875 | } |
3876 | ||
d62a17ae | 3877 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
3878 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
3879 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
3880 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3881 | "Remove private ASNs in outbound updates\n" | |
3882 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3883 | |
5000f21c DS |
3884 | DEFUN (neighbor_remove_private_as_all_replace_as, |
3885 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 3886 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3887 | NEIGHBOR_STR |
3888 | NEIGHBOR_ADDR_STR2 | |
3889 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3890 | "Apply to all AS numbers\n" |
5000f21c DS |
3891 | "Replace private ASNs with our ASN in outbound updates\n") |
3892 | { | |
d62a17ae | 3893 | int idx_peer = 1; |
3894 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3895 | bgp_node_safi(vty), | |
3896 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
3897 | } |
3898 | ||
d62a17ae | 3899 | ALIAS_HIDDEN( |
3900 | neighbor_remove_private_as_all_replace_as, | |
3901 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
3902 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
3903 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3904 | "Remove private ASNs in outbound updates\n" | |
3905 | "Apply to all AS numbers\n" | |
3906 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3907 | |
718e3744 | 3908 | DEFUN (no_neighbor_remove_private_as, |
3909 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3910 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3911 | NO_STR |
3912 | NEIGHBOR_STR | |
3913 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3914 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3915 | { |
d62a17ae | 3916 | int idx_peer = 2; |
3917 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3918 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3919 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 3920 | } |
6b0655a2 | 3921 | |
d62a17ae | 3922 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
3923 | no_neighbor_remove_private_as_hidden_cmd, | |
3924 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
3925 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3926 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 3927 | |
88b8ed8d | 3928 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 3929 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 3930 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3931 | NO_STR |
3932 | NEIGHBOR_STR | |
3933 | NEIGHBOR_ADDR_STR2 | |
3934 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3935 | "Apply to all AS numbers\n") |
88b8ed8d | 3936 | { |
d62a17ae | 3937 | int idx_peer = 2; |
3938 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3939 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3940 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 3941 | } |
5000f21c | 3942 | |
d62a17ae | 3943 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
3944 | no_neighbor_remove_private_as_all_hidden_cmd, | |
3945 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
3946 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3947 | "Remove private ASNs in outbound updates\n" | |
3948 | "Apply to all AS numbers\n") | |
596c17ba | 3949 | |
88b8ed8d | 3950 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 3951 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 3952 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3953 | NO_STR |
3954 | NEIGHBOR_STR | |
3955 | NEIGHBOR_ADDR_STR2 | |
3956 | "Remove private ASNs in outbound updates\n" | |
3957 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 3958 | { |
d62a17ae | 3959 | int idx_peer = 2; |
3960 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3961 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3962 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 3963 | } |
5000f21c | 3964 | |
d62a17ae | 3965 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
3966 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
3967 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
3968 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3969 | "Remove private ASNs in outbound updates\n" | |
3970 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3971 | |
88b8ed8d | 3972 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 3973 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 3974 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3975 | NO_STR |
3976 | NEIGHBOR_STR | |
3977 | NEIGHBOR_ADDR_STR2 | |
3978 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3979 | "Apply to all AS numbers\n" |
5000f21c | 3980 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 3981 | { |
d62a17ae | 3982 | int idx_peer = 2; |
3983 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3984 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3985 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 3986 | } |
5000f21c | 3987 | |
d62a17ae | 3988 | ALIAS_HIDDEN( |
3989 | no_neighbor_remove_private_as_all_replace_as, | |
3990 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
3991 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
3992 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3993 | "Remove private ASNs in outbound updates\n" | |
3994 | "Apply to all AS numbers\n" | |
3995 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3996 | |
5000f21c | 3997 | |
718e3744 | 3998 | /* neighbor send-community. */ |
3999 | DEFUN (neighbor_send_community, | |
4000 | neighbor_send_community_cmd, | |
9ccf14f7 | 4001 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4002 | NEIGHBOR_STR |
4003 | NEIGHBOR_ADDR_STR2 | |
4004 | "Send Community attribute to this neighbor\n") | |
4005 | { | |
d62a17ae | 4006 | int idx_peer = 1; |
4007 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4008 | bgp_node_safi(vty), | |
4009 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4010 | } |
4011 | ||
d62a17ae | 4012 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4013 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4014 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4015 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4016 | |
718e3744 | 4017 | DEFUN (no_neighbor_send_community, |
4018 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4019 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4020 | NO_STR |
4021 | NEIGHBOR_STR | |
4022 | NEIGHBOR_ADDR_STR2 | |
4023 | "Send Community attribute to this neighbor\n") | |
4024 | { | |
d62a17ae | 4025 | int idx_peer = 2; |
4026 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4027 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4028 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4029 | } |
6b0655a2 | 4030 | |
d62a17ae | 4031 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4032 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4033 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4034 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4035 | |
718e3744 | 4036 | /* neighbor send-community extended. */ |
4037 | DEFUN (neighbor_send_community_type, | |
4038 | neighbor_send_community_type_cmd, | |
57d187bc | 4039 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4040 | NEIGHBOR_STR |
4041 | NEIGHBOR_ADDR_STR2 | |
4042 | "Send Community attribute to this neighbor\n" | |
4043 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4044 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4045 | "Send Extended Community attributes\n" |
57d187bc JS |
4046 | "Send Standard Community attributes\n" |
4047 | "Send Large Community attributes\n") | |
718e3744 | 4048 | { |
d62a17ae | 4049 | int idx = 0; |
4050 | u_int32_t flag = 0; | |
4051 | ||
4052 | char *peer = argv[1]->arg; | |
4053 | ||
4054 | if (argv_find(argv, argc, "standard", &idx)) | |
4055 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4056 | else if (argv_find(argv, argc, "extended", &idx)) | |
4057 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4058 | else if (argv_find(argv, argc, "large", &idx)) | |
4059 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4060 | else if (argv_find(argv, argc, "both", &idx)) { | |
4061 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4062 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4063 | } else { | |
4064 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4065 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4066 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4067 | } | |
4068 | ||
4069 | return peer_af_flag_set_vty(vty, peer, bgp_node_afi(vty), | |
4070 | bgp_node_safi(vty), flag); | |
4071 | } | |
4072 | ||
4073 | ALIAS_HIDDEN( | |
4074 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4075 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4076 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4077 | "Send Community attribute to this neighbor\n" | |
4078 | "Send Standard and Extended Community attributes\n" | |
4079 | "Send Standard, Large and Extended Community attributes\n" | |
4080 | "Send Extended Community attributes\n" | |
4081 | "Send Standard Community attributes\n" | |
4082 | "Send Large Community attributes\n") | |
596c17ba | 4083 | |
718e3744 | 4084 | DEFUN (no_neighbor_send_community_type, |
4085 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4086 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4087 | NO_STR |
4088 | NEIGHBOR_STR | |
4089 | NEIGHBOR_ADDR_STR2 | |
4090 | "Send Community attribute to this neighbor\n" | |
4091 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4092 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4093 | "Send Extended Community attributes\n" |
57d187bc JS |
4094 | "Send Standard Community attributes\n" |
4095 | "Send Large Community attributes\n") | |
718e3744 | 4096 | { |
d62a17ae | 4097 | int idx_peer = 2; |
4098 | ||
4099 | const char *type = argv[argc - 1]->text; | |
4100 | ||
4101 | if (strmatch(type, "standard")) | |
4102 | return peer_af_flag_unset_vty( | |
4103 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4104 | bgp_node_safi(vty), PEER_FLAG_SEND_COMMUNITY); | |
4105 | if (strmatch(type, "extended")) | |
4106 | return peer_af_flag_unset_vty( | |
4107 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4108 | bgp_node_safi(vty), PEER_FLAG_SEND_EXT_COMMUNITY); | |
4109 | if (strmatch(type, "large")) | |
4110 | return peer_af_flag_unset_vty( | |
4111 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4112 | bgp_node_safi(vty), PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4113 | if (strmatch(type, "both")) | |
4114 | return peer_af_flag_unset_vty( | |
4115 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4116 | bgp_node_safi(vty), | |
4117 | PEER_FLAG_SEND_COMMUNITY | |
4118 | | PEER_FLAG_SEND_EXT_COMMUNITY); | |
4119 | ||
4120 | /* if (strmatch (type, "all")) */ | |
4121 | return peer_af_flag_unset_vty( | |
4122 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4123 | (PEER_FLAG_SEND_COMMUNITY | PEER_FLAG_SEND_EXT_COMMUNITY | |
4124 | | PEER_FLAG_SEND_LARGE_COMMUNITY)); | |
4125 | } | |
4126 | ||
4127 | ALIAS_HIDDEN( | |
4128 | no_neighbor_send_community_type, | |
4129 | no_neighbor_send_community_type_hidden_cmd, | |
4130 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4131 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4132 | "Send Community attribute to this neighbor\n" | |
4133 | "Send Standard and Extended Community attributes\n" | |
4134 | "Send Standard, Large and Extended Community attributes\n" | |
4135 | "Send Extended Community attributes\n" | |
4136 | "Send Standard Community attributes\n" | |
4137 | "Send Large Community attributes\n") | |
596c17ba | 4138 | |
718e3744 | 4139 | /* neighbor soft-reconfig. */ |
4140 | DEFUN (neighbor_soft_reconfiguration, | |
4141 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4142 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4143 | NEIGHBOR_STR |
4144 | NEIGHBOR_ADDR_STR2 | |
4145 | "Per neighbor soft reconfiguration\n" | |
4146 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4147 | { | |
d62a17ae | 4148 | int idx_peer = 1; |
4149 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4150 | bgp_node_safi(vty), | |
4151 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4152 | } |
4153 | ||
d62a17ae | 4154 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4155 | neighbor_soft_reconfiguration_hidden_cmd, | |
4156 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4157 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4158 | "Per neighbor soft reconfiguration\n" | |
4159 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4160 | |
718e3744 | 4161 | DEFUN (no_neighbor_soft_reconfiguration, |
4162 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4163 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4164 | NO_STR |
4165 | NEIGHBOR_STR | |
4166 | NEIGHBOR_ADDR_STR2 | |
4167 | "Per neighbor soft reconfiguration\n" | |
4168 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4169 | { | |
d62a17ae | 4170 | int idx_peer = 2; |
4171 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4172 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4173 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4174 | } |
6b0655a2 | 4175 | |
d62a17ae | 4176 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
4177 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4178 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4179 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4180 | "Per neighbor soft reconfiguration\n" | |
4181 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4182 | |
718e3744 | 4183 | DEFUN (neighbor_route_reflector_client, |
4184 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4185 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4186 | NEIGHBOR_STR |
4187 | NEIGHBOR_ADDR_STR2 | |
4188 | "Configure a neighbor as Route Reflector client\n") | |
4189 | { | |
d62a17ae | 4190 | int idx_peer = 1; |
4191 | struct peer *peer; | |
718e3744 | 4192 | |
4193 | ||
d62a17ae | 4194 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4195 | if (!peer) | |
4196 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4197 | |
d62a17ae | 4198 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4199 | bgp_node_safi(vty), | |
4200 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4201 | } |
4202 | ||
d62a17ae | 4203 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
4204 | neighbor_route_reflector_client_hidden_cmd, | |
4205 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4206 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4207 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4208 | |
718e3744 | 4209 | DEFUN (no_neighbor_route_reflector_client, |
4210 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4211 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4212 | NO_STR |
4213 | NEIGHBOR_STR | |
4214 | NEIGHBOR_ADDR_STR2 | |
4215 | "Configure a neighbor as Route Reflector client\n") | |
4216 | { | |
d62a17ae | 4217 | int idx_peer = 2; |
4218 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4219 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4220 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4221 | } |
6b0655a2 | 4222 | |
d62a17ae | 4223 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
4224 | no_neighbor_route_reflector_client_hidden_cmd, | |
4225 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4226 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4227 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4228 | |
718e3744 | 4229 | /* neighbor route-server-client. */ |
4230 | DEFUN (neighbor_route_server_client, | |
4231 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4232 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4233 | NEIGHBOR_STR |
4234 | NEIGHBOR_ADDR_STR2 | |
4235 | "Configure a neighbor as Route Server client\n") | |
4236 | { | |
d62a17ae | 4237 | int idx_peer = 1; |
4238 | struct peer *peer; | |
2a3d5731 | 4239 | |
d62a17ae | 4240 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4241 | if (!peer) | |
4242 | return CMD_WARNING_CONFIG_FAILED; | |
4243 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4244 | bgp_node_safi(vty), | |
4245 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4246 | } |
4247 | ||
d62a17ae | 4248 | ALIAS_HIDDEN(neighbor_route_server_client, |
4249 | neighbor_route_server_client_hidden_cmd, | |
4250 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4251 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4252 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4253 | |
718e3744 | 4254 | DEFUN (no_neighbor_route_server_client, |
4255 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4256 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4257 | NO_STR |
4258 | NEIGHBOR_STR | |
4259 | NEIGHBOR_ADDR_STR2 | |
4260 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4261 | { |
d62a17ae | 4262 | int idx_peer = 2; |
4263 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4264 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4265 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4266 | } |
6b0655a2 | 4267 | |
d62a17ae | 4268 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
4269 | no_neighbor_route_server_client_hidden_cmd, | |
4270 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4271 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4272 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4273 | |
fee0f4c6 | 4274 | DEFUN (neighbor_nexthop_local_unchanged, |
4275 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4276 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4277 | NEIGHBOR_STR |
4278 | NEIGHBOR_ADDR_STR2 | |
4279 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4280 | "Leave link-local nexthop unchanged for this peer\n") | |
4281 | { | |
d62a17ae | 4282 | int idx_peer = 1; |
4283 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4284 | bgp_node_safi(vty), | |
4285 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 4286 | } |
6b0655a2 | 4287 | |
fee0f4c6 | 4288 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4289 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4290 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4291 | NO_STR |
4292 | NEIGHBOR_STR | |
4293 | NEIGHBOR_ADDR_STR2 | |
4294 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4295 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4296 | { |
d62a17ae | 4297 | int idx_peer = 2; |
4298 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4299 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4300 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 4301 | } |
6b0655a2 | 4302 | |
718e3744 | 4303 | DEFUN (neighbor_attr_unchanged, |
4304 | neighbor_attr_unchanged_cmd, | |
a8206004 | 4305 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 4306 | NEIGHBOR_STR |
4307 | NEIGHBOR_ADDR_STR2 | |
4308 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4309 | "As-path attribute\n" | |
4310 | "Nexthop attribute\n" | |
a8206004 | 4311 | "Med attribute\n") |
718e3744 | 4312 | { |
d62a17ae | 4313 | int idx = 0; |
8eeb0335 DW |
4314 | char *peer_str = argv[1]->arg; |
4315 | struct peer *peer; | |
d62a17ae | 4316 | u_int16_t flags = 0; |
8eeb0335 DW |
4317 | afi_t afi = bgp_node_afi(vty); |
4318 | safi_t safi = bgp_node_safi(vty); | |
4319 | ||
4320 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4321 | if (!peer) | |
4322 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4323 | |
4324 | if (argv_find(argv, argc, "as-path", &idx)) | |
4325 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4326 | idx = 0; | |
4327 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4328 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4329 | idx = 0; | |
4330 | if (argv_find(argv, argc, "med", &idx)) | |
4331 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4332 | ||
8eeb0335 DW |
4333 | /* no flags means all of them! */ |
4334 | if (!flags) { | |
d62a17ae | 4335 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
4336 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4337 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 DW |
4338 | } else { |
4339 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) && | |
4340 | peer_af_flag_check(peer, afi, safi, | |
4341 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
4342 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
4343 | PEER_FLAG_AS_PATH_UNCHANGED); | |
4344 | } | |
4345 | ||
4346 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) && | |
4347 | peer_af_flag_check(peer, afi, safi, | |
4348 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
4349 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
4350 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
4351 | } | |
4352 | ||
4353 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) && | |
4354 | peer_af_flag_check(peer, afi, safi, | |
4355 | PEER_FLAG_MED_UNCHANGED)) { | |
4356 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
4357 | PEER_FLAG_MED_UNCHANGED); | |
4358 | } | |
d62a17ae | 4359 | } |
4360 | ||
8eeb0335 | 4361 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 4362 | } |
4363 | ||
4364 | ALIAS_HIDDEN( | |
4365 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
4366 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4367 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4368 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4369 | "As-path attribute\n" | |
4370 | "Nexthop attribute\n" | |
4371 | "Med attribute\n") | |
596c17ba | 4372 | |
718e3744 | 4373 | DEFUN (no_neighbor_attr_unchanged, |
4374 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 4375 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 4376 | NO_STR |
718e3744 | 4377 | NEIGHBOR_STR |
4378 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4379 | "BGP attribute is propagated unchanged to this neighbor\n" |
4380 | "As-path attribute\n" | |
40e718b5 | 4381 | "Nexthop attribute\n" |
a8206004 | 4382 | "Med attribute\n") |
718e3744 | 4383 | { |
d62a17ae | 4384 | int idx = 0; |
4385 | char *peer = argv[2]->arg; | |
4386 | u_int16_t flags = 0; | |
4387 | ||
4388 | if (argv_find(argv, argc, "as-path", &idx)) | |
4389 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4390 | idx = 0; | |
4391 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4392 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4393 | idx = 0; | |
4394 | if (argv_find(argv, argc, "med", &idx)) | |
4395 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4396 | ||
4397 | if (!flags) // no flags means all of them! | |
4398 | { | |
4399 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4400 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4401 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4402 | } | |
4403 | ||
4404 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
4405 | bgp_node_safi(vty), flags); | |
4406 | } | |
4407 | ||
4408 | ALIAS_HIDDEN( | |
4409 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
4410 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4411 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4412 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4413 | "As-path attribute\n" | |
4414 | "Nexthop attribute\n" | |
4415 | "Med attribute\n") | |
718e3744 | 4416 | |
718e3744 | 4417 | /* EBGP multihop configuration. */ |
d62a17ae | 4418 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
4419 | const char *ttl_str) | |
718e3744 | 4420 | { |
d62a17ae | 4421 | struct peer *peer; |
4422 | unsigned int ttl; | |
718e3744 | 4423 | |
d62a17ae | 4424 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4425 | if (!peer) | |
4426 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4427 | |
d62a17ae | 4428 | if (peer->conf_if) |
4429 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 4430 | |
d62a17ae | 4431 | if (!ttl_str) |
4432 | ttl = MAXTTL; | |
4433 | else | |
4434 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 4435 | |
d62a17ae | 4436 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 4437 | } |
4438 | ||
d62a17ae | 4439 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4440 | { |
d62a17ae | 4441 | struct peer *peer; |
718e3744 | 4442 | |
d62a17ae | 4443 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4444 | if (!peer) | |
4445 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4446 | |
d62a17ae | 4447 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 4448 | } |
4449 | ||
4450 | /* neighbor ebgp-multihop. */ | |
4451 | DEFUN (neighbor_ebgp_multihop, | |
4452 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4453 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4454 | NEIGHBOR_STR |
4455 | NEIGHBOR_ADDR_STR2 | |
4456 | "Allow EBGP neighbors not on directly connected networks\n") | |
4457 | { | |
d62a17ae | 4458 | int idx_peer = 1; |
4459 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4460 | } |
4461 | ||
4462 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4463 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4464 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4465 | NEIGHBOR_STR |
4466 | NEIGHBOR_ADDR_STR2 | |
4467 | "Allow EBGP neighbors not on directly connected networks\n" | |
4468 | "maximum hop count\n") | |
4469 | { | |
d62a17ae | 4470 | int idx_peer = 1; |
4471 | int idx_number = 3; | |
4472 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
4473 | argv[idx_number]->arg); | |
718e3744 | 4474 | } |
4475 | ||
4476 | DEFUN (no_neighbor_ebgp_multihop, | |
4477 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4478 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4479 | NO_STR |
4480 | NEIGHBOR_STR | |
4481 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4482 | "Allow EBGP neighbors not on directly connected networks\n" |
4483 | "maximum hop count\n") | |
718e3744 | 4484 | { |
d62a17ae | 4485 | int idx_peer = 2; |
4486 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4487 | } |
4488 | ||
6b0655a2 | 4489 | |
6ffd2079 | 4490 | /* disable-connected-check */ |
4491 | DEFUN (neighbor_disable_connected_check, | |
4492 | neighbor_disable_connected_check_cmd, | |
a636c635 | 4493 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4494 | NEIGHBOR_STR |
4495 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4496 | "one-hop away EBGP peer using loopback address\n" |
4497 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4498 | { |
d62a17ae | 4499 | int idx_peer = 1; |
4500 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4501 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4502 | } |
4503 | ||
4504 | DEFUN (no_neighbor_disable_connected_check, | |
4505 | no_neighbor_disable_connected_check_cmd, | |
a636c635 | 4506 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4507 | NO_STR |
4508 | NEIGHBOR_STR | |
4509 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4510 | "one-hop away EBGP peer using loopback address\n" |
4511 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4512 | { |
d62a17ae | 4513 | int idx_peer = 2; |
4514 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4515 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4516 | } |
4517 | ||
718e3744 | 4518 | DEFUN (neighbor_description, |
4519 | neighbor_description_cmd, | |
e961923c | 4520 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4521 | NEIGHBOR_STR |
4522 | NEIGHBOR_ADDR_STR2 | |
4523 | "Neighbor specific description\n" | |
4524 | "Up to 80 characters describing this neighbor\n") | |
4525 | { | |
d62a17ae | 4526 | int idx_peer = 1; |
4527 | int idx_line = 3; | |
4528 | struct peer *peer; | |
4529 | char *str; | |
718e3744 | 4530 | |
d62a17ae | 4531 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4532 | if (!peer) | |
4533 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4534 | |
d62a17ae | 4535 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4536 | |
d62a17ae | 4537 | peer_description_set(peer, str); |
718e3744 | 4538 | |
d62a17ae | 4539 | XFREE(MTYPE_TMP, str); |
718e3744 | 4540 | |
d62a17ae | 4541 | return CMD_SUCCESS; |
718e3744 | 4542 | } |
4543 | ||
4544 | DEFUN (no_neighbor_description, | |
4545 | no_neighbor_description_cmd, | |
a636c635 | 4546 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]", |
718e3744 | 4547 | NO_STR |
4548 | NEIGHBOR_STR | |
4549 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4550 | "Neighbor specific description\n" |
4551 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 4552 | { |
d62a17ae | 4553 | int idx_peer = 2; |
4554 | struct peer *peer; | |
718e3744 | 4555 | |
d62a17ae | 4556 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4557 | if (!peer) | |
4558 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4559 | |
d62a17ae | 4560 | peer_description_unset(peer); |
718e3744 | 4561 | |
d62a17ae | 4562 | return CMD_SUCCESS; |
718e3744 | 4563 | } |
4564 | ||
6b0655a2 | 4565 | |
718e3744 | 4566 | /* Neighbor update-source. */ |
d62a17ae | 4567 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
4568 | const char *source_str) | |
4569 | { | |
4570 | struct peer *peer; | |
4571 | struct prefix p; | |
4572 | ||
4573 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4574 | if (!peer) | |
4575 | return CMD_WARNING_CONFIG_FAILED; | |
4576 | ||
4577 | if (peer->conf_if) | |
4578 | return CMD_WARNING; | |
4579 | ||
4580 | if (source_str) { | |
4581 | union sockunion su; | |
4582 | int ret = str2sockunion(source_str, &su); | |
4583 | ||
4584 | if (ret == 0) | |
4585 | peer_update_source_addr_set(peer, &su); | |
4586 | else { | |
4587 | if (str2prefix(source_str, &p)) { | |
4588 | vty_out(vty, | |
4589 | "%% Invalid update-source, remove prefix length \n"); | |
4590 | return CMD_WARNING_CONFIG_FAILED; | |
4591 | } else | |
4592 | peer_update_source_if_set(peer, source_str); | |
4593 | } | |
4594 | } else | |
4595 | peer_update_source_unset(peer); | |
4596 | ||
4597 | return CMD_SUCCESS; | |
4598 | } | |
4599 | ||
4600 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
4601 | "IPv4 address\n" \ | |
4602 | "IPv6 address\n" \ | |
4603 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4604 | |
718e3744 | 4605 | DEFUN (neighbor_update_source, |
4606 | neighbor_update_source_cmd, | |
9ccf14f7 | 4607 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4608 | NEIGHBOR_STR |
4609 | NEIGHBOR_ADDR_STR2 | |
4610 | "Source of routing updates\n" | |
369688c0 | 4611 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4612 | { |
d62a17ae | 4613 | int idx_peer = 1; |
4614 | int idx_peer_2 = 3; | |
4615 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
4616 | argv[idx_peer_2]->arg); | |
718e3744 | 4617 | } |
4618 | ||
4619 | DEFUN (no_neighbor_update_source, | |
4620 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4621 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4622 | NO_STR |
4623 | NEIGHBOR_STR | |
4624 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4625 | "Source of routing updates\n" |
4626 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4627 | { |
d62a17ae | 4628 | int idx_peer = 2; |
4629 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4630 | } |
6b0655a2 | 4631 | |
d62a17ae | 4632 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
4633 | afi_t afi, safi_t safi, | |
4634 | const char *rmap, int set) | |
718e3744 | 4635 | { |
d62a17ae | 4636 | int ret; |
4637 | struct peer *peer; | |
718e3744 | 4638 | |
d62a17ae | 4639 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4640 | if (!peer) | |
4641 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4642 | |
d62a17ae | 4643 | if (set) |
4644 | ret = peer_default_originate_set(peer, afi, safi, rmap); | |
4645 | else | |
4646 | ret = peer_default_originate_unset(peer, afi, safi); | |
718e3744 | 4647 | |
d62a17ae | 4648 | return bgp_vty_return(vty, ret); |
718e3744 | 4649 | } |
4650 | ||
4651 | /* neighbor default-originate. */ | |
4652 | DEFUN (neighbor_default_originate, | |
4653 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4654 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4655 | NEIGHBOR_STR |
4656 | NEIGHBOR_ADDR_STR2 | |
4657 | "Originate default route to this neighbor\n") | |
4658 | { | |
d62a17ae | 4659 | int idx_peer = 1; |
4660 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4661 | bgp_node_afi(vty), | |
4662 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 4663 | } |
4664 | ||
d62a17ae | 4665 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
4666 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
4667 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4668 | "Originate default route to this neighbor\n") | |
596c17ba | 4669 | |
718e3744 | 4670 | DEFUN (neighbor_default_originate_rmap, |
4671 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4672 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4673 | NEIGHBOR_STR |
4674 | NEIGHBOR_ADDR_STR2 | |
4675 | "Originate default route to this neighbor\n" | |
4676 | "Route-map to specify criteria to originate default\n" | |
4677 | "route-map name\n") | |
4678 | { | |
d62a17ae | 4679 | int idx_peer = 1; |
4680 | int idx_word = 4; | |
4681 | return peer_default_originate_set_vty( | |
4682 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4683 | argv[idx_word]->arg, 1); | |
718e3744 | 4684 | } |
4685 | ||
d62a17ae | 4686 | ALIAS_HIDDEN( |
4687 | neighbor_default_originate_rmap, | |
4688 | neighbor_default_originate_rmap_hidden_cmd, | |
4689 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
4690 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4691 | "Originate default route to this neighbor\n" | |
4692 | "Route-map to specify criteria to originate default\n" | |
4693 | "route-map name\n") | |
596c17ba | 4694 | |
718e3744 | 4695 | DEFUN (no_neighbor_default_originate, |
4696 | no_neighbor_default_originate_cmd, | |
a636c635 | 4697 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4698 | NO_STR |
4699 | NEIGHBOR_STR | |
4700 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4701 | "Originate default route to this neighbor\n" |
4702 | "Route-map to specify criteria to originate default\n" | |
4703 | "route-map name\n") | |
718e3744 | 4704 | { |
d62a17ae | 4705 | int idx_peer = 2; |
4706 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4707 | bgp_node_afi(vty), | |
4708 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 4709 | } |
4710 | ||
d62a17ae | 4711 | ALIAS_HIDDEN( |
4712 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
4713 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
4714 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4715 | "Originate default route to this neighbor\n" | |
4716 | "Route-map to specify criteria to originate default\n" | |
4717 | "route-map name\n") | |
596c17ba | 4718 | |
6b0655a2 | 4719 | |
718e3744 | 4720 | /* Set neighbor's BGP port. */ |
d62a17ae | 4721 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
4722 | const char *port_str) | |
4723 | { | |
4724 | struct peer *peer; | |
4725 | u_int16_t port; | |
4726 | struct servent *sp; | |
4727 | ||
4728 | peer = peer_lookup_vty(vty, ip_str); | |
4729 | if (!peer) | |
4730 | return CMD_WARNING_CONFIG_FAILED; | |
4731 | ||
4732 | if (!port_str) { | |
4733 | sp = getservbyname("bgp", "tcp"); | |
4734 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
4735 | } else { | |
4736 | port = strtoul(port_str, NULL, 10); | |
4737 | } | |
718e3744 | 4738 | |
d62a17ae | 4739 | peer_port_set(peer, port); |
718e3744 | 4740 | |
d62a17ae | 4741 | return CMD_SUCCESS; |
718e3744 | 4742 | } |
4743 | ||
f418446b | 4744 | /* Set specified peer's BGP port. */ |
718e3744 | 4745 | DEFUN (neighbor_port, |
4746 | neighbor_port_cmd, | |
9ccf14f7 | 4747 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4748 | NEIGHBOR_STR |
4749 | NEIGHBOR_ADDR_STR | |
4750 | "Neighbor's BGP port\n" | |
4751 | "TCP port number\n") | |
4752 | { | |
d62a17ae | 4753 | int idx_ip = 1; |
4754 | int idx_number = 3; | |
4755 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
4756 | argv[idx_number]->arg); | |
718e3744 | 4757 | } |
4758 | ||
4759 | DEFUN (no_neighbor_port, | |
4760 | no_neighbor_port_cmd, | |
9ccf14f7 | 4761 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4762 | NO_STR |
4763 | NEIGHBOR_STR | |
4764 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4765 | "Neighbor's BGP port\n" |
4766 | "TCP port number\n") | |
718e3744 | 4767 | { |
d62a17ae | 4768 | int idx_ip = 2; |
4769 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4770 | } |
4771 | ||
6b0655a2 | 4772 | |
718e3744 | 4773 | /* neighbor weight. */ |
d62a17ae | 4774 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4775 | safi_t safi, const char *weight_str) | |
718e3744 | 4776 | { |
d62a17ae | 4777 | int ret; |
4778 | struct peer *peer; | |
4779 | unsigned long weight; | |
718e3744 | 4780 | |
d62a17ae | 4781 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4782 | if (!peer) | |
4783 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4784 | |
d62a17ae | 4785 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 4786 | |
d62a17ae | 4787 | ret = peer_weight_set(peer, afi, safi, weight); |
4788 | return bgp_vty_return(vty, ret); | |
718e3744 | 4789 | } |
4790 | ||
d62a17ae | 4791 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4792 | safi_t safi) | |
718e3744 | 4793 | { |
d62a17ae | 4794 | int ret; |
4795 | struct peer *peer; | |
718e3744 | 4796 | |
d62a17ae | 4797 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4798 | if (!peer) | |
4799 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4800 | |
d62a17ae | 4801 | ret = peer_weight_unset(peer, afi, safi); |
4802 | return bgp_vty_return(vty, ret); | |
718e3744 | 4803 | } |
4804 | ||
4805 | DEFUN (neighbor_weight, | |
4806 | neighbor_weight_cmd, | |
9ccf14f7 | 4807 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 4808 | NEIGHBOR_STR |
4809 | NEIGHBOR_ADDR_STR2 | |
4810 | "Set default weight for routes from this neighbor\n" | |
4811 | "default weight\n") | |
4812 | { | |
d62a17ae | 4813 | int idx_peer = 1; |
4814 | int idx_number = 3; | |
4815 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4816 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 4817 | } |
4818 | ||
d62a17ae | 4819 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
4820 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
4821 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4822 | "Set default weight for routes from this neighbor\n" | |
4823 | "default weight\n") | |
596c17ba | 4824 | |
718e3744 | 4825 | DEFUN (no_neighbor_weight, |
4826 | no_neighbor_weight_cmd, | |
9ccf14f7 | 4827 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 4828 | NO_STR |
4829 | NEIGHBOR_STR | |
4830 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4831 | "Set default weight for routes from this neighbor\n" |
4832 | "default weight\n") | |
718e3744 | 4833 | { |
d62a17ae | 4834 | int idx_peer = 2; |
4835 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
4836 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 4837 | } |
4838 | ||
d62a17ae | 4839 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
4840 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
4841 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4842 | "Set default weight for routes from this neighbor\n" | |
4843 | "default weight\n") | |
596c17ba | 4844 | |
6b0655a2 | 4845 | |
718e3744 | 4846 | /* Override capability negotiation. */ |
4847 | DEFUN (neighbor_override_capability, | |
4848 | neighbor_override_capability_cmd, | |
9ccf14f7 | 4849 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4850 | NEIGHBOR_STR |
4851 | NEIGHBOR_ADDR_STR2 | |
4852 | "Override capability negotiation result\n") | |
4853 | { | |
d62a17ae | 4854 | int idx_peer = 1; |
4855 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4856 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4857 | } |
4858 | ||
4859 | DEFUN (no_neighbor_override_capability, | |
4860 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 4861 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4862 | NO_STR |
4863 | NEIGHBOR_STR | |
4864 | NEIGHBOR_ADDR_STR2 | |
4865 | "Override capability negotiation result\n") | |
4866 | { | |
d62a17ae | 4867 | int idx_peer = 2; |
4868 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4869 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4870 | } |
6b0655a2 | 4871 | |
718e3744 | 4872 | DEFUN (neighbor_strict_capability, |
4873 | neighbor_strict_capability_cmd, | |
9ccf14f7 | 4874 | "neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4875 | NEIGHBOR_STR |
4876 | NEIGHBOR_ADDR_STR | |
4877 | "Strict capability negotiation match\n") | |
4878 | { | |
d62a17ae | 4879 | int idx_ip = 1; |
4880 | return peer_flag_set_vty(vty, argv[idx_ip]->arg, | |
4881 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4882 | } |
4883 | ||
4884 | DEFUN (no_neighbor_strict_capability, | |
4885 | no_neighbor_strict_capability_cmd, | |
9ccf14f7 | 4886 | "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4887 | NO_STR |
4888 | NEIGHBOR_STR | |
4889 | NEIGHBOR_ADDR_STR | |
4890 | "Strict capability negotiation match\n") | |
4891 | { | |
d62a17ae | 4892 | int idx_ip = 2; |
4893 | return peer_flag_unset_vty(vty, argv[idx_ip]->arg, | |
4894 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4895 | } |
6b0655a2 | 4896 | |
d62a17ae | 4897 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
4898 | const char *keep_str, const char *hold_str) | |
718e3744 | 4899 | { |
d62a17ae | 4900 | int ret; |
4901 | struct peer *peer; | |
4902 | u_int32_t keepalive; | |
4903 | u_int32_t holdtime; | |
718e3744 | 4904 | |
d62a17ae | 4905 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4906 | if (!peer) | |
4907 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4908 | |
d62a17ae | 4909 | keepalive = strtoul(keep_str, NULL, 10); |
4910 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 4911 | |
d62a17ae | 4912 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 4913 | |
d62a17ae | 4914 | return bgp_vty_return(vty, ret); |
718e3744 | 4915 | } |
6b0655a2 | 4916 | |
d62a17ae | 4917 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4918 | { |
d62a17ae | 4919 | int ret; |
4920 | struct peer *peer; | |
718e3744 | 4921 | |
d62a17ae | 4922 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4923 | if (!peer) | |
4924 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4925 | |
d62a17ae | 4926 | ret = peer_timers_unset(peer); |
718e3744 | 4927 | |
d62a17ae | 4928 | return bgp_vty_return(vty, ret); |
718e3744 | 4929 | } |
4930 | ||
4931 | DEFUN (neighbor_timers, | |
4932 | neighbor_timers_cmd, | |
9ccf14f7 | 4933 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 4934 | NEIGHBOR_STR |
4935 | NEIGHBOR_ADDR_STR2 | |
4936 | "BGP per neighbor timers\n" | |
4937 | "Keepalive interval\n" | |
4938 | "Holdtime\n") | |
4939 | { | |
d62a17ae | 4940 | int idx_peer = 1; |
4941 | int idx_number = 3; | |
4942 | int idx_number_2 = 4; | |
4943 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
4944 | argv[idx_number]->arg, | |
4945 | argv[idx_number_2]->arg); | |
718e3744 | 4946 | } |
4947 | ||
4948 | DEFUN (no_neighbor_timers, | |
4949 | no_neighbor_timers_cmd, | |
9ccf14f7 | 4950 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 4951 | NO_STR |
4952 | NEIGHBOR_STR | |
4953 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4954 | "BGP per neighbor timers\n" |
4955 | "Keepalive interval\n" | |
4956 | "Holdtime\n") | |
718e3744 | 4957 | { |
d62a17ae | 4958 | int idx_peer = 2; |
4959 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4960 | } |
6b0655a2 | 4961 | |
813d4307 | 4962 | |
d62a17ae | 4963 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
4964 | const char *time_str) | |
718e3744 | 4965 | { |
d62a17ae | 4966 | int ret; |
4967 | struct peer *peer; | |
4968 | u_int32_t connect; | |
718e3744 | 4969 | |
d62a17ae | 4970 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4971 | if (!peer) | |
4972 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4973 | |
d62a17ae | 4974 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 4975 | |
d62a17ae | 4976 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 4977 | |
d62a17ae | 4978 | return bgp_vty_return(vty, ret); |
718e3744 | 4979 | } |
4980 | ||
d62a17ae | 4981 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4982 | { |
d62a17ae | 4983 | int ret; |
4984 | struct peer *peer; | |
718e3744 | 4985 | |
d62a17ae | 4986 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4987 | if (!peer) | |
4988 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4989 | |
d62a17ae | 4990 | ret = peer_timers_connect_unset(peer); |
718e3744 | 4991 | |
d62a17ae | 4992 | return bgp_vty_return(vty, ret); |
718e3744 | 4993 | } |
4994 | ||
4995 | DEFUN (neighbor_timers_connect, | |
4996 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 4997 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 4998 | NEIGHBOR_STR |
966f821c | 4999 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5000 | "BGP per neighbor timers\n" |
5001 | "BGP connect timer\n" | |
5002 | "Connect timer\n") | |
5003 | { | |
d62a17ae | 5004 | int idx_peer = 1; |
5005 | int idx_number = 4; | |
5006 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5007 | argv[idx_number]->arg); | |
718e3744 | 5008 | } |
5009 | ||
5010 | DEFUN (no_neighbor_timers_connect, | |
5011 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5012 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5013 | NO_STR |
5014 | NEIGHBOR_STR | |
966f821c | 5015 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5016 | "BGP per neighbor timers\n" |
8334fd5a DW |
5017 | "BGP connect timer\n" |
5018 | "Connect timer\n") | |
718e3744 | 5019 | { |
d62a17ae | 5020 | int idx_peer = 2; |
5021 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5022 | } |
5023 | ||
6b0655a2 | 5024 | |
d62a17ae | 5025 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5026 | const char *time_str, int set) | |
718e3744 | 5027 | { |
d62a17ae | 5028 | int ret; |
5029 | struct peer *peer; | |
5030 | u_int32_t routeadv = 0; | |
718e3744 | 5031 | |
d62a17ae | 5032 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5033 | if (!peer) | |
5034 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5035 | |
d62a17ae | 5036 | if (time_str) |
5037 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5038 | |
d62a17ae | 5039 | if (set) |
5040 | ret = peer_advertise_interval_set(peer, routeadv); | |
5041 | else | |
5042 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5043 | |
d62a17ae | 5044 | return bgp_vty_return(vty, ret); |
718e3744 | 5045 | } |
5046 | ||
5047 | DEFUN (neighbor_advertise_interval, | |
5048 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5049 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5050 | NEIGHBOR_STR |
966f821c | 5051 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5052 | "Minimum interval between sending BGP routing updates\n" |
5053 | "time in seconds\n") | |
5054 | { | |
d62a17ae | 5055 | int idx_peer = 1; |
5056 | int idx_number = 3; | |
5057 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5058 | argv[idx_number]->arg, 1); | |
718e3744 | 5059 | } |
5060 | ||
5061 | DEFUN (no_neighbor_advertise_interval, | |
5062 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5063 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5064 | NO_STR |
5065 | NEIGHBOR_STR | |
966f821c | 5066 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5067 | "Minimum interval between sending BGP routing updates\n" |
5068 | "time in seconds\n") | |
718e3744 | 5069 | { |
d62a17ae | 5070 | int idx_peer = 2; |
5071 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5072 | } |
5073 | ||
6b0655a2 | 5074 | |
518f0eb1 DS |
5075 | /* Time to wait before processing route-map updates */ |
5076 | DEFUN (bgp_set_route_map_delay_timer, | |
5077 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5078 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5079 | SET_STR |
5080 | "BGP route-map delay timer\n" | |
5081 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5082 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5083 | { |
d62a17ae | 5084 | int idx_number = 3; |
5085 | u_int32_t rmap_delay_timer; | |
5086 | ||
5087 | if (argv[idx_number]->arg) { | |
5088 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
5089 | bm->rmap_update_timer = rmap_delay_timer; | |
5090 | ||
5091 | /* if the dynamic update handling is being disabled, and a timer | |
5092 | * is | |
5093 | * running, stop the timer and act as if the timer has already | |
5094 | * fired. | |
5095 | */ | |
5096 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
5097 | BGP_TIMER_OFF(bm->t_rmap_update); | |
5098 | thread_execute(bm->master, bgp_route_map_update_timer, | |
5099 | NULL, 0); | |
5100 | } | |
5101 | return CMD_SUCCESS; | |
5102 | } else { | |
5103 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5104 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5105 | } |
518f0eb1 DS |
5106 | } |
5107 | ||
5108 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5109 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5110 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5111 | NO_STR |
3a2d747c | 5112 | BGP_STR |
518f0eb1 | 5113 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5114 | "Reset to default time to wait for processing route-map changes\n" |
5115 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5116 | { |
518f0eb1 | 5117 | |
d62a17ae | 5118 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 5119 | |
d62a17ae | 5120 | return CMD_SUCCESS; |
518f0eb1 DS |
5121 | } |
5122 | ||
f414725f | 5123 | |
718e3744 | 5124 | /* neighbor interface */ |
d62a17ae | 5125 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
5126 | const char *str) | |
718e3744 | 5127 | { |
d62a17ae | 5128 | struct peer *peer; |
718e3744 | 5129 | |
d62a17ae | 5130 | peer = peer_lookup_vty(vty, ip_str); |
5131 | if (!peer || peer->conf_if) { | |
5132 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
5133 | return CMD_WARNING_CONFIG_FAILED; | |
5134 | } | |
718e3744 | 5135 | |
d62a17ae | 5136 | if (str) |
5137 | peer_interface_set(peer, str); | |
5138 | else | |
5139 | peer_interface_unset(peer); | |
718e3744 | 5140 | |
d62a17ae | 5141 | return CMD_SUCCESS; |
718e3744 | 5142 | } |
5143 | ||
5144 | DEFUN (neighbor_interface, | |
5145 | neighbor_interface_cmd, | |
9ccf14f7 | 5146 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5147 | NEIGHBOR_STR |
5148 | NEIGHBOR_ADDR_STR | |
5149 | "Interface\n" | |
5150 | "Interface name\n") | |
5151 | { | |
d62a17ae | 5152 | int idx_ip = 1; |
5153 | int idx_word = 3; | |
5154 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 5155 | } |
5156 | ||
5157 | DEFUN (no_neighbor_interface, | |
5158 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5159 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5160 | NO_STR |
5161 | NEIGHBOR_STR | |
16cedbb0 | 5162 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5163 | "Interface\n" |
5164 | "Interface name\n") | |
5165 | { | |
d62a17ae | 5166 | int idx_peer = 2; |
5167 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5168 | } |
6b0655a2 | 5169 | |
718e3744 | 5170 | DEFUN (neighbor_distribute_list, |
5171 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5172 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5173 | NEIGHBOR_STR |
5174 | NEIGHBOR_ADDR_STR2 | |
5175 | "Filter updates to/from this neighbor\n" | |
5176 | "IP access-list number\n" | |
5177 | "IP access-list number (expanded range)\n" | |
5178 | "IP Access-list name\n" | |
5179 | "Filter incoming updates\n" | |
5180 | "Filter outgoing updates\n") | |
5181 | { | |
d62a17ae | 5182 | int idx_peer = 1; |
5183 | int idx_acl = 3; | |
5184 | int direct, ret; | |
5185 | struct peer *peer; | |
a8206004 | 5186 | |
d62a17ae | 5187 | const char *pstr = argv[idx_peer]->arg; |
5188 | const char *acl = argv[idx_acl]->arg; | |
5189 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5190 | |
d62a17ae | 5191 | peer = peer_and_group_lookup_vty(vty, pstr); |
5192 | if (!peer) | |
5193 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5194 | |
d62a17ae | 5195 | /* Check filter direction. */ |
5196 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5197 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5198 | direct, acl); | |
a8206004 | 5199 | |
d62a17ae | 5200 | return bgp_vty_return(vty, ret); |
718e3744 | 5201 | } |
5202 | ||
d62a17ae | 5203 | ALIAS_HIDDEN( |
5204 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
5205 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5206 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5207 | "Filter updates to/from this neighbor\n" | |
5208 | "IP access-list number\n" | |
5209 | "IP access-list number (expanded range)\n" | |
5210 | "IP Access-list name\n" | |
5211 | "Filter incoming updates\n" | |
5212 | "Filter outgoing updates\n") | |
596c17ba | 5213 | |
718e3744 | 5214 | DEFUN (no_neighbor_distribute_list, |
5215 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5216 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5217 | NO_STR |
5218 | NEIGHBOR_STR | |
5219 | NEIGHBOR_ADDR_STR2 | |
5220 | "Filter updates to/from this neighbor\n" | |
5221 | "IP access-list number\n" | |
5222 | "IP access-list number (expanded range)\n" | |
5223 | "IP Access-list name\n" | |
5224 | "Filter incoming updates\n" | |
5225 | "Filter outgoing updates\n") | |
5226 | { | |
d62a17ae | 5227 | int idx_peer = 2; |
5228 | int direct, ret; | |
5229 | struct peer *peer; | |
a8206004 | 5230 | |
d62a17ae | 5231 | const char *pstr = argv[idx_peer]->arg; |
5232 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5233 | |
d62a17ae | 5234 | peer = peer_and_group_lookup_vty(vty, pstr); |
5235 | if (!peer) | |
5236 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5237 | |
d62a17ae | 5238 | /* Check filter direction. */ |
5239 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5240 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5241 | direct); | |
a8206004 | 5242 | |
d62a17ae | 5243 | return bgp_vty_return(vty, ret); |
718e3744 | 5244 | } |
6b0655a2 | 5245 | |
d62a17ae | 5246 | ALIAS_HIDDEN( |
5247 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
5248 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5249 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5250 | "Filter updates to/from this neighbor\n" | |
5251 | "IP access-list number\n" | |
5252 | "IP access-list number (expanded range)\n" | |
5253 | "IP Access-list name\n" | |
5254 | "Filter incoming updates\n" | |
5255 | "Filter outgoing updates\n") | |
596c17ba | 5256 | |
718e3744 | 5257 | /* Set prefix list to the peer. */ |
d62a17ae | 5258 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
5259 | afi_t afi, safi_t safi, | |
5260 | const char *name_str, | |
5261 | const char *direct_str) | |
718e3744 | 5262 | { |
d62a17ae | 5263 | int ret; |
5264 | struct peer *peer; | |
5265 | int direct = FILTER_IN; | |
718e3744 | 5266 | |
d62a17ae | 5267 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5268 | if (!peer) | |
5269 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5270 | |
d62a17ae | 5271 | /* Check filter direction. */ |
5272 | if (strncmp(direct_str, "i", 1) == 0) | |
5273 | direct = FILTER_IN; | |
5274 | else if (strncmp(direct_str, "o", 1) == 0) | |
5275 | direct = FILTER_OUT; | |
718e3744 | 5276 | |
d62a17ae | 5277 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 5278 | |
d62a17ae | 5279 | return bgp_vty_return(vty, ret); |
718e3744 | 5280 | } |
5281 | ||
d62a17ae | 5282 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
5283 | afi_t afi, safi_t safi, | |
5284 | const char *direct_str) | |
718e3744 | 5285 | { |
d62a17ae | 5286 | int ret; |
5287 | struct peer *peer; | |
5288 | int direct = FILTER_IN; | |
718e3744 | 5289 | |
d62a17ae | 5290 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5291 | if (!peer) | |
5292 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 5293 | |
d62a17ae | 5294 | /* Check filter direction. */ |
5295 | if (strncmp(direct_str, "i", 1) == 0) | |
5296 | direct = FILTER_IN; | |
5297 | else if (strncmp(direct_str, "o", 1) == 0) | |
5298 | direct = FILTER_OUT; | |
718e3744 | 5299 | |
d62a17ae | 5300 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 5301 | |
d62a17ae | 5302 | return bgp_vty_return(vty, ret); |
718e3744 | 5303 | } |
5304 | ||
5305 | DEFUN (neighbor_prefix_list, | |
5306 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5307 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5308 | NEIGHBOR_STR |
5309 | NEIGHBOR_ADDR_STR2 | |
5310 | "Filter updates to/from this neighbor\n" | |
5311 | "Name of a prefix list\n" | |
5312 | "Filter incoming updates\n" | |
5313 | "Filter outgoing updates\n") | |
5314 | { | |
d62a17ae | 5315 | int idx_peer = 1; |
5316 | int idx_word = 3; | |
5317 | int idx_in_out = 4; | |
5318 | return peer_prefix_list_set_vty( | |
5319 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5320 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5321 | } |
5322 | ||
d62a17ae | 5323 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
5324 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5325 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5326 | "Filter updates to/from this neighbor\n" | |
5327 | "Name of a prefix list\n" | |
5328 | "Filter incoming updates\n" | |
5329 | "Filter outgoing updates\n") | |
596c17ba | 5330 | |
718e3744 | 5331 | DEFUN (no_neighbor_prefix_list, |
5332 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5333 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5334 | NO_STR |
5335 | NEIGHBOR_STR | |
5336 | NEIGHBOR_ADDR_STR2 | |
5337 | "Filter updates to/from this neighbor\n" | |
5338 | "Name of a prefix list\n" | |
5339 | "Filter incoming updates\n" | |
5340 | "Filter outgoing updates\n") | |
5341 | { | |
d62a17ae | 5342 | int idx_peer = 2; |
5343 | int idx_in_out = 5; | |
5344 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
5345 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5346 | argv[idx_in_out]->arg); | |
718e3744 | 5347 | } |
6b0655a2 | 5348 | |
d62a17ae | 5349 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
5350 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5351 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5352 | "Filter updates to/from this neighbor\n" | |
5353 | "Name of a prefix list\n" | |
5354 | "Filter incoming updates\n" | |
5355 | "Filter outgoing updates\n") | |
596c17ba | 5356 | |
d62a17ae | 5357 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5358 | safi_t safi, const char *name_str, | |
5359 | const char *direct_str) | |
718e3744 | 5360 | { |
d62a17ae | 5361 | int ret; |
5362 | struct peer *peer; | |
5363 | int direct = FILTER_IN; | |
718e3744 | 5364 | |
d62a17ae | 5365 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5366 | if (!peer) | |
5367 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5368 | |
d62a17ae | 5369 | /* Check filter direction. */ |
5370 | if (strncmp(direct_str, "i", 1) == 0) | |
5371 | direct = FILTER_IN; | |
5372 | else if (strncmp(direct_str, "o", 1) == 0) | |
5373 | direct = FILTER_OUT; | |
718e3744 | 5374 | |
d62a17ae | 5375 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 5376 | |
d62a17ae | 5377 | return bgp_vty_return(vty, ret); |
718e3744 | 5378 | } |
5379 | ||
d62a17ae | 5380 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5381 | safi_t safi, const char *direct_str) | |
718e3744 | 5382 | { |
d62a17ae | 5383 | int ret; |
5384 | struct peer *peer; | |
5385 | int direct = FILTER_IN; | |
718e3744 | 5386 | |
d62a17ae | 5387 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5388 | if (!peer) | |
5389 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5390 | |
d62a17ae | 5391 | /* Check filter direction. */ |
5392 | if (strncmp(direct_str, "i", 1) == 0) | |
5393 | direct = FILTER_IN; | |
5394 | else if (strncmp(direct_str, "o", 1) == 0) | |
5395 | direct = FILTER_OUT; | |
718e3744 | 5396 | |
d62a17ae | 5397 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 5398 | |
d62a17ae | 5399 | return bgp_vty_return(vty, ret); |
718e3744 | 5400 | } |
5401 | ||
5402 | DEFUN (neighbor_filter_list, | |
5403 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5404 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5405 | NEIGHBOR_STR |
5406 | NEIGHBOR_ADDR_STR2 | |
5407 | "Establish BGP filters\n" | |
5408 | "AS path access-list name\n" | |
5409 | "Filter incoming routes\n" | |
5410 | "Filter outgoing routes\n") | |
5411 | { | |
d62a17ae | 5412 | int idx_peer = 1; |
5413 | int idx_word = 3; | |
5414 | int idx_in_out = 4; | |
5415 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5416 | bgp_node_safi(vty), argv[idx_word]->arg, | |
5417 | argv[idx_in_out]->arg); | |
718e3744 | 5418 | } |
5419 | ||
d62a17ae | 5420 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
5421 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5422 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5423 | "Establish BGP filters\n" | |
5424 | "AS path access-list name\n" | |
5425 | "Filter incoming routes\n" | |
5426 | "Filter outgoing routes\n") | |
596c17ba | 5427 | |
718e3744 | 5428 | DEFUN (no_neighbor_filter_list, |
5429 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5430 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5431 | NO_STR |
5432 | NEIGHBOR_STR | |
5433 | NEIGHBOR_ADDR_STR2 | |
5434 | "Establish BGP filters\n" | |
5435 | "AS path access-list name\n" | |
5436 | "Filter incoming routes\n" | |
5437 | "Filter outgoing routes\n") | |
5438 | { | |
d62a17ae | 5439 | int idx_peer = 2; |
5440 | int idx_in_out = 5; | |
5441 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
5442 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5443 | argv[idx_in_out]->arg); | |
718e3744 | 5444 | } |
6b0655a2 | 5445 | |
d62a17ae | 5446 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
5447 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5448 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5449 | "Establish BGP filters\n" | |
5450 | "AS path access-list name\n" | |
5451 | "Filter incoming routes\n" | |
5452 | "Filter outgoing routes\n") | |
596c17ba | 5453 | |
718e3744 | 5454 | /* Set route-map to the peer. */ |
d62a17ae | 5455 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
5456 | afi_t afi, safi_t safi, const char *name_str, | |
5457 | const char *direct_str) | |
718e3744 | 5458 | { |
d62a17ae | 5459 | int ret; |
5460 | struct peer *peer; | |
5461 | int direct = RMAP_IN; | |
718e3744 | 5462 | |
d62a17ae | 5463 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5464 | if (!peer) | |
5465 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5466 | |
d62a17ae | 5467 | /* Check filter direction. */ |
5468 | if (strncmp(direct_str, "in", 2) == 0) | |
5469 | direct = RMAP_IN; | |
5470 | else if (strncmp(direct_str, "o", 1) == 0) | |
5471 | direct = RMAP_OUT; | |
718e3744 | 5472 | |
d62a17ae | 5473 | ret = peer_route_map_set(peer, afi, safi, direct, name_str); |
718e3744 | 5474 | |
d62a17ae | 5475 | return bgp_vty_return(vty, ret); |
718e3744 | 5476 | } |
5477 | ||
d62a17ae | 5478 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
5479 | afi_t afi, safi_t safi, | |
5480 | const char *direct_str) | |
718e3744 | 5481 | { |
d62a17ae | 5482 | int ret; |
5483 | struct peer *peer; | |
5484 | int direct = RMAP_IN; | |
718e3744 | 5485 | |
d62a17ae | 5486 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5487 | if (!peer) | |
5488 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5489 | |
d62a17ae | 5490 | /* Check filter direction. */ |
5491 | if (strncmp(direct_str, "in", 2) == 0) | |
5492 | direct = RMAP_IN; | |
5493 | else if (strncmp(direct_str, "o", 1) == 0) | |
5494 | direct = RMAP_OUT; | |
718e3744 | 5495 | |
d62a17ae | 5496 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 5497 | |
d62a17ae | 5498 | return bgp_vty_return(vty, ret); |
718e3744 | 5499 | } |
5500 | ||
5501 | DEFUN (neighbor_route_map, | |
5502 | neighbor_route_map_cmd, | |
9ccf14f7 | 5503 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5504 | NEIGHBOR_STR |
5505 | NEIGHBOR_ADDR_STR2 | |
5506 | "Apply route map to neighbor\n" | |
5507 | "Name of route map\n" | |
5508 | "Apply map to incoming routes\n" | |
2a3d5731 | 5509 | "Apply map to outbound routes\n") |
718e3744 | 5510 | { |
d62a17ae | 5511 | int idx_peer = 1; |
5512 | int idx_word = 3; | |
5513 | int idx_in_out = 4; | |
5514 | return peer_route_map_set_vty( | |
5515 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5516 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5517 | } |
5518 | ||
d62a17ae | 5519 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
5520 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5521 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5522 | "Apply route map to neighbor\n" | |
5523 | "Name of route map\n" | |
5524 | "Apply map to incoming routes\n" | |
5525 | "Apply map to outbound routes\n") | |
596c17ba | 5526 | |
718e3744 | 5527 | DEFUN (no_neighbor_route_map, |
5528 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5529 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5530 | NO_STR |
5531 | NEIGHBOR_STR | |
5532 | NEIGHBOR_ADDR_STR2 | |
5533 | "Apply route map to neighbor\n" | |
5534 | "Name of route map\n" | |
5535 | "Apply map to incoming routes\n" | |
2a3d5731 | 5536 | "Apply map to outbound routes\n") |
718e3744 | 5537 | { |
d62a17ae | 5538 | int idx_peer = 2; |
5539 | int idx_in_out = 5; | |
5540 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
5541 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5542 | argv[idx_in_out]->arg); | |
718e3744 | 5543 | } |
6b0655a2 | 5544 | |
d62a17ae | 5545 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
5546 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5547 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5548 | "Apply route map to neighbor\n" | |
5549 | "Name of route map\n" | |
5550 | "Apply map to incoming routes\n" | |
5551 | "Apply map to outbound routes\n") | |
596c17ba | 5552 | |
718e3744 | 5553 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 5554 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
5555 | afi_t afi, safi_t safi, | |
5556 | const char *name_str) | |
718e3744 | 5557 | { |
d62a17ae | 5558 | int ret; |
5559 | struct peer *peer; | |
718e3744 | 5560 | |
d62a17ae | 5561 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5562 | if (!peer) | |
5563 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5564 | |
d62a17ae | 5565 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str); |
718e3744 | 5566 | |
d62a17ae | 5567 | return bgp_vty_return(vty, ret); |
718e3744 | 5568 | } |
5569 | ||
5570 | /* Unset route-map from the peer. */ | |
d62a17ae | 5571 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
5572 | afi_t afi, safi_t safi) | |
718e3744 | 5573 | { |
d62a17ae | 5574 | int ret; |
5575 | struct peer *peer; | |
718e3744 | 5576 | |
d62a17ae | 5577 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5578 | if (!peer) | |
5579 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5580 | |
d62a17ae | 5581 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 5582 | |
d62a17ae | 5583 | return bgp_vty_return(vty, ret); |
718e3744 | 5584 | } |
5585 | ||
5586 | DEFUN (neighbor_unsuppress_map, | |
5587 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5588 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5589 | NEIGHBOR_STR |
5590 | NEIGHBOR_ADDR_STR2 | |
5591 | "Route-map to selectively unsuppress suppressed routes\n" | |
5592 | "Name of route map\n") | |
5593 | { | |
d62a17ae | 5594 | int idx_peer = 1; |
5595 | int idx_word = 3; | |
5596 | return peer_unsuppress_map_set_vty( | |
5597 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5598 | argv[idx_word]->arg); | |
718e3744 | 5599 | } |
5600 | ||
d62a17ae | 5601 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
5602 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5603 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5604 | "Route-map to selectively unsuppress suppressed routes\n" | |
5605 | "Name of route map\n") | |
596c17ba | 5606 | |
718e3744 | 5607 | DEFUN (no_neighbor_unsuppress_map, |
5608 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5609 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5610 | NO_STR |
5611 | NEIGHBOR_STR | |
5612 | NEIGHBOR_ADDR_STR2 | |
5613 | "Route-map to selectively unsuppress suppressed routes\n" | |
5614 | "Name of route map\n") | |
5615 | { | |
d62a17ae | 5616 | int idx_peer = 2; |
5617 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
5618 | bgp_node_afi(vty), | |
5619 | bgp_node_safi(vty)); | |
718e3744 | 5620 | } |
6b0655a2 | 5621 | |
d62a17ae | 5622 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
5623 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5624 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5625 | "Route-map to selectively unsuppress suppressed routes\n" | |
5626 | "Name of route map\n") | |
596c17ba | 5627 | |
d62a17ae | 5628 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
5629 | afi_t afi, safi_t safi, | |
5630 | const char *num_str, | |
5631 | const char *threshold_str, int warning, | |
5632 | const char *restart_str) | |
718e3744 | 5633 | { |
d62a17ae | 5634 | int ret; |
5635 | struct peer *peer; | |
5636 | u_int32_t max; | |
5637 | u_char threshold; | |
5638 | u_int16_t restart; | |
718e3744 | 5639 | |
d62a17ae | 5640 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5641 | if (!peer) | |
5642 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5643 | |
d62a17ae | 5644 | max = strtoul(num_str, NULL, 10); |
5645 | if (threshold_str) | |
5646 | threshold = atoi(threshold_str); | |
5647 | else | |
5648 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5649 | |
d62a17ae | 5650 | if (restart_str) |
5651 | restart = atoi(restart_str); | |
5652 | else | |
5653 | restart = 0; | |
0a486e5f | 5654 | |
d62a17ae | 5655 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
5656 | restart); | |
718e3744 | 5657 | |
d62a17ae | 5658 | return bgp_vty_return(vty, ret); |
718e3744 | 5659 | } |
5660 | ||
d62a17ae | 5661 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
5662 | afi_t afi, safi_t safi) | |
718e3744 | 5663 | { |
d62a17ae | 5664 | int ret; |
5665 | struct peer *peer; | |
718e3744 | 5666 | |
d62a17ae | 5667 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5668 | if (!peer) | |
5669 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5670 | |
d62a17ae | 5671 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 5672 | |
d62a17ae | 5673 | return bgp_vty_return(vty, ret); |
718e3744 | 5674 | } |
5675 | ||
5676 | /* Maximum number of prefix configuration. prefix count is different | |
5677 | for each peer configuration. So this configuration can be set for | |
5678 | each peer configuration. */ | |
5679 | DEFUN (neighbor_maximum_prefix, | |
5680 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5681 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5682 | NEIGHBOR_STR |
5683 | NEIGHBOR_ADDR_STR2 | |
5684 | "Maximum number of prefix accept from this peer\n" | |
5685 | "maximum no. of prefix limit\n") | |
5686 | { | |
d62a17ae | 5687 | int idx_peer = 1; |
5688 | int idx_number = 3; | |
5689 | return peer_maximum_prefix_set_vty( | |
5690 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5691 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 5692 | } |
5693 | ||
d62a17ae | 5694 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
5695 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
5696 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5697 | "Maximum number of prefix accept from this peer\n" | |
5698 | "maximum no. of prefix limit\n") | |
596c17ba | 5699 | |
e0701b79 | 5700 | DEFUN (neighbor_maximum_prefix_threshold, |
5701 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5702 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5703 | NEIGHBOR_STR |
5704 | NEIGHBOR_ADDR_STR2 | |
5705 | "Maximum number of prefix accept from this peer\n" | |
5706 | "maximum no. of prefix limit\n" | |
5707 | "Threshold value (%) at which to generate a warning msg\n") | |
5708 | { | |
d62a17ae | 5709 | int idx_peer = 1; |
5710 | int idx_number = 3; | |
5711 | int idx_number_2 = 4; | |
5712 | return peer_maximum_prefix_set_vty( | |
5713 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5714 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 5715 | } |
e0701b79 | 5716 | |
d62a17ae | 5717 | ALIAS_HIDDEN( |
5718 | neighbor_maximum_prefix_threshold, | |
5719 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
5720 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
5721 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5722 | "Maximum number of prefix accept from this peer\n" | |
5723 | "maximum no. of prefix limit\n" | |
5724 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 5725 | |
718e3744 | 5726 | DEFUN (neighbor_maximum_prefix_warning, |
5727 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5728 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5729 | NEIGHBOR_STR |
5730 | NEIGHBOR_ADDR_STR2 | |
5731 | "Maximum number of prefix accept from this peer\n" | |
5732 | "maximum no. of prefix limit\n" | |
5733 | "Only give warning message when limit is exceeded\n") | |
5734 | { | |
d62a17ae | 5735 | int idx_peer = 1; |
5736 | int idx_number = 3; | |
5737 | return peer_maximum_prefix_set_vty( | |
5738 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5739 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 5740 | } |
5741 | ||
d62a17ae | 5742 | ALIAS_HIDDEN( |
5743 | neighbor_maximum_prefix_warning, | |
5744 | neighbor_maximum_prefix_warning_hidden_cmd, | |
5745 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
5746 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5747 | "Maximum number of prefix accept from this peer\n" | |
5748 | "maximum no. of prefix limit\n" | |
5749 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5750 | |
e0701b79 | 5751 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5752 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5753 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5754 | NEIGHBOR_STR |
5755 | NEIGHBOR_ADDR_STR2 | |
5756 | "Maximum number of prefix accept from this peer\n" | |
5757 | "maximum no. of prefix limit\n" | |
5758 | "Threshold value (%) at which to generate a warning msg\n" | |
5759 | "Only give warning message when limit is exceeded\n") | |
5760 | { | |
d62a17ae | 5761 | int idx_peer = 1; |
5762 | int idx_number = 3; | |
5763 | int idx_number_2 = 4; | |
5764 | return peer_maximum_prefix_set_vty( | |
5765 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5766 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5767 | } |
5768 | ||
d62a17ae | 5769 | ALIAS_HIDDEN( |
5770 | neighbor_maximum_prefix_threshold_warning, | |
5771 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
5772 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
5773 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5774 | "Maximum number of prefix accept from this peer\n" | |
5775 | "maximum no. of prefix limit\n" | |
5776 | "Threshold value (%) at which to generate a warning msg\n" | |
5777 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5778 | |
0a486e5f | 5779 | DEFUN (neighbor_maximum_prefix_restart, |
5780 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5781 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 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 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 5787 | "Restart interval in minutes\n") |
0a486e5f | 5788 | { |
d62a17ae | 5789 | int idx_peer = 1; |
5790 | int idx_number = 3; | |
5791 | int idx_number_2 = 5; | |
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, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 5795 | } |
5796 | ||
d62a17ae | 5797 | ALIAS_HIDDEN( |
5798 | neighbor_maximum_prefix_restart, | |
5799 | neighbor_maximum_prefix_restart_hidden_cmd, | |
5800 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
5801 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5802 | "Maximum number of prefix accept from this peer\n" | |
5803 | "maximum no. of prefix limit\n" | |
5804 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 5805 | "Restart interval in minutes\n") |
596c17ba | 5806 | |
0a486e5f | 5807 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
5808 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 5809 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 5810 | NEIGHBOR_STR |
5811 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5812 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 5813 | "maximum no. of prefix limit\n" |
5814 | "Threshold value (%) at which to generate a warning msg\n" | |
5815 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5816 | "Restart interval in minutes\n") |
0a486e5f | 5817 | { |
d62a17ae | 5818 | int idx_peer = 1; |
5819 | int idx_number = 3; | |
5820 | int idx_number_2 = 4; | |
5821 | int idx_number_3 = 6; | |
5822 | return peer_maximum_prefix_set_vty( | |
5823 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5824 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
5825 | argv[idx_number_3]->arg); | |
5826 | } | |
5827 | ||
5828 | ALIAS_HIDDEN( | |
5829 | neighbor_maximum_prefix_threshold_restart, | |
5830 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
5831 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
5832 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5833 | "Maximum number of prefixes to accept from this peer\n" | |
5834 | "maximum no. of prefix limit\n" | |
5835 | "Threshold value (%) at which to generate a warning msg\n" | |
5836 | "Restart bgp connection after limit is exceeded\n" | |
5837 | "Restart interval in minutes\n") | |
596c17ba | 5838 | |
718e3744 | 5839 | DEFUN (no_neighbor_maximum_prefix, |
5840 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 5841 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 5842 | NO_STR |
5843 | NEIGHBOR_STR | |
5844 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5845 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
5846 | "maximum no. of prefix limit\n" |
5847 | "Threshold value (%) at which to generate a warning msg\n" | |
5848 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5849 | "Restart interval in minutes\n" |
31500417 | 5850 | "Only give warning message when limit is exceeded\n") |
718e3744 | 5851 | { |
d62a17ae | 5852 | int idx_peer = 2; |
5853 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
5854 | bgp_node_afi(vty), | |
5855 | bgp_node_safi(vty)); | |
718e3744 | 5856 | } |
e52702f2 | 5857 | |
d62a17ae | 5858 | ALIAS_HIDDEN( |
5859 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
5860 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
5861 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5862 | "Maximum number of prefixes to accept from this peer\n" | |
5863 | "maximum no. of prefix limit\n" | |
5864 | "Threshold value (%) at which to generate a warning msg\n" | |
5865 | "Restart bgp connection after limit is exceeded\n" | |
5866 | "Restart interval in minutes\n" | |
5867 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5868 | |
718e3744 | 5869 | |
718e3744 | 5870 | /* "neighbor allowas-in" */ |
5871 | DEFUN (neighbor_allowas_in, | |
5872 | neighbor_allowas_in_cmd, | |
fd8503f5 | 5873 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5874 | NEIGHBOR_STR |
5875 | NEIGHBOR_ADDR_STR2 | |
31500417 | 5876 | "Accept as-path with my AS present in it\n" |
fd8503f5 QY |
5877 | "Number of occurances of AS number\n" |
5878 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5879 | { |
d62a17ae | 5880 | int idx_peer = 1; |
5881 | int idx_number_origin = 3; | |
5882 | int ret; | |
5883 | int origin = 0; | |
5884 | struct peer *peer; | |
5885 | int allow_num = 0; | |
5886 | ||
5887 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5888 | if (!peer) | |
5889 | return CMD_WARNING_CONFIG_FAILED; | |
5890 | ||
5891 | if (argc <= idx_number_origin) | |
5892 | allow_num = 3; | |
5893 | else { | |
5894 | if (argv[idx_number_origin]->type == WORD_TKN) | |
5895 | origin = 1; | |
5896 | else | |
5897 | allow_num = atoi(argv[idx_number_origin]->arg); | |
5898 | } | |
5899 | ||
5900 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5901 | allow_num, origin); | |
5902 | ||
5903 | return bgp_vty_return(vty, ret); | |
5904 | } | |
5905 | ||
5906 | ALIAS_HIDDEN( | |
5907 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
5908 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
5909 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5910 | "Accept as-path with my AS present in it\n" | |
5911 | "Number of occurances of AS number\n" | |
5912 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
596c17ba | 5913 | |
718e3744 | 5914 | DEFUN (no_neighbor_allowas_in, |
5915 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 5916 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5917 | NO_STR |
5918 | NEIGHBOR_STR | |
5919 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 5920 | "allow local ASN appears in aspath attribute\n" |
fd8503f5 QY |
5921 | "Number of occurances of AS number\n" |
5922 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5923 | { |
d62a17ae | 5924 | int idx_peer = 2; |
5925 | int ret; | |
5926 | struct peer *peer; | |
718e3744 | 5927 | |
d62a17ae | 5928 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5929 | if (!peer) | |
5930 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5931 | |
d62a17ae | 5932 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
5933 | bgp_node_safi(vty)); | |
718e3744 | 5934 | |
d62a17ae | 5935 | return bgp_vty_return(vty, ret); |
718e3744 | 5936 | } |
6b0655a2 | 5937 | |
d62a17ae | 5938 | ALIAS_HIDDEN( |
5939 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
5940 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
5941 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5942 | "allow local ASN appears in aspath attribute\n" | |
5943 | "Number of occurances of AS number\n" | |
5944 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
596c17ba | 5945 | |
fa411a21 NH |
5946 | DEFUN (neighbor_ttl_security, |
5947 | neighbor_ttl_security_cmd, | |
9ccf14f7 | 5948 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5949 | NEIGHBOR_STR |
5950 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5951 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
5952 | "Specify the maximum number of hops to the BGP peer\n" |
5953 | "Number of hops to BGP peer\n") | |
fa411a21 | 5954 | { |
d62a17ae | 5955 | int idx_peer = 1; |
5956 | int idx_number = 4; | |
5957 | struct peer *peer; | |
5958 | int gtsm_hops; | |
5959 | ||
5960 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5961 | if (!peer) | |
5962 | return CMD_WARNING_CONFIG_FAILED; | |
5963 | ||
5964 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
5965 | ||
5966 | /* | |
5967 | * If 'neighbor swpX', then this is for directly connected peers, | |
5968 | * we should not accept a ttl-security hops value greater than 1. | |
5969 | */ | |
5970 | if (peer->conf_if && (gtsm_hops > 1)) { | |
5971 | vty_out(vty, | |
5972 | "%s is directly connected peer, hops cannot exceed 1\n", | |
5973 | argv[idx_peer]->arg); | |
5974 | return CMD_WARNING_CONFIG_FAILED; | |
5975 | } | |
8cdabf90 | 5976 | |
d62a17ae | 5977 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
5978 | } |
5979 | ||
5980 | DEFUN (no_neighbor_ttl_security, | |
5981 | no_neighbor_ttl_security_cmd, | |
9ccf14f7 | 5982 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5983 | NO_STR |
5984 | NEIGHBOR_STR | |
5985 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5986 | "BGP ttl-security parameters\n" |
3a2d747c QY |
5987 | "Specify the maximum number of hops to the BGP peer\n" |
5988 | "Number of hops to BGP peer\n") | |
fa411a21 | 5989 | { |
d62a17ae | 5990 | int idx_peer = 2; |
5991 | struct peer *peer; | |
fa411a21 | 5992 | |
d62a17ae | 5993 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5994 | if (!peer) | |
5995 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 5996 | |
d62a17ae | 5997 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 5998 | } |
6b0655a2 | 5999 | |
adbac85e DW |
6000 | DEFUN (neighbor_addpath_tx_all_paths, |
6001 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6002 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6003 | NEIGHBOR_STR |
6004 | NEIGHBOR_ADDR_STR2 | |
6005 | "Use addpath to advertise all paths to a neighbor\n") | |
6006 | { | |
d62a17ae | 6007 | int idx_peer = 1; |
6008 | struct peer *peer; | |
adbac85e | 6009 | |
d62a17ae | 6010 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6011 | if (!peer) | |
6012 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6013 | |
d62a17ae | 6014 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6015 | bgp_node_safi(vty), | |
6016 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
adbac85e DW |
6017 | } |
6018 | ||
d62a17ae | 6019 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6020 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6021 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6022 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6023 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6024 | |
adbac85e DW |
6025 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6026 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6027 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6028 | NO_STR |
6029 | NEIGHBOR_STR | |
6030 | NEIGHBOR_ADDR_STR2 | |
6031 | "Use addpath to advertise all paths to a neighbor\n") | |
6032 | { | |
d62a17ae | 6033 | int idx_peer = 2; |
6034 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6035 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6036 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
adbac85e DW |
6037 | } |
6038 | ||
d62a17ae | 6039 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6040 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6041 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6042 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6043 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6044 | |
06370dac DW |
6045 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6046 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6047 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6048 | NEIGHBOR_STR |
6049 | NEIGHBOR_ADDR_STR2 | |
6050 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6051 | { | |
d62a17ae | 6052 | int idx_peer = 1; |
6053 | struct peer *peer; | |
06370dac | 6054 | |
d62a17ae | 6055 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6056 | if (!peer) | |
6057 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 6058 | |
d62a17ae | 6059 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6060 | bgp_node_safi(vty), | |
6061 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
06370dac DW |
6062 | } |
6063 | ||
d62a17ae | 6064 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
6065 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6066 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6067 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6068 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6069 | |
06370dac DW |
6070 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
6071 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6072 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6073 | NO_STR |
6074 | NEIGHBOR_STR | |
6075 | NEIGHBOR_ADDR_STR2 | |
6076 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6077 | { | |
d62a17ae | 6078 | int idx_peer = 2; |
6079 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6080 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6081 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
06370dac DW |
6082 | } |
6083 | ||
d62a17ae | 6084 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
6085 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6086 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6087 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6088 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6089 | |
505e5056 | 6090 | DEFUN_NOSH (address_family_ipv4_safi, |
718e3744 | 6091 | address_family_ipv4_safi_cmd, |
5b1f0f29 | 6092 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast>]", |
718e3744 | 6093 | "Enter Address Family command mode\n" |
8c3deaae | 6094 | "Address Family\n" |
b6ab5a3a | 6095 | BGP_SAFI_WITH_LABEL_HELP_STR) |
718e3744 | 6096 | { |
f51bae9c | 6097 | |
d62a17ae | 6098 | if (argc == 3) { |
2131d5cf | 6099 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 6100 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
2131d5cf LB |
6101 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT && |
6102 | safi != SAFI_UNICAST && safi != SAFI_MULTICAST) { | |
6103 | vty_out(vty, "Only Unicast and Multicast SAFIs supported in non-core instances.\n"); | |
6104 | return CMD_WARNING_CONFIG_FAILED; | |
6105 | } | |
d62a17ae | 6106 | vty->node = bgp_node_type(AFI_IP, safi); |
6107 | } else | |
6108 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 6109 | |
d62a17ae | 6110 | return CMD_SUCCESS; |
718e3744 | 6111 | } |
6112 | ||
505e5056 | 6113 | DEFUN_NOSH (address_family_ipv6_safi, |
25ffbdc1 | 6114 | address_family_ipv6_safi_cmd, |
5b1f0f29 | 6115 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast>]", |
718e3744 | 6116 | "Enter Address Family command mode\n" |
8c3deaae | 6117 | "Address Family\n" |
b6ab5a3a | 6118 | BGP_SAFI_WITH_LABEL_HELP_STR) |
25ffbdc1 | 6119 | { |
d62a17ae | 6120 | if (argc == 3) { |
2131d5cf | 6121 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 6122 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
2131d5cf LB |
6123 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT && |
6124 | safi != SAFI_UNICAST && safi != SAFI_MULTICAST) { | |
6125 | vty_out(vty, "Only Unicast and Multicast SAFIs supported in non-core instances.\n"); | |
6126 | return CMD_WARNING_CONFIG_FAILED; | |
6127 | } | |
d62a17ae | 6128 | vty->node = bgp_node_type(AFI_IP6, safi); |
6129 | } else | |
6130 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 6131 | |
d62a17ae | 6132 | return CMD_SUCCESS; |
25ffbdc1 | 6133 | } |
718e3744 | 6134 | |
d6902373 | 6135 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 6136 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 6137 | address_family_vpnv4_cmd, |
8334fd5a | 6138 | "address-family vpnv4 [unicast]", |
718e3744 | 6139 | "Enter Address Family command mode\n" |
8c3deaae | 6140 | "Address Family\n" |
3a2d747c | 6141 | "Address Family modifier\n") |
718e3744 | 6142 | { |
d62a17ae | 6143 | vty->node = BGP_VPNV4_NODE; |
6144 | return CMD_SUCCESS; | |
718e3744 | 6145 | } |
6146 | ||
505e5056 | 6147 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 6148 | address_family_vpnv6_cmd, |
8334fd5a | 6149 | "address-family vpnv6 [unicast]", |
8ecd3266 | 6150 | "Enter Address Family command mode\n" |
8c3deaae | 6151 | "Address Family\n" |
3a2d747c | 6152 | "Address Family modifier\n") |
8ecd3266 | 6153 | { |
d62a17ae | 6154 | vty->node = BGP_VPNV6_NODE; |
6155 | return CMD_SUCCESS; | |
8ecd3266 | 6156 | } |
c016b6c7 | 6157 | #endif |
d6902373 | 6158 | |
505e5056 | 6159 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 6160 | address_family_evpn_cmd, |
7111c1a0 | 6161 | "address-family l2vpn evpn", |
4e0b7b6d | 6162 | "Enter Address Family command mode\n" |
7111c1a0 QY |
6163 | "Address Family\n" |
6164 | "Address Family modifier\n") | |
4e0b7b6d | 6165 | { |
2131d5cf LB |
6166 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6167 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) { | |
6168 | vty_out(vty, "Only Unicast and Multicast SAFIs supported in non-core instances.\n"); | |
6169 | return CMD_WARNING_CONFIG_FAILED; | |
6170 | } | |
d62a17ae | 6171 | vty->node = BGP_EVPN_NODE; |
6172 | return CMD_SUCCESS; | |
4e0b7b6d PG |
6173 | } |
6174 | ||
505e5056 | 6175 | DEFUN_NOSH (exit_address_family, |
718e3744 | 6176 | exit_address_family_cmd, |
6177 | "exit-address-family", | |
6178 | "Exit from Address Family configuration mode\n") | |
6179 | { | |
d62a17ae | 6180 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
6181 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
6182 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
6183 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
6184 | || vty->node == BGP_EVPN_NODE) | |
6185 | vty->node = BGP_NODE; | |
6186 | return CMD_SUCCESS; | |
718e3744 | 6187 | } |
6b0655a2 | 6188 | |
8ad7271d | 6189 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 6190 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
6191 | const char *ip_str, afi_t afi, safi_t safi, | |
6192 | struct prefix_rd *prd) | |
6193 | { | |
6194 | int ret; | |
6195 | struct prefix match; | |
6196 | struct bgp_node *rn; | |
6197 | struct bgp_node *rm; | |
6198 | struct bgp *bgp; | |
6199 | struct bgp_table *table; | |
6200 | struct bgp_table *rib; | |
6201 | ||
6202 | /* BGP structure lookup. */ | |
6203 | if (view_name) { | |
6204 | bgp = bgp_lookup_by_name(view_name); | |
6205 | if (bgp == NULL) { | |
6206 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
6207 | view_name); | |
6208 | return CMD_WARNING; | |
6209 | } | |
6210 | } else { | |
6211 | bgp = bgp_get_default(); | |
6212 | if (bgp == NULL) { | |
6213 | vty_out(vty, "%% No BGP process is configured\n"); | |
6214 | return CMD_WARNING; | |
6215 | } | |
6216 | } | |
6217 | ||
6218 | /* Check IP address argument. */ | |
6219 | ret = str2prefix(ip_str, &match); | |
6220 | if (!ret) { | |
6221 | vty_out(vty, "%% address is malformed\n"); | |
6222 | return CMD_WARNING; | |
6223 | } | |
6224 | ||
6225 | match.family = afi2family(afi); | |
6226 | rib = bgp->rib[afi][safi]; | |
6227 | ||
6228 | if (safi == SAFI_MPLS_VPN) { | |
6229 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
6230 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
6231 | continue; | |
6232 | ||
6233 | if ((table = rn->info) != NULL) { | |
6234 | if ((rm = bgp_node_match(table, &match)) | |
6235 | != NULL) { | |
6236 | if (rm->p.prefixlen | |
6237 | == match.prefixlen) { | |
6238 | SET_FLAG(rn->flags, | |
6239 | BGP_NODE_USER_CLEAR); | |
6240 | bgp_process(bgp, rm, afi, safi); | |
6241 | } | |
6242 | bgp_unlock_node(rm); | |
6243 | } | |
6244 | } | |
6245 | } | |
6246 | } else { | |
6247 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
6248 | if (rn->p.prefixlen == match.prefixlen) { | |
6249 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
6250 | bgp_process(bgp, rn, afi, safi); | |
6251 | } | |
6252 | bgp_unlock_node(rn); | |
6253 | } | |
6254 | } | |
6255 | ||
6256 | return CMD_SUCCESS; | |
8ad7271d DS |
6257 | } |
6258 | ||
b09b5ae0 | 6259 | /* one clear bgp command to rule them all */ |
718e3744 | 6260 | DEFUN (clear_ip_bgp_all, |
6261 | clear_ip_bgp_all_cmd, | |
c1a44e43 | 6262 | "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 | 6263 | CLEAR_STR |
6264 | IP_STR | |
6265 | BGP_STR | |
838758ac | 6266 | BGP_INSTANCE_HELP_STR |
510afcd6 DS |
6267 | BGP_AFI_HELP_STR |
6268 | BGP_SAFI_WITH_LABEL_HELP_STR | |
b09b5ae0 DW |
6269 | "Clear all peers\n" |
6270 | "BGP neighbor address to clear\n" | |
a80beece | 6271 | "BGP IPv6 neighbor to clear\n" |
838758ac | 6272 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
6273 | "Clear peers with the AS number\n" |
6274 | "Clear all external peers\n" | |
718e3744 | 6275 | "Clear all members of peer-group\n" |
b09b5ae0 | 6276 | "BGP peer-group name\n" |
b09b5ae0 DW |
6277 | BGP_SOFT_STR |
6278 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
6279 | BGP_SOFT_OUT_STR |
6280 | BGP_SOFT_IN_STR | |
6281 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 6282 | BGP_SOFT_OUT_STR) |
718e3744 | 6283 | { |
d62a17ae | 6284 | char *vrf = NULL; |
6285 | ||
6286 | afi_t afi = AFI_IP6; | |
6287 | safi_t safi = SAFI_UNICAST; | |
6288 | enum clear_sort clr_sort = clear_peer; | |
6289 | enum bgp_clear_type clr_type; | |
6290 | char *clr_arg = NULL; | |
6291 | ||
6292 | int idx = 0; | |
6293 | ||
6294 | /* clear [ip] bgp */ | |
6295 | if (argv_find(argv, argc, "ip", &idx)) | |
6296 | afi = AFI_IP; | |
6297 | ||
6298 | /* [<view|vrf> VIEWVRFNAME] */ | |
6299 | if (argv_find(argv, argc, "view", &idx) | |
6300 | || argv_find(argv, argc, "vrf", &idx)) { | |
6301 | vrf = argv[idx + 1]->arg; | |
6302 | idx += 2; | |
6303 | } | |
6304 | ||
6305 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
6306 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
6307 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
6308 | ||
6309 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ | |
6310 | if (argv_find(argv, argc, "*", &idx)) { | |
6311 | clr_sort = clear_all; | |
6312 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
6313 | clr_sort = clear_peer; | |
6314 | clr_arg = argv[idx]->arg; | |
6315 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
6316 | clr_sort = clear_peer; | |
6317 | clr_arg = argv[idx]->arg; | |
6318 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
6319 | clr_sort = clear_group; | |
6320 | idx++; | |
6321 | clr_arg = argv[idx]->arg; | |
6322 | } else if (argv_find(argv, argc, "WORD", &idx)) { | |
6323 | clr_sort = clear_peer; | |
6324 | clr_arg = argv[idx]->arg; | |
6325 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { | |
6326 | clr_sort = clear_as; | |
6327 | clr_arg = argv[idx]->arg; | |
6328 | } else if (argv_find(argv, argc, "external", &idx)) { | |
6329 | clr_sort = clear_external; | |
6330 | } | |
6331 | ||
6332 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
6333 | if (argv_find(argv, argc, "soft", &idx)) { | |
6334 | if (argv_find(argv, argc, "in", &idx) | |
6335 | || argv_find(argv, argc, "out", &idx)) | |
6336 | clr_type = strmatch(argv[idx]->text, "in") | |
6337 | ? BGP_CLEAR_SOFT_IN | |
6338 | : BGP_CLEAR_SOFT_OUT; | |
6339 | else | |
6340 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
6341 | } else if (argv_find(argv, argc, "in", &idx)) { | |
6342 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
6343 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
6344 | : BGP_CLEAR_SOFT_IN; | |
6345 | } else if (argv_find(argv, argc, "out", &idx)) { | |
6346 | clr_type = BGP_CLEAR_SOFT_OUT; | |
6347 | } else | |
6348 | clr_type = BGP_CLEAR_SOFT_NONE; | |
6349 | ||
6350 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 6351 | } |
01080f7c | 6352 | |
8ad7271d DS |
6353 | DEFUN (clear_ip_bgp_prefix, |
6354 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 6355 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
6356 | CLEAR_STR |
6357 | IP_STR | |
6358 | BGP_STR | |
838758ac | 6359 | BGP_INSTANCE_HELP_STR |
8ad7271d | 6360 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6361 | "IPv4 prefix\n") |
8ad7271d | 6362 | { |
d62a17ae | 6363 | char *vrf = NULL; |
6364 | char *prefix = NULL; | |
8ad7271d | 6365 | |
d62a17ae | 6366 | int idx = 0; |
01080f7c | 6367 | |
d62a17ae | 6368 | /* [<view|vrf> VIEWVRFNAME] */ |
1d35f218 | 6369 | if (argv_find(argv, argc, "VIEWVRFNAME", &idx)) |
d62a17ae | 6370 | vrf = argv[idx]->arg; |
0c7b1b01 | 6371 | |
d62a17ae | 6372 | prefix = argv[argc - 1]->arg; |
8ad7271d | 6373 | |
d62a17ae | 6374 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 6375 | } |
8ad7271d | 6376 | |
b09b5ae0 DW |
6377 | DEFUN (clear_bgp_ipv6_safi_prefix, |
6378 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 6379 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6380 | CLEAR_STR |
3a2d747c | 6381 | IP_STR |
718e3744 | 6382 | BGP_STR |
8c3deaae | 6383 | "Address Family\n" |
46f296b4 | 6384 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6385 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6386 | "IPv6 prefix\n") |
718e3744 | 6387 | { |
d62a17ae | 6388 | int idx_safi = 3; |
6389 | int idx_ipv6_prefixlen = 5; | |
6390 | return bgp_clear_prefix( | |
6391 | vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, | |
6392 | bgp_vty_safi_from_str(argv[idx_safi]->text), NULL); | |
838758ac | 6393 | } |
01080f7c | 6394 | |
b09b5ae0 DW |
6395 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
6396 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 6397 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6398 | CLEAR_STR |
3a2d747c | 6399 | IP_STR |
718e3744 | 6400 | BGP_STR |
838758ac | 6401 | BGP_INSTANCE_HELP_STR |
8c3deaae | 6402 | "Address Family\n" |
46f296b4 | 6403 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6404 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6405 | "IPv6 prefix\n") |
718e3744 | 6406 | { |
d62a17ae | 6407 | int idx_word = 3; |
6408 | int idx_safi = 5; | |
6409 | int idx_ipv6_prefixlen = 7; | |
6410 | return bgp_clear_prefix( | |
6411 | vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, | |
6412 | AFI_IP6, bgp_vty_safi_from_str(argv[idx_safi]->text), NULL); | |
718e3744 | 6413 | } |
6414 | ||
b09b5ae0 DW |
6415 | DEFUN (show_bgp_views, |
6416 | show_bgp_views_cmd, | |
d6e3c605 | 6417 | "show [ip] bgp views", |
b09b5ae0 | 6418 | SHOW_STR |
d6e3c605 | 6419 | IP_STR |
01080f7c | 6420 | BGP_STR |
b09b5ae0 | 6421 | "Show the defined BGP views\n") |
01080f7c | 6422 | { |
d62a17ae | 6423 | struct list *inst = bm->bgp; |
6424 | struct listnode *node; | |
6425 | struct bgp *bgp; | |
01080f7c | 6426 | |
d62a17ae | 6427 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { |
6428 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
6429 | return CMD_WARNING; | |
6430 | } | |
e52702f2 | 6431 | |
d62a17ae | 6432 | vty_out(vty, "Defined BGP views:\n"); |
6433 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
6434 | /* Skip VRFs. */ | |
6435 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
6436 | continue; | |
6437 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
6438 | bgp->as); | |
6439 | } | |
e52702f2 | 6440 | |
d62a17ae | 6441 | return CMD_SUCCESS; |
e0081f70 ML |
6442 | } |
6443 | ||
8386ac43 | 6444 | DEFUN (show_bgp_vrfs, |
6445 | show_bgp_vrfs_cmd, | |
d6e3c605 | 6446 | "show [ip] bgp vrfs [json]", |
8386ac43 | 6447 | SHOW_STR |
d6e3c605 | 6448 | IP_STR |
8386ac43 | 6449 | BGP_STR |
6450 | "Show BGP VRFs\n" | |
9973d184 | 6451 | JSON_STR) |
8386ac43 | 6452 | { |
d62a17ae | 6453 | struct list *inst = bm->bgp; |
6454 | struct listnode *node; | |
6455 | struct bgp *bgp; | |
6456 | u_char uj = use_json(argc, argv); | |
6457 | json_object *json = NULL; | |
6458 | json_object *json_vrfs = NULL; | |
6459 | int count = 0; | |
6460 | static char header[] = | |
6461 | "Type Id RouterId #PeersCfg #PeersEstb Name"; | |
6462 | ||
6463 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { | |
6464 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
6465 | return CMD_WARNING; | |
6466 | } | |
6467 | ||
6468 | if (uj) { | |
6469 | json = json_object_new_object(); | |
6470 | json_vrfs = json_object_new_object(); | |
6471 | } | |
6472 | ||
6473 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
6474 | const char *name, *type; | |
6475 | struct peer *peer; | |
6476 | struct listnode *node, *nnode; | |
6477 | int peers_cfg, peers_estb; | |
6478 | json_object *json_vrf = NULL; | |
6479 | int vrf_id_ui; | |
6480 | ||
6481 | /* Skip Views. */ | |
6482 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
6483 | continue; | |
6484 | ||
6485 | count++; | |
6486 | if (!uj && count == 1) | |
6487 | vty_out(vty, "%s\n", header); | |
6488 | ||
6489 | peers_cfg = peers_estb = 0; | |
6490 | if (uj) | |
6491 | json_vrf = json_object_new_object(); | |
6492 | ||
6493 | ||
6494 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
6495 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6496 | continue; | |
6497 | peers_cfg++; | |
6498 | if (peer->status == Established) | |
6499 | peers_estb++; | |
6500 | } | |
6501 | ||
6502 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
6503 | name = "Default"; | |
6504 | type = "DFLT"; | |
6505 | } else { | |
6506 | name = bgp->name; | |
6507 | type = "VRF"; | |
6508 | } | |
6509 | ||
6510 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; | |
6511 | if (uj) { | |
6512 | json_object_string_add(json_vrf, "type", type); | |
6513 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
6514 | json_object_string_add(json_vrf, "routerId", | |
6515 | inet_ntoa(bgp->router_id)); | |
6516 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
6517 | peers_cfg); | |
6518 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
6519 | peers_estb); | |
6520 | ||
6521 | json_object_object_add(json_vrfs, name, json_vrf); | |
6522 | } else | |
6523 | vty_out(vty, "%4s %-5d %-16s %9u %10u %s\n", type, | |
6524 | vrf_id_ui, inet_ntoa(bgp->router_id), peers_cfg, | |
6525 | peers_estb, name); | |
6526 | } | |
6527 | ||
6528 | if (uj) { | |
6529 | json_object_object_add(json, "vrfs", json_vrfs); | |
6530 | ||
6531 | json_object_int_add(json, "totalVrfs", count); | |
6532 | ||
9d303b37 DL |
6533 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
6534 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 6535 | json_object_free(json); |
6536 | } else { | |
6537 | if (count) | |
6538 | vty_out(vty, | |
6539 | "\nTotal number of VRFs (including default): %d\n", | |
6540 | count); | |
6541 | } | |
6542 | ||
6543 | return CMD_SUCCESS; | |
8386ac43 | 6544 | } |
6545 | ||
acf71666 MK |
6546 | static void show_address_entry(struct hash_backet *backet, void *args) |
6547 | { | |
60466a63 QY |
6548 | struct vty *vty = (struct vty *)args; |
6549 | struct bgp_addr *addr = (struct bgp_addr *)backet->data; | |
acf71666 | 6550 | |
60466a63 | 6551 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(addr->addr), |
acf71666 MK |
6552 | addr->refcnt); |
6553 | } | |
6554 | ||
6555 | static void show_tip_entry(struct hash_backet *backet, void *args) | |
6556 | { | |
0291c246 | 6557 | struct vty *vty = (struct vty *)args; |
60466a63 | 6558 | struct tip_addr *tip = (struct tip_addr *)backet->data; |
acf71666 | 6559 | |
60466a63 | 6560 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
6561 | tip->refcnt); |
6562 | } | |
6563 | ||
6564 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
6565 | { | |
6566 | vty_out(vty, "self nexthop database:\n"); | |
6567 | hash_iterate(bgp->address_hash, | |
6568 | (void (*)(struct hash_backet *, void *))show_address_entry, | |
6569 | vty); | |
6570 | ||
6571 | vty_out(vty, "Tunnel-ip database:\n"); | |
6572 | hash_iterate(bgp->tip_hash, | |
6573 | (void (*)(struct hash_backet *, void *))show_tip_entry, | |
6574 | vty); | |
6575 | } | |
6576 | ||
60466a63 QY |
6577 | DEFUN(show_bgp_martian_nexthop_db, |
6578 | show_bgp_martian_nexthop_db_cmd, | |
6579 | "show bgp martian next-hop", | |
6580 | SHOW_STR | |
6581 | BGP_STR | |
6582 | "martian next-hops\n" | |
6583 | "martian next-hop database\n") | |
acf71666 | 6584 | { |
0291c246 | 6585 | struct bgp *bgp = NULL; |
acf71666 MK |
6586 | |
6587 | bgp = bgp_get_default(); | |
6588 | if (!bgp) { | |
6589 | vty_out(vty, "%% No BGP process is configured\n"); | |
6590 | return CMD_WARNING; | |
6591 | } | |
6592 | bgp_show_martian_nexthops(vty, bgp); | |
6593 | ||
6594 | return CMD_SUCCESS; | |
6595 | } | |
6596 | ||
f412b39a | 6597 | DEFUN (show_bgp_memory, |
4bf6a362 | 6598 | show_bgp_memory_cmd, |
7fa12b13 | 6599 | "show [ip] bgp memory", |
4bf6a362 | 6600 | SHOW_STR |
3a2d747c | 6601 | IP_STR |
4bf6a362 PJ |
6602 | BGP_STR |
6603 | "Global BGP memory statistics\n") | |
6604 | { | |
d62a17ae | 6605 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
6606 | unsigned long count; | |
6607 | ||
6608 | /* RIB related usage stats */ | |
6609 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
6610 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
6611 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6612 | count * sizeof(struct bgp_node))); | |
6613 | ||
6614 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
6615 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
6616 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6617 | count * sizeof(struct bgp_info))); | |
6618 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) | |
6619 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
6620 | count, | |
6621 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6622 | count * sizeof(struct bgp_info_extra))); | |
6623 | ||
6624 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
6625 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
6626 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6627 | count * sizeof(struct bgp_static))); | |
6628 | ||
6629 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
6630 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
6631 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6632 | count * sizeof(struct bpacket))); | |
6633 | ||
6634 | /* Adj-In/Out */ | |
6635 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
6636 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
6637 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6638 | count * sizeof(struct bgp_adj_in))); | |
6639 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
6640 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
6641 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6642 | count * sizeof(struct bgp_adj_out))); | |
6643 | ||
6644 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
6645 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
6646 | count, | |
6647 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6648 | count * sizeof(struct bgp_nexthop_cache))); | |
6649 | ||
6650 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
6651 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
6652 | count, | |
6653 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6654 | count * sizeof(struct bgp_damp_info))); | |
6655 | ||
6656 | /* Attributes */ | |
6657 | count = attr_count(); | |
6658 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
6659 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6660 | count * sizeof(struct attr))); | |
6661 | ||
6662 | if ((count = attr_unknown_count())) | |
6663 | vty_out(vty, "%ld unknown attributes\n", count); | |
6664 | ||
6665 | /* AS_PATH attributes */ | |
6666 | count = aspath_count(); | |
6667 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
6668 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6669 | count * sizeof(struct aspath))); | |
6670 | ||
6671 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
6672 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
6673 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6674 | count * sizeof(struct assegment))); | |
6675 | ||
6676 | /* Other attributes */ | |
6677 | if ((count = community_count())) | |
6678 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
9d303b37 DL |
6679 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
6680 | count * sizeof(struct community))); | |
d62a17ae | 6681 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
6682 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
9d303b37 DL |
6683 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
6684 | count * sizeof(struct ecommunity))); | |
d62a17ae | 6685 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
6686 | vty_out(vty, | |
6687 | "%ld BGP large-community entries, using %s of memory\n", | |
9d303b37 DL |
6688 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
6689 | count * sizeof(struct lcommunity))); | |
d62a17ae | 6690 | |
6691 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
6692 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
6693 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6694 | count * sizeof(struct cluster_list))); | |
6695 | ||
6696 | /* Peer related usage */ | |
6697 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
6698 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
6699 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6700 | count * sizeof(struct peer))); | |
6701 | ||
6702 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
6703 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
6704 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6705 | count * sizeof(struct peer_group))); | |
6706 | ||
6707 | /* Other */ | |
6708 | if ((count = mtype_stats_alloc(MTYPE_HASH))) | |
6709 | vty_out(vty, "%ld hash tables, using %s of memory\n", count, | |
6710 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6711 | count * sizeof(struct hash))); | |
6712 | if ((count = mtype_stats_alloc(MTYPE_HASH_BACKET))) | |
6713 | vty_out(vty, "%ld hash buckets, using %s of memory\n", count, | |
6714 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6715 | count * sizeof(struct hash_backet))); | |
6716 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) | |
6717 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
9d303b37 DL |
6718 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
6719 | count * sizeof(regex_t))); | |
d62a17ae | 6720 | return CMD_SUCCESS; |
4bf6a362 | 6721 | } |
fee0f4c6 | 6722 | |
57a9c8a8 DS |
6723 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
6724 | { | |
6725 | json_object *bestpath = json_object_new_object(); | |
6726 | ||
6727 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
6728 | json_object_string_add(bestpath, "asPath", "ignore"); | |
6729 | ||
6730 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
6731 | json_object_string_add(bestpath, "asPath", "confed"); | |
6732 | ||
6733 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
6734 | if (bgp_flag_check(bgp, | |
6735 | BGP_FLAG_MULTIPATH_RELAX_AS_SET)) | |
6736 | json_object_string_add(bestpath, | |
6737 | "multiPathRelax", | |
6738 | "as-set"); | |
6739 | else | |
6740 | json_object_string_add(bestpath, | |
6741 | "multiPathRelax", | |
6742 | "true"); | |
6743 | } else | |
6744 | json_object_string_add(bestpath, | |
6745 | "multiPathRelax", | |
6746 | "false"); | |
6747 | ||
6748 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
6749 | json_object_string_add(bestpath, "compareRouterId", "true"); | |
6750 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
6751 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
6752 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
6753 | json_object_string_add(bestpath, "med", | |
6754 | "confed"); | |
6755 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) | |
6756 | json_object_string_add(bestpath, "med", | |
6757 | "missing-as-worst"); | |
6758 | else | |
6759 | json_object_string_add(bestpath, "med", "true"); | |
6760 | } | |
6761 | ||
6762 | json_object_object_add(json, "bestPath", bestpath); | |
6763 | } | |
6764 | ||
718e3744 | 6765 | /* Show BGP peer's summary information. */ |
d62a17ae | 6766 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
6767 | u_char use_json, json_object *json) | |
6768 | { | |
6769 | struct peer *peer; | |
6770 | struct listnode *node, *nnode; | |
6771 | unsigned int count = 0, dn_count = 0; | |
6772 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
6773 | char neighbor_buf[VTY_BUFSIZ]; | |
6774 | int neighbor_col_default_width = 16; | |
6775 | int len; | |
6776 | int max_neighbor_width = 0; | |
6777 | int pfx_rcd_safi; | |
6778 | json_object *json_peer = NULL; | |
6779 | json_object *json_peers = NULL; | |
6780 | ||
6781 | /* labeled-unicast routes are installed in the unicast table so in order | |
6782 | * to | |
6783 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
6784 | */ | |
6785 | if (safi == SAFI_LABELED_UNICAST) | |
6786 | pfx_rcd_safi = SAFI_UNICAST; | |
6787 | else | |
6788 | pfx_rcd_safi = safi; | |
6789 | ||
6790 | if (use_json) { | |
6791 | if (json == NULL) | |
6792 | json = json_object_new_object(); | |
6793 | ||
6794 | json_peers = json_object_new_object(); | |
6795 | } else { | |
6796 | /* Loop over all neighbors that will be displayed to determine | |
6797 | * how many | |
6798 | * characters are needed for the Neighbor column | |
6799 | */ | |
6800 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
6801 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6802 | continue; | |
6803 | ||
6804 | if (peer->afc[afi][safi]) { | |
6805 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
6806 | if (peer_dynamic_neighbor(peer)) | |
6807 | dn_flag[0] = '*'; | |
6808 | ||
6809 | if (peer->hostname | |
6810 | && bgp_flag_check(bgp, | |
6811 | BGP_FLAG_SHOW_HOSTNAME)) | |
6812 | sprintf(neighbor_buf, "%s%s(%s) ", | |
6813 | dn_flag, peer->hostname, | |
6814 | peer->host); | |
6815 | else | |
6816 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
6817 | peer->host); | |
6818 | ||
6819 | len = strlen(neighbor_buf); | |
6820 | ||
6821 | if (len > max_neighbor_width) | |
6822 | max_neighbor_width = len; | |
6823 | } | |
6824 | } | |
f933309e | 6825 | |
d62a17ae | 6826 | /* Originally we displayed the Neighbor column as 16 |
6827 | * characters wide so make that the default | |
6828 | */ | |
6829 | if (max_neighbor_width < neighbor_col_default_width) | |
6830 | max_neighbor_width = neighbor_col_default_width; | |
6831 | } | |
f933309e | 6832 | |
d62a17ae | 6833 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
6834 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6835 | continue; | |
6836 | ||
ea47320b DL |
6837 | if (!peer->afc[afi][safi]) |
6838 | continue; | |
d62a17ae | 6839 | |
ea47320b DL |
6840 | if (!count) { |
6841 | unsigned long ents; | |
6842 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
6843 | int vrf_id_ui; | |
d62a17ae | 6844 | |
60466a63 QY |
6845 | vrf_id_ui = |
6846 | (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; | |
ea47320b DL |
6847 | |
6848 | /* Usage summary and header */ | |
6849 | if (use_json) { | |
6850 | json_object_string_add( | |
6851 | json, "routerId", | |
6852 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
6853 | json_object_int_add(json, "as", bgp->as); |
6854 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
6855 | json_object_string_add( |
6856 | json, "vrfName", | |
6857 | (bgp->inst_type | |
6858 | == BGP_INSTANCE_TYPE_DEFAULT) | |
6859 | ? "Default" | |
6860 | : bgp->name); | |
6861 | } else { | |
6862 | vty_out(vty, | |
6863 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 QY |
6864 | inet_ntoa(bgp->router_id), bgp->as, |
6865 | vrf_id_ui); | |
ea47320b DL |
6866 | vty_out(vty, "\n"); |
6867 | } | |
d62a17ae | 6868 | |
ea47320b | 6869 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 6870 | if (use_json) { |
ea47320b | 6871 | json_object_int_add( |
60466a63 | 6872 | json, "updateDelayLimit", |
ea47320b | 6873 | bgp->v_update_delay); |
d62a17ae | 6874 | |
ea47320b DL |
6875 | if (bgp->v_update_delay |
6876 | != bgp->v_establish_wait) | |
d62a17ae | 6877 | json_object_int_add( |
6878 | json, | |
ea47320b DL |
6879 | "updateDelayEstablishWait", |
6880 | bgp->v_establish_wait); | |
d62a17ae | 6881 | |
60466a63 | 6882 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
6883 | json_object_string_add( |
6884 | json, | |
6885 | "updateDelayFirstNeighbor", | |
6886 | bgp->update_delay_begin_time); | |
6887 | json_object_boolean_true_add( | |
6888 | json, | |
6889 | "updateDelayInProgress"); | |
6890 | } else { | |
6891 | if (bgp->update_delay_over) { | |
d62a17ae | 6892 | json_object_string_add( |
6893 | json, | |
6894 | "updateDelayFirstNeighbor", | |
6895 | bgp->update_delay_begin_time); | |
ea47320b | 6896 | json_object_string_add( |
d62a17ae | 6897 | json, |
ea47320b DL |
6898 | "updateDelayBestpathResumed", |
6899 | bgp->update_delay_end_time); | |
6900 | json_object_string_add( | |
d62a17ae | 6901 | json, |
ea47320b DL |
6902 | "updateDelayZebraUpdateResume", |
6903 | bgp->update_delay_zebra_resume_time); | |
6904 | json_object_string_add( | |
6905 | json, | |
6906 | "updateDelayPeerUpdateResume", | |
6907 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 6908 | } |
ea47320b DL |
6909 | } |
6910 | } else { | |
6911 | vty_out(vty, | |
6912 | "Read-only mode update-delay limit: %d seconds\n", | |
6913 | bgp->v_update_delay); | |
6914 | if (bgp->v_update_delay | |
6915 | != bgp->v_establish_wait) | |
d62a17ae | 6916 | vty_out(vty, |
ea47320b DL |
6917 | " Establish wait: %d seconds\n", |
6918 | bgp->v_establish_wait); | |
d62a17ae | 6919 | |
60466a63 | 6920 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
6921 | vty_out(vty, |
6922 | " First neighbor established: %s\n", | |
6923 | bgp->update_delay_begin_time); | |
6924 | vty_out(vty, | |
6925 | " Delay in progress\n"); | |
6926 | } else { | |
6927 | if (bgp->update_delay_over) { | |
d62a17ae | 6928 | vty_out(vty, |
6929 | " First neighbor established: %s\n", | |
6930 | bgp->update_delay_begin_time); | |
6931 | vty_out(vty, | |
ea47320b DL |
6932 | " Best-paths resumed: %s\n", |
6933 | bgp->update_delay_end_time); | |
6934 | vty_out(vty, | |
6935 | " zebra update resumed: %s\n", | |
6936 | bgp->update_delay_zebra_resume_time); | |
6937 | vty_out(vty, | |
6938 | " peers update resumed: %s\n", | |
6939 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 6940 | } |
6941 | } | |
6942 | } | |
ea47320b | 6943 | } |
d62a17ae | 6944 | |
ea47320b DL |
6945 | if (use_json) { |
6946 | if (bgp_maxmed_onstartup_configured(bgp) | |
6947 | && bgp->maxmed_active) | |
6948 | json_object_boolean_true_add( | |
60466a63 | 6949 | json, "maxMedOnStartup"); |
ea47320b DL |
6950 | if (bgp->v_maxmed_admin) |
6951 | json_object_boolean_true_add( | |
60466a63 | 6952 | json, "maxMedAdministrative"); |
d62a17ae | 6953 | |
ea47320b DL |
6954 | json_object_int_add( |
6955 | json, "tableVersion", | |
60466a63 | 6956 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 6957 | |
60466a63 QY |
6958 | ents = bgp_table_count(bgp->rib[afi][safi]); |
6959 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
6960 | json_object_int_add( |
6961 | json, "ribMemory", | |
6962 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 6963 | |
ea47320b | 6964 | ents = listcount(bgp->peer); |
60466a63 QY |
6965 | json_object_int_add(json, "peerCount", ents); |
6966 | json_object_int_add(json, "peerMemory", | |
6967 | ents * sizeof(struct peer)); | |
d62a17ae | 6968 | |
ea47320b DL |
6969 | if ((ents = listcount(bgp->group))) { |
6970 | json_object_int_add( | |
60466a63 | 6971 | json, "peerGroupCount", ents); |
ea47320b DL |
6972 | json_object_int_add( |
6973 | json, "peerGroupMemory", | |
6974 | ents * sizeof(struct | |
6975 | peer_group)); | |
6976 | } | |
d62a17ae | 6977 | |
ea47320b DL |
6978 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
6979 | BGP_CONFIG_DAMPENING)) | |
6980 | json_object_boolean_true_add( | |
60466a63 | 6981 | json, "dampeningEnabled"); |
ea47320b DL |
6982 | } else { |
6983 | if (bgp_maxmed_onstartup_configured(bgp) | |
6984 | && bgp->maxmed_active) | |
d62a17ae | 6985 | vty_out(vty, |
ea47320b DL |
6986 | "Max-med on-startup active\n"); |
6987 | if (bgp->v_maxmed_admin) | |
d62a17ae | 6988 | vty_out(vty, |
ea47320b | 6989 | "Max-med administrative active\n"); |
d62a17ae | 6990 | |
60466a63 QY |
6991 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
6992 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 6993 | |
60466a63 | 6994 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
6995 | vty_out(vty, |
6996 | "RIB entries %ld, using %s of memory\n", | |
6997 | ents, | |
60466a63 QY |
6998 | mtype_memstr(memstrbuf, |
6999 | sizeof(memstrbuf), | |
7000 | ents * sizeof(struct | |
7001 | bgp_node))); | |
ea47320b DL |
7002 | |
7003 | /* Peer related usage */ | |
7004 | ents = listcount(bgp->peer); | |
60466a63 | 7005 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
7006 | ents, |
7007 | mtype_memstr( | |
60466a63 QY |
7008 | memstrbuf, sizeof(memstrbuf), |
7009 | ents * sizeof(struct peer))); | |
ea47320b DL |
7010 | |
7011 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 7012 | vty_out(vty, |
ea47320b | 7013 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 7014 | ents, |
7015 | mtype_memstr( | |
7016 | memstrbuf, | |
7017 | sizeof(memstrbuf), | |
9d303b37 | 7018 | ents * sizeof(struct |
ea47320b | 7019 | peer_group))); |
d62a17ae | 7020 | |
ea47320b DL |
7021 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
7022 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 7023 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 7024 | vty_out(vty, "\n"); |
d62a17ae | 7025 | |
ea47320b DL |
7026 | /* Subtract 8 here because 'Neighbor' is |
7027 | * 8 characters */ | |
7028 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
7029 | vty_out(vty, "%*s", max_neighbor_width - 8, |
7030 | " "); | |
ea47320b DL |
7031 | vty_out(vty, |
7032 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); | |
d62a17ae | 7033 | } |
ea47320b | 7034 | } |
d62a17ae | 7035 | |
ea47320b | 7036 | count++; |
d62a17ae | 7037 | |
ea47320b DL |
7038 | if (use_json) { |
7039 | json_peer = json_object_new_object(); | |
d62a17ae | 7040 | |
ea47320b | 7041 | if (peer_dynamic_neighbor(peer)) |
60466a63 QY |
7042 | json_object_boolean_true_add(json_peer, |
7043 | "dynamicPeer"); | |
d62a17ae | 7044 | |
ea47320b | 7045 | if (peer->hostname) |
60466a63 | 7046 | json_object_string_add(json_peer, "hostname", |
ea47320b | 7047 | peer->hostname); |
d62a17ae | 7048 | |
ea47320b | 7049 | if (peer->domainname) |
60466a63 QY |
7050 | json_object_string_add(json_peer, "domainname", |
7051 | peer->domainname); | |
d62a17ae | 7052 | |
60466a63 | 7053 | json_object_int_add(json_peer, "remoteAs", peer->as); |
ea47320b | 7054 | json_object_int_add(json_peer, "version", 4); |
60466a63 QY |
7055 | json_object_int_add(json_peer, "msgRcvd", |
7056 | peer->open_in + peer->update_in | |
7057 | + peer->keepalive_in | |
7058 | + peer->notify_in | |
7059 | + peer->refresh_in | |
7060 | + peer->dynamic_cap_in); | |
7061 | json_object_int_add(json_peer, "msgSent", | |
7062 | peer->open_out + peer->update_out | |
7063 | + peer->keepalive_out | |
7064 | + peer->notify_out | |
7065 | + peer->refresh_out | |
7066 | + peer->dynamic_cap_out); | |
ea47320b DL |
7067 | |
7068 | json_object_int_add(json_peer, "tableVersion", | |
7069 | peer->version[afi][safi]); | |
7070 | json_object_int_add(json_peer, "outq", | |
7071 | peer->obuf->count); | |
7072 | json_object_int_add(json_peer, "inq", 0); | |
60466a63 QY |
7073 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
7074 | use_json, json_peer); | |
7075 | json_object_int_add(json_peer, "prefixReceivedCount", | |
7076 | peer->pcount[afi][pfx_rcd_safi]); | |
d62a17ae | 7077 | |
ea47320b | 7078 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
60466a63 | 7079 | json_object_string_add(json_peer, "state", |
ea47320b | 7080 | "Idle (Admin)"); |
60466a63 QY |
7081 | else if (CHECK_FLAG(peer->sflags, |
7082 | PEER_STATUS_PREFIX_OVERFLOW)) | |
7083 | json_object_string_add(json_peer, "state", | |
ea47320b DL |
7084 | "Idle (PfxCt)"); |
7085 | else | |
7086 | json_object_string_add( | |
7087 | json_peer, "state", | |
60466a63 QY |
7088 | lookup_msg(bgp_status_msg, peer->status, |
7089 | NULL)); | |
ea47320b DL |
7090 | |
7091 | if (peer->conf_if) | |
60466a63 | 7092 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
7093 | "interface"); |
7094 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
7095 | json_object_string_add(json_peer, "idType", |
7096 | "ipv4"); | |
ea47320b | 7097 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
7098 | json_object_string_add(json_peer, "idType", |
7099 | "ipv6"); | |
d62a17ae | 7100 | |
ea47320b DL |
7101 | json_object_object_add(json_peers, peer->host, |
7102 | json_peer); | |
7103 | } else { | |
7104 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7105 | if (peer_dynamic_neighbor(peer)) { | |
7106 | dn_count++; | |
7107 | dn_flag[0] = '*'; | |
7108 | } | |
d62a17ae | 7109 | |
ea47320b | 7110 | if (peer->hostname |
60466a63 | 7111 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
ea47320b | 7112 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
60466a63 | 7113 | peer->hostname, peer->host); |
ea47320b | 7114 | else |
60466a63 | 7115 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
ea47320b DL |
7116 | |
7117 | /* pad the neighbor column with spaces */ | |
7118 | if (len < max_neighbor_width) | |
60466a63 QY |
7119 | vty_out(vty, "%*s", max_neighbor_width - len, |
7120 | " "); | |
ea47320b | 7121 | |
86a55b99 | 7122 | vty_out(vty, "4 %10u %7u %7u %8" PRIu64 " %4d %4zd %8s", |
ea47320b | 7123 | peer->as, |
424ab01d QY |
7124 | atomic_load_explicit(&peer->open_in, |
7125 | memory_order_relaxed) | |
7126 | + atomic_load_explicit( | |
7127 | &peer->update_in, | |
7128 | memory_order_relaxed) | |
7129 | + atomic_load_explicit( | |
7130 | &peer->keepalive_in, | |
7131 | memory_order_relaxed) | |
7132 | + atomic_load_explicit( | |
7133 | &peer->notify_in, | |
7134 | memory_order_relaxed) | |
7135 | + atomic_load_explicit( | |
7136 | &peer->refresh_in, | |
7137 | memory_order_relaxed) | |
7138 | + atomic_load_explicit( | |
7139 | &peer->dynamic_cap_in, | |
7140 | memory_order_relaxed), | |
7141 | atomic_load_explicit(&peer->open_out, | |
7142 | memory_order_relaxed) | |
7143 | + atomic_load_explicit( | |
7144 | &peer->update_out, | |
7145 | memory_order_relaxed) | |
7146 | + atomic_load_explicit( | |
7147 | &peer->keepalive_out, | |
7148 | memory_order_relaxed) | |
7149 | + atomic_load_explicit( | |
7150 | &peer->notify_out, | |
7151 | memory_order_relaxed) | |
7152 | + atomic_load_explicit( | |
7153 | &peer->refresh_out, | |
7154 | memory_order_relaxed) | |
7155 | + atomic_load_explicit( | |
7156 | &peer->dynamic_cap_out, | |
7157 | memory_order_relaxed), | |
60466a63 | 7158 | peer->version[afi][safi], 0, peer->obuf->count, |
d62a17ae | 7159 | peer_uptime(peer->uptime, timebuf, |
ea47320b | 7160 | BGP_UPTIME_LEN, 0, NULL)); |
d62a17ae | 7161 | |
ea47320b DL |
7162 | if (peer->status == Established) |
7163 | vty_out(vty, " %12ld", | |
60466a63 | 7164 | peer->pcount[afi][pfx_rcd_safi]); |
ea47320b | 7165 | else { |
60466a63 | 7166 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
ea47320b | 7167 | vty_out(vty, " Idle (Admin)"); |
60466a63 QY |
7168 | else if (CHECK_FLAG( |
7169 | peer->sflags, | |
7170 | PEER_STATUS_PREFIX_OVERFLOW)) | |
ea47320b | 7171 | vty_out(vty, " Idle (PfxCt)"); |
d62a17ae | 7172 | else |
ea47320b | 7173 | vty_out(vty, " %12s", |
60466a63 QY |
7174 | lookup_msg(bgp_status_msg, |
7175 | peer->status, NULL)); | |
d62a17ae | 7176 | } |
ea47320b | 7177 | vty_out(vty, "\n"); |
d62a17ae | 7178 | } |
7179 | } | |
f933309e | 7180 | |
d62a17ae | 7181 | if (use_json) { |
7182 | json_object_object_add(json, "peers", json_peers); | |
7183 | ||
7184 | json_object_int_add(json, "totalPeers", count); | |
7185 | json_object_int_add(json, "dynamicPeers", dn_count); | |
7186 | ||
57a9c8a8 DS |
7187 | bgp_show_bestpath_json(bgp, json); |
7188 | ||
9d303b37 DL |
7189 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
7190 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 7191 | json_object_free(json); |
7192 | } else { | |
7193 | if (count) | |
7194 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
7195 | else { | |
7196 | if (use_json) | |
7197 | vty_out(vty, | |
7198 | "{\"error\": {\"message\": \"No %s neighbor configured\"}}\n", | |
7199 | afi_safi_print(afi, safi)); | |
7200 | else | |
7201 | vty_out(vty, "No %s neighbor is configured\n", | |
7202 | afi_safi_print(afi, safi)); | |
7203 | } | |
b05a1c8b | 7204 | |
d62a17ae | 7205 | if (dn_count && !use_json) { |
7206 | vty_out(vty, "* - dynamic neighbor\n"); | |
7207 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
7208 | dn_count, bgp->dynamic_neighbors_limit); | |
7209 | } | |
7210 | } | |
1ff9a340 | 7211 | |
d62a17ae | 7212 | return CMD_SUCCESS; |
718e3744 | 7213 | } |
7214 | ||
d62a17ae | 7215 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
7216 | int safi, u_char use_json, | |
7217 | json_object *json) | |
7218 | { | |
7219 | int is_first = 1; | |
7220 | int afi_wildcard = (afi == AFI_MAX); | |
7221 | int safi_wildcard = (safi == SAFI_MAX); | |
7222 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
7223 | bool json_output = false; | |
7224 | ||
7225 | if (use_json && is_wildcard) | |
7226 | vty_out(vty, "{\n"); | |
7227 | if (afi_wildcard) | |
7228 | afi = 1; /* AFI_IP */ | |
7229 | while (afi < AFI_MAX) { | |
7230 | if (safi_wildcard) | |
7231 | safi = 1; /* SAFI_UNICAST */ | |
7232 | while (safi < SAFI_MAX) { | |
318cac96 | 7233 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
d62a17ae | 7234 | json_output = true; |
7235 | if (is_wildcard) { | |
7236 | /* | |
7237 | * So limit output to those afi/safi | |
7238 | * pairs that | |
7239 | * actualy have something interesting in | |
7240 | * them | |
7241 | */ | |
7242 | if (use_json) { | |
7243 | json = json_object_new_object(); | |
7244 | ||
7245 | if (!is_first) | |
7246 | vty_out(vty, ",\n"); | |
7247 | else | |
7248 | is_first = 0; | |
7249 | ||
7250 | vty_out(vty, "\"%s\":", | |
7251 | afi_safi_json(afi, | |
7252 | safi)); | |
7253 | } else { | |
7254 | vty_out(vty, "\n%s Summary:\n", | |
7255 | afi_safi_print(afi, | |
7256 | safi)); | |
7257 | } | |
7258 | } | |
7259 | bgp_show_summary(vty, bgp, afi, safi, use_json, | |
7260 | json); | |
7261 | } | |
7262 | safi++; | |
d62a17ae | 7263 | if (!safi_wildcard) |
7264 | safi = SAFI_MAX; | |
7265 | } | |
7266 | afi++; | |
7267 | if (!afi_wildcard | |
7268 | || afi == AFI_L2VPN) /* special case, not handled yet */ | |
7269 | afi = AFI_MAX; | |
7270 | } | |
7271 | ||
7272 | if (use_json && is_wildcard) | |
7273 | vty_out(vty, "}\n"); | |
7274 | else if (use_json && !json_output) | |
7275 | vty_out(vty, "{}\n"); | |
7276 | } | |
7277 | ||
7278 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
7279 | safi_t safi, u_char use_json) | |
7280 | { | |
7281 | struct listnode *node, *nnode; | |
7282 | struct bgp *bgp; | |
7283 | json_object *json = NULL; | |
7284 | int is_first = 1; | |
7285 | ||
7286 | if (use_json) | |
7287 | vty_out(vty, "{\n"); | |
7288 | ||
7289 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
7290 | if (use_json) { | |
7291 | json = json_object_new_object(); | |
7292 | ||
7293 | if (!is_first) | |
7294 | vty_out(vty, ",\n"); | |
7295 | else | |
7296 | is_first = 0; | |
7297 | ||
7298 | vty_out(vty, "\"%s\":", | |
7299 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7300 | ? "Default" | |
7301 | : bgp->name); | |
7302 | } else { | |
7303 | vty_out(vty, "\nInstance %s:\n", | |
7304 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7305 | ? "Default" | |
7306 | : bgp->name); | |
7307 | } | |
7308 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, json); | |
7309 | } | |
7310 | ||
7311 | if (use_json) | |
7312 | vty_out(vty, "}\n"); | |
7313 | } | |
7314 | ||
7315 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
7316 | safi_t safi, u_char use_json) | |
7317 | { | |
7318 | struct bgp *bgp; | |
7319 | ||
7320 | if (name) { | |
7321 | if (strmatch(name, "all")) { | |
7322 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
7323 | use_json); | |
7324 | return CMD_SUCCESS; | |
7325 | } else { | |
7326 | bgp = bgp_lookup_by_name(name); | |
7327 | ||
7328 | if (!bgp) { | |
7329 | if (use_json) | |
7330 | vty_out(vty, "{}\n"); | |
7331 | else | |
7332 | vty_out(vty, | |
7333 | "%% No such BGP instance exist\n"); | |
7334 | return CMD_WARNING; | |
7335 | } | |
7336 | ||
7337 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, | |
7338 | NULL); | |
7339 | return CMD_SUCCESS; | |
7340 | } | |
7341 | } | |
7342 | ||
7343 | bgp = bgp_get_default(); | |
7344 | ||
7345 | if (bgp) | |
7346 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, NULL); | |
7347 | ||
7348 | return CMD_SUCCESS; | |
4fb25c53 DW |
7349 | } |
7350 | ||
716b2d8a | 7351 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 7352 | DEFUN (show_ip_bgp_summary, |
718e3744 | 7353 | show_ip_bgp_summary_cmd, |
dd6bd0f1 | 7354 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [json]", |
718e3744 | 7355 | SHOW_STR |
7356 | IP_STR | |
7357 | BGP_STR | |
8386ac43 | 7358 | BGP_INSTANCE_HELP_STR |
46f296b4 | 7359 | BGP_AFI_HELP_STR |
dd6bd0f1 | 7360 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 7361 | "Summary of BGP neighbor status\n" |
9973d184 | 7362 | JSON_STR) |
718e3744 | 7363 | { |
d62a17ae | 7364 | char *vrf = NULL; |
7365 | afi_t afi = AFI_MAX; | |
7366 | safi_t safi = SAFI_MAX; | |
7367 | ||
7368 | int idx = 0; | |
7369 | ||
7370 | /* show [ip] bgp */ | |
7371 | if (argv_find(argv, argc, "ip", &idx)) | |
7372 | afi = AFI_IP; | |
7373 | /* [<view|vrf> VIEWVRFNAME] */ | |
7374 | if (argv_find(argv, argc, "view", &idx) | |
7375 | || argv_find(argv, argc, "vrf", &idx)) | |
7376 | vrf = argv[++idx]->arg; | |
7377 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
7378 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
7379 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
7380 | } | |
7381 | ||
7382 | int uj = use_json(argc, argv); | |
7383 | ||
7384 | return bgp_show_summary_vty(vty, vrf, afi, safi, uj); | |
7385 | } | |
7386 | ||
7387 | const char *afi_safi_print(afi_t afi, safi_t safi) | |
7388 | { | |
7389 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
7390 | return "IPv4 Unicast"; | |
7391 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
7392 | return "IPv4 Multicast"; | |
7393 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
7394 | return "IPv4 Labeled Unicast"; | |
7395 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
7396 | return "IPv4 VPN"; | |
7397 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
7398 | return "IPv4 Encap"; | |
7399 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
7400 | return "IPv6 Unicast"; | |
7401 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
7402 | return "IPv6 Multicast"; | |
7403 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
7404 | return "IPv6 Labeled Unicast"; | |
7405 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
7406 | return "IPv6 VPN"; | |
7407 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
7408 | return "IPv6 Encap"; | |
7409 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
7410 | return "L2VPN EVPN"; | |
7411 | else | |
7412 | return "Unknown"; | |
538621f2 | 7413 | } |
7414 | ||
b9f77ec8 DS |
7415 | /* |
7416 | * Please note that we have intentionally camelCased | |
7417 | * the return strings here. So if you want | |
7418 | * to use this function, please ensure you | |
7419 | * are doing this within json output | |
7420 | */ | |
d62a17ae | 7421 | const char *afi_safi_json(afi_t afi, safi_t safi) |
7422 | { | |
7423 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
7424 | return "ipv4Unicast"; | |
7425 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
7426 | return "ipv4Multicast"; | |
7427 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
7428 | return "ipv4LabeledUnicast"; | |
7429 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
7430 | return "ipv4Vpn"; | |
7431 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
7432 | return "ipv4Encap"; | |
7433 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
7434 | return "ipv6Unicast"; | |
7435 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
7436 | return "ipv6Multicast"; | |
7437 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
7438 | return "ipv6LabeledUnicast"; | |
7439 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
7440 | return "ipv6Vpn"; | |
7441 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
7442 | return "ipv6Encap"; | |
7443 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
7444 | return "l2VpnEvpn"; | |
7445 | else | |
7446 | return "Unknown"; | |
27162734 LB |
7447 | } |
7448 | ||
718e3744 | 7449 | /* Show BGP peer's information. */ |
d62a17ae | 7450 | enum show_type { show_all, show_peer }; |
7451 | ||
7452 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
7453 | afi_t afi, safi_t safi, | |
7454 | u_int16_t adv_smcap, u_int16_t adv_rmcap, | |
7455 | u_int16_t rcv_smcap, u_int16_t rcv_rmcap, | |
7456 | u_char use_json, json_object *json_pref) | |
7457 | { | |
7458 | /* Send-Mode */ | |
7459 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
7460 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
7461 | if (use_json) { | |
7462 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
7463 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
7464 | json_object_string_add(json_pref, "sendMode", | |
7465 | "advertisedAndReceived"); | |
7466 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
7467 | json_object_string_add(json_pref, "sendMode", | |
7468 | "advertised"); | |
7469 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
7470 | json_object_string_add(json_pref, "sendMode", | |
7471 | "received"); | |
7472 | } else { | |
7473 | vty_out(vty, " Send-mode: "); | |
7474 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
7475 | vty_out(vty, "advertised"); | |
7476 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
7477 | vty_out(vty, "%sreceived", | |
7478 | CHECK_FLAG(p->af_cap[afi][safi], | |
7479 | adv_smcap) | |
7480 | ? ", " | |
7481 | : ""); | |
7482 | vty_out(vty, "\n"); | |
7483 | } | |
7484 | } | |
7485 | ||
7486 | /* Receive-Mode */ | |
7487 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
7488 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
7489 | if (use_json) { | |
7490 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
7491 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
7492 | json_object_string_add(json_pref, "recvMode", | |
7493 | "advertisedAndReceived"); | |
7494 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
7495 | json_object_string_add(json_pref, "recvMode", | |
7496 | "advertised"); | |
7497 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
7498 | json_object_string_add(json_pref, "recvMode", | |
7499 | "received"); | |
7500 | } else { | |
7501 | vty_out(vty, " Receive-mode: "); | |
7502 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
7503 | vty_out(vty, "advertised"); | |
7504 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
7505 | vty_out(vty, "%sreceived", | |
7506 | CHECK_FLAG(p->af_cap[afi][safi], | |
7507 | adv_rmcap) | |
7508 | ? ", " | |
7509 | : ""); | |
7510 | vty_out(vty, "\n"); | |
7511 | } | |
7512 | } | |
7513 | } | |
7514 | ||
7515 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, | |
7516 | safi_t safi, u_char use_json, | |
7517 | json_object *json_neigh) | |
7518 | { | |
0291c246 MK |
7519 | struct bgp_filter *filter; |
7520 | struct peer_af *paf; | |
7521 | char orf_pfx_name[BUFSIZ]; | |
7522 | int orf_pfx_count; | |
7523 | json_object *json_af = NULL; | |
7524 | json_object *json_prefA = NULL; | |
7525 | json_object *json_prefB = NULL; | |
7526 | json_object *json_addr = NULL; | |
d62a17ae | 7527 | |
7528 | if (use_json) { | |
7529 | json_addr = json_object_new_object(); | |
7530 | json_af = json_object_new_object(); | |
7531 | filter = &p->filter[afi][safi]; | |
7532 | ||
7533 | if (peer_group_active(p)) | |
7534 | json_object_string_add(json_addr, "peerGroupMember", | |
7535 | p->group->name); | |
7536 | ||
7537 | paf = peer_af_find(p, afi, safi); | |
7538 | if (paf && PAF_SUBGRP(paf)) { | |
7539 | json_object_int_add(json_addr, "updateGroupId", | |
7540 | PAF_UPDGRP(paf)->id); | |
7541 | json_object_int_add(json_addr, "subGroupId", | |
7542 | PAF_SUBGRP(paf)->id); | |
7543 | json_object_int_add(json_addr, "packetQueueLength", | |
7544 | bpacket_queue_virtual_length(paf)); | |
7545 | } | |
7546 | ||
7547 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7548 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7549 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7550 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7551 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7552 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7553 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
7554 | json_object_int_add(json_af, "orfType", | |
7555 | ORF_TYPE_PREFIX); | |
7556 | json_prefA = json_object_new_object(); | |
7557 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
7558 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7559 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7560 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7561 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
7562 | use_json, json_prefA); | |
7563 | json_object_object_add(json_af, "orfPrefixList", | |
7564 | json_prefA); | |
7565 | } | |
7566 | ||
7567 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7568 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7569 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7570 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7571 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7572 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7573 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
7574 | json_object_int_add(json_af, "orfOldType", | |
7575 | ORF_TYPE_PREFIX_OLD); | |
7576 | json_prefB = json_object_new_object(); | |
7577 | bgp_show_peer_afi_orf_cap( | |
7578 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
7579 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7580 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7581 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
7582 | json_prefB); | |
7583 | json_object_object_add(json_af, "orfOldPrefixList", | |
7584 | json_prefB); | |
7585 | } | |
7586 | ||
7587 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7588 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7589 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7590 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7591 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7592 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7593 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7594 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7595 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
7596 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7597 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7598 | json_object_object_add(json_addr, "afDependentCap", | |
7599 | json_af); | |
7600 | else | |
7601 | json_object_free(json_af); | |
7602 | ||
7603 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
7604 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
7605 | NULL, afi, orf_pfx_name, use_json); | |
7606 | ||
7607 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7608 | PEER_STATUS_ORF_PREFIX_SEND) | |
7609 | || orf_pfx_count) { | |
7610 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7611 | PEER_STATUS_ORF_PREFIX_SEND)) | |
7612 | json_object_boolean_true_add(json_neigh, | |
7613 | "orfSent"); | |
7614 | if (orf_pfx_count) | |
7615 | json_object_int_add(json_addr, "orfRecvCounter", | |
7616 | orf_pfx_count); | |
7617 | } | |
7618 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7619 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
7620 | json_object_string_add( | |
7621 | json_addr, "orfFirstUpdate", | |
7622 | "deferredUntilORFOrRouteRefreshRecvd"); | |
7623 | ||
7624 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7625 | PEER_FLAG_REFLECTOR_CLIENT)) | |
7626 | json_object_boolean_true_add(json_addr, | |
7627 | "routeReflectorClient"); | |
7628 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7629 | PEER_FLAG_RSERVER_CLIENT)) | |
7630 | json_object_boolean_true_add(json_addr, | |
7631 | "routeServerClient"); | |
7632 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7633 | json_object_boolean_true_add(json_addr, | |
7634 | "inboundSoftConfigPermit"); | |
7635 | ||
7636 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7637 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
7638 | json_object_boolean_true_add( | |
7639 | json_addr, | |
7640 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
7641 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7642 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
7643 | json_object_boolean_true_add( | |
7644 | json_addr, | |
7645 | "privateAsNumsReplacedInUpdatesToNbr"); | |
7646 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7647 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
7648 | json_object_boolean_true_add( | |
7649 | json_addr, | |
7650 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
7651 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7652 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
7653 | json_object_boolean_true_add( | |
7654 | json_addr, | |
7655 | "privateAsNumsRemovedInUpdatesToNbr"); | |
7656 | ||
7657 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7658 | PEER_FLAG_ADDPATH_TX_ALL_PATHS)) | |
7659 | json_object_boolean_true_add(json_addr, | |
7660 | "addpathTxAllPaths"); | |
7661 | ||
7662 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7663 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
7664 | json_object_boolean_true_add(json_addr, | |
7665 | "addpathTxBestpathPerAS"); | |
7666 | ||
7667 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
7668 | json_object_string_add(json_addr, | |
7669 | "overrideASNsInOutboundUpdates", | |
7670 | "ifAspathEqualRemoteAs"); | |
7671 | ||
7672 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
7673 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7674 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7675 | json_object_boolean_true_add(json_addr, | |
7676 | "routerAlwaysNextHop"); | |
7677 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7678 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
7679 | json_object_boolean_true_add( | |
7680 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
7681 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7682 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7683 | json_object_boolean_true_add( | |
7684 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
7685 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7686 | json_object_boolean_true_add( | |
7687 | json_addr, "unchangedMedPropogatedToNbr"); | |
7688 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7689 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7690 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
7691 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7692 | PEER_FLAG_SEND_COMMUNITY) | |
7693 | && CHECK_FLAG(p->af_flags[afi][safi], | |
7694 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7695 | json_object_string_add(json_addr, | |
7696 | "commAttriSentToNbr", | |
7697 | "extendedAndStandard"); | |
7698 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7699 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7700 | json_object_string_add(json_addr, | |
7701 | "commAttriSentToNbr", | |
7702 | "extended"); | |
7703 | else | |
7704 | json_object_string_add(json_addr, | |
7705 | "commAttriSentToNbr", | |
7706 | "standard"); | |
7707 | } | |
7708 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7709 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
7710 | if (p->default_rmap[afi][safi].name) | |
7711 | json_object_string_add( | |
7712 | json_addr, "defaultRouteMap", | |
7713 | p->default_rmap[afi][safi].name); | |
7714 | ||
7715 | if (paf && PAF_SUBGRP(paf) | |
7716 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
7717 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7718 | json_object_boolean_true_add(json_addr, | |
7719 | "defaultSent"); | |
7720 | else | |
7721 | json_object_boolean_true_add(json_addr, | |
7722 | "defaultNotSent"); | |
7723 | } | |
7724 | ||
dff8f48d MK |
7725 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
7726 | if (p->bgp->advertise_all_vni) | |
60466a63 QY |
7727 | json_object_boolean_true_add( |
7728 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
7729 | } |
7730 | ||
d62a17ae | 7731 | if (filter->plist[FILTER_IN].name |
7732 | || filter->dlist[FILTER_IN].name | |
7733 | || filter->aslist[FILTER_IN].name | |
7734 | || filter->map[RMAP_IN].name) | |
7735 | json_object_boolean_true_add(json_addr, | |
7736 | "inboundPathPolicyConfig"); | |
7737 | if (filter->plist[FILTER_OUT].name | |
7738 | || filter->dlist[FILTER_OUT].name | |
7739 | || filter->aslist[FILTER_OUT].name | |
7740 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
7741 | json_object_boolean_true_add( | |
7742 | json_addr, "outboundPathPolicyConfig"); | |
7743 | ||
7744 | /* prefix-list */ | |
7745 | if (filter->plist[FILTER_IN].name) | |
7746 | json_object_string_add(json_addr, | |
7747 | "incomingUpdatePrefixFilterList", | |
7748 | filter->plist[FILTER_IN].name); | |
7749 | if (filter->plist[FILTER_OUT].name) | |
7750 | json_object_string_add(json_addr, | |
7751 | "outgoingUpdatePrefixFilterList", | |
7752 | filter->plist[FILTER_OUT].name); | |
7753 | ||
7754 | /* distribute-list */ | |
7755 | if (filter->dlist[FILTER_IN].name) | |
7756 | json_object_string_add( | |
7757 | json_addr, "incomingUpdateNetworkFilterList", | |
7758 | filter->dlist[FILTER_IN].name); | |
7759 | if (filter->dlist[FILTER_OUT].name) | |
7760 | json_object_string_add( | |
7761 | json_addr, "outgoingUpdateNetworkFilterList", | |
7762 | filter->dlist[FILTER_OUT].name); | |
7763 | ||
7764 | /* filter-list. */ | |
7765 | if (filter->aslist[FILTER_IN].name) | |
7766 | json_object_string_add(json_addr, | |
7767 | "incomingUpdateAsPathFilterList", | |
7768 | filter->aslist[FILTER_IN].name); | |
7769 | if (filter->aslist[FILTER_OUT].name) | |
7770 | json_object_string_add(json_addr, | |
7771 | "outgoingUpdateAsPathFilterList", | |
7772 | filter->aslist[FILTER_OUT].name); | |
7773 | ||
7774 | /* route-map. */ | |
7775 | if (filter->map[RMAP_IN].name) | |
7776 | json_object_string_add( | |
7777 | json_addr, "routeMapForIncomingAdvertisements", | |
7778 | filter->map[RMAP_IN].name); | |
7779 | if (filter->map[RMAP_OUT].name) | |
7780 | json_object_string_add( | |
7781 | json_addr, "routeMapForOutgoingAdvertisements", | |
7782 | filter->map[RMAP_OUT].name); | |
7783 | ||
7784 | /* unsuppress-map */ | |
7785 | if (filter->usmap.name) | |
7786 | json_object_string_add(json_addr, | |
7787 | "selectiveUnsuppressRouteMap", | |
7788 | filter->usmap.name); | |
7789 | ||
7790 | /* Receive prefix count */ | |
7791 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
7792 | p->pcount[afi][safi]); | |
7793 | ||
7794 | /* Maximum prefix */ | |
7795 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
7796 | json_object_int_add(json_addr, "prefixAllowedMax", | |
7797 | p->pmax[afi][safi]); | |
7798 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7799 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
7800 | json_object_boolean_true_add( | |
7801 | json_addr, "prefixAllowedMaxWarning"); | |
7802 | json_object_int_add(json_addr, | |
7803 | "prefixAllowedWarningThresh", | |
7804 | p->pmax_threshold[afi][safi]); | |
7805 | if (p->pmax_restart[afi][safi]) | |
7806 | json_object_int_add( | |
7807 | json_addr, | |
7808 | "prefixAllowedRestartIntervalMsecs", | |
7809 | p->pmax_restart[afi][safi] * 60000); | |
7810 | } | |
7811 | json_object_object_add(json_neigh, afi_safi_print(afi, safi), | |
7812 | json_addr); | |
7813 | ||
7814 | } else { | |
7815 | filter = &p->filter[afi][safi]; | |
7816 | ||
7817 | vty_out(vty, " For address family: %s\n", | |
7818 | afi_safi_print(afi, safi)); | |
7819 | ||
7820 | if (peer_group_active(p)) | |
7821 | vty_out(vty, " %s peer-group member\n", | |
7822 | p->group->name); | |
7823 | ||
7824 | paf = peer_af_find(p, afi, safi); | |
7825 | if (paf && PAF_SUBGRP(paf)) { | |
9d303b37 DL |
7826 | vty_out(vty, " Update group %" PRIu64 |
7827 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 7828 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
7829 | vty_out(vty, " Packet Queue length %d\n", | |
7830 | bpacket_queue_virtual_length(paf)); | |
7831 | } else { | |
7832 | vty_out(vty, " Not part of any update group\n"); | |
7833 | } | |
7834 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7835 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7836 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7837 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7838 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7839 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7840 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7841 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7842 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
7843 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7844 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7845 | vty_out(vty, " AF-dependant capabilities:\n"); | |
7846 | ||
7847 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7848 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7849 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7850 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7851 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7852 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7853 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
7854 | vty_out(vty, | |
7855 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
7856 | ORF_TYPE_PREFIX); | |
7857 | bgp_show_peer_afi_orf_cap( | |
7858 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
7859 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7860 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7861 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
7862 | } | |
7863 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7864 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7865 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7866 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7867 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7868 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7869 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
7870 | vty_out(vty, | |
7871 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
7872 | ORF_TYPE_PREFIX_OLD); | |
7873 | bgp_show_peer_afi_orf_cap( | |
7874 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
7875 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7876 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7877 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
7878 | } | |
7879 | ||
7880 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
7881 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
7882 | NULL, afi, orf_pfx_name, use_json); | |
7883 | ||
7884 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7885 | PEER_STATUS_ORF_PREFIX_SEND) | |
7886 | || orf_pfx_count) { | |
7887 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
7888 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7889 | PEER_STATUS_ORF_PREFIX_SEND)) | |
7890 | vty_out(vty, " sent;"); | |
7891 | if (orf_pfx_count) | |
7892 | vty_out(vty, " received (%d entries)", | |
7893 | orf_pfx_count); | |
7894 | vty_out(vty, "\n"); | |
7895 | } | |
7896 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7897 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
7898 | vty_out(vty, | |
7899 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
7900 | ||
7901 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7902 | PEER_FLAG_REFLECTOR_CLIENT)) | |
7903 | vty_out(vty, " Route-Reflector Client\n"); | |
7904 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7905 | PEER_FLAG_RSERVER_CLIENT)) | |
7906 | vty_out(vty, " Route-Server Client\n"); | |
7907 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7908 | vty_out(vty, | |
7909 | " Inbound soft reconfiguration allowed\n"); | |
7910 | ||
7911 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7912 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
7913 | vty_out(vty, | |
7914 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
7915 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7916 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
7917 | vty_out(vty, | |
7918 | " Private AS numbers replaced in updates to this neighbor\n"); | |
7919 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7920 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
7921 | vty_out(vty, | |
7922 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
7923 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7924 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
7925 | vty_out(vty, | |
7926 | " Private AS numbers removed in updates to this neighbor\n"); | |
7927 | ||
7928 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7929 | PEER_FLAG_ADDPATH_TX_ALL_PATHS)) | |
7930 | vty_out(vty, " Advertise all paths via addpath\n"); | |
7931 | ||
7932 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7933 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
7934 | vty_out(vty, | |
7935 | " Advertise bestpath per AS via addpath\n"); | |
7936 | ||
7937 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
7938 | vty_out(vty, | |
7939 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
7940 | ||
7941 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
7942 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7943 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7944 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
7945 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7946 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
7947 | vty_out(vty, | |
7948 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
7949 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7950 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7951 | vty_out(vty, | |
7952 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
7953 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7954 | vty_out(vty, | |
7955 | " MED is propagated unchanged to this neighbor\n"); | |
7956 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7957 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7958 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
7959 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7960 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
7961 | vty_out(vty, | |
7962 | " Community attribute sent to this neighbor"); | |
7963 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7964 | PEER_FLAG_SEND_COMMUNITY) | |
7965 | && CHECK_FLAG(p->af_flags[afi][safi], | |
7966 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
7967 | && CHECK_FLAG(p->af_flags[afi][safi], | |
7968 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7969 | vty_out(vty, "(all)\n"); | |
7970 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7971 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7972 | vty_out(vty, "(large)\n"); | |
7973 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7974 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7975 | vty_out(vty, "(extended)\n"); | |
7976 | else | |
7977 | vty_out(vty, "(standard)\n"); | |
7978 | } | |
7979 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7980 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
7981 | vty_out(vty, " Default information originate,"); | |
7982 | ||
7983 | if (p->default_rmap[afi][safi].name) | |
7984 | vty_out(vty, " default route-map %s%s,", | |
7985 | p->default_rmap[afi][safi].map ? "*" | |
7986 | : "", | |
7987 | p->default_rmap[afi][safi].name); | |
7988 | if (paf && PAF_SUBGRP(paf) | |
7989 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
7990 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7991 | vty_out(vty, " default sent\n"); | |
7992 | else | |
7993 | vty_out(vty, " default not sent\n"); | |
7994 | } | |
7995 | ||
dff8f48d MK |
7996 | /* advertise-vni-all */ |
7997 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
7998 | if (p->bgp->advertise_all_vni) | |
7999 | vty_out(vty, " advertise-all-vni\n"); | |
8000 | } | |
8001 | ||
d62a17ae | 8002 | if (filter->plist[FILTER_IN].name |
8003 | || filter->dlist[FILTER_IN].name | |
8004 | || filter->aslist[FILTER_IN].name | |
8005 | || filter->map[RMAP_IN].name) | |
8006 | vty_out(vty, " Inbound path policy configured\n"); | |
8007 | if (filter->plist[FILTER_OUT].name | |
8008 | || filter->dlist[FILTER_OUT].name | |
8009 | || filter->aslist[FILTER_OUT].name | |
8010 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
8011 | vty_out(vty, " Outbound path policy configured\n"); | |
8012 | ||
8013 | /* prefix-list */ | |
8014 | if (filter->plist[FILTER_IN].name) | |
8015 | vty_out(vty, | |
8016 | " Incoming update prefix filter list is %s%s\n", | |
8017 | filter->plist[FILTER_IN].plist ? "*" : "", | |
8018 | filter->plist[FILTER_IN].name); | |
8019 | if (filter->plist[FILTER_OUT].name) | |
8020 | vty_out(vty, | |
8021 | " Outgoing update prefix filter list is %s%s\n", | |
8022 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
8023 | filter->plist[FILTER_OUT].name); | |
8024 | ||
8025 | /* distribute-list */ | |
8026 | if (filter->dlist[FILTER_IN].name) | |
8027 | vty_out(vty, | |
8028 | " Incoming update network filter list is %s%s\n", | |
8029 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
8030 | filter->dlist[FILTER_IN].name); | |
8031 | if (filter->dlist[FILTER_OUT].name) | |
8032 | vty_out(vty, | |
8033 | " Outgoing update network filter list is %s%s\n", | |
8034 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
8035 | filter->dlist[FILTER_OUT].name); | |
8036 | ||
8037 | /* filter-list. */ | |
8038 | if (filter->aslist[FILTER_IN].name) | |
8039 | vty_out(vty, | |
8040 | " Incoming update AS path filter list is %s%s\n", | |
8041 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
8042 | filter->aslist[FILTER_IN].name); | |
8043 | if (filter->aslist[FILTER_OUT].name) | |
8044 | vty_out(vty, | |
8045 | " Outgoing update AS path filter list is %s%s\n", | |
8046 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
8047 | filter->aslist[FILTER_OUT].name); | |
8048 | ||
8049 | /* route-map. */ | |
8050 | if (filter->map[RMAP_IN].name) | |
8051 | vty_out(vty, | |
8052 | " Route map for incoming advertisements is %s%s\n", | |
8053 | filter->map[RMAP_IN].map ? "*" : "", | |
8054 | filter->map[RMAP_IN].name); | |
8055 | if (filter->map[RMAP_OUT].name) | |
8056 | vty_out(vty, | |
8057 | " Route map for outgoing advertisements is %s%s\n", | |
8058 | filter->map[RMAP_OUT].map ? "*" : "", | |
8059 | filter->map[RMAP_OUT].name); | |
8060 | ||
8061 | /* unsuppress-map */ | |
8062 | if (filter->usmap.name) | |
8063 | vty_out(vty, | |
8064 | " Route map for selective unsuppress is %s%s\n", | |
8065 | filter->usmap.map ? "*" : "", | |
8066 | filter->usmap.name); | |
8067 | ||
8068 | /* Receive prefix count */ | |
8069 | vty_out(vty, " %ld accepted prefixes\n", p->pcount[afi][safi]); | |
8070 | ||
8071 | /* Maximum prefix */ | |
8072 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
8073 | vty_out(vty, " Maximum prefixes allowed %ld%s\n", | |
8074 | p->pmax[afi][safi], | |
8075 | CHECK_FLAG(p->af_flags[afi][safi], | |
8076 | PEER_FLAG_MAX_PREFIX_WARNING) | |
8077 | ? " (warning-only)" | |
8078 | : ""); | |
8079 | vty_out(vty, " Threshold for warning message %d%%", | |
8080 | p->pmax_threshold[afi][safi]); | |
8081 | if (p->pmax_restart[afi][safi]) | |
8082 | vty_out(vty, ", restart interval %d min", | |
8083 | p->pmax_restart[afi][safi]); | |
8084 | vty_out(vty, "\n"); | |
8085 | } | |
8086 | ||
8087 | vty_out(vty, "\n"); | |
8088 | } | |
8089 | } | |
8090 | ||
8091 | static void bgp_show_peer(struct vty *vty, struct peer *p, u_char use_json, | |
8092 | json_object *json) | |
718e3744 | 8093 | { |
d62a17ae | 8094 | struct bgp *bgp; |
8095 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
8096 | char timebuf[BGP_UPTIME_LEN]; | |
8097 | char dn_flag[2]; | |
8098 | const char *subcode_str; | |
8099 | const char *code_str; | |
8100 | afi_t afi; | |
8101 | safi_t safi; | |
8102 | u_int16_t i; | |
8103 | u_char *msg; | |
8104 | json_object *json_neigh = NULL; | |
8105 | time_t epoch_tbuf; | |
718e3744 | 8106 | |
d62a17ae | 8107 | bgp = p->bgp; |
8108 | ||
8109 | if (use_json) | |
8110 | json_neigh = json_object_new_object(); | |
8111 | ||
8112 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8113 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
8114 | dn_flag[0] = '*'; | |
8115 | ||
8116 | if (!use_json) { | |
8117 | if (p->conf_if) /* Configured interface name. */ | |
8118 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
8119 | BGP_PEER_SU_UNSPEC(p) | |
8120 | ? "None" | |
8121 | : sockunion2str(&p->su, buf, | |
8122 | SU_ADDRSTRLEN)); | |
8123 | else /* Configured IP address. */ | |
8124 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
8125 | p->host); | |
8126 | } | |
8127 | ||
8128 | if (use_json) { | |
8129 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
8130 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
8131 | "none"); | |
8132 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
8133 | json_object_string_add( | |
8134 | json_neigh, "bgpNeighborAddr", | |
8135 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
8136 | ||
8137 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
8138 | ||
8139 | if (p->change_local_as) | |
8140 | json_object_int_add(json_neigh, "localAs", | |
8141 | p->change_local_as); | |
8142 | else | |
8143 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
8144 | ||
8145 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
8146 | json_object_boolean_true_add(json_neigh, | |
8147 | "localAsNoPrepend"); | |
8148 | ||
8149 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
8150 | json_object_boolean_true_add(json_neigh, | |
8151 | "localAsReplaceAs"); | |
8152 | } else { | |
8153 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
8154 | || (p->as_type == AS_INTERNAL)) | |
8155 | vty_out(vty, "remote AS %u, ", p->as); | |
8156 | else | |
8157 | vty_out(vty, "remote AS Unspecified, "); | |
8158 | vty_out(vty, "local AS %u%s%s, ", | |
8159 | p->change_local_as ? p->change_local_as : p->local_as, | |
8160 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
8161 | ? " no-prepend" | |
8162 | : "", | |
8163 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
8164 | ? " replace-as" | |
8165 | : ""); | |
8166 | } | |
8167 | /* peer type internal, external, confed-internal or confed-external */ | |
8168 | if (p->as == p->local_as) { | |
8169 | if (use_json) { | |
8170 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
8171 | json_object_boolean_true_add( | |
8172 | json_neigh, "nbrConfedInternalLink"); | |
8173 | else | |
8174 | json_object_boolean_true_add(json_neigh, | |
8175 | "nbrInternalLink"); | |
8176 | } else { | |
8177 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
8178 | vty_out(vty, "confed-internal link\n"); | |
8179 | else | |
8180 | vty_out(vty, "internal link\n"); | |
8181 | } | |
8182 | } else { | |
8183 | if (use_json) { | |
8184 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
8185 | json_object_boolean_true_add( | |
8186 | json_neigh, "nbrConfedExternalLink"); | |
8187 | else | |
8188 | json_object_boolean_true_add(json_neigh, | |
8189 | "nbrExternalLink"); | |
8190 | } else { | |
8191 | if (bgp_confederation_peers_check(bgp, p->as)) | |
8192 | vty_out(vty, "confed-external link\n"); | |
8193 | else | |
8194 | vty_out(vty, "external link\n"); | |
8195 | } | |
8196 | } | |
8197 | ||
8198 | /* Description. */ | |
8199 | if (p->desc) { | |
8200 | if (use_json) | |
8201 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
8202 | else | |
8203 | vty_out(vty, " Description: %s\n", p->desc); | |
8204 | } | |
8205 | ||
8206 | if (p->hostname) { | |
8207 | if (use_json) { | |
8208 | if (p->hostname) | |
8209 | json_object_string_add(json_neigh, "hostname", | |
8210 | p->hostname); | |
8211 | ||
8212 | if (p->domainname) | |
8213 | json_object_string_add(json_neigh, "domainname", | |
8214 | p->domainname); | |
8215 | } else { | |
8216 | if (p->domainname && (p->domainname[0] != '\0')) | |
8217 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
8218 | p->domainname); | |
8219 | else | |
8220 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
8221 | } | |
8222 | } | |
8223 | ||
8224 | /* Peer-group */ | |
8225 | if (p->group) { | |
8226 | if (use_json) { | |
8227 | json_object_string_add(json_neigh, "peerGroup", | |
8228 | p->group->name); | |
8229 | ||
8230 | if (dn_flag[0]) { | |
8231 | struct prefix prefix, *range = NULL; | |
8232 | ||
8233 | sockunion2hostprefix(&(p->su), &prefix); | |
8234 | range = peer_group_lookup_dynamic_neighbor_range( | |
8235 | p->group, &prefix); | |
8236 | ||
8237 | if (range) { | |
8238 | prefix2str(range, buf1, sizeof(buf1)); | |
8239 | json_object_string_add( | |
8240 | json_neigh, | |
8241 | "peerSubnetRangeGroup", buf1); | |
8242 | } | |
8243 | } | |
8244 | } else { | |
8245 | vty_out(vty, | |
8246 | " Member of peer-group %s for session parameters\n", | |
8247 | p->group->name); | |
8248 | ||
8249 | if (dn_flag[0]) { | |
8250 | struct prefix prefix, *range = NULL; | |
8251 | ||
8252 | sockunion2hostprefix(&(p->su), &prefix); | |
8253 | range = peer_group_lookup_dynamic_neighbor_range( | |
8254 | p->group, &prefix); | |
8255 | ||
8256 | if (range) { | |
8257 | prefix2str(range, buf1, sizeof(buf1)); | |
8258 | vty_out(vty, | |
8259 | " Belongs to the subnet range group: %s\n", | |
8260 | buf1); | |
8261 | } | |
8262 | } | |
8263 | } | |
8264 | } | |
8265 | ||
8266 | if (use_json) { | |
8267 | /* Administrative shutdown. */ | |
8268 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
8269 | json_object_boolean_true_add(json_neigh, | |
8270 | "adminShutDown"); | |
8271 | ||
8272 | /* BGP Version. */ | |
8273 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
8274 | json_object_string_add( | |
8275 | json_neigh, "remoteRouterId", | |
8276 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
8277 | ||
8278 | /* Confederation */ | |
8279 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
8280 | && bgp_confederation_peers_check(bgp, p->as)) | |
8281 | json_object_boolean_true_add(json_neigh, | |
8282 | "nbrCommonAdmin"); | |
8283 | ||
8284 | /* Status. */ | |
8285 | json_object_string_add( | |
8286 | json_neigh, "bgpState", | |
8287 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
8288 | ||
8289 | if (p->status == Established) { | |
8290 | time_t uptime; | |
8291 | struct tm *tm; | |
8292 | ||
8293 | uptime = bgp_clock(); | |
8294 | uptime -= p->uptime; | |
8295 | tm = gmtime(&uptime); | |
8296 | epoch_tbuf = time(NULL) - uptime; | |
8297 | ||
8298 | json_object_int_add(json_neigh, "bgpTimerUp", | |
8299 | (tm->tm_sec * 1000) | |
8300 | + (tm->tm_min * 60000) | |
8301 | + (tm->tm_hour * 3600000)); | |
8302 | json_object_string_add(json_neigh, "bgpTimerUpString", | |
8303 | peer_uptime(p->uptime, timebuf, | |
8304 | BGP_UPTIME_LEN, 0, | |
8305 | NULL)); | |
8306 | json_object_int_add(json_neigh, | |
8307 | "bgpTimerUpEstablishedEpoch", | |
8308 | epoch_tbuf); | |
8309 | } | |
8310 | ||
8311 | else if (p->status == Active) { | |
8312 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
8313 | json_object_string_add(json_neigh, "bgpStateIs", | |
8314 | "passive"); | |
8315 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
8316 | json_object_string_add(json_neigh, "bgpStateIs", | |
8317 | "passiveNSF"); | |
8318 | } | |
8319 | ||
8320 | /* read timer */ | |
8321 | time_t uptime; | |
8322 | struct tm *tm; | |
8323 | ||
8324 | uptime = bgp_clock(); | |
8325 | uptime -= p->readtime; | |
8326 | tm = gmtime(&uptime); | |
8327 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
8328 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
8329 | + (tm->tm_hour * 3600000)); | |
8330 | ||
8331 | uptime = bgp_clock(); | |
8332 | uptime -= p->last_write; | |
8333 | tm = gmtime(&uptime); | |
8334 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
8335 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
8336 | + (tm->tm_hour * 3600000)); | |
8337 | ||
8338 | uptime = bgp_clock(); | |
8339 | uptime -= p->update_time; | |
8340 | tm = gmtime(&uptime); | |
8341 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
8342 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
8343 | + (tm->tm_hour * 3600000)); | |
8344 | ||
8345 | /* Configured timer values. */ | |
8346 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
8347 | p->v_holdtime * 1000); | |
8348 | json_object_int_add(json_neigh, | |
8349 | "bgpTimerKeepAliveIntervalMsecs", | |
8350 | p->v_keepalive * 1000); | |
8351 | ||
d25e4efc | 8352 | if (PEER_OR_GROUP_TIMER_SET(p)) { |
d62a17ae | 8353 | json_object_int_add(json_neigh, |
8354 | "bgpTimerConfiguredHoldTimeMsecs", | |
8355 | p->holdtime * 1000); | |
8356 | json_object_int_add( | |
8357 | json_neigh, | |
8358 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
8359 | p->keepalive * 1000); | |
d25e4efc DS |
8360 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
8361 | || (bgp->default_keepalive != | |
8362 | BGP_DEFAULT_KEEPALIVE)) { | |
8363 | json_object_int_add(json_neigh, | |
8364 | "bgpTimerConfiguredHoldTimeMsecs", | |
8365 | bgp->default_holdtime); | |
8366 | json_object_int_add( | |
8367 | json_neigh, | |
8368 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
8369 | bgp->default_keepalive); | |
d62a17ae | 8370 | } |
8371 | } else { | |
8372 | /* Administrative shutdown. */ | |
8373 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
8374 | vty_out(vty, " Administratively shut down\n"); | |
8375 | ||
8376 | /* BGP Version. */ | |
8377 | vty_out(vty, " BGP version 4"); | |
8378 | vty_out(vty, ", remote router ID %s\n", | |
8379 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
8380 | ||
8381 | /* Confederation */ | |
8382 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
8383 | && bgp_confederation_peers_check(bgp, p->as)) | |
8384 | vty_out(vty, | |
8385 | " Neighbor under common administration\n"); | |
8386 | ||
8387 | /* Status. */ | |
8388 | vty_out(vty, " BGP state = %s", | |
8389 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
8390 | ||
8391 | if (p->status == Established) | |
8392 | vty_out(vty, ", up for %8s", | |
8393 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
8394 | 0, NULL)); | |
8395 | ||
8396 | else if (p->status == Active) { | |
8397 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
8398 | vty_out(vty, " (passive)"); | |
8399 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
8400 | vty_out(vty, " (NSF passive)"); | |
8401 | } | |
8402 | vty_out(vty, "\n"); | |
8403 | ||
8404 | /* read timer */ | |
8405 | vty_out(vty, " Last read %s", | |
8406 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
8407 | NULL)); | |
8408 | vty_out(vty, ", Last write %s\n", | |
8409 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
8410 | NULL)); | |
8411 | ||
8412 | /* Configured timer values. */ | |
8413 | vty_out(vty, | |
8414 | " Hold time is %d, keepalive interval is %d seconds\n", | |
8415 | p->v_holdtime, p->v_keepalive); | |
d25e4efc | 8416 | if (PEER_OR_GROUP_TIMER_SET(p)) { |
d62a17ae | 8417 | vty_out(vty, " Configured hold time is %d", |
8418 | p->holdtime); | |
8419 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
8420 | p->keepalive); | |
d25e4efc DS |
8421 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
8422 | || (bgp->default_keepalive != | |
8423 | BGP_DEFAULT_KEEPALIVE)) { | |
8424 | vty_out(vty, " Configured hold time is %d", | |
8425 | bgp->default_holdtime); | |
8426 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
8427 | bgp->default_keepalive); | |
d62a17ae | 8428 | } |
8429 | } | |
8430 | /* Capability. */ | |
8431 | if (p->status == Established) { | |
8432 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
8433 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
8434 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
8435 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
8436 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
8437 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
8438 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
8439 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
8440 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
8441 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
8442 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
8443 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
8444 | || p->afc_adv[AFI_IP][SAFI_ENCAP] | |
8445 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
8446 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] | |
8447 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
8448 | if (use_json) { | |
8449 | json_object *json_cap = NULL; | |
8450 | ||
8451 | json_cap = json_object_new_object(); | |
8452 | ||
8453 | /* AS4 */ | |
8454 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
8455 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
8456 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
8457 | && CHECK_FLAG(p->cap, | |
8458 | PEER_CAP_AS4_RCV)) | |
8459 | json_object_string_add( | |
8460 | json_cap, "4byteAs", | |
8461 | "advertisedAndReceived"); | |
8462 | else if (CHECK_FLAG(p->cap, | |
8463 | PEER_CAP_AS4_ADV)) | |
8464 | json_object_string_add( | |
8465 | json_cap, "4byteAs", | |
8466 | "advertised"); | |
8467 | else if (CHECK_FLAG(p->cap, | |
8468 | PEER_CAP_AS4_RCV)) | |
8469 | json_object_string_add( | |
8470 | json_cap, "4byteAs", | |
8471 | "received"); | |
8472 | } | |
8473 | ||
8474 | /* AddPath */ | |
8475 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
8476 | || CHECK_FLAG(p->cap, | |
8477 | PEER_CAP_ADDPATH_ADV)) { | |
8478 | json_object *json_add = NULL; | |
8479 | const char *print_store; | |
8480 | ||
8481 | json_add = json_object_new_object(); | |
8482 | ||
05c7a1cc QY |
8483 | FOREACH_AFI_SAFI (afi, safi) { |
8484 | json_object *json_sub = NULL; | |
8485 | json_sub = | |
8486 | json_object_new_object(); | |
8487 | print_store = afi_safi_print( | |
8488 | afi, safi); | |
d62a17ae | 8489 | |
05c7a1cc QY |
8490 | if (CHECK_FLAG( |
8491 | p->af_cap[afi] | |
8492 | [safi], | |
8493 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8494 | || CHECK_FLAG( | |
8495 | p->af_cap[afi] | |
8496 | [safi], | |
8497 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 8498 | if (CHECK_FLAG( |
8499 | p->af_cap | |
8500 | [afi] | |
8501 | [safi], | |
8502 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 8503 | && CHECK_FLAG( |
d62a17ae | 8504 | p->af_cap |
8505 | [afi] | |
8506 | [safi], | |
05c7a1cc QY |
8507 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
8508 | json_object_boolean_true_add( | |
8509 | json_sub, | |
8510 | "txAdvertisedAndReceived"); | |
8511 | else if ( | |
8512 | CHECK_FLAG( | |
8513 | p->af_cap | |
8514 | [afi] | |
8515 | [safi], | |
8516 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
8517 | json_object_boolean_true_add( | |
8518 | json_sub, | |
8519 | "txAdvertised"); | |
8520 | else if ( | |
8521 | CHECK_FLAG( | |
8522 | p->af_cap | |
8523 | [afi] | |
8524 | [safi], | |
8525 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8526 | json_object_boolean_true_add( | |
8527 | json_sub, | |
8528 | "txReceived"); | |
8529 | } | |
d62a17ae | 8530 | |
05c7a1cc QY |
8531 | if (CHECK_FLAG( |
8532 | p->af_cap[afi] | |
8533 | [safi], | |
8534 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8535 | || CHECK_FLAG( | |
8536 | p->af_cap[afi] | |
8537 | [safi], | |
8538 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 8539 | if (CHECK_FLAG( |
8540 | p->af_cap | |
8541 | [afi] | |
8542 | [safi], | |
8543 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 8544 | && CHECK_FLAG( |
d62a17ae | 8545 | p->af_cap |
8546 | [afi] | |
8547 | [safi], | |
8548 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
8549 | json_object_boolean_true_add( |
8550 | json_sub, | |
8551 | "rxAdvertisedAndReceived"); | |
8552 | else if ( | |
8553 | CHECK_FLAG( | |
8554 | p->af_cap | |
8555 | [afi] | |
8556 | [safi], | |
8557 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
8558 | json_object_boolean_true_add( | |
8559 | json_sub, | |
8560 | "rxAdvertised"); | |
8561 | else if ( | |
8562 | CHECK_FLAG( | |
8563 | p->af_cap | |
8564 | [afi] | |
8565 | [safi], | |
8566 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8567 | json_object_boolean_true_add( | |
8568 | json_sub, | |
8569 | "rxReceived"); | |
d62a17ae | 8570 | } |
8571 | ||
05c7a1cc QY |
8572 | if (CHECK_FLAG( |
8573 | p->af_cap[afi] | |
8574 | [safi], | |
8575 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8576 | || CHECK_FLAG( | |
8577 | p->af_cap[afi] | |
8578 | [safi], | |
8579 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
8580 | || CHECK_FLAG( | |
8581 | p->af_cap[afi] | |
8582 | [safi], | |
8583 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8584 | || CHECK_FLAG( | |
8585 | p->af_cap[afi] | |
8586 | [safi], | |
8587 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8588 | json_object_object_add( | |
8589 | json_add, | |
8590 | print_store, | |
8591 | json_sub); | |
8592 | else | |
8593 | json_object_free( | |
8594 | json_sub); | |
8595 | } | |
8596 | ||
d62a17ae | 8597 | json_object_object_add( |
8598 | json_cap, "addPath", json_add); | |
8599 | } | |
8600 | ||
8601 | /* Dynamic */ | |
8602 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
8603 | || CHECK_FLAG(p->cap, | |
8604 | PEER_CAP_DYNAMIC_ADV)) { | |
8605 | if (CHECK_FLAG(p->cap, | |
8606 | PEER_CAP_DYNAMIC_ADV) | |
8607 | && CHECK_FLAG(p->cap, | |
8608 | PEER_CAP_DYNAMIC_RCV)) | |
8609 | json_object_string_add( | |
8610 | json_cap, "dynamic", | |
8611 | "advertisedAndReceived"); | |
8612 | else if (CHECK_FLAG( | |
8613 | p->cap, | |
8614 | PEER_CAP_DYNAMIC_ADV)) | |
8615 | json_object_string_add( | |
8616 | json_cap, "dynamic", | |
8617 | "advertised"); | |
8618 | else if (CHECK_FLAG( | |
8619 | p->cap, | |
8620 | PEER_CAP_DYNAMIC_RCV)) | |
8621 | json_object_string_add( | |
8622 | json_cap, "dynamic", | |
8623 | "received"); | |
8624 | } | |
8625 | ||
8626 | /* Extended nexthop */ | |
8627 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
8628 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
8629 | json_object *json_nxt = NULL; | |
8630 | const char *print_store; | |
8631 | ||
8632 | ||
8633 | if (CHECK_FLAG(p->cap, | |
8634 | PEER_CAP_ENHE_ADV) | |
8635 | && CHECK_FLAG(p->cap, | |
8636 | PEER_CAP_ENHE_RCV)) | |
8637 | json_object_string_add( | |
8638 | json_cap, | |
8639 | "extendedNexthop", | |
8640 | "advertisedAndReceived"); | |
8641 | else if (CHECK_FLAG(p->cap, | |
8642 | PEER_CAP_ENHE_ADV)) | |
8643 | json_object_string_add( | |
8644 | json_cap, | |
8645 | "extendedNexthop", | |
8646 | "advertised"); | |
8647 | else if (CHECK_FLAG(p->cap, | |
8648 | PEER_CAP_ENHE_RCV)) | |
8649 | json_object_string_add( | |
8650 | json_cap, | |
8651 | "extendedNexthop", | |
8652 | "received"); | |
8653 | ||
8654 | if (CHECK_FLAG(p->cap, | |
8655 | PEER_CAP_ENHE_RCV)) { | |
8656 | json_nxt = | |
8657 | json_object_new_object(); | |
8658 | ||
8659 | for (safi = SAFI_UNICAST; | |
8660 | safi < SAFI_MAX; safi++) { | |
8661 | if (CHECK_FLAG( | |
8662 | p->af_cap | |
8663 | [AFI_IP] | |
8664 | [safi], | |
8665 | PEER_CAP_ENHE_AF_RCV)) { | |
8666 | print_store = afi_safi_print( | |
8667 | AFI_IP, | |
8668 | safi); | |
8669 | json_object_string_add( | |
8670 | json_nxt, | |
8671 | print_store, | |
8672 | "recieved"); | |
8673 | } | |
8674 | } | |
8675 | json_object_object_add( | |
8676 | json_cap, | |
8677 | "extendedNexthopFamililesByPeer", | |
8678 | json_nxt); | |
8679 | } | |
8680 | } | |
8681 | ||
8682 | /* Route Refresh */ | |
8683 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
8684 | || CHECK_FLAG(p->cap, | |
8685 | PEER_CAP_REFRESH_NEW_RCV) | |
8686 | || CHECK_FLAG(p->cap, | |
8687 | PEER_CAP_REFRESH_OLD_RCV)) { | |
8688 | if (CHECK_FLAG(p->cap, | |
8689 | PEER_CAP_REFRESH_ADV) | |
8690 | && (CHECK_FLAG( | |
8691 | p->cap, | |
8692 | PEER_CAP_REFRESH_NEW_RCV) | |
8693 | || CHECK_FLAG( | |
8694 | p->cap, | |
8695 | PEER_CAP_REFRESH_OLD_RCV))) { | |
8696 | if (CHECK_FLAG( | |
8697 | p->cap, | |
8698 | PEER_CAP_REFRESH_OLD_RCV) | |
8699 | && CHECK_FLAG( | |
8700 | p->cap, | |
8701 | PEER_CAP_REFRESH_NEW_RCV)) | |
8702 | json_object_string_add( | |
8703 | json_cap, | |
8704 | "routeRefresh", | |
8705 | "advertisedAndReceivedOldNew"); | |
8706 | else { | |
8707 | if (CHECK_FLAG( | |
8708 | p->cap, | |
8709 | PEER_CAP_REFRESH_OLD_RCV)) | |
8710 | json_object_string_add( | |
8711 | json_cap, | |
8712 | "routeRefresh", | |
8713 | "advertisedAndReceivedOld"); | |
8714 | else | |
8715 | json_object_string_add( | |
8716 | json_cap, | |
8717 | "routeRefresh", | |
8718 | "advertisedAndReceivedNew"); | |
8719 | } | |
8720 | } else if ( | |
8721 | CHECK_FLAG( | |
8722 | p->cap, | |
8723 | PEER_CAP_REFRESH_ADV)) | |
8724 | json_object_string_add( | |
8725 | json_cap, | |
8726 | "routeRefresh", | |
8727 | "advertised"); | |
8728 | else if ( | |
8729 | CHECK_FLAG( | |
8730 | p->cap, | |
8731 | PEER_CAP_REFRESH_NEW_RCV) | |
8732 | || CHECK_FLAG( | |
8733 | p->cap, | |
8734 | PEER_CAP_REFRESH_OLD_RCV)) | |
8735 | json_object_string_add( | |
8736 | json_cap, | |
8737 | "routeRefresh", | |
8738 | "received"); | |
8739 | } | |
8740 | ||
8741 | /* Multiprotocol Extensions */ | |
8742 | json_object *json_multi = NULL; | |
8743 | json_multi = json_object_new_object(); | |
8744 | ||
05c7a1cc QY |
8745 | FOREACH_AFI_SAFI (afi, safi) { |
8746 | if (p->afc_adv[afi][safi] | |
8747 | || p->afc_recv[afi][safi]) { | |
8748 | json_object *json_exten = NULL; | |
8749 | json_exten = | |
8750 | json_object_new_object(); | |
8751 | ||
d62a17ae | 8752 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
8753 | && p->afc_recv[afi][safi]) |
8754 | json_object_boolean_true_add( | |
8755 | json_exten, | |
8756 | "advertisedAndReceived"); | |
8757 | else if (p->afc_adv[afi][safi]) | |
8758 | json_object_boolean_true_add( | |
8759 | json_exten, | |
8760 | "advertised"); | |
8761 | else if (p->afc_recv[afi][safi]) | |
8762 | json_object_boolean_true_add( | |
8763 | json_exten, | |
8764 | "received"); | |
d62a17ae | 8765 | |
05c7a1cc QY |
8766 | json_object_object_add( |
8767 | json_multi, | |
8768 | afi_safi_print(afi, | |
8769 | safi), | |
8770 | json_exten); | |
d62a17ae | 8771 | } |
8772 | } | |
8773 | json_object_object_add( | |
8774 | json_cap, "multiprotocolExtensions", | |
8775 | json_multi); | |
8776 | ||
d77114b7 | 8777 | /* Hostname capabilities */ |
60466a63 | 8778 | json_object *json_hname = NULL; |
d77114b7 MK |
8779 | |
8780 | json_hname = json_object_new_object(); | |
8781 | ||
8782 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
8783 | json_object_string_add( | |
60466a63 QY |
8784 | json_hname, "advHostName", |
8785 | bgp->peer_self->hostname | |
8786 | ? bgp->peer_self | |
8787 | ->hostname | |
d77114b7 MK |
8788 | : "n/a"); |
8789 | json_object_string_add( | |
60466a63 QY |
8790 | json_hname, "advDomainName", |
8791 | bgp->peer_self->domainname | |
8792 | ? bgp->peer_self | |
8793 | ->domainname | |
d77114b7 MK |
8794 | : "n/a"); |
8795 | } | |
8796 | ||
8797 | ||
8798 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
8799 | json_object_string_add( | |
60466a63 QY |
8800 | json_hname, "rcvHostName", |
8801 | p->hostname ? p->hostname | |
8802 | : "n/a"); | |
d77114b7 | 8803 | json_object_string_add( |
60466a63 QY |
8804 | json_hname, "rcvDomainName", |
8805 | p->domainname ? p->domainname | |
8806 | : "n/a"); | |
d77114b7 MK |
8807 | } |
8808 | ||
60466a63 | 8809 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
8810 | json_hname); |
8811 | ||
d62a17ae | 8812 | /* Gracefull Restart */ |
8813 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
8814 | || CHECK_FLAG(p->cap, | |
8815 | PEER_CAP_RESTART_ADV)) { | |
8816 | if (CHECK_FLAG(p->cap, | |
8817 | PEER_CAP_RESTART_ADV) | |
8818 | && CHECK_FLAG(p->cap, | |
8819 | PEER_CAP_RESTART_RCV)) | |
8820 | json_object_string_add( | |
8821 | json_cap, | |
8822 | "gracefulRestart", | |
8823 | "advertisedAndReceived"); | |
8824 | else if (CHECK_FLAG( | |
8825 | p->cap, | |
8826 | PEER_CAP_RESTART_ADV)) | |
8827 | json_object_string_add( | |
8828 | json_cap, | |
8829 | "gracefulRestartCapability", | |
8830 | "advertised"); | |
8831 | else if (CHECK_FLAG( | |
8832 | p->cap, | |
8833 | PEER_CAP_RESTART_RCV)) | |
8834 | json_object_string_add( | |
8835 | json_cap, | |
8836 | "gracefulRestartCapability", | |
8837 | "received"); | |
8838 | ||
8839 | if (CHECK_FLAG(p->cap, | |
8840 | PEER_CAP_RESTART_RCV)) { | |
8841 | int restart_af_count = 0; | |
8842 | json_object *json_restart = | |
8843 | NULL; | |
8844 | json_restart = | |
8845 | json_object_new_object(); | |
8846 | ||
8847 | json_object_int_add( | |
8848 | json_cap, | |
8849 | "gracefulRestartRemoteTimerMsecs", | |
8850 | p->v_gr_restart * 1000); | |
8851 | ||
05c7a1cc QY |
8852 | FOREACH_AFI_SAFI (afi, safi) { |
8853 | if (CHECK_FLAG( | |
8854 | p->af_cap | |
8855 | [afi] | |
8856 | [safi], | |
8857 | PEER_CAP_RESTART_AF_RCV)) { | |
8858 | json_object * | |
8859 | json_sub = | |
8860 | NULL; | |
8861 | json_sub = | |
8862 | json_object_new_object(); | |
8863 | ||
d62a17ae | 8864 | if (CHECK_FLAG( |
8865 | p->af_cap | |
8866 | [afi] | |
8867 | [safi], | |
05c7a1cc QY |
8868 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
8869 | json_object_boolean_true_add( | |
8870 | json_sub, | |
8871 | "preserved"); | |
8872 | restart_af_count++; | |
8873 | json_object_object_add( | |
8874 | json_restart, | |
8875 | afi_safi_print( | |
8876 | afi, | |
8877 | safi), | |
8878 | json_sub); | |
d62a17ae | 8879 | } |
8880 | } | |
8881 | if (!restart_af_count) { | |
8882 | json_object_string_add( | |
8883 | json_cap, | |
8884 | "addressFamiliesByPeer", | |
8885 | "none"); | |
8886 | json_object_free( | |
8887 | json_restart); | |
8888 | } else | |
8889 | json_object_object_add( | |
8890 | json_cap, | |
8891 | "addressFamiliesByPeer", | |
8892 | json_restart); | |
8893 | } | |
8894 | } | |
8895 | json_object_object_add(json_neigh, | |
8896 | "neighborCapabilities", | |
8897 | json_cap); | |
8898 | } else { | |
8899 | vty_out(vty, " Neighbor capabilities:\n"); | |
8900 | ||
8901 | /* AS4 */ | |
8902 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
8903 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
8904 | vty_out(vty, " 4 Byte AS:"); | |
8905 | if (CHECK_FLAG(p->cap, | |
8906 | PEER_CAP_AS4_ADV)) | |
8907 | vty_out(vty, " advertised"); | |
8908 | if (CHECK_FLAG(p->cap, | |
8909 | PEER_CAP_AS4_RCV)) | |
8910 | vty_out(vty, " %sreceived", | |
8911 | CHECK_FLAG( | |
8912 | p->cap, | |
8913 | PEER_CAP_AS4_ADV) | |
8914 | ? "and " | |
8915 | : ""); | |
8916 | vty_out(vty, "\n"); | |
8917 | } | |
8918 | ||
8919 | /* AddPath */ | |
8920 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
8921 | || CHECK_FLAG(p->cap, | |
8922 | PEER_CAP_ADDPATH_ADV)) { | |
8923 | vty_out(vty, " AddPath:\n"); | |
8924 | ||
05c7a1cc QY |
8925 | FOREACH_AFI_SAFI (afi, safi) { |
8926 | if (CHECK_FLAG( | |
8927 | p->af_cap[afi] | |
8928 | [safi], | |
8929 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8930 | || CHECK_FLAG( | |
8931 | p->af_cap[afi] | |
8932 | [safi], | |
8933 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
8934 | vty_out(vty, | |
8935 | " %s: TX ", | |
8936 | afi_safi_print( | |
8937 | afi, | |
8938 | safi)); | |
8939 | ||
d62a17ae | 8940 | if (CHECK_FLAG( |
8941 | p->af_cap | |
8942 | [afi] | |
8943 | [safi], | |
05c7a1cc | 8944 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 8945 | vty_out(vty, |
05c7a1cc | 8946 | "advertised %s", |
d62a17ae | 8947 | afi_safi_print( |
8948 | afi, | |
8949 | safi)); | |
8950 | ||
05c7a1cc QY |
8951 | if (CHECK_FLAG( |
8952 | p->af_cap | |
8953 | [afi] | |
8954 | [safi], | |
8955 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8956 | vty_out(vty, | |
8957 | "%sreceived", | |
8958 | CHECK_FLAG( | |
8959 | p->af_cap | |
8960 | [afi] | |
8961 | [safi], | |
8962 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8963 | ? " and " | |
8964 | : ""); | |
d62a17ae | 8965 | |
05c7a1cc QY |
8966 | vty_out(vty, "\n"); |
8967 | } | |
d62a17ae | 8968 | |
05c7a1cc QY |
8969 | if (CHECK_FLAG( |
8970 | p->af_cap[afi] | |
8971 | [safi], | |
8972 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8973 | || CHECK_FLAG( | |
8974 | p->af_cap[afi] | |
8975 | [safi], | |
8976 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
8977 | vty_out(vty, | |
8978 | " %s: RX ", | |
8979 | afi_safi_print( | |
8980 | afi, | |
8981 | safi)); | |
d62a17ae | 8982 | |
8983 | if (CHECK_FLAG( | |
8984 | p->af_cap | |
8985 | [afi] | |
8986 | [safi], | |
05c7a1cc | 8987 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 8988 | vty_out(vty, |
05c7a1cc | 8989 | "advertised %s", |
d62a17ae | 8990 | afi_safi_print( |
8991 | afi, | |
8992 | safi)); | |
8993 | ||
05c7a1cc QY |
8994 | if (CHECK_FLAG( |
8995 | p->af_cap | |
8996 | [afi] | |
8997 | [safi], | |
8998 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 8999 | vty_out(vty, |
05c7a1cc QY |
9000 | "%sreceived", |
9001 | CHECK_FLAG( | |
9002 | p->af_cap | |
9003 | [afi] | |
9004 | [safi], | |
9005 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9006 | ? " and " | |
9007 | : ""); | |
9008 | ||
9009 | vty_out(vty, "\n"); | |
d62a17ae | 9010 | } |
05c7a1cc | 9011 | } |
d62a17ae | 9012 | } |
9013 | ||
9014 | /* Dynamic */ | |
9015 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
9016 | || CHECK_FLAG(p->cap, | |
9017 | PEER_CAP_DYNAMIC_ADV)) { | |
9018 | vty_out(vty, " Dynamic:"); | |
9019 | if (CHECK_FLAG(p->cap, | |
9020 | PEER_CAP_DYNAMIC_ADV)) | |
9021 | vty_out(vty, " advertised"); | |
9022 | if (CHECK_FLAG(p->cap, | |
9023 | PEER_CAP_DYNAMIC_RCV)) | |
9024 | vty_out(vty, " %sreceived", | |
9025 | CHECK_FLAG( | |
9026 | p->cap, | |
9027 | PEER_CAP_DYNAMIC_ADV) | |
9028 | ? "and " | |
9029 | : ""); | |
9030 | vty_out(vty, "\n"); | |
9031 | } | |
9032 | ||
9033 | /* Extended nexthop */ | |
9034 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
9035 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
9036 | vty_out(vty, " Extended nexthop:"); | |
9037 | if (CHECK_FLAG(p->cap, | |
9038 | PEER_CAP_ENHE_ADV)) | |
9039 | vty_out(vty, " advertised"); | |
9040 | if (CHECK_FLAG(p->cap, | |
9041 | PEER_CAP_ENHE_RCV)) | |
9042 | vty_out(vty, " %sreceived", | |
9043 | CHECK_FLAG( | |
9044 | p->cap, | |
9045 | PEER_CAP_ENHE_ADV) | |
9046 | ? "and " | |
9047 | : ""); | |
9048 | vty_out(vty, "\n"); | |
9049 | ||
9050 | if (CHECK_FLAG(p->cap, | |
9051 | PEER_CAP_ENHE_RCV)) { | |
9052 | vty_out(vty, | |
9053 | " Address families by peer:\n "); | |
9054 | for (safi = SAFI_UNICAST; | |
9055 | safi < SAFI_MAX; safi++) | |
9056 | if (CHECK_FLAG( | |
9057 | p->af_cap | |
9058 | [AFI_IP] | |
9059 | [safi], | |
9060 | PEER_CAP_ENHE_AF_RCV)) | |
9061 | vty_out(vty, | |
9062 | " %s\n", | |
9063 | afi_safi_print( | |
9064 | AFI_IP, | |
9065 | safi)); | |
9066 | } | |
9067 | } | |
9068 | ||
9069 | /* Route Refresh */ | |
9070 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
9071 | || CHECK_FLAG(p->cap, | |
9072 | PEER_CAP_REFRESH_NEW_RCV) | |
9073 | || CHECK_FLAG(p->cap, | |
9074 | PEER_CAP_REFRESH_OLD_RCV)) { | |
9075 | vty_out(vty, " Route refresh:"); | |
9076 | if (CHECK_FLAG(p->cap, | |
9077 | PEER_CAP_REFRESH_ADV)) | |
9078 | vty_out(vty, " advertised"); | |
9079 | if (CHECK_FLAG(p->cap, | |
9080 | PEER_CAP_REFRESH_NEW_RCV) | |
9081 | || CHECK_FLAG( | |
9082 | p->cap, | |
9083 | PEER_CAP_REFRESH_OLD_RCV)) | |
9084 | vty_out(vty, " %sreceived(%s)", | |
9085 | CHECK_FLAG( | |
9086 | p->cap, | |
9087 | PEER_CAP_REFRESH_ADV) | |
9088 | ? "and " | |
9089 | : "", | |
9090 | (CHECK_FLAG( | |
9091 | p->cap, | |
9092 | PEER_CAP_REFRESH_OLD_RCV) | |
9093 | && CHECK_FLAG( | |
9094 | p->cap, | |
9095 | PEER_CAP_REFRESH_NEW_RCV)) | |
9096 | ? "old & new" | |
9097 | : CHECK_FLAG( | |
9098 | p->cap, | |
9099 | PEER_CAP_REFRESH_OLD_RCV) | |
9100 | ? "old" | |
9101 | : "new"); | |
9102 | ||
9103 | vty_out(vty, "\n"); | |
9104 | } | |
9105 | ||
9106 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
9107 | FOREACH_AFI_SAFI (afi, safi) |
9108 | if (p->afc_adv[afi][safi] | |
9109 | || p->afc_recv[afi][safi]) { | |
9110 | vty_out(vty, | |
9111 | " Address Family %s:", | |
9112 | afi_safi_print(afi, | |
9113 | safi)); | |
9114 | if (p->afc_adv[afi][safi]) | |
d62a17ae | 9115 | vty_out(vty, |
05c7a1cc QY |
9116 | " advertised"); |
9117 | if (p->afc_recv[afi][safi]) | |
9118 | vty_out(vty, | |
9119 | " %sreceived", | |
9120 | p->afc_adv[afi] | |
9121 | [safi] | |
9122 | ? "and " | |
9123 | : ""); | |
9124 | vty_out(vty, "\n"); | |
9125 | } | |
d62a17ae | 9126 | |
9127 | /* Hostname capability */ | |
60466a63 | 9128 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
9129 | |
9130 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
9131 | vty_out(vty, |
9132 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
9133 | bgp->peer_self->hostname |
9134 | ? bgp->peer_self | |
9135 | ->hostname | |
d77114b7 | 9136 | : "n/a", |
60466a63 QY |
9137 | bgp->peer_self->domainname |
9138 | ? bgp->peer_self | |
9139 | ->domainname | |
d77114b7 MK |
9140 | : "n/a"); |
9141 | } else { | |
9142 | vty_out(vty, " not advertised"); | |
d62a17ae | 9143 | } |
9144 | ||
d77114b7 | 9145 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
9146 | vty_out(vty, |
9147 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
9148 | p->hostname ? p->hostname |
9149 | : "n/a", | |
9150 | p->domainname ? p->domainname | |
9151 | : "n/a"); | |
d77114b7 MK |
9152 | } else { |
9153 | vty_out(vty, " not received"); | |
9154 | } | |
9155 | ||
9156 | vty_out(vty, "\n"); | |
9157 | ||
d62a17ae | 9158 | /* Gracefull Restart */ |
9159 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
9160 | || CHECK_FLAG(p->cap, | |
9161 | PEER_CAP_RESTART_ADV)) { | |
9162 | vty_out(vty, | |
9163 | " Graceful Restart Capabilty:"); | |
9164 | if (CHECK_FLAG(p->cap, | |
9165 | PEER_CAP_RESTART_ADV)) | |
9166 | vty_out(vty, " advertised"); | |
9167 | if (CHECK_FLAG(p->cap, | |
9168 | PEER_CAP_RESTART_RCV)) | |
9169 | vty_out(vty, " %sreceived", | |
9170 | CHECK_FLAG( | |
9171 | p->cap, | |
9172 | PEER_CAP_RESTART_ADV) | |
9173 | ? "and " | |
9174 | : ""); | |
9175 | vty_out(vty, "\n"); | |
9176 | ||
9177 | if (CHECK_FLAG(p->cap, | |
9178 | PEER_CAP_RESTART_RCV)) { | |
9179 | int restart_af_count = 0; | |
9180 | ||
9181 | vty_out(vty, | |
9182 | " Remote Restart timer is %d seconds\n", | |
9183 | p->v_gr_restart); | |
9184 | vty_out(vty, | |
9185 | " Address families by peer:\n "); | |
9186 | ||
05c7a1cc QY |
9187 | FOREACH_AFI_SAFI (afi, safi) |
9188 | if (CHECK_FLAG( | |
9189 | p->af_cap | |
9190 | [afi] | |
9191 | [safi], | |
9192 | PEER_CAP_RESTART_AF_RCV)) { | |
9193 | vty_out(vty, | |
9194 | "%s%s(%s)", | |
9195 | restart_af_count | |
9196 | ? ", " | |
9197 | : "", | |
9198 | afi_safi_print( | |
9199 | afi, | |
9200 | safi), | |
9201 | CHECK_FLAG( | |
9202 | p->af_cap | |
9203 | [afi] | |
9204 | [safi], | |
9205 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
9206 | ? "preserved" | |
9207 | : "not preserved"); | |
9208 | restart_af_count++; | |
9209 | } | |
d62a17ae | 9210 | if (!restart_af_count) |
9211 | vty_out(vty, "none"); | |
9212 | vty_out(vty, "\n"); | |
9213 | } | |
9214 | } | |
9215 | } | |
9216 | } | |
9217 | } | |
9218 | ||
9219 | /* graceful restart information */ | |
9220 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || p->t_gr_restart | |
9221 | || p->t_gr_stale) { | |
9222 | json_object *json_grace = NULL; | |
9223 | json_object *json_grace_send = NULL; | |
9224 | json_object *json_grace_recv = NULL; | |
9225 | int eor_send_af_count = 0; | |
9226 | int eor_receive_af_count = 0; | |
9227 | ||
9228 | if (use_json) { | |
9229 | json_grace = json_object_new_object(); | |
9230 | json_grace_send = json_object_new_object(); | |
9231 | json_grace_recv = json_object_new_object(); | |
9232 | ||
9233 | if (p->status == Established) { | |
05c7a1cc QY |
9234 | FOREACH_AFI_SAFI (afi, safi) { |
9235 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9236 | PEER_STATUS_EOR_SEND)) { | |
9237 | json_object_boolean_true_add( | |
9238 | json_grace_send, | |
9239 | afi_safi_print(afi, | |
9240 | safi)); | |
9241 | eor_send_af_count++; | |
d62a17ae | 9242 | } |
9243 | } | |
05c7a1cc QY |
9244 | FOREACH_AFI_SAFI (afi, safi) { |
9245 | if (CHECK_FLAG( | |
9246 | p->af_sflags[afi][safi], | |
9247 | PEER_STATUS_EOR_RECEIVED)) { | |
9248 | json_object_boolean_true_add( | |
9249 | json_grace_recv, | |
9250 | afi_safi_print(afi, | |
9251 | safi)); | |
9252 | eor_receive_af_count++; | |
d62a17ae | 9253 | } |
9254 | } | |
9255 | } | |
9256 | ||
9257 | json_object_object_add(json_grace, "endOfRibSend", | |
9258 | json_grace_send); | |
9259 | json_object_object_add(json_grace, "endOfRibRecv", | |
9260 | json_grace_recv); | |
9261 | ||
9262 | if (p->t_gr_restart) | |
9263 | json_object_int_add(json_grace, | |
9264 | "gracefulRestartTimerMsecs", | |
9265 | thread_timer_remain_second( | |
9266 | p->t_gr_restart) | |
9267 | * 1000); | |
9268 | ||
9269 | if (p->t_gr_stale) | |
9270 | json_object_int_add( | |
9271 | json_grace, | |
9272 | "gracefulStalepathTimerMsecs", | |
9273 | thread_timer_remain_second( | |
9274 | p->t_gr_stale) | |
9275 | * 1000); | |
9276 | ||
9277 | json_object_object_add( | |
9278 | json_neigh, "gracefulRestartInfo", json_grace); | |
9279 | } else { | |
9280 | vty_out(vty, " Graceful restart informations:\n"); | |
9281 | if (p->status == Established) { | |
9282 | vty_out(vty, " End-of-RIB send: "); | |
05c7a1cc QY |
9283 | FOREACH_AFI_SAFI (afi, safi) { |
9284 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9285 | PEER_STATUS_EOR_SEND)) { | |
9286 | vty_out(vty, "%s%s", | |
9287 | eor_send_af_count ? ", " | |
9288 | : "", | |
9289 | afi_safi_print(afi, | |
9290 | safi)); | |
9291 | eor_send_af_count++; | |
d62a17ae | 9292 | } |
9293 | } | |
9294 | vty_out(vty, "\n"); | |
9295 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
9296 | FOREACH_AFI_SAFI (afi, safi) { |
9297 | if (CHECK_FLAG( | |
9298 | p->af_sflags[afi][safi], | |
9299 | PEER_STATUS_EOR_RECEIVED)) { | |
9300 | vty_out(vty, "%s%s", | |
9301 | eor_receive_af_count | |
9302 | ? ", " | |
9303 | : "", | |
9304 | afi_safi_print(afi, | |
9305 | safi)); | |
9306 | eor_receive_af_count++; | |
d62a17ae | 9307 | } |
9308 | } | |
9309 | vty_out(vty, "\n"); | |
9310 | } | |
9311 | ||
9312 | if (p->t_gr_restart) | |
9313 | vty_out(vty, | |
9314 | " The remaining time of restart timer is %ld\n", | |
9315 | thread_timer_remain_second( | |
9316 | p->t_gr_restart)); | |
9317 | ||
9318 | if (p->t_gr_stale) | |
9319 | vty_out(vty, | |
9320 | " The remaining time of stalepath timer is %ld\n", | |
9321 | thread_timer_remain_second( | |
9322 | p->t_gr_stale)); | |
9323 | } | |
9324 | } | |
9325 | if (use_json) { | |
9326 | json_object *json_stat = NULL; | |
9327 | json_stat = json_object_new_object(); | |
9328 | /* Packet counts. */ | |
9329 | json_object_int_add(json_stat, "depthInq", 0); | |
9330 | json_object_int_add(json_stat, "depthOutq", | |
9331 | (unsigned long)p->obuf->count); | |
9332 | json_object_int_add(json_stat, "opensSent", p->open_out); | |
9333 | json_object_int_add(json_stat, "opensRecv", p->open_in); | |
9334 | json_object_int_add(json_stat, "notificationsSent", | |
9335 | p->notify_out); | |
9336 | json_object_int_add(json_stat, "notificationsRecv", | |
9337 | p->notify_in); | |
9338 | json_object_int_add(json_stat, "updatesSent", p->update_out); | |
9339 | json_object_int_add(json_stat, "updatesRecv", p->update_in); | |
9340 | json_object_int_add(json_stat, "keepalivesSent", | |
9341 | p->keepalive_out); | |
9342 | json_object_int_add(json_stat, "keepalivesRecv", | |
9343 | p->keepalive_in); | |
9344 | json_object_int_add(json_stat, "routeRefreshSent", | |
9345 | p->refresh_out); | |
9346 | json_object_int_add(json_stat, "routeRefreshRecv", | |
9347 | p->refresh_in); | |
9348 | json_object_int_add(json_stat, "capabilitySent", | |
9349 | p->dynamic_cap_out); | |
9350 | json_object_int_add(json_stat, "capabilityRecv", | |
9351 | p->dynamic_cap_in); | |
9352 | json_object_int_add(json_stat, "totalSent", | |
9353 | p->open_out + p->notify_out + p->update_out | |
9354 | + p->keepalive_out + p->refresh_out | |
9355 | + p->dynamic_cap_out); | |
9356 | json_object_int_add(json_stat, "totalRecv", | |
9357 | p->open_in + p->notify_in + p->update_in | |
9358 | + p->keepalive_in + p->refresh_in | |
9359 | + p->dynamic_cap_in); | |
9360 | json_object_object_add(json_neigh, "messageStats", json_stat); | |
9361 | } else { | |
9362 | /* Packet counts. */ | |
9363 | vty_out(vty, " Message statistics:\n"); | |
9364 | vty_out(vty, " Inq depth is 0\n"); | |
9365 | vty_out(vty, " Outq depth is %lu\n", | |
9366 | (unsigned long)p->obuf->count); | |
9367 | vty_out(vty, " Sent Rcvd\n"); | |
9368 | vty_out(vty, " Opens: %10d %10d\n", p->open_out, | |
9369 | p->open_in); | |
9370 | vty_out(vty, " Notifications: %10d %10d\n", p->notify_out, | |
9371 | p->notify_in); | |
9372 | vty_out(vty, " Updates: %10d %10d\n", p->update_out, | |
9373 | p->update_in); | |
9374 | vty_out(vty, " Keepalives: %10d %10d\n", p->keepalive_out, | |
9375 | p->keepalive_in); | |
9376 | vty_out(vty, " Route Refresh: %10d %10d\n", p->refresh_out, | |
9377 | p->refresh_in); | |
9378 | vty_out(vty, " Capability: %10d %10d\n", | |
9379 | p->dynamic_cap_out, p->dynamic_cap_in); | |
9380 | vty_out(vty, " Total: %10d %10d\n", | |
9381 | p->open_out + p->notify_out + p->update_out | |
9382 | + p->keepalive_out + p->refresh_out | |
9383 | + p->dynamic_cap_out, | |
9384 | p->open_in + p->notify_in + p->update_in | |
9385 | + p->keepalive_in + p->refresh_in | |
9386 | + p->dynamic_cap_in); | |
9387 | } | |
9388 | ||
9389 | if (use_json) { | |
9390 | /* advertisement-interval */ | |
9391 | json_object_int_add(json_neigh, | |
9392 | "minBtwnAdvertisementRunsTimerMsecs", | |
9393 | p->v_routeadv * 1000); | |
9394 | ||
9395 | /* Update-source. */ | |
9396 | if (p->update_if || p->update_source) { | |
9397 | if (p->update_if) | |
9398 | json_object_string_add(json_neigh, | |
9399 | "updateSource", | |
9400 | p->update_if); | |
9401 | else if (p->update_source) | |
9402 | json_object_string_add( | |
9403 | json_neigh, "updateSource", | |
9404 | sockunion2str(p->update_source, buf1, | |
9405 | SU_ADDRSTRLEN)); | |
9406 | } | |
9407 | } else { | |
9408 | /* advertisement-interval */ | |
9409 | vty_out(vty, | |
9410 | " Minimum time between advertisement runs is %d seconds\n", | |
9411 | p->v_routeadv); | |
9412 | ||
9413 | /* Update-source. */ | |
9414 | if (p->update_if || p->update_source) { | |
9415 | vty_out(vty, " Update source is "); | |
9416 | if (p->update_if) | |
9417 | vty_out(vty, "%s", p->update_if); | |
9418 | else if (p->update_source) | |
9419 | vty_out(vty, "%s", | |
9420 | sockunion2str(p->update_source, buf1, | |
9421 | SU_ADDRSTRLEN)); | |
9422 | vty_out(vty, "\n"); | |
9423 | } | |
9424 | ||
9425 | vty_out(vty, "\n"); | |
9426 | } | |
9427 | ||
9428 | /* Address Family Information */ | |
9429 | json_object *json_hold = NULL; | |
9430 | ||
9431 | if (use_json) | |
9432 | json_hold = json_object_new_object(); | |
9433 | ||
05c7a1cc QY |
9434 | FOREACH_AFI_SAFI (afi, safi) |
9435 | if (p->afc[afi][safi]) | |
9436 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
9437 | json_hold); | |
d62a17ae | 9438 | |
9439 | if (use_json) { | |
9440 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
9441 | json_hold); | |
9442 | json_object_int_add(json_neigh, "connectionsEstablished", | |
9443 | p->established); | |
9444 | json_object_int_add(json_neigh, "connectionsDropped", | |
9445 | p->dropped); | |
9446 | } else | |
9447 | vty_out(vty, " Connections established %d; dropped %d\n", | |
9448 | p->established, p->dropped); | |
9449 | ||
9450 | if (!p->last_reset) { | |
9451 | if (use_json) | |
9452 | json_object_string_add(json_neigh, "lastReset", | |
9453 | "never"); | |
9454 | else | |
9455 | vty_out(vty, " Last reset never\n"); | |
9456 | } else { | |
9457 | if (use_json) { | |
9458 | time_t uptime; | |
9459 | struct tm *tm; | |
9460 | ||
9461 | uptime = bgp_clock(); | |
9462 | uptime -= p->resettime; | |
9463 | tm = gmtime(&uptime); | |
9464 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
9465 | (tm->tm_sec * 1000) | |
9466 | + (tm->tm_min * 60000) | |
9467 | + (tm->tm_hour * 3600000)); | |
9468 | json_object_string_add( | |
9469 | json_neigh, "lastResetDueTo", | |
9470 | peer_down_str[(int)p->last_reset]); | |
9471 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
9472 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
9473 | char errorcodesubcode_hexstr[5]; | |
9474 | char errorcodesubcode_str[256]; | |
9475 | ||
9476 | code_str = bgp_notify_code_str(p->notify.code); | |
9477 | subcode_str = bgp_notify_subcode_str( | |
9478 | p->notify.code, p->notify.subcode); | |
9479 | ||
9480 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
9481 | p->notify.code, p->notify.subcode); | |
9482 | json_object_string_add(json_neigh, | |
9483 | "lastErrorCodeSubcode", | |
9484 | errorcodesubcode_hexstr); | |
9485 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
9486 | code_str, subcode_str); | |
9487 | json_object_string_add(json_neigh, | |
9488 | "lastNotificationReason", | |
9489 | errorcodesubcode_str); | |
9490 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
9491 | && p->notify.code == BGP_NOTIFY_CEASE | |
9492 | && (p->notify.subcode | |
9493 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
9494 | || p->notify.subcode | |
9495 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
9496 | && p->notify.length) { | |
9497 | char msgbuf[1024]; | |
9498 | const char *msg_str; | |
9499 | ||
9500 | msg_str = bgp_notify_admin_message( | |
9501 | msgbuf, sizeof(msgbuf), | |
9502 | (u_char *)p->notify.data, | |
9503 | p->notify.length); | |
9504 | if (msg_str) | |
9505 | json_object_string_add( | |
9506 | json_neigh, | |
9507 | "lastShutdownDescription", | |
9508 | msg_str); | |
9509 | } | |
9510 | } | |
9511 | } else { | |
9512 | vty_out(vty, " Last reset %s, ", | |
9513 | peer_uptime(p->resettime, timebuf, | |
9514 | BGP_UPTIME_LEN, 0, NULL)); | |
9515 | ||
9516 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
9517 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
9518 | code_str = bgp_notify_code_str(p->notify.code); | |
9519 | subcode_str = bgp_notify_subcode_str( | |
9520 | p->notify.code, p->notify.subcode); | |
9521 | vty_out(vty, "due to NOTIFICATION %s (%s%s)\n", | |
9522 | p->last_reset == PEER_DOWN_NOTIFY_SEND | |
9523 | ? "sent" | |
9524 | : "received", | |
9525 | code_str, subcode_str); | |
9526 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
9527 | && p->notify.code == BGP_NOTIFY_CEASE | |
9528 | && (p->notify.subcode | |
9529 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
9530 | || p->notify.subcode | |
9531 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
9532 | && p->notify.length) { | |
9533 | char msgbuf[1024]; | |
9534 | const char *msg_str; | |
9535 | ||
9536 | msg_str = bgp_notify_admin_message( | |
9537 | msgbuf, sizeof(msgbuf), | |
9538 | (u_char *)p->notify.data, | |
9539 | p->notify.length); | |
9540 | if (msg_str) | |
9541 | vty_out(vty, | |
9542 | " Message: \"%s\"\n", | |
9543 | msg_str); | |
9544 | } | |
9545 | } else { | |
9546 | vty_out(vty, "due to %s\n", | |
9547 | peer_down_str[(int)p->last_reset]); | |
9548 | } | |
9549 | ||
9550 | if (p->last_reset_cause_size) { | |
9551 | msg = p->last_reset_cause; | |
9552 | vty_out(vty, | |
9553 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
9554 | for (i = 1; i <= p->last_reset_cause_size; | |
9555 | i++) { | |
9556 | vty_out(vty, "%02X", *msg++); | |
9557 | ||
9558 | if (i != p->last_reset_cause_size) { | |
9559 | if (i % 16 == 0) { | |
9560 | vty_out(vty, "\n "); | |
9561 | } else if (i % 4 == 0) { | |
9562 | vty_out(vty, " "); | |
9563 | } | |
9564 | } | |
9565 | } | |
9566 | vty_out(vty, "\n"); | |
9567 | } | |
9568 | } | |
9569 | } | |
9570 | ||
9571 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
9572 | if (use_json) | |
9573 | json_object_boolean_true_add(json_neigh, | |
9574 | "prefixesConfigExceedMax"); | |
9575 | else | |
9576 | vty_out(vty, | |
9577 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
9578 | ||
9579 | if (p->t_pmax_restart) { | |
9580 | if (use_json) { | |
9581 | json_object_boolean_true_add( | |
9582 | json_neigh, "reducePrefixNumFrom"); | |
9583 | json_object_int_add(json_neigh, | |
9584 | "restartInTimerMsec", | |
9585 | thread_timer_remain_second( | |
9586 | p->t_pmax_restart) | |
9587 | * 1000); | |
9588 | } else | |
9589 | vty_out(vty, | |
9590 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
9d303b37 DL |
9591 | p->host, thread_timer_remain_second( |
9592 | p->t_pmax_restart)); | |
d62a17ae | 9593 | } else { |
9594 | if (use_json) | |
9595 | json_object_boolean_true_add( | |
9596 | json_neigh, | |
9597 | "reducePrefixNumAndClearIpBgp"); | |
9598 | else | |
9599 | vty_out(vty, | |
9600 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
9601 | p->host); | |
9602 | } | |
9603 | } | |
9604 | ||
9605 | /* EBGP Multihop and GTSM */ | |
9606 | if (p->sort != BGP_PEER_IBGP) { | |
9607 | if (use_json) { | |
9608 | if (p->gtsm_hops > 0) | |
9609 | json_object_int_add(json_neigh, | |
9610 | "externalBgpNbrMaxHopsAway", | |
9611 | p->gtsm_hops); | |
9612 | else if (p->ttl > 1) | |
9613 | json_object_int_add(json_neigh, | |
9614 | "externalBgpNbrMaxHopsAway", | |
9615 | p->ttl); | |
9616 | } else { | |
9617 | if (p->gtsm_hops > 0) | |
9618 | vty_out(vty, | |
9619 | " External BGP neighbor may be up to %d hops away.\n", | |
9620 | p->gtsm_hops); | |
9621 | else if (p->ttl > 1) | |
9622 | vty_out(vty, | |
9623 | " External BGP neighbor may be up to %d hops away.\n", | |
9624 | p->ttl); | |
9625 | } | |
9626 | } else { | |
9627 | if (p->gtsm_hops > 0) { | |
9628 | if (use_json) | |
9629 | json_object_int_add(json_neigh, | |
9630 | "internalBgpNbrMaxHopsAway", | |
9631 | p->gtsm_hops); | |
9632 | else | |
9633 | vty_out(vty, | |
9634 | " Internal BGP neighbor may be up to %d hops away.\n", | |
9635 | p->gtsm_hops); | |
9636 | } | |
9637 | } | |
9638 | ||
9639 | /* Local address. */ | |
9640 | if (p->su_local) { | |
9641 | if (use_json) { | |
9642 | json_object_string_add(json_neigh, "hostLocal", | |
9643 | sockunion2str(p->su_local, buf1, | |
9644 | SU_ADDRSTRLEN)); | |
9645 | json_object_int_add(json_neigh, "portLocal", | |
9646 | ntohs(p->su_local->sin.sin_port)); | |
9647 | } else | |
9648 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
9649 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
9650 | ntohs(p->su_local->sin.sin_port)); | |
9651 | } | |
9652 | ||
9653 | /* Remote address. */ | |
9654 | if (p->su_remote) { | |
9655 | if (use_json) { | |
9656 | json_object_string_add(json_neigh, "hostForeign", | |
9657 | sockunion2str(p->su_remote, buf1, | |
9658 | SU_ADDRSTRLEN)); | |
9659 | json_object_int_add(json_neigh, "portForeign", | |
9660 | ntohs(p->su_remote->sin.sin_port)); | |
9661 | } else | |
9662 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
9663 | sockunion2str(p->su_remote, buf1, | |
9664 | SU_ADDRSTRLEN), | |
9665 | ntohs(p->su_remote->sin.sin_port)); | |
9666 | } | |
9667 | ||
9668 | /* Nexthop display. */ | |
9669 | if (p->su_local) { | |
9670 | if (use_json) { | |
9671 | json_object_string_add(json_neigh, "nexthop", | |
9672 | inet_ntop(AF_INET, | |
9673 | &p->nexthop.v4, buf1, | |
9674 | sizeof(buf1))); | |
9675 | json_object_string_add(json_neigh, "nexthopGlobal", | |
9676 | inet_ntop(AF_INET6, | |
9677 | &p->nexthop.v6_global, | |
9678 | buf1, sizeof(buf1))); | |
9679 | json_object_string_add(json_neigh, "nexthopLocal", | |
9680 | inet_ntop(AF_INET6, | |
9681 | &p->nexthop.v6_local, | |
9682 | buf1, sizeof(buf1))); | |
9683 | if (p->shared_network) | |
9684 | json_object_string_add(json_neigh, | |
9685 | "bgpConnection", | |
9686 | "sharedNetwork"); | |
9687 | else | |
9688 | json_object_string_add(json_neigh, | |
9689 | "bgpConnection", | |
9690 | "nonSharedNetwork"); | |
9691 | } else { | |
9692 | vty_out(vty, "Nexthop: %s\n", | |
9693 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
9694 | sizeof(buf1))); | |
9695 | vty_out(vty, "Nexthop global: %s\n", | |
9696 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
9697 | sizeof(buf1))); | |
9698 | vty_out(vty, "Nexthop local: %s\n", | |
9699 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
9700 | sizeof(buf1))); | |
9701 | vty_out(vty, "BGP connection: %s\n", | |
9702 | p->shared_network ? "shared network" | |
9703 | : "non shared network"); | |
9704 | } | |
9705 | } | |
9706 | ||
9707 | /* Timer information. */ | |
9708 | if (use_json) { | |
9709 | json_object_int_add(json_neigh, "connectRetryTimer", | |
9710 | p->v_connect); | |
9711 | if (p->status == Established && p->rtt) | |
9712 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
9713 | p->rtt); | |
9714 | if (p->t_start) | |
9715 | json_object_int_add( | |
9716 | json_neigh, "nextStartTimerDueInMsecs", | |
9717 | thread_timer_remain_second(p->t_start) * 1000); | |
9718 | if (p->t_connect) | |
9719 | json_object_int_add( | |
9720 | json_neigh, "nextConnectTimerDueInMsecs", | |
9721 | thread_timer_remain_second(p->t_connect) | |
9722 | * 1000); | |
9723 | if (p->t_routeadv) { | |
9724 | json_object_int_add(json_neigh, "mraiInterval", | |
9725 | p->v_routeadv); | |
9726 | json_object_int_add( | |
9727 | json_neigh, "mraiTimerExpireInMsecs", | |
9728 | thread_timer_remain_second(p->t_routeadv) | |
9729 | * 1000); | |
9730 | } | |
9731 | if (p->password) | |
9732 | json_object_int_add(json_neigh, "authenticationEnabled", | |
9733 | 1); | |
9734 | ||
9735 | if (p->t_read) | |
9736 | json_object_string_add(json_neigh, "readThread", "on"); | |
9737 | else | |
9738 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
9739 | |
9740 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 9741 | json_object_string_add(json_neigh, "writeThread", "on"); |
9742 | else | |
9743 | json_object_string_add(json_neigh, "writeThread", | |
9744 | "off"); | |
9745 | } else { | |
9746 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
9747 | p->v_connect); | |
9748 | if (p->status == Established && p->rtt) | |
9749 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
9750 | p->rtt); | |
9751 | if (p->t_start) | |
9752 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
9753 | thread_timer_remain_second(p->t_start)); | |
9754 | if (p->t_connect) | |
9755 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
9756 | thread_timer_remain_second(p->t_connect)); | |
9757 | if (p->t_routeadv) | |
9758 | vty_out(vty, | |
9759 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
9760 | p->v_routeadv, | |
9761 | thread_timer_remain_second(p->t_routeadv)); | |
9762 | if (p->password) | |
9763 | vty_out(vty, "Peer Authentication Enabled\n"); | |
9764 | ||
9765 | vty_out(vty, "Read thread: %s Write thread: %s\n", | |
49507a6f QY |
9766 | p->t_read ? "on" : "off", |
9767 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
9768 | ? "on" | |
9769 | : "off"); | |
d62a17ae | 9770 | } |
9771 | ||
9772 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
9773 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
9774 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
9775 | ||
9776 | if (!use_json) | |
9777 | vty_out(vty, "\n"); | |
9778 | ||
9779 | /* BFD information. */ | |
9780 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
9781 | ||
9782 | if (use_json) { | |
9783 | if (p->conf_if) /* Configured interface name. */ | |
9784 | json_object_object_add(json, p->conf_if, json_neigh); | |
9785 | else /* Configured IP address. */ | |
9786 | json_object_object_add(json, p->host, json_neigh); | |
9787 | } | |
9788 | } | |
9789 | ||
9790 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, | |
9791 | enum show_type type, union sockunion *su, | |
9792 | const char *conf_if, u_char use_json, | |
9793 | json_object *json) | |
9794 | { | |
9795 | struct listnode *node, *nnode; | |
9796 | struct peer *peer; | |
9797 | int find = 0; | |
9798 | ||
9799 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
9800 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
9801 | continue; | |
9802 | ||
9803 | switch (type) { | |
9804 | case show_all: | |
9805 | bgp_show_peer(vty, peer, use_json, json); | |
9806 | break; | |
9807 | case show_peer: | |
9808 | if (conf_if) { | |
9809 | if ((peer->conf_if | |
9810 | && !strcmp(peer->conf_if, conf_if)) | |
9811 | || (peer->hostname | |
9812 | && !strcmp(peer->hostname, conf_if))) { | |
9813 | find = 1; | |
9814 | bgp_show_peer(vty, peer, use_json, | |
9815 | json); | |
9816 | } | |
9817 | } else { | |
9818 | if (sockunion_same(&peer->su, su)) { | |
9819 | find = 1; | |
9820 | bgp_show_peer(vty, peer, use_json, | |
9821 | json); | |
9822 | } | |
9823 | } | |
9824 | break; | |
9825 | } | |
9826 | } | |
9827 | ||
9828 | if (type == show_peer && !find) { | |
9829 | if (use_json) | |
9830 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
9831 | else | |
9832 | vty_out(vty, "%% No such neighbor\n"); | |
9833 | } | |
9834 | ||
9835 | if (use_json) { | |
57a9c8a8 | 9836 | bgp_show_bestpath_json(bgp, json); |
9d303b37 DL |
9837 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
9838 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9839 | json_object_free(json); |
9840 | } else { | |
9841 | vty_out(vty, "\n"); | |
9842 | } | |
9843 | ||
9844 | return CMD_SUCCESS; | |
9845 | } | |
9846 | ||
9847 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, | |
9848 | u_char use_json) | |
9849 | { | |
0291c246 MK |
9850 | struct listnode *node, *nnode; |
9851 | struct bgp *bgp; | |
9852 | json_object *json = NULL; | |
9853 | int is_first = 1; | |
d62a17ae | 9854 | |
9855 | if (use_json) | |
9856 | vty_out(vty, "{\n"); | |
9857 | ||
9858 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9859 | if (use_json) { | |
9860 | if (!(json = json_object_new_object())) { | |
9861 | zlog_err( | |
9862 | "Unable to allocate memory for JSON object"); | |
9863 | vty_out(vty, | |
9864 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
9865 | return; | |
9866 | } | |
9867 | ||
9868 | json_object_int_add(json, "vrfId", | |
9869 | (bgp->vrf_id == VRF_UNKNOWN) | |
9870 | ? -1 | |
9871 | : bgp->vrf_id); | |
9872 | json_object_string_add( | |
9873 | json, "vrfName", | |
9874 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9875 | ? "Default" | |
9876 | : bgp->name); | |
9877 | ||
9878 | if (!is_first) | |
9879 | vty_out(vty, ",\n"); | |
9880 | else | |
9881 | is_first = 0; | |
9882 | ||
9883 | vty_out(vty, "\"%s\":", | |
9884 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9885 | ? "Default" | |
9886 | : bgp->name); | |
9887 | } else { | |
9888 | vty_out(vty, "\nInstance %s:\n", | |
9889 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9890 | ? "Default" | |
9891 | : bgp->name); | |
9892 | } | |
9893 | bgp_show_neighbor(vty, bgp, show_all, NULL, NULL, use_json, | |
9894 | json); | |
9895 | } | |
9896 | ||
9897 | if (use_json) | |
9898 | vty_out(vty, "}\n"); | |
9899 | } | |
9900 | ||
9901 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
9902 | enum show_type type, const char *ip_str, | |
9903 | u_char use_json) | |
9904 | { | |
9905 | int ret; | |
9906 | struct bgp *bgp; | |
9907 | union sockunion su; | |
9908 | json_object *json = NULL; | |
9909 | ||
9910 | if (name) { | |
9911 | if (strmatch(name, "all")) { | |
9912 | bgp_show_all_instances_neighbors_vty(vty, use_json); | |
9913 | return CMD_SUCCESS; | |
9914 | } else { | |
9915 | bgp = bgp_lookup_by_name(name); | |
9916 | if (!bgp) { | |
9917 | if (use_json) { | |
9918 | json = json_object_new_object(); | |
9919 | json_object_boolean_true_add( | |
9920 | json, "bgpNoSuchInstance"); | |
9921 | vty_out(vty, "%s\n", | |
9922 | json_object_to_json_string_ext( | |
9923 | json, | |
9924 | JSON_C_TO_STRING_PRETTY)); | |
9925 | json_object_free(json); | |
9926 | } else | |
9927 | vty_out(vty, | |
9928 | "%% No such BGP instance exist\n"); | |
9929 | ||
9930 | return CMD_WARNING; | |
9931 | } | |
9932 | } | |
9933 | } else { | |
9934 | bgp = bgp_get_default(); | |
9935 | } | |
9936 | ||
9937 | if (bgp) { | |
9938 | json = json_object_new_object(); | |
9939 | if (ip_str) { | |
9940 | ret = str2sockunion(ip_str, &su); | |
9941 | if (ret < 0) | |
9942 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
9943 | use_json, json); | |
9944 | else | |
9945 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
9946 | use_json, json); | |
9947 | } else { | |
9948 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
9949 | json); | |
9950 | } | |
9951 | json_object_free(json); | |
9952 | } | |
9953 | ||
9954 | return CMD_SUCCESS; | |
4fb25c53 DW |
9955 | } |
9956 | ||
716b2d8a | 9957 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 9958 | DEFUN (show_ip_bgp_neighbors, |
9959 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 9960 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 9961 | SHOW_STR |
9962 | IP_STR | |
9963 | BGP_STR | |
f2a8972b | 9964 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
9965 | "Address Family\n" |
9966 | "Address Family\n" | |
718e3744 | 9967 | "Detailed information on TCP and BGP neighbor connections\n" |
9968 | "Neighbor to display information about\n" | |
a80beece | 9969 | "Neighbor to display information about\n" |
91d37724 | 9970 | "Neighbor on BGP configured interface\n" |
9973d184 | 9971 | JSON_STR) |
718e3744 | 9972 | { |
d62a17ae | 9973 | char *vrf = NULL; |
9974 | char *sh_arg = NULL; | |
9975 | enum show_type sh_type; | |
718e3744 | 9976 | |
d62a17ae | 9977 | u_char uj = use_json(argc, argv); |
718e3744 | 9978 | |
d62a17ae | 9979 | int idx = 0; |
718e3744 | 9980 | |
d62a17ae | 9981 | if (argv_find(argv, argc, "view", &idx) |
9982 | || argv_find(argv, argc, "vrf", &idx)) | |
9983 | vrf = argv[idx + 1]->arg; | |
718e3744 | 9984 | |
d62a17ae | 9985 | idx++; |
9986 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
9987 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
9988 | || argv_find(argv, argc, "WORD", &idx)) { | |
9989 | sh_type = show_peer; | |
9990 | sh_arg = argv[idx]->arg; | |
9991 | } else | |
9992 | sh_type = show_all; | |
856ca177 | 9993 | |
d62a17ae | 9994 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 9995 | } |
9996 | ||
716b2d8a | 9997 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 9998 | paths' and `show ip mbgp paths'. Those functions results are the |
9999 | same.*/ | |
f412b39a | 10000 | DEFUN (show_ip_bgp_paths, |
718e3744 | 10001 | show_ip_bgp_paths_cmd, |
46f296b4 | 10002 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 10003 | SHOW_STR |
10004 | IP_STR | |
10005 | BGP_STR | |
46f296b4 | 10006 | BGP_SAFI_HELP_STR |
718e3744 | 10007 | "Path information\n") |
10008 | { | |
d62a17ae | 10009 | vty_out(vty, "Address Refcnt Path\n"); |
10010 | aspath_print_all_vty(vty); | |
10011 | return CMD_SUCCESS; | |
718e3744 | 10012 | } |
10013 | ||
718e3744 | 10014 | #include "hash.h" |
10015 | ||
d62a17ae | 10016 | static void community_show_all_iterator(struct hash_backet *backet, |
10017 | struct vty *vty) | |
718e3744 | 10018 | { |
d62a17ae | 10019 | struct community *com; |
718e3744 | 10020 | |
d62a17ae | 10021 | com = (struct community *)backet->data; |
3f65c5b1 | 10022 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 10023 | community_str(com, false)); |
718e3744 | 10024 | } |
10025 | ||
10026 | /* Show BGP's community internal data. */ | |
f412b39a | 10027 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 10028 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 10029 | "show [ip] bgp community-info", |
718e3744 | 10030 | SHOW_STR |
10031 | IP_STR | |
10032 | BGP_STR | |
10033 | "List all bgp community information\n") | |
10034 | { | |
d62a17ae | 10035 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 10036 | |
d62a17ae | 10037 | hash_iterate(community_hash(), |
10038 | (void (*)(struct hash_backet *, | |
10039 | void *))community_show_all_iterator, | |
10040 | vty); | |
718e3744 | 10041 | |
d62a17ae | 10042 | return CMD_SUCCESS; |
718e3744 | 10043 | } |
10044 | ||
d62a17ae | 10045 | static void lcommunity_show_all_iterator(struct hash_backet *backet, |
10046 | struct vty *vty) | |
57d187bc | 10047 | { |
d62a17ae | 10048 | struct lcommunity *lcom; |
57d187bc | 10049 | |
d62a17ae | 10050 | lcom = (struct lcommunity *)backet->data; |
3f65c5b1 | 10051 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
d62a17ae | 10052 | lcommunity_str(lcom)); |
57d187bc JS |
10053 | } |
10054 | ||
10055 | /* Show BGP's community internal data. */ | |
10056 | DEFUN (show_ip_bgp_lcommunity_info, | |
10057 | show_ip_bgp_lcommunity_info_cmd, | |
10058 | "show ip bgp large-community-info", | |
10059 | SHOW_STR | |
10060 | IP_STR | |
10061 | BGP_STR | |
10062 | "List all bgp large-community information\n") | |
10063 | { | |
d62a17ae | 10064 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 10065 | |
d62a17ae | 10066 | hash_iterate(lcommunity_hash(), |
10067 | (void (*)(struct hash_backet *, | |
10068 | void *))lcommunity_show_all_iterator, | |
10069 | vty); | |
57d187bc | 10070 | |
d62a17ae | 10071 | return CMD_SUCCESS; |
57d187bc JS |
10072 | } |
10073 | ||
10074 | ||
f412b39a | 10075 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 10076 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 10077 | "show [ip] bgp attribute-info", |
718e3744 | 10078 | SHOW_STR |
10079 | IP_STR | |
10080 | BGP_STR | |
10081 | "List all bgp attribute information\n") | |
10082 | { | |
d62a17ae | 10083 | attr_show_all(vty); |
10084 | return CMD_SUCCESS; | |
718e3744 | 10085 | } |
6b0655a2 | 10086 | |
d62a17ae | 10087 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
10088 | safi_t safi) | |
f186de26 | 10089 | { |
d62a17ae | 10090 | struct listnode *node, *nnode; |
10091 | struct bgp *bgp; | |
f186de26 | 10092 | |
d62a17ae | 10093 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
10094 | vty_out(vty, "\nInstance %s:\n", | |
10095 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
10096 | ? "Default" | |
10097 | : bgp->name); | |
10098 | update_group_show(bgp, afi, safi, vty, 0); | |
10099 | } | |
f186de26 | 10100 | } |
10101 | ||
d62a17ae | 10102 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
10103 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 10104 | { |
d62a17ae | 10105 | struct bgp *bgp; |
4fb25c53 | 10106 | |
d62a17ae | 10107 | if (name) { |
10108 | if (strmatch(name, "all")) { | |
10109 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
10110 | return CMD_SUCCESS; | |
10111 | } else { | |
10112 | bgp = bgp_lookup_by_name(name); | |
10113 | } | |
10114 | } else { | |
10115 | bgp = bgp_get_default(); | |
10116 | } | |
4fb25c53 | 10117 | |
d62a17ae | 10118 | if (bgp) |
10119 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
10120 | return CMD_SUCCESS; | |
4fb25c53 DW |
10121 | } |
10122 | ||
8fe8a7f6 DS |
10123 | DEFUN (show_ip_bgp_updgrps, |
10124 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 10125 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 10126 | SHOW_STR |
10127 | IP_STR | |
10128 | BGP_STR | |
10129 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 10130 | BGP_AFI_HELP_STR |
9bedbb1e | 10131 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
10132 | "Detailed info about dynamic update groups\n" |
10133 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 10134 | { |
d62a17ae | 10135 | char *vrf = NULL; |
10136 | afi_t afi = AFI_IP6; | |
10137 | safi_t safi = SAFI_UNICAST; | |
10138 | uint64_t subgrp_id = 0; | |
10139 | ||
10140 | int idx = 0; | |
10141 | ||
10142 | /* show [ip] bgp */ | |
10143 | if (argv_find(argv, argc, "ip", &idx)) | |
10144 | afi = AFI_IP; | |
10145 | /* [<view|vrf> VIEWVRFNAME] */ | |
10146 | if (argv_find(argv, argc, "view", &idx) | |
10147 | || argv_find(argv, argc, "vrf", &idx)) | |
10148 | vrf = argv[++idx]->arg; | |
10149 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
10150 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
10151 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
10152 | } | |
5bf15956 | 10153 | |
d62a17ae | 10154 | /* get subgroup id, if provided */ |
10155 | idx = argc - 1; | |
10156 | if (argv[idx]->type == VARIABLE_TKN) | |
10157 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 10158 | |
d62a17ae | 10159 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
10160 | } |
10161 | ||
f186de26 | 10162 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
10163 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 10164 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 10165 | SHOW_STR |
716b2d8a | 10166 | IP_STR |
f186de26 | 10167 | BGP_STR |
10168 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 10169 | "Detailed info about dynamic update groups\n") |
f186de26 | 10170 | { |
d62a17ae | 10171 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
10172 | return CMD_SUCCESS; | |
f186de26 | 10173 | } |
10174 | ||
5bf15956 DW |
10175 | DEFUN (show_bgp_updgrps_stats, |
10176 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 10177 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 10178 | SHOW_STR |
716b2d8a | 10179 | IP_STR |
3f9c7369 | 10180 | BGP_STR |
0c7b1b01 | 10181 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
10182 | "Statistics\n") |
10183 | { | |
d62a17ae | 10184 | struct bgp *bgp; |
3f9c7369 | 10185 | |
d62a17ae | 10186 | bgp = bgp_get_default(); |
10187 | if (bgp) | |
10188 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 10189 | |
d62a17ae | 10190 | return CMD_SUCCESS; |
3f9c7369 DS |
10191 | } |
10192 | ||
8386ac43 | 10193 | DEFUN (show_bgp_instance_updgrps_stats, |
10194 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 10195 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 10196 | SHOW_STR |
716b2d8a | 10197 | IP_STR |
8386ac43 | 10198 | BGP_STR |
10199 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10200 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10201 | "Statistics\n") |
10202 | { | |
d62a17ae | 10203 | int idx_word = 3; |
10204 | struct bgp *bgp; | |
8386ac43 | 10205 | |
d62a17ae | 10206 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
10207 | if (bgp) | |
10208 | update_group_show_stats(bgp, vty); | |
8386ac43 | 10209 | |
d62a17ae | 10210 | return CMD_SUCCESS; |
8386ac43 | 10211 | } |
10212 | ||
d62a17ae | 10213 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
10214 | afi_t afi, safi_t safi, | |
10215 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 10216 | { |
d62a17ae | 10217 | struct bgp *bgp; |
8386ac43 | 10218 | |
d62a17ae | 10219 | if (name) |
10220 | bgp = bgp_lookup_by_name(name); | |
10221 | else | |
10222 | bgp = bgp_get_default(); | |
8386ac43 | 10223 | |
d62a17ae | 10224 | if (bgp) { |
10225 | if (!strcmp(what, "advertise-queue")) | |
10226 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
10227 | subgrp_id); | |
10228 | else if (!strcmp(what, "advertised-routes")) | |
10229 | update_group_show_advertised(bgp, afi, safi, vty, | |
10230 | subgrp_id); | |
10231 | else if (!strcmp(what, "packet-queue")) | |
10232 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
10233 | subgrp_id); | |
10234 | } | |
3f9c7369 DS |
10235 | } |
10236 | ||
10237 | DEFUN (show_ip_bgp_updgrps_adj, | |
10238 | show_ip_bgp_updgrps_adj_cmd, | |
716b2d8a | 10239 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
10240 | SHOW_STR |
10241 | IP_STR | |
10242 | BGP_STR | |
0c7b1b01 | 10243 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
10244 | "Advertisement queue\n" |
10245 | "Announced routes\n" | |
10246 | "Packet queue\n") | |
10247 | { | |
d62a17ae | 10248 | int idx_type = 4; |
10249 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, | |
10250 | argv[idx_type]->arg, 0); | |
10251 | return CMD_SUCCESS; | |
8386ac43 | 10252 | } |
10253 | ||
10254 | DEFUN (show_ip_bgp_instance_updgrps_adj, | |
10255 | show_ip_bgp_instance_updgrps_adj_cmd, | |
18c57037 | 10256 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10257 | SHOW_STR |
10258 | IP_STR | |
10259 | BGP_STR | |
10260 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10261 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10262 | "Advertisement queue\n" |
10263 | "Announced routes\n" | |
10264 | "Packet queue\n") | |
8386ac43 | 10265 | { |
d62a17ae | 10266 | int idx_word = 4; |
10267 | int idx_type = 6; | |
10268 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, | |
10269 | SAFI_UNICAST, argv[idx_type]->arg, 0); | |
10270 | return CMD_SUCCESS; | |
3f9c7369 DS |
10271 | } |
10272 | ||
10273 | DEFUN (show_bgp_updgrps_afi_adj, | |
10274 | show_bgp_updgrps_afi_adj_cmd, | |
46f296b4 | 10275 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 10276 | SHOW_STR |
716b2d8a | 10277 | IP_STR |
3f9c7369 | 10278 | BGP_STR |
46f296b4 | 10279 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 10280 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
10281 | "Advertisement queue\n" |
10282 | "Announced routes\n" | |
7111c1a0 | 10283 | "Packet queue\n") |
3f9c7369 | 10284 | { |
d62a17ae | 10285 | int idx_afi = 2; |
10286 | int idx_safi = 3; | |
10287 | int idx_type = 5; | |
10288 | show_bgp_updgrps_adj_info_aux( | |
10289 | vty, NULL, bgp_vty_afi_from_str(argv[idx_afi]->text), | |
10290 | bgp_vty_safi_from_str(argv[idx_safi]->text), | |
10291 | argv[idx_type]->arg, 0); | |
10292 | return CMD_SUCCESS; | |
3f9c7369 DS |
10293 | } |
10294 | ||
10295 | DEFUN (show_bgp_updgrps_adj, | |
10296 | show_bgp_updgrps_adj_cmd, | |
716b2d8a | 10297 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 10298 | SHOW_STR |
716b2d8a | 10299 | IP_STR |
3f9c7369 | 10300 | BGP_STR |
0c7b1b01 | 10301 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
10302 | "Advertisement queue\n" |
10303 | "Announced routes\n" | |
10304 | "Packet queue\n") | |
10305 | { | |
d62a17ae | 10306 | int idx_type = 3; |
10307 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, | |
10308 | argv[idx_type]->arg, 0); | |
10309 | return CMD_SUCCESS; | |
8386ac43 | 10310 | } |
10311 | ||
10312 | DEFUN (show_bgp_instance_updgrps_adj, | |
10313 | show_bgp_instance_updgrps_adj_cmd, | |
18c57037 | 10314 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10315 | SHOW_STR |
716b2d8a | 10316 | IP_STR |
8386ac43 | 10317 | BGP_STR |
10318 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10319 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10320 | "Advertisement queue\n" |
10321 | "Announced routes\n" | |
10322 | "Packet queue\n") | |
10323 | { | |
d62a17ae | 10324 | int idx_word = 3; |
10325 | int idx_type = 5; | |
10326 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, | |
10327 | SAFI_UNICAST, argv[idx_type]->arg, 0); | |
10328 | return CMD_SUCCESS; | |
3f9c7369 DS |
10329 | } |
10330 | ||
10331 | DEFUN (show_ip_bgp_updgrps_adj_s, | |
8fe8a7f6 | 10332 | show_ip_bgp_updgrps_adj_s_cmd, |
716b2d8a | 10333 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
10334 | SHOW_STR |
10335 | IP_STR | |
10336 | BGP_STR | |
0c7b1b01 | 10337 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 10338 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
10339 | "Advertisement queue\n" |
10340 | "Announced routes\n" | |
10341 | "Packet queue\n") | |
3f9c7369 | 10342 | { |
d62a17ae | 10343 | int idx_subgroup_id = 4; |
10344 | int idx_type = 5; | |
10345 | uint64_t subgrp_id; | |
8fe8a7f6 | 10346 | |
d62a17ae | 10347 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8fe8a7f6 | 10348 | |
d62a17ae | 10349 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, |
10350 | argv[idx_type]->arg, subgrp_id); | |
10351 | return CMD_SUCCESS; | |
8386ac43 | 10352 | } |
10353 | ||
10354 | DEFUN (show_ip_bgp_instance_updgrps_adj_s, | |
10355 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
18c57037 | 10356 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10357 | SHOW_STR |
10358 | IP_STR | |
10359 | BGP_STR | |
10360 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10361 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10362 | "Specific subgroup to display info for\n" |
10363 | "Advertisement queue\n" | |
10364 | "Announced routes\n" | |
10365 | "Packet queue\n") | |
8386ac43 | 10366 | { |
d62a17ae | 10367 | int idx_vrf = 4; |
10368 | int idx_subgroup_id = 6; | |
10369 | int idx_type = 7; | |
10370 | uint64_t subgrp_id; | |
8386ac43 | 10371 | |
d62a17ae | 10372 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8386ac43 | 10373 | |
d62a17ae | 10374 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP, |
10375 | SAFI_UNICAST, argv[idx_type]->arg, | |
10376 | subgrp_id); | |
10377 | return CMD_SUCCESS; | |
3f9c7369 DS |
10378 | } |
10379 | ||
8fe8a7f6 DS |
10380 | DEFUN (show_bgp_updgrps_afi_adj_s, |
10381 | show_bgp_updgrps_afi_adj_s_cmd, | |
46f296b4 | 10382 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 10383 | SHOW_STR |
716b2d8a | 10384 | IP_STR |
3f9c7369 | 10385 | BGP_STR |
46f296b4 | 10386 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 10387 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 10388 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
10389 | "Advertisement queue\n" |
10390 | "Announced routes\n" | |
7111c1a0 | 10391 | "Packet queue\n") |
3f9c7369 | 10392 | { |
d62a17ae | 10393 | int idx_afi = 2; |
10394 | int idx_safi = 3; | |
10395 | int idx_subgroup_id = 5; | |
10396 | int idx_type = 6; | |
10397 | uint64_t subgrp_id; | |
3f9c7369 | 10398 | |
d62a17ae | 10399 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8fe8a7f6 | 10400 | |
d62a17ae | 10401 | show_bgp_updgrps_adj_info_aux( |
10402 | vty, NULL, bgp_vty_afi_from_str(argv[idx_afi]->text), | |
10403 | bgp_vty_safi_from_str(argv[idx_safi]->text), | |
10404 | argv[idx_type]->arg, subgrp_id); | |
10405 | return CMD_SUCCESS; | |
3f9c7369 DS |
10406 | } |
10407 | ||
8fe8a7f6 DS |
10408 | DEFUN (show_bgp_updgrps_adj_s, |
10409 | show_bgp_updgrps_adj_s_cmd, | |
716b2d8a | 10410 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8fe8a7f6 | 10411 | SHOW_STR |
716b2d8a | 10412 | IP_STR |
8fe8a7f6 | 10413 | BGP_STR |
0c7b1b01 | 10414 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 DS |
10415 | "Specific subgroup to display info for\n" |
10416 | "Advertisement queue\n" | |
10417 | "Announced routes\n" | |
10418 | "Packet queue\n") | |
10419 | { | |
d62a17ae | 10420 | int idx_subgroup_id = 3; |
10421 | int idx_type = 4; | |
10422 | uint64_t subgrp_id; | |
8fe8a7f6 | 10423 | |
d62a17ae | 10424 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8fe8a7f6 | 10425 | |
d62a17ae | 10426 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, |
10427 | argv[idx_type]->arg, subgrp_id); | |
10428 | return CMD_SUCCESS; | |
8fe8a7f6 DS |
10429 | } |
10430 | ||
8386ac43 | 10431 | DEFUN (show_bgp_instance_updgrps_adj_s, |
10432 | show_bgp_instance_updgrps_adj_s_cmd, | |
18c57037 | 10433 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10434 | SHOW_STR |
716b2d8a | 10435 | IP_STR |
8386ac43 | 10436 | BGP_STR |
10437 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10438 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10439 | "Specific subgroup to display info for\n" |
10440 | "Advertisement queue\n" | |
10441 | "Announced routes\n" | |
10442 | "Packet queue\n") | |
10443 | { | |
d62a17ae | 10444 | int idx_vrf = 3; |
10445 | int idx_subgroup_id = 5; | |
10446 | int idx_type = 6; | |
10447 | uint64_t subgrp_id; | |
10448 | ||
10449 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); | |
10450 | ||
10451 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP6, | |
10452 | SAFI_UNICAST, argv[idx_type]->arg, | |
10453 | subgrp_id); | |
10454 | return CMD_SUCCESS; | |
10455 | } | |
10456 | ||
10457 | ||
10458 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) | |
10459 | { | |
10460 | struct listnode *node, *nnode; | |
10461 | struct prefix *range; | |
10462 | struct peer *conf; | |
10463 | struct peer *peer; | |
10464 | char buf[PREFIX2STR_BUFFER]; | |
10465 | afi_t afi; | |
10466 | safi_t safi; | |
10467 | const char *peer_status; | |
10468 | const char *af_str; | |
10469 | int lr_count; | |
10470 | int dynamic; | |
10471 | int af_cfgd; | |
10472 | ||
10473 | conf = group->conf; | |
10474 | ||
10475 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
10476 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
10477 | conf->as); | |
10478 | } else if (conf->as_type == AS_INTERNAL) { | |
10479 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
10480 | group->bgp->as); | |
10481 | } else { | |
10482 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
10483 | } | |
f14e6fdb | 10484 | |
d62a17ae | 10485 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
10486 | vty_out(vty, " Peer-group type is internal\n"); | |
10487 | else | |
10488 | vty_out(vty, " Peer-group type is external\n"); | |
10489 | ||
10490 | /* Display AFs configured. */ | |
10491 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
10492 | FOREACH_AFI_SAFI (afi, safi) { |
10493 | if (conf->afc[afi][safi]) { | |
10494 | af_cfgd = 1; | |
10495 | vty_out(vty, " %s;", afi_safi_print(afi, safi)); | |
d62a17ae | 10496 | } |
05c7a1cc | 10497 | } |
d62a17ae | 10498 | if (!af_cfgd) |
10499 | vty_out(vty, " none\n"); | |
10500 | else | |
10501 | vty_out(vty, "\n"); | |
10502 | ||
10503 | /* Display listen ranges (for dynamic neighbors), if any */ | |
10504 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
10505 | if (afi == AFI_IP) | |
10506 | af_str = "IPv4"; | |
10507 | else if (afi == AFI_IP6) | |
10508 | af_str = "IPv6"; | |
10509 | else | |
10510 | af_str = "???"; | |
10511 | lr_count = listcount(group->listen_range[afi]); | |
10512 | if (lr_count) { | |
10513 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
10514 | af_str); | |
10515 | ||
10516 | ||
10517 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
10518 | nnode, range)) { | |
10519 | prefix2str(range, buf, sizeof(buf)); | |
10520 | vty_out(vty, " %s\n", buf); | |
10521 | } | |
10522 | } | |
10523 | } | |
f14e6fdb | 10524 | |
d62a17ae | 10525 | /* Display group members and their status */ |
10526 | if (listcount(group->peer)) { | |
10527 | vty_out(vty, " Peer-group members:\n"); | |
10528 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
10529 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
10530 | peer_status = "Idle (Admin)"; | |
10531 | else if (CHECK_FLAG(peer->sflags, | |
10532 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10533 | peer_status = "Idle (PfxCt)"; | |
10534 | else | |
10535 | peer_status = lookup_msg(bgp_status_msg, | |
10536 | peer->status, NULL); | |
10537 | ||
10538 | dynamic = peer_dynamic_neighbor(peer); | |
10539 | vty_out(vty, " %s %s %s \n", peer->host, | |
10540 | dynamic ? "(dynamic)" : "", peer_status); | |
10541 | } | |
10542 | } | |
f14e6fdb | 10543 | |
d62a17ae | 10544 | return CMD_SUCCESS; |
10545 | } | |
10546 | ||
ff9959b0 QY |
10547 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
10548 | const char *group_name) | |
d62a17ae | 10549 | { |
ff9959b0 | 10550 | struct bgp *bgp; |
d62a17ae | 10551 | struct listnode *node, *nnode; |
10552 | struct peer_group *group; | |
ff9959b0 QY |
10553 | bool found = false; |
10554 | ||
10555 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
10556 | ||
10557 | if (!bgp) { | |
10558 | vty_out(vty, "%% No such BGP instance exists\n"); | |
10559 | return CMD_WARNING; | |
10560 | } | |
d62a17ae | 10561 | |
10562 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
10563 | if (group_name) { |
10564 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 10565 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
10566 | found = true; |
10567 | break; | |
d62a17ae | 10568 | } |
ff9959b0 QY |
10569 | } else { |
10570 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 10571 | } |
f14e6fdb | 10572 | } |
f14e6fdb | 10573 | |
ff9959b0 | 10574 | if (group_name && !found) |
d62a17ae | 10575 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 10576 | |
d62a17ae | 10577 | return CMD_SUCCESS; |
f14e6fdb DS |
10578 | } |
10579 | ||
f14e6fdb DS |
10580 | DEFUN (show_ip_bgp_peer_groups, |
10581 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 10582 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
10583 | SHOW_STR |
10584 | IP_STR | |
10585 | BGP_STR | |
8386ac43 | 10586 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
10587 | "Detailed information on BGP peer groups\n" |
10588 | "Peer group name\n") | |
f14e6fdb | 10589 | { |
d62a17ae | 10590 | char *vrf, *pg; |
10591 | vrf = pg = NULL; | |
10592 | int idx = 0; | |
f14e6fdb | 10593 | |
1d35f218 | 10594 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg : NULL; |
d62a17ae | 10595 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 10596 | |
ff9959b0 | 10597 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 10598 | } |
3f9c7369 | 10599 | |
d6e3c605 | 10600 | |
718e3744 | 10601 | /* Redistribute VTY commands. */ |
10602 | ||
718e3744 | 10603 | DEFUN (bgp_redistribute_ipv4, |
10604 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 10605 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 10606 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10607 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 10608 | { |
d62a17ae | 10609 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10610 | int idx_protocol = 1; | |
10611 | int type; | |
718e3744 | 10612 | |
d62a17ae | 10613 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
10614 | if (type < 0) { | |
10615 | vty_out(vty, "%% Invalid route type\n"); | |
10616 | return CMD_WARNING_CONFIG_FAILED; | |
10617 | } | |
7f323236 | 10618 | |
d62a17ae | 10619 | bgp_redist_add(bgp, AFI_IP, type, 0); |
10620 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
718e3744 | 10621 | } |
10622 | ||
d62a17ae | 10623 | ALIAS_HIDDEN( |
10624 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
10625 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
10626 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 10627 | |
718e3744 | 10628 | DEFUN (bgp_redistribute_ipv4_rmap, |
10629 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 10630 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 10631 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10632 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10633 | "Route map reference\n" |
10634 | "Pointer to route-map entries\n") | |
10635 | { | |
d62a17ae | 10636 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10637 | int idx_protocol = 1; | |
10638 | int idx_word = 3; | |
10639 | int type; | |
10640 | struct bgp_redist *red; | |
718e3744 | 10641 | |
d62a17ae | 10642 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
10643 | if (type < 0) { | |
10644 | vty_out(vty, "%% Invalid route type\n"); | |
10645 | return CMD_WARNING_CONFIG_FAILED; | |
10646 | } | |
718e3744 | 10647 | |
d62a17ae | 10648 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
10649 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10650 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
718e3744 | 10651 | } |
10652 | ||
d62a17ae | 10653 | ALIAS_HIDDEN( |
10654 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
10655 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
10656 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10657 | "Route map reference\n" | |
10658 | "Pointer to route-map entries\n") | |
596c17ba | 10659 | |
718e3744 | 10660 | DEFUN (bgp_redistribute_ipv4_metric, |
10661 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 10662 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 10663 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10664 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10665 | "Metric for redistributed routes\n" |
10666 | "Default metric\n") | |
10667 | { | |
d62a17ae | 10668 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10669 | int idx_protocol = 1; | |
10670 | int idx_number = 3; | |
10671 | int type; | |
10672 | u_int32_t metric; | |
10673 | struct bgp_redist *red; | |
10674 | ||
10675 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
10676 | if (type < 0) { | |
10677 | vty_out(vty, "%% Invalid route type\n"); | |
10678 | return CMD_WARNING_CONFIG_FAILED; | |
10679 | } | |
10680 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
10681 | ||
10682 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
10683 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
10684 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
10685 | } | |
10686 | ||
10687 | ALIAS_HIDDEN( | |
10688 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
10689 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
10690 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10691 | "Metric for redistributed routes\n" | |
10692 | "Default metric\n") | |
596c17ba | 10693 | |
718e3744 | 10694 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
10695 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 10696 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 10697 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10698 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10699 | "Route map reference\n" |
10700 | "Pointer to route-map entries\n" | |
10701 | "Metric for redistributed routes\n" | |
10702 | "Default metric\n") | |
10703 | { | |
d62a17ae | 10704 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10705 | int idx_protocol = 1; | |
10706 | int idx_word = 3; | |
10707 | int idx_number = 5; | |
10708 | int type; | |
10709 | u_int32_t metric; | |
10710 | struct bgp_redist *red; | |
10711 | ||
10712 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
10713 | if (type < 0) { | |
10714 | vty_out(vty, "%% Invalid route type\n"); | |
10715 | return CMD_WARNING_CONFIG_FAILED; | |
10716 | } | |
10717 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
10718 | ||
10719 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
10720 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10721 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
10722 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
10723 | } | |
10724 | ||
10725 | ALIAS_HIDDEN( | |
10726 | bgp_redistribute_ipv4_rmap_metric, | |
10727 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
10728 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
10729 | " route-map WORD metric (0-4294967295)", | |
10730 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10731 | "Route map reference\n" | |
10732 | "Pointer to route-map entries\n" | |
10733 | "Metric for redistributed routes\n" | |
10734 | "Default metric\n") | |
596c17ba | 10735 | |
718e3744 | 10736 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
10737 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 10738 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 10739 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10740 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10741 | "Metric for redistributed routes\n" |
10742 | "Default metric\n" | |
10743 | "Route map reference\n" | |
10744 | "Pointer to route-map entries\n") | |
10745 | { | |
d62a17ae | 10746 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10747 | int idx_protocol = 1; | |
10748 | int idx_number = 3; | |
10749 | int idx_word = 5; | |
10750 | int type; | |
10751 | u_int32_t metric; | |
10752 | struct bgp_redist *red; | |
10753 | ||
10754 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
10755 | if (type < 0) { | |
10756 | vty_out(vty, "%% Invalid route type\n"); | |
10757 | return CMD_WARNING_CONFIG_FAILED; | |
10758 | } | |
10759 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
10760 | ||
10761 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
10762 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
10763 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10764 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
10765 | } | |
10766 | ||
10767 | ALIAS_HIDDEN( | |
10768 | bgp_redistribute_ipv4_metric_rmap, | |
10769 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
10770 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
10771 | " metric (0-4294967295) route-map WORD", | |
10772 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10773 | "Metric for redistributed routes\n" | |
10774 | "Default metric\n" | |
10775 | "Route map reference\n" | |
10776 | "Pointer to route-map entries\n") | |
596c17ba | 10777 | |
7c8ff89e DS |
10778 | DEFUN (bgp_redistribute_ipv4_ospf, |
10779 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 10780 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
10781 | "Redistribute information from another routing protocol\n" |
10782 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10783 | "Non-main Kernel Routing Table\n" |
10784 | "Instance ID/Table ID\n") | |
7c8ff89e | 10785 | { |
d62a17ae | 10786 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10787 | int idx_ospf_table = 1; | |
10788 | int idx_number = 2; | |
10789 | u_short instance; | |
10790 | u_short protocol; | |
7c8ff89e | 10791 | |
d62a17ae | 10792 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 10793 | |
d62a17ae | 10794 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
10795 | protocol = ZEBRA_ROUTE_OSPF; | |
10796 | else | |
10797 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 10798 | |
d62a17ae | 10799 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
10800 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
10801 | } |
10802 | ||
d62a17ae | 10803 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
10804 | "redistribute <ospf|table> (1-65535)", | |
10805 | "Redistribute information from another routing protocol\n" | |
10806 | "Open Shortest Path First (OSPFv2)\n" | |
10807 | "Non-main Kernel Routing Table\n" | |
10808 | "Instance ID/Table ID\n") | |
596c17ba | 10809 | |
7c8ff89e DS |
10810 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
10811 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 10812 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
10813 | "Redistribute information from another routing protocol\n" |
10814 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10815 | "Non-main Kernel Routing Table\n" |
10816 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10817 | "Route map reference\n" |
10818 | "Pointer to route-map entries\n") | |
10819 | { | |
d62a17ae | 10820 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10821 | int idx_ospf_table = 1; | |
10822 | int idx_number = 2; | |
10823 | int idx_word = 4; | |
10824 | struct bgp_redist *red; | |
10825 | u_short instance; | |
10826 | int protocol; | |
10827 | ||
10828 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10829 | protocol = ZEBRA_ROUTE_OSPF; | |
10830 | else | |
10831 | protocol = ZEBRA_ROUTE_TABLE; | |
10832 | ||
10833 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10834 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
10835 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10836 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
10837 | } | |
10838 | ||
10839 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
10840 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
10841 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
10842 | "Redistribute information from another routing protocol\n" | |
10843 | "Open Shortest Path First (OSPFv2)\n" | |
10844 | "Non-main Kernel Routing Table\n" | |
10845 | "Instance ID/Table ID\n" | |
10846 | "Route map reference\n" | |
10847 | "Pointer to route-map entries\n") | |
596c17ba | 10848 | |
7c8ff89e DS |
10849 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
10850 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 10851 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
10852 | "Redistribute information from another routing protocol\n" |
10853 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10854 | "Non-main Kernel Routing Table\n" |
10855 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10856 | "Metric for redistributed routes\n" |
10857 | "Default metric\n") | |
10858 | { | |
d62a17ae | 10859 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10860 | int idx_ospf_table = 1; | |
10861 | int idx_number = 2; | |
10862 | int idx_number_2 = 4; | |
10863 | u_int32_t metric; | |
10864 | struct bgp_redist *red; | |
10865 | u_short instance; | |
10866 | int protocol; | |
10867 | ||
10868 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10869 | protocol = ZEBRA_ROUTE_OSPF; | |
10870 | else | |
10871 | protocol = ZEBRA_ROUTE_TABLE; | |
10872 | ||
10873 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10874 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
10875 | ||
10876 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
10877 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
10878 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
10879 | } | |
10880 | ||
10881 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
10882 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
10883 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
10884 | "Redistribute information from another routing protocol\n" | |
10885 | "Open Shortest Path First (OSPFv2)\n" | |
10886 | "Non-main Kernel Routing Table\n" | |
10887 | "Instance ID/Table ID\n" | |
10888 | "Metric for redistributed routes\n" | |
10889 | "Default metric\n") | |
596c17ba | 10890 | |
7c8ff89e DS |
10891 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
10892 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 10893 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
10894 | "Redistribute information from another routing protocol\n" |
10895 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10896 | "Non-main Kernel Routing Table\n" |
10897 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10898 | "Route map reference\n" |
10899 | "Pointer to route-map entries\n" | |
10900 | "Metric for redistributed routes\n" | |
10901 | "Default metric\n") | |
10902 | { | |
d62a17ae | 10903 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10904 | int idx_ospf_table = 1; | |
10905 | int idx_number = 2; | |
10906 | int idx_word = 4; | |
10907 | int idx_number_2 = 6; | |
10908 | u_int32_t metric; | |
10909 | struct bgp_redist *red; | |
10910 | u_short instance; | |
10911 | int protocol; | |
10912 | ||
10913 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10914 | protocol = ZEBRA_ROUTE_OSPF; | |
10915 | else | |
10916 | protocol = ZEBRA_ROUTE_TABLE; | |
10917 | ||
10918 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10919 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
10920 | ||
10921 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
10922 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10923 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
10924 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
10925 | } | |
10926 | ||
10927 | ALIAS_HIDDEN( | |
10928 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
10929 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
10930 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
10931 | "Redistribute information from another routing protocol\n" | |
10932 | "Open Shortest Path First (OSPFv2)\n" | |
10933 | "Non-main Kernel Routing Table\n" | |
10934 | "Instance ID/Table ID\n" | |
10935 | "Route map reference\n" | |
10936 | "Pointer to route-map entries\n" | |
10937 | "Metric for redistributed routes\n" | |
10938 | "Default metric\n") | |
596c17ba | 10939 | |
7c8ff89e DS |
10940 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
10941 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 10942 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
10943 | "Redistribute information from another routing protocol\n" |
10944 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10945 | "Non-main Kernel Routing Table\n" |
10946 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10947 | "Metric for redistributed routes\n" |
10948 | "Default metric\n" | |
10949 | "Route map reference\n" | |
10950 | "Pointer to route-map entries\n") | |
10951 | { | |
d62a17ae | 10952 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10953 | int idx_ospf_table = 1; | |
10954 | int idx_number = 2; | |
10955 | int idx_number_2 = 4; | |
10956 | int idx_word = 6; | |
10957 | u_int32_t metric; | |
10958 | struct bgp_redist *red; | |
10959 | u_short instance; | |
10960 | int protocol; | |
10961 | ||
10962 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10963 | protocol = ZEBRA_ROUTE_OSPF; | |
10964 | else | |
10965 | protocol = ZEBRA_ROUTE_TABLE; | |
10966 | ||
10967 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10968 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
10969 | ||
10970 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
10971 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
10972 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10973 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
10974 | } | |
10975 | ||
10976 | ALIAS_HIDDEN( | |
10977 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
10978 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
10979 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
10980 | "Redistribute information from another routing protocol\n" | |
10981 | "Open Shortest Path First (OSPFv2)\n" | |
10982 | "Non-main Kernel Routing Table\n" | |
10983 | "Instance ID/Table ID\n" | |
10984 | "Metric for redistributed routes\n" | |
10985 | "Default metric\n" | |
10986 | "Route map reference\n" | |
10987 | "Pointer to route-map entries\n") | |
596c17ba | 10988 | |
7c8ff89e DS |
10989 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
10990 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 10991 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
10992 | NO_STR |
10993 | "Redistribute information from another routing protocol\n" | |
10994 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 10995 | "Non-main Kernel Routing Table\n" |
31500417 DW |
10996 | "Instance ID/Table ID\n" |
10997 | "Metric for redistributed routes\n" | |
10998 | "Default metric\n" | |
10999 | "Route map reference\n" | |
11000 | "Pointer to route-map entries\n") | |
7c8ff89e | 11001 | { |
d62a17ae | 11002 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11003 | int idx_ospf_table = 2; | |
11004 | int idx_number = 3; | |
11005 | u_short instance; | |
11006 | int protocol; | |
11007 | ||
11008 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11009 | protocol = ZEBRA_ROUTE_OSPF; | |
11010 | else | |
11011 | protocol = ZEBRA_ROUTE_TABLE; | |
11012 | ||
11013 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11014 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
11015 | } | |
11016 | ||
11017 | ALIAS_HIDDEN( | |
11018 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
11019 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", | |
11020 | NO_STR | |
11021 | "Redistribute information from another routing protocol\n" | |
11022 | "Open Shortest Path First (OSPFv2)\n" | |
11023 | "Non-main Kernel Routing Table\n" | |
11024 | "Instance ID/Table ID\n" | |
11025 | "Metric for redistributed routes\n" | |
11026 | "Default metric\n" | |
11027 | "Route map reference\n" | |
11028 | "Pointer to route-map entries\n") | |
596c17ba | 11029 | |
718e3744 | 11030 | DEFUN (no_bgp_redistribute_ipv4, |
11031 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 11032 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 11033 | NO_STR |
11034 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 11035 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
11036 | "Metric for redistributed routes\n" |
11037 | "Default metric\n" | |
11038 | "Route map reference\n" | |
11039 | "Pointer to route-map entries\n") | |
718e3744 | 11040 | { |
d62a17ae | 11041 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11042 | int idx_protocol = 2; | |
11043 | int type; | |
11044 | ||
11045 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11046 | if (type < 0) { | |
11047 | vty_out(vty, "%% Invalid route type\n"); | |
11048 | return CMD_WARNING_CONFIG_FAILED; | |
11049 | } | |
11050 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
11051 | } | |
11052 | ||
11053 | ALIAS_HIDDEN( | |
11054 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
11055 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
11056 | " [metric (0-4294967295)] [route-map WORD]", | |
11057 | NO_STR | |
11058 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11059 | "Metric for redistributed routes\n" | |
11060 | "Default metric\n" | |
11061 | "Route map reference\n" | |
11062 | "Pointer to route-map entries\n") | |
596c17ba | 11063 | |
718e3744 | 11064 | DEFUN (bgp_redistribute_ipv6, |
11065 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 11066 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 11067 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11068 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 11069 | { |
d62a17ae | 11070 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11071 | int idx_protocol = 1; | |
11072 | int type; | |
718e3744 | 11073 | |
d62a17ae | 11074 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
11075 | if (type < 0) { | |
11076 | vty_out(vty, "%% Invalid route type\n"); | |
11077 | return CMD_WARNING_CONFIG_FAILED; | |
11078 | } | |
718e3744 | 11079 | |
d62a17ae | 11080 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
11081 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11082 | } |
11083 | ||
11084 | DEFUN (bgp_redistribute_ipv6_rmap, | |
11085 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 11086 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 11087 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11088 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11089 | "Route map reference\n" |
11090 | "Pointer to route-map entries\n") | |
11091 | { | |
d62a17ae | 11092 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11093 | int idx_protocol = 1; | |
11094 | int idx_word = 3; | |
11095 | int type; | |
11096 | struct bgp_redist *red; | |
718e3744 | 11097 | |
d62a17ae | 11098 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
11099 | if (type < 0) { | |
11100 | vty_out(vty, "%% Invalid route type\n"); | |
11101 | return CMD_WARNING_CONFIG_FAILED; | |
11102 | } | |
718e3744 | 11103 | |
d62a17ae | 11104 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11105 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11106 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11107 | } |
11108 | ||
11109 | DEFUN (bgp_redistribute_ipv6_metric, | |
11110 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 11111 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 11112 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11113 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11114 | "Metric for redistributed routes\n" |
11115 | "Default metric\n") | |
11116 | { | |
d62a17ae | 11117 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11118 | int idx_protocol = 1; | |
11119 | int idx_number = 3; | |
11120 | int type; | |
11121 | u_int32_t metric; | |
11122 | struct bgp_redist *red; | |
11123 | ||
11124 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
11125 | if (type < 0) { | |
11126 | vty_out(vty, "%% Invalid route type\n"); | |
11127 | return CMD_WARNING_CONFIG_FAILED; | |
11128 | } | |
11129 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 11130 | |
d62a17ae | 11131 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11132 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
11133 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11134 | } |
11135 | ||
11136 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
11137 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 11138 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 11139 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11140 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11141 | "Route map reference\n" |
11142 | "Pointer to route-map entries\n" | |
11143 | "Metric for redistributed routes\n" | |
11144 | "Default metric\n") | |
11145 | { | |
d62a17ae | 11146 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11147 | int idx_protocol = 1; | |
11148 | int idx_word = 3; | |
11149 | int idx_number = 5; | |
11150 | int type; | |
11151 | u_int32_t metric; | |
11152 | struct bgp_redist *red; | |
11153 | ||
11154 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
11155 | if (type < 0) { | |
11156 | vty_out(vty, "%% Invalid route type\n"); | |
11157 | return CMD_WARNING_CONFIG_FAILED; | |
11158 | } | |
11159 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 11160 | |
d62a17ae | 11161 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11162 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11163 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
11164 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11165 | } |
11166 | ||
11167 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
11168 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 11169 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 11170 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11171 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11172 | "Metric for redistributed routes\n" |
11173 | "Default metric\n" | |
11174 | "Route map reference\n" | |
11175 | "Pointer to route-map entries\n") | |
11176 | { | |
d62a17ae | 11177 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11178 | int idx_protocol = 1; | |
11179 | int idx_number = 3; | |
11180 | int idx_word = 5; | |
11181 | int type; | |
11182 | u_int32_t metric; | |
11183 | struct bgp_redist *red; | |
11184 | ||
11185 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
11186 | if (type < 0) { | |
11187 | vty_out(vty, "%% Invalid route type\n"); | |
11188 | return CMD_WARNING_CONFIG_FAILED; | |
11189 | } | |
11190 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 11191 | |
d62a17ae | 11192 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11193 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric); | |
11194 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11195 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11196 | } |
11197 | ||
11198 | DEFUN (no_bgp_redistribute_ipv6, | |
11199 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 11200 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 11201 | NO_STR |
11202 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 11203 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
11204 | "Metric for redistributed routes\n" |
11205 | "Default metric\n" | |
11206 | "Route map reference\n" | |
11207 | "Pointer to route-map entries\n") | |
718e3744 | 11208 | { |
d62a17ae | 11209 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11210 | int idx_protocol = 2; | |
11211 | int type; | |
718e3744 | 11212 | |
d62a17ae | 11213 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
11214 | if (type < 0) { | |
11215 | vty_out(vty, "%% Invalid route type\n"); | |
11216 | return CMD_WARNING_CONFIG_FAILED; | |
11217 | } | |
718e3744 | 11218 | |
d62a17ae | 11219 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
11220 | } | |
11221 | ||
2b791107 | 11222 | void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 11223 | safi_t safi) |
d62a17ae | 11224 | { |
11225 | int i; | |
11226 | ||
11227 | /* Unicast redistribution only. */ | |
11228 | if (safi != SAFI_UNICAST) | |
2b791107 | 11229 | return; |
d62a17ae | 11230 | |
11231 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
11232 | /* Redistribute BGP does not make sense. */ | |
11233 | if (i != ZEBRA_ROUTE_BGP) { | |
11234 | struct list *red_list; | |
11235 | struct listnode *node; | |
11236 | struct bgp_redist *red; | |
11237 | ||
11238 | red_list = bgp->redist[afi][i]; | |
11239 | if (!red_list) | |
11240 | continue; | |
11241 | ||
11242 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 11243 | /* "redistribute" configuration. */ |
11244 | vty_out(vty, " redistribute %s", | |
11245 | zebra_route_string(i)); | |
11246 | if (red->instance) | |
11247 | vty_out(vty, " %d", red->instance); | |
11248 | if (red->redist_metric_flag) | |
11249 | vty_out(vty, " metric %u", | |
11250 | red->redist_metric); | |
11251 | if (red->rmap.name) | |
11252 | vty_out(vty, " route-map %s", | |
11253 | red->rmap.name); | |
11254 | vty_out(vty, "\n"); | |
11255 | } | |
11256 | } | |
11257 | } | |
718e3744 | 11258 | } |
6b0655a2 | 11259 | |
718e3744 | 11260 | /* BGP node structure. */ |
d62a17ae | 11261 | static struct cmd_node bgp_node = { |
9d303b37 | 11262 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 11263 | }; |
11264 | ||
d62a17ae | 11265 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 11266 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 11267 | }; |
11268 | ||
d62a17ae | 11269 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 11270 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 11271 | }; |
11272 | ||
d62a17ae | 11273 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 11274 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
11275 | }; |
11276 | ||
d62a17ae | 11277 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 11278 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 11279 | }; |
11280 | ||
d62a17ae | 11281 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 11282 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 11283 | }; |
11284 | ||
d62a17ae | 11285 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 11286 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
11287 | }; |
11288 | ||
d62a17ae | 11289 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
11290 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 11291 | |
d62a17ae | 11292 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
11293 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 11294 | |
d62a17ae | 11295 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
11296 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 11297 | |
d62a17ae | 11298 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
11299 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 11300 | |
d62a17ae | 11301 | static void community_list_vty(void); |
1f8ae70b | 11302 | |
d62a17ae | 11303 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 11304 | { |
d62a17ae | 11305 | struct bgp *bgp; |
11306 | struct peer *peer; | |
11307 | struct peer_group *group; | |
11308 | struct listnode *lnbgp, *lnpeer; | |
b8a815e5 | 11309 | |
d62a17ae | 11310 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
11311 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
11312 | /* only provide suggestions on the appropriate input | |
11313 | * token type, | |
11314 | * they'll otherwise show up multiple times */ | |
11315 | enum cmd_token_type match_type; | |
11316 | char *name = peer->host; | |
d48ed3e0 | 11317 | |
d62a17ae | 11318 | if (peer->conf_if) { |
11319 | match_type = VARIABLE_TKN; | |
11320 | name = peer->conf_if; | |
11321 | } else if (strchr(peer->host, ':')) | |
11322 | match_type = IPV6_TKN; | |
11323 | else | |
11324 | match_type = IPV4_TKN; | |
d48ed3e0 | 11325 | |
d62a17ae | 11326 | if (token->type != match_type) |
11327 | continue; | |
d48ed3e0 | 11328 | |
d62a17ae | 11329 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
11330 | } | |
d48ed3e0 | 11331 | |
d62a17ae | 11332 | if (token->type == VARIABLE_TKN) |
11333 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
11334 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
11335 | group->name)); | |
11336 | } | |
b8a815e5 DL |
11337 | } |
11338 | ||
11339 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 11340 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
11341 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 11342 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 11343 | {.completions = NULL}}; |
11344 | ||
11345 | void bgp_vty_init(void) | |
11346 | { | |
11347 | cmd_variable_handler_register(bgp_var_neighbor); | |
11348 | ||
11349 | /* Install bgp top node. */ | |
11350 | install_node(&bgp_node, bgp_config_write); | |
11351 | install_node(&bgp_ipv4_unicast_node, NULL); | |
11352 | install_node(&bgp_ipv4_multicast_node, NULL); | |
11353 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
11354 | install_node(&bgp_ipv6_unicast_node, NULL); | |
11355 | install_node(&bgp_ipv6_multicast_node, NULL); | |
11356 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
11357 | install_node(&bgp_vpnv4_node, NULL); | |
11358 | install_node(&bgp_vpnv6_node, NULL); | |
11359 | install_node(&bgp_evpn_node, NULL); | |
11360 | install_node(&bgp_evpn_vni_node, NULL); | |
11361 | ||
11362 | /* Install default VTY commands to new nodes. */ | |
11363 | install_default(BGP_NODE); | |
11364 | install_default(BGP_IPV4_NODE); | |
11365 | install_default(BGP_IPV4M_NODE); | |
11366 | install_default(BGP_IPV4L_NODE); | |
11367 | install_default(BGP_IPV6_NODE); | |
11368 | install_default(BGP_IPV6M_NODE); | |
11369 | install_default(BGP_IPV6L_NODE); | |
11370 | install_default(BGP_VPNV4_NODE); | |
11371 | install_default(BGP_VPNV6_NODE); | |
11372 | install_default(BGP_EVPN_NODE); | |
11373 | install_default(BGP_EVPN_VNI_NODE); | |
11374 | ||
11375 | /* "bgp multiple-instance" commands. */ | |
11376 | install_element(CONFIG_NODE, &bgp_multiple_instance_cmd); | |
11377 | install_element(CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
11378 | ||
11379 | /* "bgp config-type" commands. */ | |
11380 | install_element(CONFIG_NODE, &bgp_config_type_cmd); | |
11381 | install_element(CONFIG_NODE, &no_bgp_config_type_cmd); | |
11382 | ||
11383 | /* bgp route-map delay-timer commands. */ | |
11384 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
11385 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
11386 | ||
11387 | /* Dummy commands (Currently not supported) */ | |
11388 | install_element(BGP_NODE, &no_synchronization_cmd); | |
11389 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
11390 | ||
11391 | /* "router bgp" commands. */ | |
11392 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
11393 | ||
11394 | /* "no router bgp" commands. */ | |
11395 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
11396 | ||
11397 | /* "bgp router-id" commands. */ | |
11398 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
11399 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
11400 | ||
11401 | /* "bgp cluster-id" commands. */ | |
11402 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
11403 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
11404 | ||
11405 | /* "bgp confederation" commands. */ | |
11406 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
11407 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
11408 | ||
11409 | /* "bgp confederation peers" commands. */ | |
11410 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
11411 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
11412 | ||
11413 | /* bgp max-med command */ | |
11414 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
11415 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
11416 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
11417 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
11418 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
11419 | ||
11420 | /* bgp disable-ebgp-connected-nh-check */ | |
11421 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
11422 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
11423 | ||
11424 | /* bgp update-delay command */ | |
11425 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
11426 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
11427 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
11428 | ||
11429 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
11430 | install_element(BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
555e09d4 QY |
11431 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
11432 | install_element(BGP_NODE, &no_bgp_rpkt_quanta_cmd); | |
d62a17ae | 11433 | |
11434 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
11435 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
11436 | ||
11437 | /* "maximum-paths" commands. */ | |
11438 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
11439 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
11440 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
11441 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
11442 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
11443 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
11444 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
11445 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
11446 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
11447 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
11448 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
11449 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
11450 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
11451 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
11452 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
11453 | ||
11454 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
11455 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
11456 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
11457 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
11458 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
11459 | ||
11460 | /* "timers bgp" commands. */ | |
11461 | install_element(BGP_NODE, &bgp_timers_cmd); | |
11462 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
11463 | ||
11464 | /* route-map delay-timer commands - per instance for backwards compat. | |
11465 | */ | |
11466 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
11467 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
11468 | ||
11469 | /* "bgp client-to-client reflection" commands */ | |
11470 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
11471 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
11472 | ||
11473 | /* "bgp always-compare-med" commands */ | |
11474 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
11475 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
11476 | ||
11477 | /* "bgp deterministic-med" commands */ | |
11478 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
11479 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
11480 | ||
11481 | /* "bgp graceful-restart" commands */ | |
11482 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); | |
11483 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
11484 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); | |
11485 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
11486 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
11487 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
11488 | ||
11489 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); | |
11490 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
11491 | ||
7f323236 DW |
11492 | /* "bgp graceful-shutdown" commands */ |
11493 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
11494 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
11495 | ||
d62a17ae | 11496 | /* "bgp fast-external-failover" commands */ |
11497 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
11498 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
11499 | ||
11500 | /* "bgp enforce-first-as" commands */ | |
11501 | install_element(BGP_NODE, &bgp_enforce_first_as_cmd); | |
11502 | install_element(BGP_NODE, &no_bgp_enforce_first_as_cmd); | |
11503 | ||
11504 | /* "bgp bestpath compare-routerid" commands */ | |
11505 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
11506 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
11507 | ||
11508 | /* "bgp bestpath as-path ignore" commands */ | |
11509 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
11510 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
11511 | ||
11512 | /* "bgp bestpath as-path confed" commands */ | |
11513 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
11514 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
11515 | ||
11516 | /* "bgp bestpath as-path multipath-relax" commands */ | |
11517 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
11518 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
11519 | ||
11520 | /* "bgp log-neighbor-changes" commands */ | |
11521 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
11522 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
11523 | ||
11524 | /* "bgp bestpath med" commands */ | |
11525 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
11526 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
11527 | ||
11528 | /* "no bgp default ipv4-unicast" commands. */ | |
11529 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
11530 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
11531 | ||
11532 | /* "bgp network import-check" commands. */ | |
11533 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
11534 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
11535 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
11536 | ||
11537 | /* "bgp default local-preference" commands. */ | |
11538 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
11539 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
11540 | ||
11541 | /* bgp default show-hostname */ | |
11542 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
11543 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
11544 | ||
11545 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
11546 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
11547 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
11548 | ||
11549 | /* bgp ibgp-allow-policy-mods command */ | |
11550 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
11551 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
11552 | ||
11553 | /* "bgp listen limit" commands. */ | |
11554 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
11555 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
11556 | ||
11557 | /* "bgp listen range" commands. */ | |
11558 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
11559 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
11560 | ||
11561 | /* "neighbor remote-as" commands. */ | |
11562 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
11563 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
11564 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
11565 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
11566 | install_element(BGP_NODE, | |
11567 | &neighbor_interface_v6only_config_remote_as_cmd); | |
11568 | install_element(BGP_NODE, &no_neighbor_cmd); | |
11569 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
11570 | ||
11571 | /* "neighbor peer-group" commands. */ | |
11572 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
11573 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
11574 | install_element(BGP_NODE, | |
11575 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
11576 | ||
11577 | /* "neighbor local-as" commands. */ | |
11578 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
11579 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
11580 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
11581 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
11582 | ||
11583 | /* "neighbor solo" commands. */ | |
11584 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
11585 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
11586 | ||
11587 | /* "neighbor password" commands. */ | |
11588 | install_element(BGP_NODE, &neighbor_password_cmd); | |
11589 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
11590 | ||
11591 | /* "neighbor activate" commands. */ | |
11592 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
11593 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
11594 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
11595 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
11596 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
11597 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
11598 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
11599 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
11600 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
11601 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); | |
11602 | ||
11603 | /* "no neighbor activate" commands. */ | |
11604 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
11605 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
11606 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
11607 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
11608 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
11609 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
11610 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
11611 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
11612 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
11613 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); | |
11614 | ||
11615 | /* "neighbor peer-group" set commands. */ | |
11616 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
11617 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11618 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11619 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11620 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11621 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11622 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11623 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11624 | ||
11625 | /* "no neighbor peer-group unset" commands. */ | |
11626 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
11627 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11628 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11629 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11630 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11631 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11632 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11633 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11634 | ||
11635 | /* "neighbor softreconfiguration inbound" commands.*/ | |
11636 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
11637 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
11638 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
11639 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11640 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
11641 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11642 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
11643 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11644 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
11645 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11646 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
11647 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11648 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
11649 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11650 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
11651 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11652 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
11653 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11654 | ||
11655 | /* "neighbor attribute-unchanged" commands. */ | |
11656 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
11657 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
11658 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
11659 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
11660 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
11661 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
11662 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
11663 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
11664 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
11665 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
11666 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
11667 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
11668 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
11669 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
11670 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
11671 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
11672 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
11673 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
11674 | ||
11675 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
11676 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
11677 | ||
11678 | /* "nexthop-local unchanged" commands */ | |
11679 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
11680 | install_element(BGP_IPV6_NODE, | |
11681 | &no_neighbor_nexthop_local_unchanged_cmd); | |
11682 | ||
11683 | /* "neighbor next-hop-self" commands. */ | |
11684 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
11685 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
11686 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
11687 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
11688 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
11689 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
11690 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
11691 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
11692 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
11693 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
11694 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
11695 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
11696 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
11697 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
11698 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
11699 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
11700 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
11701 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
11702 | ||
11703 | /* "neighbor next-hop-self force" commands. */ | |
11704 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
11705 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
11706 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
11707 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11708 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
11709 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11710 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); | |
11711 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11712 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
11713 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11714 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
11715 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11716 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); | |
11717 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11718 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
11719 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11720 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); | |
11721 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11722 | ||
11723 | /* "neighbor as-override" commands. */ | |
11724 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
11725 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
11726 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
11727 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
11728 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
11729 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
11730 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
11731 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
11732 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
11733 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
11734 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
11735 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
11736 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
11737 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
11738 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
11739 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
11740 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
11741 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
11742 | ||
11743 | /* "neighbor remove-private-AS" commands. */ | |
11744 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
11745 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
11746 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
11747 | install_element(BGP_NODE, | |
11748 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
11749 | install_element(BGP_NODE, | |
11750 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
11751 | install_element(BGP_NODE, | |
11752 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
11753 | install_element(BGP_NODE, | |
11754 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
11755 | install_element( | |
11756 | BGP_NODE, | |
11757 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
11758 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
11759 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
11760 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
11761 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11762 | install_element(BGP_IPV4_NODE, | |
11763 | &neighbor_remove_private_as_replace_as_cmd); | |
11764 | install_element(BGP_IPV4_NODE, | |
11765 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11766 | install_element(BGP_IPV4_NODE, | |
11767 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11768 | install_element(BGP_IPV4_NODE, | |
11769 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11770 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
11771 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
11772 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
11773 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11774 | install_element(BGP_IPV4M_NODE, | |
11775 | &neighbor_remove_private_as_replace_as_cmd); | |
11776 | install_element(BGP_IPV4M_NODE, | |
11777 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11778 | install_element(BGP_IPV4M_NODE, | |
11779 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11780 | install_element(BGP_IPV4M_NODE, | |
11781 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11782 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
11783 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
11784 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
11785 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11786 | install_element(BGP_IPV4L_NODE, | |
11787 | &neighbor_remove_private_as_replace_as_cmd); | |
11788 | install_element(BGP_IPV4L_NODE, | |
11789 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11790 | install_element(BGP_IPV4L_NODE, | |
11791 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11792 | install_element(BGP_IPV4L_NODE, | |
11793 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11794 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
11795 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
11796 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
11797 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11798 | install_element(BGP_IPV6_NODE, | |
11799 | &neighbor_remove_private_as_replace_as_cmd); | |
11800 | install_element(BGP_IPV6_NODE, | |
11801 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11802 | install_element(BGP_IPV6_NODE, | |
11803 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11804 | install_element(BGP_IPV6_NODE, | |
11805 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11806 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
11807 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
11808 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
11809 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11810 | install_element(BGP_IPV6M_NODE, | |
11811 | &neighbor_remove_private_as_replace_as_cmd); | |
11812 | install_element(BGP_IPV6M_NODE, | |
11813 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11814 | install_element(BGP_IPV6M_NODE, | |
11815 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11816 | install_element(BGP_IPV6M_NODE, | |
11817 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11818 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
11819 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
11820 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
11821 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11822 | install_element(BGP_IPV6L_NODE, | |
11823 | &neighbor_remove_private_as_replace_as_cmd); | |
11824 | install_element(BGP_IPV6L_NODE, | |
11825 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11826 | install_element(BGP_IPV6L_NODE, | |
11827 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11828 | install_element(BGP_IPV6L_NODE, | |
11829 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11830 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
11831 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
11832 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
11833 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11834 | install_element(BGP_VPNV4_NODE, | |
11835 | &neighbor_remove_private_as_replace_as_cmd); | |
11836 | install_element(BGP_VPNV4_NODE, | |
11837 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11838 | install_element(BGP_VPNV4_NODE, | |
11839 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11840 | install_element(BGP_VPNV4_NODE, | |
11841 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11842 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
11843 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
11844 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
11845 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11846 | install_element(BGP_VPNV6_NODE, | |
11847 | &neighbor_remove_private_as_replace_as_cmd); | |
11848 | install_element(BGP_VPNV6_NODE, | |
11849 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11850 | install_element(BGP_VPNV6_NODE, | |
11851 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11852 | install_element(BGP_VPNV6_NODE, | |
11853 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11854 | ||
11855 | /* "neighbor send-community" commands.*/ | |
11856 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
11857 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
11858 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
11859 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
11860 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
11861 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
11862 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
11863 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
11864 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
11865 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
11866 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
11867 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
11868 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
11869 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
11870 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
11871 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
11872 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
11873 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
11874 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
11875 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
11876 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
11877 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
11878 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
11879 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
11880 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
11881 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
11882 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
11883 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
11884 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
11885 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
11886 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
11887 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
11888 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
11889 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
11890 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
11891 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
11892 | ||
11893 | /* "neighbor route-reflector" commands.*/ | |
11894 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
11895 | install_element(BGP_NODE, | |
11896 | &no_neighbor_route_reflector_client_hidden_cmd); | |
11897 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
11898 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
11899 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
11900 | install_element(BGP_IPV4M_NODE, | |
11901 | &no_neighbor_route_reflector_client_cmd); | |
11902 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
11903 | install_element(BGP_IPV4L_NODE, | |
11904 | &no_neighbor_route_reflector_client_cmd); | |
11905 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
11906 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
11907 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
11908 | install_element(BGP_IPV6M_NODE, | |
11909 | &no_neighbor_route_reflector_client_cmd); | |
11910 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
11911 | install_element(BGP_IPV6L_NODE, | |
11912 | &no_neighbor_route_reflector_client_cmd); | |
11913 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
11914 | install_element(BGP_VPNV4_NODE, | |
11915 | &no_neighbor_route_reflector_client_cmd); | |
11916 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
11917 | install_element(BGP_VPNV6_NODE, | |
11918 | &no_neighbor_route_reflector_client_cmd); | |
11919 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); | |
11920 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
11921 | ||
11922 | /* "neighbor route-server" commands.*/ | |
11923 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
11924 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
11925 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
11926 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
11927 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
11928 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
11929 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
11930 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
11931 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
11932 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
11933 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
11934 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
11935 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
11936 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
11937 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
11938 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
11939 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
11940 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
11941 | ||
11942 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
11943 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
11944 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
11945 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11946 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11947 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11948 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11949 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11950 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11951 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11952 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11953 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11954 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11955 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11956 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11957 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11958 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11959 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11960 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11961 | ||
11962 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
11963 | install_element(BGP_NODE, | |
11964 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
11965 | install_element(BGP_NODE, | |
11966 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
11967 | install_element(BGP_IPV4_NODE, | |
11968 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11969 | install_element(BGP_IPV4_NODE, | |
11970 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11971 | install_element(BGP_IPV4M_NODE, | |
11972 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11973 | install_element(BGP_IPV4M_NODE, | |
11974 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11975 | install_element(BGP_IPV4L_NODE, | |
11976 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11977 | install_element(BGP_IPV4L_NODE, | |
11978 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11979 | install_element(BGP_IPV6_NODE, | |
11980 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11981 | install_element(BGP_IPV6_NODE, | |
11982 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11983 | install_element(BGP_IPV6M_NODE, | |
11984 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11985 | install_element(BGP_IPV6M_NODE, | |
11986 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11987 | install_element(BGP_IPV6L_NODE, | |
11988 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11989 | install_element(BGP_IPV6L_NODE, | |
11990 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11991 | install_element(BGP_VPNV4_NODE, | |
11992 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11993 | install_element(BGP_VPNV4_NODE, | |
11994 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11995 | install_element(BGP_VPNV6_NODE, | |
11996 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11997 | install_element(BGP_VPNV6_NODE, | |
11998 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11999 | ||
12000 | /* "neighbor passive" commands. */ | |
12001 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
12002 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
12003 | ||
12004 | ||
12005 | /* "neighbor shutdown" commands. */ | |
12006 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
12007 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
12008 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
12009 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
12010 | ||
12011 | /* "neighbor capability extended-nexthop" commands.*/ | |
12012 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
12013 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
12014 | ||
12015 | /* "neighbor capability orf prefix-list" commands.*/ | |
12016 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
12017 | install_element(BGP_NODE, | |
12018 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
12019 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
12020 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
12021 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
12022 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
12023 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
12024 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
12025 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
12026 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
12027 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
12028 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
12029 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
12030 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
12031 | ||
12032 | /* "neighbor capability dynamic" commands.*/ | |
12033 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
12034 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
12035 | ||
12036 | /* "neighbor dont-capability-negotiate" commands. */ | |
12037 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
12038 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
12039 | ||
12040 | /* "neighbor ebgp-multihop" commands. */ | |
12041 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
12042 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
12043 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
12044 | ||
12045 | /* "neighbor disable-connected-check" commands. */ | |
12046 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
12047 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
12048 | ||
12049 | /* "neighbor description" commands. */ | |
12050 | install_element(BGP_NODE, &neighbor_description_cmd); | |
12051 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
12052 | ||
12053 | /* "neighbor update-source" commands. "*/ | |
12054 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
12055 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
12056 | ||
12057 | /* "neighbor default-originate" commands. */ | |
12058 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
12059 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
12060 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
12061 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
12062 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
12063 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
12064 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
12065 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
12066 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
12067 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
12068 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
12069 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
12070 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
12071 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
12072 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
12073 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
12074 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
12075 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
12076 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
12077 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
12078 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
12079 | ||
12080 | /* "neighbor port" commands. */ | |
12081 | install_element(BGP_NODE, &neighbor_port_cmd); | |
12082 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
12083 | ||
12084 | /* "neighbor weight" commands. */ | |
12085 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
12086 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
12087 | ||
12088 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
12089 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
12090 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
12091 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
12092 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
12093 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
12094 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
12095 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
12096 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
12097 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
12098 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
12099 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
12100 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
12101 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
12102 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
12103 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
12104 | ||
12105 | /* "neighbor override-capability" commands. */ | |
12106 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
12107 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
12108 | ||
12109 | /* "neighbor strict-capability-match" commands. */ | |
12110 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
12111 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
12112 | ||
12113 | /* "neighbor timers" commands. */ | |
12114 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
12115 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
12116 | ||
12117 | /* "neighbor timers connect" commands. */ | |
12118 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
12119 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
12120 | ||
12121 | /* "neighbor advertisement-interval" commands. */ | |
12122 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
12123 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
12124 | ||
12125 | /* "neighbor interface" commands. */ | |
12126 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
12127 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
12128 | ||
12129 | /* "neighbor distribute" commands. */ | |
12130 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
12131 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
12132 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
12133 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
12134 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
12135 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
12136 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
12137 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
12138 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
12139 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
12140 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
12141 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
12142 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
12143 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
12144 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
12145 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
12146 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
12147 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
12148 | ||
12149 | /* "neighbor prefix-list" commands. */ | |
12150 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
12151 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
12152 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
12153 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
12154 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
12155 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
12156 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
12157 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
12158 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
12159 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
12160 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
12161 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
12162 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
12163 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
12164 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
12165 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
12166 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
12167 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
12168 | ||
12169 | /* "neighbor filter-list" commands. */ | |
12170 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
12171 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
12172 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
12173 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
12174 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
12175 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
12176 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
12177 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
12178 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
12179 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
12180 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
12181 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
12182 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
12183 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
12184 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
12185 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
12186 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
12187 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
12188 | ||
12189 | /* "neighbor route-map" commands. */ | |
12190 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
12191 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
12192 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
12193 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
12194 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
12195 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
12196 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
12197 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
12198 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
12199 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
12200 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
12201 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
12202 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
12203 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
12204 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
12205 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
12206 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
12207 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
12208 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
12209 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 12210 | |
12211 | /* "neighbor unsuppress-map" commands. */ | |
12212 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
12213 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
12214 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
12215 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
12216 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
12217 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
12218 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
12219 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
12220 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
12221 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
12222 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
12223 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
12224 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
12225 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
12226 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
12227 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
12228 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
12229 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
12230 | ||
12231 | /* "neighbor maximum-prefix" commands. */ | |
12232 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
12233 | install_element(BGP_NODE, | |
12234 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
12235 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
12236 | install_element(BGP_NODE, | |
12237 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
12238 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
12239 | install_element(BGP_NODE, | |
12240 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
12241 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
12242 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
12243 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12244 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12245 | install_element(BGP_IPV4_NODE, | |
12246 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12247 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12248 | install_element(BGP_IPV4_NODE, | |
12249 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12250 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
12251 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
12252 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12253 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12254 | install_element(BGP_IPV4M_NODE, | |
12255 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12256 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12257 | install_element(BGP_IPV4M_NODE, | |
12258 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12259 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
12260 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
12261 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12262 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12263 | install_element(BGP_IPV4L_NODE, | |
12264 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12265 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12266 | install_element(BGP_IPV4L_NODE, | |
12267 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12268 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
12269 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
12270 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12271 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12272 | install_element(BGP_IPV6_NODE, | |
12273 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12274 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12275 | install_element(BGP_IPV6_NODE, | |
12276 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12277 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
12278 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
12279 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12280 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12281 | install_element(BGP_IPV6M_NODE, | |
12282 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12283 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12284 | install_element(BGP_IPV6M_NODE, | |
12285 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12286 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
12287 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
12288 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12289 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12290 | install_element(BGP_IPV6L_NODE, | |
12291 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12292 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12293 | install_element(BGP_IPV6L_NODE, | |
12294 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12295 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
12296 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
12297 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12298 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12299 | install_element(BGP_VPNV4_NODE, | |
12300 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12301 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12302 | install_element(BGP_VPNV4_NODE, | |
12303 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12304 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
12305 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
12306 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12307 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12308 | install_element(BGP_VPNV6_NODE, | |
12309 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12310 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12311 | install_element(BGP_VPNV6_NODE, | |
12312 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12313 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
12314 | ||
12315 | /* "neighbor allowas-in" */ | |
12316 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
12317 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
12318 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
12319 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
12320 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
12321 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
12322 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
12323 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
12324 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
12325 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
12326 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
12327 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
12328 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
12329 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
12330 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
12331 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
12332 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
12333 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
12334 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
12335 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
12336 | ||
12337 | /* address-family commands. */ | |
12338 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
12339 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 12340 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 12341 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
12342 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 12343 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 12344 | |
d62a17ae | 12345 | install_element(BGP_NODE, &address_family_evpn_cmd); |
12346 | ||
12347 | /* "exit-address-family" command. */ | |
12348 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
12349 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
12350 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
12351 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
12352 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
12353 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
12354 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
12355 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
12356 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); | |
12357 | ||
12358 | /* "clear ip bgp commands" */ | |
12359 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
12360 | ||
12361 | /* clear ip bgp prefix */ | |
12362 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
12363 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
12364 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
12365 | ||
12366 | /* "show [ip] bgp summary" commands. */ | |
12367 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
12368 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd); | |
12369 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); | |
12370 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); | |
12371 | install_element(VIEW_NODE, &show_bgp_updgrps_adj_cmd); | |
12372 | install_element(VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); | |
12373 | install_element(VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); | |
12374 | install_element(VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); | |
12375 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); | |
12376 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); | |
12377 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); | |
12378 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
12379 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); | |
12380 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); | |
12381 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); | |
12382 | ||
12383 | /* "show [ip] bgp neighbors" commands. */ | |
12384 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
12385 | ||
12386 | /* "show [ip] bgp peer-group" commands. */ | |
12387 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
12388 | ||
12389 | /* "show [ip] bgp paths" commands. */ | |
12390 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
12391 | ||
12392 | /* "show [ip] bgp community" commands. */ | |
12393 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
12394 | ||
12395 | /* "show ip bgp large-community" commands. */ | |
12396 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
12397 | /* "show [ip] bgp attribute-info" commands. */ | |
12398 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
12399 | ||
12400 | /* "redistribute" commands. */ | |
12401 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
12402 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
12403 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
12404 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
12405 | install_element(BGP_NODE, | |
12406 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
12407 | install_element(BGP_NODE, | |
12408 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
12409 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
12410 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
12411 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
12412 | install_element(BGP_NODE, | |
12413 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
12414 | install_element(BGP_NODE, | |
12415 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
12416 | install_element(BGP_NODE, | |
12417 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
12418 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
12419 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
12420 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
12421 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
12422 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
12423 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
12424 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
12425 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
12426 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
12427 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
12428 | install_element(BGP_IPV4_NODE, | |
12429 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
12430 | install_element(BGP_IPV4_NODE, | |
12431 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
12432 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
12433 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
12434 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
12435 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
12436 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
12437 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
12438 | ||
12439 | /* ttl_security commands */ | |
12440 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
12441 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
12442 | ||
12443 | /* "show [ip] bgp memory" commands. */ | |
12444 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
12445 | ||
acf71666 MK |
12446 | /* "show bgp martian next-hop" */ |
12447 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
12448 | ||
d62a17ae | 12449 | /* "show [ip] bgp views" commands. */ |
12450 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
12451 | ||
12452 | /* "show [ip] bgp vrfs" commands. */ | |
12453 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
12454 | ||
12455 | /* Community-list. */ | |
12456 | community_list_vty(); | |
718e3744 | 12457 | } |
6b0655a2 | 12458 | |
718e3744 | 12459 | #include "memory.h" |
12460 | #include "bgp_regex.h" | |
12461 | #include "bgp_clist.h" | |
12462 | #include "bgp_ecommunity.h" | |
12463 | ||
12464 | /* VTY functions. */ | |
12465 | ||
12466 | /* Direction value to string conversion. */ | |
d62a17ae | 12467 | static const char *community_direct_str(int direct) |
12468 | { | |
12469 | switch (direct) { | |
12470 | case COMMUNITY_DENY: | |
12471 | return "deny"; | |
12472 | case COMMUNITY_PERMIT: | |
12473 | return "permit"; | |
12474 | default: | |
12475 | return "unknown"; | |
12476 | } | |
718e3744 | 12477 | } |
12478 | ||
12479 | /* Display error string. */ | |
d62a17ae | 12480 | static void community_list_perror(struct vty *vty, int ret) |
12481 | { | |
12482 | switch (ret) { | |
12483 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
12484 | vty_out(vty, "%% Can't find community-list\n"); | |
12485 | break; | |
12486 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
12487 | vty_out(vty, "%% Malformed community-list value\n"); | |
12488 | break; | |
12489 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
12490 | vty_out(vty, | |
12491 | "%% Community name conflict, previously defined as standard community\n"); | |
12492 | break; | |
12493 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
12494 | vty_out(vty, | |
12495 | "%% Community name conflict, previously defined as expanded community\n"); | |
12496 | break; | |
12497 | } | |
718e3744 | 12498 | } |
12499 | ||
5bf15956 DW |
12500 | /* "community-list" keyword help string. */ |
12501 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
12502 | ||
5bf15956 | 12503 | /* ip community-list standard */ |
718e3744 | 12504 | DEFUN (ip_community_list_standard, |
12505 | ip_community_list_standard_cmd, | |
e961923c | 12506 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 12507 | IP_STR |
12508 | COMMUNITY_LIST_STR | |
12509 | "Community list number (standard)\n" | |
5bf15956 | 12510 | "Add an standard community-list entry\n" |
718e3744 | 12511 | "Community list name\n" |
12512 | "Specify community to reject\n" | |
12513 | "Specify community to accept\n" | |
12514 | COMMUNITY_VAL_STR) | |
12515 | { | |
d62a17ae | 12516 | char *cl_name_or_number = NULL; |
12517 | int direct = 0; | |
12518 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 12519 | |
d62a17ae | 12520 | int idx = 0; |
12521 | argv_find(argv, argc, "(1-99)", &idx); | |
12522 | argv_find(argv, argc, "WORD", &idx); | |
12523 | cl_name_or_number = argv[idx]->arg; | |
12524 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12525 | : COMMUNITY_DENY; | |
12526 | argv_find(argv, argc, "AA:NN", &idx); | |
12527 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12528 | |
d62a17ae | 12529 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
12530 | style); | |
42f914d4 | 12531 | |
d62a17ae | 12532 | XFREE(MTYPE_TMP, str); |
42f914d4 | 12533 | |
d62a17ae | 12534 | if (ret < 0) { |
12535 | /* Display error string. */ | |
12536 | community_list_perror(vty, ret); | |
12537 | return CMD_WARNING_CONFIG_FAILED; | |
12538 | } | |
42f914d4 | 12539 | |
d62a17ae | 12540 | return CMD_SUCCESS; |
718e3744 | 12541 | } |
12542 | ||
fee6e4e4 | 12543 | DEFUN (no_ip_community_list_standard_all, |
12544 | no_ip_community_list_standard_all_cmd, | |
e961923c | 12545 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 12546 | NO_STR |
12547 | IP_STR | |
12548 | COMMUNITY_LIST_STR | |
12549 | "Community list number (standard)\n" | |
5bf15956 DW |
12550 | "Add an standard community-list entry\n" |
12551 | "Community list name\n" | |
718e3744 | 12552 | "Specify community to reject\n" |
12553 | "Specify community to accept\n" | |
12554 | COMMUNITY_VAL_STR) | |
12555 | { | |
d62a17ae | 12556 | int delete_all = 0; |
42f914d4 | 12557 | |
d62a17ae | 12558 | char *cl_name_or_number = NULL; |
12559 | int direct = 0; | |
12560 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 12561 | |
d62a17ae | 12562 | int idx = 0; |
12563 | argv_find(argv, argc, "(1-99)", &idx); | |
12564 | argv_find(argv, argc, "WORD", &idx); | |
12565 | cl_name_or_number = argv[idx]->arg; | |
12566 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12567 | : COMMUNITY_DENY; | |
12568 | argv_find(argv, argc, "AA:NN", &idx); | |
12569 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12570 | |
d62a17ae | 12571 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
12572 | direct, style, delete_all); | |
42f914d4 | 12573 | |
d62a17ae | 12574 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 12575 | |
d62a17ae | 12576 | if (ret < 0) { |
12577 | community_list_perror(vty, ret); | |
12578 | return CMD_WARNING_CONFIG_FAILED; | |
12579 | } | |
42f914d4 | 12580 | |
d62a17ae | 12581 | return CMD_SUCCESS; |
718e3744 | 12582 | } |
12583 | ||
5bf15956 DW |
12584 | /* ip community-list expanded */ |
12585 | DEFUN (ip_community_list_expanded_all, | |
12586 | ip_community_list_expanded_all_cmd, | |
42f914d4 | 12587 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 12588 | IP_STR |
12589 | COMMUNITY_LIST_STR | |
12590 | "Community list number (expanded)\n" | |
5bf15956 | 12591 | "Add an expanded community-list entry\n" |
718e3744 | 12592 | "Community list name\n" |
12593 | "Specify community to reject\n" | |
12594 | "Specify community to accept\n" | |
12595 | COMMUNITY_VAL_STR) | |
12596 | { | |
d62a17ae | 12597 | char *cl_name_or_number = NULL; |
12598 | int direct = 0; | |
12599 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 12600 | |
d62a17ae | 12601 | int idx = 0; |
12602 | argv_find(argv, argc, "(100-500)", &idx); | |
12603 | argv_find(argv, argc, "WORD", &idx); | |
12604 | cl_name_or_number = argv[idx]->arg; | |
12605 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12606 | : COMMUNITY_DENY; | |
12607 | argv_find(argv, argc, "AA:NN", &idx); | |
12608 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12609 | |
d62a17ae | 12610 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
12611 | style); | |
42f914d4 | 12612 | |
d62a17ae | 12613 | XFREE(MTYPE_TMP, str); |
42f914d4 | 12614 | |
d62a17ae | 12615 | if (ret < 0) { |
12616 | /* Display error string. */ | |
12617 | community_list_perror(vty, ret); | |
12618 | return CMD_WARNING_CONFIG_FAILED; | |
12619 | } | |
42f914d4 | 12620 | |
d62a17ae | 12621 | return CMD_SUCCESS; |
718e3744 | 12622 | } |
12623 | ||
5bf15956 DW |
12624 | DEFUN (no_ip_community_list_expanded_all, |
12625 | no_ip_community_list_expanded_all_cmd, | |
42f914d4 | 12626 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 12627 | NO_STR |
12628 | IP_STR | |
12629 | COMMUNITY_LIST_STR | |
5bf15956 DW |
12630 | "Community list number (expanded)\n" |
12631 | "Add an expanded community-list entry\n" | |
718e3744 | 12632 | "Community list name\n" |
12633 | "Specify community to reject\n" | |
12634 | "Specify community to accept\n" | |
5bf15956 | 12635 | COMMUNITY_VAL_STR) |
718e3744 | 12636 | { |
d62a17ae | 12637 | int delete_all = 0; |
42f914d4 | 12638 | |
d62a17ae | 12639 | char *cl_name_or_number = NULL; |
12640 | int direct = 0; | |
12641 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 12642 | |
d62a17ae | 12643 | int idx = 0; |
12644 | argv_find(argv, argc, "(100-500)", &idx); | |
12645 | argv_find(argv, argc, "WORD", &idx); | |
12646 | cl_name_or_number = argv[idx]->arg; | |
12647 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12648 | : COMMUNITY_DENY; | |
12649 | argv_find(argv, argc, "AA:NN", &idx); | |
12650 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12651 | |
d62a17ae | 12652 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
12653 | direct, style, delete_all); | |
42f914d4 | 12654 | |
d62a17ae | 12655 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 12656 | |
d62a17ae | 12657 | if (ret < 0) { |
12658 | community_list_perror(vty, ret); | |
12659 | return CMD_WARNING_CONFIG_FAILED; | |
12660 | } | |
42f914d4 | 12661 | |
d62a17ae | 12662 | return CMD_SUCCESS; |
718e3744 | 12663 | } |
12664 | ||
d62a17ae | 12665 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 12666 | { |
d62a17ae | 12667 | struct community_entry *entry; |
718e3744 | 12668 | |
d62a17ae | 12669 | for (entry = list->head; entry; entry = entry->next) { |
12670 | if (entry == list->head) { | |
12671 | if (all_digit(list->name)) | |
12672 | vty_out(vty, "Community %s list %s\n", | |
12673 | entry->style == COMMUNITY_LIST_STANDARD | |
12674 | ? "standard" | |
12675 | : "(expanded) access", | |
12676 | list->name); | |
12677 | else | |
12678 | vty_out(vty, "Named Community %s list %s\n", | |
12679 | entry->style == COMMUNITY_LIST_STANDARD | |
12680 | ? "standard" | |
12681 | : "expanded", | |
12682 | list->name); | |
12683 | } | |
12684 | if (entry->any) | |
12685 | vty_out(vty, " %s\n", | |
12686 | community_direct_str(entry->direct)); | |
12687 | else | |
12688 | vty_out(vty, " %s %s\n", | |
12689 | community_direct_str(entry->direct), | |
12690 | entry->style == COMMUNITY_LIST_STANDARD | |
a69ea8ae | 12691 | ? community_str(entry->u.com, false) |
d62a17ae | 12692 | : entry->config); |
12693 | } | |
718e3744 | 12694 | } |
12695 | ||
12696 | DEFUN (show_ip_community_list, | |
12697 | show_ip_community_list_cmd, | |
12698 | "show ip community-list", | |
12699 | SHOW_STR | |
12700 | IP_STR | |
12701 | "List community-list\n") | |
12702 | { | |
d62a17ae | 12703 | struct community_list *list; |
12704 | struct community_list_master *cm; | |
718e3744 | 12705 | |
d62a17ae | 12706 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
12707 | if (!cm) | |
12708 | return CMD_SUCCESS; | |
718e3744 | 12709 | |
d62a17ae | 12710 | for (list = cm->num.head; list; list = list->next) |
12711 | community_list_show(vty, list); | |
718e3744 | 12712 | |
d62a17ae | 12713 | for (list = cm->str.head; list; list = list->next) |
12714 | community_list_show(vty, list); | |
718e3744 | 12715 | |
d62a17ae | 12716 | return CMD_SUCCESS; |
718e3744 | 12717 | } |
12718 | ||
12719 | DEFUN (show_ip_community_list_arg, | |
12720 | show_ip_community_list_arg_cmd, | |
6147e2c6 | 12721 | "show ip community-list <(1-500)|WORD>", |
718e3744 | 12722 | SHOW_STR |
12723 | IP_STR | |
12724 | "List community-list\n" | |
12725 | "Community-list number\n" | |
12726 | "Community-list name\n") | |
12727 | { | |
d62a17ae | 12728 | int idx_comm_list = 3; |
12729 | struct community_list *list; | |
718e3744 | 12730 | |
d62a17ae | 12731 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
12732 | COMMUNITY_LIST_MASTER); | |
12733 | if (!list) { | |
12734 | vty_out(vty, "%% Can't find community-list\n"); | |
12735 | return CMD_WARNING; | |
12736 | } | |
718e3744 | 12737 | |
d62a17ae | 12738 | community_list_show(vty, list); |
718e3744 | 12739 | |
d62a17ae | 12740 | return CMD_SUCCESS; |
718e3744 | 12741 | } |
6b0655a2 | 12742 | |
57d187bc JS |
12743 | /* |
12744 | * Large Community code. | |
12745 | */ | |
d62a17ae | 12746 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
12747 | struct cmd_token **argv, int style, | |
12748 | int reject_all_digit_name) | |
12749 | { | |
12750 | int ret; | |
12751 | int direct; | |
12752 | char *str; | |
12753 | int idx = 0; | |
12754 | char *cl_name; | |
12755 | ||
12756 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12757 | : COMMUNITY_DENY; | |
12758 | ||
12759 | /* All digit name check. */ | |
12760 | idx = 0; | |
12761 | argv_find(argv, argc, "WORD", &idx); | |
12762 | argv_find(argv, argc, "(1-99)", &idx); | |
12763 | argv_find(argv, argc, "(100-500)", &idx); | |
12764 | cl_name = argv[idx]->arg; | |
12765 | if (reject_all_digit_name && all_digit(cl_name)) { | |
12766 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
12767 | return CMD_WARNING_CONFIG_FAILED; | |
12768 | } | |
12769 | ||
12770 | idx = 0; | |
12771 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
12772 | argv_find(argv, argc, "LINE", &idx); | |
12773 | /* Concat community string argument. */ | |
12774 | if (idx) | |
12775 | str = argv_concat(argv, argc, idx); | |
12776 | else | |
12777 | str = NULL; | |
12778 | ||
12779 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
12780 | ||
12781 | /* Free temporary community list string allocated by | |
12782 | argv_concat(). */ | |
12783 | if (str) | |
12784 | XFREE(MTYPE_TMP, str); | |
12785 | ||
12786 | if (ret < 0) { | |
12787 | community_list_perror(vty, ret); | |
12788 | return CMD_WARNING_CONFIG_FAILED; | |
12789 | } | |
12790 | return CMD_SUCCESS; | |
12791 | } | |
12792 | ||
12793 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
12794 | struct cmd_token **argv, int style) | |
12795 | { | |
12796 | int ret; | |
12797 | int direct = 0; | |
12798 | char *str = NULL; | |
12799 | int idx = 0; | |
12800 | ||
12801 | argv_find(argv, argc, "permit", &idx); | |
12802 | argv_find(argv, argc, "deny", &idx); | |
12803 | ||
12804 | if (idx) { | |
12805 | /* Check the list direct. */ | |
12806 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
12807 | direct = COMMUNITY_PERMIT; | |
12808 | else | |
12809 | direct = COMMUNITY_DENY; | |
12810 | ||
12811 | idx = 0; | |
12812 | argv_find(argv, argc, "LINE", &idx); | |
12813 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
12814 | /* Concat community string argument. */ | |
12815 | str = argv_concat(argv, argc, idx); | |
12816 | } | |
12817 | ||
12818 | idx = 0; | |
12819 | argv_find(argv, argc, "(1-99)", &idx); | |
12820 | argv_find(argv, argc, "(100-500)", &idx); | |
12821 | argv_find(argv, argc, "WORD", &idx); | |
12822 | ||
12823 | /* Unset community list. */ | |
12824 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
12825 | style); | |
12826 | ||
12827 | /* Free temporary community list string allocated by | |
12828 | argv_concat(). */ | |
12829 | if (str) | |
12830 | XFREE(MTYPE_TMP, str); | |
12831 | ||
12832 | if (ret < 0) { | |
12833 | community_list_perror(vty, ret); | |
12834 | return CMD_WARNING_CONFIG_FAILED; | |
12835 | } | |
12836 | ||
12837 | return CMD_SUCCESS; | |
57d187bc JS |
12838 | } |
12839 | ||
12840 | /* "large-community-list" keyword help string. */ | |
12841 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
12842 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
12843 | ||
12844 | DEFUN (ip_lcommunity_list_standard, | |
12845 | ip_lcommunity_list_standard_cmd, | |
52951b63 DS |
12846 | "ip large-community-list (1-99) <deny|permit>", |
12847 | IP_STR | |
12848 | LCOMMUNITY_LIST_STR | |
12849 | "Large Community list number (standard)\n" | |
12850 | "Specify large community to reject\n" | |
7111c1a0 | 12851 | "Specify large community to accept\n") |
52951b63 | 12852 | { |
d62a17ae | 12853 | return lcommunity_list_set_vty(vty, argc, argv, |
12854 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
12855 | } |
12856 | ||
12857 | DEFUN (ip_lcommunity_list_standard1, | |
12858 | ip_lcommunity_list_standard1_cmd, | |
12859 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
12860 | IP_STR |
12861 | LCOMMUNITY_LIST_STR | |
12862 | "Large Community list number (standard)\n" | |
12863 | "Specify large community to reject\n" | |
12864 | "Specify large community to accept\n" | |
12865 | LCOMMUNITY_VAL_STR) | |
12866 | { | |
d62a17ae | 12867 | return lcommunity_list_set_vty(vty, argc, argv, |
12868 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
57d187bc JS |
12869 | } |
12870 | ||
12871 | DEFUN (ip_lcommunity_list_expanded, | |
12872 | ip_lcommunity_list_expanded_cmd, | |
12873 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
12874 | IP_STR | |
12875 | LCOMMUNITY_LIST_STR | |
12876 | "Large Community list number (expanded)\n" | |
12877 | "Specify large community to reject\n" | |
12878 | "Specify large community to accept\n" | |
12879 | "An ordered list as a regular-expression\n") | |
12880 | { | |
d62a17ae | 12881 | return lcommunity_list_set_vty(vty, argc, argv, |
12882 | LARGE_COMMUNITY_LIST_EXPANDED, 0); | |
57d187bc JS |
12883 | } |
12884 | ||
12885 | DEFUN (ip_lcommunity_list_name_standard, | |
12886 | ip_lcommunity_list_name_standard_cmd, | |
52951b63 DS |
12887 | "ip large-community-list standard WORD <deny|permit>", |
12888 | IP_STR | |
12889 | LCOMMUNITY_LIST_STR | |
12890 | "Specify standard large-community-list\n" | |
12891 | "Large Community list name\n" | |
12892 | "Specify large community to reject\n" | |
12893 | "Specify large community to accept\n") | |
12894 | { | |
d62a17ae | 12895 | return lcommunity_list_set_vty(vty, argc, argv, |
12896 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
12897 | } |
12898 | ||
12899 | DEFUN (ip_lcommunity_list_name_standard1, | |
12900 | ip_lcommunity_list_name_standard1_cmd, | |
12901 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
12902 | IP_STR |
12903 | LCOMMUNITY_LIST_STR | |
12904 | "Specify standard large-community-list\n" | |
12905 | "Large Community list name\n" | |
12906 | "Specify large community to reject\n" | |
12907 | "Specify large community to accept\n" | |
12908 | LCOMMUNITY_VAL_STR) | |
12909 | { | |
d62a17ae | 12910 | return lcommunity_list_set_vty(vty, argc, argv, |
12911 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
57d187bc JS |
12912 | } |
12913 | ||
12914 | DEFUN (ip_lcommunity_list_name_expanded, | |
12915 | ip_lcommunity_list_name_expanded_cmd, | |
12916 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
12917 | IP_STR | |
12918 | LCOMMUNITY_LIST_STR | |
12919 | "Specify expanded large-community-list\n" | |
12920 | "Large Community list name\n" | |
12921 | "Specify large community to reject\n" | |
12922 | "Specify large community to accept\n" | |
12923 | "An ordered list as a regular-expression\n") | |
12924 | { | |
d62a17ae | 12925 | return lcommunity_list_set_vty(vty, argc, argv, |
12926 | LARGE_COMMUNITY_LIST_EXPANDED, 1); | |
57d187bc JS |
12927 | } |
12928 | ||
12929 | DEFUN (no_ip_lcommunity_list_standard_all, | |
12930 | no_ip_lcommunity_list_standard_all_cmd, | |
12931 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
12932 | NO_STR | |
12933 | IP_STR | |
12934 | LCOMMUNITY_LIST_STR | |
12935 | "Large Community list number (standard)\n" | |
12936 | "Large Community list number (expanded)\n" | |
12937 | "Large Community list name\n") | |
12938 | { | |
d62a17ae | 12939 | return lcommunity_list_unset_vty(vty, argc, argv, |
12940 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
12941 | } |
12942 | ||
12943 | DEFUN (no_ip_lcommunity_list_name_expanded_all, | |
12944 | no_ip_lcommunity_list_name_expanded_all_cmd, | |
12945 | "no ip large-community-list expanded WORD", | |
12946 | NO_STR | |
12947 | IP_STR | |
12948 | LCOMMUNITY_LIST_STR | |
12949 | "Specify expanded large-community-list\n" | |
12950 | "Large Community list name\n") | |
12951 | { | |
d62a17ae | 12952 | return lcommunity_list_unset_vty(vty, argc, argv, |
12953 | LARGE_COMMUNITY_LIST_EXPANDED); | |
57d187bc JS |
12954 | } |
12955 | ||
12956 | DEFUN (no_ip_lcommunity_list_standard, | |
12957 | no_ip_lcommunity_list_standard_cmd, | |
12958 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
12959 | NO_STR | |
12960 | IP_STR | |
12961 | LCOMMUNITY_LIST_STR | |
12962 | "Large Community list number (standard)\n" | |
12963 | "Specify large community to reject\n" | |
12964 | "Specify large community to accept\n" | |
12965 | LCOMMUNITY_VAL_STR) | |
12966 | { | |
d62a17ae | 12967 | return lcommunity_list_unset_vty(vty, argc, argv, |
12968 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
12969 | } |
12970 | ||
12971 | DEFUN (no_ip_lcommunity_list_expanded, | |
12972 | no_ip_lcommunity_list_expanded_cmd, | |
12973 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
12974 | NO_STR | |
12975 | IP_STR | |
12976 | LCOMMUNITY_LIST_STR | |
12977 | "Large Community list number (expanded)\n" | |
12978 | "Specify large community to reject\n" | |
12979 | "Specify large community to accept\n" | |
12980 | "An ordered list as a regular-expression\n") | |
12981 | { | |
d62a17ae | 12982 | return lcommunity_list_unset_vty(vty, argc, argv, |
12983 | LARGE_COMMUNITY_LIST_EXPANDED); | |
57d187bc JS |
12984 | } |
12985 | ||
12986 | DEFUN (no_ip_lcommunity_list_name_standard, | |
12987 | no_ip_lcommunity_list_name_standard_cmd, | |
12988 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
12989 | NO_STR | |
12990 | IP_STR | |
12991 | LCOMMUNITY_LIST_STR | |
12992 | "Specify standard large-community-list\n" | |
12993 | "Large Community list name\n" | |
12994 | "Specify large community to reject\n" | |
12995 | "Specify large community to accept\n" | |
12996 | LCOMMUNITY_VAL_STR) | |
12997 | { | |
d62a17ae | 12998 | return lcommunity_list_unset_vty(vty, argc, argv, |
12999 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
13000 | } |
13001 | ||
13002 | DEFUN (no_ip_lcommunity_list_name_expanded, | |
13003 | no_ip_lcommunity_list_name_expanded_cmd, | |
13004 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
13005 | NO_STR | |
13006 | IP_STR | |
13007 | LCOMMUNITY_LIST_STR | |
13008 | "Specify expanded large-community-list\n" | |
13009 | "Large community list name\n" | |
13010 | "Specify large community to reject\n" | |
13011 | "Specify large community to accept\n" | |
13012 | "An ordered list as a regular-expression\n") | |
13013 | { | |
d62a17ae | 13014 | return lcommunity_list_unset_vty(vty, argc, argv, |
13015 | LARGE_COMMUNITY_LIST_EXPANDED); | |
13016 | } | |
13017 | ||
13018 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) | |
13019 | { | |
13020 | struct community_entry *entry; | |
13021 | ||
13022 | for (entry = list->head; entry; entry = entry->next) { | |
13023 | if (entry == list->head) { | |
13024 | if (all_digit(list->name)) | |
13025 | vty_out(vty, "Large community %s list %s\n", | |
13026 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13027 | ? "standard" | |
13028 | : "(expanded) access", | |
13029 | list->name); | |
13030 | else | |
13031 | vty_out(vty, | |
13032 | "Named large community %s list %s\n", | |
13033 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13034 | ? "standard" | |
13035 | : "expanded", | |
13036 | list->name); | |
13037 | } | |
13038 | if (entry->any) | |
13039 | vty_out(vty, " %s\n", | |
13040 | community_direct_str(entry->direct)); | |
13041 | else | |
13042 | vty_out(vty, " %s %s\n", | |
13043 | community_direct_str(entry->direct), | |
13044 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13045 | ? entry->u.ecom->str | |
13046 | : entry->config); | |
13047 | } | |
57d187bc JS |
13048 | } |
13049 | ||
13050 | DEFUN (show_ip_lcommunity_list, | |
13051 | show_ip_lcommunity_list_cmd, | |
13052 | "show ip large-community-list", | |
13053 | SHOW_STR | |
13054 | IP_STR | |
13055 | "List large-community list\n") | |
13056 | { | |
d62a17ae | 13057 | struct community_list *list; |
13058 | struct community_list_master *cm; | |
57d187bc | 13059 | |
d62a17ae | 13060 | cm = community_list_master_lookup(bgp_clist, |
13061 | LARGE_COMMUNITY_LIST_MASTER); | |
13062 | if (!cm) | |
13063 | return CMD_SUCCESS; | |
57d187bc | 13064 | |
d62a17ae | 13065 | for (list = cm->num.head; list; list = list->next) |
13066 | lcommunity_list_show(vty, list); | |
57d187bc | 13067 | |
d62a17ae | 13068 | for (list = cm->str.head; list; list = list->next) |
13069 | lcommunity_list_show(vty, list); | |
57d187bc | 13070 | |
d62a17ae | 13071 | return CMD_SUCCESS; |
57d187bc JS |
13072 | } |
13073 | ||
13074 | DEFUN (show_ip_lcommunity_list_arg, | |
13075 | show_ip_lcommunity_list_arg_cmd, | |
13076 | "show ip large-community-list <(1-500)|WORD>", | |
13077 | SHOW_STR | |
13078 | IP_STR | |
13079 | "List large-community list\n" | |
13080 | "large-community-list number\n" | |
13081 | "large-community-list name\n") | |
13082 | { | |
d62a17ae | 13083 | struct community_list *list; |
57d187bc | 13084 | |
d62a17ae | 13085 | list = community_list_lookup(bgp_clist, argv[3]->arg, |
13086 | LARGE_COMMUNITY_LIST_MASTER); | |
13087 | if (!list) { | |
13088 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
13089 | return CMD_WARNING; | |
13090 | } | |
57d187bc | 13091 | |
d62a17ae | 13092 | lcommunity_list_show(vty, list); |
57d187bc | 13093 | |
d62a17ae | 13094 | return CMD_SUCCESS; |
57d187bc JS |
13095 | } |
13096 | ||
718e3744 | 13097 | /* "extcommunity-list" keyword help string. */ |
13098 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
13099 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
13100 | ||
13101 | DEFUN (ip_extcommunity_list_standard, | |
13102 | ip_extcommunity_list_standard_cmd, | |
e961923c | 13103 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 13104 | IP_STR |
13105 | EXTCOMMUNITY_LIST_STR | |
13106 | "Extended Community list number (standard)\n" | |
718e3744 | 13107 | "Specify standard extcommunity-list\n" |
5bf15956 | 13108 | "Community list name\n" |
718e3744 | 13109 | "Specify community to reject\n" |
13110 | "Specify community to accept\n" | |
13111 | EXTCOMMUNITY_VAL_STR) | |
13112 | { | |
d62a17ae | 13113 | int style = EXTCOMMUNITY_LIST_STANDARD; |
13114 | int direct = 0; | |
13115 | char *cl_number_or_name = NULL; | |
42f914d4 | 13116 | |
d62a17ae | 13117 | int idx = 0; |
13118 | argv_find(argv, argc, "(1-99)", &idx); | |
13119 | argv_find(argv, argc, "WORD", &idx); | |
13120 | cl_number_or_name = argv[idx]->arg; | |
13121 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13122 | : COMMUNITY_DENY; | |
13123 | argv_find(argv, argc, "AA:NN", &idx); | |
13124 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13125 | |
d62a17ae | 13126 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
13127 | direct, style); | |
42f914d4 | 13128 | |
d62a17ae | 13129 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13130 | |
d62a17ae | 13131 | if (ret < 0) { |
13132 | community_list_perror(vty, ret); | |
13133 | return CMD_WARNING_CONFIG_FAILED; | |
13134 | } | |
42f914d4 | 13135 | |
d62a17ae | 13136 | return CMD_SUCCESS; |
718e3744 | 13137 | } |
13138 | ||
718e3744 | 13139 | DEFUN (ip_extcommunity_list_name_expanded, |
13140 | ip_extcommunity_list_name_expanded_cmd, | |
e961923c | 13141 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 13142 | IP_STR |
13143 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 13144 | "Extended Community list number (expanded)\n" |
718e3744 | 13145 | "Specify expanded extcommunity-list\n" |
13146 | "Extended Community list name\n" | |
13147 | "Specify community to reject\n" | |
13148 | "Specify community to accept\n" | |
13149 | "An ordered list as a regular-expression\n") | |
13150 | { | |
d62a17ae | 13151 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
13152 | int direct = 0; | |
13153 | char *cl_number_or_name = NULL; | |
42f914d4 | 13154 | |
d62a17ae | 13155 | int idx = 0; |
13156 | argv_find(argv, argc, "(100-500)", &idx); | |
13157 | argv_find(argv, argc, "WORD", &idx); | |
13158 | cl_number_or_name = argv[idx]->arg; | |
13159 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13160 | : COMMUNITY_DENY; | |
13161 | argv_find(argv, argc, "LINE", &idx); | |
13162 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13163 | |
d62a17ae | 13164 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
13165 | direct, style); | |
42f914d4 | 13166 | |
d62a17ae | 13167 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13168 | |
d62a17ae | 13169 | if (ret < 0) { |
13170 | community_list_perror(vty, ret); | |
13171 | return CMD_WARNING_CONFIG_FAILED; | |
13172 | } | |
42f914d4 | 13173 | |
d62a17ae | 13174 | return CMD_SUCCESS; |
718e3744 | 13175 | } |
13176 | ||
fee6e4e4 | 13177 | DEFUN (no_ip_extcommunity_list_standard_all, |
13178 | no_ip_extcommunity_list_standard_all_cmd, | |
e961923c | 13179 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
813d4307 DW |
13180 | NO_STR |
13181 | IP_STR | |
13182 | EXTCOMMUNITY_LIST_STR | |
13183 | "Extended Community list number (standard)\n" | |
718e3744 | 13184 | "Specify standard extcommunity-list\n" |
5bf15956 | 13185 | "Community list name\n" |
718e3744 | 13186 | "Specify community to reject\n" |
13187 | "Specify community to accept\n" | |
13188 | EXTCOMMUNITY_VAL_STR) | |
13189 | { | |
d62a17ae | 13190 | int deleteall = 0; |
42f914d4 | 13191 | |
d62a17ae | 13192 | int style = EXTCOMMUNITY_LIST_STANDARD; |
13193 | int direct = 0; | |
13194 | char *cl_number_or_name = NULL; | |
42f914d4 | 13195 | |
d62a17ae | 13196 | int idx = 0; |
13197 | argv_find(argv, argc, "(1-99)", &idx); | |
13198 | argv_find(argv, argc, "WORD", &idx); | |
13199 | cl_number_or_name = argv[idx]->arg; | |
13200 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13201 | : COMMUNITY_DENY; | |
13202 | argv_find(argv, argc, "AA:NN", &idx); | |
13203 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13204 | |
d62a17ae | 13205 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
13206 | direct, style, deleteall); | |
42f914d4 | 13207 | |
d62a17ae | 13208 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13209 | |
d62a17ae | 13210 | if (ret < 0) { |
13211 | community_list_perror(vty, ret); | |
13212 | return CMD_WARNING_CONFIG_FAILED; | |
13213 | } | |
42f914d4 | 13214 | |
d62a17ae | 13215 | return CMD_SUCCESS; |
718e3744 | 13216 | } |
13217 | ||
5bf15956 DW |
13218 | DEFUN (no_ip_extcommunity_list_expanded_all, |
13219 | no_ip_extcommunity_list_expanded_all_cmd, | |
e961923c | 13220 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 13221 | NO_STR |
13222 | IP_STR | |
13223 | EXTCOMMUNITY_LIST_STR | |
13224 | "Extended Community list number (expanded)\n" | |
718e3744 | 13225 | "Specify expanded extcommunity-list\n" |
5bf15956 | 13226 | "Extended Community list name\n" |
718e3744 | 13227 | "Specify community to reject\n" |
13228 | "Specify community to accept\n" | |
13229 | "An ordered list as a regular-expression\n") | |
13230 | { | |
d62a17ae | 13231 | int deleteall = 0; |
42f914d4 | 13232 | |
d62a17ae | 13233 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
13234 | int direct = 0; | |
13235 | char *cl_number_or_name = NULL; | |
42f914d4 | 13236 | |
d62a17ae | 13237 | int idx = 0; |
13238 | argv_find(argv, argc, "(100-500)", &idx); | |
13239 | argv_find(argv, argc, "WORD", &idx); | |
13240 | cl_number_or_name = argv[idx]->arg; | |
13241 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13242 | : COMMUNITY_DENY; | |
13243 | argv_find(argv, argc, "LINE", &idx); | |
13244 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13245 | |
d62a17ae | 13246 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
13247 | direct, style, deleteall); | |
42f914d4 | 13248 | |
d62a17ae | 13249 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13250 | |
d62a17ae | 13251 | if (ret < 0) { |
13252 | community_list_perror(vty, ret); | |
13253 | return CMD_WARNING_CONFIG_FAILED; | |
13254 | } | |
42f914d4 | 13255 | |
d62a17ae | 13256 | return CMD_SUCCESS; |
718e3744 | 13257 | } |
13258 | ||
d62a17ae | 13259 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 13260 | { |
d62a17ae | 13261 | struct community_entry *entry; |
718e3744 | 13262 | |
d62a17ae | 13263 | for (entry = list->head; entry; entry = entry->next) { |
13264 | if (entry == list->head) { | |
13265 | if (all_digit(list->name)) | |
13266 | vty_out(vty, "Extended community %s list %s\n", | |
13267 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13268 | ? "standard" | |
13269 | : "(expanded) access", | |
13270 | list->name); | |
13271 | else | |
13272 | vty_out(vty, | |
13273 | "Named extended community %s list %s\n", | |
13274 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13275 | ? "standard" | |
13276 | : "expanded", | |
13277 | list->name); | |
13278 | } | |
13279 | if (entry->any) | |
13280 | vty_out(vty, " %s\n", | |
13281 | community_direct_str(entry->direct)); | |
13282 | else | |
13283 | vty_out(vty, " %s %s\n", | |
13284 | community_direct_str(entry->direct), | |
13285 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13286 | ? entry->u.ecom->str | |
13287 | : entry->config); | |
13288 | } | |
718e3744 | 13289 | } |
13290 | ||
13291 | DEFUN (show_ip_extcommunity_list, | |
13292 | show_ip_extcommunity_list_cmd, | |
13293 | "show ip extcommunity-list", | |
13294 | SHOW_STR | |
13295 | IP_STR | |
13296 | "List extended-community list\n") | |
13297 | { | |
d62a17ae | 13298 | struct community_list *list; |
13299 | struct community_list_master *cm; | |
718e3744 | 13300 | |
d62a17ae | 13301 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
13302 | if (!cm) | |
13303 | return CMD_SUCCESS; | |
718e3744 | 13304 | |
d62a17ae | 13305 | for (list = cm->num.head; list; list = list->next) |
13306 | extcommunity_list_show(vty, list); | |
718e3744 | 13307 | |
d62a17ae | 13308 | for (list = cm->str.head; list; list = list->next) |
13309 | extcommunity_list_show(vty, list); | |
718e3744 | 13310 | |
d62a17ae | 13311 | return CMD_SUCCESS; |
718e3744 | 13312 | } |
13313 | ||
13314 | DEFUN (show_ip_extcommunity_list_arg, | |
13315 | show_ip_extcommunity_list_arg_cmd, | |
6147e2c6 | 13316 | "show ip extcommunity-list <(1-500)|WORD>", |
718e3744 | 13317 | SHOW_STR |
13318 | IP_STR | |
13319 | "List extended-community list\n" | |
13320 | "Extcommunity-list number\n" | |
13321 | "Extcommunity-list name\n") | |
13322 | { | |
d62a17ae | 13323 | int idx_comm_list = 3; |
13324 | struct community_list *list; | |
718e3744 | 13325 | |
d62a17ae | 13326 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
13327 | EXTCOMMUNITY_LIST_MASTER); | |
13328 | if (!list) { | |
13329 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
13330 | return CMD_WARNING; | |
13331 | } | |
718e3744 | 13332 | |
d62a17ae | 13333 | extcommunity_list_show(vty, list); |
718e3744 | 13334 | |
d62a17ae | 13335 | return CMD_SUCCESS; |
718e3744 | 13336 | } |
6b0655a2 | 13337 | |
718e3744 | 13338 | /* Return configuration string of community-list entry. */ |
d62a17ae | 13339 | static const char *community_list_config_str(struct community_entry *entry) |
718e3744 | 13340 | { |
d62a17ae | 13341 | const char *str; |
718e3744 | 13342 | |
d62a17ae | 13343 | if (entry->any) |
13344 | str = ""; | |
13345 | else { | |
13346 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
a69ea8ae | 13347 | str = community_str(entry->u.com, false); |
d62a17ae | 13348 | else |
13349 | str = entry->config; | |
13350 | } | |
13351 | return str; | |
718e3744 | 13352 | } |
13353 | ||
13354 | /* Display community-list and extcommunity-list configuration. */ | |
d62a17ae | 13355 | static int community_list_config_write(struct vty *vty) |
13356 | { | |
13357 | struct community_list *list; | |
13358 | struct community_entry *entry; | |
13359 | struct community_list_master *cm; | |
13360 | int write = 0; | |
13361 | ||
13362 | /* Community-list. */ | |
13363 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
13364 | ||
13365 | for (list = cm->num.head; list; list = list->next) | |
13366 | for (entry = list->head; entry; entry = entry->next) { | |
13367 | vty_out(vty, "ip community-list %s %s %s\n", list->name, | |
13368 | community_direct_str(entry->direct), | |
13369 | community_list_config_str(entry)); | |
13370 | write++; | |
13371 | } | |
13372 | for (list = cm->str.head; list; list = list->next) | |
13373 | for (entry = list->head; entry; entry = entry->next) { | |
13374 | vty_out(vty, "ip community-list %s %s %s %s\n", | |
13375 | entry->style == COMMUNITY_LIST_STANDARD | |
13376 | ? "standard" | |
13377 | : "expanded", | |
13378 | list->name, community_direct_str(entry->direct), | |
13379 | community_list_config_str(entry)); | |
13380 | write++; | |
13381 | } | |
13382 | ||
13383 | /* Extcommunity-list. */ | |
13384 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
13385 | ||
13386 | for (list = cm->num.head; list; list = list->next) | |
13387 | for (entry = list->head; entry; entry = entry->next) { | |
13388 | vty_out(vty, "ip extcommunity-list %s %s %s\n", | |
13389 | list->name, community_direct_str(entry->direct), | |
13390 | community_list_config_str(entry)); | |
13391 | write++; | |
13392 | } | |
13393 | for (list = cm->str.head; list; list = list->next) | |
13394 | for (entry = list->head; entry; entry = entry->next) { | |
13395 | vty_out(vty, "ip extcommunity-list %s %s %s %s\n", | |
13396 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13397 | ? "standard" | |
13398 | : "expanded", | |
13399 | list->name, community_direct_str(entry->direct), | |
13400 | community_list_config_str(entry)); | |
13401 | write++; | |
13402 | } | |
13403 | ||
13404 | ||
13405 | /* lcommunity-list. */ | |
13406 | cm = community_list_master_lookup(bgp_clist, | |
13407 | LARGE_COMMUNITY_LIST_MASTER); | |
13408 | ||
13409 | for (list = cm->num.head; list; list = list->next) | |
13410 | for (entry = list->head; entry; entry = entry->next) { | |
13411 | vty_out(vty, "ip large-community-list %s %s %s\n", | |
13412 | list->name, community_direct_str(entry->direct), | |
13413 | community_list_config_str(entry)); | |
13414 | write++; | |
13415 | } | |
13416 | for (list = cm->str.head; list; list = list->next) | |
13417 | for (entry = list->head; entry; entry = entry->next) { | |
13418 | vty_out(vty, "ip large-community-list %s %s %s %s\n", | |
13419 | entry->style == LARGE_COMMUNITY_LIST_STANDARD | |
13420 | ? "standard" | |
13421 | : "expanded", | |
13422 | list->name, community_direct_str(entry->direct), | |
13423 | community_list_config_str(entry)); | |
13424 | write++; | |
13425 | } | |
13426 | ||
13427 | return write; | |
13428 | } | |
13429 | ||
13430 | static struct cmd_node community_list_node = { | |
13431 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 13432 | }; |
13433 | ||
d62a17ae | 13434 | static void community_list_vty(void) |
13435 | { | |
13436 | install_node(&community_list_node, community_list_config_write); | |
13437 | ||
13438 | /* Community-list. */ | |
13439 | install_element(CONFIG_NODE, &ip_community_list_standard_cmd); | |
13440 | install_element(CONFIG_NODE, &ip_community_list_expanded_all_cmd); | |
13441 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_cmd); | |
13442 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); | |
13443 | install_element(VIEW_NODE, &show_ip_community_list_cmd); | |
13444 | install_element(VIEW_NODE, &show_ip_community_list_arg_cmd); | |
13445 | ||
13446 | /* Extcommunity-list. */ | |
13447 | install_element(CONFIG_NODE, &ip_extcommunity_list_standard_cmd); | |
13448 | install_element(CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); | |
13449 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); | |
13450 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
13451 | install_element(VIEW_NODE, &show_ip_extcommunity_list_cmd); | |
13452 | install_element(VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
13453 | ||
13454 | /* Large Community List */ | |
13455 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard_cmd); | |
13456 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); | |
13457 | install_element(CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); | |
13458 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
13459 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); | |
13460 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); | |
13461 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
13462 | install_element(CONFIG_NODE, | |
13463 | &no_ip_lcommunity_list_name_expanded_all_cmd); | |
13464 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
13465 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
13466 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
13467 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
13468 | install_element(VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
13469 | install_element(VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 13470 | } |