]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP VTY interface. |
896014f4 DL |
2 | * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License along | |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
718e3744 | 20 | |
21 | #include <zebra.h> | |
22 | ||
23 | #include "command.h" | |
afec25d9 | 24 | #include "lib/json.h" |
718e3744 | 25 | #include "prefix.h" |
26 | #include "plist.h" | |
27 | #include "buffer.h" | |
28 | #include "linklist.h" | |
29 | #include "stream.h" | |
30 | #include "thread.h" | |
31 | #include "log.h" | |
3b8b1855 | 32 | #include "memory.h" |
fc7948fa | 33 | #include "memory_vty.h" |
4bf6a362 | 34 | #include "hash.h" |
3f9c7369 | 35 | #include "queue.h" |
039f3a34 | 36 | #include "filter.h" |
718e3744 | 37 | |
38 | #include "bgpd/bgpd.h" | |
4bf6a362 | 39 | #include "bgpd/bgp_advertise.h" |
718e3744 | 40 | #include "bgpd/bgp_attr.h" |
41 | #include "bgpd/bgp_aspath.h" | |
42 | #include "bgpd/bgp_community.h" | |
4bf6a362 | 43 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 44 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 45 | #include "bgpd/bgp_damp.h" |
718e3744 | 46 | #include "bgpd/bgp_debug.h" |
e0701b79 | 47 | #include "bgpd/bgp_fsm.h" |
4bf6a362 | 48 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 49 | #include "bgpd/bgp_open.h" |
4bf6a362 | 50 | #include "bgpd/bgp_regex.h" |
718e3744 | 51 | #include "bgpd/bgp_route.h" |
c016b6c7 | 52 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 53 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 54 | #include "bgpd/bgp_table.h" |
94f2b392 | 55 | #include "bgpd/bgp_vty.h" |
165b5fff | 56 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 57 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 58 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 59 | #include "bgpd/bgp_bfd.h" |
718e3744 | 60 | |
d62a17ae | 61 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
62 | struct prefix *range, int exact); | |
63 | ||
64 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) | |
65 | { | |
66 | switch (afi) { | |
67 | case AFI_IP: | |
68 | switch (safi) { | |
69 | case SAFI_UNICAST: | |
70 | return BGP_IPV4_NODE; | |
71 | break; | |
72 | case SAFI_MULTICAST: | |
73 | return BGP_IPV4M_NODE; | |
74 | break; | |
75 | case SAFI_LABELED_UNICAST: | |
76 | return BGP_IPV4L_NODE; | |
77 | break; | |
78 | case SAFI_MPLS_VPN: | |
79 | return BGP_VPNV4_NODE; | |
80 | break; | |
5c525538 RW |
81 | default: |
82 | /* not expected */ | |
83 | return BGP_IPV4_NODE; | |
84 | break; | |
d62a17ae | 85 | } |
86 | break; | |
87 | case AFI_IP6: | |
88 | switch (safi) { | |
89 | case SAFI_UNICAST: | |
90 | return BGP_IPV6_NODE; | |
91 | break; | |
92 | case SAFI_MULTICAST: | |
93 | return BGP_IPV6M_NODE; | |
94 | break; | |
95 | case SAFI_LABELED_UNICAST: | |
96 | return BGP_IPV6L_NODE; | |
97 | break; | |
98 | case SAFI_MPLS_VPN: | |
99 | return BGP_VPNV6_NODE; | |
100 | break; | |
5c525538 RW |
101 | default: |
102 | /* not expected */ | |
103 | return BGP_IPV4_NODE; | |
104 | break; | |
d62a17ae | 105 | } |
106 | break; | |
107 | case AFI_L2VPN: | |
108 | return BGP_EVPN_NODE; | |
109 | break; | |
110 | case AFI_MAX: | |
111 | // We should never be here but to clarify the switch statement.. | |
112 | return BGP_IPV4_NODE; | |
113 | break; | |
114 | } | |
115 | ||
116 | // Impossible to happen | |
117 | return BGP_IPV4_NODE; | |
f51bae9c | 118 | } |
20eb8864 | 119 | |
718e3744 | 120 | /* Utility function to get address family from current node. */ |
d62a17ae | 121 | afi_t bgp_node_afi(struct vty *vty) |
122 | { | |
123 | afi_t afi; | |
124 | switch (vty->node) { | |
125 | case BGP_IPV6_NODE: | |
126 | case BGP_IPV6M_NODE: | |
127 | case BGP_IPV6L_NODE: | |
128 | case BGP_VPNV6_NODE: | |
129 | afi = AFI_IP6; | |
130 | break; | |
131 | case BGP_EVPN_NODE: | |
132 | afi = AFI_L2VPN; | |
133 | break; | |
134 | default: | |
135 | afi = AFI_IP; | |
136 | break; | |
137 | } | |
138 | return afi; | |
718e3744 | 139 | } |
140 | ||
141 | /* Utility function to get subsequent address family from current | |
142 | node. */ | |
d62a17ae | 143 | safi_t bgp_node_safi(struct vty *vty) |
144 | { | |
145 | safi_t safi; | |
146 | switch (vty->node) { | |
147 | case BGP_VPNV4_NODE: | |
148 | case BGP_VPNV6_NODE: | |
149 | safi = SAFI_MPLS_VPN; | |
150 | break; | |
151 | case BGP_IPV4M_NODE: | |
152 | case BGP_IPV6M_NODE: | |
153 | safi = SAFI_MULTICAST; | |
154 | break; | |
155 | case BGP_EVPN_NODE: | |
156 | safi = SAFI_EVPN; | |
157 | break; | |
158 | case BGP_IPV4L_NODE: | |
159 | case BGP_IPV6L_NODE: | |
160 | safi = SAFI_LABELED_UNICAST; | |
161 | break; | |
162 | default: | |
163 | safi = SAFI_UNICAST; | |
164 | break; | |
165 | } | |
166 | return safi; | |
718e3744 | 167 | } |
168 | ||
55f91488 QY |
169 | /** |
170 | * Converts an AFI in string form to afi_t | |
171 | * | |
172 | * @param afi string, one of | |
173 | * - "ipv4" | |
174 | * - "ipv6" | |
175 | * @return the corresponding afi_t | |
176 | */ | |
d62a17ae | 177 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
178 | { | |
179 | afi_t afi = AFI_MAX; /* unknown */ | |
180 | if (strmatch(afi_str, "ipv4")) | |
181 | afi = AFI_IP; | |
182 | else if (strmatch(afi_str, "ipv6")) | |
183 | afi = AFI_IP6; | |
184 | return afi; | |
185 | } | |
186 | ||
187 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
188 | afi_t *afi) | |
189 | { | |
190 | int ret = 0; | |
191 | if (argv_find(argv, argc, "ipv4", index)) { | |
192 | ret = 1; | |
193 | if (afi) | |
194 | *afi = AFI_IP; | |
195 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
196 | ret = 1; | |
197 | if (afi) | |
198 | *afi = AFI_IP6; | |
199 | } | |
200 | return ret; | |
46f296b4 LB |
201 | } |
202 | ||
375a2e67 | 203 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 204 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
205 | { | |
206 | safi_t safi = SAFI_MAX; /* unknown */ | |
207 | if (strmatch(safi_str, "multicast")) | |
208 | safi = SAFI_MULTICAST; | |
209 | else if (strmatch(safi_str, "unicast")) | |
210 | safi = SAFI_UNICAST; | |
211 | else if (strmatch(safi_str, "vpn")) | |
212 | safi = SAFI_MPLS_VPN; | |
213 | else if (strmatch(safi_str, "labeled-unicast")) | |
214 | safi = SAFI_LABELED_UNICAST; | |
215 | return safi; | |
216 | } | |
217 | ||
218 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
219 | safi_t *safi) | |
220 | { | |
221 | int ret = 0; | |
222 | if (argv_find(argv, argc, "unicast", index)) { | |
223 | ret = 1; | |
224 | if (safi) | |
225 | *safi = SAFI_UNICAST; | |
226 | } else if (argv_find(argv, argc, "multicast", index)) { | |
227 | ret = 1; | |
228 | if (safi) | |
229 | *safi = SAFI_MULTICAST; | |
230 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
231 | ret = 1; | |
232 | if (safi) | |
233 | *safi = SAFI_LABELED_UNICAST; | |
234 | } else if (argv_find(argv, argc, "vpn", index)) { | |
235 | ret = 1; | |
236 | if (safi) | |
237 | *safi = SAFI_MPLS_VPN; | |
238 | } | |
239 | return ret; | |
46f296b4 LB |
240 | } |
241 | ||
7eeee51e | 242 | /* |
f212a857 | 243 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 244 | * |
f212a857 DS |
245 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
246 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
247 | * to appropriate values for the calling function. This is to allow the |
248 | * calling function to make decisions appropriate for the show command | |
249 | * that is being parsed. | |
250 | * | |
251 | * The show commands are generally of the form: | |
d62a17ae | 252 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
253 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
254 | * |
255 | * Since we use argv_find if the show command in particular doesn't have: | |
256 | * [ip] | |
18c57037 | 257 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 258 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
259 | * The command parsing should still be ok. |
260 | * | |
261 | * vty -> The vty for the command so we can output some useful data in | |
262 | * the event of a parse error in the vrf. | |
263 | * argv -> The command tokens | |
264 | * argc -> How many command tokens we have | |
d62a17ae | 265 | * idx -> The current place in the command, generally should be 0 for this |
266 | * function | |
7eeee51e DS |
267 | * afi -> The parsed afi if it was included in the show command, returned here |
268 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 269 | * bgp -> Pointer to the bgp data structure we need to fill in. |
7eeee51e DS |
270 | * |
271 | * The function returns the correct location in the parse tree for the | |
272 | * last token found. | |
0e37c258 DS |
273 | * |
274 | * Returns 0 for failure to parse correctly, else the idx position of where | |
275 | * it found the last token. | |
7eeee51e | 276 | */ |
d62a17ae | 277 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
278 | struct cmd_token **argv, int argc, | |
279 | int *idx, afi_t *afi, safi_t *safi, | |
280 | struct bgp **bgp) | |
281 | { | |
282 | char *vrf_name = NULL; | |
283 | ||
284 | assert(afi); | |
285 | assert(safi); | |
286 | assert(bgp); | |
287 | ||
288 | if (argv_find(argv, argc, "ip", idx)) | |
289 | *afi = AFI_IP; | |
290 | ||
291 | if (argv_find(argv, argc, "view", idx) | |
292 | || argv_find(argv, argc, "vrf", idx)) { | |
293 | vrf_name = argv[*idx + 1]->arg; | |
294 | ||
295 | if (strmatch(vrf_name, "all")) | |
296 | *bgp = NULL; | |
297 | else { | |
298 | *bgp = bgp_lookup_by_name(vrf_name); | |
299 | if (!*bgp) { | |
300 | vty_out(vty, | |
301 | "View/Vrf specified is unknown: %s\n", | |
302 | vrf_name); | |
303 | *idx = 0; | |
304 | return 0; | |
305 | } | |
306 | } | |
307 | } else { | |
308 | *bgp = bgp_get_default(); | |
309 | if (!*bgp) { | |
310 | vty_out(vty, "Unable to find default BGP instance\n"); | |
311 | *idx = 0; | |
312 | return 0; | |
313 | } | |
314 | } | |
315 | ||
316 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
317 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
318 | ||
319 | *idx += 1; | |
320 | return *idx; | |
321 | } | |
322 | ||
323 | static int peer_address_self_check(struct bgp *bgp, union sockunion *su) | |
324 | { | |
325 | struct interface *ifp = NULL; | |
326 | ||
327 | if (su->sa.sa_family == AF_INET) | |
328 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
329 | else if (su->sa.sa_family == AF_INET6) | |
330 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
331 | su->sin6.sin6_scope_id, | |
332 | bgp->vrf_id); | |
333 | ||
334 | if (ifp) | |
335 | return 1; | |
336 | ||
337 | return 0; | |
718e3744 | 338 | } |
339 | ||
340 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
341 | /* This is used only for configuration, so disallow if attempted on |
342 | * a dynamic neighbor. | |
343 | */ | |
d62a17ae | 344 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
345 | { | |
346 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
347 | int ret; | |
348 | union sockunion su; | |
349 | struct peer *peer; | |
350 | ||
351 | if (!bgp) { | |
352 | return NULL; | |
353 | } | |
354 | ||
355 | ret = str2sockunion(ip_str, &su); | |
356 | if (ret < 0) { | |
357 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
358 | if (!peer) { | |
359 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
360 | == NULL) { | |
361 | vty_out(vty, | |
362 | "%% Malformed address or name: %s\n", | |
363 | ip_str); | |
364 | return NULL; | |
365 | } | |
366 | } | |
367 | } else { | |
368 | peer = peer_lookup(bgp, &su); | |
369 | if (!peer) { | |
370 | vty_out(vty, | |
371 | "%% Specify remote-as or peer-group commands first\n"); | |
372 | return NULL; | |
373 | } | |
374 | if (peer_dynamic_neighbor(peer)) { | |
375 | vty_out(vty, | |
376 | "%% Operation not allowed on a dynamic neighbor\n"); | |
377 | return NULL; | |
378 | } | |
379 | } | |
380 | return peer; | |
718e3744 | 381 | } |
382 | ||
383 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
384 | /* This is used only for configuration, so disallow if attempted on |
385 | * a dynamic neighbor. | |
386 | */ | |
d62a17ae | 387 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
388 | { | |
389 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
390 | int ret; | |
391 | union sockunion su; | |
392 | struct peer *peer = NULL; | |
393 | struct peer_group *group = NULL; | |
394 | ||
395 | if (!bgp) { | |
396 | return NULL; | |
397 | } | |
398 | ||
399 | ret = str2sockunion(peer_str, &su); | |
400 | if (ret == 0) { | |
401 | /* IP address, locate peer. */ | |
402 | peer = peer_lookup(bgp, &su); | |
403 | } else { | |
404 | /* Not IP, could match either peer configured on interface or a | |
405 | * group. */ | |
406 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
407 | if (!peer) | |
408 | group = peer_group_lookup(bgp, peer_str); | |
409 | } | |
410 | ||
411 | if (peer) { | |
412 | if (peer_dynamic_neighbor(peer)) { | |
413 | vty_out(vty, | |
414 | "%% Operation not allowed on a dynamic neighbor\n"); | |
415 | return NULL; | |
416 | } | |
417 | ||
418 | return peer; | |
419 | } | |
420 | ||
421 | if (group) | |
422 | return group->conf; | |
423 | ||
424 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
425 | ||
426 | return NULL; | |
427 | } | |
428 | ||
429 | int bgp_vty_return(struct vty *vty, int ret) | |
430 | { | |
431 | const char *str = NULL; | |
432 | ||
433 | switch (ret) { | |
434 | case BGP_ERR_INVALID_VALUE: | |
435 | str = "Invalid value"; | |
436 | break; | |
437 | case BGP_ERR_INVALID_FLAG: | |
438 | str = "Invalid flag"; | |
439 | break; | |
440 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
441 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
442 | break; | |
443 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
444 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
445 | break; | |
446 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
447 | str = "Specify remote-as or peer-group remote AS first"; | |
448 | break; | |
449 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
450 | str = "Cannot change the peer-group. Deconfigure first"; | |
451 | break; | |
452 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
453 | str = "Peer is not a member of this peer-group"; | |
454 | break; | |
455 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
456 | str = "Prefix/distribute list can not co-exist"; | |
457 | break; | |
458 | case BGP_ERR_NOT_INTERNAL_PEER: | |
459 | str = "Invalid command. Not an internal neighbor"; | |
460 | break; | |
461 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
462 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
463 | break; | |
464 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
465 | str = "Local-AS allowed only for EBGP peers"; | |
466 | break; | |
467 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
468 | str = "Cannot have local-as same as BGP AS number"; | |
469 | break; | |
470 | case BGP_ERR_TCPSIG_FAILED: | |
471 | str = "Error while applying TCP-Sig to session(s)"; | |
472 | break; | |
473 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
474 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
475 | break; | |
476 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
477 | str = "ttl-security only allowed for EBGP peers"; | |
478 | break; | |
479 | case BGP_ERR_AS_OVERRIDE: | |
480 | str = "as-override cannot be configured for IBGP peers"; | |
481 | break; | |
482 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
483 | str = "Invalid limit for number of dynamic neighbors"; | |
484 | break; | |
485 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
486 | str = "Dynamic neighbor listen range already exists"; | |
487 | break; | |
488 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
489 | str = "Operation not allowed on a dynamic neighbor"; | |
490 | break; | |
491 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
492 | str = "Operation not allowed on a directly connected neighbor"; | |
493 | break; | |
494 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
495 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; | |
496 | break; | |
497 | } | |
498 | if (str) { | |
499 | vty_out(vty, "%% %s\n", str); | |
500 | return CMD_WARNING_CONFIG_FAILED; | |
501 | } | |
502 | return CMD_SUCCESS; | |
718e3744 | 503 | } |
504 | ||
7aafcaca | 505 | /* BGP clear sort. */ |
d62a17ae | 506 | enum clear_sort { |
507 | clear_all, | |
508 | clear_peer, | |
509 | clear_group, | |
510 | clear_external, | |
511 | clear_as | |
7aafcaca DS |
512 | }; |
513 | ||
d62a17ae | 514 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
515 | safi_t safi, int error) | |
516 | { | |
517 | switch (error) { | |
518 | case BGP_ERR_AF_UNCONFIGURED: | |
519 | vty_out(vty, | |
520 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
521 | afi_safi_print(afi, safi), peer->host); | |
522 | break; | |
523 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
524 | vty_out(vty, | |
525 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
526 | peer->host); | |
527 | break; | |
528 | default: | |
529 | break; | |
530 | } | |
7aafcaca DS |
531 | } |
532 | ||
533 | /* `clear ip bgp' functions. */ | |
d62a17ae | 534 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
535 | enum clear_sort sort, enum bgp_clear_type stype, | |
536 | const char *arg) | |
537 | { | |
538 | int ret; | |
539 | struct peer *peer; | |
540 | struct listnode *node, *nnode; | |
541 | ||
542 | /* Clear all neighbors. */ | |
543 | /* | |
544 | * Pass along pointer to next node to peer_clear() when walking all | |
545 | * nodes | |
546 | * on the BGP instance as that may get freed if it is a doppelganger | |
547 | */ | |
548 | if (sort == clear_all) { | |
549 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
550 | if (stype == BGP_CLEAR_SOFT_NONE) | |
551 | ret = peer_clear(peer, &nnode); | |
552 | else if (peer->afc[afi][safi]) | |
553 | ret = peer_clear_soft(peer, afi, safi, stype); | |
554 | else | |
555 | ret = 0; | |
556 | ||
557 | if (ret < 0) | |
558 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
04b6bdc0 | 559 | } |
d62a17ae | 560 | |
561 | /* This is to apply read-only mode on this clear. */ | |
562 | if (stype == BGP_CLEAR_SOFT_NONE) | |
563 | bgp->update_delay_over = 0; | |
564 | ||
565 | return CMD_SUCCESS; | |
7aafcaca DS |
566 | } |
567 | ||
d62a17ae | 568 | /* Clear specified neighbors. */ |
569 | if (sort == clear_peer) { | |
570 | union sockunion su; | |
571 | int ret; | |
572 | ||
573 | /* Make sockunion for lookup. */ | |
574 | ret = str2sockunion(arg, &su); | |
575 | if (ret < 0) { | |
576 | peer = peer_lookup_by_conf_if(bgp, arg); | |
577 | if (!peer) { | |
578 | peer = peer_lookup_by_hostname(bgp, arg); | |
579 | if (!peer) { | |
580 | vty_out(vty, | |
581 | "Malformed address or name: %s\n", | |
582 | arg); | |
583 | return CMD_WARNING; | |
584 | } | |
585 | } | |
586 | } else { | |
587 | peer = peer_lookup(bgp, &su); | |
588 | if (!peer) { | |
589 | vty_out(vty, | |
590 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
591 | arg); | |
592 | return CMD_WARNING; | |
593 | } | |
594 | } | |
7aafcaca | 595 | |
d62a17ae | 596 | if (stype == BGP_CLEAR_SOFT_NONE) |
597 | ret = peer_clear(peer, NULL); | |
598 | else | |
599 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 600 | |
d62a17ae | 601 | if (ret < 0) |
602 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 603 | |
d62a17ae | 604 | return CMD_SUCCESS; |
7aafcaca | 605 | } |
7aafcaca | 606 | |
d62a17ae | 607 | /* Clear all peer-group members. */ |
608 | if (sort == clear_group) { | |
609 | struct peer_group *group; | |
7aafcaca | 610 | |
d62a17ae | 611 | group = peer_group_lookup(bgp, arg); |
612 | if (!group) { | |
613 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
614 | return CMD_WARNING; | |
615 | } | |
616 | ||
617 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
618 | if (stype == BGP_CLEAR_SOFT_NONE) { | |
619 | peer_clear(peer, NULL); | |
620 | continue; | |
621 | } | |
622 | ||
623 | if (!peer->afc[afi][safi]) | |
624 | continue; | |
625 | ||
626 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 627 | |
d62a17ae | 628 | if (ret < 0) |
629 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
630 | } | |
631 | return CMD_SUCCESS; | |
7aafcaca | 632 | } |
7aafcaca | 633 | |
d62a17ae | 634 | if (sort == clear_external) { |
635 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
636 | if (peer->sort == BGP_PEER_IBGP) | |
637 | continue; | |
7aafcaca | 638 | |
d62a17ae | 639 | if (stype == BGP_CLEAR_SOFT_NONE) |
640 | ret = peer_clear(peer, &nnode); | |
641 | else | |
642 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 643 | |
d62a17ae | 644 | if (ret < 0) |
645 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
646 | } | |
647 | return CMD_SUCCESS; | |
648 | } | |
649 | ||
650 | if (sort == clear_as) { | |
651 | as_t as; | |
652 | int find = 0; | |
653 | ||
654 | as = strtoul(arg, NULL, 10); | |
655 | ||
656 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
657 | if (peer->as != as) | |
658 | continue; | |
659 | ||
660 | find = 1; | |
661 | if (stype == BGP_CLEAR_SOFT_NONE) | |
662 | ret = peer_clear(peer, &nnode); | |
663 | else | |
664 | ret = peer_clear_soft(peer, afi, safi, stype); | |
665 | ||
666 | if (ret < 0) | |
667 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
668 | } | |
669 | if (!find) | |
670 | vty_out(vty, | |
671 | "%%BGP: No peer is configured with AS %s\n", | |
672 | arg); | |
673 | return CMD_SUCCESS; | |
674 | } | |
675 | ||
676 | return CMD_SUCCESS; | |
677 | } | |
678 | ||
679 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
680 | safi_t safi, enum clear_sort sort, | |
681 | enum bgp_clear_type stype, const char *arg) | |
682 | { | |
683 | struct bgp *bgp; | |
684 | ||
685 | /* BGP structure lookup. */ | |
686 | if (name) { | |
687 | bgp = bgp_lookup_by_name(name); | |
688 | if (bgp == NULL) { | |
689 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
690 | return CMD_WARNING; | |
691 | } | |
692 | } else { | |
693 | bgp = bgp_get_default(); | |
694 | if (bgp == NULL) { | |
695 | vty_out(vty, "No BGP process is configured\n"); | |
696 | return CMD_WARNING; | |
697 | } | |
698 | } | |
699 | ||
700 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
701 | } |
702 | ||
703 | /* clear soft inbound */ | |
d62a17ae | 704 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 705 | { |
d62a17ae | 706 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
707 | BGP_CLEAR_SOFT_IN, NULL); | |
708 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
709 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
710 | } |
711 | ||
712 | /* clear soft outbound */ | |
d62a17ae | 713 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 714 | { |
d62a17ae | 715 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
716 | BGP_CLEAR_SOFT_OUT, NULL); | |
717 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
718 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
719 | } |
720 | ||
721 | ||
f787d7a0 DL |
722 | #ifndef VTYSH_EXTRACT_PL |
723 | #include "bgp_vty_clippy.c" | |
724 | #endif | |
725 | ||
718e3744 | 726 | /* BGP global configuration. */ |
727 | ||
728 | DEFUN (bgp_multiple_instance_func, | |
729 | bgp_multiple_instance_cmd, | |
730 | "bgp multiple-instance", | |
731 | BGP_STR | |
732 | "Enable bgp multiple instance\n") | |
733 | { | |
d62a17ae | 734 | bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE); |
735 | return CMD_SUCCESS; | |
718e3744 | 736 | } |
737 | ||
738 | DEFUN (no_bgp_multiple_instance, | |
739 | no_bgp_multiple_instance_cmd, | |
740 | "no bgp multiple-instance", | |
741 | NO_STR | |
742 | BGP_STR | |
743 | "BGP multiple instance\n") | |
744 | { | |
d62a17ae | 745 | int ret; |
718e3744 | 746 | |
d62a17ae | 747 | ret = bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE); |
748 | if (ret < 0) { | |
749 | vty_out(vty, "%% There are more than two BGP instances\n"); | |
750 | return CMD_WARNING_CONFIG_FAILED; | |
751 | } | |
752 | return CMD_SUCCESS; | |
718e3744 | 753 | } |
754 | ||
755 | DEFUN (bgp_config_type, | |
756 | bgp_config_type_cmd, | |
6147e2c6 | 757 | "bgp config-type <cisco|zebra>", |
718e3744 | 758 | BGP_STR |
759 | "Configuration type\n" | |
760 | "cisco\n" | |
761 | "zebra\n") | |
762 | { | |
d62a17ae | 763 | int idx = 0; |
764 | if (argv_find(argv, argc, "cisco", &idx)) | |
765 | bgp_option_set(BGP_OPT_CONFIG_CISCO); | |
766 | else | |
767 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); | |
718e3744 | 768 | |
d62a17ae | 769 | return CMD_SUCCESS; |
718e3744 | 770 | } |
771 | ||
772 | DEFUN (no_bgp_config_type, | |
773 | no_bgp_config_type_cmd, | |
c7178fe7 | 774 | "no bgp config-type [<cisco|zebra>]", |
718e3744 | 775 | NO_STR |
776 | BGP_STR | |
838758ac DW |
777 | "Display configuration type\n" |
778 | "cisco\n" | |
779 | "zebra\n") | |
718e3744 | 780 | { |
d62a17ae | 781 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
782 | return CMD_SUCCESS; | |
718e3744 | 783 | } |
784 | ||
813d4307 | 785 | |
718e3744 | 786 | DEFUN (no_synchronization, |
787 | no_synchronization_cmd, | |
788 | "no synchronization", | |
789 | NO_STR | |
790 | "Perform IGP synchronization\n") | |
791 | { | |
d62a17ae | 792 | return CMD_SUCCESS; |
718e3744 | 793 | } |
794 | ||
795 | DEFUN (no_auto_summary, | |
796 | no_auto_summary_cmd, | |
797 | "no auto-summary", | |
798 | NO_STR | |
799 | "Enable automatic network number summarization\n") | |
800 | { | |
d62a17ae | 801 | return CMD_SUCCESS; |
718e3744 | 802 | } |
3d515fd9 | 803 | |
718e3744 | 804 | /* "router bgp" commands. */ |
505e5056 | 805 | DEFUN_NOSH (router_bgp, |
f412b39a | 806 | router_bgp_cmd, |
18c57037 | 807 | "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 808 | ROUTER_STR |
809 | BGP_STR | |
31500417 DW |
810 | AS_STR |
811 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 812 | { |
d62a17ae | 813 | int idx_asn = 2; |
814 | int idx_view_vrf = 3; | |
815 | int idx_vrf = 4; | |
816 | int ret; | |
817 | as_t as; | |
818 | struct bgp *bgp; | |
819 | const char *name = NULL; | |
820 | enum bgp_instance_type inst_type; | |
821 | ||
822 | // "router bgp" without an ASN | |
823 | if (argc == 2) { | |
824 | // Pending: Make VRF option available for ASN less config | |
825 | bgp = bgp_get_default(); | |
826 | ||
827 | if (bgp == NULL) { | |
828 | vty_out(vty, "%% No BGP process is configured\n"); | |
829 | return CMD_WARNING_CONFIG_FAILED; | |
830 | } | |
831 | ||
832 | if (listcount(bm->bgp) > 1) { | |
833 | vty_out(vty, | |
834 | "%% Multiple BGP processes are configured\n"); | |
835 | return CMD_WARNING_CONFIG_FAILED; | |
836 | } | |
837 | } | |
838 | ||
839 | // "router bgp X" | |
840 | else { | |
841 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
842 | ||
843 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
844 | if (argc > 3) { | |
845 | name = argv[idx_vrf]->arg; | |
846 | ||
847 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) | |
848 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
849 | else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
850 | inst_type = BGP_INSTANCE_TYPE_VIEW; | |
851 | } | |
852 | ||
853 | ret = bgp_get(&bgp, &as, name, inst_type); | |
854 | switch (ret) { | |
855 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
856 | vty_out(vty, | |
857 | "Please specify 'bgp multiple-instance' first\n"); | |
858 | return CMD_WARNING_CONFIG_FAILED; | |
859 | case BGP_ERR_AS_MISMATCH: | |
860 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
861 | return CMD_WARNING_CONFIG_FAILED; | |
862 | case BGP_ERR_INSTANCE_MISMATCH: | |
863 | vty_out(vty, | |
864 | "BGP instance name and AS number mismatch\n"); | |
865 | vty_out(vty, | |
866 | "BGP instance is already running; AS is %u\n", | |
867 | as); | |
868 | return CMD_WARNING_CONFIG_FAILED; | |
869 | } | |
870 | ||
871 | /* Pending: handle when user tries to change a view to vrf n vv. | |
872 | */ | |
873 | } | |
874 | ||
875 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); | |
876 | ||
877 | return CMD_SUCCESS; | |
718e3744 | 878 | } |
879 | ||
718e3744 | 880 | /* "no router bgp" commands. */ |
881 | DEFUN (no_router_bgp, | |
882 | no_router_bgp_cmd, | |
18c57037 | 883 | "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 884 | NO_STR |
885 | ROUTER_STR | |
886 | BGP_STR | |
31500417 DW |
887 | AS_STR |
888 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 889 | { |
d62a17ae | 890 | int idx_asn = 3; |
891 | int idx_vrf = 5; | |
892 | as_t as; | |
893 | struct bgp *bgp; | |
894 | const char *name = NULL; | |
718e3744 | 895 | |
d62a17ae | 896 | // "no router bgp" without an ASN |
897 | if (argc == 3) { | |
898 | // Pending: Make VRF option available for ASN less config | |
899 | bgp = bgp_get_default(); | |
718e3744 | 900 | |
d62a17ae | 901 | if (bgp == NULL) { |
902 | vty_out(vty, "%% No BGP process is configured\n"); | |
903 | return CMD_WARNING_CONFIG_FAILED; | |
904 | } | |
7fb21a9f | 905 | |
d62a17ae | 906 | if (listcount(bm->bgp) > 1) { |
907 | vty_out(vty, | |
908 | "%% Multiple BGP processes are configured\n"); | |
909 | return CMD_WARNING_CONFIG_FAILED; | |
910 | } | |
911 | } else { | |
912 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 913 | |
d62a17ae | 914 | if (argc > 4) |
915 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 916 | |
d62a17ae | 917 | /* Lookup bgp structure. */ |
918 | bgp = bgp_lookup(as, name); | |
919 | if (!bgp) { | |
920 | vty_out(vty, "%% Can't find BGP instance\n"); | |
921 | return CMD_WARNING_CONFIG_FAILED; | |
922 | } | |
923 | } | |
718e3744 | 924 | |
d62a17ae | 925 | bgp_delete(bgp); |
718e3744 | 926 | |
d62a17ae | 927 | return CMD_SUCCESS; |
718e3744 | 928 | } |
929 | ||
6b0655a2 | 930 | |
718e3744 | 931 | /* BGP router-id. */ |
932 | ||
f787d7a0 | 933 | DEFPY (bgp_router_id, |
718e3744 | 934 | bgp_router_id_cmd, |
935 | "bgp router-id A.B.C.D", | |
936 | BGP_STR | |
937 | "Override configured router identifier\n" | |
938 | "Manually configured router identifier\n") | |
939 | { | |
d62a17ae | 940 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
941 | bgp_router_id_static_set(bgp, router_id); | |
942 | return CMD_SUCCESS; | |
718e3744 | 943 | } |
944 | ||
f787d7a0 | 945 | DEFPY (no_bgp_router_id, |
718e3744 | 946 | no_bgp_router_id_cmd, |
31500417 | 947 | "no bgp router-id [A.B.C.D]", |
718e3744 | 948 | NO_STR |
949 | BGP_STR | |
31500417 DW |
950 | "Override configured router identifier\n" |
951 | "Manually configured router identifier\n") | |
718e3744 | 952 | { |
d62a17ae | 953 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 954 | |
d62a17ae | 955 | if (router_id_str) { |
956 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
957 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
958 | return CMD_WARNING_CONFIG_FAILED; | |
959 | } | |
e018c7cc | 960 | } |
718e3744 | 961 | |
d62a17ae | 962 | router_id.s_addr = 0; |
963 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 964 | |
d62a17ae | 965 | return CMD_SUCCESS; |
718e3744 | 966 | } |
967 | ||
6b0655a2 | 968 | |
718e3744 | 969 | /* BGP Cluster ID. */ |
718e3744 | 970 | DEFUN (bgp_cluster_id, |
971 | bgp_cluster_id_cmd, | |
838758ac | 972 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 973 | BGP_STR |
974 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
975 | "Route-Reflector Cluster-id in IP address format\n" |
976 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 977 | { |
d62a17ae | 978 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
979 | int idx_ipv4 = 2; | |
980 | int ret; | |
981 | struct in_addr cluster; | |
718e3744 | 982 | |
d62a17ae | 983 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
984 | if (!ret) { | |
985 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
986 | return CMD_WARNING_CONFIG_FAILED; | |
987 | } | |
718e3744 | 988 | |
d62a17ae | 989 | bgp_cluster_id_set(bgp, &cluster); |
990 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 991 | |
d62a17ae | 992 | return CMD_SUCCESS; |
718e3744 | 993 | } |
994 | ||
718e3744 | 995 | DEFUN (no_bgp_cluster_id, |
996 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 997 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 998 | NO_STR |
999 | BGP_STR | |
838758ac DW |
1000 | "Configure Route-Reflector Cluster-id\n" |
1001 | "Route-Reflector Cluster-id in IP address format\n" | |
1002 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1003 | { |
d62a17ae | 1004 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1005 | bgp_cluster_id_unset(bgp); | |
1006 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1007 | |
d62a17ae | 1008 | return CMD_SUCCESS; |
718e3744 | 1009 | } |
1010 | ||
718e3744 | 1011 | DEFUN (bgp_confederation_identifier, |
1012 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1013 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1014 | "BGP specific commands\n" |
1015 | "AS confederation parameters\n" | |
1016 | "AS number\n" | |
1017 | "Set routing domain confederation AS\n") | |
1018 | { | |
d62a17ae | 1019 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1020 | int idx_number = 3; | |
1021 | as_t as; | |
718e3744 | 1022 | |
d62a17ae | 1023 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1024 | |
d62a17ae | 1025 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1026 | |
d62a17ae | 1027 | return CMD_SUCCESS; |
718e3744 | 1028 | } |
1029 | ||
1030 | DEFUN (no_bgp_confederation_identifier, | |
1031 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1032 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1033 | NO_STR |
1034 | "BGP specific commands\n" | |
1035 | "AS confederation parameters\n" | |
3a2d747c QY |
1036 | "AS number\n" |
1037 | "Set routing domain confederation AS\n") | |
718e3744 | 1038 | { |
d62a17ae | 1039 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1040 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1041 | |
d62a17ae | 1042 | return CMD_SUCCESS; |
718e3744 | 1043 | } |
1044 | ||
718e3744 | 1045 | DEFUN (bgp_confederation_peers, |
1046 | bgp_confederation_peers_cmd, | |
12dcf78e | 1047 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1048 | "BGP specific commands\n" |
1049 | "AS confederation parameters\n" | |
1050 | "Peer ASs in BGP confederation\n" | |
1051 | AS_STR) | |
1052 | { | |
d62a17ae | 1053 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1054 | int idx_asn = 3; | |
1055 | as_t as; | |
1056 | int i; | |
718e3744 | 1057 | |
d62a17ae | 1058 | for (i = idx_asn; i < argc; i++) { |
1059 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1060 | |
d62a17ae | 1061 | if (bgp->as == as) { |
1062 | vty_out(vty, | |
1063 | "%% Local member-AS not allowed in confed peer list\n"); | |
1064 | continue; | |
1065 | } | |
718e3744 | 1066 | |
d62a17ae | 1067 | bgp_confederation_peers_add(bgp, as); |
1068 | } | |
1069 | return CMD_SUCCESS; | |
718e3744 | 1070 | } |
1071 | ||
1072 | DEFUN (no_bgp_confederation_peers, | |
1073 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1074 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1075 | NO_STR |
1076 | "BGP specific commands\n" | |
1077 | "AS confederation parameters\n" | |
1078 | "Peer ASs in BGP confederation\n" | |
1079 | AS_STR) | |
1080 | { | |
d62a17ae | 1081 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1082 | int idx_asn = 4; | |
1083 | as_t as; | |
1084 | int i; | |
718e3744 | 1085 | |
d62a17ae | 1086 | for (i = idx_asn; i < argc; i++) { |
1087 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1088 | |
d62a17ae | 1089 | bgp_confederation_peers_remove(bgp, as); |
1090 | } | |
1091 | return CMD_SUCCESS; | |
718e3744 | 1092 | } |
6b0655a2 | 1093 | |
5e242b0d DS |
1094 | /** |
1095 | * Central routine for maximum-paths configuration. | |
1096 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1097 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1098 | */ | |
d62a17ae | 1099 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
1100 | const char *mpaths, u_int16_t options, | |
1101 | int set) | |
1102 | { | |
1103 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1104 | u_int16_t maxpaths = 0; | |
1105 | int ret; | |
1106 | afi_t afi; | |
1107 | safi_t safi; | |
1108 | ||
1109 | afi = bgp_node_afi(vty); | |
1110 | safi = bgp_node_safi(vty); | |
1111 | ||
1112 | if (set) { | |
1113 | maxpaths = strtol(mpaths, NULL, 10); | |
1114 | if (maxpaths > multipath_num) { | |
1115 | vty_out(vty, | |
1116 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1117 | maxpaths, multipath_num); | |
1118 | return CMD_WARNING_CONFIG_FAILED; | |
1119 | } | |
1120 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1121 | options); | |
1122 | } else | |
1123 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1124 | ||
1125 | if (ret < 0) { | |
1126 | vty_out(vty, | |
1127 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1128 | (set == 1) ? "" : "un", | |
1129 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1130 | maxpaths, afi, safi); | |
1131 | return CMD_WARNING_CONFIG_FAILED; | |
1132 | } | |
1133 | ||
1134 | bgp_recalculate_all_bestpaths(bgp); | |
1135 | ||
1136 | return CMD_SUCCESS; | |
165b5fff JB |
1137 | } |
1138 | ||
abc920f8 DS |
1139 | DEFUN (bgp_maxmed_admin, |
1140 | bgp_maxmed_admin_cmd, | |
1141 | "bgp max-med administrative ", | |
1142 | BGP_STR | |
1143 | "Advertise routes with max-med\n" | |
1144 | "Administratively applied, for an indefinite period\n") | |
1145 | { | |
d62a17ae | 1146 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1147 | |
d62a17ae | 1148 | bgp->v_maxmed_admin = 1; |
1149 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1150 | |
d62a17ae | 1151 | bgp_maxmed_update(bgp); |
abc920f8 | 1152 | |
d62a17ae | 1153 | return CMD_SUCCESS; |
abc920f8 DS |
1154 | } |
1155 | ||
1156 | DEFUN (bgp_maxmed_admin_medv, | |
1157 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1158 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1159 | BGP_STR |
1160 | "Advertise routes with max-med\n" | |
1161 | "Administratively applied, for an indefinite period\n" | |
1162 | "Max MED value to be used\n") | |
1163 | { | |
d62a17ae | 1164 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1165 | int idx_number = 3; | |
abc920f8 | 1166 | |
d62a17ae | 1167 | bgp->v_maxmed_admin = 1; |
1168 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1169 | |
d62a17ae | 1170 | bgp_maxmed_update(bgp); |
abc920f8 | 1171 | |
d62a17ae | 1172 | return CMD_SUCCESS; |
abc920f8 DS |
1173 | } |
1174 | ||
1175 | DEFUN (no_bgp_maxmed_admin, | |
1176 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1177 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1178 | NO_STR |
1179 | BGP_STR | |
1180 | "Advertise routes with max-med\n" | |
838758ac DW |
1181 | "Administratively applied, for an indefinite period\n" |
1182 | "Max MED value to be used\n") | |
abc920f8 | 1183 | { |
d62a17ae | 1184 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1185 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1186 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1187 | bgp_maxmed_update(bgp); | |
abc920f8 | 1188 | |
d62a17ae | 1189 | return CMD_SUCCESS; |
abc920f8 DS |
1190 | } |
1191 | ||
abc920f8 DS |
1192 | DEFUN (bgp_maxmed_onstartup, |
1193 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1194 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1195 | BGP_STR |
1196 | "Advertise routes with max-med\n" | |
1197 | "Effective on a startup\n" | |
1198 | "Time (seconds) period for max-med\n" | |
1199 | "Max MED value to be used\n") | |
1200 | { | |
d62a17ae | 1201 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1202 | int idx = 0; | |
4668a151 | 1203 | |
d62a17ae | 1204 | argv_find(argv, argc, "(5-86400)", &idx); |
1205 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1206 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1207 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1208 | else | |
1209 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1210 | |
d62a17ae | 1211 | bgp_maxmed_update(bgp); |
abc920f8 | 1212 | |
d62a17ae | 1213 | return CMD_SUCCESS; |
abc920f8 DS |
1214 | } |
1215 | ||
1216 | DEFUN (no_bgp_maxmed_onstartup, | |
1217 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1218 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1219 | NO_STR |
1220 | BGP_STR | |
1221 | "Advertise routes with max-med\n" | |
838758ac DW |
1222 | "Effective on a startup\n" |
1223 | "Time (seconds) period for max-med\n" | |
1224 | "Max MED value to be used\n") | |
abc920f8 | 1225 | { |
d62a17ae | 1226 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1227 | |
d62a17ae | 1228 | /* Cancel max-med onstartup if its on */ |
1229 | if (bgp->t_maxmed_onstartup) { | |
1230 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1231 | bgp->maxmed_onstartup_over = 1; | |
1232 | } | |
abc920f8 | 1233 | |
d62a17ae | 1234 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1235 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1236 | |
d62a17ae | 1237 | bgp_maxmed_update(bgp); |
abc920f8 | 1238 | |
d62a17ae | 1239 | return CMD_SUCCESS; |
abc920f8 DS |
1240 | } |
1241 | ||
d62a17ae | 1242 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1243 | const char *wait) | |
f188f2c4 | 1244 | { |
d62a17ae | 1245 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1246 | u_int16_t update_delay; | |
1247 | u_int16_t establish_wait; | |
f188f2c4 | 1248 | |
d62a17ae | 1249 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1250 | |
d62a17ae | 1251 | if (!wait) /* update-delay <delay> */ |
1252 | { | |
1253 | bgp->v_update_delay = update_delay; | |
1254 | bgp->v_establish_wait = bgp->v_update_delay; | |
1255 | return CMD_SUCCESS; | |
1256 | } | |
f188f2c4 | 1257 | |
d62a17ae | 1258 | /* update-delay <delay> <establish-wait> */ |
1259 | establish_wait = atoi(wait); | |
1260 | if (update_delay < establish_wait) { | |
1261 | vty_out(vty, | |
1262 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1263 | return CMD_WARNING_CONFIG_FAILED; | |
1264 | } | |
f188f2c4 | 1265 | |
d62a17ae | 1266 | bgp->v_update_delay = update_delay; |
1267 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1268 | |
d62a17ae | 1269 | return CMD_SUCCESS; |
f188f2c4 DS |
1270 | } |
1271 | ||
d62a17ae | 1272 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1273 | { |
d62a17ae | 1274 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1275 | |
d62a17ae | 1276 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1277 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1278 | |
d62a17ae | 1279 | return CMD_SUCCESS; |
f188f2c4 DS |
1280 | } |
1281 | ||
d62a17ae | 1282 | int bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1283 | { |
d62a17ae | 1284 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1285 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1286 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1287 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1288 | vty_out(vty, "\n"); | |
1289 | } | |
f188f2c4 | 1290 | |
d62a17ae | 1291 | return 0; |
f188f2c4 DS |
1292 | } |
1293 | ||
1294 | ||
1295 | /* Update-delay configuration */ | |
1296 | DEFUN (bgp_update_delay, | |
1297 | bgp_update_delay_cmd, | |
6147e2c6 | 1298 | "update-delay (0-3600)", |
f188f2c4 DS |
1299 | "Force initial delay for best-path and updates\n" |
1300 | "Seconds\n") | |
1301 | { | |
d62a17ae | 1302 | int idx_number = 1; |
1303 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1304 | } |
1305 | ||
1306 | DEFUN (bgp_update_delay_establish_wait, | |
1307 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1308 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1309 | "Force initial delay for best-path and updates\n" |
1310 | "Seconds\n" | |
f188f2c4 DS |
1311 | "Seconds\n") |
1312 | { | |
d62a17ae | 1313 | int idx_number = 1; |
1314 | int idx_number_2 = 2; | |
1315 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1316 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1317 | } |
1318 | ||
1319 | /* Update-delay deconfiguration */ | |
1320 | DEFUN (no_bgp_update_delay, | |
1321 | no_bgp_update_delay_cmd, | |
838758ac DW |
1322 | "no update-delay [(0-3600) [(1-3600)]]", |
1323 | NO_STR | |
f188f2c4 | 1324 | "Force initial delay for best-path and updates\n" |
838758ac | 1325 | "Seconds\n" |
7111c1a0 | 1326 | "Seconds\n") |
f188f2c4 | 1327 | { |
d62a17ae | 1328 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1329 | } |
1330 | ||
5e242b0d | 1331 | |
d62a17ae | 1332 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, const char *num, |
1333 | char set) | |
cb1faec9 | 1334 | { |
d62a17ae | 1335 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1336 | |
d62a17ae | 1337 | if (set) |
1338 | bgp->wpkt_quanta = strtoul(num, NULL, 10); | |
1339 | else | |
1340 | bgp->wpkt_quanta = BGP_WRITE_PACKET_MAX; | |
cb1faec9 | 1341 | |
d62a17ae | 1342 | return CMD_SUCCESS; |
cb1faec9 DS |
1343 | } |
1344 | ||
d62a17ae | 1345 | int bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1346 | { |
d62a17ae | 1347 | if (bgp->wpkt_quanta != BGP_WRITE_PACKET_MAX) |
1348 | vty_out(vty, " write-quanta %d\n", bgp->wpkt_quanta); | |
cb1faec9 | 1349 | |
d62a17ae | 1350 | return 0; |
cb1faec9 DS |
1351 | } |
1352 | ||
1353 | ||
1354 | /* Update-delay configuration */ | |
1355 | DEFUN (bgp_wpkt_quanta, | |
1356 | bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1357 | "write-quanta (1-10000)", |
cb1faec9 DS |
1358 | "How many packets to write to peer socket per run\n" |
1359 | "Number of packets\n") | |
1360 | { | |
d62a17ae | 1361 | int idx_number = 1; |
1362 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1363 | } |
1364 | ||
1365 | /* Update-delay deconfiguration */ | |
1366 | DEFUN (no_bgp_wpkt_quanta, | |
1367 | no_bgp_wpkt_quanta_cmd, | |
6147e2c6 | 1368 | "no write-quanta (1-10000)", |
d7fa34c1 | 1369 | NO_STR |
cb1faec9 DS |
1370 | "How many packets to write to peer socket per run\n" |
1371 | "Number of packets\n") | |
1372 | { | |
d62a17ae | 1373 | int idx_number = 2; |
1374 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1375 | } |
1376 | ||
d62a17ae | 1377 | int bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1378 | { |
d62a17ae | 1379 | if (bgp->coalesce_time != BGP_DEFAULT_SUBGROUP_COALESCE_TIME) |
1380 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); | |
3f9c7369 | 1381 | |
d62a17ae | 1382 | return 0; |
3f9c7369 DS |
1383 | } |
1384 | ||
1385 | ||
1386 | DEFUN (bgp_coalesce_time, | |
1387 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1388 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1389 | "Subgroup coalesce timer\n" |
1390 | "Subgroup coalesce timer value (in ms)\n") | |
1391 | { | |
d62a17ae | 1392 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1393 | |
d62a17ae | 1394 | int idx = 0; |
1395 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
1396 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); | |
1397 | return CMD_SUCCESS; | |
3f9c7369 DS |
1398 | } |
1399 | ||
1400 | DEFUN (no_bgp_coalesce_time, | |
1401 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1402 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1403 | NO_STR |
3f9c7369 DS |
1404 | "Subgroup coalesce timer\n" |
1405 | "Subgroup coalesce timer value (in ms)\n") | |
1406 | { | |
d62a17ae | 1407 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1408 | |
d62a17ae | 1409 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1410 | return CMD_SUCCESS; | |
3f9c7369 DS |
1411 | } |
1412 | ||
5e242b0d DS |
1413 | /* Maximum-paths configuration */ |
1414 | DEFUN (bgp_maxpaths, | |
1415 | bgp_maxpaths_cmd, | |
6319fd63 | 1416 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1417 | "Forward packets over multiple paths\n" |
1418 | "Number of paths\n") | |
1419 | { | |
d62a17ae | 1420 | int idx_number = 1; |
1421 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1422 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1423 | } |
1424 | ||
d62a17ae | 1425 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1426 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1427 | "Forward packets over multiple paths\n" | |
1428 | "Number of paths\n") | |
596c17ba | 1429 | |
165b5fff JB |
1430 | DEFUN (bgp_maxpaths_ibgp, |
1431 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1432 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1433 | "Forward packets over multiple paths\n" |
1434 | "iBGP-multipath\n" | |
1435 | "Number of paths\n") | |
1436 | { | |
d62a17ae | 1437 | int idx_number = 2; |
1438 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1439 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1440 | } |
165b5fff | 1441 | |
d62a17ae | 1442 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1443 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1444 | "Forward packets over multiple paths\n" | |
1445 | "iBGP-multipath\n" | |
1446 | "Number of paths\n") | |
596c17ba | 1447 | |
5e242b0d DS |
1448 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1449 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1450 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1451 | "Forward packets over multiple paths\n" |
1452 | "iBGP-multipath\n" | |
1453 | "Number of paths\n" | |
1454 | "Match the cluster length\n") | |
1455 | { | |
d62a17ae | 1456 | int idx_number = 2; |
1457 | return bgp_maxpaths_config_vty( | |
1458 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1459 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1460 | } |
1461 | ||
d62a17ae | 1462 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1463 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1464 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1465 | "Forward packets over multiple paths\n" | |
1466 | "iBGP-multipath\n" | |
1467 | "Number of paths\n" | |
1468 | "Match the cluster length\n") | |
596c17ba | 1469 | |
165b5fff JB |
1470 | DEFUN (no_bgp_maxpaths, |
1471 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1472 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1473 | NO_STR |
1474 | "Forward packets over multiple paths\n" | |
1475 | "Number of paths\n") | |
1476 | { | |
d62a17ae | 1477 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1478 | } |
1479 | ||
d62a17ae | 1480 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
9d303b37 | 1481 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1482 | "Forward packets over multiple paths\n" |
1483 | "Number of paths\n") | |
596c17ba | 1484 | |
165b5fff JB |
1485 | DEFUN (no_bgp_maxpaths_ibgp, |
1486 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1487 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1488 | NO_STR |
1489 | "Forward packets over multiple paths\n" | |
1490 | "iBGP-multipath\n" | |
838758ac DW |
1491 | "Number of paths\n" |
1492 | "Match the cluster length\n") | |
165b5fff | 1493 | { |
d62a17ae | 1494 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1495 | } |
1496 | ||
d62a17ae | 1497 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1498 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1499 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1500 | NO_STR | |
1501 | "Forward packets over multiple paths\n" | |
1502 | "iBGP-multipath\n" | |
1503 | "Number of paths\n" | |
1504 | "Match the cluster length\n") | |
596c17ba | 1505 | |
d62a17ae | 1506 | int bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi, |
1507 | safi_t safi, int *write) | |
165b5fff | 1508 | { |
d62a17ae | 1509 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
1510 | bgp_config_write_family_header(vty, afi, safi, write); | |
1511 | vty_out(vty, " maximum-paths %d\n", | |
1512 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1513 | } | |
165b5fff | 1514 | |
d62a17ae | 1515 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
1516 | bgp_config_write_family_header(vty, afi, safi, write); | |
1517 | vty_out(vty, " maximum-paths ibgp %d", | |
1518 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1519 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1520 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1521 | vty_out(vty, " equal-cluster-length"); | |
1522 | vty_out(vty, "\n"); | |
1523 | } | |
165b5fff | 1524 | |
d62a17ae | 1525 | return 0; |
165b5fff | 1526 | } |
6b0655a2 | 1527 | |
718e3744 | 1528 | /* BGP timers. */ |
1529 | ||
1530 | DEFUN (bgp_timers, | |
1531 | bgp_timers_cmd, | |
6147e2c6 | 1532 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1533 | "Adjust routing timers\n" |
1534 | "BGP timers\n" | |
1535 | "Keepalive interval\n" | |
1536 | "Holdtime\n") | |
1537 | { | |
d62a17ae | 1538 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1539 | int idx_number = 2; | |
1540 | int idx_number_2 = 3; | |
1541 | unsigned long keepalive = 0; | |
1542 | unsigned long holdtime = 0; | |
718e3744 | 1543 | |
d62a17ae | 1544 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1545 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1546 | |
d62a17ae | 1547 | /* Holdtime value check. */ |
1548 | if (holdtime < 3 && holdtime != 0) { | |
1549 | vty_out(vty, | |
1550 | "%% hold time value must be either 0 or greater than 3\n"); | |
1551 | return CMD_WARNING_CONFIG_FAILED; | |
1552 | } | |
718e3744 | 1553 | |
d62a17ae | 1554 | bgp_timers_set(bgp, keepalive, holdtime); |
718e3744 | 1555 | |
d62a17ae | 1556 | return CMD_SUCCESS; |
718e3744 | 1557 | } |
1558 | ||
1559 | DEFUN (no_bgp_timers, | |
1560 | no_bgp_timers_cmd, | |
838758ac | 1561 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1562 | NO_STR |
1563 | "Adjust routing timers\n" | |
838758ac DW |
1564 | "BGP timers\n" |
1565 | "Keepalive interval\n" | |
1566 | "Holdtime\n") | |
718e3744 | 1567 | { |
d62a17ae | 1568 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1569 | bgp_timers_unset(bgp); | |
718e3744 | 1570 | |
d62a17ae | 1571 | return CMD_SUCCESS; |
718e3744 | 1572 | } |
1573 | ||
6b0655a2 | 1574 | |
718e3744 | 1575 | DEFUN (bgp_client_to_client_reflection, |
1576 | bgp_client_to_client_reflection_cmd, | |
1577 | "bgp client-to-client reflection", | |
1578 | "BGP specific commands\n" | |
1579 | "Configure client to client route reflection\n" | |
1580 | "reflection of routes allowed\n") | |
1581 | { | |
d62a17ae | 1582 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1583 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1584 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1585 | |
d62a17ae | 1586 | return CMD_SUCCESS; |
718e3744 | 1587 | } |
1588 | ||
1589 | DEFUN (no_bgp_client_to_client_reflection, | |
1590 | no_bgp_client_to_client_reflection_cmd, | |
1591 | "no bgp client-to-client reflection", | |
1592 | NO_STR | |
1593 | "BGP specific commands\n" | |
1594 | "Configure client to client route reflection\n" | |
1595 | "reflection of routes allowed\n") | |
1596 | { | |
d62a17ae | 1597 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1598 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1599 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1600 | |
d62a17ae | 1601 | return CMD_SUCCESS; |
718e3744 | 1602 | } |
1603 | ||
1604 | /* "bgp always-compare-med" configuration. */ | |
1605 | DEFUN (bgp_always_compare_med, | |
1606 | bgp_always_compare_med_cmd, | |
1607 | "bgp always-compare-med", | |
1608 | "BGP specific commands\n" | |
1609 | "Allow comparing MED from different neighbors\n") | |
1610 | { | |
d62a17ae | 1611 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1612 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1613 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1614 | |
d62a17ae | 1615 | return CMD_SUCCESS; |
718e3744 | 1616 | } |
1617 | ||
1618 | DEFUN (no_bgp_always_compare_med, | |
1619 | no_bgp_always_compare_med_cmd, | |
1620 | "no bgp always-compare-med", | |
1621 | NO_STR | |
1622 | "BGP specific commands\n" | |
1623 | "Allow comparing MED from different neighbors\n") | |
1624 | { | |
d62a17ae | 1625 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1626 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1627 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1628 | |
d62a17ae | 1629 | return CMD_SUCCESS; |
718e3744 | 1630 | } |
6b0655a2 | 1631 | |
718e3744 | 1632 | /* "bgp deterministic-med" configuration. */ |
1633 | DEFUN (bgp_deterministic_med, | |
1634 | bgp_deterministic_med_cmd, | |
1635 | "bgp deterministic-med", | |
1636 | "BGP specific commands\n" | |
1637 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1638 | { | |
d62a17ae | 1639 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 1640 | |
d62a17ae | 1641 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
1642 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1643 | bgp_recalculate_all_bestpaths(bgp); | |
1644 | } | |
7aafcaca | 1645 | |
d62a17ae | 1646 | return CMD_SUCCESS; |
718e3744 | 1647 | } |
1648 | ||
1649 | DEFUN (no_bgp_deterministic_med, | |
1650 | no_bgp_deterministic_med_cmd, | |
1651 | "no bgp deterministic-med", | |
1652 | NO_STR | |
1653 | "BGP specific commands\n" | |
1654 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1655 | { | |
d62a17ae | 1656 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1657 | int bestpath_per_as_used; | |
1658 | afi_t afi; | |
1659 | safi_t safi; | |
1660 | struct peer *peer; | |
1661 | struct listnode *node, *nnode; | |
1662 | ||
1663 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
1664 | bestpath_per_as_used = 0; | |
1665 | ||
1666 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
1667 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
1668 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; | |
1669 | safi++) | |
1670 | if (CHECK_FLAG( | |
1671 | peer->af_flags[afi][safi], | |
1672 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) { | |
1673 | bestpath_per_as_used = 1; | |
1674 | break; | |
1675 | } | |
1676 | ||
1677 | if (bestpath_per_as_used) | |
1678 | break; | |
1679 | } | |
1680 | ||
1681 | if (bestpath_per_as_used) { | |
1682 | vty_out(vty, | |
1683 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
1684 | return CMD_WARNING_CONFIG_FAILED; | |
1685 | } else { | |
1686 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1687 | bgp_recalculate_all_bestpaths(bgp); | |
1688 | } | |
1689 | } | |
1690 | ||
1691 | return CMD_SUCCESS; | |
718e3744 | 1692 | } |
538621f2 | 1693 | |
1694 | /* "bgp graceful-restart" configuration. */ | |
1695 | DEFUN (bgp_graceful_restart, | |
1696 | bgp_graceful_restart_cmd, | |
1697 | "bgp graceful-restart", | |
1698 | "BGP specific commands\n" | |
1699 | "Graceful restart capability parameters\n") | |
1700 | { | |
d62a17ae | 1701 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1702 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1703 | return CMD_SUCCESS; | |
538621f2 | 1704 | } |
1705 | ||
1706 | DEFUN (no_bgp_graceful_restart, | |
1707 | no_bgp_graceful_restart_cmd, | |
1708 | "no bgp graceful-restart", | |
1709 | NO_STR | |
1710 | "BGP specific commands\n" | |
1711 | "Graceful restart capability parameters\n") | |
1712 | { | |
d62a17ae | 1713 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1714 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1715 | return CMD_SUCCESS; | |
538621f2 | 1716 | } |
1717 | ||
93406d87 | 1718 | DEFUN (bgp_graceful_restart_stalepath_time, |
1719 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1720 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1721 | "BGP specific commands\n" |
1722 | "Graceful restart capability parameters\n" | |
1723 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1724 | "Delay value (seconds)\n") | |
1725 | { | |
d62a17ae | 1726 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1727 | int idx_number = 3; | |
1728 | u_int32_t stalepath; | |
93406d87 | 1729 | |
d62a17ae | 1730 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
1731 | bgp->stalepath_time = stalepath; | |
1732 | return CMD_SUCCESS; | |
93406d87 | 1733 | } |
1734 | ||
eb6f1b41 PG |
1735 | DEFUN (bgp_graceful_restart_restart_time, |
1736 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1737 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1738 | "BGP specific commands\n" |
1739 | "Graceful restart capability parameters\n" | |
1740 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1741 | "Delay value (seconds)\n") | |
1742 | { | |
d62a17ae | 1743 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1744 | int idx_number = 3; | |
1745 | u_int32_t restart; | |
eb6f1b41 | 1746 | |
d62a17ae | 1747 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
1748 | bgp->restart_time = restart; | |
1749 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1750 | } |
1751 | ||
93406d87 | 1752 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1753 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1754 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1755 | NO_STR |
1756 | "BGP specific commands\n" | |
1757 | "Graceful restart capability parameters\n" | |
838758ac DW |
1758 | "Set the max time to hold onto restarting peer's stale paths\n" |
1759 | "Delay value (seconds)\n") | |
93406d87 | 1760 | { |
d62a17ae | 1761 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1762 | |
d62a17ae | 1763 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
1764 | return CMD_SUCCESS; | |
93406d87 | 1765 | } |
1766 | ||
eb6f1b41 PG |
1767 | DEFUN (no_bgp_graceful_restart_restart_time, |
1768 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1769 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1770 | NO_STR |
1771 | "BGP specific commands\n" | |
1772 | "Graceful restart capability parameters\n" | |
838758ac DW |
1773 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1774 | "Delay value (seconds)\n") | |
eb6f1b41 | 1775 | { |
d62a17ae | 1776 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 1777 | |
d62a17ae | 1778 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
1779 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1780 | } |
1781 | ||
43fc21b3 JC |
1782 | DEFUN (bgp_graceful_restart_preserve_fw, |
1783 | bgp_graceful_restart_preserve_fw_cmd, | |
1784 | "bgp graceful-restart preserve-fw-state", | |
1785 | "BGP specific commands\n" | |
1786 | "Graceful restart capability parameters\n" | |
1787 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1788 | { | |
d62a17ae | 1789 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1790 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1791 | return CMD_SUCCESS; | |
43fc21b3 JC |
1792 | } |
1793 | ||
1794 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
1795 | no_bgp_graceful_restart_preserve_fw_cmd, | |
1796 | "no bgp graceful-restart preserve-fw-state", | |
1797 | NO_STR | |
1798 | "BGP specific commands\n" | |
1799 | "Graceful restart capability parameters\n" | |
1800 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1801 | { | |
d62a17ae | 1802 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1803 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1804 | return CMD_SUCCESS; | |
43fc21b3 JC |
1805 | } |
1806 | ||
718e3744 | 1807 | /* "bgp fast-external-failover" configuration. */ |
1808 | DEFUN (bgp_fast_external_failover, | |
1809 | bgp_fast_external_failover_cmd, | |
1810 | "bgp fast-external-failover", | |
1811 | BGP_STR | |
1812 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1813 | { | |
d62a17ae | 1814 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1815 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
1816 | return CMD_SUCCESS; | |
718e3744 | 1817 | } |
1818 | ||
1819 | DEFUN (no_bgp_fast_external_failover, | |
1820 | no_bgp_fast_external_failover_cmd, | |
1821 | "no bgp fast-external-failover", | |
1822 | NO_STR | |
1823 | BGP_STR | |
1824 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1825 | { | |
d62a17ae | 1826 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1827 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
1828 | return CMD_SUCCESS; | |
718e3744 | 1829 | } |
6b0655a2 | 1830 | |
718e3744 | 1831 | /* "bgp enforce-first-as" configuration. */ |
1832 | DEFUN (bgp_enforce_first_as, | |
1833 | bgp_enforce_first_as_cmd, | |
1834 | "bgp enforce-first-as", | |
1835 | BGP_STR | |
1836 | "Enforce the first AS for EBGP routes\n") | |
1837 | { | |
d62a17ae | 1838 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1839 | bgp_flag_set(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
1840 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 1841 | |
d62a17ae | 1842 | return CMD_SUCCESS; |
718e3744 | 1843 | } |
1844 | ||
1845 | DEFUN (no_bgp_enforce_first_as, | |
1846 | no_bgp_enforce_first_as_cmd, | |
1847 | "no bgp enforce-first-as", | |
1848 | NO_STR | |
1849 | BGP_STR | |
1850 | "Enforce the first AS for EBGP routes\n") | |
1851 | { | |
d62a17ae | 1852 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1853 | bgp_flag_unset(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
1854 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 1855 | |
d62a17ae | 1856 | return CMD_SUCCESS; |
718e3744 | 1857 | } |
6b0655a2 | 1858 | |
718e3744 | 1859 | /* "bgp bestpath compare-routerid" configuration. */ |
1860 | DEFUN (bgp_bestpath_compare_router_id, | |
1861 | bgp_bestpath_compare_router_id_cmd, | |
1862 | "bgp bestpath compare-routerid", | |
1863 | "BGP specific commands\n" | |
1864 | "Change the default bestpath selection\n" | |
1865 | "Compare router-id for identical EBGP paths\n") | |
1866 | { | |
d62a17ae | 1867 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1868 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
1869 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1870 | |
d62a17ae | 1871 | return CMD_SUCCESS; |
718e3744 | 1872 | } |
1873 | ||
1874 | DEFUN (no_bgp_bestpath_compare_router_id, | |
1875 | no_bgp_bestpath_compare_router_id_cmd, | |
1876 | "no bgp bestpath compare-routerid", | |
1877 | NO_STR | |
1878 | "BGP specific commands\n" | |
1879 | "Change the default bestpath selection\n" | |
1880 | "Compare router-id for identical EBGP paths\n") | |
1881 | { | |
d62a17ae | 1882 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1883 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
1884 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1885 | |
d62a17ae | 1886 | return CMD_SUCCESS; |
718e3744 | 1887 | } |
6b0655a2 | 1888 | |
718e3744 | 1889 | /* "bgp bestpath as-path ignore" configuration. */ |
1890 | DEFUN (bgp_bestpath_aspath_ignore, | |
1891 | bgp_bestpath_aspath_ignore_cmd, | |
1892 | "bgp bestpath as-path ignore", | |
1893 | "BGP specific commands\n" | |
1894 | "Change the default bestpath selection\n" | |
1895 | "AS-path attribute\n" | |
1896 | "Ignore as-path length in selecting a route\n") | |
1897 | { | |
d62a17ae | 1898 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1899 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
1900 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1901 | |
d62a17ae | 1902 | return CMD_SUCCESS; |
718e3744 | 1903 | } |
1904 | ||
1905 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
1906 | no_bgp_bestpath_aspath_ignore_cmd, | |
1907 | "no bgp bestpath as-path ignore", | |
1908 | NO_STR | |
1909 | "BGP specific commands\n" | |
1910 | "Change the default bestpath selection\n" | |
1911 | "AS-path attribute\n" | |
1912 | "Ignore as-path length in selecting a route\n") | |
1913 | { | |
d62a17ae | 1914 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1915 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
1916 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1917 | |
d62a17ae | 1918 | return CMD_SUCCESS; |
718e3744 | 1919 | } |
6b0655a2 | 1920 | |
6811845b | 1921 | /* "bgp bestpath as-path confed" configuration. */ |
1922 | DEFUN (bgp_bestpath_aspath_confed, | |
1923 | bgp_bestpath_aspath_confed_cmd, | |
1924 | "bgp bestpath as-path confed", | |
1925 | "BGP specific commands\n" | |
1926 | "Change the default bestpath selection\n" | |
1927 | "AS-path attribute\n" | |
1928 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
1929 | { | |
d62a17ae | 1930 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1931 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
1932 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1933 | |
d62a17ae | 1934 | return CMD_SUCCESS; |
6811845b | 1935 | } |
1936 | ||
1937 | DEFUN (no_bgp_bestpath_aspath_confed, | |
1938 | no_bgp_bestpath_aspath_confed_cmd, | |
1939 | "no bgp bestpath as-path confed", | |
1940 | NO_STR | |
1941 | "BGP specific commands\n" | |
1942 | "Change the default bestpath selection\n" | |
1943 | "AS-path attribute\n" | |
1944 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
1945 | { | |
d62a17ae | 1946 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1947 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
1948 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1949 | |
d62a17ae | 1950 | return CMD_SUCCESS; |
6811845b | 1951 | } |
6b0655a2 | 1952 | |
2fdd455c PM |
1953 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
1954 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
1955 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 1956 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
1957 | "BGP specific commands\n" |
1958 | "Change the default bestpath selection\n" | |
1959 | "AS-path attribute\n" | |
1960 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 1961 | "Generate an AS_SET\n" |
16fc1eec DS |
1962 | "Do not generate an AS_SET\n") |
1963 | { | |
d62a17ae | 1964 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1965 | int idx = 0; | |
1966 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 1967 | |
d62a17ae | 1968 | /* no-as-set is now the default behavior so we can silently |
1969 | * ignore it */ | |
1970 | if (argv_find(argv, argc, "as-set", &idx)) | |
1971 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
1972 | else | |
1973 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 1974 | |
d62a17ae | 1975 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 1976 | |
d62a17ae | 1977 | return CMD_SUCCESS; |
16fc1eec DS |
1978 | } |
1979 | ||
219178b6 DW |
1980 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
1981 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 1982 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
1983 | NO_STR |
1984 | "BGP specific commands\n" | |
1985 | "Change the default bestpath selection\n" | |
1986 | "AS-path attribute\n" | |
1987 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 1988 | "Generate an AS_SET\n" |
16fc1eec DS |
1989 | "Do not generate an AS_SET\n") |
1990 | { | |
d62a17ae | 1991 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1992 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
1993 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
1994 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1995 | |
d62a17ae | 1996 | return CMD_SUCCESS; |
2fdd455c | 1997 | } |
6b0655a2 | 1998 | |
848973c7 | 1999 | /* "bgp log-neighbor-changes" configuration. */ |
2000 | DEFUN (bgp_log_neighbor_changes, | |
2001 | bgp_log_neighbor_changes_cmd, | |
2002 | "bgp log-neighbor-changes", | |
2003 | "BGP specific commands\n" | |
2004 | "Log neighbor up/down and reset reason\n") | |
2005 | { | |
d62a17ae | 2006 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2007 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2008 | return CMD_SUCCESS; | |
848973c7 | 2009 | } |
2010 | ||
2011 | DEFUN (no_bgp_log_neighbor_changes, | |
2012 | no_bgp_log_neighbor_changes_cmd, | |
2013 | "no bgp log-neighbor-changes", | |
2014 | NO_STR | |
2015 | "BGP specific commands\n" | |
2016 | "Log neighbor up/down and reset reason\n") | |
2017 | { | |
d62a17ae | 2018 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2019 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2020 | return CMD_SUCCESS; | |
848973c7 | 2021 | } |
6b0655a2 | 2022 | |
718e3744 | 2023 | /* "bgp bestpath med" configuration. */ |
2024 | DEFUN (bgp_bestpath_med, | |
2025 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2026 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2027 | "BGP specific commands\n" |
2028 | "Change the default bestpath selection\n" | |
2029 | "MED attribute\n" | |
2030 | "Compare MED among confederation paths\n" | |
838758ac DW |
2031 | "Treat missing MED as the least preferred one\n" |
2032 | "Treat missing MED as the least preferred one\n" | |
2033 | "Compare MED among confederation paths\n") | |
718e3744 | 2034 | { |
d62a17ae | 2035 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2036 | |
d62a17ae | 2037 | int idx = 0; |
2038 | if (argv_find(argv, argc, "confed", &idx)) | |
2039 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2040 | idx = 0; | |
2041 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2042 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2043 | |
d62a17ae | 2044 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2045 | |
d62a17ae | 2046 | return CMD_SUCCESS; |
718e3744 | 2047 | } |
2048 | ||
718e3744 | 2049 | DEFUN (no_bgp_bestpath_med, |
2050 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2051 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2052 | NO_STR |
2053 | "BGP specific commands\n" | |
2054 | "Change the default bestpath selection\n" | |
2055 | "MED attribute\n" | |
2056 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2057 | "Treat missing MED as the least preferred one\n" |
2058 | "Treat missing MED as the least preferred one\n" | |
2059 | "Compare MED among confederation paths\n") | |
718e3744 | 2060 | { |
d62a17ae | 2061 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2062 | |
d62a17ae | 2063 | int idx = 0; |
2064 | if (argv_find(argv, argc, "confed", &idx)) | |
2065 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2066 | idx = 0; | |
2067 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2068 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2069 | |
d62a17ae | 2070 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2071 | |
d62a17ae | 2072 | return CMD_SUCCESS; |
718e3744 | 2073 | } |
2074 | ||
718e3744 | 2075 | /* "no bgp default ipv4-unicast". */ |
2076 | DEFUN (no_bgp_default_ipv4_unicast, | |
2077 | no_bgp_default_ipv4_unicast_cmd, | |
2078 | "no bgp default ipv4-unicast", | |
2079 | NO_STR | |
2080 | "BGP specific commands\n" | |
2081 | "Configure BGP defaults\n" | |
2082 | "Activate ipv4-unicast for a peer by default\n") | |
2083 | { | |
d62a17ae | 2084 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2085 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2086 | return CMD_SUCCESS; | |
718e3744 | 2087 | } |
2088 | ||
2089 | DEFUN (bgp_default_ipv4_unicast, | |
2090 | bgp_default_ipv4_unicast_cmd, | |
2091 | "bgp default ipv4-unicast", | |
2092 | "BGP specific commands\n" | |
2093 | "Configure BGP defaults\n" | |
2094 | "Activate ipv4-unicast for a peer by default\n") | |
2095 | { | |
d62a17ae | 2096 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2097 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2098 | return CMD_SUCCESS; | |
718e3744 | 2099 | } |
6b0655a2 | 2100 | |
04b6bdc0 DW |
2101 | /* Display hostname in certain command outputs */ |
2102 | DEFUN (bgp_default_show_hostname, | |
2103 | bgp_default_show_hostname_cmd, | |
2104 | "bgp default show-hostname", | |
2105 | "BGP specific commands\n" | |
2106 | "Configure BGP defaults\n" | |
2107 | "Show hostname in certain command ouputs\n") | |
2108 | { | |
d62a17ae | 2109 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2110 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2111 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2112 | } |
2113 | ||
2114 | DEFUN (no_bgp_default_show_hostname, | |
2115 | no_bgp_default_show_hostname_cmd, | |
2116 | "no bgp default show-hostname", | |
2117 | NO_STR | |
2118 | "BGP specific commands\n" | |
2119 | "Configure BGP defaults\n" | |
2120 | "Show hostname in certain command ouputs\n") | |
2121 | { | |
d62a17ae | 2122 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2123 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2124 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2125 | } |
2126 | ||
8233ef81 | 2127 | /* "bgp network import-check" configuration. */ |
718e3744 | 2128 | DEFUN (bgp_network_import_check, |
2129 | bgp_network_import_check_cmd, | |
5623e905 | 2130 | "bgp network import-check", |
718e3744 | 2131 | "BGP specific commands\n" |
2132 | "BGP network command\n" | |
5623e905 | 2133 | "Check BGP network route exists in IGP\n") |
718e3744 | 2134 | { |
d62a17ae | 2135 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2136 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2137 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
2138 | bgp_static_redo_import_check(bgp); | |
2139 | } | |
078430f6 | 2140 | |
d62a17ae | 2141 | return CMD_SUCCESS; |
718e3744 | 2142 | } |
2143 | ||
d62a17ae | 2144 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
2145 | "bgp network import-check exact", | |
2146 | "BGP specific commands\n" | |
2147 | "BGP network command\n" | |
2148 | "Check BGP network route exists in IGP\n" | |
2149 | "Match route precisely\n") | |
8233ef81 | 2150 | |
718e3744 | 2151 | DEFUN (no_bgp_network_import_check, |
2152 | no_bgp_network_import_check_cmd, | |
5623e905 | 2153 | "no bgp network import-check", |
718e3744 | 2154 | NO_STR |
2155 | "BGP specific commands\n" | |
2156 | "BGP network command\n" | |
2157 | "Check BGP network route exists in IGP\n") | |
2158 | { | |
d62a17ae | 2159 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2160 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2161 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
2162 | bgp_static_redo_import_check(bgp); | |
2163 | } | |
5623e905 | 2164 | |
d62a17ae | 2165 | return CMD_SUCCESS; |
718e3744 | 2166 | } |
6b0655a2 | 2167 | |
718e3744 | 2168 | DEFUN (bgp_default_local_preference, |
2169 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2170 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2171 | "BGP specific commands\n" |
2172 | "Configure BGP defaults\n" | |
2173 | "local preference (higher=more preferred)\n" | |
2174 | "Configure default local preference value\n") | |
2175 | { | |
d62a17ae | 2176 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2177 | int idx_number = 3; | |
2178 | u_int32_t local_pref; | |
718e3744 | 2179 | |
d62a17ae | 2180 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2181 | |
d62a17ae | 2182 | bgp_default_local_preference_set(bgp, local_pref); |
2183 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 2184 | |
d62a17ae | 2185 | return CMD_SUCCESS; |
718e3744 | 2186 | } |
2187 | ||
2188 | DEFUN (no_bgp_default_local_preference, | |
2189 | no_bgp_default_local_preference_cmd, | |
838758ac | 2190 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2191 | NO_STR |
2192 | "BGP specific commands\n" | |
2193 | "Configure BGP defaults\n" | |
838758ac DW |
2194 | "local preference (higher=more preferred)\n" |
2195 | "Configure default local preference value\n") | |
718e3744 | 2196 | { |
d62a17ae | 2197 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2198 | bgp_default_local_preference_unset(bgp); | |
2199 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2200 | |
d62a17ae | 2201 | return CMD_SUCCESS; |
718e3744 | 2202 | } |
2203 | ||
6b0655a2 | 2204 | |
3f9c7369 DS |
2205 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2206 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2207 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2208 | "BGP specific commands\n" |
2209 | "Configure BGP defaults\n" | |
2210 | "subgroup-pkt-queue-max\n" | |
2211 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2212 | { |
d62a17ae | 2213 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2214 | int idx_number = 3; | |
2215 | u_int32_t max_size; | |
8bd9d948 | 2216 | |
d62a17ae | 2217 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 2218 | |
d62a17ae | 2219 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 2220 | |
d62a17ae | 2221 | return CMD_SUCCESS; |
3f9c7369 DS |
2222 | } |
2223 | ||
2224 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2225 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2226 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2227 | NO_STR |
2228 | "BGP specific commands\n" | |
2229 | "Configure BGP defaults\n" | |
838758ac DW |
2230 | "subgroup-pkt-queue-max\n" |
2231 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2232 | { |
d62a17ae | 2233 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2234 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
2235 | return CMD_SUCCESS; | |
8bd9d948 DS |
2236 | } |
2237 | ||
813d4307 | 2238 | |
8bd9d948 DS |
2239 | DEFUN (bgp_rr_allow_outbound_policy, |
2240 | bgp_rr_allow_outbound_policy_cmd, | |
2241 | "bgp route-reflector allow-outbound-policy", | |
2242 | "BGP specific commands\n" | |
2243 | "Allow modifications made by out route-map\n" | |
2244 | "on ibgp neighbors\n") | |
2245 | { | |
d62a17ae | 2246 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2247 | |
d62a17ae | 2248 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2249 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2250 | update_group_announce_rrclients(bgp); | |
2251 | bgp_clear_star_soft_out(vty, bgp->name); | |
2252 | } | |
8bd9d948 | 2253 | |
d62a17ae | 2254 | return CMD_SUCCESS; |
8bd9d948 DS |
2255 | } |
2256 | ||
2257 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2258 | no_bgp_rr_allow_outbound_policy_cmd, | |
2259 | "no bgp route-reflector allow-outbound-policy", | |
2260 | NO_STR | |
2261 | "BGP specific commands\n" | |
2262 | "Allow modifications made by out route-map\n" | |
2263 | "on ibgp neighbors\n") | |
2264 | { | |
d62a17ae | 2265 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2266 | |
d62a17ae | 2267 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2268 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2269 | update_group_announce_rrclients(bgp); | |
2270 | bgp_clear_star_soft_out(vty, bgp->name); | |
2271 | } | |
8bd9d948 | 2272 | |
d62a17ae | 2273 | return CMD_SUCCESS; |
8bd9d948 DS |
2274 | } |
2275 | ||
f14e6fdb DS |
2276 | DEFUN (bgp_listen_limit, |
2277 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2278 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2279 | "BGP specific commands\n" |
2280 | "Configure BGP defaults\n" | |
2281 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2282 | "Configure Dynamic Neighbors listen limit value\n") | |
2283 | { | |
d62a17ae | 2284 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2285 | int idx_number = 3; | |
2286 | int listen_limit; | |
f14e6fdb | 2287 | |
d62a17ae | 2288 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 2289 | |
d62a17ae | 2290 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 2291 | |
d62a17ae | 2292 | return CMD_SUCCESS; |
f14e6fdb DS |
2293 | } |
2294 | ||
2295 | DEFUN (no_bgp_listen_limit, | |
2296 | no_bgp_listen_limit_cmd, | |
838758ac | 2297 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2298 | "BGP specific commands\n" |
2299 | "Configure BGP defaults\n" | |
2300 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2301 | "Configure Dynamic Neighbors listen limit value to default\n" |
2302 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2303 | { |
d62a17ae | 2304 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2305 | bgp_listen_limit_unset(bgp); | |
2306 | return CMD_SUCCESS; | |
f14e6fdb DS |
2307 | } |
2308 | ||
2309 | ||
20eb8864 | 2310 | /* |
2311 | * Check if this listen range is already configured. Check for exact | |
2312 | * match or overlap based on input. | |
2313 | */ | |
d62a17ae | 2314 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
2315 | struct prefix *range, int exact) | |
2316 | { | |
2317 | struct listnode *node, *nnode; | |
2318 | struct listnode *node1, *nnode1; | |
2319 | struct peer_group *group; | |
2320 | struct prefix *lr; | |
2321 | afi_t afi; | |
2322 | int match; | |
2323 | ||
2324 | afi = family2afi(range->family); | |
2325 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2326 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
2327 | lr)) { | |
2328 | if (exact) | |
2329 | match = prefix_same(range, lr); | |
2330 | else | |
2331 | match = (prefix_match(range, lr) | |
2332 | || prefix_match(lr, range)); | |
2333 | if (match) | |
2334 | return group; | |
2335 | } | |
2336 | } | |
2337 | ||
2338 | return NULL; | |
20eb8864 | 2339 | } |
2340 | ||
f14e6fdb DS |
2341 | DEFUN (bgp_listen_range, |
2342 | bgp_listen_range_cmd, | |
9ccf14f7 | 2343 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2344 | "BGP specific commands\n" |
d7fa34c1 QY |
2345 | "Configure BGP dynamic neighbors listen range\n" |
2346 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2347 | NEIGHBOR_ADDR_STR |
2348 | "Member of the peer-group\n" | |
2349 | "Peer-group name\n") | |
f14e6fdb | 2350 | { |
d62a17ae | 2351 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2352 | struct prefix range; | |
2353 | struct peer_group *group, *existing_group; | |
2354 | afi_t afi; | |
2355 | int ret; | |
2356 | int idx = 0; | |
2357 | ||
2358 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2359 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2360 | char *prefix = argv[idx]->arg; | |
2361 | argv_find(argv, argc, "WORD", &idx); | |
2362 | char *peergroup = argv[idx]->arg; | |
2363 | ||
2364 | /* Convert IP prefix string to struct prefix. */ | |
2365 | ret = str2prefix(prefix, &range); | |
2366 | if (!ret) { | |
2367 | vty_out(vty, "%% Malformed listen range\n"); | |
2368 | return CMD_WARNING_CONFIG_FAILED; | |
2369 | } | |
2370 | ||
2371 | afi = family2afi(range.family); | |
2372 | ||
2373 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2374 | vty_out(vty, | |
2375 | "%% Malformed listen range (link-local address)\n"); | |
2376 | return CMD_WARNING_CONFIG_FAILED; | |
2377 | } | |
2378 | ||
2379 | apply_mask(&range); | |
2380 | ||
2381 | /* Check if same listen range is already configured. */ | |
2382 | existing_group = listen_range_exists(bgp, &range, 1); | |
2383 | if (existing_group) { | |
2384 | if (strcmp(existing_group->name, peergroup) == 0) | |
2385 | return CMD_SUCCESS; | |
2386 | else { | |
2387 | vty_out(vty, | |
2388 | "%% Same listen range is attached to peer-group %s\n", | |
2389 | existing_group->name); | |
2390 | return CMD_WARNING_CONFIG_FAILED; | |
2391 | } | |
2392 | } | |
2393 | ||
2394 | /* Check if an overlapping listen range exists. */ | |
2395 | if (listen_range_exists(bgp, &range, 0)) { | |
2396 | vty_out(vty, | |
2397 | "%% Listen range overlaps with existing listen range\n"); | |
2398 | return CMD_WARNING_CONFIG_FAILED; | |
2399 | } | |
2400 | ||
2401 | group = peer_group_lookup(bgp, peergroup); | |
2402 | if (!group) { | |
2403 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2404 | return CMD_WARNING_CONFIG_FAILED; | |
2405 | } | |
2406 | ||
2407 | ret = peer_group_listen_range_add(group, &range); | |
2408 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
2409 | } |
2410 | ||
2411 | DEFUN (no_bgp_listen_range, | |
2412 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2413 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2414 | NO_STR | |
f14e6fdb | 2415 | "BGP specific commands\n" |
d7fa34c1 QY |
2416 | "Unconfigure BGP dynamic neighbors listen range\n" |
2417 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2418 | NEIGHBOR_ADDR_STR | |
2419 | "Member of the peer-group\n" | |
2420 | "Peer-group name\n") | |
f14e6fdb | 2421 | { |
d62a17ae | 2422 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2423 | struct prefix range; | |
2424 | struct peer_group *group; | |
2425 | afi_t afi; | |
2426 | int ret; | |
2427 | int idx = 0; | |
2428 | ||
2429 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2430 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2431 | char *prefix = argv[idx]->arg; | |
2432 | argv_find(argv, argc, "WORD", &idx); | |
2433 | char *peergroup = argv[idx]->arg; | |
2434 | ||
2435 | /* Convert IP prefix string to struct prefix. */ | |
2436 | ret = str2prefix(prefix, &range); | |
2437 | if (!ret) { | |
2438 | vty_out(vty, "%% Malformed listen range\n"); | |
2439 | return CMD_WARNING_CONFIG_FAILED; | |
2440 | } | |
2441 | ||
2442 | afi = family2afi(range.family); | |
2443 | ||
2444 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2445 | vty_out(vty, | |
2446 | "%% Malformed listen range (link-local address)\n"); | |
2447 | return CMD_WARNING_CONFIG_FAILED; | |
2448 | } | |
2449 | ||
2450 | apply_mask(&range); | |
2451 | ||
2452 | group = peer_group_lookup(bgp, peergroup); | |
2453 | if (!group) { | |
2454 | vty_out(vty, "%% Peer-group does not exist\n"); | |
2455 | return CMD_WARNING_CONFIG_FAILED; | |
2456 | } | |
2457 | ||
2458 | ret = peer_group_listen_range_del(group, &range); | |
2459 | return bgp_vty_return(vty, ret); | |
2460 | } | |
2461 | ||
2462 | int bgp_config_write_listen(struct vty *vty, struct bgp *bgp) | |
2463 | { | |
2464 | struct peer_group *group; | |
2465 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2466 | struct prefix *range; | |
2467 | afi_t afi; | |
2468 | char buf[PREFIX2STR_BUFFER]; | |
2469 | ||
2470 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2471 | vty_out(vty, " bgp listen limit %d\n", | |
2472 | bgp->dynamic_neighbors_limit); | |
2473 | ||
2474 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2475 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
2476 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
2477 | nrnode, range)) { | |
2478 | prefix2str(range, buf, sizeof(buf)); | |
2479 | vty_out(vty, | |
2480 | " bgp listen range %s peer-group %s\n", | |
2481 | buf, group->name); | |
2482 | } | |
2483 | } | |
2484 | } | |
2485 | ||
2486 | return 0; | |
f14e6fdb DS |
2487 | } |
2488 | ||
2489 | ||
907f92c8 DS |
2490 | DEFUN (bgp_disable_connected_route_check, |
2491 | bgp_disable_connected_route_check_cmd, | |
2492 | "bgp disable-ebgp-connected-route-check", | |
2493 | "BGP specific commands\n" | |
2494 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2495 | { | |
d62a17ae | 2496 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2497 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2498 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2499 | |
d62a17ae | 2500 | return CMD_SUCCESS; |
907f92c8 DS |
2501 | } |
2502 | ||
2503 | DEFUN (no_bgp_disable_connected_route_check, | |
2504 | no_bgp_disable_connected_route_check_cmd, | |
2505 | "no bgp disable-ebgp-connected-route-check", | |
2506 | NO_STR | |
2507 | "BGP specific commands\n" | |
2508 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2509 | { | |
d62a17ae | 2510 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2511 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2512 | bgp_clear_star_soft_in(vty, bgp->name); | |
2513 | ||
2514 | return CMD_SUCCESS; | |
2515 | } | |
2516 | ||
2517 | ||
2518 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
2519 | const char *as_str, afi_t afi, safi_t safi) | |
2520 | { | |
2521 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2522 | int ret; | |
2523 | as_t as; | |
2524 | int as_type = AS_SPECIFIED; | |
2525 | union sockunion su; | |
2526 | ||
2527 | if (as_str[0] == 'i') { | |
2528 | as = 0; | |
2529 | as_type = AS_INTERNAL; | |
2530 | } else if (as_str[0] == 'e') { | |
2531 | as = 0; | |
2532 | as_type = AS_EXTERNAL; | |
2533 | } else { | |
2534 | /* Get AS number. */ | |
2535 | as = strtoul(as_str, NULL, 10); | |
2536 | } | |
2537 | ||
2538 | /* If peer is peer group, call proper function. */ | |
2539 | ret = str2sockunion(peer_str, &su); | |
2540 | if (ret < 0) { | |
2541 | /* Check for peer by interface */ | |
2542 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, | |
2543 | safi); | |
2544 | if (ret < 0) { | |
2545 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); | |
2546 | if (ret < 0) { | |
2547 | vty_out(vty, | |
2548 | "%% Create the peer-group or interface first\n"); | |
2549 | return CMD_WARNING_CONFIG_FAILED; | |
2550 | } | |
2551 | return CMD_SUCCESS; | |
2552 | } | |
2553 | } else { | |
2554 | if (peer_address_self_check(bgp, &su)) { | |
2555 | vty_out(vty, | |
2556 | "%% Can not configure the local system as neighbor\n"); | |
2557 | return CMD_WARNING_CONFIG_FAILED; | |
2558 | } | |
2559 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
2560 | } | |
2561 | ||
2562 | /* This peer belongs to peer group. */ | |
2563 | switch (ret) { | |
2564 | case BGP_ERR_PEER_GROUP_MEMBER: | |
2565 | vty_out(vty, | |
2566 | "%% Peer-group AS %u. Cannot configure remote-as for member\n", | |
2567 | as); | |
2568 | return CMD_WARNING_CONFIG_FAILED; | |
2569 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
2570 | vty_out(vty, | |
2571 | "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n", | |
2572 | as, as_str); | |
2573 | return CMD_WARNING_CONFIG_FAILED; | |
2574 | } | |
2575 | return bgp_vty_return(vty, ret); | |
718e3744 | 2576 | } |
2577 | ||
2578 | DEFUN (neighbor_remote_as, | |
2579 | neighbor_remote_as_cmd, | |
3a2d747c | 2580 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2581 | NEIGHBOR_STR |
2582 | NEIGHBOR_ADDR_STR2 | |
2583 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2584 | AS_STR |
3a2d747c QY |
2585 | "Internal BGP peer\n" |
2586 | "External BGP peer\n") | |
718e3744 | 2587 | { |
d62a17ae | 2588 | int idx_peer = 1; |
2589 | int idx_remote_as = 3; | |
2590 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
2591 | argv[idx_remote_as]->arg, AFI_IP, | |
2592 | SAFI_UNICAST); | |
2593 | } | |
2594 | ||
2595 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
2596 | afi_t afi, safi_t safi, int v6only, | |
2597 | const char *peer_group_name, | |
2598 | const char *as_str) | |
2599 | { | |
2600 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2601 | as_t as = 0; | |
2602 | int as_type = AS_UNSPECIFIED; | |
2603 | struct peer *peer; | |
2604 | struct peer_group *group; | |
2605 | int ret = 0; | |
2606 | union sockunion su; | |
2607 | ||
2608 | group = peer_group_lookup(bgp, conf_if); | |
2609 | ||
2610 | if (group) { | |
2611 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
2612 | return CMD_WARNING_CONFIG_FAILED; | |
2613 | } | |
2614 | ||
2615 | if (as_str) { | |
2616 | if (as_str[0] == 'i') { | |
2617 | as_type = AS_INTERNAL; | |
2618 | } else if (as_str[0] == 'e') { | |
2619 | as_type = AS_EXTERNAL; | |
2620 | } else { | |
2621 | /* Get AS number. */ | |
2622 | as = strtoul(as_str, NULL, 10); | |
2623 | as_type = AS_SPECIFIED; | |
2624 | } | |
2625 | } | |
2626 | ||
2627 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
2628 | if (peer) { | |
2629 | if (as_str) | |
2630 | ret = peer_remote_as(bgp, &su, conf_if, &as, as_type, | |
2631 | afi, safi); | |
2632 | } else { | |
2633 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2634 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
2635 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2636 | as_type, 0, 0, NULL); | |
2637 | else | |
2638 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2639 | as_type, afi, safi, NULL); | |
2640 | ||
2641 | if (!peer) { | |
2642 | vty_out(vty, "%% BGP failed to create peer\n"); | |
2643 | return CMD_WARNING_CONFIG_FAILED; | |
2644 | } | |
2645 | ||
2646 | if (v6only) | |
2647 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2648 | ||
2649 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
2650 | * this | |
2651 | * any unnumbered peer in order to not worry about run-time | |
2652 | * transitions | |
2653 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
2654 | * address | |
2655 | * gets deleted later etc.) | |
2656 | */ | |
2657 | if (peer->ifp) | |
2658 | bgp_zebra_initiate_radv(bgp, peer); | |
2659 | } | |
2660 | ||
2661 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
2662 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
2663 | if (v6only) | |
2664 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2665 | else | |
2666 | UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2667 | ||
2668 | /* v6only flag changed. Reset bgp seesion */ | |
2669 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2670 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2671 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2672 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2673 | } else | |
2674 | bgp_session_reset(peer); | |
2675 | } | |
2676 | ||
2677 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) | |
2678 | peer_flag_set(peer, PEER_FLAG_CAPABILITY_ENHE); | |
2679 | ||
2680 | if (peer_group_name) { | |
2681 | group = peer_group_lookup(bgp, peer_group_name); | |
2682 | if (!group) { | |
2683 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2684 | return CMD_WARNING_CONFIG_FAILED; | |
2685 | } | |
2686 | ||
2687 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
2688 | } | |
2689 | ||
2690 | return bgp_vty_return(vty, ret); | |
a80beece DS |
2691 | } |
2692 | ||
4c48cf63 DW |
2693 | DEFUN (neighbor_interface_config, |
2694 | neighbor_interface_config_cmd, | |
31500417 | 2695 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2696 | NEIGHBOR_STR |
2697 | "Interface name or neighbor tag\n" | |
31500417 DW |
2698 | "Enable BGP on interface\n" |
2699 | "Member of the peer-group\n" | |
16cedbb0 | 2700 | "Peer-group name\n") |
4c48cf63 | 2701 | { |
d62a17ae | 2702 | int idx_word = 1; |
2703 | int idx_peer_group_word = 4; | |
31500417 | 2704 | |
d62a17ae | 2705 | if (argc > idx_peer_group_word) |
2706 | return peer_conf_interface_get( | |
2707 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2708 | argv[idx_peer_group_word]->arg, NULL); | |
2709 | else | |
2710 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2711 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
2712 | } |
2713 | ||
4c48cf63 DW |
2714 | DEFUN (neighbor_interface_config_v6only, |
2715 | neighbor_interface_config_v6only_cmd, | |
31500417 | 2716 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
2717 | NEIGHBOR_STR |
2718 | "Interface name or neighbor tag\n" | |
2719 | "Enable BGP on interface\n" | |
31500417 DW |
2720 | "Enable BGP with v6 link-local only\n" |
2721 | "Member of the peer-group\n" | |
16cedbb0 | 2722 | "Peer-group name\n") |
4c48cf63 | 2723 | { |
d62a17ae | 2724 | int idx_word = 1; |
2725 | int idx_peer_group_word = 5; | |
31500417 | 2726 | |
d62a17ae | 2727 | if (argc > idx_peer_group_word) |
2728 | return peer_conf_interface_get( | |
2729 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2730 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 2731 | |
d62a17ae | 2732 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
2733 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
2734 | } |
2735 | ||
a80beece | 2736 | |
b3a39dc5 DD |
2737 | DEFUN (neighbor_interface_config_remote_as, |
2738 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2739 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2740 | NEIGHBOR_STR |
2741 | "Interface name or neighbor tag\n" | |
2742 | "Enable BGP on interface\n" | |
3a2d747c | 2743 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2744 | AS_STR |
3a2d747c QY |
2745 | "Internal BGP peer\n" |
2746 | "External BGP peer\n") | |
b3a39dc5 | 2747 | { |
d62a17ae | 2748 | int idx_word = 1; |
2749 | int idx_remote_as = 4; | |
2750 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2751 | SAFI_UNICAST, 0, NULL, | |
2752 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2753 | } |
2754 | ||
2755 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
2756 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 2757 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2758 | NEIGHBOR_STR |
2759 | "Interface name or neighbor tag\n" | |
3a2d747c | 2760 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 2761 | "Enable BGP on interface\n" |
3a2d747c | 2762 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2763 | AS_STR |
3a2d747c QY |
2764 | "Internal BGP peer\n" |
2765 | "External BGP peer\n") | |
b3a39dc5 | 2766 | { |
d62a17ae | 2767 | int idx_word = 1; |
2768 | int idx_remote_as = 5; | |
2769 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2770 | SAFI_UNICAST, 1, NULL, | |
2771 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2772 | } |
2773 | ||
718e3744 | 2774 | DEFUN (neighbor_peer_group, |
2775 | neighbor_peer_group_cmd, | |
2776 | "neighbor WORD peer-group", | |
2777 | NEIGHBOR_STR | |
a80beece | 2778 | "Interface name or neighbor tag\n" |
718e3744 | 2779 | "Configure peer-group\n") |
2780 | { | |
d62a17ae | 2781 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2782 | int idx_word = 1; | |
2783 | struct peer *peer; | |
2784 | struct peer_group *group; | |
718e3744 | 2785 | |
d62a17ae | 2786 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
2787 | if (peer) { | |
2788 | vty_out(vty, "%% Name conflict with interface: \n"); | |
2789 | return CMD_WARNING_CONFIG_FAILED; | |
2790 | } | |
718e3744 | 2791 | |
d62a17ae | 2792 | group = peer_group_get(bgp, argv[idx_word]->arg); |
2793 | if (!group) { | |
2794 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
2795 | return CMD_WARNING_CONFIG_FAILED; | |
2796 | } | |
718e3744 | 2797 | |
d62a17ae | 2798 | return CMD_SUCCESS; |
718e3744 | 2799 | } |
2800 | ||
2801 | DEFUN (no_neighbor, | |
2802 | no_neighbor_cmd, | |
dab8cd00 | 2803 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 2804 | NO_STR |
2805 | NEIGHBOR_STR | |
3a2d747c QY |
2806 | NEIGHBOR_ADDR_STR2 |
2807 | "Specify a BGP neighbor\n" | |
2808 | AS_STR | |
2809 | "Internal BGP peer\n" | |
2810 | "External BGP peer\n") | |
718e3744 | 2811 | { |
d62a17ae | 2812 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2813 | int idx_peer = 2; | |
2814 | int ret; | |
2815 | union sockunion su; | |
2816 | struct peer_group *group; | |
2817 | struct peer *peer; | |
2818 | struct peer *other; | |
2819 | ||
2820 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
2821 | if (ret < 0) { | |
2822 | /* look up for neighbor by interface name config. */ | |
2823 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
2824 | if (peer) { | |
2825 | /* Request zebra to terminate IPv6 RAs on this | |
2826 | * interface. */ | |
2827 | if (peer->ifp) | |
2828 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
2829 | peer_delete(peer); | |
2830 | return CMD_SUCCESS; | |
2831 | } | |
f14e6fdb | 2832 | |
d62a17ae | 2833 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
2834 | if (group) | |
2835 | peer_group_delete(group); | |
2836 | else { | |
2837 | vty_out(vty, "%% Create the peer-group first\n"); | |
2838 | return CMD_WARNING_CONFIG_FAILED; | |
2839 | } | |
2840 | } else { | |
2841 | peer = peer_lookup(bgp, &su); | |
2842 | if (peer) { | |
2843 | if (peer_dynamic_neighbor(peer)) { | |
2844 | vty_out(vty, | |
2845 | "%% Operation not allowed on a dynamic neighbor\n"); | |
2846 | return CMD_WARNING_CONFIG_FAILED; | |
2847 | } | |
2848 | ||
2849 | other = peer->doppelganger; | |
2850 | peer_delete(peer); | |
2851 | if (other && other->status != Deleted) | |
2852 | peer_delete(other); | |
2853 | } | |
1ff9a340 | 2854 | } |
718e3744 | 2855 | |
d62a17ae | 2856 | return CMD_SUCCESS; |
718e3744 | 2857 | } |
2858 | ||
a80beece DS |
2859 | DEFUN (no_neighbor_interface_config, |
2860 | no_neighbor_interface_config_cmd, | |
31500417 | 2861 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
2862 | NO_STR |
2863 | NEIGHBOR_STR | |
2864 | "Interface name\n" | |
31500417 DW |
2865 | "Configure BGP on interface\n" |
2866 | "Enable BGP with v6 link-local only\n" | |
2867 | "Member of the peer-group\n" | |
16cedbb0 | 2868 | "Peer-group name\n" |
3a2d747c QY |
2869 | "Specify a BGP neighbor\n" |
2870 | AS_STR | |
2871 | "Internal BGP peer\n" | |
2872 | "External BGP peer\n") | |
a80beece | 2873 | { |
d62a17ae | 2874 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2875 | int idx_word = 2; | |
2876 | struct peer *peer; | |
2877 | ||
2878 | /* look up for neighbor by interface name config. */ | |
2879 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
2880 | if (peer) { | |
2881 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
2882 | if (peer->ifp) | |
2883 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
2884 | peer_delete(peer); | |
2885 | } else { | |
2886 | vty_out(vty, "%% Create the bgp interface first\n"); | |
2887 | return CMD_WARNING_CONFIG_FAILED; | |
2888 | } | |
2889 | return CMD_SUCCESS; | |
a80beece DS |
2890 | } |
2891 | ||
718e3744 | 2892 | DEFUN (no_neighbor_peer_group, |
2893 | no_neighbor_peer_group_cmd, | |
2894 | "no neighbor WORD peer-group", | |
2895 | NO_STR | |
2896 | NEIGHBOR_STR | |
2897 | "Neighbor tag\n" | |
2898 | "Configure peer-group\n") | |
2899 | { | |
d62a17ae | 2900 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2901 | int idx_word = 2; | |
2902 | struct peer_group *group; | |
718e3744 | 2903 | |
d62a17ae | 2904 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
2905 | if (group) | |
2906 | peer_group_delete(group); | |
2907 | else { | |
2908 | vty_out(vty, "%% Create the peer-group first\n"); | |
2909 | return CMD_WARNING_CONFIG_FAILED; | |
2910 | } | |
2911 | return CMD_SUCCESS; | |
718e3744 | 2912 | } |
2913 | ||
a80beece DS |
2914 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
2915 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 2916 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2917 | NO_STR |
2918 | NEIGHBOR_STR | |
a80beece | 2919 | "Interface name or neighbor tag\n" |
718e3744 | 2920 | "Specify a BGP neighbor\n" |
3a2d747c QY |
2921 | AS_STR |
2922 | "Internal BGP peer\n" | |
2923 | "External BGP peer\n") | |
718e3744 | 2924 | { |
d62a17ae | 2925 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2926 | int idx_word = 2; | |
2927 | struct peer_group *group; | |
2928 | struct peer *peer; | |
2929 | ||
2930 | /* look up for neighbor by interface name config. */ | |
2931 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
2932 | if (peer) { | |
2933 | peer_as_change(peer, 0, AS_SPECIFIED); | |
2934 | return CMD_SUCCESS; | |
2935 | } | |
2936 | ||
2937 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
2938 | if (group) | |
2939 | peer_group_remote_as_delete(group); | |
2940 | else { | |
2941 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
2942 | return CMD_WARNING_CONFIG_FAILED; | |
2943 | } | |
2944 | return CMD_SUCCESS; | |
718e3744 | 2945 | } |
6b0655a2 | 2946 | |
718e3744 | 2947 | DEFUN (neighbor_local_as, |
2948 | neighbor_local_as_cmd, | |
9ccf14f7 | 2949 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 2950 | NEIGHBOR_STR |
2951 | NEIGHBOR_ADDR_STR2 | |
2952 | "Specify a local-as number\n" | |
2953 | "AS number used as local AS\n") | |
2954 | { | |
d62a17ae | 2955 | int idx_peer = 1; |
2956 | int idx_number = 3; | |
2957 | struct peer *peer; | |
2958 | int ret; | |
2959 | as_t as; | |
718e3744 | 2960 | |
d62a17ae | 2961 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2962 | if (!peer) | |
2963 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 2964 | |
d62a17ae | 2965 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
2966 | ret = peer_local_as_set(peer, as, 0, 0); | |
2967 | return bgp_vty_return(vty, ret); | |
718e3744 | 2968 | } |
2969 | ||
2970 | DEFUN (neighbor_local_as_no_prepend, | |
2971 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 2972 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 2973 | NEIGHBOR_STR |
2974 | NEIGHBOR_ADDR_STR2 | |
2975 | "Specify a local-as number\n" | |
2976 | "AS number used as local AS\n" | |
2977 | "Do not prepend local-as to updates from ebgp peers\n") | |
2978 | { | |
d62a17ae | 2979 | int idx_peer = 1; |
2980 | int idx_number = 3; | |
2981 | struct peer *peer; | |
2982 | int ret; | |
2983 | as_t as; | |
718e3744 | 2984 | |
d62a17ae | 2985 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
2986 | if (!peer) | |
2987 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 2988 | |
d62a17ae | 2989 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
2990 | ret = peer_local_as_set(peer, as, 1, 0); | |
2991 | return bgp_vty_return(vty, ret); | |
718e3744 | 2992 | } |
2993 | ||
9d3f9705 AC |
2994 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
2995 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 2996 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
2997 | NEIGHBOR_STR |
2998 | NEIGHBOR_ADDR_STR2 | |
2999 | "Specify a local-as number\n" | |
3000 | "AS number used as local AS\n" | |
3001 | "Do not prepend local-as to updates from ebgp peers\n" | |
3002 | "Do not prepend local-as to updates from ibgp peers\n") | |
3003 | { | |
d62a17ae | 3004 | int idx_peer = 1; |
3005 | int idx_number = 3; | |
3006 | struct peer *peer; | |
3007 | int ret; | |
3008 | as_t as; | |
9d3f9705 | 3009 | |
d62a17ae | 3010 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3011 | if (!peer) | |
3012 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3013 | |
d62a17ae | 3014 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3015 | ret = peer_local_as_set(peer, as, 1, 1); | |
3016 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3017 | } |
3018 | ||
718e3744 | 3019 | DEFUN (no_neighbor_local_as, |
3020 | no_neighbor_local_as_cmd, | |
a636c635 | 3021 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3022 | NO_STR |
3023 | NEIGHBOR_STR | |
3024 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3025 | "Specify a local-as number\n" |
3026 | "AS number used as local AS\n" | |
3027 | "Do not prepend local-as to updates from ebgp peers\n" | |
3028 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3029 | { |
d62a17ae | 3030 | int idx_peer = 2; |
3031 | struct peer *peer; | |
3032 | int ret; | |
718e3744 | 3033 | |
d62a17ae | 3034 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3035 | if (!peer) | |
3036 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3037 | |
d62a17ae | 3038 | ret = peer_local_as_unset(peer); |
3039 | return bgp_vty_return(vty, ret); | |
718e3744 | 3040 | } |
3041 | ||
718e3744 | 3042 | |
3f9c7369 DS |
3043 | DEFUN (neighbor_solo, |
3044 | neighbor_solo_cmd, | |
9ccf14f7 | 3045 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3046 | NEIGHBOR_STR |
3047 | NEIGHBOR_ADDR_STR2 | |
3048 | "Solo peer - part of its own update group\n") | |
3049 | { | |
d62a17ae | 3050 | int idx_peer = 1; |
3051 | struct peer *peer; | |
3052 | int ret; | |
3f9c7369 | 3053 | |
d62a17ae | 3054 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3055 | if (!peer) | |
3056 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3057 | |
d62a17ae | 3058 | ret = update_group_adjust_soloness(peer, 1); |
3059 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3060 | } |
3061 | ||
3062 | DEFUN (no_neighbor_solo, | |
3063 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3064 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3065 | NO_STR |
3066 | NEIGHBOR_STR | |
3067 | NEIGHBOR_ADDR_STR2 | |
3068 | "Solo peer - part of its own update group\n") | |
3069 | { | |
d62a17ae | 3070 | int idx_peer = 2; |
3071 | struct peer *peer; | |
3072 | int ret; | |
3f9c7369 | 3073 | |
d62a17ae | 3074 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3075 | if (!peer) | |
3076 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3077 | |
d62a17ae | 3078 | ret = update_group_adjust_soloness(peer, 0); |
3079 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3080 | } |
3081 | ||
0df7c91f PJ |
3082 | DEFUN (neighbor_password, |
3083 | neighbor_password_cmd, | |
9ccf14f7 | 3084 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3085 | NEIGHBOR_STR |
3086 | NEIGHBOR_ADDR_STR2 | |
3087 | "Set a password\n" | |
3088 | "The password\n") | |
3089 | { | |
d62a17ae | 3090 | int idx_peer = 1; |
3091 | int idx_line = 3; | |
3092 | struct peer *peer; | |
3093 | int ret; | |
0df7c91f | 3094 | |
d62a17ae | 3095 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3096 | if (!peer) | |
3097 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3098 | |
d62a17ae | 3099 | ret = peer_password_set(peer, argv[idx_line]->arg); |
3100 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
3101 | } |
3102 | ||
3103 | DEFUN (no_neighbor_password, | |
3104 | no_neighbor_password_cmd, | |
a636c635 | 3105 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3106 | NO_STR |
3107 | NEIGHBOR_STR | |
3108 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3109 | "Set a password\n" |
3110 | "The password\n") | |
0df7c91f | 3111 | { |
d62a17ae | 3112 | int idx_peer = 2; |
3113 | struct peer *peer; | |
3114 | int ret; | |
0df7c91f | 3115 | |
d62a17ae | 3116 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3117 | if (!peer) | |
3118 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3119 | |
d62a17ae | 3120 | ret = peer_password_unset(peer); |
3121 | return bgp_vty_return(vty, ret); | |
0df7c91f | 3122 | } |
6b0655a2 | 3123 | |
813d4307 | 3124 | |
718e3744 | 3125 | DEFUN (neighbor_activate, |
3126 | neighbor_activate_cmd, | |
9ccf14f7 | 3127 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3128 | NEIGHBOR_STR |
3129 | NEIGHBOR_ADDR_STR2 | |
3130 | "Enable the Address Family for this Neighbor\n") | |
3131 | { | |
d62a17ae | 3132 | int idx_peer = 1; |
3133 | int ret; | |
3134 | struct peer *peer; | |
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_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3141 | return bgp_vty_return(vty, ret); | |
718e3744 | 3142 | } |
3143 | ||
d62a17ae | 3144 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
3145 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3146 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3147 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3148 | |
718e3744 | 3149 | DEFUN (no_neighbor_activate, |
3150 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3151 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3152 | NO_STR |
3153 | NEIGHBOR_STR | |
3154 | NEIGHBOR_ADDR_STR2 | |
3155 | "Enable the Address Family for this Neighbor\n") | |
3156 | { | |
d62a17ae | 3157 | int idx_peer = 2; |
3158 | int ret; | |
3159 | struct peer *peer; | |
718e3744 | 3160 | |
d62a17ae | 3161 | /* Lookup peer. */ |
3162 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3163 | if (!peer) | |
3164 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3165 | |
d62a17ae | 3166 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3167 | return bgp_vty_return(vty, ret); | |
718e3744 | 3168 | } |
6b0655a2 | 3169 | |
d62a17ae | 3170 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
3171 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3172 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3173 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3174 | |
718e3744 | 3175 | DEFUN (neighbor_set_peer_group, |
3176 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3177 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3178 | NEIGHBOR_STR |
a80beece | 3179 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3180 | "Member of the peer-group\n" |
16cedbb0 | 3181 | "Peer-group name\n") |
718e3744 | 3182 | { |
d62a17ae | 3183 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3184 | int idx_peer = 1; | |
3185 | int idx_word = 3; | |
3186 | int ret; | |
3187 | as_t as; | |
3188 | union sockunion su; | |
3189 | struct peer *peer; | |
3190 | struct peer_group *group; | |
3191 | ||
3192 | peer = NULL; | |
3193 | ||
3194 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3195 | if (ret < 0) { | |
3196 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3197 | if (!peer) { | |
3198 | vty_out(vty, "%% Malformed address or name: %s\n", | |
3199 | argv[idx_peer]->arg); | |
3200 | return CMD_WARNING_CONFIG_FAILED; | |
3201 | } | |
3202 | } else { | |
3203 | if (peer_address_self_check(bgp, &su)) { | |
3204 | vty_out(vty, | |
3205 | "%% Can not configure the local system as neighbor\n"); | |
3206 | return CMD_WARNING_CONFIG_FAILED; | |
3207 | } | |
3208 | ||
3209 | /* Disallow for dynamic neighbor. */ | |
3210 | peer = peer_lookup(bgp, &su); | |
3211 | if (peer && peer_dynamic_neighbor(peer)) { | |
3212 | vty_out(vty, | |
3213 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3214 | return CMD_WARNING_CONFIG_FAILED; | |
3215 | } | |
3216 | } | |
3217 | ||
3218 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3219 | if (!group) { | |
3220 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3221 | return CMD_WARNING_CONFIG_FAILED; | |
3222 | } | |
3223 | ||
3224 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3225 | ||
3226 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
3227 | vty_out(vty, | |
3228 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
3229 | as); | |
3230 | return CMD_WARNING_CONFIG_FAILED; | |
3231 | } | |
3232 | ||
3233 | return bgp_vty_return(vty, ret); | |
3234 | } | |
3235 | ||
3236 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
3237 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3238 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3239 | "Member of the peer-group\n" | |
3240 | "Peer-group name\n") | |
596c17ba | 3241 | |
718e3744 | 3242 | DEFUN (no_neighbor_set_peer_group, |
3243 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3244 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3245 | NO_STR |
3246 | NEIGHBOR_STR | |
a80beece | 3247 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3248 | "Member of the peer-group\n" |
16cedbb0 | 3249 | "Peer-group name\n") |
718e3744 | 3250 | { |
d62a17ae | 3251 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3252 | int idx_peer = 2; | |
3253 | int idx_word = 4; | |
3254 | int ret; | |
3255 | struct peer *peer; | |
3256 | struct peer_group *group; | |
3257 | ||
3258 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
3259 | if (!peer) | |
3260 | return CMD_WARNING_CONFIG_FAILED; | |
3261 | ||
3262 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3263 | if (!group) { | |
3264 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3265 | return CMD_WARNING_CONFIG_FAILED; | |
3266 | } | |
718e3744 | 3267 | |
d62a17ae | 3268 | ret = peer_group_unbind(bgp, peer, group); |
718e3744 | 3269 | |
d62a17ae | 3270 | return bgp_vty_return(vty, ret); |
718e3744 | 3271 | } |
6b0655a2 | 3272 | |
d62a17ae | 3273 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
3274 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3275 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3276 | "Member of the peer-group\n" | |
3277 | "Peer-group name\n") | |
596c17ba | 3278 | |
d62a17ae | 3279 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
3280 | u_int16_t flag, int set) | |
718e3744 | 3281 | { |
d62a17ae | 3282 | int ret; |
3283 | struct peer *peer; | |
718e3744 | 3284 | |
d62a17ae | 3285 | peer = peer_and_group_lookup_vty(vty, ip_str); |
3286 | if (!peer) | |
3287 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3288 | |
d62a17ae | 3289 | /* |
3290 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3291 | * we should not accept disable-connected-check. | |
3292 | */ | |
3293 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3294 | vty_out(vty, | |
3295 | "%s is directly connected peer, cannot accept disable-" | |
3296 | "connected-check\n", | |
3297 | ip_str); | |
3298 | return CMD_WARNING_CONFIG_FAILED; | |
3299 | } | |
8cdabf90 | 3300 | |
d62a17ae | 3301 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3302 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 3303 | |
d62a17ae | 3304 | if (set) |
3305 | ret = peer_flag_set(peer, flag); | |
3306 | else | |
3307 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 3308 | |
d62a17ae | 3309 | return bgp_vty_return(vty, ret); |
718e3744 | 3310 | } |
3311 | ||
d62a17ae | 3312 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, |
3313 | u_int16_t flag) | |
718e3744 | 3314 | { |
d62a17ae | 3315 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 3316 | } |
3317 | ||
d62a17ae | 3318 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
3319 | u_int16_t flag) | |
718e3744 | 3320 | { |
d62a17ae | 3321 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 3322 | } |
3323 | ||
3324 | /* neighbor passive. */ | |
3325 | DEFUN (neighbor_passive, | |
3326 | neighbor_passive_cmd, | |
9ccf14f7 | 3327 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3328 | NEIGHBOR_STR |
3329 | NEIGHBOR_ADDR_STR2 | |
3330 | "Don't send open messages to this neighbor\n") | |
3331 | { | |
d62a17ae | 3332 | int idx_peer = 1; |
3333 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3334 | } |
3335 | ||
3336 | DEFUN (no_neighbor_passive, | |
3337 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3338 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3339 | NO_STR |
3340 | NEIGHBOR_STR | |
3341 | NEIGHBOR_ADDR_STR2 | |
3342 | "Don't send open messages to this neighbor\n") | |
3343 | { | |
d62a17ae | 3344 | int idx_peer = 2; |
3345 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3346 | } |
6b0655a2 | 3347 | |
718e3744 | 3348 | /* neighbor shutdown. */ |
73d70fa6 DL |
3349 | DEFUN (neighbor_shutdown_msg, |
3350 | neighbor_shutdown_msg_cmd, | |
3351 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3352 | NEIGHBOR_STR |
3353 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3354 | "Administratively shut down this neighbor\n" |
3355 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3356 | "Shutdown message\n") | |
718e3744 | 3357 | { |
d62a17ae | 3358 | int idx_peer = 1; |
73d70fa6 | 3359 | |
d62a17ae | 3360 | if (argc >= 5) { |
3361 | struct peer *peer = | |
3362 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3363 | char *message; | |
73d70fa6 | 3364 | |
d62a17ae | 3365 | if (!peer) |
3366 | return CMD_WARNING_CONFIG_FAILED; | |
3367 | message = argv_concat(argv, argc, 4); | |
3368 | peer_tx_shutdown_message_set(peer, message); | |
3369 | XFREE(MTYPE_TMP, message); | |
3370 | } | |
73d70fa6 | 3371 | |
d62a17ae | 3372 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3373 | } |
3374 | ||
d62a17ae | 3375 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
3376 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3377 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3378 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3379 | |
3380 | DEFUN (no_neighbor_shutdown_msg, | |
3381 | no_neighbor_shutdown_msg_cmd, | |
3382 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3383 | NO_STR | |
3384 | NEIGHBOR_STR | |
3385 | NEIGHBOR_ADDR_STR2 | |
3386 | "Administratively shut down this neighbor\n" | |
3387 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3388 | "Shutdown message\n") | |
718e3744 | 3389 | { |
d62a17ae | 3390 | int idx_peer = 2; |
73d70fa6 | 3391 | |
d62a17ae | 3392 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
3393 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 3394 | } |
6b0655a2 | 3395 | |
d62a17ae | 3396 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
3397 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3398 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3399 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 3400 | |
718e3744 | 3401 | /* neighbor capability dynamic. */ |
3402 | DEFUN (neighbor_capability_dynamic, | |
3403 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3404 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3405 | NEIGHBOR_STR |
3406 | NEIGHBOR_ADDR_STR2 | |
3407 | "Advertise capability to the peer\n" | |
3408 | "Advertise dynamic capability to this neighbor\n") | |
3409 | { | |
d62a17ae | 3410 | int idx_peer = 1; |
3411 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3412 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3413 | } |
3414 | ||
3415 | DEFUN (no_neighbor_capability_dynamic, | |
3416 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3417 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3418 | NO_STR |
3419 | NEIGHBOR_STR | |
3420 | NEIGHBOR_ADDR_STR2 | |
3421 | "Advertise capability to the peer\n" | |
3422 | "Advertise dynamic capability to this neighbor\n") | |
3423 | { | |
d62a17ae | 3424 | int idx_peer = 2; |
3425 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3426 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3427 | } |
6b0655a2 | 3428 | |
718e3744 | 3429 | /* neighbor dont-capability-negotiate */ |
3430 | DEFUN (neighbor_dont_capability_negotiate, | |
3431 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3432 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3433 | NEIGHBOR_STR |
3434 | NEIGHBOR_ADDR_STR2 | |
3435 | "Do not perform capability negotiation\n") | |
3436 | { | |
d62a17ae | 3437 | int idx_peer = 1; |
3438 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3439 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3440 | } |
3441 | ||
3442 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3443 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3444 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3445 | NO_STR |
3446 | NEIGHBOR_STR | |
3447 | NEIGHBOR_ADDR_STR2 | |
3448 | "Do not perform capability negotiation\n") | |
3449 | { | |
d62a17ae | 3450 | int idx_peer = 2; |
3451 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3452 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3453 | } |
6b0655a2 | 3454 | |
8a92a8a0 DS |
3455 | /* neighbor capability extended next hop encoding */ |
3456 | DEFUN (neighbor_capability_enhe, | |
3457 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3458 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3459 | NEIGHBOR_STR |
3460 | NEIGHBOR_ADDR_STR2 | |
3461 | "Advertise capability to the peer\n" | |
3462 | "Advertise extended next-hop capability to the peer\n") | |
3463 | { | |
d62a17ae | 3464 | int idx_peer = 1; |
3465 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3466 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3467 | } |
3468 | ||
3469 | DEFUN (no_neighbor_capability_enhe, | |
3470 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3471 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3472 | NO_STR |
3473 | NEIGHBOR_STR | |
3474 | NEIGHBOR_ADDR_STR2 | |
3475 | "Advertise capability to the peer\n" | |
3476 | "Advertise extended next-hop capability to the peer\n") | |
3477 | { | |
d62a17ae | 3478 | int idx_peer = 2; |
3479 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3480 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3481 | } |
3482 | ||
d62a17ae | 3483 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
3484 | afi_t afi, safi_t safi, u_int32_t flag, | |
3485 | int set) | |
718e3744 | 3486 | { |
d62a17ae | 3487 | int ret; |
3488 | struct peer *peer; | |
718e3744 | 3489 | |
d62a17ae | 3490 | peer = peer_and_group_lookup_vty(vty, peer_str); |
3491 | if (!peer) | |
3492 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3493 | |
d62a17ae | 3494 | if (set) |
3495 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
3496 | else | |
3497 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 3498 | |
d62a17ae | 3499 | return bgp_vty_return(vty, ret); |
718e3744 | 3500 | } |
3501 | ||
d62a17ae | 3502 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
3503 | afi_t afi, safi_t safi, u_int32_t flag) | |
718e3744 | 3504 | { |
d62a17ae | 3505 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 3506 | } |
3507 | ||
d62a17ae | 3508 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
3509 | afi_t afi, safi_t safi, u_int32_t flag) | |
718e3744 | 3510 | { |
d62a17ae | 3511 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 3512 | } |
6b0655a2 | 3513 | |
718e3744 | 3514 | /* neighbor capability orf prefix-list. */ |
3515 | DEFUN (neighbor_capability_orf_prefix, | |
3516 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3517 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3518 | NEIGHBOR_STR |
3519 | NEIGHBOR_ADDR_STR2 | |
3520 | "Advertise capability to the peer\n" | |
3521 | "Advertise ORF capability to the peer\n" | |
3522 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3523 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3524 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3525 | "Capability to SEND the ORF to this neighbor\n") | |
3526 | { | |
d62a17ae | 3527 | int idx_peer = 1; |
3528 | int idx_send_recv = 5; | |
3529 | u_int16_t flag = 0; | |
3530 | ||
3531 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3532 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3533 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3534 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3535 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3536 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3537 | else { | |
3538 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3539 | return CMD_WARNING_CONFIG_FAILED; | |
3540 | } | |
3541 | ||
3542 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3543 | bgp_node_safi(vty), flag); | |
3544 | } | |
3545 | ||
3546 | ALIAS_HIDDEN( | |
3547 | neighbor_capability_orf_prefix, | |
3548 | neighbor_capability_orf_prefix_hidden_cmd, | |
3549 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3550 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3551 | "Advertise capability to the peer\n" | |
3552 | "Advertise ORF capability to the peer\n" | |
3553 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3554 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3555 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3556 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3557 | |
718e3744 | 3558 | DEFUN (no_neighbor_capability_orf_prefix, |
3559 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3560 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3561 | NO_STR |
3562 | NEIGHBOR_STR | |
3563 | NEIGHBOR_ADDR_STR2 | |
3564 | "Advertise capability to the peer\n" | |
3565 | "Advertise ORF capability to the peer\n" | |
3566 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3567 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3568 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3569 | "Capability to SEND the ORF to this neighbor\n") | |
3570 | { | |
d62a17ae | 3571 | int idx_peer = 2; |
3572 | int idx_send_recv = 6; | |
3573 | u_int16_t flag = 0; | |
3574 | ||
3575 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3576 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3577 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3578 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3579 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3580 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3581 | else { | |
3582 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3583 | return CMD_WARNING_CONFIG_FAILED; | |
3584 | } | |
3585 | ||
3586 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3587 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3588 | flag); | |
3589 | } | |
3590 | ||
3591 | ALIAS_HIDDEN( | |
3592 | no_neighbor_capability_orf_prefix, | |
3593 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
3594 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3595 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3596 | "Advertise capability to the peer\n" | |
3597 | "Advertise ORF capability to the peer\n" | |
3598 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3599 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3600 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3601 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3602 | |
718e3744 | 3603 | /* neighbor next-hop-self. */ |
3604 | DEFUN (neighbor_nexthop_self, | |
3605 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3606 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3607 | NEIGHBOR_STR |
3608 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3609 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3610 | { |
d62a17ae | 3611 | int idx_peer = 1; |
3612 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3613 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 3614 | } |
9e7a53c1 | 3615 | |
d62a17ae | 3616 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
3617 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3618 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3619 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3620 | |
a538debe DS |
3621 | /* neighbor next-hop-self. */ |
3622 | DEFUN (neighbor_nexthop_self_force, | |
3623 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3624 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3625 | NEIGHBOR_STR |
3626 | NEIGHBOR_ADDR_STR2 | |
3627 | "Disable the next hop calculation for this neighbor\n" | |
3628 | "Set the next hop to self for reflected routes\n") | |
3629 | { | |
d62a17ae | 3630 | int idx_peer = 1; |
3631 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3632 | bgp_node_safi(vty), | |
3633 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 3634 | } |
3635 | ||
d62a17ae | 3636 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3637 | neighbor_nexthop_self_force_hidden_cmd, | |
3638 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3639 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3640 | "Disable the next hop calculation for this neighbor\n" | |
3641 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3642 | |
718e3744 | 3643 | DEFUN (no_neighbor_nexthop_self, |
3644 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3645 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3646 | NO_STR |
3647 | NEIGHBOR_STR | |
3648 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3649 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3650 | { |
d62a17ae | 3651 | int idx_peer = 2; |
3652 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3653 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3654 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 3655 | } |
6b0655a2 | 3656 | |
d62a17ae | 3657 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
3658 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3659 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3660 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3661 | |
88b8ed8d | 3662 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3663 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3664 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3665 | NO_STR |
3666 | NEIGHBOR_STR | |
3667 | NEIGHBOR_ADDR_STR2 | |
3668 | "Disable the next hop calculation for this neighbor\n" | |
3669 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3670 | { |
d62a17ae | 3671 | int idx_peer = 2; |
3672 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3673 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3674 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 3675 | } |
a538debe | 3676 | |
d62a17ae | 3677 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
3678 | no_neighbor_nexthop_self_force_hidden_cmd, | |
3679 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3680 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3681 | "Disable the next hop calculation for this neighbor\n" | |
3682 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3683 | |
c7122e14 DS |
3684 | /* neighbor as-override */ |
3685 | DEFUN (neighbor_as_override, | |
3686 | neighbor_as_override_cmd, | |
9ccf14f7 | 3687 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3688 | NEIGHBOR_STR |
3689 | NEIGHBOR_ADDR_STR2 | |
3690 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3691 | { | |
d62a17ae | 3692 | int idx_peer = 1; |
3693 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3694 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3695 | } |
3696 | ||
d62a17ae | 3697 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
3698 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3699 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3700 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3701 | |
c7122e14 DS |
3702 | DEFUN (no_neighbor_as_override, |
3703 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3704 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3705 | NO_STR |
3706 | NEIGHBOR_STR | |
3707 | NEIGHBOR_ADDR_STR2 | |
3708 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3709 | { | |
d62a17ae | 3710 | int idx_peer = 2; |
3711 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3712 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3713 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3714 | } |
3715 | ||
d62a17ae | 3716 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
3717 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3718 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3719 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3720 | |
718e3744 | 3721 | /* neighbor remove-private-AS. */ |
3722 | DEFUN (neighbor_remove_private_as, | |
3723 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3724 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3725 | NEIGHBOR_STR |
3726 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3727 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3728 | { |
d62a17ae | 3729 | int idx_peer = 1; |
3730 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3731 | bgp_node_safi(vty), | |
3732 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 3733 | } |
3734 | ||
d62a17ae | 3735 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
3736 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
3737 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3738 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 3739 | |
5000f21c DS |
3740 | DEFUN (neighbor_remove_private_as_all, |
3741 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 3742 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3743 | NEIGHBOR_STR |
3744 | NEIGHBOR_ADDR_STR2 | |
3745 | "Remove private ASNs in outbound updates\n" | |
3746 | "Apply to all AS numbers") | |
3747 | { | |
d62a17ae | 3748 | int idx_peer = 1; |
3749 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3750 | bgp_node_safi(vty), | |
3751 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
3752 | } |
3753 | ||
d62a17ae | 3754 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
3755 | neighbor_remove_private_as_all_hidden_cmd, | |
3756 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
3757 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3758 | "Remove private ASNs in outbound updates\n" | |
3759 | "Apply to all AS numbers") | |
596c17ba | 3760 | |
5000f21c DS |
3761 | DEFUN (neighbor_remove_private_as_replace_as, |
3762 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 3763 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3764 | NEIGHBOR_STR |
3765 | NEIGHBOR_ADDR_STR2 | |
3766 | "Remove private ASNs in outbound updates\n" | |
3767 | "Replace private ASNs with our ASN in outbound updates\n") | |
3768 | { | |
d62a17ae | 3769 | int idx_peer = 1; |
3770 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3771 | bgp_node_safi(vty), | |
3772 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
3773 | } |
3774 | ||
d62a17ae | 3775 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
3776 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
3777 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
3778 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3779 | "Remove private ASNs in outbound updates\n" | |
3780 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3781 | |
5000f21c DS |
3782 | DEFUN (neighbor_remove_private_as_all_replace_as, |
3783 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 3784 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3785 | NEIGHBOR_STR |
3786 | NEIGHBOR_ADDR_STR2 | |
3787 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3788 | "Apply to all AS numbers\n" |
5000f21c DS |
3789 | "Replace private ASNs with our ASN in outbound updates\n") |
3790 | { | |
d62a17ae | 3791 | int idx_peer = 1; |
3792 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3793 | bgp_node_safi(vty), | |
3794 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
3795 | } |
3796 | ||
d62a17ae | 3797 | ALIAS_HIDDEN( |
3798 | neighbor_remove_private_as_all_replace_as, | |
3799 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
3800 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
3801 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3802 | "Remove private ASNs in outbound updates\n" | |
3803 | "Apply to all AS numbers\n" | |
3804 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3805 | |
718e3744 | 3806 | DEFUN (no_neighbor_remove_private_as, |
3807 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3808 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3809 | NO_STR |
3810 | NEIGHBOR_STR | |
3811 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3812 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3813 | { |
d62a17ae | 3814 | int idx_peer = 2; |
3815 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3816 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3817 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 3818 | } |
6b0655a2 | 3819 | |
d62a17ae | 3820 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
3821 | no_neighbor_remove_private_as_hidden_cmd, | |
3822 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
3823 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3824 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 3825 | |
88b8ed8d | 3826 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 3827 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 3828 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3829 | NO_STR |
3830 | NEIGHBOR_STR | |
3831 | NEIGHBOR_ADDR_STR2 | |
3832 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3833 | "Apply to all AS numbers\n") |
88b8ed8d | 3834 | { |
d62a17ae | 3835 | int idx_peer = 2; |
3836 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3837 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3838 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 3839 | } |
5000f21c | 3840 | |
d62a17ae | 3841 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
3842 | no_neighbor_remove_private_as_all_hidden_cmd, | |
3843 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
3844 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3845 | "Remove private ASNs in outbound updates\n" | |
3846 | "Apply to all AS numbers\n") | |
596c17ba | 3847 | |
88b8ed8d | 3848 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 3849 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 3850 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3851 | NO_STR |
3852 | NEIGHBOR_STR | |
3853 | NEIGHBOR_ADDR_STR2 | |
3854 | "Remove private ASNs in outbound updates\n" | |
3855 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 3856 | { |
d62a17ae | 3857 | int idx_peer = 2; |
3858 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3859 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3860 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 3861 | } |
5000f21c | 3862 | |
d62a17ae | 3863 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
3864 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
3865 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
3866 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3867 | "Remove private ASNs in outbound updates\n" | |
3868 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3869 | |
88b8ed8d | 3870 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 3871 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 3872 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3873 | NO_STR |
3874 | NEIGHBOR_STR | |
3875 | NEIGHBOR_ADDR_STR2 | |
3876 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3877 | "Apply to all AS numbers\n" |
5000f21c | 3878 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 3879 | { |
d62a17ae | 3880 | int idx_peer = 2; |
3881 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3882 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3883 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 3884 | } |
5000f21c | 3885 | |
d62a17ae | 3886 | ALIAS_HIDDEN( |
3887 | no_neighbor_remove_private_as_all_replace_as, | |
3888 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
3889 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
3890 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3891 | "Remove private ASNs in outbound updates\n" | |
3892 | "Apply to all AS numbers\n" | |
3893 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3894 | |
5000f21c | 3895 | |
718e3744 | 3896 | /* neighbor send-community. */ |
3897 | DEFUN (neighbor_send_community, | |
3898 | neighbor_send_community_cmd, | |
9ccf14f7 | 3899 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3900 | NEIGHBOR_STR |
3901 | NEIGHBOR_ADDR_STR2 | |
3902 | "Send Community attribute to this neighbor\n") | |
3903 | { | |
d62a17ae | 3904 | int idx_peer = 1; |
3905 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3906 | bgp_node_safi(vty), | |
3907 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 3908 | } |
3909 | ||
d62a17ae | 3910 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
3911 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
3912 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3913 | "Send Community attribute to this neighbor\n") | |
596c17ba | 3914 | |
718e3744 | 3915 | DEFUN (no_neighbor_send_community, |
3916 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 3917 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 3918 | NO_STR |
3919 | NEIGHBOR_STR | |
3920 | NEIGHBOR_ADDR_STR2 | |
3921 | "Send Community attribute to this neighbor\n") | |
3922 | { | |
d62a17ae | 3923 | int idx_peer = 2; |
3924 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3925 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3926 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 3927 | } |
6b0655a2 | 3928 | |
d62a17ae | 3929 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
3930 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
3931 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3932 | "Send Community attribute to this neighbor\n") | |
596c17ba | 3933 | |
718e3744 | 3934 | /* neighbor send-community extended. */ |
3935 | DEFUN (neighbor_send_community_type, | |
3936 | neighbor_send_community_type_cmd, | |
57d187bc | 3937 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 3938 | NEIGHBOR_STR |
3939 | NEIGHBOR_ADDR_STR2 | |
3940 | "Send Community attribute to this neighbor\n" | |
3941 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 3942 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 3943 | "Send Extended Community attributes\n" |
57d187bc JS |
3944 | "Send Standard Community attributes\n" |
3945 | "Send Large Community attributes\n") | |
718e3744 | 3946 | { |
d62a17ae | 3947 | int idx = 0; |
3948 | u_int32_t flag = 0; | |
3949 | ||
3950 | char *peer = argv[1]->arg; | |
3951 | ||
3952 | if (argv_find(argv, argc, "standard", &idx)) | |
3953 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
3954 | else if (argv_find(argv, argc, "extended", &idx)) | |
3955 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3956 | else if (argv_find(argv, argc, "large", &idx)) | |
3957 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
3958 | else if (argv_find(argv, argc, "both", &idx)) { | |
3959 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
3960 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3961 | } else { | |
3962 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
3963 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
3964 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
3965 | } | |
3966 | ||
3967 | return peer_af_flag_set_vty(vty, peer, bgp_node_afi(vty), | |
3968 | bgp_node_safi(vty), flag); | |
3969 | } | |
3970 | ||
3971 | ALIAS_HIDDEN( | |
3972 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
3973 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
3974 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3975 | "Send Community attribute to this neighbor\n" | |
3976 | "Send Standard and Extended Community attributes\n" | |
3977 | "Send Standard, Large and Extended Community attributes\n" | |
3978 | "Send Extended Community attributes\n" | |
3979 | "Send Standard Community attributes\n" | |
3980 | "Send Large Community attributes\n") | |
596c17ba | 3981 | |
718e3744 | 3982 | DEFUN (no_neighbor_send_community_type, |
3983 | no_neighbor_send_community_type_cmd, | |
57d187bc | 3984 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 3985 | NO_STR |
3986 | NEIGHBOR_STR | |
3987 | NEIGHBOR_ADDR_STR2 | |
3988 | "Send Community attribute to this neighbor\n" | |
3989 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 3990 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 3991 | "Send Extended Community attributes\n" |
57d187bc JS |
3992 | "Send Standard Community attributes\n" |
3993 | "Send Large Community attributes\n") | |
718e3744 | 3994 | { |
d62a17ae | 3995 | int idx_peer = 2; |
3996 | ||
3997 | const char *type = argv[argc - 1]->text; | |
3998 | ||
3999 | if (strmatch(type, "standard")) | |
4000 | return peer_af_flag_unset_vty( | |
4001 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4002 | bgp_node_safi(vty), PEER_FLAG_SEND_COMMUNITY); | |
4003 | if (strmatch(type, "extended")) | |
4004 | return peer_af_flag_unset_vty( | |
4005 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4006 | bgp_node_safi(vty), PEER_FLAG_SEND_EXT_COMMUNITY); | |
4007 | if (strmatch(type, "large")) | |
4008 | return peer_af_flag_unset_vty( | |
4009 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4010 | bgp_node_safi(vty), PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4011 | if (strmatch(type, "both")) | |
4012 | return peer_af_flag_unset_vty( | |
4013 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4014 | bgp_node_safi(vty), | |
4015 | PEER_FLAG_SEND_COMMUNITY | |
4016 | | PEER_FLAG_SEND_EXT_COMMUNITY); | |
4017 | ||
4018 | /* if (strmatch (type, "all")) */ | |
4019 | return peer_af_flag_unset_vty( | |
4020 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4021 | (PEER_FLAG_SEND_COMMUNITY | PEER_FLAG_SEND_EXT_COMMUNITY | |
4022 | | PEER_FLAG_SEND_LARGE_COMMUNITY)); | |
4023 | } | |
4024 | ||
4025 | ALIAS_HIDDEN( | |
4026 | no_neighbor_send_community_type, | |
4027 | no_neighbor_send_community_type_hidden_cmd, | |
4028 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4029 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4030 | "Send Community attribute to this neighbor\n" | |
4031 | "Send Standard and Extended Community attributes\n" | |
4032 | "Send Standard, Large and Extended Community attributes\n" | |
4033 | "Send Extended Community attributes\n" | |
4034 | "Send Standard Community attributes\n" | |
4035 | "Send Large Community attributes\n") | |
596c17ba | 4036 | |
718e3744 | 4037 | /* neighbor soft-reconfig. */ |
4038 | DEFUN (neighbor_soft_reconfiguration, | |
4039 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4040 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4041 | NEIGHBOR_STR |
4042 | NEIGHBOR_ADDR_STR2 | |
4043 | "Per neighbor soft reconfiguration\n" | |
4044 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4045 | { | |
d62a17ae | 4046 | int idx_peer = 1; |
4047 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4048 | bgp_node_safi(vty), | |
4049 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4050 | } |
4051 | ||
d62a17ae | 4052 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4053 | neighbor_soft_reconfiguration_hidden_cmd, | |
4054 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4055 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4056 | "Per neighbor soft reconfiguration\n" | |
4057 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4058 | |
718e3744 | 4059 | DEFUN (no_neighbor_soft_reconfiguration, |
4060 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4061 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4062 | NO_STR |
4063 | NEIGHBOR_STR | |
4064 | NEIGHBOR_ADDR_STR2 | |
4065 | "Per neighbor soft reconfiguration\n" | |
4066 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4067 | { | |
d62a17ae | 4068 | int idx_peer = 2; |
4069 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4070 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4071 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4072 | } |
6b0655a2 | 4073 | |
d62a17ae | 4074 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
4075 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4076 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4077 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4078 | "Per neighbor soft reconfiguration\n" | |
4079 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4080 | |
718e3744 | 4081 | DEFUN (neighbor_route_reflector_client, |
4082 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4083 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4084 | NEIGHBOR_STR |
4085 | NEIGHBOR_ADDR_STR2 | |
4086 | "Configure a neighbor as Route Reflector client\n") | |
4087 | { | |
d62a17ae | 4088 | int idx_peer = 1; |
4089 | struct peer *peer; | |
718e3744 | 4090 | |
4091 | ||
d62a17ae | 4092 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4093 | if (!peer) | |
4094 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4095 | |
d62a17ae | 4096 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4097 | bgp_node_safi(vty), | |
4098 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4099 | } |
4100 | ||
d62a17ae | 4101 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
4102 | neighbor_route_reflector_client_hidden_cmd, | |
4103 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4104 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4105 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4106 | |
718e3744 | 4107 | DEFUN (no_neighbor_route_reflector_client, |
4108 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4109 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4110 | NO_STR |
4111 | NEIGHBOR_STR | |
4112 | NEIGHBOR_ADDR_STR2 | |
4113 | "Configure a neighbor as Route Reflector client\n") | |
4114 | { | |
d62a17ae | 4115 | int idx_peer = 2; |
4116 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4117 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4118 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4119 | } |
6b0655a2 | 4120 | |
d62a17ae | 4121 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
4122 | no_neighbor_route_reflector_client_hidden_cmd, | |
4123 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4124 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4125 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4126 | |
718e3744 | 4127 | /* neighbor route-server-client. */ |
4128 | DEFUN (neighbor_route_server_client, | |
4129 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4130 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4131 | NEIGHBOR_STR |
4132 | NEIGHBOR_ADDR_STR2 | |
4133 | "Configure a neighbor as Route Server client\n") | |
4134 | { | |
d62a17ae | 4135 | int idx_peer = 1; |
4136 | struct peer *peer; | |
2a3d5731 | 4137 | |
d62a17ae | 4138 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4139 | if (!peer) | |
4140 | return CMD_WARNING_CONFIG_FAILED; | |
4141 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4142 | bgp_node_safi(vty), | |
4143 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4144 | } |
4145 | ||
d62a17ae | 4146 | ALIAS_HIDDEN(neighbor_route_server_client, |
4147 | neighbor_route_server_client_hidden_cmd, | |
4148 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4149 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4150 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4151 | |
718e3744 | 4152 | DEFUN (no_neighbor_route_server_client, |
4153 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4154 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4155 | NO_STR |
4156 | NEIGHBOR_STR | |
4157 | NEIGHBOR_ADDR_STR2 | |
4158 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4159 | { |
d62a17ae | 4160 | int idx_peer = 2; |
4161 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4162 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4163 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4164 | } |
6b0655a2 | 4165 | |
d62a17ae | 4166 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
4167 | no_neighbor_route_server_client_hidden_cmd, | |
4168 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4169 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4170 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4171 | |
fee0f4c6 | 4172 | DEFUN (neighbor_nexthop_local_unchanged, |
4173 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4174 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4175 | NEIGHBOR_STR |
4176 | NEIGHBOR_ADDR_STR2 | |
4177 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4178 | "Leave link-local nexthop unchanged for this peer\n") | |
4179 | { | |
d62a17ae | 4180 | int idx_peer = 1; |
4181 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4182 | bgp_node_safi(vty), | |
4183 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 4184 | } |
6b0655a2 | 4185 | |
fee0f4c6 | 4186 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4187 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4188 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4189 | NO_STR |
4190 | NEIGHBOR_STR | |
4191 | NEIGHBOR_ADDR_STR2 | |
4192 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4193 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4194 | { |
d62a17ae | 4195 | int idx_peer = 2; |
4196 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4197 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4198 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 4199 | } |
6b0655a2 | 4200 | |
718e3744 | 4201 | DEFUN (neighbor_attr_unchanged, |
4202 | neighbor_attr_unchanged_cmd, | |
a8206004 | 4203 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 4204 | NEIGHBOR_STR |
4205 | NEIGHBOR_ADDR_STR2 | |
4206 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4207 | "As-path attribute\n" | |
4208 | "Nexthop attribute\n" | |
a8206004 | 4209 | "Med attribute\n") |
718e3744 | 4210 | { |
d62a17ae | 4211 | int idx = 0; |
8eeb0335 DW |
4212 | char *peer_str = argv[1]->arg; |
4213 | struct peer *peer; | |
d62a17ae | 4214 | u_int16_t flags = 0; |
8eeb0335 DW |
4215 | afi_t afi = bgp_node_afi(vty); |
4216 | safi_t safi = bgp_node_safi(vty); | |
4217 | ||
4218 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4219 | if (!peer) | |
4220 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4221 | |
4222 | if (argv_find(argv, argc, "as-path", &idx)) | |
4223 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4224 | idx = 0; | |
4225 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4226 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4227 | idx = 0; | |
4228 | if (argv_find(argv, argc, "med", &idx)) | |
4229 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4230 | ||
8eeb0335 DW |
4231 | /* no flags means all of them! */ |
4232 | if (!flags) { | |
d62a17ae | 4233 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
4234 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4235 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 DW |
4236 | } else { |
4237 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) && | |
4238 | peer_af_flag_check(peer, afi, safi, | |
4239 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
4240 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
4241 | PEER_FLAG_AS_PATH_UNCHANGED); | |
4242 | } | |
4243 | ||
4244 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) && | |
4245 | peer_af_flag_check(peer, afi, safi, | |
4246 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
4247 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
4248 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
4249 | } | |
4250 | ||
4251 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) && | |
4252 | peer_af_flag_check(peer, afi, safi, | |
4253 | PEER_FLAG_MED_UNCHANGED)) { | |
4254 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, | |
4255 | PEER_FLAG_MED_UNCHANGED); | |
4256 | } | |
d62a17ae | 4257 | } |
4258 | ||
8eeb0335 | 4259 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 4260 | } |
4261 | ||
4262 | ALIAS_HIDDEN( | |
4263 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
4264 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4265 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4266 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4267 | "As-path attribute\n" | |
4268 | "Nexthop attribute\n" | |
4269 | "Med attribute\n") | |
596c17ba | 4270 | |
718e3744 | 4271 | DEFUN (no_neighbor_attr_unchanged, |
4272 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 4273 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 4274 | NO_STR |
718e3744 | 4275 | NEIGHBOR_STR |
4276 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4277 | "BGP attribute is propagated unchanged to this neighbor\n" |
4278 | "As-path attribute\n" | |
40e718b5 | 4279 | "Nexthop attribute\n" |
a8206004 | 4280 | "Med attribute\n") |
718e3744 | 4281 | { |
d62a17ae | 4282 | int idx = 0; |
4283 | char *peer = argv[2]->arg; | |
4284 | u_int16_t flags = 0; | |
4285 | ||
4286 | if (argv_find(argv, argc, "as-path", &idx)) | |
4287 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4288 | idx = 0; | |
4289 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4290 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4291 | idx = 0; | |
4292 | if (argv_find(argv, argc, "med", &idx)) | |
4293 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4294 | ||
4295 | if (!flags) // no flags means all of them! | |
4296 | { | |
4297 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4298 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4299 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4300 | } | |
4301 | ||
4302 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
4303 | bgp_node_safi(vty), flags); | |
4304 | } | |
4305 | ||
4306 | ALIAS_HIDDEN( | |
4307 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
4308 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4309 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4310 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4311 | "As-path attribute\n" | |
4312 | "Nexthop attribute\n" | |
4313 | "Med attribute\n") | |
718e3744 | 4314 | |
718e3744 | 4315 | /* EBGP multihop configuration. */ |
d62a17ae | 4316 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
4317 | const char *ttl_str) | |
718e3744 | 4318 | { |
d62a17ae | 4319 | struct peer *peer; |
4320 | unsigned int ttl; | |
718e3744 | 4321 | |
d62a17ae | 4322 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4323 | if (!peer) | |
4324 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4325 | |
d62a17ae | 4326 | if (peer->conf_if) |
4327 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 4328 | |
d62a17ae | 4329 | if (!ttl_str) |
4330 | ttl = MAXTTL; | |
4331 | else | |
4332 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 4333 | |
d62a17ae | 4334 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 4335 | } |
4336 | ||
d62a17ae | 4337 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4338 | { |
d62a17ae | 4339 | struct peer *peer; |
718e3744 | 4340 | |
d62a17ae | 4341 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4342 | if (!peer) | |
4343 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4344 | |
d62a17ae | 4345 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 4346 | } |
4347 | ||
4348 | /* neighbor ebgp-multihop. */ | |
4349 | DEFUN (neighbor_ebgp_multihop, | |
4350 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4351 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4352 | NEIGHBOR_STR |
4353 | NEIGHBOR_ADDR_STR2 | |
4354 | "Allow EBGP neighbors not on directly connected networks\n") | |
4355 | { | |
d62a17ae | 4356 | int idx_peer = 1; |
4357 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4358 | } |
4359 | ||
4360 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4361 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4362 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4363 | NEIGHBOR_STR |
4364 | NEIGHBOR_ADDR_STR2 | |
4365 | "Allow EBGP neighbors not on directly connected networks\n" | |
4366 | "maximum hop count\n") | |
4367 | { | |
d62a17ae | 4368 | int idx_peer = 1; |
4369 | int idx_number = 3; | |
4370 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
4371 | argv[idx_number]->arg); | |
718e3744 | 4372 | } |
4373 | ||
4374 | DEFUN (no_neighbor_ebgp_multihop, | |
4375 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4376 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4377 | NO_STR |
4378 | NEIGHBOR_STR | |
4379 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4380 | "Allow EBGP neighbors not on directly connected networks\n" |
4381 | "maximum hop count\n") | |
718e3744 | 4382 | { |
d62a17ae | 4383 | int idx_peer = 2; |
4384 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4385 | } |
4386 | ||
6b0655a2 | 4387 | |
6ffd2079 | 4388 | /* disable-connected-check */ |
4389 | DEFUN (neighbor_disable_connected_check, | |
4390 | neighbor_disable_connected_check_cmd, | |
a636c635 | 4391 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4392 | NEIGHBOR_STR |
4393 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4394 | "one-hop away EBGP peer using loopback address\n" |
4395 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4396 | { |
d62a17ae | 4397 | int idx_peer = 1; |
4398 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4399 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4400 | } |
4401 | ||
4402 | DEFUN (no_neighbor_disable_connected_check, | |
4403 | no_neighbor_disable_connected_check_cmd, | |
a636c635 | 4404 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4405 | NO_STR |
4406 | NEIGHBOR_STR | |
4407 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4408 | "one-hop away EBGP peer using loopback address\n" |
4409 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4410 | { |
d62a17ae | 4411 | int idx_peer = 2; |
4412 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4413 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4414 | } |
4415 | ||
718e3744 | 4416 | DEFUN (neighbor_description, |
4417 | neighbor_description_cmd, | |
e961923c | 4418 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4419 | NEIGHBOR_STR |
4420 | NEIGHBOR_ADDR_STR2 | |
4421 | "Neighbor specific description\n" | |
4422 | "Up to 80 characters describing this neighbor\n") | |
4423 | { | |
d62a17ae | 4424 | int idx_peer = 1; |
4425 | int idx_line = 3; | |
4426 | struct peer *peer; | |
4427 | char *str; | |
718e3744 | 4428 | |
d62a17ae | 4429 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4430 | if (!peer) | |
4431 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4432 | |
d62a17ae | 4433 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4434 | |
d62a17ae | 4435 | peer_description_set(peer, str); |
718e3744 | 4436 | |
d62a17ae | 4437 | XFREE(MTYPE_TMP, str); |
718e3744 | 4438 | |
d62a17ae | 4439 | return CMD_SUCCESS; |
718e3744 | 4440 | } |
4441 | ||
4442 | DEFUN (no_neighbor_description, | |
4443 | no_neighbor_description_cmd, | |
a636c635 | 4444 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]", |
718e3744 | 4445 | NO_STR |
4446 | NEIGHBOR_STR | |
4447 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4448 | "Neighbor specific description\n" |
4449 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 4450 | { |
d62a17ae | 4451 | int idx_peer = 2; |
4452 | struct peer *peer; | |
718e3744 | 4453 | |
d62a17ae | 4454 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4455 | if (!peer) | |
4456 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4457 | |
d62a17ae | 4458 | peer_description_unset(peer); |
718e3744 | 4459 | |
d62a17ae | 4460 | return CMD_SUCCESS; |
718e3744 | 4461 | } |
4462 | ||
6b0655a2 | 4463 | |
718e3744 | 4464 | /* Neighbor update-source. */ |
d62a17ae | 4465 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
4466 | const char *source_str) | |
4467 | { | |
4468 | struct peer *peer; | |
4469 | struct prefix p; | |
4470 | ||
4471 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4472 | if (!peer) | |
4473 | return CMD_WARNING_CONFIG_FAILED; | |
4474 | ||
4475 | if (peer->conf_if) | |
4476 | return CMD_WARNING; | |
4477 | ||
4478 | if (source_str) { | |
4479 | union sockunion su; | |
4480 | int ret = str2sockunion(source_str, &su); | |
4481 | ||
4482 | if (ret == 0) | |
4483 | peer_update_source_addr_set(peer, &su); | |
4484 | else { | |
4485 | if (str2prefix(source_str, &p)) { | |
4486 | vty_out(vty, | |
4487 | "%% Invalid update-source, remove prefix length \n"); | |
4488 | return CMD_WARNING_CONFIG_FAILED; | |
4489 | } else | |
4490 | peer_update_source_if_set(peer, source_str); | |
4491 | } | |
4492 | } else | |
4493 | peer_update_source_unset(peer); | |
4494 | ||
4495 | return CMD_SUCCESS; | |
4496 | } | |
4497 | ||
4498 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
4499 | "IPv4 address\n" \ | |
4500 | "IPv6 address\n" \ | |
4501 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4502 | |
718e3744 | 4503 | DEFUN (neighbor_update_source, |
4504 | neighbor_update_source_cmd, | |
9ccf14f7 | 4505 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4506 | NEIGHBOR_STR |
4507 | NEIGHBOR_ADDR_STR2 | |
4508 | "Source of routing updates\n" | |
369688c0 | 4509 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4510 | { |
d62a17ae | 4511 | int idx_peer = 1; |
4512 | int idx_peer_2 = 3; | |
4513 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
4514 | argv[idx_peer_2]->arg); | |
718e3744 | 4515 | } |
4516 | ||
4517 | DEFUN (no_neighbor_update_source, | |
4518 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4519 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4520 | NO_STR |
4521 | NEIGHBOR_STR | |
4522 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4523 | "Source of routing updates\n" |
4524 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4525 | { |
d62a17ae | 4526 | int idx_peer = 2; |
4527 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4528 | } |
6b0655a2 | 4529 | |
d62a17ae | 4530 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
4531 | afi_t afi, safi_t safi, | |
4532 | const char *rmap, int set) | |
718e3744 | 4533 | { |
d62a17ae | 4534 | int ret; |
4535 | struct peer *peer; | |
718e3744 | 4536 | |
d62a17ae | 4537 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4538 | if (!peer) | |
4539 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4540 | |
d62a17ae | 4541 | if (set) |
4542 | ret = peer_default_originate_set(peer, afi, safi, rmap); | |
4543 | else | |
4544 | ret = peer_default_originate_unset(peer, afi, safi); | |
718e3744 | 4545 | |
d62a17ae | 4546 | return bgp_vty_return(vty, ret); |
718e3744 | 4547 | } |
4548 | ||
4549 | /* neighbor default-originate. */ | |
4550 | DEFUN (neighbor_default_originate, | |
4551 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4552 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4553 | NEIGHBOR_STR |
4554 | NEIGHBOR_ADDR_STR2 | |
4555 | "Originate default route to this neighbor\n") | |
4556 | { | |
d62a17ae | 4557 | int idx_peer = 1; |
4558 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4559 | bgp_node_afi(vty), | |
4560 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 4561 | } |
4562 | ||
d62a17ae | 4563 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
4564 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
4565 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4566 | "Originate default route to this neighbor\n") | |
596c17ba | 4567 | |
718e3744 | 4568 | DEFUN (neighbor_default_originate_rmap, |
4569 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4570 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4571 | NEIGHBOR_STR |
4572 | NEIGHBOR_ADDR_STR2 | |
4573 | "Originate default route to this neighbor\n" | |
4574 | "Route-map to specify criteria to originate default\n" | |
4575 | "route-map name\n") | |
4576 | { | |
d62a17ae | 4577 | int idx_peer = 1; |
4578 | int idx_word = 4; | |
4579 | return peer_default_originate_set_vty( | |
4580 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4581 | argv[idx_word]->arg, 1); | |
718e3744 | 4582 | } |
4583 | ||
d62a17ae | 4584 | ALIAS_HIDDEN( |
4585 | neighbor_default_originate_rmap, | |
4586 | neighbor_default_originate_rmap_hidden_cmd, | |
4587 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
4588 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4589 | "Originate default route to this neighbor\n" | |
4590 | "Route-map to specify criteria to originate default\n" | |
4591 | "route-map name\n") | |
596c17ba | 4592 | |
718e3744 | 4593 | DEFUN (no_neighbor_default_originate, |
4594 | no_neighbor_default_originate_cmd, | |
a636c635 | 4595 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4596 | NO_STR |
4597 | NEIGHBOR_STR | |
4598 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4599 | "Originate default route to this neighbor\n" |
4600 | "Route-map to specify criteria to originate default\n" | |
4601 | "route-map name\n") | |
718e3744 | 4602 | { |
d62a17ae | 4603 | int idx_peer = 2; |
4604 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4605 | bgp_node_afi(vty), | |
4606 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 4607 | } |
4608 | ||
d62a17ae | 4609 | ALIAS_HIDDEN( |
4610 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
4611 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
4612 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4613 | "Originate default route to this neighbor\n" | |
4614 | "Route-map to specify criteria to originate default\n" | |
4615 | "route-map name\n") | |
596c17ba | 4616 | |
6b0655a2 | 4617 | |
718e3744 | 4618 | /* Set neighbor's BGP port. */ |
d62a17ae | 4619 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
4620 | const char *port_str) | |
4621 | { | |
4622 | struct peer *peer; | |
4623 | u_int16_t port; | |
4624 | struct servent *sp; | |
4625 | ||
4626 | peer = peer_lookup_vty(vty, ip_str); | |
4627 | if (!peer) | |
4628 | return CMD_WARNING_CONFIG_FAILED; | |
4629 | ||
4630 | if (!port_str) { | |
4631 | sp = getservbyname("bgp", "tcp"); | |
4632 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
4633 | } else { | |
4634 | port = strtoul(port_str, NULL, 10); | |
4635 | } | |
718e3744 | 4636 | |
d62a17ae | 4637 | peer_port_set(peer, port); |
718e3744 | 4638 | |
d62a17ae | 4639 | return CMD_SUCCESS; |
718e3744 | 4640 | } |
4641 | ||
f418446b | 4642 | /* Set specified peer's BGP port. */ |
718e3744 | 4643 | DEFUN (neighbor_port, |
4644 | neighbor_port_cmd, | |
9ccf14f7 | 4645 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4646 | NEIGHBOR_STR |
4647 | NEIGHBOR_ADDR_STR | |
4648 | "Neighbor's BGP port\n" | |
4649 | "TCP port number\n") | |
4650 | { | |
d62a17ae | 4651 | int idx_ip = 1; |
4652 | int idx_number = 3; | |
4653 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
4654 | argv[idx_number]->arg); | |
718e3744 | 4655 | } |
4656 | ||
4657 | DEFUN (no_neighbor_port, | |
4658 | no_neighbor_port_cmd, | |
9ccf14f7 | 4659 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4660 | NO_STR |
4661 | NEIGHBOR_STR | |
4662 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4663 | "Neighbor's BGP port\n" |
4664 | "TCP port number\n") | |
718e3744 | 4665 | { |
d62a17ae | 4666 | int idx_ip = 2; |
4667 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4668 | } |
4669 | ||
6b0655a2 | 4670 | |
718e3744 | 4671 | /* neighbor weight. */ |
d62a17ae | 4672 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4673 | safi_t safi, const char *weight_str) | |
718e3744 | 4674 | { |
d62a17ae | 4675 | int ret; |
4676 | struct peer *peer; | |
4677 | unsigned long weight; | |
718e3744 | 4678 | |
d62a17ae | 4679 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4680 | if (!peer) | |
4681 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4682 | |
d62a17ae | 4683 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 4684 | |
d62a17ae | 4685 | ret = peer_weight_set(peer, afi, safi, weight); |
4686 | return bgp_vty_return(vty, ret); | |
718e3744 | 4687 | } |
4688 | ||
d62a17ae | 4689 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4690 | safi_t safi) | |
718e3744 | 4691 | { |
d62a17ae | 4692 | int ret; |
4693 | struct peer *peer; | |
718e3744 | 4694 | |
d62a17ae | 4695 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4696 | if (!peer) | |
4697 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4698 | |
d62a17ae | 4699 | ret = peer_weight_unset(peer, afi, safi); |
4700 | return bgp_vty_return(vty, ret); | |
718e3744 | 4701 | } |
4702 | ||
4703 | DEFUN (neighbor_weight, | |
4704 | neighbor_weight_cmd, | |
9ccf14f7 | 4705 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 4706 | NEIGHBOR_STR |
4707 | NEIGHBOR_ADDR_STR2 | |
4708 | "Set default weight for routes from this neighbor\n" | |
4709 | "default weight\n") | |
4710 | { | |
d62a17ae | 4711 | int idx_peer = 1; |
4712 | int idx_number = 3; | |
4713 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4714 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 4715 | } |
4716 | ||
d62a17ae | 4717 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
4718 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
4719 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4720 | "Set default weight for routes from this neighbor\n" | |
4721 | "default weight\n") | |
596c17ba | 4722 | |
718e3744 | 4723 | DEFUN (no_neighbor_weight, |
4724 | no_neighbor_weight_cmd, | |
9ccf14f7 | 4725 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 4726 | NO_STR |
4727 | NEIGHBOR_STR | |
4728 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4729 | "Set default weight for routes from this neighbor\n" |
4730 | "default weight\n") | |
718e3744 | 4731 | { |
d62a17ae | 4732 | int idx_peer = 2; |
4733 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
4734 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 4735 | } |
4736 | ||
d62a17ae | 4737 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
4738 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
4739 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4740 | "Set default weight for routes from this neighbor\n" | |
4741 | "default weight\n") | |
596c17ba | 4742 | |
6b0655a2 | 4743 | |
718e3744 | 4744 | /* Override capability negotiation. */ |
4745 | DEFUN (neighbor_override_capability, | |
4746 | neighbor_override_capability_cmd, | |
9ccf14f7 | 4747 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4748 | NEIGHBOR_STR |
4749 | NEIGHBOR_ADDR_STR2 | |
4750 | "Override capability negotiation result\n") | |
4751 | { | |
d62a17ae | 4752 | int idx_peer = 1; |
4753 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4754 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4755 | } |
4756 | ||
4757 | DEFUN (no_neighbor_override_capability, | |
4758 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 4759 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4760 | NO_STR |
4761 | NEIGHBOR_STR | |
4762 | NEIGHBOR_ADDR_STR2 | |
4763 | "Override capability negotiation result\n") | |
4764 | { | |
d62a17ae | 4765 | int idx_peer = 2; |
4766 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4767 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4768 | } |
6b0655a2 | 4769 | |
718e3744 | 4770 | DEFUN (neighbor_strict_capability, |
4771 | neighbor_strict_capability_cmd, | |
9ccf14f7 | 4772 | "neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4773 | NEIGHBOR_STR |
4774 | NEIGHBOR_ADDR_STR | |
4775 | "Strict capability negotiation match\n") | |
4776 | { | |
d62a17ae | 4777 | int idx_ip = 1; |
4778 | return peer_flag_set_vty(vty, argv[idx_ip]->arg, | |
4779 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4780 | } |
4781 | ||
4782 | DEFUN (no_neighbor_strict_capability, | |
4783 | no_neighbor_strict_capability_cmd, | |
9ccf14f7 | 4784 | "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4785 | NO_STR |
4786 | NEIGHBOR_STR | |
4787 | NEIGHBOR_ADDR_STR | |
4788 | "Strict capability negotiation match\n") | |
4789 | { | |
d62a17ae | 4790 | int idx_ip = 2; |
4791 | return peer_flag_unset_vty(vty, argv[idx_ip]->arg, | |
4792 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4793 | } |
6b0655a2 | 4794 | |
d62a17ae | 4795 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
4796 | const char *keep_str, const char *hold_str) | |
718e3744 | 4797 | { |
d62a17ae | 4798 | int ret; |
4799 | struct peer *peer; | |
4800 | u_int32_t keepalive; | |
4801 | u_int32_t holdtime; | |
718e3744 | 4802 | |
d62a17ae | 4803 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4804 | if (!peer) | |
4805 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4806 | |
d62a17ae | 4807 | keepalive = strtoul(keep_str, NULL, 10); |
4808 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 4809 | |
d62a17ae | 4810 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 4811 | |
d62a17ae | 4812 | return bgp_vty_return(vty, ret); |
718e3744 | 4813 | } |
6b0655a2 | 4814 | |
d62a17ae | 4815 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4816 | { |
d62a17ae | 4817 | int ret; |
4818 | struct peer *peer; | |
718e3744 | 4819 | |
d62a17ae | 4820 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4821 | if (!peer) | |
4822 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4823 | |
d62a17ae | 4824 | ret = peer_timers_unset(peer); |
718e3744 | 4825 | |
d62a17ae | 4826 | return bgp_vty_return(vty, ret); |
718e3744 | 4827 | } |
4828 | ||
4829 | DEFUN (neighbor_timers, | |
4830 | neighbor_timers_cmd, | |
9ccf14f7 | 4831 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 4832 | NEIGHBOR_STR |
4833 | NEIGHBOR_ADDR_STR2 | |
4834 | "BGP per neighbor timers\n" | |
4835 | "Keepalive interval\n" | |
4836 | "Holdtime\n") | |
4837 | { | |
d62a17ae | 4838 | int idx_peer = 1; |
4839 | int idx_number = 3; | |
4840 | int idx_number_2 = 4; | |
4841 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
4842 | argv[idx_number]->arg, | |
4843 | argv[idx_number_2]->arg); | |
718e3744 | 4844 | } |
4845 | ||
4846 | DEFUN (no_neighbor_timers, | |
4847 | no_neighbor_timers_cmd, | |
9ccf14f7 | 4848 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 4849 | NO_STR |
4850 | NEIGHBOR_STR | |
4851 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4852 | "BGP per neighbor timers\n" |
4853 | "Keepalive interval\n" | |
4854 | "Holdtime\n") | |
718e3744 | 4855 | { |
d62a17ae | 4856 | int idx_peer = 2; |
4857 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4858 | } |
6b0655a2 | 4859 | |
813d4307 | 4860 | |
d62a17ae | 4861 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
4862 | const char *time_str) | |
718e3744 | 4863 | { |
d62a17ae | 4864 | int ret; |
4865 | struct peer *peer; | |
4866 | u_int32_t connect; | |
718e3744 | 4867 | |
d62a17ae | 4868 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4869 | if (!peer) | |
4870 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4871 | |
d62a17ae | 4872 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 4873 | |
d62a17ae | 4874 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 4875 | |
d62a17ae | 4876 | return bgp_vty_return(vty, ret); |
718e3744 | 4877 | } |
4878 | ||
d62a17ae | 4879 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4880 | { |
d62a17ae | 4881 | int ret; |
4882 | struct peer *peer; | |
718e3744 | 4883 | |
d62a17ae | 4884 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4885 | if (!peer) | |
4886 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4887 | |
d62a17ae | 4888 | ret = peer_timers_connect_unset(peer); |
718e3744 | 4889 | |
d62a17ae | 4890 | return bgp_vty_return(vty, ret); |
718e3744 | 4891 | } |
4892 | ||
4893 | DEFUN (neighbor_timers_connect, | |
4894 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 4895 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 4896 | NEIGHBOR_STR |
966f821c | 4897 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4898 | "BGP per neighbor timers\n" |
4899 | "BGP connect timer\n" | |
4900 | "Connect timer\n") | |
4901 | { | |
d62a17ae | 4902 | int idx_peer = 1; |
4903 | int idx_number = 4; | |
4904 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
4905 | argv[idx_number]->arg); | |
718e3744 | 4906 | } |
4907 | ||
4908 | DEFUN (no_neighbor_timers_connect, | |
4909 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 4910 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 4911 | NO_STR |
4912 | NEIGHBOR_STR | |
966f821c | 4913 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4914 | "BGP per neighbor timers\n" |
8334fd5a DW |
4915 | "BGP connect timer\n" |
4916 | "Connect timer\n") | |
718e3744 | 4917 | { |
d62a17ae | 4918 | int idx_peer = 2; |
4919 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4920 | } |
4921 | ||
6b0655a2 | 4922 | |
d62a17ae | 4923 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
4924 | const char *time_str, int set) | |
718e3744 | 4925 | { |
d62a17ae | 4926 | int ret; |
4927 | struct peer *peer; | |
4928 | u_int32_t routeadv = 0; | |
718e3744 | 4929 | |
d62a17ae | 4930 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4931 | if (!peer) | |
4932 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4933 | |
d62a17ae | 4934 | if (time_str) |
4935 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 4936 | |
d62a17ae | 4937 | if (set) |
4938 | ret = peer_advertise_interval_set(peer, routeadv); | |
4939 | else | |
4940 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 4941 | |
d62a17ae | 4942 | return bgp_vty_return(vty, ret); |
718e3744 | 4943 | } |
4944 | ||
4945 | DEFUN (neighbor_advertise_interval, | |
4946 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4947 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 4948 | NEIGHBOR_STR |
966f821c | 4949 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4950 | "Minimum interval between sending BGP routing updates\n" |
4951 | "time in seconds\n") | |
4952 | { | |
d62a17ae | 4953 | int idx_peer = 1; |
4954 | int idx_number = 3; | |
4955 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
4956 | argv[idx_number]->arg, 1); | |
718e3744 | 4957 | } |
4958 | ||
4959 | DEFUN (no_neighbor_advertise_interval, | |
4960 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 4961 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 4962 | NO_STR |
4963 | NEIGHBOR_STR | |
966f821c | 4964 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
4965 | "Minimum interval between sending BGP routing updates\n" |
4966 | "time in seconds\n") | |
718e3744 | 4967 | { |
d62a17ae | 4968 | int idx_peer = 2; |
4969 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 4970 | } |
4971 | ||
6b0655a2 | 4972 | |
518f0eb1 DS |
4973 | /* Time to wait before processing route-map updates */ |
4974 | DEFUN (bgp_set_route_map_delay_timer, | |
4975 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 4976 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
4977 | SET_STR |
4978 | "BGP route-map delay timer\n" | |
4979 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 4980 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 4981 | { |
d62a17ae | 4982 | int idx_number = 3; |
4983 | u_int32_t rmap_delay_timer; | |
4984 | ||
4985 | if (argv[idx_number]->arg) { | |
4986 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
4987 | bm->rmap_update_timer = rmap_delay_timer; | |
4988 | ||
4989 | /* if the dynamic update handling is being disabled, and a timer | |
4990 | * is | |
4991 | * running, stop the timer and act as if the timer has already | |
4992 | * fired. | |
4993 | */ | |
4994 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
4995 | BGP_TIMER_OFF(bm->t_rmap_update); | |
4996 | thread_execute(bm->master, bgp_route_map_update_timer, | |
4997 | NULL, 0); | |
4998 | } | |
4999 | return CMD_SUCCESS; | |
5000 | } else { | |
5001 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5002 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5003 | } |
518f0eb1 DS |
5004 | } |
5005 | ||
5006 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5007 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5008 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5009 | NO_STR |
3a2d747c | 5010 | BGP_STR |
518f0eb1 | 5011 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5012 | "Reset to default time to wait for processing route-map changes\n" |
5013 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5014 | { |
518f0eb1 | 5015 | |
d62a17ae | 5016 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 5017 | |
d62a17ae | 5018 | return CMD_SUCCESS; |
518f0eb1 DS |
5019 | } |
5020 | ||
f414725f | 5021 | |
718e3744 | 5022 | /* neighbor interface */ |
d62a17ae | 5023 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
5024 | const char *str) | |
718e3744 | 5025 | { |
d62a17ae | 5026 | struct peer *peer; |
718e3744 | 5027 | |
d62a17ae | 5028 | peer = peer_lookup_vty(vty, ip_str); |
5029 | if (!peer || peer->conf_if) { | |
5030 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
5031 | return CMD_WARNING_CONFIG_FAILED; | |
5032 | } | |
718e3744 | 5033 | |
d62a17ae | 5034 | if (str) |
5035 | peer_interface_set(peer, str); | |
5036 | else | |
5037 | peer_interface_unset(peer); | |
718e3744 | 5038 | |
d62a17ae | 5039 | return CMD_SUCCESS; |
718e3744 | 5040 | } |
5041 | ||
5042 | DEFUN (neighbor_interface, | |
5043 | neighbor_interface_cmd, | |
9ccf14f7 | 5044 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5045 | NEIGHBOR_STR |
5046 | NEIGHBOR_ADDR_STR | |
5047 | "Interface\n" | |
5048 | "Interface name\n") | |
5049 | { | |
d62a17ae | 5050 | int idx_ip = 1; |
5051 | int idx_word = 3; | |
5052 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 5053 | } |
5054 | ||
5055 | DEFUN (no_neighbor_interface, | |
5056 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5057 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5058 | NO_STR |
5059 | NEIGHBOR_STR | |
16cedbb0 | 5060 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5061 | "Interface\n" |
5062 | "Interface name\n") | |
5063 | { | |
d62a17ae | 5064 | int idx_peer = 2; |
5065 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5066 | } |
6b0655a2 | 5067 | |
718e3744 | 5068 | DEFUN (neighbor_distribute_list, |
5069 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5070 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5071 | NEIGHBOR_STR |
5072 | NEIGHBOR_ADDR_STR2 | |
5073 | "Filter updates to/from this neighbor\n" | |
5074 | "IP access-list number\n" | |
5075 | "IP access-list number (expanded range)\n" | |
5076 | "IP Access-list name\n" | |
5077 | "Filter incoming updates\n" | |
5078 | "Filter outgoing updates\n") | |
5079 | { | |
d62a17ae | 5080 | int idx_peer = 1; |
5081 | int idx_acl = 3; | |
5082 | int direct, ret; | |
5083 | struct peer *peer; | |
a8206004 | 5084 | |
d62a17ae | 5085 | const char *pstr = argv[idx_peer]->arg; |
5086 | const char *acl = argv[idx_acl]->arg; | |
5087 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5088 | |
d62a17ae | 5089 | peer = peer_and_group_lookup_vty(vty, pstr); |
5090 | if (!peer) | |
5091 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5092 | |
d62a17ae | 5093 | /* Check filter direction. */ |
5094 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5095 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5096 | direct, acl); | |
a8206004 | 5097 | |
d62a17ae | 5098 | return bgp_vty_return(vty, ret); |
718e3744 | 5099 | } |
5100 | ||
d62a17ae | 5101 | ALIAS_HIDDEN( |
5102 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
5103 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5104 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5105 | "Filter updates to/from this neighbor\n" | |
5106 | "IP access-list number\n" | |
5107 | "IP access-list number (expanded range)\n" | |
5108 | "IP Access-list name\n" | |
5109 | "Filter incoming updates\n" | |
5110 | "Filter outgoing updates\n") | |
596c17ba | 5111 | |
718e3744 | 5112 | DEFUN (no_neighbor_distribute_list, |
5113 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5114 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5115 | NO_STR |
5116 | NEIGHBOR_STR | |
5117 | NEIGHBOR_ADDR_STR2 | |
5118 | "Filter updates to/from this neighbor\n" | |
5119 | "IP access-list number\n" | |
5120 | "IP access-list number (expanded range)\n" | |
5121 | "IP Access-list name\n" | |
5122 | "Filter incoming updates\n" | |
5123 | "Filter outgoing updates\n") | |
5124 | { | |
d62a17ae | 5125 | int idx_peer = 2; |
5126 | int direct, ret; | |
5127 | struct peer *peer; | |
a8206004 | 5128 | |
d62a17ae | 5129 | const char *pstr = argv[idx_peer]->arg; |
5130 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5131 | |
d62a17ae | 5132 | peer = peer_and_group_lookup_vty(vty, pstr); |
5133 | if (!peer) | |
5134 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5135 | |
d62a17ae | 5136 | /* Check filter direction. */ |
5137 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5138 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5139 | direct); | |
a8206004 | 5140 | |
d62a17ae | 5141 | return bgp_vty_return(vty, ret); |
718e3744 | 5142 | } |
6b0655a2 | 5143 | |
d62a17ae | 5144 | ALIAS_HIDDEN( |
5145 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
5146 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5147 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5148 | "Filter updates to/from this neighbor\n" | |
5149 | "IP access-list number\n" | |
5150 | "IP access-list number (expanded range)\n" | |
5151 | "IP Access-list name\n" | |
5152 | "Filter incoming updates\n" | |
5153 | "Filter outgoing updates\n") | |
596c17ba | 5154 | |
718e3744 | 5155 | /* Set prefix list to the peer. */ |
d62a17ae | 5156 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
5157 | afi_t afi, safi_t safi, | |
5158 | const char *name_str, | |
5159 | const char *direct_str) | |
718e3744 | 5160 | { |
d62a17ae | 5161 | int ret; |
5162 | struct peer *peer; | |
5163 | int direct = FILTER_IN; | |
718e3744 | 5164 | |
d62a17ae | 5165 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5166 | if (!peer) | |
5167 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5168 | |
d62a17ae | 5169 | /* Check filter direction. */ |
5170 | if (strncmp(direct_str, "i", 1) == 0) | |
5171 | direct = FILTER_IN; | |
5172 | else if (strncmp(direct_str, "o", 1) == 0) | |
5173 | direct = FILTER_OUT; | |
718e3744 | 5174 | |
d62a17ae | 5175 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 5176 | |
d62a17ae | 5177 | return bgp_vty_return(vty, ret); |
718e3744 | 5178 | } |
5179 | ||
d62a17ae | 5180 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
5181 | afi_t afi, safi_t safi, | |
5182 | const char *direct_str) | |
718e3744 | 5183 | { |
d62a17ae | 5184 | int ret; |
5185 | struct peer *peer; | |
5186 | int direct = FILTER_IN; | |
718e3744 | 5187 | |
d62a17ae | 5188 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5189 | if (!peer) | |
5190 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 5191 | |
d62a17ae | 5192 | /* Check filter direction. */ |
5193 | if (strncmp(direct_str, "i", 1) == 0) | |
5194 | direct = FILTER_IN; | |
5195 | else if (strncmp(direct_str, "o", 1) == 0) | |
5196 | direct = FILTER_OUT; | |
718e3744 | 5197 | |
d62a17ae | 5198 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 5199 | |
d62a17ae | 5200 | return bgp_vty_return(vty, ret); |
718e3744 | 5201 | } |
5202 | ||
5203 | DEFUN (neighbor_prefix_list, | |
5204 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5205 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5206 | NEIGHBOR_STR |
5207 | NEIGHBOR_ADDR_STR2 | |
5208 | "Filter updates to/from this neighbor\n" | |
5209 | "Name of a prefix list\n" | |
5210 | "Filter incoming updates\n" | |
5211 | "Filter outgoing updates\n") | |
5212 | { | |
d62a17ae | 5213 | int idx_peer = 1; |
5214 | int idx_word = 3; | |
5215 | int idx_in_out = 4; | |
5216 | return peer_prefix_list_set_vty( | |
5217 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5218 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5219 | } |
5220 | ||
d62a17ae | 5221 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
5222 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5223 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5224 | "Filter updates to/from this neighbor\n" | |
5225 | "Name of a prefix list\n" | |
5226 | "Filter incoming updates\n" | |
5227 | "Filter outgoing updates\n") | |
596c17ba | 5228 | |
718e3744 | 5229 | DEFUN (no_neighbor_prefix_list, |
5230 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5231 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5232 | NO_STR |
5233 | NEIGHBOR_STR | |
5234 | NEIGHBOR_ADDR_STR2 | |
5235 | "Filter updates to/from this neighbor\n" | |
5236 | "Name of a prefix list\n" | |
5237 | "Filter incoming updates\n" | |
5238 | "Filter outgoing updates\n") | |
5239 | { | |
d62a17ae | 5240 | int idx_peer = 2; |
5241 | int idx_in_out = 5; | |
5242 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
5243 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5244 | argv[idx_in_out]->arg); | |
718e3744 | 5245 | } |
6b0655a2 | 5246 | |
d62a17ae | 5247 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
5248 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5249 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5250 | "Filter updates to/from this neighbor\n" | |
5251 | "Name of a prefix list\n" | |
5252 | "Filter incoming updates\n" | |
5253 | "Filter outgoing updates\n") | |
596c17ba | 5254 | |
d62a17ae | 5255 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5256 | safi_t safi, const char *name_str, | |
5257 | const char *direct_str) | |
718e3744 | 5258 | { |
d62a17ae | 5259 | int ret; |
5260 | struct peer *peer; | |
5261 | int direct = FILTER_IN; | |
718e3744 | 5262 | |
d62a17ae | 5263 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5264 | if (!peer) | |
5265 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5266 | |
d62a17ae | 5267 | /* Check filter direction. */ |
5268 | if (strncmp(direct_str, "i", 1) == 0) | |
5269 | direct = FILTER_IN; | |
5270 | else if (strncmp(direct_str, "o", 1) == 0) | |
5271 | direct = FILTER_OUT; | |
718e3744 | 5272 | |
d62a17ae | 5273 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 5274 | |
d62a17ae | 5275 | return bgp_vty_return(vty, ret); |
718e3744 | 5276 | } |
5277 | ||
d62a17ae | 5278 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5279 | safi_t safi, const char *direct_str) | |
718e3744 | 5280 | { |
d62a17ae | 5281 | int ret; |
5282 | struct peer *peer; | |
5283 | int direct = FILTER_IN; | |
718e3744 | 5284 | |
d62a17ae | 5285 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5286 | if (!peer) | |
5287 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5288 | |
d62a17ae | 5289 | /* Check filter direction. */ |
5290 | if (strncmp(direct_str, "i", 1) == 0) | |
5291 | direct = FILTER_IN; | |
5292 | else if (strncmp(direct_str, "o", 1) == 0) | |
5293 | direct = FILTER_OUT; | |
718e3744 | 5294 | |
d62a17ae | 5295 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 5296 | |
d62a17ae | 5297 | return bgp_vty_return(vty, ret); |
718e3744 | 5298 | } |
5299 | ||
5300 | DEFUN (neighbor_filter_list, | |
5301 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5302 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5303 | NEIGHBOR_STR |
5304 | NEIGHBOR_ADDR_STR2 | |
5305 | "Establish BGP filters\n" | |
5306 | "AS path access-list name\n" | |
5307 | "Filter incoming routes\n" | |
5308 | "Filter outgoing routes\n") | |
5309 | { | |
d62a17ae | 5310 | int idx_peer = 1; |
5311 | int idx_word = 3; | |
5312 | int idx_in_out = 4; | |
5313 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5314 | bgp_node_safi(vty), argv[idx_word]->arg, | |
5315 | argv[idx_in_out]->arg); | |
718e3744 | 5316 | } |
5317 | ||
d62a17ae | 5318 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
5319 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5320 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5321 | "Establish BGP filters\n" | |
5322 | "AS path access-list name\n" | |
5323 | "Filter incoming routes\n" | |
5324 | "Filter outgoing routes\n") | |
596c17ba | 5325 | |
718e3744 | 5326 | DEFUN (no_neighbor_filter_list, |
5327 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5328 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5329 | NO_STR |
5330 | NEIGHBOR_STR | |
5331 | NEIGHBOR_ADDR_STR2 | |
5332 | "Establish BGP filters\n" | |
5333 | "AS path access-list name\n" | |
5334 | "Filter incoming routes\n" | |
5335 | "Filter outgoing routes\n") | |
5336 | { | |
d62a17ae | 5337 | int idx_peer = 2; |
5338 | int idx_in_out = 5; | |
5339 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
5340 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5341 | argv[idx_in_out]->arg); | |
718e3744 | 5342 | } |
6b0655a2 | 5343 | |
d62a17ae | 5344 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
5345 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5346 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5347 | "Establish BGP filters\n" | |
5348 | "AS path access-list name\n" | |
5349 | "Filter incoming routes\n" | |
5350 | "Filter outgoing routes\n") | |
596c17ba | 5351 | |
718e3744 | 5352 | /* Set route-map to the peer. */ |
d62a17ae | 5353 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
5354 | afi_t afi, safi_t safi, const char *name_str, | |
5355 | const char *direct_str) | |
718e3744 | 5356 | { |
d62a17ae | 5357 | int ret; |
5358 | struct peer *peer; | |
5359 | int direct = RMAP_IN; | |
718e3744 | 5360 | |
d62a17ae | 5361 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5362 | if (!peer) | |
5363 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5364 | |
d62a17ae | 5365 | /* Check filter direction. */ |
5366 | if (strncmp(direct_str, "in", 2) == 0) | |
5367 | direct = RMAP_IN; | |
5368 | else if (strncmp(direct_str, "o", 1) == 0) | |
5369 | direct = RMAP_OUT; | |
718e3744 | 5370 | |
d62a17ae | 5371 | ret = peer_route_map_set(peer, afi, safi, direct, name_str); |
718e3744 | 5372 | |
d62a17ae | 5373 | return bgp_vty_return(vty, ret); |
718e3744 | 5374 | } |
5375 | ||
d62a17ae | 5376 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
5377 | afi_t afi, safi_t safi, | |
5378 | const char *direct_str) | |
718e3744 | 5379 | { |
d62a17ae | 5380 | int ret; |
5381 | struct peer *peer; | |
5382 | int direct = RMAP_IN; | |
718e3744 | 5383 | |
d62a17ae | 5384 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5385 | if (!peer) | |
5386 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5387 | |
d62a17ae | 5388 | /* Check filter direction. */ |
5389 | if (strncmp(direct_str, "in", 2) == 0) | |
5390 | direct = RMAP_IN; | |
5391 | else if (strncmp(direct_str, "o", 1) == 0) | |
5392 | direct = RMAP_OUT; | |
718e3744 | 5393 | |
d62a17ae | 5394 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 5395 | |
d62a17ae | 5396 | return bgp_vty_return(vty, ret); |
718e3744 | 5397 | } |
5398 | ||
5399 | DEFUN (neighbor_route_map, | |
5400 | neighbor_route_map_cmd, | |
9ccf14f7 | 5401 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5402 | NEIGHBOR_STR |
5403 | NEIGHBOR_ADDR_STR2 | |
5404 | "Apply route map to neighbor\n" | |
5405 | "Name of route map\n" | |
5406 | "Apply map to incoming routes\n" | |
2a3d5731 | 5407 | "Apply map to outbound routes\n") |
718e3744 | 5408 | { |
d62a17ae | 5409 | int idx_peer = 1; |
5410 | int idx_word = 3; | |
5411 | int idx_in_out = 4; | |
5412 | return peer_route_map_set_vty( | |
5413 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5414 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5415 | } |
5416 | ||
d62a17ae | 5417 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
5418 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5419 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5420 | "Apply route map to neighbor\n" | |
5421 | "Name of route map\n" | |
5422 | "Apply map to incoming routes\n" | |
5423 | "Apply map to outbound routes\n") | |
596c17ba | 5424 | |
718e3744 | 5425 | DEFUN (no_neighbor_route_map, |
5426 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5427 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5428 | NO_STR |
5429 | NEIGHBOR_STR | |
5430 | NEIGHBOR_ADDR_STR2 | |
5431 | "Apply route map to neighbor\n" | |
5432 | "Name of route map\n" | |
5433 | "Apply map to incoming routes\n" | |
2a3d5731 | 5434 | "Apply map to outbound routes\n") |
718e3744 | 5435 | { |
d62a17ae | 5436 | int idx_peer = 2; |
5437 | int idx_in_out = 5; | |
5438 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
5439 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5440 | argv[idx_in_out]->arg); | |
718e3744 | 5441 | } |
6b0655a2 | 5442 | |
d62a17ae | 5443 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
5444 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5445 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5446 | "Apply route map to neighbor\n" | |
5447 | "Name of route map\n" | |
5448 | "Apply map to incoming routes\n" | |
5449 | "Apply map to outbound routes\n") | |
596c17ba | 5450 | |
718e3744 | 5451 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 5452 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
5453 | afi_t afi, safi_t safi, | |
5454 | const char *name_str) | |
718e3744 | 5455 | { |
d62a17ae | 5456 | int ret; |
5457 | struct peer *peer; | |
718e3744 | 5458 | |
d62a17ae | 5459 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5460 | if (!peer) | |
5461 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5462 | |
d62a17ae | 5463 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str); |
718e3744 | 5464 | |
d62a17ae | 5465 | return bgp_vty_return(vty, ret); |
718e3744 | 5466 | } |
5467 | ||
5468 | /* Unset route-map from the peer. */ | |
d62a17ae | 5469 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
5470 | afi_t afi, safi_t safi) | |
718e3744 | 5471 | { |
d62a17ae | 5472 | int ret; |
5473 | struct peer *peer; | |
718e3744 | 5474 | |
d62a17ae | 5475 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5476 | if (!peer) | |
5477 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5478 | |
d62a17ae | 5479 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 5480 | |
d62a17ae | 5481 | return bgp_vty_return(vty, ret); |
718e3744 | 5482 | } |
5483 | ||
5484 | DEFUN (neighbor_unsuppress_map, | |
5485 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5486 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5487 | NEIGHBOR_STR |
5488 | NEIGHBOR_ADDR_STR2 | |
5489 | "Route-map to selectively unsuppress suppressed routes\n" | |
5490 | "Name of route map\n") | |
5491 | { | |
d62a17ae | 5492 | int idx_peer = 1; |
5493 | int idx_word = 3; | |
5494 | return peer_unsuppress_map_set_vty( | |
5495 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5496 | argv[idx_word]->arg); | |
718e3744 | 5497 | } |
5498 | ||
d62a17ae | 5499 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
5500 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5501 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5502 | "Route-map to selectively unsuppress suppressed routes\n" | |
5503 | "Name of route map\n") | |
596c17ba | 5504 | |
718e3744 | 5505 | DEFUN (no_neighbor_unsuppress_map, |
5506 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5507 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5508 | NO_STR |
5509 | NEIGHBOR_STR | |
5510 | NEIGHBOR_ADDR_STR2 | |
5511 | "Route-map to selectively unsuppress suppressed routes\n" | |
5512 | "Name of route map\n") | |
5513 | { | |
d62a17ae | 5514 | int idx_peer = 2; |
5515 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
5516 | bgp_node_afi(vty), | |
5517 | bgp_node_safi(vty)); | |
718e3744 | 5518 | } |
6b0655a2 | 5519 | |
d62a17ae | 5520 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
5521 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5522 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5523 | "Route-map to selectively unsuppress suppressed routes\n" | |
5524 | "Name of route map\n") | |
596c17ba | 5525 | |
d62a17ae | 5526 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
5527 | afi_t afi, safi_t safi, | |
5528 | const char *num_str, | |
5529 | const char *threshold_str, int warning, | |
5530 | const char *restart_str) | |
718e3744 | 5531 | { |
d62a17ae | 5532 | int ret; |
5533 | struct peer *peer; | |
5534 | u_int32_t max; | |
5535 | u_char threshold; | |
5536 | u_int16_t restart; | |
718e3744 | 5537 | |
d62a17ae | 5538 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5539 | if (!peer) | |
5540 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5541 | |
d62a17ae | 5542 | max = strtoul(num_str, NULL, 10); |
5543 | if (threshold_str) | |
5544 | threshold = atoi(threshold_str); | |
5545 | else | |
5546 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5547 | |
d62a17ae | 5548 | if (restart_str) |
5549 | restart = atoi(restart_str); | |
5550 | else | |
5551 | restart = 0; | |
0a486e5f | 5552 | |
d62a17ae | 5553 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
5554 | restart); | |
718e3744 | 5555 | |
d62a17ae | 5556 | return bgp_vty_return(vty, ret); |
718e3744 | 5557 | } |
5558 | ||
d62a17ae | 5559 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
5560 | afi_t afi, safi_t safi) | |
718e3744 | 5561 | { |
d62a17ae | 5562 | int ret; |
5563 | struct peer *peer; | |
718e3744 | 5564 | |
d62a17ae | 5565 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5566 | if (!peer) | |
5567 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5568 | |
d62a17ae | 5569 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 5570 | |
d62a17ae | 5571 | return bgp_vty_return(vty, ret); |
718e3744 | 5572 | } |
5573 | ||
5574 | /* Maximum number of prefix configuration. prefix count is different | |
5575 | for each peer configuration. So this configuration can be set for | |
5576 | each peer configuration. */ | |
5577 | DEFUN (neighbor_maximum_prefix, | |
5578 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5579 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5580 | NEIGHBOR_STR |
5581 | NEIGHBOR_ADDR_STR2 | |
5582 | "Maximum number of prefix accept from this peer\n" | |
5583 | "maximum no. of prefix limit\n") | |
5584 | { | |
d62a17ae | 5585 | int idx_peer = 1; |
5586 | int idx_number = 3; | |
5587 | return peer_maximum_prefix_set_vty( | |
5588 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5589 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 5590 | } |
5591 | ||
d62a17ae | 5592 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
5593 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
5594 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5595 | "Maximum number of prefix accept from this peer\n" | |
5596 | "maximum no. of prefix limit\n") | |
596c17ba | 5597 | |
e0701b79 | 5598 | DEFUN (neighbor_maximum_prefix_threshold, |
5599 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5600 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5601 | NEIGHBOR_STR |
5602 | NEIGHBOR_ADDR_STR2 | |
5603 | "Maximum number of prefix accept from this peer\n" | |
5604 | "maximum no. of prefix limit\n" | |
5605 | "Threshold value (%) at which to generate a warning msg\n") | |
5606 | { | |
d62a17ae | 5607 | int idx_peer = 1; |
5608 | int idx_number = 3; | |
5609 | int idx_number_2 = 4; | |
5610 | return peer_maximum_prefix_set_vty( | |
5611 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5612 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 5613 | } |
e0701b79 | 5614 | |
d62a17ae | 5615 | ALIAS_HIDDEN( |
5616 | neighbor_maximum_prefix_threshold, | |
5617 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
5618 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
5619 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5620 | "Maximum number of prefix accept from this peer\n" | |
5621 | "maximum no. of prefix limit\n" | |
5622 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 5623 | |
718e3744 | 5624 | DEFUN (neighbor_maximum_prefix_warning, |
5625 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5626 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5627 | NEIGHBOR_STR |
5628 | NEIGHBOR_ADDR_STR2 | |
5629 | "Maximum number of prefix accept from this peer\n" | |
5630 | "maximum no. of prefix limit\n" | |
5631 | "Only give warning message when limit is exceeded\n") | |
5632 | { | |
d62a17ae | 5633 | int idx_peer = 1; |
5634 | int idx_number = 3; | |
5635 | return peer_maximum_prefix_set_vty( | |
5636 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5637 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 5638 | } |
5639 | ||
d62a17ae | 5640 | ALIAS_HIDDEN( |
5641 | neighbor_maximum_prefix_warning, | |
5642 | neighbor_maximum_prefix_warning_hidden_cmd, | |
5643 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
5644 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5645 | "Maximum number of prefix accept from this peer\n" | |
5646 | "maximum no. of prefix limit\n" | |
5647 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5648 | |
e0701b79 | 5649 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5650 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5651 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5652 | NEIGHBOR_STR |
5653 | NEIGHBOR_ADDR_STR2 | |
5654 | "Maximum number of prefix accept from this peer\n" | |
5655 | "maximum no. of prefix limit\n" | |
5656 | "Threshold value (%) at which to generate a warning msg\n" | |
5657 | "Only give warning message when limit is exceeded\n") | |
5658 | { | |
d62a17ae | 5659 | int idx_peer = 1; |
5660 | int idx_number = 3; | |
5661 | int idx_number_2 = 4; | |
5662 | return peer_maximum_prefix_set_vty( | |
5663 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5664 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5665 | } |
5666 | ||
d62a17ae | 5667 | ALIAS_HIDDEN( |
5668 | neighbor_maximum_prefix_threshold_warning, | |
5669 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
5670 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
5671 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5672 | "Maximum number of prefix accept from this peer\n" | |
5673 | "maximum no. of prefix limit\n" | |
5674 | "Threshold value (%) at which to generate a warning msg\n" | |
5675 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5676 | |
0a486e5f | 5677 | DEFUN (neighbor_maximum_prefix_restart, |
5678 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5679 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 5680 | NEIGHBOR_STR |
5681 | NEIGHBOR_ADDR_STR2 | |
5682 | "Maximum number of prefix accept from this peer\n" | |
5683 | "maximum no. of prefix limit\n" | |
5684 | "Restart bgp connection after limit is exceeded\n" | |
5685 | "Restart interval in minutes") | |
5686 | { | |
d62a17ae | 5687 | int idx_peer = 1; |
5688 | int idx_number = 3; | |
5689 | int idx_number_2 = 5; | |
5690 | return peer_maximum_prefix_set_vty( | |
5691 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5692 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 5693 | } |
5694 | ||
d62a17ae | 5695 | ALIAS_HIDDEN( |
5696 | neighbor_maximum_prefix_restart, | |
5697 | neighbor_maximum_prefix_restart_hidden_cmd, | |
5698 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
5699 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5700 | "Maximum number of prefix accept from this peer\n" | |
5701 | "maximum no. of prefix limit\n" | |
5702 | "Restart bgp connection after limit is exceeded\n" | |
5703 | "Restart interval in minutes") | |
596c17ba | 5704 | |
0a486e5f | 5705 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
5706 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 5707 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 5708 | NEIGHBOR_STR |
5709 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5710 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 5711 | "maximum no. of prefix limit\n" |
5712 | "Threshold value (%) at which to generate a warning msg\n" | |
5713 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5714 | "Restart interval in minutes\n") |
0a486e5f | 5715 | { |
d62a17ae | 5716 | int idx_peer = 1; |
5717 | int idx_number = 3; | |
5718 | int idx_number_2 = 4; | |
5719 | int idx_number_3 = 6; | |
5720 | return peer_maximum_prefix_set_vty( | |
5721 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5722 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
5723 | argv[idx_number_3]->arg); | |
5724 | } | |
5725 | ||
5726 | ALIAS_HIDDEN( | |
5727 | neighbor_maximum_prefix_threshold_restart, | |
5728 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
5729 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
5730 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5731 | "Maximum number of prefixes to accept from this peer\n" | |
5732 | "maximum no. of prefix limit\n" | |
5733 | "Threshold value (%) at which to generate a warning msg\n" | |
5734 | "Restart bgp connection after limit is exceeded\n" | |
5735 | "Restart interval in minutes\n") | |
596c17ba | 5736 | |
718e3744 | 5737 | DEFUN (no_neighbor_maximum_prefix, |
5738 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 5739 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 5740 | NO_STR |
5741 | NEIGHBOR_STR | |
5742 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5743 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
5744 | "maximum no. of prefix limit\n" |
5745 | "Threshold value (%) at which to generate a warning msg\n" | |
5746 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5747 | "Restart interval in minutes\n" |
31500417 | 5748 | "Only give warning message when limit is exceeded\n") |
718e3744 | 5749 | { |
d62a17ae | 5750 | int idx_peer = 2; |
5751 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
5752 | bgp_node_afi(vty), | |
5753 | bgp_node_safi(vty)); | |
718e3744 | 5754 | } |
e52702f2 | 5755 | |
d62a17ae | 5756 | ALIAS_HIDDEN( |
5757 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
5758 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
5759 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5760 | "Maximum number of prefixes to accept from this peer\n" | |
5761 | "maximum no. of prefix limit\n" | |
5762 | "Threshold value (%) at which to generate a warning msg\n" | |
5763 | "Restart bgp connection after limit is exceeded\n" | |
5764 | "Restart interval in minutes\n" | |
5765 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5766 | |
718e3744 | 5767 | |
718e3744 | 5768 | /* "neighbor allowas-in" */ |
5769 | DEFUN (neighbor_allowas_in, | |
5770 | neighbor_allowas_in_cmd, | |
fd8503f5 | 5771 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5772 | NEIGHBOR_STR |
5773 | NEIGHBOR_ADDR_STR2 | |
31500417 | 5774 | "Accept as-path with my AS present in it\n" |
fd8503f5 QY |
5775 | "Number of occurances of AS number\n" |
5776 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5777 | { |
d62a17ae | 5778 | int idx_peer = 1; |
5779 | int idx_number_origin = 3; | |
5780 | int ret; | |
5781 | int origin = 0; | |
5782 | struct peer *peer; | |
5783 | int allow_num = 0; | |
5784 | ||
5785 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5786 | if (!peer) | |
5787 | return CMD_WARNING_CONFIG_FAILED; | |
5788 | ||
5789 | if (argc <= idx_number_origin) | |
5790 | allow_num = 3; | |
5791 | else { | |
5792 | if (argv[idx_number_origin]->type == WORD_TKN) | |
5793 | origin = 1; | |
5794 | else | |
5795 | allow_num = atoi(argv[idx_number_origin]->arg); | |
5796 | } | |
5797 | ||
5798 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5799 | allow_num, origin); | |
5800 | ||
5801 | return bgp_vty_return(vty, ret); | |
5802 | } | |
5803 | ||
5804 | ALIAS_HIDDEN( | |
5805 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
5806 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
5807 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5808 | "Accept as-path with my AS present in it\n" | |
5809 | "Number of occurances of AS number\n" | |
5810 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
596c17ba | 5811 | |
718e3744 | 5812 | DEFUN (no_neighbor_allowas_in, |
5813 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 5814 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5815 | NO_STR |
5816 | NEIGHBOR_STR | |
5817 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 5818 | "allow local ASN appears in aspath attribute\n" |
fd8503f5 QY |
5819 | "Number of occurances of AS number\n" |
5820 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5821 | { |
d62a17ae | 5822 | int idx_peer = 2; |
5823 | int ret; | |
5824 | struct peer *peer; | |
718e3744 | 5825 | |
d62a17ae | 5826 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5827 | if (!peer) | |
5828 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5829 | |
d62a17ae | 5830 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
5831 | bgp_node_safi(vty)); | |
718e3744 | 5832 | |
d62a17ae | 5833 | return bgp_vty_return(vty, ret); |
718e3744 | 5834 | } |
6b0655a2 | 5835 | |
d62a17ae | 5836 | ALIAS_HIDDEN( |
5837 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
5838 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
5839 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5840 | "allow local ASN appears in aspath attribute\n" | |
5841 | "Number of occurances of AS number\n" | |
5842 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
596c17ba | 5843 | |
fa411a21 NH |
5844 | DEFUN (neighbor_ttl_security, |
5845 | neighbor_ttl_security_cmd, | |
9ccf14f7 | 5846 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5847 | NEIGHBOR_STR |
5848 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5849 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
5850 | "Specify the maximum number of hops to the BGP peer\n" |
5851 | "Number of hops to BGP peer\n") | |
fa411a21 | 5852 | { |
d62a17ae | 5853 | int idx_peer = 1; |
5854 | int idx_number = 4; | |
5855 | struct peer *peer; | |
5856 | int gtsm_hops; | |
5857 | ||
5858 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5859 | if (!peer) | |
5860 | return CMD_WARNING_CONFIG_FAILED; | |
5861 | ||
5862 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
5863 | ||
5864 | /* | |
5865 | * If 'neighbor swpX', then this is for directly connected peers, | |
5866 | * we should not accept a ttl-security hops value greater than 1. | |
5867 | */ | |
5868 | if (peer->conf_if && (gtsm_hops > 1)) { | |
5869 | vty_out(vty, | |
5870 | "%s is directly connected peer, hops cannot exceed 1\n", | |
5871 | argv[idx_peer]->arg); | |
5872 | return CMD_WARNING_CONFIG_FAILED; | |
5873 | } | |
8cdabf90 | 5874 | |
d62a17ae | 5875 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
5876 | } |
5877 | ||
5878 | DEFUN (no_neighbor_ttl_security, | |
5879 | no_neighbor_ttl_security_cmd, | |
9ccf14f7 | 5880 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
5881 | NO_STR |
5882 | NEIGHBOR_STR | |
5883 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5884 | "BGP ttl-security parameters\n" |
3a2d747c QY |
5885 | "Specify the maximum number of hops to the BGP peer\n" |
5886 | "Number of hops to BGP peer\n") | |
fa411a21 | 5887 | { |
d62a17ae | 5888 | int idx_peer = 2; |
5889 | struct peer *peer; | |
fa411a21 | 5890 | |
d62a17ae | 5891 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5892 | if (!peer) | |
5893 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 5894 | |
d62a17ae | 5895 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 5896 | } |
6b0655a2 | 5897 | |
adbac85e DW |
5898 | DEFUN (neighbor_addpath_tx_all_paths, |
5899 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5900 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5901 | NEIGHBOR_STR |
5902 | NEIGHBOR_ADDR_STR2 | |
5903 | "Use addpath to advertise all paths to a neighbor\n") | |
5904 | { | |
d62a17ae | 5905 | int idx_peer = 1; |
5906 | struct peer *peer; | |
adbac85e | 5907 | |
d62a17ae | 5908 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5909 | if (!peer) | |
5910 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 5911 | |
d62a17ae | 5912 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5913 | bgp_node_safi(vty), | |
5914 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
adbac85e DW |
5915 | } |
5916 | ||
d62a17ae | 5917 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
5918 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
5919 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
5920 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5921 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 5922 | |
adbac85e DW |
5923 | DEFUN (no_neighbor_addpath_tx_all_paths, |
5924 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 5925 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
5926 | NO_STR |
5927 | NEIGHBOR_STR | |
5928 | NEIGHBOR_ADDR_STR2 | |
5929 | "Use addpath to advertise all paths to a neighbor\n") | |
5930 | { | |
d62a17ae | 5931 | int idx_peer = 2; |
5932 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5933 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5934 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
adbac85e DW |
5935 | } |
5936 | ||
d62a17ae | 5937 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
5938 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
5939 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
5940 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5941 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 5942 | |
06370dac DW |
5943 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
5944 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5945 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5946 | NEIGHBOR_STR |
5947 | NEIGHBOR_ADDR_STR2 | |
5948 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5949 | { | |
d62a17ae | 5950 | int idx_peer = 1; |
5951 | struct peer *peer; | |
06370dac | 5952 | |
d62a17ae | 5953 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
5954 | if (!peer) | |
5955 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 5956 | |
d62a17ae | 5957 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
5958 | bgp_node_safi(vty), | |
5959 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
06370dac DW |
5960 | } |
5961 | ||
d62a17ae | 5962 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
5963 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
5964 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
5965 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5966 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 5967 | |
06370dac DW |
5968 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
5969 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 5970 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
5971 | NO_STR |
5972 | NEIGHBOR_STR | |
5973 | NEIGHBOR_ADDR_STR2 | |
5974 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
5975 | { | |
d62a17ae | 5976 | int idx_peer = 2; |
5977 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5978 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5979 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
06370dac DW |
5980 | } |
5981 | ||
d62a17ae | 5982 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
5983 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
5984 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
5985 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5986 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 5987 | |
505e5056 | 5988 | DEFUN_NOSH (address_family_ipv4_safi, |
718e3744 | 5989 | address_family_ipv4_safi_cmd, |
5b1f0f29 | 5990 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast>]", |
718e3744 | 5991 | "Enter Address Family command mode\n" |
8c3deaae | 5992 | "Address Family\n" |
b6ab5a3a | 5993 | BGP_SAFI_WITH_LABEL_HELP_STR) |
718e3744 | 5994 | { |
f51bae9c | 5995 | |
d62a17ae | 5996 | if (argc == 3) { |
5997 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
5998 | vty->node = bgp_node_type(AFI_IP, safi); | |
5999 | } else | |
6000 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 6001 | |
d62a17ae | 6002 | return CMD_SUCCESS; |
718e3744 | 6003 | } |
6004 | ||
505e5056 | 6005 | DEFUN_NOSH (address_family_ipv6_safi, |
25ffbdc1 | 6006 | address_family_ipv6_safi_cmd, |
5b1f0f29 | 6007 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast>]", |
718e3744 | 6008 | "Enter Address Family command mode\n" |
8c3deaae | 6009 | "Address Family\n" |
b6ab5a3a | 6010 | BGP_SAFI_WITH_LABEL_HELP_STR) |
25ffbdc1 | 6011 | { |
d62a17ae | 6012 | if (argc == 3) { |
6013 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); | |
6014 | vty->node = bgp_node_type(AFI_IP6, safi); | |
6015 | } else | |
6016 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 6017 | |
d62a17ae | 6018 | return CMD_SUCCESS; |
25ffbdc1 | 6019 | } |
718e3744 | 6020 | |
d6902373 | 6021 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 6022 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 6023 | address_family_vpnv4_cmd, |
8334fd5a | 6024 | "address-family vpnv4 [unicast]", |
718e3744 | 6025 | "Enter Address Family command mode\n" |
8c3deaae | 6026 | "Address Family\n" |
3a2d747c | 6027 | "Address Family modifier\n") |
718e3744 | 6028 | { |
d62a17ae | 6029 | vty->node = BGP_VPNV4_NODE; |
6030 | return CMD_SUCCESS; | |
718e3744 | 6031 | } |
6032 | ||
505e5056 | 6033 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 6034 | address_family_vpnv6_cmd, |
8334fd5a | 6035 | "address-family vpnv6 [unicast]", |
8ecd3266 | 6036 | "Enter Address Family command mode\n" |
8c3deaae | 6037 | "Address Family\n" |
3a2d747c | 6038 | "Address Family modifier\n") |
8ecd3266 | 6039 | { |
d62a17ae | 6040 | vty->node = BGP_VPNV6_NODE; |
6041 | return CMD_SUCCESS; | |
8ecd3266 | 6042 | } |
c016b6c7 | 6043 | #endif |
d6902373 | 6044 | |
505e5056 | 6045 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 6046 | address_family_evpn_cmd, |
7111c1a0 | 6047 | "address-family l2vpn evpn", |
4e0b7b6d | 6048 | "Enter Address Family command mode\n" |
7111c1a0 QY |
6049 | "Address Family\n" |
6050 | "Address Family modifier\n") | |
4e0b7b6d | 6051 | { |
d62a17ae | 6052 | vty->node = BGP_EVPN_NODE; |
6053 | return CMD_SUCCESS; | |
4e0b7b6d PG |
6054 | } |
6055 | ||
505e5056 | 6056 | DEFUN_NOSH (exit_address_family, |
718e3744 | 6057 | exit_address_family_cmd, |
6058 | "exit-address-family", | |
6059 | "Exit from Address Family configuration mode\n") | |
6060 | { | |
d62a17ae | 6061 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
6062 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
6063 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
6064 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
6065 | || vty->node == BGP_EVPN_NODE) | |
6066 | vty->node = BGP_NODE; | |
6067 | return CMD_SUCCESS; | |
718e3744 | 6068 | } |
6b0655a2 | 6069 | |
8ad7271d | 6070 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 6071 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
6072 | const char *ip_str, afi_t afi, safi_t safi, | |
6073 | struct prefix_rd *prd) | |
6074 | { | |
6075 | int ret; | |
6076 | struct prefix match; | |
6077 | struct bgp_node *rn; | |
6078 | struct bgp_node *rm; | |
6079 | struct bgp *bgp; | |
6080 | struct bgp_table *table; | |
6081 | struct bgp_table *rib; | |
6082 | ||
6083 | /* BGP structure lookup. */ | |
6084 | if (view_name) { | |
6085 | bgp = bgp_lookup_by_name(view_name); | |
6086 | if (bgp == NULL) { | |
6087 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
6088 | view_name); | |
6089 | return CMD_WARNING; | |
6090 | } | |
6091 | } else { | |
6092 | bgp = bgp_get_default(); | |
6093 | if (bgp == NULL) { | |
6094 | vty_out(vty, "%% No BGP process is configured\n"); | |
6095 | return CMD_WARNING; | |
6096 | } | |
6097 | } | |
6098 | ||
6099 | /* Check IP address argument. */ | |
6100 | ret = str2prefix(ip_str, &match); | |
6101 | if (!ret) { | |
6102 | vty_out(vty, "%% address is malformed\n"); | |
6103 | return CMD_WARNING; | |
6104 | } | |
6105 | ||
6106 | match.family = afi2family(afi); | |
6107 | rib = bgp->rib[afi][safi]; | |
6108 | ||
6109 | if (safi == SAFI_MPLS_VPN) { | |
6110 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
6111 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
6112 | continue; | |
6113 | ||
6114 | if ((table = rn->info) != NULL) { | |
6115 | if ((rm = bgp_node_match(table, &match)) | |
6116 | != NULL) { | |
6117 | if (rm->p.prefixlen | |
6118 | == match.prefixlen) { | |
6119 | SET_FLAG(rn->flags, | |
6120 | BGP_NODE_USER_CLEAR); | |
6121 | bgp_process(bgp, rm, afi, safi); | |
6122 | } | |
6123 | bgp_unlock_node(rm); | |
6124 | } | |
6125 | } | |
6126 | } | |
6127 | } else { | |
6128 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
6129 | if (rn->p.prefixlen == match.prefixlen) { | |
6130 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
6131 | bgp_process(bgp, rn, afi, safi); | |
6132 | } | |
6133 | bgp_unlock_node(rn); | |
6134 | } | |
6135 | } | |
6136 | ||
6137 | return CMD_SUCCESS; | |
8ad7271d DS |
6138 | } |
6139 | ||
b09b5ae0 | 6140 | /* one clear bgp command to rule them all */ |
718e3744 | 6141 | DEFUN (clear_ip_bgp_all, |
6142 | clear_ip_bgp_all_cmd, | |
c1a44e43 | 6143 | "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 | 6144 | CLEAR_STR |
6145 | IP_STR | |
6146 | BGP_STR | |
838758ac | 6147 | BGP_INSTANCE_HELP_STR |
b09b5ae0 DW |
6148 | "Clear all peers\n" |
6149 | "BGP neighbor address to clear\n" | |
a80beece | 6150 | "BGP IPv6 neighbor to clear\n" |
838758ac | 6151 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
6152 | "Clear peers with the AS number\n" |
6153 | "Clear all external peers\n" | |
718e3744 | 6154 | "Clear all members of peer-group\n" |
b09b5ae0 | 6155 | "BGP peer-group name\n" |
46f296b4 | 6156 | BGP_AFI_HELP_STR |
9bedbb1e | 6157 | BGP_SAFI_WITH_LABEL_HELP_STR |
b09b5ae0 DW |
6158 | BGP_SOFT_STR |
6159 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
6160 | BGP_SOFT_OUT_STR |
6161 | BGP_SOFT_IN_STR | |
6162 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 6163 | BGP_SOFT_OUT_STR) |
718e3744 | 6164 | { |
d62a17ae | 6165 | char *vrf = NULL; |
6166 | ||
6167 | afi_t afi = AFI_IP6; | |
6168 | safi_t safi = SAFI_UNICAST; | |
6169 | enum clear_sort clr_sort = clear_peer; | |
6170 | enum bgp_clear_type clr_type; | |
6171 | char *clr_arg = NULL; | |
6172 | ||
6173 | int idx = 0; | |
6174 | ||
6175 | /* clear [ip] bgp */ | |
6176 | if (argv_find(argv, argc, "ip", &idx)) | |
6177 | afi = AFI_IP; | |
6178 | ||
6179 | /* [<view|vrf> VIEWVRFNAME] */ | |
6180 | if (argv_find(argv, argc, "view", &idx) | |
6181 | || argv_find(argv, argc, "vrf", &idx)) { | |
6182 | vrf = argv[idx + 1]->arg; | |
6183 | idx += 2; | |
6184 | } | |
6185 | ||
6186 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
6187 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
6188 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
6189 | ||
6190 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ | |
6191 | if (argv_find(argv, argc, "*", &idx)) { | |
6192 | clr_sort = clear_all; | |
6193 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
6194 | clr_sort = clear_peer; | |
6195 | clr_arg = argv[idx]->arg; | |
6196 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
6197 | clr_sort = clear_peer; | |
6198 | clr_arg = argv[idx]->arg; | |
6199 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
6200 | clr_sort = clear_group; | |
6201 | idx++; | |
6202 | clr_arg = argv[idx]->arg; | |
6203 | } else if (argv_find(argv, argc, "WORD", &idx)) { | |
6204 | clr_sort = clear_peer; | |
6205 | clr_arg = argv[idx]->arg; | |
6206 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { | |
6207 | clr_sort = clear_as; | |
6208 | clr_arg = argv[idx]->arg; | |
6209 | } else if (argv_find(argv, argc, "external", &idx)) { | |
6210 | clr_sort = clear_external; | |
6211 | } | |
6212 | ||
6213 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
6214 | if (argv_find(argv, argc, "soft", &idx)) { | |
6215 | if (argv_find(argv, argc, "in", &idx) | |
6216 | || argv_find(argv, argc, "out", &idx)) | |
6217 | clr_type = strmatch(argv[idx]->text, "in") | |
6218 | ? BGP_CLEAR_SOFT_IN | |
6219 | : BGP_CLEAR_SOFT_OUT; | |
6220 | else | |
6221 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
6222 | } else if (argv_find(argv, argc, "in", &idx)) { | |
6223 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
6224 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
6225 | : BGP_CLEAR_SOFT_IN; | |
6226 | } else if (argv_find(argv, argc, "out", &idx)) { | |
6227 | clr_type = BGP_CLEAR_SOFT_OUT; | |
6228 | } else | |
6229 | clr_type = BGP_CLEAR_SOFT_NONE; | |
6230 | ||
6231 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 6232 | } |
01080f7c | 6233 | |
8ad7271d DS |
6234 | DEFUN (clear_ip_bgp_prefix, |
6235 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 6236 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
6237 | CLEAR_STR |
6238 | IP_STR | |
6239 | BGP_STR | |
838758ac | 6240 | BGP_INSTANCE_HELP_STR |
8ad7271d | 6241 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6242 | "IPv4 prefix\n") |
8ad7271d | 6243 | { |
d62a17ae | 6244 | char *vrf = NULL; |
6245 | char *prefix = NULL; | |
8ad7271d | 6246 | |
d62a17ae | 6247 | int idx = 0; |
01080f7c | 6248 | |
d62a17ae | 6249 | /* [<view|vrf> VIEWVRFNAME] */ |
6250 | if (argv_find(argv, argc, "WORD", &idx)) | |
6251 | vrf = argv[idx]->arg; | |
0c7b1b01 | 6252 | |
d62a17ae | 6253 | prefix = argv[argc - 1]->arg; |
8ad7271d | 6254 | |
d62a17ae | 6255 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 6256 | } |
8ad7271d | 6257 | |
b09b5ae0 DW |
6258 | DEFUN (clear_bgp_ipv6_safi_prefix, |
6259 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 6260 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6261 | CLEAR_STR |
3a2d747c | 6262 | IP_STR |
718e3744 | 6263 | BGP_STR |
8c3deaae | 6264 | "Address Family\n" |
46f296b4 | 6265 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6266 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6267 | "IPv6 prefix\n") |
718e3744 | 6268 | { |
d62a17ae | 6269 | int idx_safi = 3; |
6270 | int idx_ipv6_prefixlen = 5; | |
6271 | return bgp_clear_prefix( | |
6272 | vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, | |
6273 | bgp_vty_safi_from_str(argv[idx_safi]->text), NULL); | |
838758ac | 6274 | } |
01080f7c | 6275 | |
b09b5ae0 DW |
6276 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
6277 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 6278 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 6279 | CLEAR_STR |
3a2d747c | 6280 | IP_STR |
718e3744 | 6281 | BGP_STR |
838758ac | 6282 | BGP_INSTANCE_HELP_STR |
8c3deaae | 6283 | "Address Family\n" |
46f296b4 | 6284 | BGP_SAFI_HELP_STR |
b09b5ae0 | 6285 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 6286 | "IPv6 prefix\n") |
718e3744 | 6287 | { |
d62a17ae | 6288 | int idx_word = 3; |
6289 | int idx_safi = 5; | |
6290 | int idx_ipv6_prefixlen = 7; | |
6291 | return bgp_clear_prefix( | |
6292 | vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, | |
6293 | AFI_IP6, bgp_vty_safi_from_str(argv[idx_safi]->text), NULL); | |
718e3744 | 6294 | } |
6295 | ||
b09b5ae0 DW |
6296 | DEFUN (show_bgp_views, |
6297 | show_bgp_views_cmd, | |
d6e3c605 | 6298 | "show [ip] bgp views", |
b09b5ae0 | 6299 | SHOW_STR |
d6e3c605 | 6300 | IP_STR |
01080f7c | 6301 | BGP_STR |
b09b5ae0 | 6302 | "Show the defined BGP views\n") |
01080f7c | 6303 | { |
d62a17ae | 6304 | struct list *inst = bm->bgp; |
6305 | struct listnode *node; | |
6306 | struct bgp *bgp; | |
01080f7c | 6307 | |
d62a17ae | 6308 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { |
6309 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
6310 | return CMD_WARNING; | |
6311 | } | |
e52702f2 | 6312 | |
d62a17ae | 6313 | vty_out(vty, "Defined BGP views:\n"); |
6314 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
6315 | /* Skip VRFs. */ | |
6316 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
6317 | continue; | |
6318 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
6319 | bgp->as); | |
6320 | } | |
e52702f2 | 6321 | |
d62a17ae | 6322 | return CMD_SUCCESS; |
e0081f70 ML |
6323 | } |
6324 | ||
8386ac43 | 6325 | DEFUN (show_bgp_vrfs, |
6326 | show_bgp_vrfs_cmd, | |
d6e3c605 | 6327 | "show [ip] bgp vrfs [json]", |
8386ac43 | 6328 | SHOW_STR |
d6e3c605 | 6329 | IP_STR |
8386ac43 | 6330 | BGP_STR |
6331 | "Show BGP VRFs\n" | |
9973d184 | 6332 | JSON_STR) |
8386ac43 | 6333 | { |
d62a17ae | 6334 | struct list *inst = bm->bgp; |
6335 | struct listnode *node; | |
6336 | struct bgp *bgp; | |
6337 | u_char uj = use_json(argc, argv); | |
6338 | json_object *json = NULL; | |
6339 | json_object *json_vrfs = NULL; | |
6340 | int count = 0; | |
6341 | static char header[] = | |
6342 | "Type Id RouterId #PeersCfg #PeersEstb Name"; | |
6343 | ||
6344 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { | |
6345 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
6346 | return CMD_WARNING; | |
6347 | } | |
6348 | ||
6349 | if (uj) { | |
6350 | json = json_object_new_object(); | |
6351 | json_vrfs = json_object_new_object(); | |
6352 | } | |
6353 | ||
6354 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
6355 | const char *name, *type; | |
6356 | struct peer *peer; | |
6357 | struct listnode *node, *nnode; | |
6358 | int peers_cfg, peers_estb; | |
6359 | json_object *json_vrf = NULL; | |
6360 | int vrf_id_ui; | |
6361 | ||
6362 | /* Skip Views. */ | |
6363 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
6364 | continue; | |
6365 | ||
6366 | count++; | |
6367 | if (!uj && count == 1) | |
6368 | vty_out(vty, "%s\n", header); | |
6369 | ||
6370 | peers_cfg = peers_estb = 0; | |
6371 | if (uj) | |
6372 | json_vrf = json_object_new_object(); | |
6373 | ||
6374 | ||
6375 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
6376 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6377 | continue; | |
6378 | peers_cfg++; | |
6379 | if (peer->status == Established) | |
6380 | peers_estb++; | |
6381 | } | |
6382 | ||
6383 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
6384 | name = "Default"; | |
6385 | type = "DFLT"; | |
6386 | } else { | |
6387 | name = bgp->name; | |
6388 | type = "VRF"; | |
6389 | } | |
6390 | ||
6391 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : bgp->vrf_id; | |
6392 | if (uj) { | |
6393 | json_object_string_add(json_vrf, "type", type); | |
6394 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
6395 | json_object_string_add(json_vrf, "routerId", | |
6396 | inet_ntoa(bgp->router_id)); | |
6397 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
6398 | peers_cfg); | |
6399 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
6400 | peers_estb); | |
6401 | ||
6402 | json_object_object_add(json_vrfs, name, json_vrf); | |
6403 | } else | |
6404 | vty_out(vty, "%4s %-5d %-16s %9u %10u %s\n", type, | |
6405 | vrf_id_ui, inet_ntoa(bgp->router_id), peers_cfg, | |
6406 | peers_estb, name); | |
6407 | } | |
6408 | ||
6409 | if (uj) { | |
6410 | json_object_object_add(json, "vrfs", json_vrfs); | |
6411 | ||
6412 | json_object_int_add(json, "totalVrfs", count); | |
6413 | ||
9d303b37 DL |
6414 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
6415 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 6416 | json_object_free(json); |
6417 | } else { | |
6418 | if (count) | |
6419 | vty_out(vty, | |
6420 | "\nTotal number of VRFs (including default): %d\n", | |
6421 | count); | |
6422 | } | |
6423 | ||
6424 | return CMD_SUCCESS; | |
8386ac43 | 6425 | } |
6426 | ||
acf71666 MK |
6427 | static void show_address_entry(struct hash_backet *backet, void *args) |
6428 | { | |
0291c246 | 6429 | struct vty *vty = (struct vty *) args; |
acf71666 MK |
6430 | struct bgp_addr *addr = (struct bgp_addr *) backet->data; |
6431 | ||
6432 | vty_out(vty, "addr: %s, count: %d\n", | |
6433 | inet_ntoa(addr->addr), | |
6434 | addr->refcnt); | |
6435 | } | |
6436 | ||
6437 | static void show_tip_entry(struct hash_backet *backet, void *args) | |
6438 | { | |
0291c246 | 6439 | struct vty *vty = (struct vty *)args; |
acf71666 MK |
6440 | struct tip_addr *tip = (struct tip_addr *) backet->data; |
6441 | ||
6442 | vty_out(vty, "addr: %s, count: %d\n", | |
6443 | inet_ntoa(tip->addr), | |
6444 | tip->refcnt); | |
6445 | } | |
6446 | ||
6447 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
6448 | { | |
6449 | vty_out(vty, "self nexthop database:\n"); | |
6450 | hash_iterate(bgp->address_hash, | |
6451 | (void (*)(struct hash_backet *, void *))show_address_entry, | |
6452 | vty); | |
6453 | ||
6454 | vty_out(vty, "Tunnel-ip database:\n"); | |
6455 | hash_iterate(bgp->tip_hash, | |
6456 | (void (*)(struct hash_backet *, void *))show_tip_entry, | |
6457 | vty); | |
6458 | } | |
6459 | ||
6460 | DEFUN (show_bgp_martian_nexthop_db, | |
6461 | show_bgp_martian_nexthop_db_cmd, | |
6462 | "show bgp martian next-hop", | |
6463 | SHOW_STR | |
6464 | BGP_STR | |
6465 | "martian next-hops\n" | |
6466 | "martian next-hop database\n") | |
6467 | { | |
0291c246 | 6468 | struct bgp *bgp = NULL; |
acf71666 MK |
6469 | |
6470 | bgp = bgp_get_default(); | |
6471 | if (!bgp) { | |
6472 | vty_out(vty, "%% No BGP process is configured\n"); | |
6473 | return CMD_WARNING; | |
6474 | } | |
6475 | bgp_show_martian_nexthops(vty, bgp); | |
6476 | ||
6477 | return CMD_SUCCESS; | |
6478 | } | |
6479 | ||
f412b39a | 6480 | DEFUN (show_bgp_memory, |
4bf6a362 | 6481 | show_bgp_memory_cmd, |
7fa12b13 | 6482 | "show [ip] bgp memory", |
4bf6a362 | 6483 | SHOW_STR |
3a2d747c | 6484 | IP_STR |
4bf6a362 PJ |
6485 | BGP_STR |
6486 | "Global BGP memory statistics\n") | |
6487 | { | |
d62a17ae | 6488 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
6489 | unsigned long count; | |
6490 | ||
6491 | /* RIB related usage stats */ | |
6492 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
6493 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
6494 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6495 | count * sizeof(struct bgp_node))); | |
6496 | ||
6497 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
6498 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
6499 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6500 | count * sizeof(struct bgp_info))); | |
6501 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) | |
6502 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
6503 | count, | |
6504 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6505 | count * sizeof(struct bgp_info_extra))); | |
6506 | ||
6507 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
6508 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
6509 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6510 | count * sizeof(struct bgp_static))); | |
6511 | ||
6512 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
6513 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
6514 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6515 | count * sizeof(struct bpacket))); | |
6516 | ||
6517 | /* Adj-In/Out */ | |
6518 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
6519 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
6520 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6521 | count * sizeof(struct bgp_adj_in))); | |
6522 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
6523 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
6524 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6525 | count * sizeof(struct bgp_adj_out))); | |
6526 | ||
6527 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
6528 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
6529 | count, | |
6530 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6531 | count * sizeof(struct bgp_nexthop_cache))); | |
6532 | ||
6533 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
6534 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
6535 | count, | |
6536 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6537 | count * sizeof(struct bgp_damp_info))); | |
6538 | ||
6539 | /* Attributes */ | |
6540 | count = attr_count(); | |
6541 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
6542 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6543 | count * sizeof(struct attr))); | |
6544 | ||
6545 | if ((count = attr_unknown_count())) | |
6546 | vty_out(vty, "%ld unknown attributes\n", count); | |
6547 | ||
6548 | /* AS_PATH attributes */ | |
6549 | count = aspath_count(); | |
6550 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
6551 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6552 | count * sizeof(struct aspath))); | |
6553 | ||
6554 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
6555 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
6556 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6557 | count * sizeof(struct assegment))); | |
6558 | ||
6559 | /* Other attributes */ | |
6560 | if ((count = community_count())) | |
6561 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
9d303b37 DL |
6562 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
6563 | count * sizeof(struct community))); | |
d62a17ae | 6564 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
6565 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
9d303b37 DL |
6566 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
6567 | count * sizeof(struct ecommunity))); | |
d62a17ae | 6568 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
6569 | vty_out(vty, | |
6570 | "%ld BGP large-community entries, using %s of memory\n", | |
9d303b37 DL |
6571 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
6572 | count * sizeof(struct lcommunity))); | |
d62a17ae | 6573 | |
6574 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
6575 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
6576 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6577 | count * sizeof(struct cluster_list))); | |
6578 | ||
6579 | /* Peer related usage */ | |
6580 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
6581 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
6582 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6583 | count * sizeof(struct peer))); | |
6584 | ||
6585 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
6586 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
6587 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6588 | count * sizeof(struct peer_group))); | |
6589 | ||
6590 | /* Other */ | |
6591 | if ((count = mtype_stats_alloc(MTYPE_HASH))) | |
6592 | vty_out(vty, "%ld hash tables, using %s of memory\n", count, | |
6593 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6594 | count * sizeof(struct hash))); | |
6595 | if ((count = mtype_stats_alloc(MTYPE_HASH_BACKET))) | |
6596 | vty_out(vty, "%ld hash buckets, using %s of memory\n", count, | |
6597 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
6598 | count * sizeof(struct hash_backet))); | |
6599 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) | |
6600 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
9d303b37 DL |
6601 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
6602 | count * sizeof(regex_t))); | |
d62a17ae | 6603 | return CMD_SUCCESS; |
4bf6a362 | 6604 | } |
fee0f4c6 | 6605 | |
718e3744 | 6606 | /* Show BGP peer's summary information. */ |
d62a17ae | 6607 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
6608 | u_char use_json, json_object *json) | |
6609 | { | |
6610 | struct peer *peer; | |
6611 | struct listnode *node, *nnode; | |
6612 | unsigned int count = 0, dn_count = 0; | |
6613 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
6614 | char neighbor_buf[VTY_BUFSIZ]; | |
6615 | int neighbor_col_default_width = 16; | |
6616 | int len; | |
6617 | int max_neighbor_width = 0; | |
6618 | int pfx_rcd_safi; | |
6619 | json_object *json_peer = NULL; | |
6620 | json_object *json_peers = NULL; | |
6621 | ||
6622 | /* labeled-unicast routes are installed in the unicast table so in order | |
6623 | * to | |
6624 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
6625 | */ | |
6626 | if (safi == SAFI_LABELED_UNICAST) | |
6627 | pfx_rcd_safi = SAFI_UNICAST; | |
6628 | else | |
6629 | pfx_rcd_safi = safi; | |
6630 | ||
6631 | if (use_json) { | |
6632 | if (json == NULL) | |
6633 | json = json_object_new_object(); | |
6634 | ||
6635 | json_peers = json_object_new_object(); | |
6636 | } else { | |
6637 | /* Loop over all neighbors that will be displayed to determine | |
6638 | * how many | |
6639 | * characters are needed for the Neighbor column | |
6640 | */ | |
6641 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
6642 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6643 | continue; | |
6644 | ||
6645 | if (peer->afc[afi][safi]) { | |
6646 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
6647 | if (peer_dynamic_neighbor(peer)) | |
6648 | dn_flag[0] = '*'; | |
6649 | ||
6650 | if (peer->hostname | |
6651 | && bgp_flag_check(bgp, | |
6652 | BGP_FLAG_SHOW_HOSTNAME)) | |
6653 | sprintf(neighbor_buf, "%s%s(%s) ", | |
6654 | dn_flag, peer->hostname, | |
6655 | peer->host); | |
6656 | else | |
6657 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
6658 | peer->host); | |
6659 | ||
6660 | len = strlen(neighbor_buf); | |
6661 | ||
6662 | if (len > max_neighbor_width) | |
6663 | max_neighbor_width = len; | |
6664 | } | |
6665 | } | |
f933309e | 6666 | |
d62a17ae | 6667 | /* Originally we displayed the Neighbor column as 16 |
6668 | * characters wide so make that the default | |
6669 | */ | |
6670 | if (max_neighbor_width < neighbor_col_default_width) | |
6671 | max_neighbor_width = neighbor_col_default_width; | |
6672 | } | |
f933309e | 6673 | |
d62a17ae | 6674 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
6675 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
6676 | continue; | |
6677 | ||
6678 | if (peer->afc[afi][safi]) { | |
6679 | if (!count) { | |
6680 | unsigned long ents; | |
6681 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
6682 | int vrf_id_ui; | |
6683 | ||
6684 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) | |
6685 | ? -1 | |
6686 | : bgp->vrf_id; | |
6687 | ||
6688 | /* Usage summary and header */ | |
6689 | if (use_json) { | |
6690 | json_object_string_add( | |
6691 | json, "routerId", | |
6692 | inet_ntoa(bgp->router_id)); | |
6693 | json_object_int_add(json, "as", | |
6694 | bgp->as); | |
6695 | json_object_int_add(json, "vrfId", | |
6696 | vrf_id_ui); | |
6697 | json_object_string_add( | |
6698 | json, "vrfName", | |
6699 | (bgp->inst_type | |
6700 | == BGP_INSTANCE_TYPE_DEFAULT) | |
6701 | ? "Default" | |
6702 | : bgp->name); | |
6703 | } else { | |
6704 | vty_out(vty, | |
6705 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
6706 | inet_ntoa(bgp->router_id), | |
6707 | bgp->as, vrf_id_ui); | |
6708 | vty_out(vty, "\n"); | |
6709 | } | |
6710 | ||
6711 | if (bgp_update_delay_configured(bgp)) { | |
6712 | if (use_json) { | |
6713 | json_object_int_add( | |
6714 | json, | |
6715 | "updateDelayLimit", | |
6716 | bgp->v_update_delay); | |
6717 | ||
6718 | if (bgp->v_update_delay | |
6719 | != bgp->v_establish_wait) | |
6720 | json_object_int_add( | |
6721 | json, | |
6722 | "updateDelayEstablishWait", | |
6723 | bgp->v_establish_wait); | |
6724 | ||
6725 | if (bgp_update_delay_active( | |
6726 | bgp)) { | |
6727 | json_object_string_add( | |
6728 | json, | |
6729 | "updateDelayFirstNeighbor", | |
6730 | bgp->update_delay_begin_time); | |
6731 | json_object_boolean_true_add( | |
6732 | json, | |
6733 | "updateDelayInProgress"); | |
6734 | } else { | |
6735 | if (bgp->update_delay_over) { | |
6736 | json_object_string_add( | |
6737 | json, | |
6738 | "updateDelayFirstNeighbor", | |
6739 | bgp->update_delay_begin_time); | |
6740 | json_object_string_add( | |
6741 | json, | |
6742 | "updateDelayBestpathResumed", | |
6743 | bgp->update_delay_end_time); | |
6744 | json_object_string_add( | |
6745 | json, | |
6746 | "updateDelayZebraUpdateResume", | |
6747 | bgp->update_delay_zebra_resume_time); | |
6748 | json_object_string_add( | |
6749 | json, | |
6750 | "updateDelayPeerUpdateResume", | |
6751 | bgp->update_delay_peers_resume_time); | |
6752 | } | |
6753 | } | |
6754 | } else { | |
6755 | vty_out(vty, | |
6756 | "Read-only mode update-delay limit: %d seconds\n", | |
6757 | bgp->v_update_delay); | |
6758 | if (bgp->v_update_delay | |
6759 | != bgp->v_establish_wait) | |
6760 | vty_out(vty, | |
6761 | " Establish wait: %d seconds\n", | |
6762 | bgp->v_establish_wait); | |
6763 | ||
6764 | if (bgp_update_delay_active( | |
6765 | bgp)) { | |
6766 | vty_out(vty, | |
6767 | " First neighbor established: %s\n", | |
6768 | bgp->update_delay_begin_time); | |
6769 | vty_out(vty, | |
6770 | " Delay in progress\n"); | |
6771 | } else { | |
6772 | if (bgp->update_delay_over) { | |
6773 | vty_out(vty, | |
6774 | " First neighbor established: %s\n", | |
6775 | bgp->update_delay_begin_time); | |
6776 | vty_out(vty, | |
6777 | " Best-paths resumed: %s\n", | |
6778 | bgp->update_delay_end_time); | |
6779 | vty_out(vty, | |
6780 | " zebra update resumed: %s\n", | |
6781 | bgp->update_delay_zebra_resume_time); | |
6782 | vty_out(vty, | |
6783 | " peers update resumed: %s\n", | |
6784 | bgp->update_delay_peers_resume_time); | |
6785 | } | |
6786 | } | |
6787 | } | |
6788 | } | |
6789 | ||
6790 | if (use_json) { | |
6791 | if (bgp_maxmed_onstartup_configured(bgp) | |
6792 | && bgp->maxmed_active) | |
6793 | json_object_boolean_true_add( | |
6794 | json, | |
6795 | "maxMedOnStartup"); | |
6796 | if (bgp->v_maxmed_admin) | |
6797 | json_object_boolean_true_add( | |
6798 | json, | |
6799 | "maxMedAdministrative"); | |
6800 | ||
6801 | json_object_int_add( | |
6802 | json, "tableVersion", | |
6803 | bgp_table_version( | |
6804 | bgp->rib[afi][safi])); | |
6805 | ||
6806 | ents = bgp_table_count( | |
6807 | bgp->rib[afi][safi]); | |
6808 | json_object_int_add(json, "ribCount", | |
6809 | ents); | |
6810 | json_object_int_add( | |
6811 | json, "ribMemory", | |
6812 | ents * sizeof(struct bgp_node)); | |
6813 | ||
6814 | ents = listcount(bgp->peer); | |
6815 | json_object_int_add(json, "peerCount", | |
6816 | ents); | |
6817 | json_object_int_add( | |
6818 | json, "peerMemory", | |
6819 | ents * sizeof(struct peer)); | |
6820 | ||
6821 | if ((ents = listcount(bgp->group))) { | |
6822 | json_object_int_add( | |
6823 | json, "peerGroupCount", | |
6824 | ents); | |
6825 | json_object_int_add( | |
6826 | json, "peerGroupMemory", | |
9d303b37 DL |
6827 | ents * sizeof(struct |
6828 | peer_group)); | |
d62a17ae | 6829 | } |
6830 | ||
6831 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
6832 | BGP_CONFIG_DAMPENING)) | |
6833 | json_object_boolean_true_add( | |
6834 | json, | |
6835 | "dampeningEnabled"); | |
6836 | } else { | |
6837 | if (bgp_maxmed_onstartup_configured(bgp) | |
6838 | && bgp->maxmed_active) | |
6839 | vty_out(vty, | |
6840 | "Max-med on-startup active\n"); | |
6841 | if (bgp->v_maxmed_admin) | |
6842 | vty_out(vty, | |
6843 | "Max-med administrative active\n"); | |
6844 | ||
6845 | vty_out(vty, | |
6846 | "BGP table version %" PRIu64 | |
6847 | "\n", | |
6848 | bgp_table_version( | |
6849 | bgp->rib[afi][safi])); | |
6850 | ||
6851 | ents = bgp_table_count( | |
6852 | bgp->rib[afi][safi]); | |
6853 | vty_out(vty, | |
6854 | "RIB entries %ld, using %s of memory\n", | |
6855 | ents, | |
6856 | mtype_memstr( | |
6857 | memstrbuf, | |
6858 | sizeof(memstrbuf), | |
9d303b37 DL |
6859 | ents * sizeof(struct |
6860 | bgp_node))); | |
d62a17ae | 6861 | |
6862 | /* Peer related usage */ | |
6863 | ents = listcount(bgp->peer); | |
6864 | vty_out(vty, | |
6865 | "Peers %ld, using %s of memory\n", | |
6866 | ents, | |
6867 | mtype_memstr( | |
6868 | memstrbuf, | |
6869 | sizeof(memstrbuf), | |
9d303b37 DL |
6870 | ents * sizeof(struct |
6871 | peer))); | |
d62a17ae | 6872 | |
6873 | if ((ents = listcount(bgp->group))) | |
6874 | vty_out(vty, | |
6875 | "Peer groups %ld, using %s of memory\n", | |
6876 | ents, | |
6877 | mtype_memstr( | |
6878 | memstrbuf, | |
6879 | sizeof(memstrbuf), | |
9d303b37 DL |
6880 | ents * sizeof(struct |
6881 | peer_group))); | |
d62a17ae | 6882 | |
6883 | if (CHECK_FLAG(bgp->af_flags[afi][safi], | |
6884 | BGP_CONFIG_DAMPENING)) | |
6885 | vty_out(vty, | |
6886 | "Dampening enabled.\n"); | |
6887 | vty_out(vty, "\n"); | |
6888 | ||
6889 | /* Subtract 8 here because 'Neighbor' is | |
6890 | * 8 characters */ | |
6891 | vty_out(vty, "Neighbor"); | |
6892 | vty_out(vty, "%*s", | |
6893 | max_neighbor_width - 8, " "); | |
6894 | vty_out(vty, | |
6895 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); | |
6896 | } | |
6897 | } | |
6898 | ||
6899 | count++; | |
6900 | ||
6901 | if (use_json) { | |
6902 | json_peer = json_object_new_object(); | |
6903 | ||
6904 | if (peer_dynamic_neighbor(peer)) | |
6905 | json_object_boolean_true_add( | |
6906 | json_peer, "dynamicPeer"); | |
6907 | ||
6908 | if (peer->hostname) | |
6909 | json_object_string_add(json_peer, | |
6910 | "hostname", | |
6911 | peer->hostname); | |
6912 | ||
6913 | if (peer->domainname) | |
6914 | json_object_string_add( | |
6915 | json_peer, "domainname", | |
6916 | peer->domainname); | |
6917 | ||
6918 | json_object_int_add(json_peer, "remoteAs", | |
6919 | peer->as); | |
6920 | json_object_int_add(json_peer, "version", 4); | |
6921 | json_object_int_add( | |
6922 | json_peer, "msgRcvd", | |
6923 | peer->open_in + peer->update_in | |
6924 | + peer->keepalive_in | |
6925 | + peer->notify_in | |
6926 | + peer->refresh_in | |
6927 | + peer->dynamic_cap_in); | |
6928 | json_object_int_add( | |
6929 | json_peer, "msgSent", | |
6930 | peer->open_out + peer->update_out | |
6931 | + peer->keepalive_out | |
6932 | + peer->notify_out | |
6933 | + peer->refresh_out | |
6934 | + peer->dynamic_cap_out); | |
6935 | ||
6936 | json_object_int_add(json_peer, "tableVersion", | |
6937 | peer->version[afi][safi]); | |
6938 | json_object_int_add(json_peer, "outq", | |
6939 | peer->obuf->count); | |
6940 | json_object_int_add(json_peer, "inq", 0); | |
6941 | peer_uptime(peer->uptime, timebuf, | |
6942 | BGP_UPTIME_LEN, use_json, | |
6943 | json_peer); | |
6944 | json_object_int_add( | |
6945 | json_peer, "prefixReceivedCount", | |
6946 | peer->pcount[afi][pfx_rcd_safi]); | |
6947 | ||
6948 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
6949 | json_object_string_add(json_peer, | |
6950 | "state", | |
6951 | "Idle (Admin)"); | |
6952 | else if (CHECK_FLAG( | |
6953 | peer->sflags, | |
6954 | PEER_STATUS_PREFIX_OVERFLOW)) | |
6955 | json_object_string_add(json_peer, | |
6956 | "state", | |
6957 | "Idle (PfxCt)"); | |
6958 | else | |
6959 | json_object_string_add( | |
6960 | json_peer, "state", | |
6961 | lookup_msg(bgp_status_msg, | |
6962 | peer->status, NULL)); | |
6963 | ||
6964 | if (peer->conf_if) | |
6965 | json_object_string_add(json_peer, | |
6966 | "idType", | |
6967 | "interface"); | |
6968 | else if (peer->su.sa.sa_family == AF_INET) | |
6969 | json_object_string_add( | |
6970 | json_peer, "idType", "ipv4"); | |
6971 | else if (peer->su.sa.sa_family == AF_INET6) | |
6972 | json_object_string_add( | |
6973 | json_peer, "idType", "ipv6"); | |
6974 | ||
6975 | json_object_object_add(json_peers, peer->host, | |
6976 | json_peer); | |
6977 | } else { | |
6978 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
6979 | if (peer_dynamic_neighbor(peer)) { | |
6980 | dn_count++; | |
6981 | dn_flag[0] = '*'; | |
6982 | } | |
6983 | ||
6984 | if (peer->hostname | |
6985 | && bgp_flag_check(bgp, | |
6986 | BGP_FLAG_SHOW_HOSTNAME)) | |
6987 | len = vty_out(vty, "%s%s(%s)", dn_flag, | |
6988 | peer->hostname, | |
6989 | peer->host); | |
6990 | else | |
6991 | len = vty_out(vty, "%s%s", dn_flag, | |
6992 | peer->host); | |
6993 | ||
6994 | /* pad the neighbor column with spaces */ | |
6995 | if (len < max_neighbor_width) | |
6996 | vty_out(vty, "%*s", | |
6997 | max_neighbor_width - len, " "); | |
6998 | ||
9d303b37 DL |
6999 | vty_out(vty, "4 %10u %7d %7d %8" PRIu64 |
7000 | " %4d %4zd %8s", | |
d62a17ae | 7001 | peer->as, |
7002 | peer->open_in + peer->update_in | |
7003 | + peer->keepalive_in | |
7004 | + peer->notify_in | |
7005 | + peer->refresh_in | |
7006 | + peer->dynamic_cap_in, | |
7007 | peer->open_out + peer->update_out | |
7008 | + peer->keepalive_out | |
7009 | + peer->notify_out | |
7010 | + peer->refresh_out | |
7011 | + peer->dynamic_cap_out, | |
7012 | peer->version[afi][safi], 0, | |
7013 | peer->obuf->count, | |
7014 | peer_uptime(peer->uptime, timebuf, | |
7015 | BGP_UPTIME_LEN, 0, NULL)); | |
7016 | ||
7017 | if (peer->status == Established) | |
7018 | vty_out(vty, " %12ld", | |
7019 | peer->pcount[afi] | |
7020 | [pfx_rcd_safi]); | |
7021 | else { | |
7022 | if (CHECK_FLAG(peer->flags, | |
7023 | PEER_FLAG_SHUTDOWN)) | |
7024 | vty_out(vty, " Idle (Admin)"); | |
7025 | else if ( | |
7026 | CHECK_FLAG( | |
7027 | peer->sflags, | |
7028 | PEER_STATUS_PREFIX_OVERFLOW)) | |
7029 | vty_out(vty, " Idle (PfxCt)"); | |
7030 | else | |
7031 | vty_out(vty, " %12s", | |
7032 | lookup_msg( | |
7033 | bgp_status_msg, | |
7034 | peer->status, | |
7035 | NULL)); | |
7036 | } | |
7037 | vty_out(vty, "\n"); | |
7038 | } | |
7039 | } | |
7040 | } | |
f933309e | 7041 | |
d62a17ae | 7042 | if (use_json) { |
7043 | json_object_object_add(json, "peers", json_peers); | |
7044 | ||
7045 | json_object_int_add(json, "totalPeers", count); | |
7046 | json_object_int_add(json, "dynamicPeers", dn_count); | |
7047 | ||
9d303b37 DL |
7048 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
7049 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 7050 | json_object_free(json); |
7051 | } else { | |
7052 | if (count) | |
7053 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
7054 | else { | |
7055 | if (use_json) | |
7056 | vty_out(vty, | |
7057 | "{\"error\": {\"message\": \"No %s neighbor configured\"}}\n", | |
7058 | afi_safi_print(afi, safi)); | |
7059 | else | |
7060 | vty_out(vty, "No %s neighbor is configured\n", | |
7061 | afi_safi_print(afi, safi)); | |
7062 | } | |
b05a1c8b | 7063 | |
d62a17ae | 7064 | if (dn_count && !use_json) { |
7065 | vty_out(vty, "* - dynamic neighbor\n"); | |
7066 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
7067 | dn_count, bgp->dynamic_neighbors_limit); | |
7068 | } | |
7069 | } | |
1ff9a340 | 7070 | |
d62a17ae | 7071 | return CMD_SUCCESS; |
718e3744 | 7072 | } |
7073 | ||
798c3572 DS |
7074 | /* |
7075 | * Return if we have a peer configured to use this afi/safi | |
7076 | */ | |
d62a17ae | 7077 | static int bgp_show_summary_afi_safi_peer_exists(struct bgp *bgp, int afi, |
7078 | int safi) | |
7079 | { | |
7080 | struct listnode *node; | |
7081 | struct peer *peer; | |
7082 | ||
7083 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, node, peer)) { | |
7084 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7085 | continue; | |
7086 | ||
7087 | if (peer->afc[afi][safi]) | |
7088 | return 1; | |
7089 | } | |
7090 | ||
7091 | return 0; | |
7092 | } | |
7093 | ||
7094 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, | |
7095 | int safi, u_char use_json, | |
7096 | json_object *json) | |
7097 | { | |
7098 | int is_first = 1; | |
7099 | int afi_wildcard = (afi == AFI_MAX); | |
7100 | int safi_wildcard = (safi == SAFI_MAX); | |
7101 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
7102 | bool json_output = false; | |
7103 | ||
7104 | if (use_json && is_wildcard) | |
7105 | vty_out(vty, "{\n"); | |
7106 | if (afi_wildcard) | |
7107 | afi = 1; /* AFI_IP */ | |
7108 | while (afi < AFI_MAX) { | |
7109 | if (safi_wildcard) | |
7110 | safi = 1; /* SAFI_UNICAST */ | |
7111 | while (safi < SAFI_MAX) { | |
7112 | if (bgp_show_summary_afi_safi_peer_exists(bgp, afi, | |
7113 | safi)) { | |
7114 | json_output = true; | |
7115 | if (is_wildcard) { | |
7116 | /* | |
7117 | * So limit output to those afi/safi | |
7118 | * pairs that | |
7119 | * actualy have something interesting in | |
7120 | * them | |
7121 | */ | |
7122 | if (use_json) { | |
7123 | json = json_object_new_object(); | |
7124 | ||
7125 | if (!is_first) | |
7126 | vty_out(vty, ",\n"); | |
7127 | else | |
7128 | is_first = 0; | |
7129 | ||
7130 | vty_out(vty, "\"%s\":", | |
7131 | afi_safi_json(afi, | |
7132 | safi)); | |
7133 | } else { | |
7134 | vty_out(vty, "\n%s Summary:\n", | |
7135 | afi_safi_print(afi, | |
7136 | safi)); | |
7137 | } | |
7138 | } | |
7139 | bgp_show_summary(vty, bgp, afi, safi, use_json, | |
7140 | json); | |
7141 | } | |
7142 | safi++; | |
d62a17ae | 7143 | if (!safi_wildcard) |
7144 | safi = SAFI_MAX; | |
7145 | } | |
7146 | afi++; | |
7147 | if (!afi_wildcard | |
7148 | || afi == AFI_L2VPN) /* special case, not handled yet */ | |
7149 | afi = AFI_MAX; | |
7150 | } | |
7151 | ||
7152 | if (use_json && is_wildcard) | |
7153 | vty_out(vty, "}\n"); | |
7154 | else if (use_json && !json_output) | |
7155 | vty_out(vty, "{}\n"); | |
7156 | } | |
7157 | ||
7158 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
7159 | safi_t safi, u_char use_json) | |
7160 | { | |
7161 | struct listnode *node, *nnode; | |
7162 | struct bgp *bgp; | |
7163 | json_object *json = NULL; | |
7164 | int is_first = 1; | |
7165 | ||
7166 | if (use_json) | |
7167 | vty_out(vty, "{\n"); | |
7168 | ||
7169 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
7170 | if (use_json) { | |
7171 | json = json_object_new_object(); | |
7172 | ||
7173 | if (!is_first) | |
7174 | vty_out(vty, ",\n"); | |
7175 | else | |
7176 | is_first = 0; | |
7177 | ||
7178 | vty_out(vty, "\"%s\":", | |
7179 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7180 | ? "Default" | |
7181 | : bgp->name); | |
7182 | } else { | |
7183 | vty_out(vty, "\nInstance %s:\n", | |
7184 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
7185 | ? "Default" | |
7186 | : bgp->name); | |
7187 | } | |
7188 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, json); | |
7189 | } | |
7190 | ||
7191 | if (use_json) | |
7192 | vty_out(vty, "}\n"); | |
7193 | } | |
7194 | ||
7195 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
7196 | safi_t safi, u_char use_json) | |
7197 | { | |
7198 | struct bgp *bgp; | |
7199 | ||
7200 | if (name) { | |
7201 | if (strmatch(name, "all")) { | |
7202 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
7203 | use_json); | |
7204 | return CMD_SUCCESS; | |
7205 | } else { | |
7206 | bgp = bgp_lookup_by_name(name); | |
7207 | ||
7208 | if (!bgp) { | |
7209 | if (use_json) | |
7210 | vty_out(vty, "{}\n"); | |
7211 | else | |
7212 | vty_out(vty, | |
7213 | "%% No such BGP instance exist\n"); | |
7214 | return CMD_WARNING; | |
7215 | } | |
7216 | ||
7217 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, | |
7218 | NULL); | |
7219 | return CMD_SUCCESS; | |
7220 | } | |
7221 | } | |
7222 | ||
7223 | bgp = bgp_get_default(); | |
7224 | ||
7225 | if (bgp) | |
7226 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, NULL); | |
7227 | ||
7228 | return CMD_SUCCESS; | |
4fb25c53 DW |
7229 | } |
7230 | ||
716b2d8a | 7231 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 7232 | DEFUN (show_ip_bgp_summary, |
718e3744 | 7233 | show_ip_bgp_summary_cmd, |
dd6bd0f1 | 7234 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [json]", |
718e3744 | 7235 | SHOW_STR |
7236 | IP_STR | |
7237 | BGP_STR | |
8386ac43 | 7238 | BGP_INSTANCE_HELP_STR |
46f296b4 | 7239 | BGP_AFI_HELP_STR |
dd6bd0f1 | 7240 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 7241 | "Summary of BGP neighbor status\n" |
9973d184 | 7242 | JSON_STR) |
718e3744 | 7243 | { |
d62a17ae | 7244 | char *vrf = NULL; |
7245 | afi_t afi = AFI_MAX; | |
7246 | safi_t safi = SAFI_MAX; | |
7247 | ||
7248 | int idx = 0; | |
7249 | ||
7250 | /* show [ip] bgp */ | |
7251 | if (argv_find(argv, argc, "ip", &idx)) | |
7252 | afi = AFI_IP; | |
7253 | /* [<view|vrf> VIEWVRFNAME] */ | |
7254 | if (argv_find(argv, argc, "view", &idx) | |
7255 | || argv_find(argv, argc, "vrf", &idx)) | |
7256 | vrf = argv[++idx]->arg; | |
7257 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
7258 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
7259 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
7260 | } | |
7261 | ||
7262 | int uj = use_json(argc, argv); | |
7263 | ||
7264 | return bgp_show_summary_vty(vty, vrf, afi, safi, uj); | |
7265 | } | |
7266 | ||
7267 | const char *afi_safi_print(afi_t afi, safi_t safi) | |
7268 | { | |
7269 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
7270 | return "IPv4 Unicast"; | |
7271 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
7272 | return "IPv4 Multicast"; | |
7273 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
7274 | return "IPv4 Labeled Unicast"; | |
7275 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
7276 | return "IPv4 VPN"; | |
7277 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
7278 | return "IPv4 Encap"; | |
7279 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
7280 | return "IPv6 Unicast"; | |
7281 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
7282 | return "IPv6 Multicast"; | |
7283 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
7284 | return "IPv6 Labeled Unicast"; | |
7285 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
7286 | return "IPv6 VPN"; | |
7287 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
7288 | return "IPv6 Encap"; | |
7289 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
7290 | return "L2VPN EVPN"; | |
7291 | else | |
7292 | return "Unknown"; | |
538621f2 | 7293 | } |
7294 | ||
b9f77ec8 DS |
7295 | /* |
7296 | * Please note that we have intentionally camelCased | |
7297 | * the return strings here. So if you want | |
7298 | * to use this function, please ensure you | |
7299 | * are doing this within json output | |
7300 | */ | |
d62a17ae | 7301 | const char *afi_safi_json(afi_t afi, safi_t safi) |
7302 | { | |
7303 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
7304 | return "ipv4Unicast"; | |
7305 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
7306 | return "ipv4Multicast"; | |
7307 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
7308 | return "ipv4LabeledUnicast"; | |
7309 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
7310 | return "ipv4Vpn"; | |
7311 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
7312 | return "ipv4Encap"; | |
7313 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) | |
7314 | return "ipv6Unicast"; | |
7315 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
7316 | return "ipv6Multicast"; | |
7317 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
7318 | return "ipv6LabeledUnicast"; | |
7319 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
7320 | return "ipv6Vpn"; | |
7321 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
7322 | return "ipv6Encap"; | |
7323 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) | |
7324 | return "l2VpnEvpn"; | |
7325 | else | |
7326 | return "Unknown"; | |
27162734 LB |
7327 | } |
7328 | ||
718e3744 | 7329 | /* Show BGP peer's information. */ |
d62a17ae | 7330 | enum show_type { show_all, show_peer }; |
7331 | ||
7332 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
7333 | afi_t afi, safi_t safi, | |
7334 | u_int16_t adv_smcap, u_int16_t adv_rmcap, | |
7335 | u_int16_t rcv_smcap, u_int16_t rcv_rmcap, | |
7336 | u_char use_json, json_object *json_pref) | |
7337 | { | |
7338 | /* Send-Mode */ | |
7339 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
7340 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
7341 | if (use_json) { | |
7342 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
7343 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
7344 | json_object_string_add(json_pref, "sendMode", | |
7345 | "advertisedAndReceived"); | |
7346 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
7347 | json_object_string_add(json_pref, "sendMode", | |
7348 | "advertised"); | |
7349 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
7350 | json_object_string_add(json_pref, "sendMode", | |
7351 | "received"); | |
7352 | } else { | |
7353 | vty_out(vty, " Send-mode: "); | |
7354 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
7355 | vty_out(vty, "advertised"); | |
7356 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
7357 | vty_out(vty, "%sreceived", | |
7358 | CHECK_FLAG(p->af_cap[afi][safi], | |
7359 | adv_smcap) | |
7360 | ? ", " | |
7361 | : ""); | |
7362 | vty_out(vty, "\n"); | |
7363 | } | |
7364 | } | |
7365 | ||
7366 | /* Receive-Mode */ | |
7367 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
7368 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
7369 | if (use_json) { | |
7370 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
7371 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
7372 | json_object_string_add(json_pref, "recvMode", | |
7373 | "advertisedAndReceived"); | |
7374 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
7375 | json_object_string_add(json_pref, "recvMode", | |
7376 | "advertised"); | |
7377 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
7378 | json_object_string_add(json_pref, "recvMode", | |
7379 | "received"); | |
7380 | } else { | |
7381 | vty_out(vty, " Receive-mode: "); | |
7382 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
7383 | vty_out(vty, "advertised"); | |
7384 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
7385 | vty_out(vty, "%sreceived", | |
7386 | CHECK_FLAG(p->af_cap[afi][safi], | |
7387 | adv_rmcap) | |
7388 | ? ", " | |
7389 | : ""); | |
7390 | vty_out(vty, "\n"); | |
7391 | } | |
7392 | } | |
7393 | } | |
7394 | ||
7395 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, | |
7396 | safi_t safi, u_char use_json, | |
7397 | json_object *json_neigh) | |
7398 | { | |
0291c246 MK |
7399 | struct bgp_filter *filter; |
7400 | struct peer_af *paf; | |
7401 | char orf_pfx_name[BUFSIZ]; | |
7402 | int orf_pfx_count; | |
7403 | json_object *json_af = NULL; | |
7404 | json_object *json_prefA = NULL; | |
7405 | json_object *json_prefB = NULL; | |
7406 | json_object *json_addr = NULL; | |
d62a17ae | 7407 | |
7408 | if (use_json) { | |
7409 | json_addr = json_object_new_object(); | |
7410 | json_af = json_object_new_object(); | |
7411 | filter = &p->filter[afi][safi]; | |
7412 | ||
7413 | if (peer_group_active(p)) | |
7414 | json_object_string_add(json_addr, "peerGroupMember", | |
7415 | p->group->name); | |
7416 | ||
7417 | paf = peer_af_find(p, afi, safi); | |
7418 | if (paf && PAF_SUBGRP(paf)) { | |
7419 | json_object_int_add(json_addr, "updateGroupId", | |
7420 | PAF_UPDGRP(paf)->id); | |
7421 | json_object_int_add(json_addr, "subGroupId", | |
7422 | PAF_SUBGRP(paf)->id); | |
7423 | json_object_int_add(json_addr, "packetQueueLength", | |
7424 | bpacket_queue_virtual_length(paf)); | |
7425 | } | |
7426 | ||
7427 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7428 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7429 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7430 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7431 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7432 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7433 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
7434 | json_object_int_add(json_af, "orfType", | |
7435 | ORF_TYPE_PREFIX); | |
7436 | json_prefA = json_object_new_object(); | |
7437 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
7438 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
7439 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7440 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7441 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
7442 | use_json, json_prefA); | |
7443 | json_object_object_add(json_af, "orfPrefixList", | |
7444 | json_prefA); | |
7445 | } | |
7446 | ||
7447 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7448 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7449 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7450 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7451 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7452 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7453 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
7454 | json_object_int_add(json_af, "orfOldType", | |
7455 | ORF_TYPE_PREFIX_OLD); | |
7456 | json_prefB = json_object_new_object(); | |
7457 | bgp_show_peer_afi_orf_cap( | |
7458 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
7459 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7460 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7461 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
7462 | json_prefB); | |
7463 | json_object_object_add(json_af, "orfOldPrefixList", | |
7464 | json_prefB); | |
7465 | } | |
7466 | ||
7467 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7468 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7469 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7470 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7471 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7472 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7473 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7474 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7475 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
7476 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7477 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7478 | json_object_object_add(json_addr, "afDependentCap", | |
7479 | json_af); | |
7480 | else | |
7481 | json_object_free(json_af); | |
7482 | ||
7483 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
7484 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
7485 | NULL, afi, orf_pfx_name, use_json); | |
7486 | ||
7487 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7488 | PEER_STATUS_ORF_PREFIX_SEND) | |
7489 | || orf_pfx_count) { | |
7490 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7491 | PEER_STATUS_ORF_PREFIX_SEND)) | |
7492 | json_object_boolean_true_add(json_neigh, | |
7493 | "orfSent"); | |
7494 | if (orf_pfx_count) | |
7495 | json_object_int_add(json_addr, "orfRecvCounter", | |
7496 | orf_pfx_count); | |
7497 | } | |
7498 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7499 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
7500 | json_object_string_add( | |
7501 | json_addr, "orfFirstUpdate", | |
7502 | "deferredUntilORFOrRouteRefreshRecvd"); | |
7503 | ||
7504 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7505 | PEER_FLAG_REFLECTOR_CLIENT)) | |
7506 | json_object_boolean_true_add(json_addr, | |
7507 | "routeReflectorClient"); | |
7508 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7509 | PEER_FLAG_RSERVER_CLIENT)) | |
7510 | json_object_boolean_true_add(json_addr, | |
7511 | "routeServerClient"); | |
7512 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7513 | json_object_boolean_true_add(json_addr, | |
7514 | "inboundSoftConfigPermit"); | |
7515 | ||
7516 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7517 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
7518 | json_object_boolean_true_add( | |
7519 | json_addr, | |
7520 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
7521 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7522 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
7523 | json_object_boolean_true_add( | |
7524 | json_addr, | |
7525 | "privateAsNumsReplacedInUpdatesToNbr"); | |
7526 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7527 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
7528 | json_object_boolean_true_add( | |
7529 | json_addr, | |
7530 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
7531 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7532 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
7533 | json_object_boolean_true_add( | |
7534 | json_addr, | |
7535 | "privateAsNumsRemovedInUpdatesToNbr"); | |
7536 | ||
7537 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7538 | PEER_FLAG_ADDPATH_TX_ALL_PATHS)) | |
7539 | json_object_boolean_true_add(json_addr, | |
7540 | "addpathTxAllPaths"); | |
7541 | ||
7542 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7543 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
7544 | json_object_boolean_true_add(json_addr, | |
7545 | "addpathTxBestpathPerAS"); | |
7546 | ||
7547 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
7548 | json_object_string_add(json_addr, | |
7549 | "overrideASNsInOutboundUpdates", | |
7550 | "ifAspathEqualRemoteAs"); | |
7551 | ||
7552 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
7553 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7554 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7555 | json_object_boolean_true_add(json_addr, | |
7556 | "routerAlwaysNextHop"); | |
7557 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7558 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
7559 | json_object_boolean_true_add( | |
7560 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
7561 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7562 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7563 | json_object_boolean_true_add( | |
7564 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
7565 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7566 | json_object_boolean_true_add( | |
7567 | json_addr, "unchangedMedPropogatedToNbr"); | |
7568 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7569 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7570 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
7571 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7572 | PEER_FLAG_SEND_COMMUNITY) | |
7573 | && CHECK_FLAG(p->af_flags[afi][safi], | |
7574 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7575 | json_object_string_add(json_addr, | |
7576 | "commAttriSentToNbr", | |
7577 | "extendedAndStandard"); | |
7578 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7579 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7580 | json_object_string_add(json_addr, | |
7581 | "commAttriSentToNbr", | |
7582 | "extended"); | |
7583 | else | |
7584 | json_object_string_add(json_addr, | |
7585 | "commAttriSentToNbr", | |
7586 | "standard"); | |
7587 | } | |
7588 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7589 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
7590 | if (p->default_rmap[afi][safi].name) | |
7591 | json_object_string_add( | |
7592 | json_addr, "defaultRouteMap", | |
7593 | p->default_rmap[afi][safi].name); | |
7594 | ||
7595 | if (paf && PAF_SUBGRP(paf) | |
7596 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
7597 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7598 | json_object_boolean_true_add(json_addr, | |
7599 | "defaultSent"); | |
7600 | else | |
7601 | json_object_boolean_true_add(json_addr, | |
7602 | "defaultNotSent"); | |
7603 | } | |
7604 | ||
dff8f48d MK |
7605 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
7606 | if (p->bgp->advertise_all_vni) | |
7607 | json_object_boolean_true_add(json_addr, | |
7608 | "advertiseAllVnis"); | |
7609 | } | |
7610 | ||
d62a17ae | 7611 | if (filter->plist[FILTER_IN].name |
7612 | || filter->dlist[FILTER_IN].name | |
7613 | || filter->aslist[FILTER_IN].name | |
7614 | || filter->map[RMAP_IN].name) | |
7615 | json_object_boolean_true_add(json_addr, | |
7616 | "inboundPathPolicyConfig"); | |
7617 | if (filter->plist[FILTER_OUT].name | |
7618 | || filter->dlist[FILTER_OUT].name | |
7619 | || filter->aslist[FILTER_OUT].name | |
7620 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
7621 | json_object_boolean_true_add( | |
7622 | json_addr, "outboundPathPolicyConfig"); | |
7623 | ||
7624 | /* prefix-list */ | |
7625 | if (filter->plist[FILTER_IN].name) | |
7626 | json_object_string_add(json_addr, | |
7627 | "incomingUpdatePrefixFilterList", | |
7628 | filter->plist[FILTER_IN].name); | |
7629 | if (filter->plist[FILTER_OUT].name) | |
7630 | json_object_string_add(json_addr, | |
7631 | "outgoingUpdatePrefixFilterList", | |
7632 | filter->plist[FILTER_OUT].name); | |
7633 | ||
7634 | /* distribute-list */ | |
7635 | if (filter->dlist[FILTER_IN].name) | |
7636 | json_object_string_add( | |
7637 | json_addr, "incomingUpdateNetworkFilterList", | |
7638 | filter->dlist[FILTER_IN].name); | |
7639 | if (filter->dlist[FILTER_OUT].name) | |
7640 | json_object_string_add( | |
7641 | json_addr, "outgoingUpdateNetworkFilterList", | |
7642 | filter->dlist[FILTER_OUT].name); | |
7643 | ||
7644 | /* filter-list. */ | |
7645 | if (filter->aslist[FILTER_IN].name) | |
7646 | json_object_string_add(json_addr, | |
7647 | "incomingUpdateAsPathFilterList", | |
7648 | filter->aslist[FILTER_IN].name); | |
7649 | if (filter->aslist[FILTER_OUT].name) | |
7650 | json_object_string_add(json_addr, | |
7651 | "outgoingUpdateAsPathFilterList", | |
7652 | filter->aslist[FILTER_OUT].name); | |
7653 | ||
7654 | /* route-map. */ | |
7655 | if (filter->map[RMAP_IN].name) | |
7656 | json_object_string_add( | |
7657 | json_addr, "routeMapForIncomingAdvertisements", | |
7658 | filter->map[RMAP_IN].name); | |
7659 | if (filter->map[RMAP_OUT].name) | |
7660 | json_object_string_add( | |
7661 | json_addr, "routeMapForOutgoingAdvertisements", | |
7662 | filter->map[RMAP_OUT].name); | |
7663 | ||
7664 | /* unsuppress-map */ | |
7665 | if (filter->usmap.name) | |
7666 | json_object_string_add(json_addr, | |
7667 | "selectiveUnsuppressRouteMap", | |
7668 | filter->usmap.name); | |
7669 | ||
7670 | /* Receive prefix count */ | |
7671 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
7672 | p->pcount[afi][safi]); | |
7673 | ||
7674 | /* Maximum prefix */ | |
7675 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
7676 | json_object_int_add(json_addr, "prefixAllowedMax", | |
7677 | p->pmax[afi][safi]); | |
7678 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7679 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
7680 | json_object_boolean_true_add( | |
7681 | json_addr, "prefixAllowedMaxWarning"); | |
7682 | json_object_int_add(json_addr, | |
7683 | "prefixAllowedWarningThresh", | |
7684 | p->pmax_threshold[afi][safi]); | |
7685 | if (p->pmax_restart[afi][safi]) | |
7686 | json_object_int_add( | |
7687 | json_addr, | |
7688 | "prefixAllowedRestartIntervalMsecs", | |
7689 | p->pmax_restart[afi][safi] * 60000); | |
7690 | } | |
7691 | json_object_object_add(json_neigh, afi_safi_print(afi, safi), | |
7692 | json_addr); | |
7693 | ||
7694 | } else { | |
7695 | filter = &p->filter[afi][safi]; | |
7696 | ||
7697 | vty_out(vty, " For address family: %s\n", | |
7698 | afi_safi_print(afi, safi)); | |
7699 | ||
7700 | if (peer_group_active(p)) | |
7701 | vty_out(vty, " %s peer-group member\n", | |
7702 | p->group->name); | |
7703 | ||
7704 | paf = peer_af_find(p, afi, safi); | |
7705 | if (paf && PAF_SUBGRP(paf)) { | |
9d303b37 DL |
7706 | vty_out(vty, " Update group %" PRIu64 |
7707 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 7708 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
7709 | vty_out(vty, " Packet Queue length %d\n", | |
7710 | bpacket_queue_virtual_length(paf)); | |
7711 | } else { | |
7712 | vty_out(vty, " Not part of any update group\n"); | |
7713 | } | |
7714 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7715 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7716 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7717 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7718 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7719 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7720 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7721 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7722 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
7723 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7724 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
7725 | vty_out(vty, " AF-dependant capabilities:\n"); | |
7726 | ||
7727 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7728 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7729 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
7730 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7731 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7732 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7733 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
7734 | vty_out(vty, | |
7735 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
7736 | ORF_TYPE_PREFIX); | |
7737 | bgp_show_peer_afi_orf_cap( | |
7738 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
7739 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7740 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
7741 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
7742 | } | |
7743 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
7744 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7745 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
7746 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7747 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
7748 | || CHECK_FLAG(p->af_cap[afi][safi], | |
7749 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
7750 | vty_out(vty, | |
7751 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
7752 | ORF_TYPE_PREFIX_OLD); | |
7753 | bgp_show_peer_afi_orf_cap( | |
7754 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
7755 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
7756 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
7757 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
7758 | } | |
7759 | ||
7760 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
7761 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
7762 | NULL, afi, orf_pfx_name, use_json); | |
7763 | ||
7764 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7765 | PEER_STATUS_ORF_PREFIX_SEND) | |
7766 | || orf_pfx_count) { | |
7767 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
7768 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7769 | PEER_STATUS_ORF_PREFIX_SEND)) | |
7770 | vty_out(vty, " sent;"); | |
7771 | if (orf_pfx_count) | |
7772 | vty_out(vty, " received (%d entries)", | |
7773 | orf_pfx_count); | |
7774 | vty_out(vty, "\n"); | |
7775 | } | |
7776 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
7777 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
7778 | vty_out(vty, | |
7779 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
7780 | ||
7781 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7782 | PEER_FLAG_REFLECTOR_CLIENT)) | |
7783 | vty_out(vty, " Route-Reflector Client\n"); | |
7784 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7785 | PEER_FLAG_RSERVER_CLIENT)) | |
7786 | vty_out(vty, " Route-Server Client\n"); | |
7787 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
7788 | vty_out(vty, | |
7789 | " Inbound soft reconfiguration allowed\n"); | |
7790 | ||
7791 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7792 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
7793 | vty_out(vty, | |
7794 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
7795 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7796 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
7797 | vty_out(vty, | |
7798 | " Private AS numbers replaced in updates to this neighbor\n"); | |
7799 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7800 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
7801 | vty_out(vty, | |
7802 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
7803 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7804 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
7805 | vty_out(vty, | |
7806 | " Private AS numbers removed in updates to this neighbor\n"); | |
7807 | ||
7808 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7809 | PEER_FLAG_ADDPATH_TX_ALL_PATHS)) | |
7810 | vty_out(vty, " Advertise all paths via addpath\n"); | |
7811 | ||
7812 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7813 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
7814 | vty_out(vty, | |
7815 | " Advertise bestpath per AS via addpath\n"); | |
7816 | ||
7817 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
7818 | vty_out(vty, | |
7819 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
7820 | ||
7821 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
7822 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7823 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
7824 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
7825 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7826 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
7827 | vty_out(vty, | |
7828 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
7829 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7830 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
7831 | vty_out(vty, | |
7832 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
7833 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
7834 | vty_out(vty, | |
7835 | " MED is propagated unchanged to this neighbor\n"); | |
7836 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
7837 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7838 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
7839 | || CHECK_FLAG(p->af_flags[afi][safi], | |
7840 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
7841 | vty_out(vty, | |
7842 | " Community attribute sent to this neighbor"); | |
7843 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7844 | PEER_FLAG_SEND_COMMUNITY) | |
7845 | && CHECK_FLAG(p->af_flags[afi][safi], | |
7846 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
7847 | && CHECK_FLAG(p->af_flags[afi][safi], | |
7848 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7849 | vty_out(vty, "(all)\n"); | |
7850 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7851 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
7852 | vty_out(vty, "(large)\n"); | |
7853 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
7854 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
7855 | vty_out(vty, "(extended)\n"); | |
7856 | else | |
7857 | vty_out(vty, "(standard)\n"); | |
7858 | } | |
7859 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
7860 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
7861 | vty_out(vty, " Default information originate,"); | |
7862 | ||
7863 | if (p->default_rmap[afi][safi].name) | |
7864 | vty_out(vty, " default route-map %s%s,", | |
7865 | p->default_rmap[afi][safi].map ? "*" | |
7866 | : "", | |
7867 | p->default_rmap[afi][safi].name); | |
7868 | if (paf && PAF_SUBGRP(paf) | |
7869 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
7870 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
7871 | vty_out(vty, " default sent\n"); | |
7872 | else | |
7873 | vty_out(vty, " default not sent\n"); | |
7874 | } | |
7875 | ||
dff8f48d MK |
7876 | /* advertise-vni-all */ |
7877 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
7878 | if (p->bgp->advertise_all_vni) | |
7879 | vty_out(vty, " advertise-all-vni\n"); | |
7880 | } | |
7881 | ||
d62a17ae | 7882 | if (filter->plist[FILTER_IN].name |
7883 | || filter->dlist[FILTER_IN].name | |
7884 | || filter->aslist[FILTER_IN].name | |
7885 | || filter->map[RMAP_IN].name) | |
7886 | vty_out(vty, " Inbound path policy configured\n"); | |
7887 | if (filter->plist[FILTER_OUT].name | |
7888 | || filter->dlist[FILTER_OUT].name | |
7889 | || filter->aslist[FILTER_OUT].name | |
7890 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
7891 | vty_out(vty, " Outbound path policy configured\n"); | |
7892 | ||
7893 | /* prefix-list */ | |
7894 | if (filter->plist[FILTER_IN].name) | |
7895 | vty_out(vty, | |
7896 | " Incoming update prefix filter list is %s%s\n", | |
7897 | filter->plist[FILTER_IN].plist ? "*" : "", | |
7898 | filter->plist[FILTER_IN].name); | |
7899 | if (filter->plist[FILTER_OUT].name) | |
7900 | vty_out(vty, | |
7901 | " Outgoing update prefix filter list is %s%s\n", | |
7902 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
7903 | filter->plist[FILTER_OUT].name); | |
7904 | ||
7905 | /* distribute-list */ | |
7906 | if (filter->dlist[FILTER_IN].name) | |
7907 | vty_out(vty, | |
7908 | " Incoming update network filter list is %s%s\n", | |
7909 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
7910 | filter->dlist[FILTER_IN].name); | |
7911 | if (filter->dlist[FILTER_OUT].name) | |
7912 | vty_out(vty, | |
7913 | " Outgoing update network filter list is %s%s\n", | |
7914 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
7915 | filter->dlist[FILTER_OUT].name); | |
7916 | ||
7917 | /* filter-list. */ | |
7918 | if (filter->aslist[FILTER_IN].name) | |
7919 | vty_out(vty, | |
7920 | " Incoming update AS path filter list is %s%s\n", | |
7921 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
7922 | filter->aslist[FILTER_IN].name); | |
7923 | if (filter->aslist[FILTER_OUT].name) | |
7924 | vty_out(vty, | |
7925 | " Outgoing update AS path filter list is %s%s\n", | |
7926 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
7927 | filter->aslist[FILTER_OUT].name); | |
7928 | ||
7929 | /* route-map. */ | |
7930 | if (filter->map[RMAP_IN].name) | |
7931 | vty_out(vty, | |
7932 | " Route map for incoming advertisements is %s%s\n", | |
7933 | filter->map[RMAP_IN].map ? "*" : "", | |
7934 | filter->map[RMAP_IN].name); | |
7935 | if (filter->map[RMAP_OUT].name) | |
7936 | vty_out(vty, | |
7937 | " Route map for outgoing advertisements is %s%s\n", | |
7938 | filter->map[RMAP_OUT].map ? "*" : "", | |
7939 | filter->map[RMAP_OUT].name); | |
7940 | ||
7941 | /* unsuppress-map */ | |
7942 | if (filter->usmap.name) | |
7943 | vty_out(vty, | |
7944 | " Route map for selective unsuppress is %s%s\n", | |
7945 | filter->usmap.map ? "*" : "", | |
7946 | filter->usmap.name); | |
7947 | ||
7948 | /* Receive prefix count */ | |
7949 | vty_out(vty, " %ld accepted prefixes\n", p->pcount[afi][safi]); | |
7950 | ||
7951 | /* Maximum prefix */ | |
7952 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
7953 | vty_out(vty, " Maximum prefixes allowed %ld%s\n", | |
7954 | p->pmax[afi][safi], | |
7955 | CHECK_FLAG(p->af_flags[afi][safi], | |
7956 | PEER_FLAG_MAX_PREFIX_WARNING) | |
7957 | ? " (warning-only)" | |
7958 | : ""); | |
7959 | vty_out(vty, " Threshold for warning message %d%%", | |
7960 | p->pmax_threshold[afi][safi]); | |
7961 | if (p->pmax_restart[afi][safi]) | |
7962 | vty_out(vty, ", restart interval %d min", | |
7963 | p->pmax_restart[afi][safi]); | |
7964 | vty_out(vty, "\n"); | |
7965 | } | |
7966 | ||
7967 | vty_out(vty, "\n"); | |
7968 | } | |
7969 | } | |
7970 | ||
7971 | static void bgp_show_peer(struct vty *vty, struct peer *p, u_char use_json, | |
7972 | json_object *json) | |
718e3744 | 7973 | { |
d62a17ae | 7974 | struct bgp *bgp; |
7975 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
7976 | char timebuf[BGP_UPTIME_LEN]; | |
7977 | char dn_flag[2]; | |
7978 | const char *subcode_str; | |
7979 | const char *code_str; | |
7980 | afi_t afi; | |
7981 | safi_t safi; | |
7982 | u_int16_t i; | |
7983 | u_char *msg; | |
7984 | json_object *json_neigh = NULL; | |
7985 | time_t epoch_tbuf; | |
718e3744 | 7986 | |
d62a17ae | 7987 | bgp = p->bgp; |
7988 | ||
7989 | if (use_json) | |
7990 | json_neigh = json_object_new_object(); | |
7991 | ||
7992 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7993 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
7994 | dn_flag[0] = '*'; | |
7995 | ||
7996 | if (!use_json) { | |
7997 | if (p->conf_if) /* Configured interface name. */ | |
7998 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
7999 | BGP_PEER_SU_UNSPEC(p) | |
8000 | ? "None" | |
8001 | : sockunion2str(&p->su, buf, | |
8002 | SU_ADDRSTRLEN)); | |
8003 | else /* Configured IP address. */ | |
8004 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
8005 | p->host); | |
8006 | } | |
8007 | ||
8008 | if (use_json) { | |
8009 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
8010 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
8011 | "none"); | |
8012 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
8013 | json_object_string_add( | |
8014 | json_neigh, "bgpNeighborAddr", | |
8015 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
8016 | ||
8017 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
8018 | ||
8019 | if (p->change_local_as) | |
8020 | json_object_int_add(json_neigh, "localAs", | |
8021 | p->change_local_as); | |
8022 | else | |
8023 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
8024 | ||
8025 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
8026 | json_object_boolean_true_add(json_neigh, | |
8027 | "localAsNoPrepend"); | |
8028 | ||
8029 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
8030 | json_object_boolean_true_add(json_neigh, | |
8031 | "localAsReplaceAs"); | |
8032 | } else { | |
8033 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
8034 | || (p->as_type == AS_INTERNAL)) | |
8035 | vty_out(vty, "remote AS %u, ", p->as); | |
8036 | else | |
8037 | vty_out(vty, "remote AS Unspecified, "); | |
8038 | vty_out(vty, "local AS %u%s%s, ", | |
8039 | p->change_local_as ? p->change_local_as : p->local_as, | |
8040 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
8041 | ? " no-prepend" | |
8042 | : "", | |
8043 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
8044 | ? " replace-as" | |
8045 | : ""); | |
8046 | } | |
8047 | /* peer type internal, external, confed-internal or confed-external */ | |
8048 | if (p->as == p->local_as) { | |
8049 | if (use_json) { | |
8050 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
8051 | json_object_boolean_true_add( | |
8052 | json_neigh, "nbrConfedInternalLink"); | |
8053 | else | |
8054 | json_object_boolean_true_add(json_neigh, | |
8055 | "nbrInternalLink"); | |
8056 | } else { | |
8057 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
8058 | vty_out(vty, "confed-internal link\n"); | |
8059 | else | |
8060 | vty_out(vty, "internal link\n"); | |
8061 | } | |
8062 | } else { | |
8063 | if (use_json) { | |
8064 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
8065 | json_object_boolean_true_add( | |
8066 | json_neigh, "nbrConfedExternalLink"); | |
8067 | else | |
8068 | json_object_boolean_true_add(json_neigh, | |
8069 | "nbrExternalLink"); | |
8070 | } else { | |
8071 | if (bgp_confederation_peers_check(bgp, p->as)) | |
8072 | vty_out(vty, "confed-external link\n"); | |
8073 | else | |
8074 | vty_out(vty, "external link\n"); | |
8075 | } | |
8076 | } | |
8077 | ||
8078 | /* Description. */ | |
8079 | if (p->desc) { | |
8080 | if (use_json) | |
8081 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
8082 | else | |
8083 | vty_out(vty, " Description: %s\n", p->desc); | |
8084 | } | |
8085 | ||
8086 | if (p->hostname) { | |
8087 | if (use_json) { | |
8088 | if (p->hostname) | |
8089 | json_object_string_add(json_neigh, "hostname", | |
8090 | p->hostname); | |
8091 | ||
8092 | if (p->domainname) | |
8093 | json_object_string_add(json_neigh, "domainname", | |
8094 | p->domainname); | |
8095 | } else { | |
8096 | if (p->domainname && (p->domainname[0] != '\0')) | |
8097 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
8098 | p->domainname); | |
8099 | else | |
8100 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
8101 | } | |
8102 | } | |
8103 | ||
8104 | /* Peer-group */ | |
8105 | if (p->group) { | |
8106 | if (use_json) { | |
8107 | json_object_string_add(json_neigh, "peerGroup", | |
8108 | p->group->name); | |
8109 | ||
8110 | if (dn_flag[0]) { | |
8111 | struct prefix prefix, *range = NULL; | |
8112 | ||
8113 | sockunion2hostprefix(&(p->su), &prefix); | |
8114 | range = peer_group_lookup_dynamic_neighbor_range( | |
8115 | p->group, &prefix); | |
8116 | ||
8117 | if (range) { | |
8118 | prefix2str(range, buf1, sizeof(buf1)); | |
8119 | json_object_string_add( | |
8120 | json_neigh, | |
8121 | "peerSubnetRangeGroup", buf1); | |
8122 | } | |
8123 | } | |
8124 | } else { | |
8125 | vty_out(vty, | |
8126 | " Member of peer-group %s for session parameters\n", | |
8127 | p->group->name); | |
8128 | ||
8129 | if (dn_flag[0]) { | |
8130 | struct prefix prefix, *range = NULL; | |
8131 | ||
8132 | sockunion2hostprefix(&(p->su), &prefix); | |
8133 | range = peer_group_lookup_dynamic_neighbor_range( | |
8134 | p->group, &prefix); | |
8135 | ||
8136 | if (range) { | |
8137 | prefix2str(range, buf1, sizeof(buf1)); | |
8138 | vty_out(vty, | |
8139 | " Belongs to the subnet range group: %s\n", | |
8140 | buf1); | |
8141 | } | |
8142 | } | |
8143 | } | |
8144 | } | |
8145 | ||
8146 | if (use_json) { | |
8147 | /* Administrative shutdown. */ | |
8148 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
8149 | json_object_boolean_true_add(json_neigh, | |
8150 | "adminShutDown"); | |
8151 | ||
8152 | /* BGP Version. */ | |
8153 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
8154 | json_object_string_add( | |
8155 | json_neigh, "remoteRouterId", | |
8156 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
8157 | ||
8158 | /* Confederation */ | |
8159 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
8160 | && bgp_confederation_peers_check(bgp, p->as)) | |
8161 | json_object_boolean_true_add(json_neigh, | |
8162 | "nbrCommonAdmin"); | |
8163 | ||
8164 | /* Status. */ | |
8165 | json_object_string_add( | |
8166 | json_neigh, "bgpState", | |
8167 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
8168 | ||
8169 | if (p->status == Established) { | |
8170 | time_t uptime; | |
8171 | struct tm *tm; | |
8172 | ||
8173 | uptime = bgp_clock(); | |
8174 | uptime -= p->uptime; | |
8175 | tm = gmtime(&uptime); | |
8176 | epoch_tbuf = time(NULL) - uptime; | |
8177 | ||
8178 | json_object_int_add(json_neigh, "bgpTimerUp", | |
8179 | (tm->tm_sec * 1000) | |
8180 | + (tm->tm_min * 60000) | |
8181 | + (tm->tm_hour * 3600000)); | |
8182 | json_object_string_add(json_neigh, "bgpTimerUpString", | |
8183 | peer_uptime(p->uptime, timebuf, | |
8184 | BGP_UPTIME_LEN, 0, | |
8185 | NULL)); | |
8186 | json_object_int_add(json_neigh, | |
8187 | "bgpTimerUpEstablishedEpoch", | |
8188 | epoch_tbuf); | |
8189 | } | |
8190 | ||
8191 | else if (p->status == Active) { | |
8192 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
8193 | json_object_string_add(json_neigh, "bgpStateIs", | |
8194 | "passive"); | |
8195 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
8196 | json_object_string_add(json_neigh, "bgpStateIs", | |
8197 | "passiveNSF"); | |
8198 | } | |
8199 | ||
8200 | /* read timer */ | |
8201 | time_t uptime; | |
8202 | struct tm *tm; | |
8203 | ||
8204 | uptime = bgp_clock(); | |
8205 | uptime -= p->readtime; | |
8206 | tm = gmtime(&uptime); | |
8207 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
8208 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
8209 | + (tm->tm_hour * 3600000)); | |
8210 | ||
8211 | uptime = bgp_clock(); | |
8212 | uptime -= p->last_write; | |
8213 | tm = gmtime(&uptime); | |
8214 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
8215 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
8216 | + (tm->tm_hour * 3600000)); | |
8217 | ||
8218 | uptime = bgp_clock(); | |
8219 | uptime -= p->update_time; | |
8220 | tm = gmtime(&uptime); | |
8221 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
8222 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
8223 | + (tm->tm_hour * 3600000)); | |
8224 | ||
8225 | /* Configured timer values. */ | |
8226 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
8227 | p->v_holdtime * 1000); | |
8228 | json_object_int_add(json_neigh, | |
8229 | "bgpTimerKeepAliveIntervalMsecs", | |
8230 | p->v_keepalive * 1000); | |
8231 | ||
8232 | if (CHECK_FLAG(p->config, PEER_CONFIG_TIMER)) { | |
8233 | json_object_int_add(json_neigh, | |
8234 | "bgpTimerConfiguredHoldTimeMsecs", | |
8235 | p->holdtime * 1000); | |
8236 | json_object_int_add( | |
8237 | json_neigh, | |
8238 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
8239 | p->keepalive * 1000); | |
8240 | } | |
8241 | } else { | |
8242 | /* Administrative shutdown. */ | |
8243 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
8244 | vty_out(vty, " Administratively shut down\n"); | |
8245 | ||
8246 | /* BGP Version. */ | |
8247 | vty_out(vty, " BGP version 4"); | |
8248 | vty_out(vty, ", remote router ID %s\n", | |
8249 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
8250 | ||
8251 | /* Confederation */ | |
8252 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
8253 | && bgp_confederation_peers_check(bgp, p->as)) | |
8254 | vty_out(vty, | |
8255 | " Neighbor under common administration\n"); | |
8256 | ||
8257 | /* Status. */ | |
8258 | vty_out(vty, " BGP state = %s", | |
8259 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
8260 | ||
8261 | if (p->status == Established) | |
8262 | vty_out(vty, ", up for %8s", | |
8263 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
8264 | 0, NULL)); | |
8265 | ||
8266 | else if (p->status == Active) { | |
8267 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
8268 | vty_out(vty, " (passive)"); | |
8269 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
8270 | vty_out(vty, " (NSF passive)"); | |
8271 | } | |
8272 | vty_out(vty, "\n"); | |
8273 | ||
8274 | /* read timer */ | |
8275 | vty_out(vty, " Last read %s", | |
8276 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
8277 | NULL)); | |
8278 | vty_out(vty, ", Last write %s\n", | |
8279 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
8280 | NULL)); | |
8281 | ||
8282 | /* Configured timer values. */ | |
8283 | vty_out(vty, | |
8284 | " Hold time is %d, keepalive interval is %d seconds\n", | |
8285 | p->v_holdtime, p->v_keepalive); | |
8286 | if (CHECK_FLAG(p->config, PEER_CONFIG_TIMER)) { | |
8287 | vty_out(vty, " Configured hold time is %d", | |
8288 | p->holdtime); | |
8289 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
8290 | p->keepalive); | |
8291 | } | |
8292 | } | |
8293 | /* Capability. */ | |
8294 | if (p->status == Established) { | |
8295 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
8296 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
8297 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
8298 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
8299 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
8300 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
8301 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
8302 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
8303 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
8304 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
8305 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
8306 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
8307 | || p->afc_adv[AFI_IP][SAFI_ENCAP] | |
8308 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
8309 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] | |
8310 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
8311 | if (use_json) { | |
8312 | json_object *json_cap = NULL; | |
8313 | ||
8314 | json_cap = json_object_new_object(); | |
8315 | ||
8316 | /* AS4 */ | |
8317 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
8318 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
8319 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
8320 | && CHECK_FLAG(p->cap, | |
8321 | PEER_CAP_AS4_RCV)) | |
8322 | json_object_string_add( | |
8323 | json_cap, "4byteAs", | |
8324 | "advertisedAndReceived"); | |
8325 | else if (CHECK_FLAG(p->cap, | |
8326 | PEER_CAP_AS4_ADV)) | |
8327 | json_object_string_add( | |
8328 | json_cap, "4byteAs", | |
8329 | "advertised"); | |
8330 | else if (CHECK_FLAG(p->cap, | |
8331 | PEER_CAP_AS4_RCV)) | |
8332 | json_object_string_add( | |
8333 | json_cap, "4byteAs", | |
8334 | "received"); | |
8335 | } | |
8336 | ||
8337 | /* AddPath */ | |
8338 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
8339 | || CHECK_FLAG(p->cap, | |
8340 | PEER_CAP_ADDPATH_ADV)) { | |
8341 | json_object *json_add = NULL; | |
8342 | const char *print_store; | |
8343 | ||
8344 | json_add = json_object_new_object(); | |
8345 | ||
8346 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
8347 | for (safi = SAFI_UNICAST; | |
8348 | safi < SAFI_MAX; safi++) { | |
8349 | json_object *json_sub = | |
8350 | NULL; | |
8351 | json_sub = | |
8352 | json_object_new_object(); | |
8353 | print_store = | |
8354 | afi_safi_print( | |
8355 | afi, | |
8356 | safi); | |
8357 | ||
8358 | if (CHECK_FLAG( | |
8359 | p->af_cap | |
8360 | [afi] | |
8361 | [safi], | |
8362 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8363 | || CHECK_FLAG( | |
8364 | p->af_cap | |
8365 | [afi] | |
8366 | [safi], | |
8367 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
8368 | if (CHECK_FLAG( | |
8369 | p->af_cap | |
8370 | [afi] | |
8371 | [safi], | |
8372 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8373 | && CHECK_FLAG( | |
8374 | p->af_cap | |
8375 | [afi] | |
8376 | [safi], | |
8377 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8378 | json_object_boolean_true_add( | |
8379 | json_sub, | |
8380 | "txAdvertisedAndReceived"); | |
8381 | else if ( | |
8382 | CHECK_FLAG( | |
8383 | p->af_cap | |
8384 | [afi] | |
8385 | [safi], | |
8386 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
8387 | json_object_boolean_true_add( | |
8388 | json_sub, | |
8389 | "txAdvertised"); | |
8390 | else if ( | |
8391 | CHECK_FLAG( | |
8392 | p->af_cap | |
8393 | [afi] | |
8394 | [safi], | |
8395 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8396 | json_object_boolean_true_add( | |
8397 | json_sub, | |
8398 | "txReceived"); | |
8399 | } | |
8400 | ||
8401 | if (CHECK_FLAG( | |
8402 | p->af_cap | |
8403 | [afi] | |
8404 | [safi], | |
8405 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8406 | || CHECK_FLAG( | |
8407 | p->af_cap | |
8408 | [afi] | |
8409 | [safi], | |
8410 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
8411 | if (CHECK_FLAG( | |
8412 | p->af_cap | |
8413 | [afi] | |
8414 | [safi], | |
8415 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8416 | && CHECK_FLAG( | |
8417 | p->af_cap | |
8418 | [afi] | |
8419 | [safi], | |
8420 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8421 | json_object_boolean_true_add( | |
8422 | json_sub, | |
8423 | "rxAdvertisedAndReceived"); | |
8424 | else if ( | |
8425 | CHECK_FLAG( | |
8426 | p->af_cap | |
8427 | [afi] | |
8428 | [safi], | |
8429 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
8430 | json_object_boolean_true_add( | |
8431 | json_sub, | |
8432 | "rxAdvertised"); | |
8433 | else if ( | |
8434 | CHECK_FLAG( | |
8435 | p->af_cap | |
8436 | [afi] | |
8437 | [safi], | |
8438 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8439 | json_object_boolean_true_add( | |
8440 | json_sub, | |
8441 | "rxReceived"); | |
8442 | } | |
8443 | ||
8444 | if (CHECK_FLAG( | |
8445 | p->af_cap | |
8446 | [afi] | |
8447 | [safi], | |
8448 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8449 | || CHECK_FLAG( | |
8450 | p->af_cap | |
8451 | [afi] | |
8452 | [safi], | |
8453 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
8454 | || CHECK_FLAG( | |
8455 | p->af_cap | |
8456 | [afi] | |
8457 | [safi], | |
8458 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8459 | || CHECK_FLAG( | |
8460 | p->af_cap | |
8461 | [afi] | |
8462 | [safi], | |
8463 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8464 | json_object_object_add( | |
8465 | json_add, | |
8466 | print_store, | |
8467 | json_sub); | |
8468 | else | |
8469 | json_object_free( | |
8470 | json_sub); | |
8471 | } | |
8472 | ||
8473 | json_object_object_add( | |
8474 | json_cap, "addPath", json_add); | |
8475 | } | |
8476 | ||
8477 | /* Dynamic */ | |
8478 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
8479 | || CHECK_FLAG(p->cap, | |
8480 | PEER_CAP_DYNAMIC_ADV)) { | |
8481 | if (CHECK_FLAG(p->cap, | |
8482 | PEER_CAP_DYNAMIC_ADV) | |
8483 | && CHECK_FLAG(p->cap, | |
8484 | PEER_CAP_DYNAMIC_RCV)) | |
8485 | json_object_string_add( | |
8486 | json_cap, "dynamic", | |
8487 | "advertisedAndReceived"); | |
8488 | else if (CHECK_FLAG( | |
8489 | p->cap, | |
8490 | PEER_CAP_DYNAMIC_ADV)) | |
8491 | json_object_string_add( | |
8492 | json_cap, "dynamic", | |
8493 | "advertised"); | |
8494 | else if (CHECK_FLAG( | |
8495 | p->cap, | |
8496 | PEER_CAP_DYNAMIC_RCV)) | |
8497 | json_object_string_add( | |
8498 | json_cap, "dynamic", | |
8499 | "received"); | |
8500 | } | |
8501 | ||
8502 | /* Extended nexthop */ | |
8503 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
8504 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
8505 | json_object *json_nxt = NULL; | |
8506 | const char *print_store; | |
8507 | ||
8508 | ||
8509 | if (CHECK_FLAG(p->cap, | |
8510 | PEER_CAP_ENHE_ADV) | |
8511 | && CHECK_FLAG(p->cap, | |
8512 | PEER_CAP_ENHE_RCV)) | |
8513 | json_object_string_add( | |
8514 | json_cap, | |
8515 | "extendedNexthop", | |
8516 | "advertisedAndReceived"); | |
8517 | else if (CHECK_FLAG(p->cap, | |
8518 | PEER_CAP_ENHE_ADV)) | |
8519 | json_object_string_add( | |
8520 | json_cap, | |
8521 | "extendedNexthop", | |
8522 | "advertised"); | |
8523 | else if (CHECK_FLAG(p->cap, | |
8524 | PEER_CAP_ENHE_RCV)) | |
8525 | json_object_string_add( | |
8526 | json_cap, | |
8527 | "extendedNexthop", | |
8528 | "received"); | |
8529 | ||
8530 | if (CHECK_FLAG(p->cap, | |
8531 | PEER_CAP_ENHE_RCV)) { | |
8532 | json_nxt = | |
8533 | json_object_new_object(); | |
8534 | ||
8535 | for (safi = SAFI_UNICAST; | |
8536 | safi < SAFI_MAX; safi++) { | |
8537 | if (CHECK_FLAG( | |
8538 | p->af_cap | |
8539 | [AFI_IP] | |
8540 | [safi], | |
8541 | PEER_CAP_ENHE_AF_RCV)) { | |
8542 | print_store = afi_safi_print( | |
8543 | AFI_IP, | |
8544 | safi); | |
8545 | json_object_string_add( | |
8546 | json_nxt, | |
8547 | print_store, | |
8548 | "recieved"); | |
8549 | } | |
8550 | } | |
8551 | json_object_object_add( | |
8552 | json_cap, | |
8553 | "extendedNexthopFamililesByPeer", | |
8554 | json_nxt); | |
8555 | } | |
8556 | } | |
8557 | ||
8558 | /* Route Refresh */ | |
8559 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
8560 | || CHECK_FLAG(p->cap, | |
8561 | PEER_CAP_REFRESH_NEW_RCV) | |
8562 | || CHECK_FLAG(p->cap, | |
8563 | PEER_CAP_REFRESH_OLD_RCV)) { | |
8564 | if (CHECK_FLAG(p->cap, | |
8565 | PEER_CAP_REFRESH_ADV) | |
8566 | && (CHECK_FLAG( | |
8567 | p->cap, | |
8568 | PEER_CAP_REFRESH_NEW_RCV) | |
8569 | || CHECK_FLAG( | |
8570 | p->cap, | |
8571 | PEER_CAP_REFRESH_OLD_RCV))) { | |
8572 | if (CHECK_FLAG( | |
8573 | p->cap, | |
8574 | PEER_CAP_REFRESH_OLD_RCV) | |
8575 | && CHECK_FLAG( | |
8576 | p->cap, | |
8577 | PEER_CAP_REFRESH_NEW_RCV)) | |
8578 | json_object_string_add( | |
8579 | json_cap, | |
8580 | "routeRefresh", | |
8581 | "advertisedAndReceivedOldNew"); | |
8582 | else { | |
8583 | if (CHECK_FLAG( | |
8584 | p->cap, | |
8585 | PEER_CAP_REFRESH_OLD_RCV)) | |
8586 | json_object_string_add( | |
8587 | json_cap, | |
8588 | "routeRefresh", | |
8589 | "advertisedAndReceivedOld"); | |
8590 | else | |
8591 | json_object_string_add( | |
8592 | json_cap, | |
8593 | "routeRefresh", | |
8594 | "advertisedAndReceivedNew"); | |
8595 | } | |
8596 | } else if ( | |
8597 | CHECK_FLAG( | |
8598 | p->cap, | |
8599 | PEER_CAP_REFRESH_ADV)) | |
8600 | json_object_string_add( | |
8601 | json_cap, | |
8602 | "routeRefresh", | |
8603 | "advertised"); | |
8604 | else if ( | |
8605 | CHECK_FLAG( | |
8606 | p->cap, | |
8607 | PEER_CAP_REFRESH_NEW_RCV) | |
8608 | || CHECK_FLAG( | |
8609 | p->cap, | |
8610 | PEER_CAP_REFRESH_OLD_RCV)) | |
8611 | json_object_string_add( | |
8612 | json_cap, | |
8613 | "routeRefresh", | |
8614 | "received"); | |
8615 | } | |
8616 | ||
8617 | /* Multiprotocol Extensions */ | |
8618 | json_object *json_multi = NULL; | |
8619 | json_multi = json_object_new_object(); | |
8620 | ||
8621 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
8622 | for (safi = SAFI_UNICAST; | |
8623 | safi < SAFI_MAX; safi++) { | |
8624 | if (p->afc_adv[afi][safi] | |
8625 | || p->afc_recv[afi][safi]) { | |
8626 | json_object | |
8627 | *json_exten = | |
8628 | NULL; | |
8629 | json_exten = | |
8630 | json_object_new_object(); | |
8631 | ||
8632 | if (p->afc_adv[afi] | |
8633 | [safi] | |
8634 | && p->afc_recv | |
8635 | [afi] | |
8636 | [safi]) | |
8637 | json_object_boolean_true_add( | |
8638 | json_exten, | |
8639 | "advertisedAndReceived"); | |
8640 | else if (p->afc_adv | |
8641 | [afi] | |
8642 | [safi]) | |
8643 | json_object_boolean_true_add( | |
8644 | json_exten, | |
8645 | "advertised"); | |
8646 | else if (p->afc_recv | |
8647 | [afi] | |
8648 | [safi]) | |
8649 | json_object_boolean_true_add( | |
8650 | json_exten, | |
8651 | "received"); | |
8652 | ||
8653 | json_object_object_add( | |
8654 | json_multi, | |
8655 | afi_safi_print( | |
8656 | afi, | |
8657 | safi), | |
8658 | json_exten); | |
8659 | } | |
8660 | } | |
8661 | } | |
8662 | json_object_object_add( | |
8663 | json_cap, "multiprotocolExtensions", | |
8664 | json_multi); | |
8665 | ||
d77114b7 MK |
8666 | /* Hostname capabilities */ |
8667 | json_object *json_hname = NULL; | |
8668 | ||
8669 | json_hname = json_object_new_object(); | |
8670 | ||
8671 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
8672 | json_object_string_add( | |
8673 | json_hname, | |
8674 | "advHostName", | |
8675 | bgp->peer_self->hostname ? | |
8676 | bgp->peer_self->hostname | |
8677 | : "n/a"); | |
8678 | json_object_string_add( | |
8679 | json_hname, | |
8680 | "advDomainName", | |
8681 | bgp->peer_self->domainname ? | |
8682 | bgp->peer_self->domainname | |
8683 | : "n/a"); | |
8684 | } | |
8685 | ||
8686 | ||
8687 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
8688 | json_object_string_add( | |
8689 | json_hname, | |
8690 | "rcvHostName", | |
8691 | p->hostname ? | |
8692 | p->hostname : | |
8693 | "n/a"); | |
8694 | json_object_string_add( | |
8695 | json_hname, | |
8696 | "rcvDomainName", | |
8697 | p->domainname ? | |
8698 | p->domainname : | |
8699 | "n/a"); | |
8700 | } | |
8701 | ||
8702 | json_object_object_add(json_cap, | |
8703 | "hostName", | |
8704 | json_hname); | |
8705 | ||
d62a17ae | 8706 | /* Gracefull Restart */ |
8707 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
8708 | || CHECK_FLAG(p->cap, | |
8709 | PEER_CAP_RESTART_ADV)) { | |
8710 | if (CHECK_FLAG(p->cap, | |
8711 | PEER_CAP_RESTART_ADV) | |
8712 | && CHECK_FLAG(p->cap, | |
8713 | PEER_CAP_RESTART_RCV)) | |
8714 | json_object_string_add( | |
8715 | json_cap, | |
8716 | "gracefulRestart", | |
8717 | "advertisedAndReceived"); | |
8718 | else if (CHECK_FLAG( | |
8719 | p->cap, | |
8720 | PEER_CAP_RESTART_ADV)) | |
8721 | json_object_string_add( | |
8722 | json_cap, | |
8723 | "gracefulRestartCapability", | |
8724 | "advertised"); | |
8725 | else if (CHECK_FLAG( | |
8726 | p->cap, | |
8727 | PEER_CAP_RESTART_RCV)) | |
8728 | json_object_string_add( | |
8729 | json_cap, | |
8730 | "gracefulRestartCapability", | |
8731 | "received"); | |
8732 | ||
8733 | if (CHECK_FLAG(p->cap, | |
8734 | PEER_CAP_RESTART_RCV)) { | |
8735 | int restart_af_count = 0; | |
8736 | json_object *json_restart = | |
8737 | NULL; | |
8738 | json_restart = | |
8739 | json_object_new_object(); | |
8740 | ||
8741 | json_object_int_add( | |
8742 | json_cap, | |
8743 | "gracefulRestartRemoteTimerMsecs", | |
8744 | p->v_gr_restart * 1000); | |
8745 | ||
8746 | for (afi = AFI_IP; | |
8747 | afi < AFI_MAX; afi++) { | |
8748 | for (safi = SAFI_UNICAST; | |
8749 | safi < SAFI_MAX; | |
8750 | safi++) { | |
8751 | if (CHECK_FLAG( | |
8752 | p->af_cap | |
8753 | [afi] | |
8754 | [safi], | |
8755 | PEER_CAP_RESTART_AF_RCV)) { | |
8756 | json_object *json_sub = | |
8757 | NULL; | |
8758 | json_sub = | |
8759 | json_object_new_object(); | |
8760 | ||
8761 | if (CHECK_FLAG( | |
8762 | p->af_cap | |
8763 | [afi] | |
8764 | [safi], | |
8765 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) | |
8766 | json_object_boolean_true_add( | |
8767 | json_sub, | |
8768 | "preserved"); | |
8769 | restart_af_count++; | |
8770 | json_object_object_add( | |
8771 | json_restart, | |
8772 | afi_safi_print( | |
8773 | afi, | |
8774 | safi), | |
8775 | json_sub); | |
8776 | } | |
8777 | } | |
8778 | } | |
8779 | if (!restart_af_count) { | |
8780 | json_object_string_add( | |
8781 | json_cap, | |
8782 | "addressFamiliesByPeer", | |
8783 | "none"); | |
8784 | json_object_free( | |
8785 | json_restart); | |
8786 | } else | |
8787 | json_object_object_add( | |
8788 | json_cap, | |
8789 | "addressFamiliesByPeer", | |
8790 | json_restart); | |
8791 | } | |
8792 | } | |
8793 | json_object_object_add(json_neigh, | |
8794 | "neighborCapabilities", | |
8795 | json_cap); | |
8796 | } else { | |
8797 | vty_out(vty, " Neighbor capabilities:\n"); | |
8798 | ||
8799 | /* AS4 */ | |
8800 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
8801 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
8802 | vty_out(vty, " 4 Byte AS:"); | |
8803 | if (CHECK_FLAG(p->cap, | |
8804 | PEER_CAP_AS4_ADV)) | |
8805 | vty_out(vty, " advertised"); | |
8806 | if (CHECK_FLAG(p->cap, | |
8807 | PEER_CAP_AS4_RCV)) | |
8808 | vty_out(vty, " %sreceived", | |
8809 | CHECK_FLAG( | |
8810 | p->cap, | |
8811 | PEER_CAP_AS4_ADV) | |
8812 | ? "and " | |
8813 | : ""); | |
8814 | vty_out(vty, "\n"); | |
8815 | } | |
8816 | ||
8817 | /* AddPath */ | |
8818 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
8819 | || CHECK_FLAG(p->cap, | |
8820 | PEER_CAP_ADDPATH_ADV)) { | |
8821 | vty_out(vty, " AddPath:\n"); | |
8822 | ||
8823 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
8824 | for (safi = SAFI_UNICAST; | |
8825 | safi < SAFI_MAX; safi++) { | |
8826 | if (CHECK_FLAG( | |
8827 | p->af_cap | |
8828 | [afi] | |
8829 | [safi], | |
8830 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8831 | || CHECK_FLAG( | |
8832 | p->af_cap | |
8833 | [afi] | |
8834 | [safi], | |
8835 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
8836 | vty_out(vty, | |
8837 | " %s: TX ", | |
8838 | afi_safi_print( | |
8839 | afi, | |
8840 | safi)); | |
8841 | ||
8842 | if (CHECK_FLAG( | |
8843 | p->af_cap | |
8844 | [afi] | |
8845 | [safi], | |
8846 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
8847 | vty_out(vty, | |
8848 | "advertised %s", | |
8849 | afi_safi_print( | |
8850 | afi, | |
8851 | safi)); | |
8852 | ||
8853 | if (CHECK_FLAG( | |
8854 | p->af_cap | |
8855 | [afi] | |
8856 | [safi], | |
8857 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
8858 | vty_out(vty, | |
8859 | "%sreceived", | |
8860 | CHECK_FLAG( | |
8861 | p->af_cap | |
8862 | [afi] | |
8863 | [safi], | |
8864 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
8865 | ? " and " | |
8866 | : ""); | |
8867 | ||
8868 | vty_out(vty, | |
8869 | "\n"); | |
8870 | } | |
8871 | ||
8872 | if (CHECK_FLAG( | |
8873 | p->af_cap | |
8874 | [afi] | |
8875 | [safi], | |
8876 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8877 | || CHECK_FLAG( | |
8878 | p->af_cap | |
8879 | [afi] | |
8880 | [safi], | |
8881 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
8882 | vty_out(vty, | |
8883 | " %s: RX ", | |
8884 | afi_safi_print( | |
8885 | afi, | |
8886 | safi)); | |
8887 | ||
8888 | if (CHECK_FLAG( | |
8889 | p->af_cap | |
8890 | [afi] | |
8891 | [safi], | |
8892 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
8893 | vty_out(vty, | |
8894 | "advertised %s", | |
8895 | afi_safi_print( | |
8896 | afi, | |
8897 | safi)); | |
8898 | ||
8899 | if (CHECK_FLAG( | |
8900 | p->af_cap | |
8901 | [afi] | |
8902 | [safi], | |
8903 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
8904 | vty_out(vty, | |
8905 | "%sreceived", | |
8906 | CHECK_FLAG( | |
8907 | p->af_cap | |
8908 | [afi] | |
8909 | [safi], | |
8910 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
8911 | ? " and " | |
8912 | : ""); | |
8913 | ||
8914 | vty_out(vty, | |
8915 | "\n"); | |
8916 | } | |
8917 | } | |
8918 | } | |
8919 | ||
8920 | /* Dynamic */ | |
8921 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
8922 | || CHECK_FLAG(p->cap, | |
8923 | PEER_CAP_DYNAMIC_ADV)) { | |
8924 | vty_out(vty, " Dynamic:"); | |
8925 | if (CHECK_FLAG(p->cap, | |
8926 | PEER_CAP_DYNAMIC_ADV)) | |
8927 | vty_out(vty, " advertised"); | |
8928 | if (CHECK_FLAG(p->cap, | |
8929 | PEER_CAP_DYNAMIC_RCV)) | |
8930 | vty_out(vty, " %sreceived", | |
8931 | CHECK_FLAG( | |
8932 | p->cap, | |
8933 | PEER_CAP_DYNAMIC_ADV) | |
8934 | ? "and " | |
8935 | : ""); | |
8936 | vty_out(vty, "\n"); | |
8937 | } | |
8938 | ||
8939 | /* Extended nexthop */ | |
8940 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
8941 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
8942 | vty_out(vty, " Extended nexthop:"); | |
8943 | if (CHECK_FLAG(p->cap, | |
8944 | PEER_CAP_ENHE_ADV)) | |
8945 | vty_out(vty, " advertised"); | |
8946 | if (CHECK_FLAG(p->cap, | |
8947 | PEER_CAP_ENHE_RCV)) | |
8948 | vty_out(vty, " %sreceived", | |
8949 | CHECK_FLAG( | |
8950 | p->cap, | |
8951 | PEER_CAP_ENHE_ADV) | |
8952 | ? "and " | |
8953 | : ""); | |
8954 | vty_out(vty, "\n"); | |
8955 | ||
8956 | if (CHECK_FLAG(p->cap, | |
8957 | PEER_CAP_ENHE_RCV)) { | |
8958 | vty_out(vty, | |
8959 | " Address families by peer:\n "); | |
8960 | for (safi = SAFI_UNICAST; | |
8961 | safi < SAFI_MAX; safi++) | |
8962 | if (CHECK_FLAG( | |
8963 | p->af_cap | |
8964 | [AFI_IP] | |
8965 | [safi], | |
8966 | PEER_CAP_ENHE_AF_RCV)) | |
8967 | vty_out(vty, | |
8968 | " %s\n", | |
8969 | afi_safi_print( | |
8970 | AFI_IP, | |
8971 | safi)); | |
8972 | } | |
8973 | } | |
8974 | ||
8975 | /* Route Refresh */ | |
8976 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
8977 | || CHECK_FLAG(p->cap, | |
8978 | PEER_CAP_REFRESH_NEW_RCV) | |
8979 | || CHECK_FLAG(p->cap, | |
8980 | PEER_CAP_REFRESH_OLD_RCV)) { | |
8981 | vty_out(vty, " Route refresh:"); | |
8982 | if (CHECK_FLAG(p->cap, | |
8983 | PEER_CAP_REFRESH_ADV)) | |
8984 | vty_out(vty, " advertised"); | |
8985 | if (CHECK_FLAG(p->cap, | |
8986 | PEER_CAP_REFRESH_NEW_RCV) | |
8987 | || CHECK_FLAG( | |
8988 | p->cap, | |
8989 | PEER_CAP_REFRESH_OLD_RCV)) | |
8990 | vty_out(vty, " %sreceived(%s)", | |
8991 | CHECK_FLAG( | |
8992 | p->cap, | |
8993 | PEER_CAP_REFRESH_ADV) | |
8994 | ? "and " | |
8995 | : "", | |
8996 | (CHECK_FLAG( | |
8997 | p->cap, | |
8998 | PEER_CAP_REFRESH_OLD_RCV) | |
8999 | && CHECK_FLAG( | |
9000 | p->cap, | |
9001 | PEER_CAP_REFRESH_NEW_RCV)) | |
9002 | ? "old & new" | |
9003 | : CHECK_FLAG( | |
9004 | p->cap, | |
9005 | PEER_CAP_REFRESH_OLD_RCV) | |
9006 | ? "old" | |
9007 | : "new"); | |
9008 | ||
9009 | vty_out(vty, "\n"); | |
9010 | } | |
9011 | ||
9012 | /* Multiprotocol Extensions */ | |
9013 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9014 | for (safi = SAFI_UNICAST; | |
9015 | safi < SAFI_MAX; safi++) | |
9016 | if (p->afc_adv[afi][safi] | |
9017 | || p->afc_recv[afi][safi]) { | |
9018 | vty_out(vty, | |
9019 | " Address Family %s:", | |
9020 | afi_safi_print( | |
9021 | afi, | |
9022 | safi)); | |
9023 | if (p->afc_adv[afi] | |
9024 | [safi]) | |
9025 | vty_out(vty, | |
9026 | " advertised"); | |
9027 | if (p->afc_recv[afi] | |
9028 | [safi]) | |
9029 | vty_out(vty, | |
9030 | " %sreceived", | |
9031 | p->afc_adv[afi] | |
9032 | [safi] | |
9033 | ? "and " | |
9034 | : ""); | |
9035 | vty_out(vty, "\n"); | |
9036 | } | |
9037 | ||
9038 | /* Hostname capability */ | |
d77114b7 MK |
9039 | vty_out(vty, |
9040 | " Hostname Capability:"); | |
9041 | ||
9042 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
9043 | vty_out(vty, |
9044 | " advertised (name: %s,domain name: %s)", | |
d77114b7 MK |
9045 | bgp->peer_self->hostname ? |
9046 | bgp->peer_self->hostname | |
9047 | : "n/a", | |
9048 | bgp->peer_self->domainname ? | |
9049 | bgp->peer_self->domainname | |
9050 | : "n/a"); | |
9051 | } else { | |
9052 | vty_out(vty, " not advertised"); | |
d62a17ae | 9053 | } |
9054 | ||
d77114b7 | 9055 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
9056 | vty_out(vty, |
9057 | " received (name: %s,domain name: %s)", | |
d77114b7 MK |
9058 | p->hostname ? |
9059 | p->hostname : "n/a", | |
9060 | p->domainname ? | |
9061 | p->domainname : "n/a"); | |
9062 | } else { | |
9063 | vty_out(vty, " not received"); | |
9064 | } | |
9065 | ||
9066 | vty_out(vty, "\n"); | |
9067 | ||
d62a17ae | 9068 | /* Gracefull Restart */ |
9069 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
9070 | || CHECK_FLAG(p->cap, | |
9071 | PEER_CAP_RESTART_ADV)) { | |
9072 | vty_out(vty, | |
9073 | " Graceful Restart Capabilty:"); | |
9074 | if (CHECK_FLAG(p->cap, | |
9075 | PEER_CAP_RESTART_ADV)) | |
9076 | vty_out(vty, " advertised"); | |
9077 | if (CHECK_FLAG(p->cap, | |
9078 | PEER_CAP_RESTART_RCV)) | |
9079 | vty_out(vty, " %sreceived", | |
9080 | CHECK_FLAG( | |
9081 | p->cap, | |
9082 | PEER_CAP_RESTART_ADV) | |
9083 | ? "and " | |
9084 | : ""); | |
9085 | vty_out(vty, "\n"); | |
9086 | ||
9087 | if (CHECK_FLAG(p->cap, | |
9088 | PEER_CAP_RESTART_RCV)) { | |
9089 | int restart_af_count = 0; | |
9090 | ||
9091 | vty_out(vty, | |
9092 | " Remote Restart timer is %d seconds\n", | |
9093 | p->v_gr_restart); | |
9094 | vty_out(vty, | |
9095 | " Address families by peer:\n "); | |
9096 | ||
9097 | for (afi = AFI_IP; | |
9098 | afi < AFI_MAX; afi++) | |
9099 | for (safi = SAFI_UNICAST; | |
9100 | safi < SAFI_MAX; | |
9101 | safi++) | |
9102 | if (CHECK_FLAG( | |
9103 | p->af_cap | |
9104 | [afi] | |
9105 | [safi], | |
9106 | PEER_CAP_RESTART_AF_RCV)) { | |
9107 | vty_out(vty, | |
9108 | "%s%s(%s)", | |
9109 | restart_af_count | |
9110 | ? ", " | |
9111 | : "", | |
9112 | afi_safi_print( | |
9113 | afi, | |
9114 | safi), | |
9115 | CHECK_FLAG( | |
9116 | p->af_cap | |
9117 | [afi] | |
9118 | [safi], | |
9119 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
9120 | ? "preserved" | |
9121 | : "not preserved"); | |
9122 | restart_af_count++; | |
9123 | } | |
9124 | if (!restart_af_count) | |
9125 | vty_out(vty, "none"); | |
9126 | vty_out(vty, "\n"); | |
9127 | } | |
9128 | } | |
9129 | } | |
9130 | } | |
9131 | } | |
9132 | ||
9133 | /* graceful restart information */ | |
9134 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || p->t_gr_restart | |
9135 | || p->t_gr_stale) { | |
9136 | json_object *json_grace = NULL; | |
9137 | json_object *json_grace_send = NULL; | |
9138 | json_object *json_grace_recv = NULL; | |
9139 | int eor_send_af_count = 0; | |
9140 | int eor_receive_af_count = 0; | |
9141 | ||
9142 | if (use_json) { | |
9143 | json_grace = json_object_new_object(); | |
9144 | json_grace_send = json_object_new_object(); | |
9145 | json_grace_recv = json_object_new_object(); | |
9146 | ||
9147 | if (p->status == Established) { | |
9148 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9149 | for (safi = SAFI_UNICAST; | |
9150 | safi < SAFI_MAX; safi++) { | |
9151 | if (CHECK_FLAG( | |
9152 | p->af_sflags[afi] | |
9153 | [safi], | |
9154 | PEER_STATUS_EOR_SEND)) { | |
9155 | json_object_boolean_true_add( | |
9156 | json_grace_send, | |
9157 | afi_safi_print( | |
9158 | afi, | |
9159 | safi)); | |
9160 | eor_send_af_count++; | |
9161 | } | |
9162 | } | |
9163 | } | |
9164 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9165 | for (safi = SAFI_UNICAST; | |
9166 | safi < SAFI_MAX; safi++) { | |
9167 | if (CHECK_FLAG( | |
9168 | p->af_sflags[afi] | |
9169 | [safi], | |
9170 | PEER_STATUS_EOR_RECEIVED)) { | |
9171 | json_object_boolean_true_add( | |
9172 | json_grace_recv, | |
9173 | afi_safi_print( | |
9174 | afi, | |
9175 | safi)); | |
9176 | eor_receive_af_count++; | |
9177 | } | |
9178 | } | |
9179 | } | |
9180 | } | |
9181 | ||
9182 | json_object_object_add(json_grace, "endOfRibSend", | |
9183 | json_grace_send); | |
9184 | json_object_object_add(json_grace, "endOfRibRecv", | |
9185 | json_grace_recv); | |
9186 | ||
9187 | if (p->t_gr_restart) | |
9188 | json_object_int_add(json_grace, | |
9189 | "gracefulRestartTimerMsecs", | |
9190 | thread_timer_remain_second( | |
9191 | p->t_gr_restart) | |
9192 | * 1000); | |
9193 | ||
9194 | if (p->t_gr_stale) | |
9195 | json_object_int_add( | |
9196 | json_grace, | |
9197 | "gracefulStalepathTimerMsecs", | |
9198 | thread_timer_remain_second( | |
9199 | p->t_gr_stale) | |
9200 | * 1000); | |
9201 | ||
9202 | json_object_object_add( | |
9203 | json_neigh, "gracefulRestartInfo", json_grace); | |
9204 | } else { | |
9205 | vty_out(vty, " Graceful restart informations:\n"); | |
9206 | if (p->status == Established) { | |
9207 | vty_out(vty, " End-of-RIB send: "); | |
9208 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9209 | for (safi = SAFI_UNICAST; | |
9210 | safi < SAFI_MAX; safi++) { | |
9211 | if (CHECK_FLAG( | |
9212 | p->af_sflags[afi] | |
9213 | [safi], | |
9214 | PEER_STATUS_EOR_SEND)) { | |
9215 | vty_out(vty, "%s%s", | |
9216 | eor_send_af_count | |
9217 | ? ", " | |
9218 | : "", | |
9219 | afi_safi_print( | |
9220 | afi, | |
9221 | safi)); | |
9222 | eor_send_af_count++; | |
9223 | } | |
9224 | } | |
9225 | } | |
9226 | vty_out(vty, "\n"); | |
9227 | vty_out(vty, " End-of-RIB received: "); | |
9228 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
9229 | for (safi = SAFI_UNICAST; | |
9230 | safi < SAFI_MAX; safi++) { | |
9231 | if (CHECK_FLAG( | |
9232 | p->af_sflags[afi] | |
9233 | [safi], | |
9234 | PEER_STATUS_EOR_RECEIVED)) { | |
9235 | vty_out(vty, "%s%s", | |
9236 | eor_receive_af_count | |
9237 | ? ", " | |
9238 | : "", | |
9239 | afi_safi_print( | |
9240 | afi, | |
9241 | safi)); | |
9242 | eor_receive_af_count++; | |
9243 | } | |
9244 | } | |
9245 | } | |
9246 | vty_out(vty, "\n"); | |
9247 | } | |
9248 | ||
9249 | if (p->t_gr_restart) | |
9250 | vty_out(vty, | |
9251 | " The remaining time of restart timer is %ld\n", | |
9252 | thread_timer_remain_second( | |
9253 | p->t_gr_restart)); | |
9254 | ||
9255 | if (p->t_gr_stale) | |
9256 | vty_out(vty, | |
9257 | " The remaining time of stalepath timer is %ld\n", | |
9258 | thread_timer_remain_second( | |
9259 | p->t_gr_stale)); | |
9260 | } | |
9261 | } | |
9262 | if (use_json) { | |
9263 | json_object *json_stat = NULL; | |
9264 | json_stat = json_object_new_object(); | |
9265 | /* Packet counts. */ | |
9266 | json_object_int_add(json_stat, "depthInq", 0); | |
9267 | json_object_int_add(json_stat, "depthOutq", | |
9268 | (unsigned long)p->obuf->count); | |
9269 | json_object_int_add(json_stat, "opensSent", p->open_out); | |
9270 | json_object_int_add(json_stat, "opensRecv", p->open_in); | |
9271 | json_object_int_add(json_stat, "notificationsSent", | |
9272 | p->notify_out); | |
9273 | json_object_int_add(json_stat, "notificationsRecv", | |
9274 | p->notify_in); | |
9275 | json_object_int_add(json_stat, "updatesSent", p->update_out); | |
9276 | json_object_int_add(json_stat, "updatesRecv", p->update_in); | |
9277 | json_object_int_add(json_stat, "keepalivesSent", | |
9278 | p->keepalive_out); | |
9279 | json_object_int_add(json_stat, "keepalivesRecv", | |
9280 | p->keepalive_in); | |
9281 | json_object_int_add(json_stat, "routeRefreshSent", | |
9282 | p->refresh_out); | |
9283 | json_object_int_add(json_stat, "routeRefreshRecv", | |
9284 | p->refresh_in); | |
9285 | json_object_int_add(json_stat, "capabilitySent", | |
9286 | p->dynamic_cap_out); | |
9287 | json_object_int_add(json_stat, "capabilityRecv", | |
9288 | p->dynamic_cap_in); | |
9289 | json_object_int_add(json_stat, "totalSent", | |
9290 | p->open_out + p->notify_out + p->update_out | |
9291 | + p->keepalive_out + p->refresh_out | |
9292 | + p->dynamic_cap_out); | |
9293 | json_object_int_add(json_stat, "totalRecv", | |
9294 | p->open_in + p->notify_in + p->update_in | |
9295 | + p->keepalive_in + p->refresh_in | |
9296 | + p->dynamic_cap_in); | |
9297 | json_object_object_add(json_neigh, "messageStats", json_stat); | |
9298 | } else { | |
9299 | /* Packet counts. */ | |
9300 | vty_out(vty, " Message statistics:\n"); | |
9301 | vty_out(vty, " Inq depth is 0\n"); | |
9302 | vty_out(vty, " Outq depth is %lu\n", | |
9303 | (unsigned long)p->obuf->count); | |
9304 | vty_out(vty, " Sent Rcvd\n"); | |
9305 | vty_out(vty, " Opens: %10d %10d\n", p->open_out, | |
9306 | p->open_in); | |
9307 | vty_out(vty, " Notifications: %10d %10d\n", p->notify_out, | |
9308 | p->notify_in); | |
9309 | vty_out(vty, " Updates: %10d %10d\n", p->update_out, | |
9310 | p->update_in); | |
9311 | vty_out(vty, " Keepalives: %10d %10d\n", p->keepalive_out, | |
9312 | p->keepalive_in); | |
9313 | vty_out(vty, " Route Refresh: %10d %10d\n", p->refresh_out, | |
9314 | p->refresh_in); | |
9315 | vty_out(vty, " Capability: %10d %10d\n", | |
9316 | p->dynamic_cap_out, p->dynamic_cap_in); | |
9317 | vty_out(vty, " Total: %10d %10d\n", | |
9318 | p->open_out + p->notify_out + p->update_out | |
9319 | + p->keepalive_out + p->refresh_out | |
9320 | + p->dynamic_cap_out, | |
9321 | p->open_in + p->notify_in + p->update_in | |
9322 | + p->keepalive_in + p->refresh_in | |
9323 | + p->dynamic_cap_in); | |
9324 | } | |
9325 | ||
9326 | if (use_json) { | |
9327 | /* advertisement-interval */ | |
9328 | json_object_int_add(json_neigh, | |
9329 | "minBtwnAdvertisementRunsTimerMsecs", | |
9330 | p->v_routeadv * 1000); | |
9331 | ||
9332 | /* Update-source. */ | |
9333 | if (p->update_if || p->update_source) { | |
9334 | if (p->update_if) | |
9335 | json_object_string_add(json_neigh, | |
9336 | "updateSource", | |
9337 | p->update_if); | |
9338 | else if (p->update_source) | |
9339 | json_object_string_add( | |
9340 | json_neigh, "updateSource", | |
9341 | sockunion2str(p->update_source, buf1, | |
9342 | SU_ADDRSTRLEN)); | |
9343 | } | |
9344 | } else { | |
9345 | /* advertisement-interval */ | |
9346 | vty_out(vty, | |
9347 | " Minimum time between advertisement runs is %d seconds\n", | |
9348 | p->v_routeadv); | |
9349 | ||
9350 | /* Update-source. */ | |
9351 | if (p->update_if || p->update_source) { | |
9352 | vty_out(vty, " Update source is "); | |
9353 | if (p->update_if) | |
9354 | vty_out(vty, "%s", p->update_if); | |
9355 | else if (p->update_source) | |
9356 | vty_out(vty, "%s", | |
9357 | sockunion2str(p->update_source, buf1, | |
9358 | SU_ADDRSTRLEN)); | |
9359 | vty_out(vty, "\n"); | |
9360 | } | |
9361 | ||
9362 | vty_out(vty, "\n"); | |
9363 | } | |
9364 | ||
9365 | /* Address Family Information */ | |
9366 | json_object *json_hold = NULL; | |
9367 | ||
9368 | if (use_json) | |
9369 | json_hold = json_object_new_object(); | |
9370 | ||
9371 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
9372 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) | |
9373 | if (p->afc[afi][safi]) | |
9374 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
9375 | json_hold); | |
9376 | ||
9377 | if (use_json) { | |
9378 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
9379 | json_hold); | |
9380 | json_object_int_add(json_neigh, "connectionsEstablished", | |
9381 | p->established); | |
9382 | json_object_int_add(json_neigh, "connectionsDropped", | |
9383 | p->dropped); | |
9384 | } else | |
9385 | vty_out(vty, " Connections established %d; dropped %d\n", | |
9386 | p->established, p->dropped); | |
9387 | ||
9388 | if (!p->last_reset) { | |
9389 | if (use_json) | |
9390 | json_object_string_add(json_neigh, "lastReset", | |
9391 | "never"); | |
9392 | else | |
9393 | vty_out(vty, " Last reset never\n"); | |
9394 | } else { | |
9395 | if (use_json) { | |
9396 | time_t uptime; | |
9397 | struct tm *tm; | |
9398 | ||
9399 | uptime = bgp_clock(); | |
9400 | uptime -= p->resettime; | |
9401 | tm = gmtime(&uptime); | |
9402 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
9403 | (tm->tm_sec * 1000) | |
9404 | + (tm->tm_min * 60000) | |
9405 | + (tm->tm_hour * 3600000)); | |
9406 | json_object_string_add( | |
9407 | json_neigh, "lastResetDueTo", | |
9408 | peer_down_str[(int)p->last_reset]); | |
9409 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
9410 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
9411 | char errorcodesubcode_hexstr[5]; | |
9412 | char errorcodesubcode_str[256]; | |
9413 | ||
9414 | code_str = bgp_notify_code_str(p->notify.code); | |
9415 | subcode_str = bgp_notify_subcode_str( | |
9416 | p->notify.code, p->notify.subcode); | |
9417 | ||
9418 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
9419 | p->notify.code, p->notify.subcode); | |
9420 | json_object_string_add(json_neigh, | |
9421 | "lastErrorCodeSubcode", | |
9422 | errorcodesubcode_hexstr); | |
9423 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
9424 | code_str, subcode_str); | |
9425 | json_object_string_add(json_neigh, | |
9426 | "lastNotificationReason", | |
9427 | errorcodesubcode_str); | |
9428 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
9429 | && p->notify.code == BGP_NOTIFY_CEASE | |
9430 | && (p->notify.subcode | |
9431 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
9432 | || p->notify.subcode | |
9433 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
9434 | && p->notify.length) { | |
9435 | char msgbuf[1024]; | |
9436 | const char *msg_str; | |
9437 | ||
9438 | msg_str = bgp_notify_admin_message( | |
9439 | msgbuf, sizeof(msgbuf), | |
9440 | (u_char *)p->notify.data, | |
9441 | p->notify.length); | |
9442 | if (msg_str) | |
9443 | json_object_string_add( | |
9444 | json_neigh, | |
9445 | "lastShutdownDescription", | |
9446 | msg_str); | |
9447 | } | |
9448 | } | |
9449 | } else { | |
9450 | vty_out(vty, " Last reset %s, ", | |
9451 | peer_uptime(p->resettime, timebuf, | |
9452 | BGP_UPTIME_LEN, 0, NULL)); | |
9453 | ||
9454 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
9455 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
9456 | code_str = bgp_notify_code_str(p->notify.code); | |
9457 | subcode_str = bgp_notify_subcode_str( | |
9458 | p->notify.code, p->notify.subcode); | |
9459 | vty_out(vty, "due to NOTIFICATION %s (%s%s)\n", | |
9460 | p->last_reset == PEER_DOWN_NOTIFY_SEND | |
9461 | ? "sent" | |
9462 | : "received", | |
9463 | code_str, subcode_str); | |
9464 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
9465 | && p->notify.code == BGP_NOTIFY_CEASE | |
9466 | && (p->notify.subcode | |
9467 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
9468 | || p->notify.subcode | |
9469 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
9470 | && p->notify.length) { | |
9471 | char msgbuf[1024]; | |
9472 | const char *msg_str; | |
9473 | ||
9474 | msg_str = bgp_notify_admin_message( | |
9475 | msgbuf, sizeof(msgbuf), | |
9476 | (u_char *)p->notify.data, | |
9477 | p->notify.length); | |
9478 | if (msg_str) | |
9479 | vty_out(vty, | |
9480 | " Message: \"%s\"\n", | |
9481 | msg_str); | |
9482 | } | |
9483 | } else { | |
9484 | vty_out(vty, "due to %s\n", | |
9485 | peer_down_str[(int)p->last_reset]); | |
9486 | } | |
9487 | ||
9488 | if (p->last_reset_cause_size) { | |
9489 | msg = p->last_reset_cause; | |
9490 | vty_out(vty, | |
9491 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
9492 | for (i = 1; i <= p->last_reset_cause_size; | |
9493 | i++) { | |
9494 | vty_out(vty, "%02X", *msg++); | |
9495 | ||
9496 | if (i != p->last_reset_cause_size) { | |
9497 | if (i % 16 == 0) { | |
9498 | vty_out(vty, "\n "); | |
9499 | } else if (i % 4 == 0) { | |
9500 | vty_out(vty, " "); | |
9501 | } | |
9502 | } | |
9503 | } | |
9504 | vty_out(vty, "\n"); | |
9505 | } | |
9506 | } | |
9507 | } | |
9508 | ||
9509 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
9510 | if (use_json) | |
9511 | json_object_boolean_true_add(json_neigh, | |
9512 | "prefixesConfigExceedMax"); | |
9513 | else | |
9514 | vty_out(vty, | |
9515 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
9516 | ||
9517 | if (p->t_pmax_restart) { | |
9518 | if (use_json) { | |
9519 | json_object_boolean_true_add( | |
9520 | json_neigh, "reducePrefixNumFrom"); | |
9521 | json_object_int_add(json_neigh, | |
9522 | "restartInTimerMsec", | |
9523 | thread_timer_remain_second( | |
9524 | p->t_pmax_restart) | |
9525 | * 1000); | |
9526 | } else | |
9527 | vty_out(vty, | |
9528 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
9d303b37 DL |
9529 | p->host, thread_timer_remain_second( |
9530 | p->t_pmax_restart)); | |
d62a17ae | 9531 | } else { |
9532 | if (use_json) | |
9533 | json_object_boolean_true_add( | |
9534 | json_neigh, | |
9535 | "reducePrefixNumAndClearIpBgp"); | |
9536 | else | |
9537 | vty_out(vty, | |
9538 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
9539 | p->host); | |
9540 | } | |
9541 | } | |
9542 | ||
9543 | /* EBGP Multihop and GTSM */ | |
9544 | if (p->sort != BGP_PEER_IBGP) { | |
9545 | if (use_json) { | |
9546 | if (p->gtsm_hops > 0) | |
9547 | json_object_int_add(json_neigh, | |
9548 | "externalBgpNbrMaxHopsAway", | |
9549 | p->gtsm_hops); | |
9550 | else if (p->ttl > 1) | |
9551 | json_object_int_add(json_neigh, | |
9552 | "externalBgpNbrMaxHopsAway", | |
9553 | p->ttl); | |
9554 | } else { | |
9555 | if (p->gtsm_hops > 0) | |
9556 | vty_out(vty, | |
9557 | " External BGP neighbor may be up to %d hops away.\n", | |
9558 | p->gtsm_hops); | |
9559 | else if (p->ttl > 1) | |
9560 | vty_out(vty, | |
9561 | " External BGP neighbor may be up to %d hops away.\n", | |
9562 | p->ttl); | |
9563 | } | |
9564 | } else { | |
9565 | if (p->gtsm_hops > 0) { | |
9566 | if (use_json) | |
9567 | json_object_int_add(json_neigh, | |
9568 | "internalBgpNbrMaxHopsAway", | |
9569 | p->gtsm_hops); | |
9570 | else | |
9571 | vty_out(vty, | |
9572 | " Internal BGP neighbor may be up to %d hops away.\n", | |
9573 | p->gtsm_hops); | |
9574 | } | |
9575 | } | |
9576 | ||
9577 | /* Local address. */ | |
9578 | if (p->su_local) { | |
9579 | if (use_json) { | |
9580 | json_object_string_add(json_neigh, "hostLocal", | |
9581 | sockunion2str(p->su_local, buf1, | |
9582 | SU_ADDRSTRLEN)); | |
9583 | json_object_int_add(json_neigh, "portLocal", | |
9584 | ntohs(p->su_local->sin.sin_port)); | |
9585 | } else | |
9586 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
9587 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
9588 | ntohs(p->su_local->sin.sin_port)); | |
9589 | } | |
9590 | ||
9591 | /* Remote address. */ | |
9592 | if (p->su_remote) { | |
9593 | if (use_json) { | |
9594 | json_object_string_add(json_neigh, "hostForeign", | |
9595 | sockunion2str(p->su_remote, buf1, | |
9596 | SU_ADDRSTRLEN)); | |
9597 | json_object_int_add(json_neigh, "portForeign", | |
9598 | ntohs(p->su_remote->sin.sin_port)); | |
9599 | } else | |
9600 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
9601 | sockunion2str(p->su_remote, buf1, | |
9602 | SU_ADDRSTRLEN), | |
9603 | ntohs(p->su_remote->sin.sin_port)); | |
9604 | } | |
9605 | ||
9606 | /* Nexthop display. */ | |
9607 | if (p->su_local) { | |
9608 | if (use_json) { | |
9609 | json_object_string_add(json_neigh, "nexthop", | |
9610 | inet_ntop(AF_INET, | |
9611 | &p->nexthop.v4, buf1, | |
9612 | sizeof(buf1))); | |
9613 | json_object_string_add(json_neigh, "nexthopGlobal", | |
9614 | inet_ntop(AF_INET6, | |
9615 | &p->nexthop.v6_global, | |
9616 | buf1, sizeof(buf1))); | |
9617 | json_object_string_add(json_neigh, "nexthopLocal", | |
9618 | inet_ntop(AF_INET6, | |
9619 | &p->nexthop.v6_local, | |
9620 | buf1, sizeof(buf1))); | |
9621 | if (p->shared_network) | |
9622 | json_object_string_add(json_neigh, | |
9623 | "bgpConnection", | |
9624 | "sharedNetwork"); | |
9625 | else | |
9626 | json_object_string_add(json_neigh, | |
9627 | "bgpConnection", | |
9628 | "nonSharedNetwork"); | |
9629 | } else { | |
9630 | vty_out(vty, "Nexthop: %s\n", | |
9631 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
9632 | sizeof(buf1))); | |
9633 | vty_out(vty, "Nexthop global: %s\n", | |
9634 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
9635 | sizeof(buf1))); | |
9636 | vty_out(vty, "Nexthop local: %s\n", | |
9637 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
9638 | sizeof(buf1))); | |
9639 | vty_out(vty, "BGP connection: %s\n", | |
9640 | p->shared_network ? "shared network" | |
9641 | : "non shared network"); | |
9642 | } | |
9643 | } | |
9644 | ||
9645 | /* Timer information. */ | |
9646 | if (use_json) { | |
9647 | json_object_int_add(json_neigh, "connectRetryTimer", | |
9648 | p->v_connect); | |
9649 | if (p->status == Established && p->rtt) | |
9650 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
9651 | p->rtt); | |
9652 | if (p->t_start) | |
9653 | json_object_int_add( | |
9654 | json_neigh, "nextStartTimerDueInMsecs", | |
9655 | thread_timer_remain_second(p->t_start) * 1000); | |
9656 | if (p->t_connect) | |
9657 | json_object_int_add( | |
9658 | json_neigh, "nextConnectTimerDueInMsecs", | |
9659 | thread_timer_remain_second(p->t_connect) | |
9660 | * 1000); | |
9661 | if (p->t_routeadv) { | |
9662 | json_object_int_add(json_neigh, "mraiInterval", | |
9663 | p->v_routeadv); | |
9664 | json_object_int_add( | |
9665 | json_neigh, "mraiTimerExpireInMsecs", | |
9666 | thread_timer_remain_second(p->t_routeadv) | |
9667 | * 1000); | |
9668 | } | |
9669 | if (p->password) | |
9670 | json_object_int_add(json_neigh, "authenticationEnabled", | |
9671 | 1); | |
9672 | ||
9673 | if (p->t_read) | |
9674 | json_object_string_add(json_neigh, "readThread", "on"); | |
9675 | else | |
9676 | json_object_string_add(json_neigh, "readThread", "off"); | |
9677 | if (p->t_write) | |
9678 | json_object_string_add(json_neigh, "writeThread", "on"); | |
9679 | else | |
9680 | json_object_string_add(json_neigh, "writeThread", | |
9681 | "off"); | |
9682 | } else { | |
9683 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
9684 | p->v_connect); | |
9685 | if (p->status == Established && p->rtt) | |
9686 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
9687 | p->rtt); | |
9688 | if (p->t_start) | |
9689 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
9690 | thread_timer_remain_second(p->t_start)); | |
9691 | if (p->t_connect) | |
9692 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
9693 | thread_timer_remain_second(p->t_connect)); | |
9694 | if (p->t_routeadv) | |
9695 | vty_out(vty, | |
9696 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
9697 | p->v_routeadv, | |
9698 | thread_timer_remain_second(p->t_routeadv)); | |
9699 | if (p->password) | |
9700 | vty_out(vty, "Peer Authentication Enabled\n"); | |
9701 | ||
9702 | vty_out(vty, "Read thread: %s Write thread: %s\n", | |
9703 | p->t_read ? "on" : "off", p->t_write ? "on" : "off"); | |
9704 | } | |
9705 | ||
9706 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
9707 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
9708 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
9709 | ||
9710 | if (!use_json) | |
9711 | vty_out(vty, "\n"); | |
9712 | ||
9713 | /* BFD information. */ | |
9714 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
9715 | ||
9716 | if (use_json) { | |
9717 | if (p->conf_if) /* Configured interface name. */ | |
9718 | json_object_object_add(json, p->conf_if, json_neigh); | |
9719 | else /* Configured IP address. */ | |
9720 | json_object_object_add(json, p->host, json_neigh); | |
9721 | } | |
9722 | } | |
9723 | ||
9724 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, | |
9725 | enum show_type type, union sockunion *su, | |
9726 | const char *conf_if, u_char use_json, | |
9727 | json_object *json) | |
9728 | { | |
9729 | struct listnode *node, *nnode; | |
9730 | struct peer *peer; | |
9731 | int find = 0; | |
9732 | ||
9733 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
9734 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
9735 | continue; | |
9736 | ||
9737 | switch (type) { | |
9738 | case show_all: | |
9739 | bgp_show_peer(vty, peer, use_json, json); | |
9740 | break; | |
9741 | case show_peer: | |
9742 | if (conf_if) { | |
9743 | if ((peer->conf_if | |
9744 | && !strcmp(peer->conf_if, conf_if)) | |
9745 | || (peer->hostname | |
9746 | && !strcmp(peer->hostname, conf_if))) { | |
9747 | find = 1; | |
9748 | bgp_show_peer(vty, peer, use_json, | |
9749 | json); | |
9750 | } | |
9751 | } else { | |
9752 | if (sockunion_same(&peer->su, su)) { | |
9753 | find = 1; | |
9754 | bgp_show_peer(vty, peer, use_json, | |
9755 | json); | |
9756 | } | |
9757 | } | |
9758 | break; | |
9759 | } | |
9760 | } | |
9761 | ||
9762 | if (type == show_peer && !find) { | |
9763 | if (use_json) | |
9764 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
9765 | else | |
9766 | vty_out(vty, "%% No such neighbor\n"); | |
9767 | } | |
9768 | ||
9769 | if (use_json) { | |
9d303b37 DL |
9770 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
9771 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 9772 | json_object_free(json); |
9773 | } else { | |
9774 | vty_out(vty, "\n"); | |
9775 | } | |
9776 | ||
9777 | return CMD_SUCCESS; | |
9778 | } | |
9779 | ||
9780 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, | |
9781 | u_char use_json) | |
9782 | { | |
0291c246 MK |
9783 | struct listnode *node, *nnode; |
9784 | struct bgp *bgp; | |
9785 | json_object *json = NULL; | |
9786 | int is_first = 1; | |
d62a17ae | 9787 | |
9788 | if (use_json) | |
9789 | vty_out(vty, "{\n"); | |
9790 | ||
9791 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9792 | if (use_json) { | |
9793 | if (!(json = json_object_new_object())) { | |
9794 | zlog_err( | |
9795 | "Unable to allocate memory for JSON object"); | |
9796 | vty_out(vty, | |
9797 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
9798 | return; | |
9799 | } | |
9800 | ||
9801 | json_object_int_add(json, "vrfId", | |
9802 | (bgp->vrf_id == VRF_UNKNOWN) | |
9803 | ? -1 | |
9804 | : bgp->vrf_id); | |
9805 | json_object_string_add( | |
9806 | json, "vrfName", | |
9807 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9808 | ? "Default" | |
9809 | : bgp->name); | |
9810 | ||
9811 | if (!is_first) | |
9812 | vty_out(vty, ",\n"); | |
9813 | else | |
9814 | is_first = 0; | |
9815 | ||
9816 | vty_out(vty, "\"%s\":", | |
9817 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9818 | ? "Default" | |
9819 | : bgp->name); | |
9820 | } else { | |
9821 | vty_out(vty, "\nInstance %s:\n", | |
9822 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
9823 | ? "Default" | |
9824 | : bgp->name); | |
9825 | } | |
9826 | bgp_show_neighbor(vty, bgp, show_all, NULL, NULL, use_json, | |
9827 | json); | |
9828 | } | |
9829 | ||
9830 | if (use_json) | |
9831 | vty_out(vty, "}\n"); | |
9832 | } | |
9833 | ||
9834 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
9835 | enum show_type type, const char *ip_str, | |
9836 | u_char use_json) | |
9837 | { | |
9838 | int ret; | |
9839 | struct bgp *bgp; | |
9840 | union sockunion su; | |
9841 | json_object *json = NULL; | |
9842 | ||
9843 | if (name) { | |
9844 | if (strmatch(name, "all")) { | |
9845 | bgp_show_all_instances_neighbors_vty(vty, use_json); | |
9846 | return CMD_SUCCESS; | |
9847 | } else { | |
9848 | bgp = bgp_lookup_by_name(name); | |
9849 | if (!bgp) { | |
9850 | if (use_json) { | |
9851 | json = json_object_new_object(); | |
9852 | json_object_boolean_true_add( | |
9853 | json, "bgpNoSuchInstance"); | |
9854 | vty_out(vty, "%s\n", | |
9855 | json_object_to_json_string_ext( | |
9856 | json, | |
9857 | JSON_C_TO_STRING_PRETTY)); | |
9858 | json_object_free(json); | |
9859 | } else | |
9860 | vty_out(vty, | |
9861 | "%% No such BGP instance exist\n"); | |
9862 | ||
9863 | return CMD_WARNING; | |
9864 | } | |
9865 | } | |
9866 | } else { | |
9867 | bgp = bgp_get_default(); | |
9868 | } | |
9869 | ||
9870 | if (bgp) { | |
9871 | json = json_object_new_object(); | |
9872 | if (ip_str) { | |
9873 | ret = str2sockunion(ip_str, &su); | |
9874 | if (ret < 0) | |
9875 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
9876 | use_json, json); | |
9877 | else | |
9878 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
9879 | use_json, json); | |
9880 | } else { | |
9881 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
9882 | json); | |
9883 | } | |
9884 | json_object_free(json); | |
9885 | } | |
9886 | ||
9887 | return CMD_SUCCESS; | |
4fb25c53 DW |
9888 | } |
9889 | ||
716b2d8a | 9890 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 9891 | DEFUN (show_ip_bgp_neighbors, |
9892 | show_ip_bgp_neighbors_cmd, | |
18c57037 | 9893 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|vpnv4 <all|rd ASN:nn_or_IP-address:nn>>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 9894 | SHOW_STR |
9895 | IP_STR | |
9896 | BGP_STR | |
f2a8972b | 9897 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
9898 | "Address Family\n" |
9899 | "Address Family\n" | |
91d37724 QY |
9900 | "Address Family\n" |
9901 | "Display information about all VPNv4 NLRIs\n" | |
9902 | "Display information for a route distinguisher\n" | |
9903 | "VPN Route Distinguisher\n" | |
718e3744 | 9904 | "Detailed information on TCP and BGP neighbor connections\n" |
9905 | "Neighbor to display information about\n" | |
a80beece | 9906 | "Neighbor to display information about\n" |
91d37724 | 9907 | "Neighbor on BGP configured interface\n" |
9973d184 | 9908 | JSON_STR) |
718e3744 | 9909 | { |
d62a17ae | 9910 | char *vrf = NULL; |
9911 | char *sh_arg = NULL; | |
9912 | enum show_type sh_type; | |
718e3744 | 9913 | |
d62a17ae | 9914 | u_char uj = use_json(argc, argv); |
718e3744 | 9915 | |
d62a17ae | 9916 | int idx = 0; |
718e3744 | 9917 | |
d62a17ae | 9918 | if (argv_find(argv, argc, "view", &idx) |
9919 | || argv_find(argv, argc, "vrf", &idx)) | |
9920 | vrf = argv[idx + 1]->arg; | |
718e3744 | 9921 | |
d62a17ae | 9922 | idx++; |
9923 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
9924 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
9925 | || argv_find(argv, argc, "WORD", &idx)) { | |
9926 | sh_type = show_peer; | |
9927 | sh_arg = argv[idx]->arg; | |
9928 | } else | |
9929 | sh_type = show_all; | |
856ca177 | 9930 | |
d62a17ae | 9931 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 9932 | } |
9933 | ||
716b2d8a | 9934 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 9935 | paths' and `show ip mbgp paths'. Those functions results are the |
9936 | same.*/ | |
f412b39a | 9937 | DEFUN (show_ip_bgp_paths, |
718e3744 | 9938 | show_ip_bgp_paths_cmd, |
46f296b4 | 9939 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 9940 | SHOW_STR |
9941 | IP_STR | |
9942 | BGP_STR | |
46f296b4 | 9943 | BGP_SAFI_HELP_STR |
718e3744 | 9944 | "Path information\n") |
9945 | { | |
d62a17ae | 9946 | vty_out(vty, "Address Refcnt Path\n"); |
9947 | aspath_print_all_vty(vty); | |
9948 | return CMD_SUCCESS; | |
718e3744 | 9949 | } |
9950 | ||
718e3744 | 9951 | #include "hash.h" |
9952 | ||
d62a17ae | 9953 | static void community_show_all_iterator(struct hash_backet *backet, |
9954 | struct vty *vty) | |
718e3744 | 9955 | { |
d62a17ae | 9956 | struct community *com; |
718e3744 | 9957 | |
d62a17ae | 9958 | com = (struct community *)backet->data; |
9959 | vty_out(vty, "[%p] (%ld) %s\n", (void *)backet, com->refcnt, | |
9960 | community_str(com)); | |
718e3744 | 9961 | } |
9962 | ||
9963 | /* Show BGP's community internal data. */ | |
f412b39a | 9964 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 9965 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 9966 | "show [ip] bgp community-info", |
718e3744 | 9967 | SHOW_STR |
9968 | IP_STR | |
9969 | BGP_STR | |
9970 | "List all bgp community information\n") | |
9971 | { | |
d62a17ae | 9972 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 9973 | |
d62a17ae | 9974 | hash_iterate(community_hash(), |
9975 | (void (*)(struct hash_backet *, | |
9976 | void *))community_show_all_iterator, | |
9977 | vty); | |
718e3744 | 9978 | |
d62a17ae | 9979 | return CMD_SUCCESS; |
718e3744 | 9980 | } |
9981 | ||
d62a17ae | 9982 | static void lcommunity_show_all_iterator(struct hash_backet *backet, |
9983 | struct vty *vty) | |
57d187bc | 9984 | { |
d62a17ae | 9985 | struct lcommunity *lcom; |
57d187bc | 9986 | |
d62a17ae | 9987 | lcom = (struct lcommunity *)backet->data; |
9988 | vty_out(vty, "[%p] (%ld) %s\n", (void *)backet, lcom->refcnt, | |
9989 | lcommunity_str(lcom)); | |
57d187bc JS |
9990 | } |
9991 | ||
9992 | /* Show BGP's community internal data. */ | |
9993 | DEFUN (show_ip_bgp_lcommunity_info, | |
9994 | show_ip_bgp_lcommunity_info_cmd, | |
9995 | "show ip bgp large-community-info", | |
9996 | SHOW_STR | |
9997 | IP_STR | |
9998 | BGP_STR | |
9999 | "List all bgp large-community information\n") | |
10000 | { | |
d62a17ae | 10001 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 10002 | |
d62a17ae | 10003 | hash_iterate(lcommunity_hash(), |
10004 | (void (*)(struct hash_backet *, | |
10005 | void *))lcommunity_show_all_iterator, | |
10006 | vty); | |
57d187bc | 10007 | |
d62a17ae | 10008 | return CMD_SUCCESS; |
57d187bc JS |
10009 | } |
10010 | ||
10011 | ||
f412b39a | 10012 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 10013 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 10014 | "show [ip] bgp attribute-info", |
718e3744 | 10015 | SHOW_STR |
10016 | IP_STR | |
10017 | BGP_STR | |
10018 | "List all bgp attribute information\n") | |
10019 | { | |
d62a17ae | 10020 | attr_show_all(vty); |
10021 | return CMD_SUCCESS; | |
718e3744 | 10022 | } |
6b0655a2 | 10023 | |
d62a17ae | 10024 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
10025 | safi_t safi) | |
f186de26 | 10026 | { |
d62a17ae | 10027 | struct listnode *node, *nnode; |
10028 | struct bgp *bgp; | |
f186de26 | 10029 | |
d62a17ae | 10030 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
10031 | vty_out(vty, "\nInstance %s:\n", | |
10032 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
10033 | ? "Default" | |
10034 | : bgp->name); | |
10035 | update_group_show(bgp, afi, safi, vty, 0); | |
10036 | } | |
f186de26 | 10037 | } |
10038 | ||
d62a17ae | 10039 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
10040 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 10041 | { |
d62a17ae | 10042 | struct bgp *bgp; |
4fb25c53 | 10043 | |
d62a17ae | 10044 | if (name) { |
10045 | if (strmatch(name, "all")) { | |
10046 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
10047 | return CMD_SUCCESS; | |
10048 | } else { | |
10049 | bgp = bgp_lookup_by_name(name); | |
10050 | } | |
10051 | } else { | |
10052 | bgp = bgp_get_default(); | |
10053 | } | |
4fb25c53 | 10054 | |
d62a17ae | 10055 | if (bgp) |
10056 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
10057 | return CMD_SUCCESS; | |
4fb25c53 DW |
10058 | } |
10059 | ||
8fe8a7f6 DS |
10060 | DEFUN (show_ip_bgp_updgrps, |
10061 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 10062 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 10063 | SHOW_STR |
10064 | IP_STR | |
10065 | BGP_STR | |
10066 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 10067 | BGP_AFI_HELP_STR |
9bedbb1e | 10068 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
10069 | "Detailed info about dynamic update groups\n" |
10070 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 10071 | { |
d62a17ae | 10072 | char *vrf = NULL; |
10073 | afi_t afi = AFI_IP6; | |
10074 | safi_t safi = SAFI_UNICAST; | |
10075 | uint64_t subgrp_id = 0; | |
10076 | ||
10077 | int idx = 0; | |
10078 | ||
10079 | /* show [ip] bgp */ | |
10080 | if (argv_find(argv, argc, "ip", &idx)) | |
10081 | afi = AFI_IP; | |
10082 | /* [<view|vrf> VIEWVRFNAME] */ | |
10083 | if (argv_find(argv, argc, "view", &idx) | |
10084 | || argv_find(argv, argc, "vrf", &idx)) | |
10085 | vrf = argv[++idx]->arg; | |
10086 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
10087 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
10088 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
10089 | } | |
5bf15956 | 10090 | |
d62a17ae | 10091 | /* get subgroup id, if provided */ |
10092 | idx = argc - 1; | |
10093 | if (argv[idx]->type == VARIABLE_TKN) | |
10094 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 10095 | |
d62a17ae | 10096 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
10097 | } |
10098 | ||
f186de26 | 10099 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
10100 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 10101 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 10102 | SHOW_STR |
716b2d8a | 10103 | IP_STR |
f186de26 | 10104 | BGP_STR |
10105 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 10106 | "Detailed info about dynamic update groups\n") |
f186de26 | 10107 | { |
d62a17ae | 10108 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
10109 | return CMD_SUCCESS; | |
f186de26 | 10110 | } |
10111 | ||
5bf15956 DW |
10112 | DEFUN (show_bgp_updgrps_stats, |
10113 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 10114 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 10115 | SHOW_STR |
716b2d8a | 10116 | IP_STR |
3f9c7369 | 10117 | BGP_STR |
0c7b1b01 | 10118 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
10119 | "Statistics\n") |
10120 | { | |
d62a17ae | 10121 | struct bgp *bgp; |
3f9c7369 | 10122 | |
d62a17ae | 10123 | bgp = bgp_get_default(); |
10124 | if (bgp) | |
10125 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 10126 | |
d62a17ae | 10127 | return CMD_SUCCESS; |
3f9c7369 DS |
10128 | } |
10129 | ||
8386ac43 | 10130 | DEFUN (show_bgp_instance_updgrps_stats, |
10131 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 10132 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 10133 | SHOW_STR |
716b2d8a | 10134 | IP_STR |
8386ac43 | 10135 | BGP_STR |
10136 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10137 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10138 | "Statistics\n") |
10139 | { | |
d62a17ae | 10140 | int idx_word = 3; |
10141 | struct bgp *bgp; | |
8386ac43 | 10142 | |
d62a17ae | 10143 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
10144 | if (bgp) | |
10145 | update_group_show_stats(bgp, vty); | |
8386ac43 | 10146 | |
d62a17ae | 10147 | return CMD_SUCCESS; |
8386ac43 | 10148 | } |
10149 | ||
d62a17ae | 10150 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
10151 | afi_t afi, safi_t safi, | |
10152 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 10153 | { |
d62a17ae | 10154 | struct bgp *bgp; |
8386ac43 | 10155 | |
d62a17ae | 10156 | if (name) |
10157 | bgp = bgp_lookup_by_name(name); | |
10158 | else | |
10159 | bgp = bgp_get_default(); | |
8386ac43 | 10160 | |
d62a17ae | 10161 | if (bgp) { |
10162 | if (!strcmp(what, "advertise-queue")) | |
10163 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
10164 | subgrp_id); | |
10165 | else if (!strcmp(what, "advertised-routes")) | |
10166 | update_group_show_advertised(bgp, afi, safi, vty, | |
10167 | subgrp_id); | |
10168 | else if (!strcmp(what, "packet-queue")) | |
10169 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
10170 | subgrp_id); | |
10171 | } | |
3f9c7369 DS |
10172 | } |
10173 | ||
10174 | DEFUN (show_ip_bgp_updgrps_adj, | |
10175 | show_ip_bgp_updgrps_adj_cmd, | |
716b2d8a | 10176 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
10177 | SHOW_STR |
10178 | IP_STR | |
10179 | BGP_STR | |
0c7b1b01 | 10180 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
10181 | "Advertisement queue\n" |
10182 | "Announced routes\n" | |
10183 | "Packet queue\n") | |
10184 | { | |
d62a17ae | 10185 | int idx_type = 4; |
10186 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, | |
10187 | argv[idx_type]->arg, 0); | |
10188 | return CMD_SUCCESS; | |
8386ac43 | 10189 | } |
10190 | ||
10191 | DEFUN (show_ip_bgp_instance_updgrps_adj, | |
10192 | show_ip_bgp_instance_updgrps_adj_cmd, | |
18c57037 | 10193 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10194 | SHOW_STR |
10195 | IP_STR | |
10196 | BGP_STR | |
10197 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10198 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10199 | "Advertisement queue\n" |
10200 | "Announced routes\n" | |
10201 | "Packet queue\n") | |
8386ac43 | 10202 | { |
d62a17ae | 10203 | int idx_word = 4; |
10204 | int idx_type = 6; | |
10205 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP, | |
10206 | SAFI_UNICAST, argv[idx_type]->arg, 0); | |
10207 | return CMD_SUCCESS; | |
3f9c7369 DS |
10208 | } |
10209 | ||
10210 | DEFUN (show_bgp_updgrps_afi_adj, | |
10211 | show_bgp_updgrps_afi_adj_cmd, | |
46f296b4 | 10212 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 10213 | SHOW_STR |
716b2d8a | 10214 | IP_STR |
3f9c7369 | 10215 | BGP_STR |
46f296b4 | 10216 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 10217 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
10218 | "Advertisement queue\n" |
10219 | "Announced routes\n" | |
7111c1a0 | 10220 | "Packet queue\n") |
3f9c7369 | 10221 | { |
d62a17ae | 10222 | int idx_afi = 2; |
10223 | int idx_safi = 3; | |
10224 | int idx_type = 5; | |
10225 | show_bgp_updgrps_adj_info_aux( | |
10226 | vty, NULL, bgp_vty_afi_from_str(argv[idx_afi]->text), | |
10227 | bgp_vty_safi_from_str(argv[idx_safi]->text), | |
10228 | argv[idx_type]->arg, 0); | |
10229 | return CMD_SUCCESS; | |
3f9c7369 DS |
10230 | } |
10231 | ||
10232 | DEFUN (show_bgp_updgrps_adj, | |
10233 | show_bgp_updgrps_adj_cmd, | |
716b2d8a | 10234 | "show [ip] bgp update-groups <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 10235 | SHOW_STR |
716b2d8a | 10236 | IP_STR |
3f9c7369 | 10237 | BGP_STR |
0c7b1b01 | 10238 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
10239 | "Advertisement queue\n" |
10240 | "Announced routes\n" | |
10241 | "Packet queue\n") | |
10242 | { | |
d62a17ae | 10243 | int idx_type = 3; |
10244 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, | |
10245 | argv[idx_type]->arg, 0); | |
10246 | return CMD_SUCCESS; | |
8386ac43 | 10247 | } |
10248 | ||
10249 | DEFUN (show_bgp_instance_updgrps_adj, | |
10250 | show_bgp_instance_updgrps_adj_cmd, | |
18c57037 | 10251 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10252 | SHOW_STR |
716b2d8a | 10253 | IP_STR |
8386ac43 | 10254 | BGP_STR |
10255 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10256 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10257 | "Advertisement queue\n" |
10258 | "Announced routes\n" | |
10259 | "Packet queue\n") | |
10260 | { | |
d62a17ae | 10261 | int idx_word = 3; |
10262 | int idx_type = 5; | |
10263 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_word]->arg, AFI_IP6, | |
10264 | SAFI_UNICAST, argv[idx_type]->arg, 0); | |
10265 | return CMD_SUCCESS; | |
3f9c7369 DS |
10266 | } |
10267 | ||
10268 | DEFUN (show_ip_bgp_updgrps_adj_s, | |
8fe8a7f6 | 10269 | show_ip_bgp_updgrps_adj_s_cmd, |
716b2d8a | 10270 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 DS |
10271 | SHOW_STR |
10272 | IP_STR | |
10273 | BGP_STR | |
0c7b1b01 | 10274 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 10275 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
10276 | "Advertisement queue\n" |
10277 | "Announced routes\n" | |
10278 | "Packet queue\n") | |
3f9c7369 | 10279 | { |
d62a17ae | 10280 | int idx_subgroup_id = 4; |
10281 | int idx_type = 5; | |
10282 | uint64_t subgrp_id; | |
8fe8a7f6 | 10283 | |
d62a17ae | 10284 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8fe8a7f6 | 10285 | |
d62a17ae | 10286 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP, SAFI_UNICAST, |
10287 | argv[idx_type]->arg, subgrp_id); | |
10288 | return CMD_SUCCESS; | |
8386ac43 | 10289 | } |
10290 | ||
10291 | DEFUN (show_ip_bgp_instance_updgrps_adj_s, | |
10292 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
18c57037 | 10293 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10294 | SHOW_STR |
10295 | IP_STR | |
10296 | BGP_STR | |
10297 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10298 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10299 | "Specific subgroup to display info for\n" |
10300 | "Advertisement queue\n" | |
10301 | "Announced routes\n" | |
10302 | "Packet queue\n") | |
8386ac43 | 10303 | { |
d62a17ae | 10304 | int idx_vrf = 4; |
10305 | int idx_subgroup_id = 6; | |
10306 | int idx_type = 7; | |
10307 | uint64_t subgrp_id; | |
8386ac43 | 10308 | |
d62a17ae | 10309 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8386ac43 | 10310 | |
d62a17ae | 10311 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP, |
10312 | SAFI_UNICAST, argv[idx_type]->arg, | |
10313 | subgrp_id); | |
10314 | return CMD_SUCCESS; | |
3f9c7369 DS |
10315 | } |
10316 | ||
8fe8a7f6 DS |
10317 | DEFUN (show_bgp_updgrps_afi_adj_s, |
10318 | show_bgp_updgrps_afi_adj_s_cmd, | |
46f296b4 | 10319 | "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
3f9c7369 | 10320 | SHOW_STR |
716b2d8a | 10321 | IP_STR |
3f9c7369 | 10322 | BGP_STR |
46f296b4 | 10323 | BGP_AFI_SAFI_HELP_STR |
0c7b1b01 | 10324 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 | 10325 | "Specific subgroup to display info for\n" |
3f9c7369 DS |
10326 | "Advertisement queue\n" |
10327 | "Announced routes\n" | |
7111c1a0 | 10328 | "Packet queue\n") |
3f9c7369 | 10329 | { |
d62a17ae | 10330 | int idx_afi = 2; |
10331 | int idx_safi = 3; | |
10332 | int idx_subgroup_id = 5; | |
10333 | int idx_type = 6; | |
10334 | uint64_t subgrp_id; | |
3f9c7369 | 10335 | |
d62a17ae | 10336 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8fe8a7f6 | 10337 | |
d62a17ae | 10338 | show_bgp_updgrps_adj_info_aux( |
10339 | vty, NULL, bgp_vty_afi_from_str(argv[idx_afi]->text), | |
10340 | bgp_vty_safi_from_str(argv[idx_safi]->text), | |
10341 | argv[idx_type]->arg, subgrp_id); | |
10342 | return CMD_SUCCESS; | |
3f9c7369 DS |
10343 | } |
10344 | ||
8fe8a7f6 DS |
10345 | DEFUN (show_bgp_updgrps_adj_s, |
10346 | show_bgp_updgrps_adj_s_cmd, | |
716b2d8a | 10347 | "show [ip] bgp update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8fe8a7f6 | 10348 | SHOW_STR |
716b2d8a | 10349 | IP_STR |
8fe8a7f6 | 10350 | BGP_STR |
0c7b1b01 | 10351 | "Detailed info about dynamic update groups\n" |
8fe8a7f6 DS |
10352 | "Specific subgroup to display info for\n" |
10353 | "Advertisement queue\n" | |
10354 | "Announced routes\n" | |
10355 | "Packet queue\n") | |
10356 | { | |
d62a17ae | 10357 | int idx_subgroup_id = 3; |
10358 | int idx_type = 4; | |
10359 | uint64_t subgrp_id; | |
8fe8a7f6 | 10360 | |
d62a17ae | 10361 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); |
8fe8a7f6 | 10362 | |
d62a17ae | 10363 | show_bgp_updgrps_adj_info_aux(vty, NULL, AFI_IP6, SAFI_UNICAST, |
10364 | argv[idx_type]->arg, subgrp_id); | |
10365 | return CMD_SUCCESS; | |
8fe8a7f6 DS |
10366 | } |
10367 | ||
8386ac43 | 10368 | DEFUN (show_bgp_instance_updgrps_adj_s, |
10369 | show_bgp_instance_updgrps_adj_s_cmd, | |
18c57037 | 10370 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups SUBGROUP-ID <advertise-queue|advertised-routes|packet-queue>", |
8386ac43 | 10371 | SHOW_STR |
716b2d8a | 10372 | IP_STR |
8386ac43 | 10373 | BGP_STR |
10374 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 10375 | "Detailed info about dynamic update groups\n" |
8386ac43 | 10376 | "Specific subgroup to display info for\n" |
10377 | "Advertisement queue\n" | |
10378 | "Announced routes\n" | |
10379 | "Packet queue\n") | |
10380 | { | |
d62a17ae | 10381 | int idx_vrf = 3; |
10382 | int idx_subgroup_id = 5; | |
10383 | int idx_type = 6; | |
10384 | uint64_t subgrp_id; | |
10385 | ||
10386 | subgrp_id = strtoull(argv[idx_subgroup_id]->arg, NULL, 10); | |
10387 | ||
10388 | show_bgp_updgrps_adj_info_aux(vty, argv[idx_vrf]->arg, AFI_IP6, | |
10389 | SAFI_UNICAST, argv[idx_type]->arg, | |
10390 | subgrp_id); | |
10391 | return CMD_SUCCESS; | |
10392 | } | |
10393 | ||
10394 | ||
10395 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) | |
10396 | { | |
10397 | struct listnode *node, *nnode; | |
10398 | struct prefix *range; | |
10399 | struct peer *conf; | |
10400 | struct peer *peer; | |
10401 | char buf[PREFIX2STR_BUFFER]; | |
10402 | afi_t afi; | |
10403 | safi_t safi; | |
10404 | const char *peer_status; | |
10405 | const char *af_str; | |
10406 | int lr_count; | |
10407 | int dynamic; | |
10408 | int af_cfgd; | |
10409 | ||
10410 | conf = group->conf; | |
10411 | ||
10412 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
10413 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
10414 | conf->as); | |
10415 | } else if (conf->as_type == AS_INTERNAL) { | |
10416 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
10417 | group->bgp->as); | |
10418 | } else { | |
10419 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
10420 | } | |
f14e6fdb | 10421 | |
d62a17ae | 10422 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
10423 | vty_out(vty, " Peer-group type is internal\n"); | |
10424 | else | |
10425 | vty_out(vty, " Peer-group type is external\n"); | |
10426 | ||
10427 | /* Display AFs configured. */ | |
10428 | vty_out(vty, " Configured address-families:"); | |
10429 | for (afi = AFI_IP; afi < AFI_MAX; afi++) | |
10430 | for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { | |
10431 | if (conf->afc[afi][safi]) { | |
10432 | af_cfgd = 1; | |
10433 | vty_out(vty, " %s;", afi_safi_print(afi, safi)); | |
10434 | } | |
10435 | } | |
10436 | if (!af_cfgd) | |
10437 | vty_out(vty, " none\n"); | |
10438 | else | |
10439 | vty_out(vty, "\n"); | |
10440 | ||
10441 | /* Display listen ranges (for dynamic neighbors), if any */ | |
10442 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
10443 | if (afi == AFI_IP) | |
10444 | af_str = "IPv4"; | |
10445 | else if (afi == AFI_IP6) | |
10446 | af_str = "IPv6"; | |
10447 | else | |
10448 | af_str = "???"; | |
10449 | lr_count = listcount(group->listen_range[afi]); | |
10450 | if (lr_count) { | |
10451 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
10452 | af_str); | |
10453 | ||
10454 | ||
10455 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
10456 | nnode, range)) { | |
10457 | prefix2str(range, buf, sizeof(buf)); | |
10458 | vty_out(vty, " %s\n", buf); | |
10459 | } | |
10460 | } | |
10461 | } | |
f14e6fdb | 10462 | |
d62a17ae | 10463 | /* Display group members and their status */ |
10464 | if (listcount(group->peer)) { | |
10465 | vty_out(vty, " Peer-group members:\n"); | |
10466 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
10467 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
10468 | peer_status = "Idle (Admin)"; | |
10469 | else if (CHECK_FLAG(peer->sflags, | |
10470 | PEER_STATUS_PREFIX_OVERFLOW)) | |
10471 | peer_status = "Idle (PfxCt)"; | |
10472 | else | |
10473 | peer_status = lookup_msg(bgp_status_msg, | |
10474 | peer->status, NULL); | |
10475 | ||
10476 | dynamic = peer_dynamic_neighbor(peer); | |
10477 | vty_out(vty, " %s %s %s \n", peer->host, | |
10478 | dynamic ? "(dynamic)" : "", peer_status); | |
10479 | } | |
10480 | } | |
f14e6fdb | 10481 | |
d62a17ae | 10482 | return CMD_SUCCESS; |
10483 | } | |
10484 | ||
10485 | /* Show BGP peer group's information. */ | |
10486 | enum show_group_type { show_all_groups, show_peer_group }; | |
10487 | ||
10488 | static int bgp_show_peer_group(struct vty *vty, struct bgp *bgp, | |
10489 | enum show_group_type type, | |
10490 | const char *group_name) | |
10491 | { | |
10492 | struct listnode *node, *nnode; | |
10493 | struct peer_group *group; | |
10494 | int find = 0; | |
10495 | ||
10496 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
10497 | switch (type) { | |
10498 | case show_all_groups: | |
10499 | bgp_show_one_peer_group(vty, group); | |
10500 | break; | |
10501 | case show_peer_group: | |
10502 | if (group_name | |
10503 | && (strcmp(group->name, group_name) == 0)) { | |
10504 | find = 1; | |
10505 | bgp_show_one_peer_group(vty, group); | |
10506 | } | |
10507 | break; | |
10508 | } | |
f14e6fdb | 10509 | } |
f14e6fdb | 10510 | |
d62a17ae | 10511 | if (type == show_peer_group && !find) |
10512 | vty_out(vty, "%% No such peer-group\n"); | |
f14e6fdb | 10513 | |
d62a17ae | 10514 | return CMD_SUCCESS; |
f14e6fdb DS |
10515 | } |
10516 | ||
d62a17ae | 10517 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
10518 | enum show_group_type type, | |
10519 | const char *group_name) | |
f14e6fdb | 10520 | { |
d62a17ae | 10521 | struct bgp *bgp; |
10522 | int ret = CMD_SUCCESS; | |
f14e6fdb | 10523 | |
d62a17ae | 10524 | if (name) |
10525 | bgp = bgp_lookup_by_name(name); | |
10526 | else | |
10527 | bgp = bgp_get_default(); | |
f14e6fdb | 10528 | |
d62a17ae | 10529 | if (!bgp) { |
10530 | vty_out(vty, "%% No such BGP instance exist\n"); | |
10531 | return CMD_WARNING; | |
10532 | } | |
f14e6fdb | 10533 | |
d62a17ae | 10534 | ret = bgp_show_peer_group(vty, bgp, type, group_name); |
f14e6fdb | 10535 | |
d62a17ae | 10536 | return ret; |
f14e6fdb DS |
10537 | } |
10538 | ||
10539 | DEFUN (show_ip_bgp_peer_groups, | |
10540 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 10541 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
10542 | SHOW_STR |
10543 | IP_STR | |
10544 | BGP_STR | |
8386ac43 | 10545 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
10546 | "Detailed information on BGP peer groups\n" |
10547 | "Peer group name\n") | |
f14e6fdb | 10548 | { |
d62a17ae | 10549 | char *vrf, *pg; |
10550 | vrf = pg = NULL; | |
10551 | int idx = 0; | |
f14e6fdb | 10552 | |
d62a17ae | 10553 | vrf = argv_find(argv, argc, "WORD", &idx) ? argv[idx]->arg : NULL; |
10554 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; | |
f14e6fdb | 10555 | |
d62a17ae | 10556 | return bgp_show_peer_group_vty(vty, vrf, show_all_groups, pg); |
f14e6fdb | 10557 | } |
3f9c7369 | 10558 | |
d6e3c605 | 10559 | |
718e3744 | 10560 | /* Redistribute VTY commands. */ |
10561 | ||
718e3744 | 10562 | DEFUN (bgp_redistribute_ipv4, |
10563 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 10564 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 10565 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10566 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 10567 | { |
d62a17ae | 10568 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10569 | int idx_protocol = 1; | |
10570 | int type; | |
718e3744 | 10571 | |
d62a17ae | 10572 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
10573 | if (type < 0) { | |
10574 | vty_out(vty, "%% Invalid route type\n"); | |
10575 | return CMD_WARNING_CONFIG_FAILED; | |
10576 | } | |
10577 | bgp_redist_add(bgp, AFI_IP, type, 0); | |
10578 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
718e3744 | 10579 | } |
10580 | ||
d62a17ae | 10581 | ALIAS_HIDDEN( |
10582 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
10583 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
10584 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 10585 | |
718e3744 | 10586 | DEFUN (bgp_redistribute_ipv4_rmap, |
10587 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 10588 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 10589 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10590 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10591 | "Route map reference\n" |
10592 | "Pointer to route-map entries\n") | |
10593 | { | |
d62a17ae | 10594 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10595 | int idx_protocol = 1; | |
10596 | int idx_word = 3; | |
10597 | int type; | |
10598 | struct bgp_redist *red; | |
718e3744 | 10599 | |
d62a17ae | 10600 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
10601 | if (type < 0) { | |
10602 | vty_out(vty, "%% Invalid route type\n"); | |
10603 | return CMD_WARNING_CONFIG_FAILED; | |
10604 | } | |
718e3744 | 10605 | |
d62a17ae | 10606 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
10607 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10608 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
718e3744 | 10609 | } |
10610 | ||
d62a17ae | 10611 | ALIAS_HIDDEN( |
10612 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
10613 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
10614 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10615 | "Route map reference\n" | |
10616 | "Pointer to route-map entries\n") | |
596c17ba | 10617 | |
718e3744 | 10618 | DEFUN (bgp_redistribute_ipv4_metric, |
10619 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 10620 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 10621 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10622 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10623 | "Metric for redistributed routes\n" |
10624 | "Default metric\n") | |
10625 | { | |
d62a17ae | 10626 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10627 | int idx_protocol = 1; | |
10628 | int idx_number = 3; | |
10629 | int type; | |
10630 | u_int32_t metric; | |
10631 | struct bgp_redist *red; | |
10632 | ||
10633 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
10634 | if (type < 0) { | |
10635 | vty_out(vty, "%% Invalid route type\n"); | |
10636 | return CMD_WARNING_CONFIG_FAILED; | |
10637 | } | |
10638 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
10639 | ||
10640 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
10641 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
10642 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
10643 | } | |
10644 | ||
10645 | ALIAS_HIDDEN( | |
10646 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
10647 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
10648 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10649 | "Metric for redistributed routes\n" | |
10650 | "Default metric\n") | |
596c17ba | 10651 | |
718e3744 | 10652 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
10653 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 10654 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 10655 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10656 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10657 | "Route map reference\n" |
10658 | "Pointer to route-map entries\n" | |
10659 | "Metric for redistributed routes\n" | |
10660 | "Default metric\n") | |
10661 | { | |
d62a17ae | 10662 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10663 | int idx_protocol = 1; | |
10664 | int idx_word = 3; | |
10665 | int idx_number = 5; | |
10666 | int type; | |
10667 | u_int32_t metric; | |
10668 | struct bgp_redist *red; | |
10669 | ||
10670 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
10671 | if (type < 0) { | |
10672 | vty_out(vty, "%% Invalid route type\n"); | |
10673 | return CMD_WARNING_CONFIG_FAILED; | |
10674 | } | |
10675 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
10676 | ||
10677 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
10678 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10679 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
10680 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
10681 | } | |
10682 | ||
10683 | ALIAS_HIDDEN( | |
10684 | bgp_redistribute_ipv4_rmap_metric, | |
10685 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
10686 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
10687 | " route-map WORD metric (0-4294967295)", | |
10688 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10689 | "Route map reference\n" | |
10690 | "Pointer to route-map entries\n" | |
10691 | "Metric for redistributed routes\n" | |
10692 | "Default metric\n") | |
596c17ba | 10693 | |
718e3744 | 10694 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
10695 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 10696 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 10697 | "Redistribute information from another routing protocol\n" |
ab0181ee | 10698 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 10699 | "Metric for redistributed routes\n" |
10700 | "Default metric\n" | |
10701 | "Route map reference\n" | |
10702 | "Pointer to route-map entries\n") | |
10703 | { | |
d62a17ae | 10704 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10705 | int idx_protocol = 1; | |
10706 | int idx_number = 3; | |
10707 | int idx_word = 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_metric_set(bgp, red, AFI_IP, type, metric); | |
10721 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10722 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
10723 | } | |
10724 | ||
10725 | ALIAS_HIDDEN( | |
10726 | bgp_redistribute_ipv4_metric_rmap, | |
10727 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
10728 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
10729 | " metric (0-4294967295) route-map WORD", | |
10730 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
10731 | "Metric for redistributed routes\n" | |
10732 | "Default metric\n" | |
10733 | "Route map reference\n" | |
10734 | "Pointer to route-map entries\n") | |
596c17ba | 10735 | |
7c8ff89e DS |
10736 | DEFUN (bgp_redistribute_ipv4_ospf, |
10737 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 10738 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
10739 | "Redistribute information from another routing protocol\n" |
10740 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10741 | "Non-main Kernel Routing Table\n" |
10742 | "Instance ID/Table ID\n") | |
7c8ff89e | 10743 | { |
d62a17ae | 10744 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10745 | int idx_ospf_table = 1; | |
10746 | int idx_number = 2; | |
10747 | u_short instance; | |
10748 | u_short protocol; | |
7c8ff89e | 10749 | |
d62a17ae | 10750 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 10751 | |
d62a17ae | 10752 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
10753 | protocol = ZEBRA_ROUTE_OSPF; | |
10754 | else | |
10755 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 10756 | |
d62a17ae | 10757 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
10758 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
10759 | } |
10760 | ||
d62a17ae | 10761 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
10762 | "redistribute <ospf|table> (1-65535)", | |
10763 | "Redistribute information from another routing protocol\n" | |
10764 | "Open Shortest Path First (OSPFv2)\n" | |
10765 | "Non-main Kernel Routing Table\n" | |
10766 | "Instance ID/Table ID\n") | |
596c17ba | 10767 | |
7c8ff89e DS |
10768 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
10769 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 10770 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
10771 | "Redistribute information from another routing protocol\n" |
10772 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10773 | "Non-main Kernel Routing Table\n" |
10774 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10775 | "Route map reference\n" |
10776 | "Pointer to route-map entries\n") | |
10777 | { | |
d62a17ae | 10778 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10779 | int idx_ospf_table = 1; | |
10780 | int idx_number = 2; | |
10781 | int idx_word = 4; | |
10782 | struct bgp_redist *red; | |
10783 | u_short instance; | |
10784 | int protocol; | |
10785 | ||
10786 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10787 | protocol = ZEBRA_ROUTE_OSPF; | |
10788 | else | |
10789 | protocol = ZEBRA_ROUTE_TABLE; | |
10790 | ||
10791 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10792 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
10793 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10794 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
10795 | } | |
10796 | ||
10797 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
10798 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
10799 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
10800 | "Redistribute information from another routing protocol\n" | |
10801 | "Open Shortest Path First (OSPFv2)\n" | |
10802 | "Non-main Kernel Routing Table\n" | |
10803 | "Instance ID/Table ID\n" | |
10804 | "Route map reference\n" | |
10805 | "Pointer to route-map entries\n") | |
596c17ba | 10806 | |
7c8ff89e DS |
10807 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
10808 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 10809 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
10810 | "Redistribute information from another routing protocol\n" |
10811 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10812 | "Non-main Kernel Routing Table\n" |
10813 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10814 | "Metric for redistributed routes\n" |
10815 | "Default metric\n") | |
10816 | { | |
d62a17ae | 10817 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10818 | int idx_ospf_table = 1; | |
10819 | int idx_number = 2; | |
10820 | int idx_number_2 = 4; | |
10821 | u_int32_t metric; | |
10822 | struct bgp_redist *red; | |
10823 | u_short instance; | |
10824 | int protocol; | |
10825 | ||
10826 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10827 | protocol = ZEBRA_ROUTE_OSPF; | |
10828 | else | |
10829 | protocol = ZEBRA_ROUTE_TABLE; | |
10830 | ||
10831 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10832 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
10833 | ||
10834 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
10835 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
10836 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
10837 | } | |
10838 | ||
10839 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
10840 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
10841 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
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 | "Metric for redistributed routes\n" | |
10847 | "Default metric\n") | |
596c17ba | 10848 | |
7c8ff89e DS |
10849 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
10850 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 10851 | "redistribute <ospf|table> (1-65535) route-map WORD 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 | "Route map reference\n" |
10857 | "Pointer to route-map entries\n" | |
10858 | "Metric for redistributed routes\n" | |
10859 | "Default metric\n") | |
10860 | { | |
d62a17ae | 10861 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10862 | int idx_ospf_table = 1; | |
10863 | int idx_number = 2; | |
10864 | int idx_word = 4; | |
10865 | int idx_number_2 = 6; | |
10866 | u_int32_t metric; | |
10867 | struct bgp_redist *red; | |
10868 | u_short instance; | |
10869 | int protocol; | |
10870 | ||
10871 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10872 | protocol = ZEBRA_ROUTE_OSPF; | |
10873 | else | |
10874 | protocol = ZEBRA_ROUTE_TABLE; | |
10875 | ||
10876 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10877 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
10878 | ||
10879 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
10880 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10881 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
10882 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
10883 | } | |
10884 | ||
10885 | ALIAS_HIDDEN( | |
10886 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
10887 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
10888 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
10889 | "Redistribute information from another routing protocol\n" | |
10890 | "Open Shortest Path First (OSPFv2)\n" | |
10891 | "Non-main Kernel Routing Table\n" | |
10892 | "Instance ID/Table ID\n" | |
10893 | "Route map reference\n" | |
10894 | "Pointer to route-map entries\n" | |
10895 | "Metric for redistributed routes\n" | |
10896 | "Default metric\n") | |
596c17ba | 10897 | |
7c8ff89e DS |
10898 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
10899 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 10900 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
10901 | "Redistribute information from another routing protocol\n" |
10902 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
10903 | "Non-main Kernel Routing Table\n" |
10904 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
10905 | "Metric for redistributed routes\n" |
10906 | "Default metric\n" | |
10907 | "Route map reference\n" | |
10908 | "Pointer to route-map entries\n") | |
10909 | { | |
d62a17ae | 10910 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10911 | int idx_ospf_table = 1; | |
10912 | int idx_number = 2; | |
10913 | int idx_number_2 = 4; | |
10914 | int idx_word = 6; | |
10915 | u_int32_t metric; | |
10916 | struct bgp_redist *red; | |
10917 | u_short instance; | |
10918 | int protocol; | |
10919 | ||
10920 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10921 | protocol = ZEBRA_ROUTE_OSPF; | |
10922 | else | |
10923 | protocol = ZEBRA_ROUTE_TABLE; | |
10924 | ||
10925 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10926 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
10927 | ||
10928 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
10929 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
10930 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
10931 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
10932 | } | |
10933 | ||
10934 | ALIAS_HIDDEN( | |
10935 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
10936 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
10937 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
10938 | "Redistribute information from another routing protocol\n" | |
10939 | "Open Shortest Path First (OSPFv2)\n" | |
10940 | "Non-main Kernel Routing Table\n" | |
10941 | "Instance ID/Table ID\n" | |
10942 | "Metric for redistributed routes\n" | |
10943 | "Default metric\n" | |
10944 | "Route map reference\n" | |
10945 | "Pointer to route-map entries\n") | |
596c17ba | 10946 | |
7c8ff89e DS |
10947 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
10948 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 10949 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
10950 | NO_STR |
10951 | "Redistribute information from another routing protocol\n" | |
10952 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 10953 | "Non-main Kernel Routing Table\n" |
31500417 DW |
10954 | "Instance ID/Table ID\n" |
10955 | "Metric for redistributed routes\n" | |
10956 | "Default metric\n" | |
10957 | "Route map reference\n" | |
10958 | "Pointer to route-map entries\n") | |
7c8ff89e | 10959 | { |
d62a17ae | 10960 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
10961 | int idx_ospf_table = 2; | |
10962 | int idx_number = 3; | |
10963 | u_short instance; | |
10964 | int protocol; | |
10965 | ||
10966 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
10967 | protocol = ZEBRA_ROUTE_OSPF; | |
10968 | else | |
10969 | protocol = ZEBRA_ROUTE_TABLE; | |
10970 | ||
10971 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
10972 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
10973 | } | |
10974 | ||
10975 | ALIAS_HIDDEN( | |
10976 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
10977 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", | |
10978 | NO_STR | |
10979 | "Redistribute information from another routing protocol\n" | |
10980 | "Open Shortest Path First (OSPFv2)\n" | |
10981 | "Non-main Kernel Routing Table\n" | |
10982 | "Instance ID/Table ID\n" | |
10983 | "Metric for redistributed routes\n" | |
10984 | "Default metric\n" | |
10985 | "Route map reference\n" | |
10986 | "Pointer to route-map entries\n") | |
596c17ba | 10987 | |
718e3744 | 10988 | DEFUN (no_bgp_redistribute_ipv4, |
10989 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 10990 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 10991 | NO_STR |
10992 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 10993 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
10994 | "Metric for redistributed routes\n" |
10995 | "Default metric\n" | |
10996 | "Route map reference\n" | |
10997 | "Pointer to route-map entries\n") | |
718e3744 | 10998 | { |
d62a17ae | 10999 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11000 | int idx_protocol = 2; | |
11001 | int type; | |
11002 | ||
11003 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11004 | if (type < 0) { | |
11005 | vty_out(vty, "%% Invalid route type\n"); | |
11006 | return CMD_WARNING_CONFIG_FAILED; | |
11007 | } | |
11008 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
11009 | } | |
11010 | ||
11011 | ALIAS_HIDDEN( | |
11012 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
11013 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
11014 | " [metric (0-4294967295)] [route-map WORD]", | |
11015 | NO_STR | |
11016 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11017 | "Metric for redistributed routes\n" | |
11018 | "Default metric\n" | |
11019 | "Route map reference\n" | |
11020 | "Pointer to route-map entries\n") | |
596c17ba | 11021 | |
718e3744 | 11022 | DEFUN (bgp_redistribute_ipv6, |
11023 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 11024 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 11025 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11026 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 11027 | { |
d62a17ae | 11028 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11029 | int idx_protocol = 1; | |
11030 | int type; | |
718e3744 | 11031 | |
d62a17ae | 11032 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
11033 | if (type < 0) { | |
11034 | vty_out(vty, "%% Invalid route type\n"); | |
11035 | return CMD_WARNING_CONFIG_FAILED; | |
11036 | } | |
718e3744 | 11037 | |
d62a17ae | 11038 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
11039 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11040 | } |
11041 | ||
11042 | DEFUN (bgp_redistribute_ipv6_rmap, | |
11043 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 11044 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 11045 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11046 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11047 | "Route map reference\n" |
11048 | "Pointer to route-map entries\n") | |
11049 | { | |
d62a17ae | 11050 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11051 | int idx_protocol = 1; | |
11052 | int idx_word = 3; | |
11053 | int type; | |
11054 | struct bgp_redist *red; | |
718e3744 | 11055 | |
d62a17ae | 11056 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
11057 | if (type < 0) { | |
11058 | vty_out(vty, "%% Invalid route type\n"); | |
11059 | return CMD_WARNING_CONFIG_FAILED; | |
11060 | } | |
718e3744 | 11061 | |
d62a17ae | 11062 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11063 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11064 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11065 | } |
11066 | ||
11067 | DEFUN (bgp_redistribute_ipv6_metric, | |
11068 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 11069 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 11070 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11071 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11072 | "Metric for redistributed routes\n" |
11073 | "Default metric\n") | |
11074 | { | |
d62a17ae | 11075 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11076 | int idx_protocol = 1; | |
11077 | int idx_number = 3; | |
11078 | int type; | |
11079 | u_int32_t metric; | |
11080 | struct bgp_redist *red; | |
11081 | ||
11082 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
11083 | if (type < 0) { | |
11084 | vty_out(vty, "%% Invalid route type\n"); | |
11085 | return CMD_WARNING_CONFIG_FAILED; | |
11086 | } | |
11087 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 11088 | |
d62a17ae | 11089 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11090 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
11091 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11092 | } |
11093 | ||
11094 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
11095 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 11096 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 11097 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11098 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11099 | "Route map reference\n" |
11100 | "Pointer to route-map entries\n" | |
11101 | "Metric for redistributed routes\n" | |
11102 | "Default metric\n") | |
11103 | { | |
d62a17ae | 11104 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11105 | int idx_protocol = 1; | |
11106 | int idx_word = 3; | |
11107 | int idx_number = 5; | |
11108 | int type; | |
11109 | u_int32_t metric; | |
11110 | struct bgp_redist *red; | |
11111 | ||
11112 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
11113 | if (type < 0) { | |
11114 | vty_out(vty, "%% Invalid route type\n"); | |
11115 | return CMD_WARNING_CONFIG_FAILED; | |
11116 | } | |
11117 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 11118 | |
d62a17ae | 11119 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11120 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11121 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
11122 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11123 | } |
11124 | ||
11125 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
11126 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 11127 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 11128 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11129 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11130 | "Metric for redistributed routes\n" |
11131 | "Default metric\n" | |
11132 | "Route map reference\n" | |
11133 | "Pointer to route-map entries\n") | |
11134 | { | |
d62a17ae | 11135 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11136 | int idx_protocol = 1; | |
11137 | int idx_number = 3; | |
11138 | int idx_word = 5; | |
11139 | int type; | |
11140 | u_int32_t metric; | |
11141 | struct bgp_redist *red; | |
11142 | ||
11143 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
11144 | if (type < 0) { | |
11145 | vty_out(vty, "%% Invalid route type\n"); | |
11146 | return CMD_WARNING_CONFIG_FAILED; | |
11147 | } | |
11148 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 11149 | |
d62a17ae | 11150 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11151 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric); | |
11152 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11153 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11154 | } |
11155 | ||
11156 | DEFUN (no_bgp_redistribute_ipv6, | |
11157 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 11158 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 11159 | NO_STR |
11160 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 11161 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
11162 | "Metric for redistributed routes\n" |
11163 | "Default metric\n" | |
11164 | "Route map reference\n" | |
11165 | "Pointer to route-map entries\n") | |
718e3744 | 11166 | { |
d62a17ae | 11167 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11168 | int idx_protocol = 2; | |
11169 | int type; | |
718e3744 | 11170 | |
d62a17ae | 11171 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
11172 | if (type < 0) { | |
11173 | vty_out(vty, "%% Invalid route type\n"); | |
11174 | return CMD_WARNING_CONFIG_FAILED; | |
11175 | } | |
718e3744 | 11176 | |
d62a17ae | 11177 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
11178 | } | |
11179 | ||
11180 | int bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi, | |
11181 | safi_t safi, int *write) | |
11182 | { | |
11183 | int i; | |
11184 | ||
11185 | /* Unicast redistribution only. */ | |
11186 | if (safi != SAFI_UNICAST) | |
11187 | return 0; | |
11188 | ||
11189 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
11190 | /* Redistribute BGP does not make sense. */ | |
11191 | if (i != ZEBRA_ROUTE_BGP) { | |
11192 | struct list *red_list; | |
11193 | struct listnode *node; | |
11194 | struct bgp_redist *red; | |
11195 | ||
11196 | red_list = bgp->redist[afi][i]; | |
11197 | if (!red_list) | |
11198 | continue; | |
11199 | ||
11200 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
11201 | /* Display "address-family" when it is not yet | |
11202 | * diplayed. */ | |
11203 | bgp_config_write_family_header(vty, afi, safi, | |
11204 | write); | |
11205 | ||
11206 | /* "redistribute" configuration. */ | |
11207 | vty_out(vty, " redistribute %s", | |
11208 | zebra_route_string(i)); | |
11209 | if (red->instance) | |
11210 | vty_out(vty, " %d", red->instance); | |
11211 | if (red->redist_metric_flag) | |
11212 | vty_out(vty, " metric %u", | |
11213 | red->redist_metric); | |
11214 | if (red->rmap.name) | |
11215 | vty_out(vty, " route-map %s", | |
11216 | red->rmap.name); | |
11217 | vty_out(vty, "\n"); | |
11218 | } | |
11219 | } | |
11220 | } | |
11221 | return *write; | |
718e3744 | 11222 | } |
6b0655a2 | 11223 | |
718e3744 | 11224 | /* BGP node structure. */ |
d62a17ae | 11225 | static struct cmd_node bgp_node = { |
9d303b37 | 11226 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 11227 | }; |
11228 | ||
d62a17ae | 11229 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 11230 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 11231 | }; |
11232 | ||
d62a17ae | 11233 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 11234 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 11235 | }; |
11236 | ||
d62a17ae | 11237 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 11238 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
11239 | }; |
11240 | ||
d62a17ae | 11241 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 11242 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 11243 | }; |
11244 | ||
d62a17ae | 11245 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 11246 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 11247 | }; |
11248 | ||
d62a17ae | 11249 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 11250 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
11251 | }; |
11252 | ||
d62a17ae | 11253 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
11254 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 11255 | |
d62a17ae | 11256 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
11257 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 11258 | |
d62a17ae | 11259 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
11260 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 11261 | |
d62a17ae | 11262 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
11263 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 11264 | |
d62a17ae | 11265 | static void community_list_vty(void); |
1f8ae70b | 11266 | |
d62a17ae | 11267 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 11268 | { |
d62a17ae | 11269 | struct bgp *bgp; |
11270 | struct peer *peer; | |
11271 | struct peer_group *group; | |
11272 | struct listnode *lnbgp, *lnpeer; | |
b8a815e5 | 11273 | |
d62a17ae | 11274 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
11275 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
11276 | /* only provide suggestions on the appropriate input | |
11277 | * token type, | |
11278 | * they'll otherwise show up multiple times */ | |
11279 | enum cmd_token_type match_type; | |
11280 | char *name = peer->host; | |
d48ed3e0 | 11281 | |
d62a17ae | 11282 | if (peer->conf_if) { |
11283 | match_type = VARIABLE_TKN; | |
11284 | name = peer->conf_if; | |
11285 | } else if (strchr(peer->host, ':')) | |
11286 | match_type = IPV6_TKN; | |
11287 | else | |
11288 | match_type = IPV4_TKN; | |
d48ed3e0 | 11289 | |
d62a17ae | 11290 | if (token->type != match_type) |
11291 | continue; | |
d48ed3e0 | 11292 | |
d62a17ae | 11293 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
11294 | } | |
d48ed3e0 | 11295 | |
d62a17ae | 11296 | if (token->type == VARIABLE_TKN) |
11297 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
11298 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
11299 | group->name)); | |
11300 | } | |
b8a815e5 DL |
11301 | } |
11302 | ||
11303 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 11304 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
11305 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
11306 | {.completions = NULL}}; | |
11307 | ||
11308 | void bgp_vty_init(void) | |
11309 | { | |
11310 | cmd_variable_handler_register(bgp_var_neighbor); | |
11311 | ||
11312 | /* Install bgp top node. */ | |
11313 | install_node(&bgp_node, bgp_config_write); | |
11314 | install_node(&bgp_ipv4_unicast_node, NULL); | |
11315 | install_node(&bgp_ipv4_multicast_node, NULL); | |
11316 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
11317 | install_node(&bgp_ipv6_unicast_node, NULL); | |
11318 | install_node(&bgp_ipv6_multicast_node, NULL); | |
11319 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
11320 | install_node(&bgp_vpnv4_node, NULL); | |
11321 | install_node(&bgp_vpnv6_node, NULL); | |
11322 | install_node(&bgp_evpn_node, NULL); | |
11323 | install_node(&bgp_evpn_vni_node, NULL); | |
11324 | ||
11325 | /* Install default VTY commands to new nodes. */ | |
11326 | install_default(BGP_NODE); | |
11327 | install_default(BGP_IPV4_NODE); | |
11328 | install_default(BGP_IPV4M_NODE); | |
11329 | install_default(BGP_IPV4L_NODE); | |
11330 | install_default(BGP_IPV6_NODE); | |
11331 | install_default(BGP_IPV6M_NODE); | |
11332 | install_default(BGP_IPV6L_NODE); | |
11333 | install_default(BGP_VPNV4_NODE); | |
11334 | install_default(BGP_VPNV6_NODE); | |
11335 | install_default(BGP_EVPN_NODE); | |
11336 | install_default(BGP_EVPN_VNI_NODE); | |
11337 | ||
11338 | /* "bgp multiple-instance" commands. */ | |
11339 | install_element(CONFIG_NODE, &bgp_multiple_instance_cmd); | |
11340 | install_element(CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
11341 | ||
11342 | /* "bgp config-type" commands. */ | |
11343 | install_element(CONFIG_NODE, &bgp_config_type_cmd); | |
11344 | install_element(CONFIG_NODE, &no_bgp_config_type_cmd); | |
11345 | ||
11346 | /* bgp route-map delay-timer commands. */ | |
11347 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
11348 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
11349 | ||
11350 | /* Dummy commands (Currently not supported) */ | |
11351 | install_element(BGP_NODE, &no_synchronization_cmd); | |
11352 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
11353 | ||
11354 | /* "router bgp" commands. */ | |
11355 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
11356 | ||
11357 | /* "no router bgp" commands. */ | |
11358 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
11359 | ||
11360 | /* "bgp router-id" commands. */ | |
11361 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
11362 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
11363 | ||
11364 | /* "bgp cluster-id" commands. */ | |
11365 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
11366 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
11367 | ||
11368 | /* "bgp confederation" commands. */ | |
11369 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
11370 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
11371 | ||
11372 | /* "bgp confederation peers" commands. */ | |
11373 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
11374 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
11375 | ||
11376 | /* bgp max-med command */ | |
11377 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
11378 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
11379 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
11380 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
11381 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
11382 | ||
11383 | /* bgp disable-ebgp-connected-nh-check */ | |
11384 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
11385 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
11386 | ||
11387 | /* bgp update-delay command */ | |
11388 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
11389 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
11390 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
11391 | ||
11392 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
11393 | install_element(BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
11394 | ||
11395 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
11396 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
11397 | ||
11398 | /* "maximum-paths" commands. */ | |
11399 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
11400 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
11401 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
11402 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
11403 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
11404 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
11405 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
11406 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
11407 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
11408 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
11409 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
11410 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
11411 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
11412 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
11413 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
11414 | ||
11415 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
11416 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
11417 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
11418 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
11419 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
11420 | ||
11421 | /* "timers bgp" commands. */ | |
11422 | install_element(BGP_NODE, &bgp_timers_cmd); | |
11423 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
11424 | ||
11425 | /* route-map delay-timer commands - per instance for backwards compat. | |
11426 | */ | |
11427 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
11428 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
11429 | ||
11430 | /* "bgp client-to-client reflection" commands */ | |
11431 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
11432 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
11433 | ||
11434 | /* "bgp always-compare-med" commands */ | |
11435 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
11436 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
11437 | ||
11438 | /* "bgp deterministic-med" commands */ | |
11439 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
11440 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
11441 | ||
11442 | /* "bgp graceful-restart" commands */ | |
11443 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); | |
11444 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
11445 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); | |
11446 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
11447 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
11448 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
11449 | ||
11450 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); | |
11451 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
11452 | ||
11453 | /* "bgp fast-external-failover" commands */ | |
11454 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
11455 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
11456 | ||
11457 | /* "bgp enforce-first-as" commands */ | |
11458 | install_element(BGP_NODE, &bgp_enforce_first_as_cmd); | |
11459 | install_element(BGP_NODE, &no_bgp_enforce_first_as_cmd); | |
11460 | ||
11461 | /* "bgp bestpath compare-routerid" commands */ | |
11462 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
11463 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
11464 | ||
11465 | /* "bgp bestpath as-path ignore" commands */ | |
11466 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
11467 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
11468 | ||
11469 | /* "bgp bestpath as-path confed" commands */ | |
11470 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
11471 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
11472 | ||
11473 | /* "bgp bestpath as-path multipath-relax" commands */ | |
11474 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
11475 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
11476 | ||
11477 | /* "bgp log-neighbor-changes" commands */ | |
11478 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
11479 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
11480 | ||
11481 | /* "bgp bestpath med" commands */ | |
11482 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
11483 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
11484 | ||
11485 | /* "no bgp default ipv4-unicast" commands. */ | |
11486 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
11487 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
11488 | ||
11489 | /* "bgp network import-check" commands. */ | |
11490 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
11491 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
11492 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
11493 | ||
11494 | /* "bgp default local-preference" commands. */ | |
11495 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
11496 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
11497 | ||
11498 | /* bgp default show-hostname */ | |
11499 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
11500 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
11501 | ||
11502 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
11503 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
11504 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
11505 | ||
11506 | /* bgp ibgp-allow-policy-mods command */ | |
11507 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
11508 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
11509 | ||
11510 | /* "bgp listen limit" commands. */ | |
11511 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
11512 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
11513 | ||
11514 | /* "bgp listen range" commands. */ | |
11515 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
11516 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
11517 | ||
11518 | /* "neighbor remote-as" commands. */ | |
11519 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
11520 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
11521 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
11522 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
11523 | install_element(BGP_NODE, | |
11524 | &neighbor_interface_v6only_config_remote_as_cmd); | |
11525 | install_element(BGP_NODE, &no_neighbor_cmd); | |
11526 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
11527 | ||
11528 | /* "neighbor peer-group" commands. */ | |
11529 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
11530 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
11531 | install_element(BGP_NODE, | |
11532 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
11533 | ||
11534 | /* "neighbor local-as" commands. */ | |
11535 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
11536 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
11537 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
11538 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
11539 | ||
11540 | /* "neighbor solo" commands. */ | |
11541 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
11542 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
11543 | ||
11544 | /* "neighbor password" commands. */ | |
11545 | install_element(BGP_NODE, &neighbor_password_cmd); | |
11546 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
11547 | ||
11548 | /* "neighbor activate" commands. */ | |
11549 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
11550 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
11551 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
11552 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
11553 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
11554 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
11555 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
11556 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
11557 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
11558 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); | |
11559 | ||
11560 | /* "no neighbor activate" commands. */ | |
11561 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
11562 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
11563 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
11564 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
11565 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
11566 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
11567 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
11568 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
11569 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
11570 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); | |
11571 | ||
11572 | /* "neighbor peer-group" set commands. */ | |
11573 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
11574 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11575 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11576 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11577 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11578 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11579 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11580 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
11581 | ||
11582 | /* "no neighbor peer-group unset" commands. */ | |
11583 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
11584 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11585 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11586 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11587 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11588 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11589 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11590 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
11591 | ||
11592 | /* "neighbor softreconfiguration inbound" commands.*/ | |
11593 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
11594 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
11595 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
11596 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11597 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
11598 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11599 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
11600 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11601 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
11602 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11603 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
11604 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11605 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
11606 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11607 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
11608 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11609 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
11610 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
11611 | ||
11612 | /* "neighbor attribute-unchanged" commands. */ | |
11613 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
11614 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
11615 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
11616 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
11617 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
11618 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
11619 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
11620 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
11621 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
11622 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
11623 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
11624 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
11625 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
11626 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
11627 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
11628 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
11629 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
11630 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
11631 | ||
11632 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
11633 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
11634 | ||
11635 | /* "nexthop-local unchanged" commands */ | |
11636 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
11637 | install_element(BGP_IPV6_NODE, | |
11638 | &no_neighbor_nexthop_local_unchanged_cmd); | |
11639 | ||
11640 | /* "neighbor next-hop-self" commands. */ | |
11641 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
11642 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
11643 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
11644 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
11645 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
11646 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
11647 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
11648 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
11649 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
11650 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
11651 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
11652 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
11653 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
11654 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
11655 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
11656 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
11657 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
11658 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
11659 | ||
11660 | /* "neighbor next-hop-self force" commands. */ | |
11661 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
11662 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
11663 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
11664 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11665 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
11666 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11667 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); | |
11668 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11669 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
11670 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11671 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
11672 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11673 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); | |
11674 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11675 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
11676 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11677 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); | |
11678 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
11679 | ||
11680 | /* "neighbor as-override" commands. */ | |
11681 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
11682 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
11683 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
11684 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
11685 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
11686 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
11687 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
11688 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
11689 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
11690 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
11691 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
11692 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
11693 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
11694 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
11695 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
11696 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
11697 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
11698 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
11699 | ||
11700 | /* "neighbor remove-private-AS" commands. */ | |
11701 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
11702 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
11703 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
11704 | install_element(BGP_NODE, | |
11705 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
11706 | install_element(BGP_NODE, | |
11707 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
11708 | install_element(BGP_NODE, | |
11709 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
11710 | install_element(BGP_NODE, | |
11711 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
11712 | install_element( | |
11713 | BGP_NODE, | |
11714 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
11715 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
11716 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
11717 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
11718 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11719 | install_element(BGP_IPV4_NODE, | |
11720 | &neighbor_remove_private_as_replace_as_cmd); | |
11721 | install_element(BGP_IPV4_NODE, | |
11722 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11723 | install_element(BGP_IPV4_NODE, | |
11724 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11725 | install_element(BGP_IPV4_NODE, | |
11726 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11727 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
11728 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
11729 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
11730 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11731 | install_element(BGP_IPV4M_NODE, | |
11732 | &neighbor_remove_private_as_replace_as_cmd); | |
11733 | install_element(BGP_IPV4M_NODE, | |
11734 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11735 | install_element(BGP_IPV4M_NODE, | |
11736 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11737 | install_element(BGP_IPV4M_NODE, | |
11738 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11739 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
11740 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
11741 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
11742 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11743 | install_element(BGP_IPV4L_NODE, | |
11744 | &neighbor_remove_private_as_replace_as_cmd); | |
11745 | install_element(BGP_IPV4L_NODE, | |
11746 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11747 | install_element(BGP_IPV4L_NODE, | |
11748 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11749 | install_element(BGP_IPV4L_NODE, | |
11750 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11751 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
11752 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
11753 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
11754 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11755 | install_element(BGP_IPV6_NODE, | |
11756 | &neighbor_remove_private_as_replace_as_cmd); | |
11757 | install_element(BGP_IPV6_NODE, | |
11758 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11759 | install_element(BGP_IPV6_NODE, | |
11760 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11761 | install_element(BGP_IPV6_NODE, | |
11762 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11763 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
11764 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
11765 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
11766 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11767 | install_element(BGP_IPV6M_NODE, | |
11768 | &neighbor_remove_private_as_replace_as_cmd); | |
11769 | install_element(BGP_IPV6M_NODE, | |
11770 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11771 | install_element(BGP_IPV6M_NODE, | |
11772 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11773 | install_element(BGP_IPV6M_NODE, | |
11774 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11775 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
11776 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
11777 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
11778 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11779 | install_element(BGP_IPV6L_NODE, | |
11780 | &neighbor_remove_private_as_replace_as_cmd); | |
11781 | install_element(BGP_IPV6L_NODE, | |
11782 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11783 | install_element(BGP_IPV6L_NODE, | |
11784 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11785 | install_element(BGP_IPV6L_NODE, | |
11786 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11787 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
11788 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
11789 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
11790 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11791 | install_element(BGP_VPNV4_NODE, | |
11792 | &neighbor_remove_private_as_replace_as_cmd); | |
11793 | install_element(BGP_VPNV4_NODE, | |
11794 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11795 | install_element(BGP_VPNV4_NODE, | |
11796 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11797 | install_element(BGP_VPNV4_NODE, | |
11798 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11799 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
11800 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
11801 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
11802 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
11803 | install_element(BGP_VPNV6_NODE, | |
11804 | &neighbor_remove_private_as_replace_as_cmd); | |
11805 | install_element(BGP_VPNV6_NODE, | |
11806 | &no_neighbor_remove_private_as_replace_as_cmd); | |
11807 | install_element(BGP_VPNV6_NODE, | |
11808 | &neighbor_remove_private_as_all_replace_as_cmd); | |
11809 | install_element(BGP_VPNV6_NODE, | |
11810 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
11811 | ||
11812 | /* "neighbor send-community" commands.*/ | |
11813 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
11814 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
11815 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
11816 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
11817 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
11818 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
11819 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
11820 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
11821 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
11822 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
11823 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
11824 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
11825 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
11826 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
11827 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
11828 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
11829 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
11830 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
11831 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
11832 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
11833 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
11834 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
11835 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
11836 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
11837 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
11838 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
11839 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
11840 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
11841 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
11842 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
11843 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
11844 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
11845 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
11846 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
11847 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
11848 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
11849 | ||
11850 | /* "neighbor route-reflector" commands.*/ | |
11851 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
11852 | install_element(BGP_NODE, | |
11853 | &no_neighbor_route_reflector_client_hidden_cmd); | |
11854 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
11855 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
11856 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
11857 | install_element(BGP_IPV4M_NODE, | |
11858 | &no_neighbor_route_reflector_client_cmd); | |
11859 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
11860 | install_element(BGP_IPV4L_NODE, | |
11861 | &no_neighbor_route_reflector_client_cmd); | |
11862 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
11863 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
11864 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
11865 | install_element(BGP_IPV6M_NODE, | |
11866 | &no_neighbor_route_reflector_client_cmd); | |
11867 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
11868 | install_element(BGP_IPV6L_NODE, | |
11869 | &no_neighbor_route_reflector_client_cmd); | |
11870 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
11871 | install_element(BGP_VPNV4_NODE, | |
11872 | &no_neighbor_route_reflector_client_cmd); | |
11873 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
11874 | install_element(BGP_VPNV6_NODE, | |
11875 | &no_neighbor_route_reflector_client_cmd); | |
11876 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); | |
11877 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
11878 | ||
11879 | /* "neighbor route-server" commands.*/ | |
11880 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
11881 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
11882 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
11883 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
11884 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
11885 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
11886 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
11887 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
11888 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
11889 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
11890 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
11891 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
11892 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
11893 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
11894 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
11895 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
11896 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
11897 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
11898 | ||
11899 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
11900 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
11901 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
11902 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11903 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11904 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11905 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11906 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11907 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11908 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11909 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11910 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11911 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11912 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11913 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11914 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11915 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11916 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
11917 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
11918 | ||
11919 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
11920 | install_element(BGP_NODE, | |
11921 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
11922 | install_element(BGP_NODE, | |
11923 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
11924 | install_element(BGP_IPV4_NODE, | |
11925 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11926 | install_element(BGP_IPV4_NODE, | |
11927 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11928 | install_element(BGP_IPV4M_NODE, | |
11929 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11930 | install_element(BGP_IPV4M_NODE, | |
11931 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11932 | install_element(BGP_IPV4L_NODE, | |
11933 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11934 | install_element(BGP_IPV4L_NODE, | |
11935 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11936 | install_element(BGP_IPV6_NODE, | |
11937 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11938 | install_element(BGP_IPV6_NODE, | |
11939 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11940 | install_element(BGP_IPV6M_NODE, | |
11941 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11942 | install_element(BGP_IPV6M_NODE, | |
11943 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11944 | install_element(BGP_IPV6L_NODE, | |
11945 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11946 | install_element(BGP_IPV6L_NODE, | |
11947 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11948 | install_element(BGP_VPNV4_NODE, | |
11949 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11950 | install_element(BGP_VPNV4_NODE, | |
11951 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11952 | install_element(BGP_VPNV6_NODE, | |
11953 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
11954 | install_element(BGP_VPNV6_NODE, | |
11955 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
11956 | ||
11957 | /* "neighbor passive" commands. */ | |
11958 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
11959 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
11960 | ||
11961 | ||
11962 | /* "neighbor shutdown" commands. */ | |
11963 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
11964 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
11965 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
11966 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
11967 | ||
11968 | /* "neighbor capability extended-nexthop" commands.*/ | |
11969 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
11970 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
11971 | ||
11972 | /* "neighbor capability orf prefix-list" commands.*/ | |
11973 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
11974 | install_element(BGP_NODE, | |
11975 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
11976 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
11977 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11978 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
11979 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11980 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
11981 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11982 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
11983 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11984 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
11985 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11986 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
11987 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
11988 | ||
11989 | /* "neighbor capability dynamic" commands.*/ | |
11990 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
11991 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
11992 | ||
11993 | /* "neighbor dont-capability-negotiate" commands. */ | |
11994 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
11995 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
11996 | ||
11997 | /* "neighbor ebgp-multihop" commands. */ | |
11998 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
11999 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
12000 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
12001 | ||
12002 | /* "neighbor disable-connected-check" commands. */ | |
12003 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
12004 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
12005 | ||
12006 | /* "neighbor description" commands. */ | |
12007 | install_element(BGP_NODE, &neighbor_description_cmd); | |
12008 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
12009 | ||
12010 | /* "neighbor update-source" commands. "*/ | |
12011 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
12012 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
12013 | ||
12014 | /* "neighbor default-originate" commands. */ | |
12015 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
12016 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
12017 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
12018 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
12019 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
12020 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
12021 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
12022 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
12023 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
12024 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
12025 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
12026 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
12027 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
12028 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
12029 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
12030 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
12031 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
12032 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
12033 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
12034 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
12035 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
12036 | ||
12037 | /* "neighbor port" commands. */ | |
12038 | install_element(BGP_NODE, &neighbor_port_cmd); | |
12039 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
12040 | ||
12041 | /* "neighbor weight" commands. */ | |
12042 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
12043 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
12044 | ||
12045 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
12046 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
12047 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
12048 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
12049 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
12050 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
12051 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
12052 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
12053 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
12054 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
12055 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
12056 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
12057 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
12058 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
12059 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
12060 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
12061 | ||
12062 | /* "neighbor override-capability" commands. */ | |
12063 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
12064 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
12065 | ||
12066 | /* "neighbor strict-capability-match" commands. */ | |
12067 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
12068 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
12069 | ||
12070 | /* "neighbor timers" commands. */ | |
12071 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
12072 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
12073 | ||
12074 | /* "neighbor timers connect" commands. */ | |
12075 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
12076 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
12077 | ||
12078 | /* "neighbor advertisement-interval" commands. */ | |
12079 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
12080 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
12081 | ||
12082 | /* "neighbor interface" commands. */ | |
12083 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
12084 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
12085 | ||
12086 | /* "neighbor distribute" commands. */ | |
12087 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
12088 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
12089 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
12090 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
12091 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
12092 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
12093 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
12094 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
12095 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
12096 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
12097 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
12098 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
12099 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
12100 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
12101 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
12102 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
12103 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
12104 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
12105 | ||
12106 | /* "neighbor prefix-list" commands. */ | |
12107 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
12108 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
12109 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
12110 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
12111 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
12112 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
12113 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
12114 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
12115 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
12116 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
12117 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
12118 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
12119 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
12120 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
12121 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
12122 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
12123 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
12124 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
12125 | ||
12126 | /* "neighbor filter-list" commands. */ | |
12127 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
12128 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
12129 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
12130 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
12131 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
12132 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
12133 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
12134 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
12135 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
12136 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
12137 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
12138 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
12139 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
12140 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
12141 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
12142 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
12143 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
12144 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
12145 | ||
12146 | /* "neighbor route-map" commands. */ | |
12147 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
12148 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
12149 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
12150 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
12151 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
12152 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
12153 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
12154 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
12155 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
12156 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
12157 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
12158 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
12159 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
12160 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
12161 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
12162 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
12163 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
12164 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
12165 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
12166 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 12167 | |
12168 | /* "neighbor unsuppress-map" commands. */ | |
12169 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
12170 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
12171 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
12172 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
12173 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
12174 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
12175 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
12176 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
12177 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
12178 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
12179 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
12180 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
12181 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
12182 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
12183 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
12184 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
12185 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
12186 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
12187 | ||
12188 | /* "neighbor maximum-prefix" commands. */ | |
12189 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
12190 | install_element(BGP_NODE, | |
12191 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
12192 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
12193 | install_element(BGP_NODE, | |
12194 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
12195 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
12196 | install_element(BGP_NODE, | |
12197 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
12198 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
12199 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
12200 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12201 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12202 | install_element(BGP_IPV4_NODE, | |
12203 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12204 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12205 | install_element(BGP_IPV4_NODE, | |
12206 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12207 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
12208 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
12209 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12210 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12211 | install_element(BGP_IPV4M_NODE, | |
12212 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12213 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12214 | install_element(BGP_IPV4M_NODE, | |
12215 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12216 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
12217 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
12218 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12219 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12220 | install_element(BGP_IPV4L_NODE, | |
12221 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12222 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12223 | install_element(BGP_IPV4L_NODE, | |
12224 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12225 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
12226 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
12227 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12228 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12229 | install_element(BGP_IPV6_NODE, | |
12230 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12231 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12232 | install_element(BGP_IPV6_NODE, | |
12233 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12234 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
12235 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
12236 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12237 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12238 | install_element(BGP_IPV6M_NODE, | |
12239 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12240 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12241 | install_element(BGP_IPV6M_NODE, | |
12242 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12243 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
12244 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
12245 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12246 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12247 | install_element(BGP_IPV6L_NODE, | |
12248 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12249 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12250 | install_element(BGP_IPV6L_NODE, | |
12251 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12252 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
12253 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
12254 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12255 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12256 | install_element(BGP_VPNV4_NODE, | |
12257 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12258 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12259 | install_element(BGP_VPNV4_NODE, | |
12260 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12261 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
12262 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
12263 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
12264 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
12265 | install_element(BGP_VPNV6_NODE, | |
12266 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
12267 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
12268 | install_element(BGP_VPNV6_NODE, | |
12269 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
12270 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
12271 | ||
12272 | /* "neighbor allowas-in" */ | |
12273 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
12274 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
12275 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
12276 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
12277 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
12278 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
12279 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
12280 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
12281 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
12282 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
12283 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
12284 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
12285 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
12286 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
12287 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
12288 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
12289 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
12290 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
12291 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
12292 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
12293 | ||
12294 | /* address-family commands. */ | |
12295 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
12296 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 12297 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 12298 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
12299 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 12300 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 12301 | |
d62a17ae | 12302 | install_element(BGP_NODE, &address_family_evpn_cmd); |
12303 | ||
12304 | /* "exit-address-family" command. */ | |
12305 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
12306 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
12307 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
12308 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
12309 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
12310 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
12311 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
12312 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
12313 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); | |
12314 | ||
12315 | /* "clear ip bgp commands" */ | |
12316 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
12317 | ||
12318 | /* clear ip bgp prefix */ | |
12319 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
12320 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
12321 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
12322 | ||
12323 | /* "show [ip] bgp summary" commands. */ | |
12324 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
12325 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd); | |
12326 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); | |
12327 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); | |
12328 | install_element(VIEW_NODE, &show_bgp_updgrps_adj_cmd); | |
12329 | install_element(VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); | |
12330 | install_element(VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); | |
12331 | install_element(VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); | |
12332 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); | |
12333 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); | |
12334 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); | |
12335 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
12336 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); | |
12337 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); | |
12338 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); | |
12339 | ||
12340 | /* "show [ip] bgp neighbors" commands. */ | |
12341 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
12342 | ||
12343 | /* "show [ip] bgp peer-group" commands. */ | |
12344 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
12345 | ||
12346 | /* "show [ip] bgp paths" commands. */ | |
12347 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
12348 | ||
12349 | /* "show [ip] bgp community" commands. */ | |
12350 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
12351 | ||
12352 | /* "show ip bgp large-community" commands. */ | |
12353 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
12354 | /* "show [ip] bgp attribute-info" commands. */ | |
12355 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
12356 | ||
12357 | /* "redistribute" commands. */ | |
12358 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
12359 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
12360 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
12361 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
12362 | install_element(BGP_NODE, | |
12363 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
12364 | install_element(BGP_NODE, | |
12365 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
12366 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
12367 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
12368 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
12369 | install_element(BGP_NODE, | |
12370 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
12371 | install_element(BGP_NODE, | |
12372 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
12373 | install_element(BGP_NODE, | |
12374 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
12375 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
12376 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
12377 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
12378 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
12379 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
12380 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
12381 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
12382 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
12383 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
12384 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
12385 | install_element(BGP_IPV4_NODE, | |
12386 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
12387 | install_element(BGP_IPV4_NODE, | |
12388 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
12389 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
12390 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
12391 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
12392 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
12393 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
12394 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
12395 | ||
12396 | /* ttl_security commands */ | |
12397 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
12398 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
12399 | ||
12400 | /* "show [ip] bgp memory" commands. */ | |
12401 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
12402 | ||
acf71666 MK |
12403 | /* "show bgp martian next-hop" */ |
12404 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
12405 | ||
d62a17ae | 12406 | /* "show [ip] bgp views" commands. */ |
12407 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
12408 | ||
12409 | /* "show [ip] bgp vrfs" commands. */ | |
12410 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
12411 | ||
12412 | /* Community-list. */ | |
12413 | community_list_vty(); | |
718e3744 | 12414 | } |
6b0655a2 | 12415 | |
718e3744 | 12416 | #include "memory.h" |
12417 | #include "bgp_regex.h" | |
12418 | #include "bgp_clist.h" | |
12419 | #include "bgp_ecommunity.h" | |
12420 | ||
12421 | /* VTY functions. */ | |
12422 | ||
12423 | /* Direction value to string conversion. */ | |
d62a17ae | 12424 | static const char *community_direct_str(int direct) |
12425 | { | |
12426 | switch (direct) { | |
12427 | case COMMUNITY_DENY: | |
12428 | return "deny"; | |
12429 | case COMMUNITY_PERMIT: | |
12430 | return "permit"; | |
12431 | default: | |
12432 | return "unknown"; | |
12433 | } | |
718e3744 | 12434 | } |
12435 | ||
12436 | /* Display error string. */ | |
d62a17ae | 12437 | static void community_list_perror(struct vty *vty, int ret) |
12438 | { | |
12439 | switch (ret) { | |
12440 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
12441 | vty_out(vty, "%% Can't find community-list\n"); | |
12442 | break; | |
12443 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
12444 | vty_out(vty, "%% Malformed community-list value\n"); | |
12445 | break; | |
12446 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
12447 | vty_out(vty, | |
12448 | "%% Community name conflict, previously defined as standard community\n"); | |
12449 | break; | |
12450 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
12451 | vty_out(vty, | |
12452 | "%% Community name conflict, previously defined as expanded community\n"); | |
12453 | break; | |
12454 | } | |
718e3744 | 12455 | } |
12456 | ||
5bf15956 DW |
12457 | /* "community-list" keyword help string. */ |
12458 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
12459 | ||
5bf15956 | 12460 | /* ip community-list standard */ |
718e3744 | 12461 | DEFUN (ip_community_list_standard, |
12462 | ip_community_list_standard_cmd, | |
e961923c | 12463 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 12464 | IP_STR |
12465 | COMMUNITY_LIST_STR | |
12466 | "Community list number (standard)\n" | |
5bf15956 | 12467 | "Add an standard community-list entry\n" |
718e3744 | 12468 | "Community list name\n" |
12469 | "Specify community to reject\n" | |
12470 | "Specify community to accept\n" | |
12471 | COMMUNITY_VAL_STR) | |
12472 | { | |
d62a17ae | 12473 | char *cl_name_or_number = NULL; |
12474 | int direct = 0; | |
12475 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 12476 | |
d62a17ae | 12477 | int idx = 0; |
12478 | argv_find(argv, argc, "(1-99)", &idx); | |
12479 | argv_find(argv, argc, "WORD", &idx); | |
12480 | cl_name_or_number = argv[idx]->arg; | |
12481 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12482 | : COMMUNITY_DENY; | |
12483 | argv_find(argv, argc, "AA:NN", &idx); | |
12484 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12485 | |
d62a17ae | 12486 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
12487 | style); | |
42f914d4 | 12488 | |
d62a17ae | 12489 | XFREE(MTYPE_TMP, str); |
42f914d4 | 12490 | |
d62a17ae | 12491 | if (ret < 0) { |
12492 | /* Display error string. */ | |
12493 | community_list_perror(vty, ret); | |
12494 | return CMD_WARNING_CONFIG_FAILED; | |
12495 | } | |
42f914d4 | 12496 | |
d62a17ae | 12497 | return CMD_SUCCESS; |
718e3744 | 12498 | } |
12499 | ||
fee6e4e4 | 12500 | DEFUN (no_ip_community_list_standard_all, |
12501 | no_ip_community_list_standard_all_cmd, | |
e961923c | 12502 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 12503 | NO_STR |
12504 | IP_STR | |
12505 | COMMUNITY_LIST_STR | |
12506 | "Community list number (standard)\n" | |
5bf15956 DW |
12507 | "Add an standard community-list entry\n" |
12508 | "Community list name\n" | |
718e3744 | 12509 | "Specify community to reject\n" |
12510 | "Specify community to accept\n" | |
12511 | COMMUNITY_VAL_STR) | |
12512 | { | |
d62a17ae | 12513 | int delete_all = 0; |
42f914d4 | 12514 | |
d62a17ae | 12515 | char *cl_name_or_number = NULL; |
12516 | int direct = 0; | |
12517 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 12518 | |
d62a17ae | 12519 | int idx = 0; |
12520 | argv_find(argv, argc, "(1-99)", &idx); | |
12521 | argv_find(argv, argc, "WORD", &idx); | |
12522 | cl_name_or_number = argv[idx]->arg; | |
12523 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12524 | : COMMUNITY_DENY; | |
12525 | argv_find(argv, argc, "AA:NN", &idx); | |
12526 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12527 | |
d62a17ae | 12528 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
12529 | direct, style, delete_all); | |
42f914d4 | 12530 | |
d62a17ae | 12531 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 12532 | |
d62a17ae | 12533 | if (ret < 0) { |
12534 | community_list_perror(vty, ret); | |
12535 | return CMD_WARNING_CONFIG_FAILED; | |
12536 | } | |
42f914d4 | 12537 | |
d62a17ae | 12538 | return CMD_SUCCESS; |
718e3744 | 12539 | } |
12540 | ||
5bf15956 DW |
12541 | /* ip community-list expanded */ |
12542 | DEFUN (ip_community_list_expanded_all, | |
12543 | ip_community_list_expanded_all_cmd, | |
42f914d4 | 12544 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 12545 | IP_STR |
12546 | COMMUNITY_LIST_STR | |
12547 | "Community list number (expanded)\n" | |
5bf15956 | 12548 | "Add an expanded community-list entry\n" |
718e3744 | 12549 | "Community list name\n" |
12550 | "Specify community to reject\n" | |
12551 | "Specify community to accept\n" | |
12552 | COMMUNITY_VAL_STR) | |
12553 | { | |
d62a17ae | 12554 | char *cl_name_or_number = NULL; |
12555 | int direct = 0; | |
12556 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 12557 | |
d62a17ae | 12558 | int idx = 0; |
12559 | argv_find(argv, argc, "(100-500)", &idx); | |
12560 | argv_find(argv, argc, "WORD", &idx); | |
12561 | cl_name_or_number = argv[idx]->arg; | |
12562 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12563 | : COMMUNITY_DENY; | |
12564 | argv_find(argv, argc, "AA:NN", &idx); | |
12565 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12566 | |
d62a17ae | 12567 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
12568 | style); | |
42f914d4 | 12569 | |
d62a17ae | 12570 | XFREE(MTYPE_TMP, str); |
42f914d4 | 12571 | |
d62a17ae | 12572 | if (ret < 0) { |
12573 | /* Display error string. */ | |
12574 | community_list_perror(vty, ret); | |
12575 | return CMD_WARNING_CONFIG_FAILED; | |
12576 | } | |
42f914d4 | 12577 | |
d62a17ae | 12578 | return CMD_SUCCESS; |
718e3744 | 12579 | } |
12580 | ||
5bf15956 DW |
12581 | DEFUN (no_ip_community_list_expanded_all, |
12582 | no_ip_community_list_expanded_all_cmd, | |
42f914d4 | 12583 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 12584 | NO_STR |
12585 | IP_STR | |
12586 | COMMUNITY_LIST_STR | |
5bf15956 DW |
12587 | "Community list number (expanded)\n" |
12588 | "Add an expanded community-list entry\n" | |
718e3744 | 12589 | "Community list name\n" |
12590 | "Specify community to reject\n" | |
12591 | "Specify community to accept\n" | |
5bf15956 | 12592 | COMMUNITY_VAL_STR) |
718e3744 | 12593 | { |
d62a17ae | 12594 | int delete_all = 0; |
42f914d4 | 12595 | |
d62a17ae | 12596 | char *cl_name_or_number = NULL; |
12597 | int direct = 0; | |
12598 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 12599 | |
d62a17ae | 12600 | int idx = 0; |
12601 | argv_find(argv, argc, "(100-500)", &idx); | |
12602 | argv_find(argv, argc, "WORD", &idx); | |
12603 | cl_name_or_number = argv[idx]->arg; | |
12604 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12605 | : COMMUNITY_DENY; | |
12606 | argv_find(argv, argc, "AA:NN", &idx); | |
12607 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 12608 | |
d62a17ae | 12609 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
12610 | direct, style, delete_all); | |
42f914d4 | 12611 | |
d62a17ae | 12612 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 12613 | |
d62a17ae | 12614 | if (ret < 0) { |
12615 | community_list_perror(vty, ret); | |
12616 | return CMD_WARNING_CONFIG_FAILED; | |
12617 | } | |
42f914d4 | 12618 | |
d62a17ae | 12619 | return CMD_SUCCESS; |
718e3744 | 12620 | } |
12621 | ||
d62a17ae | 12622 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 12623 | { |
d62a17ae | 12624 | struct community_entry *entry; |
718e3744 | 12625 | |
d62a17ae | 12626 | for (entry = list->head; entry; entry = entry->next) { |
12627 | if (entry == list->head) { | |
12628 | if (all_digit(list->name)) | |
12629 | vty_out(vty, "Community %s list %s\n", | |
12630 | entry->style == COMMUNITY_LIST_STANDARD | |
12631 | ? "standard" | |
12632 | : "(expanded) access", | |
12633 | list->name); | |
12634 | else | |
12635 | vty_out(vty, "Named Community %s list %s\n", | |
12636 | entry->style == COMMUNITY_LIST_STANDARD | |
12637 | ? "standard" | |
12638 | : "expanded", | |
12639 | list->name); | |
12640 | } | |
12641 | if (entry->any) | |
12642 | vty_out(vty, " %s\n", | |
12643 | community_direct_str(entry->direct)); | |
12644 | else | |
12645 | vty_out(vty, " %s %s\n", | |
12646 | community_direct_str(entry->direct), | |
12647 | entry->style == COMMUNITY_LIST_STANDARD | |
12648 | ? community_str(entry->u.com) | |
12649 | : entry->config); | |
12650 | } | |
718e3744 | 12651 | } |
12652 | ||
12653 | DEFUN (show_ip_community_list, | |
12654 | show_ip_community_list_cmd, | |
12655 | "show ip community-list", | |
12656 | SHOW_STR | |
12657 | IP_STR | |
12658 | "List community-list\n") | |
12659 | { | |
d62a17ae | 12660 | struct community_list *list; |
12661 | struct community_list_master *cm; | |
718e3744 | 12662 | |
d62a17ae | 12663 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
12664 | if (!cm) | |
12665 | return CMD_SUCCESS; | |
718e3744 | 12666 | |
d62a17ae | 12667 | for (list = cm->num.head; list; list = list->next) |
12668 | community_list_show(vty, list); | |
718e3744 | 12669 | |
d62a17ae | 12670 | for (list = cm->str.head; list; list = list->next) |
12671 | community_list_show(vty, list); | |
718e3744 | 12672 | |
d62a17ae | 12673 | return CMD_SUCCESS; |
718e3744 | 12674 | } |
12675 | ||
12676 | DEFUN (show_ip_community_list_arg, | |
12677 | show_ip_community_list_arg_cmd, | |
6147e2c6 | 12678 | "show ip community-list <(1-500)|WORD>", |
718e3744 | 12679 | SHOW_STR |
12680 | IP_STR | |
12681 | "List community-list\n" | |
12682 | "Community-list number\n" | |
12683 | "Community-list name\n") | |
12684 | { | |
d62a17ae | 12685 | int idx_comm_list = 3; |
12686 | struct community_list *list; | |
718e3744 | 12687 | |
d62a17ae | 12688 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
12689 | COMMUNITY_LIST_MASTER); | |
12690 | if (!list) { | |
12691 | vty_out(vty, "%% Can't find community-list\n"); | |
12692 | return CMD_WARNING; | |
12693 | } | |
718e3744 | 12694 | |
d62a17ae | 12695 | community_list_show(vty, list); |
718e3744 | 12696 | |
d62a17ae | 12697 | return CMD_SUCCESS; |
718e3744 | 12698 | } |
6b0655a2 | 12699 | |
57d187bc JS |
12700 | /* |
12701 | * Large Community code. | |
12702 | */ | |
d62a17ae | 12703 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
12704 | struct cmd_token **argv, int style, | |
12705 | int reject_all_digit_name) | |
12706 | { | |
12707 | int ret; | |
12708 | int direct; | |
12709 | char *str; | |
12710 | int idx = 0; | |
12711 | char *cl_name; | |
12712 | ||
12713 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
12714 | : COMMUNITY_DENY; | |
12715 | ||
12716 | /* All digit name check. */ | |
12717 | idx = 0; | |
12718 | argv_find(argv, argc, "WORD", &idx); | |
12719 | argv_find(argv, argc, "(1-99)", &idx); | |
12720 | argv_find(argv, argc, "(100-500)", &idx); | |
12721 | cl_name = argv[idx]->arg; | |
12722 | if (reject_all_digit_name && all_digit(cl_name)) { | |
12723 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
12724 | return CMD_WARNING_CONFIG_FAILED; | |
12725 | } | |
12726 | ||
12727 | idx = 0; | |
12728 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
12729 | argv_find(argv, argc, "LINE", &idx); | |
12730 | /* Concat community string argument. */ | |
12731 | if (idx) | |
12732 | str = argv_concat(argv, argc, idx); | |
12733 | else | |
12734 | str = NULL; | |
12735 | ||
12736 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
12737 | ||
12738 | /* Free temporary community list string allocated by | |
12739 | argv_concat(). */ | |
12740 | if (str) | |
12741 | XFREE(MTYPE_TMP, str); | |
12742 | ||
12743 | if (ret < 0) { | |
12744 | community_list_perror(vty, ret); | |
12745 | return CMD_WARNING_CONFIG_FAILED; | |
12746 | } | |
12747 | return CMD_SUCCESS; | |
12748 | } | |
12749 | ||
12750 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
12751 | struct cmd_token **argv, int style) | |
12752 | { | |
12753 | int ret; | |
12754 | int direct = 0; | |
12755 | char *str = NULL; | |
12756 | int idx = 0; | |
12757 | ||
12758 | argv_find(argv, argc, "permit", &idx); | |
12759 | argv_find(argv, argc, "deny", &idx); | |
12760 | ||
12761 | if (idx) { | |
12762 | /* Check the list direct. */ | |
12763 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
12764 | direct = COMMUNITY_PERMIT; | |
12765 | else | |
12766 | direct = COMMUNITY_DENY; | |
12767 | ||
12768 | idx = 0; | |
12769 | argv_find(argv, argc, "LINE", &idx); | |
12770 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
12771 | /* Concat community string argument. */ | |
12772 | str = argv_concat(argv, argc, idx); | |
12773 | } | |
12774 | ||
12775 | idx = 0; | |
12776 | argv_find(argv, argc, "(1-99)", &idx); | |
12777 | argv_find(argv, argc, "(100-500)", &idx); | |
12778 | argv_find(argv, argc, "WORD", &idx); | |
12779 | ||
12780 | /* Unset community list. */ | |
12781 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
12782 | style); | |
12783 | ||
12784 | /* Free temporary community list string allocated by | |
12785 | argv_concat(). */ | |
12786 | if (str) | |
12787 | XFREE(MTYPE_TMP, str); | |
12788 | ||
12789 | if (ret < 0) { | |
12790 | community_list_perror(vty, ret); | |
12791 | return CMD_WARNING_CONFIG_FAILED; | |
12792 | } | |
12793 | ||
12794 | return CMD_SUCCESS; | |
57d187bc JS |
12795 | } |
12796 | ||
12797 | /* "large-community-list" keyword help string. */ | |
12798 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
12799 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
12800 | ||
12801 | DEFUN (ip_lcommunity_list_standard, | |
12802 | ip_lcommunity_list_standard_cmd, | |
52951b63 DS |
12803 | "ip large-community-list (1-99) <deny|permit>", |
12804 | IP_STR | |
12805 | LCOMMUNITY_LIST_STR | |
12806 | "Large Community list number (standard)\n" | |
12807 | "Specify large community to reject\n" | |
7111c1a0 | 12808 | "Specify large community to accept\n") |
52951b63 | 12809 | { |
d62a17ae | 12810 | return lcommunity_list_set_vty(vty, argc, argv, |
12811 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
12812 | } |
12813 | ||
12814 | DEFUN (ip_lcommunity_list_standard1, | |
12815 | ip_lcommunity_list_standard1_cmd, | |
12816 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
12817 | IP_STR |
12818 | LCOMMUNITY_LIST_STR | |
12819 | "Large Community list number (standard)\n" | |
12820 | "Specify large community to reject\n" | |
12821 | "Specify large community to accept\n" | |
12822 | LCOMMUNITY_VAL_STR) | |
12823 | { | |
d62a17ae | 12824 | return lcommunity_list_set_vty(vty, argc, argv, |
12825 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
57d187bc JS |
12826 | } |
12827 | ||
12828 | DEFUN (ip_lcommunity_list_expanded, | |
12829 | ip_lcommunity_list_expanded_cmd, | |
12830 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
12831 | IP_STR | |
12832 | LCOMMUNITY_LIST_STR | |
12833 | "Large Community list number (expanded)\n" | |
12834 | "Specify large community to reject\n" | |
12835 | "Specify large community to accept\n" | |
12836 | "An ordered list as a regular-expression\n") | |
12837 | { | |
d62a17ae | 12838 | return lcommunity_list_set_vty(vty, argc, argv, |
12839 | LARGE_COMMUNITY_LIST_EXPANDED, 0); | |
57d187bc JS |
12840 | } |
12841 | ||
12842 | DEFUN (ip_lcommunity_list_name_standard, | |
12843 | ip_lcommunity_list_name_standard_cmd, | |
52951b63 DS |
12844 | "ip large-community-list standard WORD <deny|permit>", |
12845 | IP_STR | |
12846 | LCOMMUNITY_LIST_STR | |
12847 | "Specify standard large-community-list\n" | |
12848 | "Large Community list name\n" | |
12849 | "Specify large community to reject\n" | |
12850 | "Specify large community to accept\n") | |
12851 | { | |
d62a17ae | 12852 | return lcommunity_list_set_vty(vty, argc, argv, |
12853 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
12854 | } |
12855 | ||
12856 | DEFUN (ip_lcommunity_list_name_standard1, | |
12857 | ip_lcommunity_list_name_standard1_cmd, | |
12858 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
12859 | IP_STR |
12860 | LCOMMUNITY_LIST_STR | |
12861 | "Specify standard large-community-list\n" | |
12862 | "Large Community list name\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, 1); | |
57d187bc JS |
12869 | } |
12870 | ||
12871 | DEFUN (ip_lcommunity_list_name_expanded, | |
12872 | ip_lcommunity_list_name_expanded_cmd, | |
12873 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
12874 | IP_STR | |
12875 | LCOMMUNITY_LIST_STR | |
12876 | "Specify expanded large-community-list\n" | |
12877 | "Large Community list name\n" | |
12878 | "Specify large community to reject\n" | |
12879 | "Specify large community to accept\n" | |
12880 | "An ordered list as a regular-expression\n") | |
12881 | { | |
d62a17ae | 12882 | return lcommunity_list_set_vty(vty, argc, argv, |
12883 | LARGE_COMMUNITY_LIST_EXPANDED, 1); | |
57d187bc JS |
12884 | } |
12885 | ||
12886 | DEFUN (no_ip_lcommunity_list_standard_all, | |
12887 | no_ip_lcommunity_list_standard_all_cmd, | |
12888 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
12889 | NO_STR | |
12890 | IP_STR | |
12891 | LCOMMUNITY_LIST_STR | |
12892 | "Large Community list number (standard)\n" | |
12893 | "Large Community list number (expanded)\n" | |
12894 | "Large Community list name\n") | |
12895 | { | |
d62a17ae | 12896 | return lcommunity_list_unset_vty(vty, argc, argv, |
12897 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
12898 | } |
12899 | ||
12900 | DEFUN (no_ip_lcommunity_list_name_expanded_all, | |
12901 | no_ip_lcommunity_list_name_expanded_all_cmd, | |
12902 | "no ip large-community-list expanded WORD", | |
12903 | NO_STR | |
12904 | IP_STR | |
12905 | LCOMMUNITY_LIST_STR | |
12906 | "Specify expanded large-community-list\n" | |
12907 | "Large Community list name\n") | |
12908 | { | |
d62a17ae | 12909 | return lcommunity_list_unset_vty(vty, argc, argv, |
12910 | LARGE_COMMUNITY_LIST_EXPANDED); | |
57d187bc JS |
12911 | } |
12912 | ||
12913 | DEFUN (no_ip_lcommunity_list_standard, | |
12914 | no_ip_lcommunity_list_standard_cmd, | |
12915 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
12916 | NO_STR | |
12917 | IP_STR | |
12918 | LCOMMUNITY_LIST_STR | |
12919 | "Large Community list number (standard)\n" | |
12920 | "Specify large community to reject\n" | |
12921 | "Specify large community to accept\n" | |
12922 | LCOMMUNITY_VAL_STR) | |
12923 | { | |
d62a17ae | 12924 | return lcommunity_list_unset_vty(vty, argc, argv, |
12925 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
12926 | } |
12927 | ||
12928 | DEFUN (no_ip_lcommunity_list_expanded, | |
12929 | no_ip_lcommunity_list_expanded_cmd, | |
12930 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
12931 | NO_STR | |
12932 | IP_STR | |
12933 | LCOMMUNITY_LIST_STR | |
12934 | "Large Community list number (expanded)\n" | |
12935 | "Specify large community to reject\n" | |
12936 | "Specify large community to accept\n" | |
12937 | "An ordered list as a regular-expression\n") | |
12938 | { | |
d62a17ae | 12939 | return lcommunity_list_unset_vty(vty, argc, argv, |
12940 | LARGE_COMMUNITY_LIST_EXPANDED); | |
57d187bc JS |
12941 | } |
12942 | ||
12943 | DEFUN (no_ip_lcommunity_list_name_standard, | |
12944 | no_ip_lcommunity_list_name_standard_cmd, | |
12945 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
12946 | NO_STR | |
12947 | IP_STR | |
12948 | LCOMMUNITY_LIST_STR | |
12949 | "Specify standard large-community-list\n" | |
12950 | "Large Community list name\n" | |
12951 | "Specify large community to reject\n" | |
12952 | "Specify large community to accept\n" | |
12953 | LCOMMUNITY_VAL_STR) | |
12954 | { | |
d62a17ae | 12955 | return lcommunity_list_unset_vty(vty, argc, argv, |
12956 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
12957 | } |
12958 | ||
12959 | DEFUN (no_ip_lcommunity_list_name_expanded, | |
12960 | no_ip_lcommunity_list_name_expanded_cmd, | |
12961 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
12962 | NO_STR | |
12963 | IP_STR | |
12964 | LCOMMUNITY_LIST_STR | |
12965 | "Specify expanded large-community-list\n" | |
12966 | "Large community list name\n" | |
12967 | "Specify large community to reject\n" | |
12968 | "Specify large community to accept\n" | |
12969 | "An ordered list as a regular-expression\n") | |
12970 | { | |
d62a17ae | 12971 | return lcommunity_list_unset_vty(vty, argc, argv, |
12972 | LARGE_COMMUNITY_LIST_EXPANDED); | |
12973 | } | |
12974 | ||
12975 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) | |
12976 | { | |
12977 | struct community_entry *entry; | |
12978 | ||
12979 | for (entry = list->head; entry; entry = entry->next) { | |
12980 | if (entry == list->head) { | |
12981 | if (all_digit(list->name)) | |
12982 | vty_out(vty, "Large community %s list %s\n", | |
12983 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
12984 | ? "standard" | |
12985 | : "(expanded) access", | |
12986 | list->name); | |
12987 | else | |
12988 | vty_out(vty, | |
12989 | "Named large community %s list %s\n", | |
12990 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
12991 | ? "standard" | |
12992 | : "expanded", | |
12993 | list->name); | |
12994 | } | |
12995 | if (entry->any) | |
12996 | vty_out(vty, " %s\n", | |
12997 | community_direct_str(entry->direct)); | |
12998 | else | |
12999 | vty_out(vty, " %s %s\n", | |
13000 | community_direct_str(entry->direct), | |
13001 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13002 | ? entry->u.ecom->str | |
13003 | : entry->config); | |
13004 | } | |
57d187bc JS |
13005 | } |
13006 | ||
13007 | DEFUN (show_ip_lcommunity_list, | |
13008 | show_ip_lcommunity_list_cmd, | |
13009 | "show ip large-community-list", | |
13010 | SHOW_STR | |
13011 | IP_STR | |
13012 | "List large-community list\n") | |
13013 | { | |
d62a17ae | 13014 | struct community_list *list; |
13015 | struct community_list_master *cm; | |
57d187bc | 13016 | |
d62a17ae | 13017 | cm = community_list_master_lookup(bgp_clist, |
13018 | LARGE_COMMUNITY_LIST_MASTER); | |
13019 | if (!cm) | |
13020 | return CMD_SUCCESS; | |
57d187bc | 13021 | |
d62a17ae | 13022 | for (list = cm->num.head; list; list = list->next) |
13023 | lcommunity_list_show(vty, list); | |
57d187bc | 13024 | |
d62a17ae | 13025 | for (list = cm->str.head; list; list = list->next) |
13026 | lcommunity_list_show(vty, list); | |
57d187bc | 13027 | |
d62a17ae | 13028 | return CMD_SUCCESS; |
57d187bc JS |
13029 | } |
13030 | ||
13031 | DEFUN (show_ip_lcommunity_list_arg, | |
13032 | show_ip_lcommunity_list_arg_cmd, | |
13033 | "show ip large-community-list <(1-500)|WORD>", | |
13034 | SHOW_STR | |
13035 | IP_STR | |
13036 | "List large-community list\n" | |
13037 | "large-community-list number\n" | |
13038 | "large-community-list name\n") | |
13039 | { | |
d62a17ae | 13040 | struct community_list *list; |
57d187bc | 13041 | |
d62a17ae | 13042 | list = community_list_lookup(bgp_clist, argv[3]->arg, |
13043 | LARGE_COMMUNITY_LIST_MASTER); | |
13044 | if (!list) { | |
13045 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
13046 | return CMD_WARNING; | |
13047 | } | |
57d187bc | 13048 | |
d62a17ae | 13049 | lcommunity_list_show(vty, list); |
57d187bc | 13050 | |
d62a17ae | 13051 | return CMD_SUCCESS; |
57d187bc JS |
13052 | } |
13053 | ||
718e3744 | 13054 | /* "extcommunity-list" keyword help string. */ |
13055 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
13056 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
13057 | ||
13058 | DEFUN (ip_extcommunity_list_standard, | |
13059 | ip_extcommunity_list_standard_cmd, | |
e961923c | 13060 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 13061 | IP_STR |
13062 | EXTCOMMUNITY_LIST_STR | |
13063 | "Extended Community list number (standard)\n" | |
718e3744 | 13064 | "Specify standard extcommunity-list\n" |
5bf15956 | 13065 | "Community list name\n" |
718e3744 | 13066 | "Specify community to reject\n" |
13067 | "Specify community to accept\n" | |
13068 | EXTCOMMUNITY_VAL_STR) | |
13069 | { | |
d62a17ae | 13070 | int style = EXTCOMMUNITY_LIST_STANDARD; |
13071 | int direct = 0; | |
13072 | char *cl_number_or_name = NULL; | |
42f914d4 | 13073 | |
d62a17ae | 13074 | int idx = 0; |
13075 | argv_find(argv, argc, "(1-99)", &idx); | |
13076 | argv_find(argv, argc, "WORD", &idx); | |
13077 | cl_number_or_name = argv[idx]->arg; | |
13078 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13079 | : COMMUNITY_DENY; | |
13080 | argv_find(argv, argc, "AA:NN", &idx); | |
13081 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13082 | |
d62a17ae | 13083 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
13084 | direct, style); | |
42f914d4 | 13085 | |
d62a17ae | 13086 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13087 | |
d62a17ae | 13088 | if (ret < 0) { |
13089 | community_list_perror(vty, ret); | |
13090 | return CMD_WARNING_CONFIG_FAILED; | |
13091 | } | |
42f914d4 | 13092 | |
d62a17ae | 13093 | return CMD_SUCCESS; |
718e3744 | 13094 | } |
13095 | ||
718e3744 | 13096 | DEFUN (ip_extcommunity_list_name_expanded, |
13097 | ip_extcommunity_list_name_expanded_cmd, | |
e961923c | 13098 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 13099 | IP_STR |
13100 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 13101 | "Extended Community list number (expanded)\n" |
718e3744 | 13102 | "Specify expanded extcommunity-list\n" |
13103 | "Extended Community list name\n" | |
13104 | "Specify community to reject\n" | |
13105 | "Specify community to accept\n" | |
13106 | "An ordered list as a regular-expression\n") | |
13107 | { | |
d62a17ae | 13108 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
13109 | int direct = 0; | |
13110 | char *cl_number_or_name = NULL; | |
42f914d4 | 13111 | |
d62a17ae | 13112 | int idx = 0; |
13113 | argv_find(argv, argc, "(100-500)", &idx); | |
13114 | argv_find(argv, argc, "WORD", &idx); | |
13115 | cl_number_or_name = argv[idx]->arg; | |
13116 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13117 | : COMMUNITY_DENY; | |
13118 | argv_find(argv, argc, "LINE", &idx); | |
13119 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13120 | |
d62a17ae | 13121 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
13122 | direct, style); | |
42f914d4 | 13123 | |
d62a17ae | 13124 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13125 | |
d62a17ae | 13126 | if (ret < 0) { |
13127 | community_list_perror(vty, ret); | |
13128 | return CMD_WARNING_CONFIG_FAILED; | |
13129 | } | |
42f914d4 | 13130 | |
d62a17ae | 13131 | return CMD_SUCCESS; |
718e3744 | 13132 | } |
13133 | ||
fee6e4e4 | 13134 | DEFUN (no_ip_extcommunity_list_standard_all, |
13135 | no_ip_extcommunity_list_standard_all_cmd, | |
e961923c | 13136 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
813d4307 DW |
13137 | NO_STR |
13138 | IP_STR | |
13139 | EXTCOMMUNITY_LIST_STR | |
13140 | "Extended Community list number (standard)\n" | |
718e3744 | 13141 | "Specify standard extcommunity-list\n" |
5bf15956 | 13142 | "Community list name\n" |
718e3744 | 13143 | "Specify community to reject\n" |
13144 | "Specify community to accept\n" | |
13145 | EXTCOMMUNITY_VAL_STR) | |
13146 | { | |
d62a17ae | 13147 | int deleteall = 0; |
42f914d4 | 13148 | |
d62a17ae | 13149 | int style = EXTCOMMUNITY_LIST_STANDARD; |
13150 | int direct = 0; | |
13151 | char *cl_number_or_name = NULL; | |
42f914d4 | 13152 | |
d62a17ae | 13153 | int idx = 0; |
13154 | argv_find(argv, argc, "(1-99)", &idx); | |
13155 | argv_find(argv, argc, "WORD", &idx); | |
13156 | cl_number_or_name = argv[idx]->arg; | |
13157 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13158 | : COMMUNITY_DENY; | |
13159 | argv_find(argv, argc, "AA:NN", &idx); | |
13160 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13161 | |
d62a17ae | 13162 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
13163 | direct, style, deleteall); | |
42f914d4 | 13164 | |
d62a17ae | 13165 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13166 | |
d62a17ae | 13167 | if (ret < 0) { |
13168 | community_list_perror(vty, ret); | |
13169 | return CMD_WARNING_CONFIG_FAILED; | |
13170 | } | |
42f914d4 | 13171 | |
d62a17ae | 13172 | return CMD_SUCCESS; |
718e3744 | 13173 | } |
13174 | ||
5bf15956 DW |
13175 | DEFUN (no_ip_extcommunity_list_expanded_all, |
13176 | no_ip_extcommunity_list_expanded_all_cmd, | |
e961923c | 13177 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 13178 | NO_STR |
13179 | IP_STR | |
13180 | EXTCOMMUNITY_LIST_STR | |
13181 | "Extended Community list number (expanded)\n" | |
718e3744 | 13182 | "Specify expanded extcommunity-list\n" |
5bf15956 | 13183 | "Extended Community list name\n" |
718e3744 | 13184 | "Specify community to reject\n" |
13185 | "Specify community to accept\n" | |
13186 | "An ordered list as a regular-expression\n") | |
13187 | { | |
d62a17ae | 13188 | int deleteall = 0; |
42f914d4 | 13189 | |
d62a17ae | 13190 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
13191 | int direct = 0; | |
13192 | char *cl_number_or_name = NULL; | |
42f914d4 | 13193 | |
d62a17ae | 13194 | int idx = 0; |
13195 | argv_find(argv, argc, "(100-500)", &idx); | |
13196 | argv_find(argv, argc, "WORD", &idx); | |
13197 | cl_number_or_name = argv[idx]->arg; | |
13198 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13199 | : COMMUNITY_DENY; | |
13200 | argv_find(argv, argc, "LINE", &idx); | |
13201 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13202 | |
d62a17ae | 13203 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
13204 | direct, style, deleteall); | |
42f914d4 | 13205 | |
d62a17ae | 13206 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13207 | |
d62a17ae | 13208 | if (ret < 0) { |
13209 | community_list_perror(vty, ret); | |
13210 | return CMD_WARNING_CONFIG_FAILED; | |
13211 | } | |
42f914d4 | 13212 | |
d62a17ae | 13213 | return CMD_SUCCESS; |
718e3744 | 13214 | } |
13215 | ||
d62a17ae | 13216 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 13217 | { |
d62a17ae | 13218 | struct community_entry *entry; |
718e3744 | 13219 | |
d62a17ae | 13220 | for (entry = list->head; entry; entry = entry->next) { |
13221 | if (entry == list->head) { | |
13222 | if (all_digit(list->name)) | |
13223 | vty_out(vty, "Extended community %s list %s\n", | |
13224 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13225 | ? "standard" | |
13226 | : "(expanded) access", | |
13227 | list->name); | |
13228 | else | |
13229 | vty_out(vty, | |
13230 | "Named extended community %s list %s\n", | |
13231 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13232 | ? "standard" | |
13233 | : "expanded", | |
13234 | list->name); | |
13235 | } | |
13236 | if (entry->any) | |
13237 | vty_out(vty, " %s\n", | |
13238 | community_direct_str(entry->direct)); | |
13239 | else | |
13240 | vty_out(vty, " %s %s\n", | |
13241 | community_direct_str(entry->direct), | |
13242 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13243 | ? entry->u.ecom->str | |
13244 | : entry->config); | |
13245 | } | |
718e3744 | 13246 | } |
13247 | ||
13248 | DEFUN (show_ip_extcommunity_list, | |
13249 | show_ip_extcommunity_list_cmd, | |
13250 | "show ip extcommunity-list", | |
13251 | SHOW_STR | |
13252 | IP_STR | |
13253 | "List extended-community list\n") | |
13254 | { | |
d62a17ae | 13255 | struct community_list *list; |
13256 | struct community_list_master *cm; | |
718e3744 | 13257 | |
d62a17ae | 13258 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
13259 | if (!cm) | |
13260 | return CMD_SUCCESS; | |
718e3744 | 13261 | |
d62a17ae | 13262 | for (list = cm->num.head; list; list = list->next) |
13263 | extcommunity_list_show(vty, list); | |
718e3744 | 13264 | |
d62a17ae | 13265 | for (list = cm->str.head; list; list = list->next) |
13266 | extcommunity_list_show(vty, list); | |
718e3744 | 13267 | |
d62a17ae | 13268 | return CMD_SUCCESS; |
718e3744 | 13269 | } |
13270 | ||
13271 | DEFUN (show_ip_extcommunity_list_arg, | |
13272 | show_ip_extcommunity_list_arg_cmd, | |
6147e2c6 | 13273 | "show ip extcommunity-list <(1-500)|WORD>", |
718e3744 | 13274 | SHOW_STR |
13275 | IP_STR | |
13276 | "List extended-community list\n" | |
13277 | "Extcommunity-list number\n" | |
13278 | "Extcommunity-list name\n") | |
13279 | { | |
d62a17ae | 13280 | int idx_comm_list = 3; |
13281 | struct community_list *list; | |
718e3744 | 13282 | |
d62a17ae | 13283 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
13284 | EXTCOMMUNITY_LIST_MASTER); | |
13285 | if (!list) { | |
13286 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
13287 | return CMD_WARNING; | |
13288 | } | |
718e3744 | 13289 | |
d62a17ae | 13290 | extcommunity_list_show(vty, list); |
718e3744 | 13291 | |
d62a17ae | 13292 | return CMD_SUCCESS; |
718e3744 | 13293 | } |
6b0655a2 | 13294 | |
718e3744 | 13295 | /* Return configuration string of community-list entry. */ |
d62a17ae | 13296 | static const char *community_list_config_str(struct community_entry *entry) |
718e3744 | 13297 | { |
d62a17ae | 13298 | const char *str; |
718e3744 | 13299 | |
d62a17ae | 13300 | if (entry->any) |
13301 | str = ""; | |
13302 | else { | |
13303 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
13304 | str = community_str(entry->u.com); | |
13305 | else | |
13306 | str = entry->config; | |
13307 | } | |
13308 | return str; | |
718e3744 | 13309 | } |
13310 | ||
13311 | /* Display community-list and extcommunity-list configuration. */ | |
d62a17ae | 13312 | static int community_list_config_write(struct vty *vty) |
13313 | { | |
13314 | struct community_list *list; | |
13315 | struct community_entry *entry; | |
13316 | struct community_list_master *cm; | |
13317 | int write = 0; | |
13318 | ||
13319 | /* Community-list. */ | |
13320 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
13321 | ||
13322 | for (list = cm->num.head; list; list = list->next) | |
13323 | for (entry = list->head; entry; entry = entry->next) { | |
13324 | vty_out(vty, "ip community-list %s %s %s\n", list->name, | |
13325 | community_direct_str(entry->direct), | |
13326 | community_list_config_str(entry)); | |
13327 | write++; | |
13328 | } | |
13329 | for (list = cm->str.head; list; list = list->next) | |
13330 | for (entry = list->head; entry; entry = entry->next) { | |
13331 | vty_out(vty, "ip community-list %s %s %s %s\n", | |
13332 | entry->style == COMMUNITY_LIST_STANDARD | |
13333 | ? "standard" | |
13334 | : "expanded", | |
13335 | list->name, community_direct_str(entry->direct), | |
13336 | community_list_config_str(entry)); | |
13337 | write++; | |
13338 | } | |
13339 | ||
13340 | /* Extcommunity-list. */ | |
13341 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
13342 | ||
13343 | for (list = cm->num.head; list; list = list->next) | |
13344 | for (entry = list->head; entry; entry = entry->next) { | |
13345 | vty_out(vty, "ip extcommunity-list %s %s %s\n", | |
13346 | list->name, community_direct_str(entry->direct), | |
13347 | community_list_config_str(entry)); | |
13348 | write++; | |
13349 | } | |
13350 | for (list = cm->str.head; list; list = list->next) | |
13351 | for (entry = list->head; entry; entry = entry->next) { | |
13352 | vty_out(vty, "ip extcommunity-list %s %s %s %s\n", | |
13353 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
13354 | ? "standard" | |
13355 | : "expanded", | |
13356 | list->name, community_direct_str(entry->direct), | |
13357 | community_list_config_str(entry)); | |
13358 | write++; | |
13359 | } | |
13360 | ||
13361 | ||
13362 | /* lcommunity-list. */ | |
13363 | cm = community_list_master_lookup(bgp_clist, | |
13364 | LARGE_COMMUNITY_LIST_MASTER); | |
13365 | ||
13366 | for (list = cm->num.head; list; list = list->next) | |
13367 | for (entry = list->head; entry; entry = entry->next) { | |
13368 | vty_out(vty, "ip large-community-list %s %s %s\n", | |
13369 | list->name, community_direct_str(entry->direct), | |
13370 | community_list_config_str(entry)); | |
13371 | write++; | |
13372 | } | |
13373 | for (list = cm->str.head; list; list = list->next) | |
13374 | for (entry = list->head; entry; entry = entry->next) { | |
13375 | vty_out(vty, "ip large-community-list %s %s %s %s\n", | |
13376 | entry->style == LARGE_COMMUNITY_LIST_STANDARD | |
13377 | ? "standard" | |
13378 | : "expanded", | |
13379 | list->name, community_direct_str(entry->direct), | |
13380 | community_list_config_str(entry)); | |
13381 | write++; | |
13382 | } | |
13383 | ||
13384 | return write; | |
13385 | } | |
13386 | ||
13387 | static struct cmd_node community_list_node = { | |
13388 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 13389 | }; |
13390 | ||
d62a17ae | 13391 | static void community_list_vty(void) |
13392 | { | |
13393 | install_node(&community_list_node, community_list_config_write); | |
13394 | ||
13395 | /* Community-list. */ | |
13396 | install_element(CONFIG_NODE, &ip_community_list_standard_cmd); | |
13397 | install_element(CONFIG_NODE, &ip_community_list_expanded_all_cmd); | |
13398 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_cmd); | |
13399 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); | |
13400 | install_element(VIEW_NODE, &show_ip_community_list_cmd); | |
13401 | install_element(VIEW_NODE, &show_ip_community_list_arg_cmd); | |
13402 | ||
13403 | /* Extcommunity-list. */ | |
13404 | install_element(CONFIG_NODE, &ip_extcommunity_list_standard_cmd); | |
13405 | install_element(CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); | |
13406 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); | |
13407 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
13408 | install_element(VIEW_NODE, &show_ip_extcommunity_list_cmd); | |
13409 | install_element(VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
13410 | ||
13411 | /* Large Community List */ | |
13412 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard_cmd); | |
13413 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); | |
13414 | install_element(CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); | |
13415 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
13416 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); | |
13417 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); | |
13418 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
13419 | install_element(CONFIG_NODE, | |
13420 | &no_ip_lcommunity_list_name_expanded_all_cmd); | |
13421 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
13422 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
13423 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
13424 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
13425 | install_element(VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
13426 | install_element(VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 13427 | } |