]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* BGP VTY interface. |
896014f4 DL |
2 | * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro |
3 | * | |
4 | * This file is part of GNU Zebra. | |
5 | * | |
6 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License as published by the | |
8 | * Free Software Foundation; either version 2, or (at your option) any | |
9 | * later version. | |
10 | * | |
11 | * GNU Zebra is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License along | |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
718e3744 | 20 | |
21 | #include <zebra.h> | |
22 | ||
23 | #include "command.h" | |
afec25d9 | 24 | #include "lib/json.h" |
718e3744 | 25 | #include "prefix.h" |
26 | #include "plist.h" | |
27 | #include "buffer.h" | |
28 | #include "linklist.h" | |
29 | #include "stream.h" | |
30 | #include "thread.h" | |
31 | #include "log.h" | |
3b8b1855 | 32 | #include "memory.h" |
fc7948fa | 33 | #include "memory_vty.h" |
4bf6a362 | 34 | #include "hash.h" |
3f9c7369 | 35 | #include "queue.h" |
039f3a34 | 36 | #include "filter.h" |
718e3744 | 37 | |
38 | #include "bgpd/bgpd.h" | |
4bf6a362 | 39 | #include "bgpd/bgp_advertise.h" |
718e3744 | 40 | #include "bgpd/bgp_attr.h" |
41 | #include "bgpd/bgp_aspath.h" | |
42 | #include "bgpd/bgp_community.h" | |
4bf6a362 | 43 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 44 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 45 | #include "bgpd/bgp_damp.h" |
718e3744 | 46 | #include "bgpd/bgp_debug.h" |
e0701b79 | 47 | #include "bgpd/bgp_fsm.h" |
4bf6a362 | 48 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 49 | #include "bgpd/bgp_open.h" |
4bf6a362 | 50 | #include "bgpd/bgp_regex.h" |
718e3744 | 51 | #include "bgpd/bgp_route.h" |
c016b6c7 | 52 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 53 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 54 | #include "bgpd/bgp_table.h" |
94f2b392 | 55 | #include "bgpd/bgp_vty.h" |
165b5fff | 56 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 57 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 58 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 59 | #include "bgpd/bgp_bfd.h" |
555e09d4 | 60 | #include "bgpd/bgp_io.h" |
94c2f693 | 61 | #include "bgpd/bgp_evpn.h" |
718e3744 | 62 | |
d62a17ae | 63 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
64 | struct prefix *range, int exact); | |
65 | ||
66 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) | |
67 | { | |
68 | switch (afi) { | |
69 | case AFI_IP: | |
70 | switch (safi) { | |
71 | case SAFI_UNICAST: | |
72 | return BGP_IPV4_NODE; | |
73 | break; | |
74 | case SAFI_MULTICAST: | |
75 | return BGP_IPV4M_NODE; | |
76 | break; | |
77 | case SAFI_LABELED_UNICAST: | |
78 | return BGP_IPV4L_NODE; | |
79 | break; | |
80 | case SAFI_MPLS_VPN: | |
81 | return BGP_VPNV4_NODE; | |
82 | break; | |
7c40bf39 | 83 | case SAFI_FLOWSPEC: |
84 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
85 | default: |
86 | /* not expected */ | |
87 | return BGP_IPV4_NODE; | |
88 | break; | |
d62a17ae | 89 | } |
90 | break; | |
91 | case AFI_IP6: | |
92 | switch (safi) { | |
93 | case SAFI_UNICAST: | |
94 | return BGP_IPV6_NODE; | |
95 | break; | |
96 | case SAFI_MULTICAST: | |
97 | return BGP_IPV6M_NODE; | |
98 | break; | |
99 | case SAFI_LABELED_UNICAST: | |
100 | return BGP_IPV6L_NODE; | |
101 | break; | |
102 | case SAFI_MPLS_VPN: | |
103 | return BGP_VPNV6_NODE; | |
104 | break; | |
7c40bf39 | 105 | case SAFI_FLOWSPEC: |
106 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
107 | default: |
108 | /* not expected */ | |
109 | return BGP_IPV4_NODE; | |
110 | break; | |
d62a17ae | 111 | } |
112 | break; | |
113 | case AFI_L2VPN: | |
114 | return BGP_EVPN_NODE; | |
115 | break; | |
116 | case AFI_MAX: | |
117 | // We should never be here but to clarify the switch statement.. | |
118 | return BGP_IPV4_NODE; | |
119 | break; | |
120 | } | |
121 | ||
122 | // Impossible to happen | |
123 | return BGP_IPV4_NODE; | |
f51bae9c | 124 | } |
20eb8864 | 125 | |
718e3744 | 126 | /* Utility function to get address family from current node. */ |
d62a17ae | 127 | afi_t bgp_node_afi(struct vty *vty) |
128 | { | |
129 | afi_t afi; | |
130 | switch (vty->node) { | |
131 | case BGP_IPV6_NODE: | |
132 | case BGP_IPV6M_NODE: | |
133 | case BGP_IPV6L_NODE: | |
134 | case BGP_VPNV6_NODE: | |
7c40bf39 | 135 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 136 | afi = AFI_IP6; |
137 | break; | |
138 | case BGP_EVPN_NODE: | |
139 | afi = AFI_L2VPN; | |
140 | break; | |
141 | default: | |
142 | afi = AFI_IP; | |
143 | break; | |
144 | } | |
145 | return afi; | |
718e3744 | 146 | } |
147 | ||
148 | /* Utility function to get subsequent address family from current | |
149 | node. */ | |
d62a17ae | 150 | safi_t bgp_node_safi(struct vty *vty) |
151 | { | |
152 | safi_t safi; | |
153 | switch (vty->node) { | |
154 | case BGP_VPNV4_NODE: | |
155 | case BGP_VPNV6_NODE: | |
156 | safi = SAFI_MPLS_VPN; | |
157 | break; | |
158 | case BGP_IPV4M_NODE: | |
159 | case BGP_IPV6M_NODE: | |
160 | safi = SAFI_MULTICAST; | |
161 | break; | |
162 | case BGP_EVPN_NODE: | |
163 | safi = SAFI_EVPN; | |
164 | break; | |
165 | case BGP_IPV4L_NODE: | |
166 | case BGP_IPV6L_NODE: | |
167 | safi = SAFI_LABELED_UNICAST; | |
168 | break; | |
7c40bf39 | 169 | case BGP_FLOWSPECV4_NODE: |
170 | case BGP_FLOWSPECV6_NODE: | |
171 | safi = SAFI_FLOWSPEC; | |
172 | break; | |
d62a17ae | 173 | default: |
174 | safi = SAFI_UNICAST; | |
175 | break; | |
176 | } | |
177 | return safi; | |
718e3744 | 178 | } |
179 | ||
55f91488 QY |
180 | /** |
181 | * Converts an AFI in string form to afi_t | |
182 | * | |
183 | * @param afi string, one of | |
184 | * - "ipv4" | |
185 | * - "ipv6" | |
186 | * @return the corresponding afi_t | |
187 | */ | |
d62a17ae | 188 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
189 | { | |
190 | afi_t afi = AFI_MAX; /* unknown */ | |
191 | if (strmatch(afi_str, "ipv4")) | |
192 | afi = AFI_IP; | |
193 | else if (strmatch(afi_str, "ipv6")) | |
194 | afi = AFI_IP6; | |
195 | return afi; | |
196 | } | |
197 | ||
198 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
199 | afi_t *afi) | |
200 | { | |
201 | int ret = 0; | |
202 | if (argv_find(argv, argc, "ipv4", index)) { | |
203 | ret = 1; | |
204 | if (afi) | |
205 | *afi = AFI_IP; | |
206 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
207 | ret = 1; | |
208 | if (afi) | |
209 | *afi = AFI_IP6; | |
210 | } | |
211 | return ret; | |
46f296b4 LB |
212 | } |
213 | ||
375a2e67 | 214 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 215 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
216 | { | |
217 | safi_t safi = SAFI_MAX; /* unknown */ | |
218 | if (strmatch(safi_str, "multicast")) | |
219 | safi = SAFI_MULTICAST; | |
220 | else if (strmatch(safi_str, "unicast")) | |
221 | safi = SAFI_UNICAST; | |
222 | else if (strmatch(safi_str, "vpn")) | |
223 | safi = SAFI_MPLS_VPN; | |
224 | else if (strmatch(safi_str, "labeled-unicast")) | |
225 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 226 | else if (strmatch(safi_str, "flowspec")) |
227 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 228 | return safi; |
229 | } | |
230 | ||
231 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
232 | safi_t *safi) | |
233 | { | |
234 | int ret = 0; | |
235 | if (argv_find(argv, argc, "unicast", index)) { | |
236 | ret = 1; | |
237 | if (safi) | |
238 | *safi = SAFI_UNICAST; | |
239 | } else if (argv_find(argv, argc, "multicast", index)) { | |
240 | ret = 1; | |
241 | if (safi) | |
242 | *safi = SAFI_MULTICAST; | |
243 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
244 | ret = 1; | |
245 | if (safi) | |
246 | *safi = SAFI_LABELED_UNICAST; | |
247 | } else if (argv_find(argv, argc, "vpn", index)) { | |
248 | ret = 1; | |
249 | if (safi) | |
250 | *safi = SAFI_MPLS_VPN; | |
7c40bf39 | 251 | } else if (argv_find(argv, argc, "flowspec", index)) { |
252 | ret = 1; | |
253 | if (safi) | |
254 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 255 | } |
256 | return ret; | |
46f296b4 LB |
257 | } |
258 | ||
7eeee51e | 259 | /* |
f212a857 | 260 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 261 | * |
f212a857 DS |
262 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
263 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
264 | * to appropriate values for the calling function. This is to allow the |
265 | * calling function to make decisions appropriate for the show command | |
266 | * that is being parsed. | |
267 | * | |
268 | * The show commands are generally of the form: | |
d62a17ae | 269 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
270 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
271 | * |
272 | * Since we use argv_find if the show command in particular doesn't have: | |
273 | * [ip] | |
18c57037 | 274 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 275 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
276 | * The command parsing should still be ok. |
277 | * | |
278 | * vty -> The vty for the command so we can output some useful data in | |
279 | * the event of a parse error in the vrf. | |
280 | * argv -> The command tokens | |
281 | * argc -> How many command tokens we have | |
d62a17ae | 282 | * idx -> The current place in the command, generally should be 0 for this |
283 | * function | |
7eeee51e DS |
284 | * afi -> The parsed afi if it was included in the show command, returned here |
285 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 286 | * bgp -> Pointer to the bgp data structure we need to fill in. |
7eeee51e DS |
287 | * |
288 | * The function returns the correct location in the parse tree for the | |
289 | * last token found. | |
0e37c258 DS |
290 | * |
291 | * Returns 0 for failure to parse correctly, else the idx position of where | |
292 | * it found the last token. | |
7eeee51e | 293 | */ |
d62a17ae | 294 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
295 | struct cmd_token **argv, int argc, | |
296 | int *idx, afi_t *afi, safi_t *safi, | |
297 | struct bgp **bgp) | |
298 | { | |
299 | char *vrf_name = NULL; | |
300 | ||
301 | assert(afi); | |
302 | assert(safi); | |
303 | assert(bgp); | |
304 | ||
305 | if (argv_find(argv, argc, "ip", idx)) | |
306 | *afi = AFI_IP; | |
307 | ||
308 | if (argv_find(argv, argc, "view", idx) | |
309 | || argv_find(argv, argc, "vrf", idx)) { | |
310 | vrf_name = argv[*idx + 1]->arg; | |
311 | ||
312 | if (strmatch(vrf_name, "all")) | |
313 | *bgp = NULL; | |
314 | else { | |
315 | *bgp = bgp_lookup_by_name(vrf_name); | |
316 | if (!*bgp) { | |
317 | vty_out(vty, | |
318 | "View/Vrf specified is unknown: %s\n", | |
319 | vrf_name); | |
320 | *idx = 0; | |
321 | return 0; | |
322 | } | |
323 | } | |
324 | } else { | |
325 | *bgp = bgp_get_default(); | |
326 | if (!*bgp) { | |
327 | vty_out(vty, "Unable to find default BGP instance\n"); | |
328 | *idx = 0; | |
329 | return 0; | |
330 | } | |
331 | } | |
332 | ||
333 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
334 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
335 | ||
336 | *idx += 1; | |
337 | return *idx; | |
338 | } | |
339 | ||
340 | static int peer_address_self_check(struct bgp *bgp, union sockunion *su) | |
341 | { | |
342 | struct interface *ifp = NULL; | |
343 | ||
344 | if (su->sa.sa_family == AF_INET) | |
345 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
346 | else if (su->sa.sa_family == AF_INET6) | |
347 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
348 | su->sin6.sin6_scope_id, | |
349 | bgp->vrf_id); | |
350 | ||
351 | if (ifp) | |
352 | return 1; | |
353 | ||
354 | return 0; | |
718e3744 | 355 | } |
356 | ||
357 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
358 | /* This is used only for configuration, so disallow if attempted on |
359 | * a dynamic neighbor. | |
360 | */ | |
d62a17ae | 361 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
362 | { | |
363 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
364 | int ret; | |
365 | union sockunion su; | |
366 | struct peer *peer; | |
367 | ||
368 | if (!bgp) { | |
369 | return NULL; | |
370 | } | |
371 | ||
372 | ret = str2sockunion(ip_str, &su); | |
373 | if (ret < 0) { | |
374 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
375 | if (!peer) { | |
376 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
377 | == NULL) { | |
378 | vty_out(vty, | |
379 | "%% Malformed address or name: %s\n", | |
380 | ip_str); | |
381 | return NULL; | |
382 | } | |
383 | } | |
384 | } else { | |
385 | peer = peer_lookup(bgp, &su); | |
386 | if (!peer) { | |
387 | vty_out(vty, | |
388 | "%% Specify remote-as or peer-group commands first\n"); | |
389 | return NULL; | |
390 | } | |
391 | if (peer_dynamic_neighbor(peer)) { | |
392 | vty_out(vty, | |
393 | "%% Operation not allowed on a dynamic neighbor\n"); | |
394 | return NULL; | |
395 | } | |
396 | } | |
397 | return peer; | |
718e3744 | 398 | } |
399 | ||
400 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
401 | /* This is used only for configuration, so disallow if attempted on |
402 | * a dynamic neighbor. | |
403 | */ | |
d62a17ae | 404 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
405 | { | |
406 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
407 | int ret; | |
408 | union sockunion su; | |
409 | struct peer *peer = NULL; | |
410 | struct peer_group *group = NULL; | |
411 | ||
412 | if (!bgp) { | |
413 | return NULL; | |
414 | } | |
415 | ||
416 | ret = str2sockunion(peer_str, &su); | |
417 | if (ret == 0) { | |
418 | /* IP address, locate peer. */ | |
419 | peer = peer_lookup(bgp, &su); | |
420 | } else { | |
421 | /* Not IP, could match either peer configured on interface or a | |
422 | * group. */ | |
423 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
424 | if (!peer) | |
425 | group = peer_group_lookup(bgp, peer_str); | |
426 | } | |
427 | ||
428 | if (peer) { | |
429 | if (peer_dynamic_neighbor(peer)) { | |
430 | vty_out(vty, | |
431 | "%% Operation not allowed on a dynamic neighbor\n"); | |
432 | return NULL; | |
433 | } | |
434 | ||
435 | return peer; | |
436 | } | |
437 | ||
438 | if (group) | |
439 | return group->conf; | |
440 | ||
441 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
442 | ||
443 | return NULL; | |
444 | } | |
445 | ||
446 | int bgp_vty_return(struct vty *vty, int ret) | |
447 | { | |
448 | const char *str = NULL; | |
449 | ||
450 | switch (ret) { | |
451 | case BGP_ERR_INVALID_VALUE: | |
452 | str = "Invalid value"; | |
453 | break; | |
454 | case BGP_ERR_INVALID_FLAG: | |
455 | str = "Invalid flag"; | |
456 | break; | |
457 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
458 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
459 | break; | |
460 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
461 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
462 | break; | |
463 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
464 | str = "Specify remote-as or peer-group remote AS first"; | |
465 | break; | |
466 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
467 | str = "Cannot change the peer-group. Deconfigure first"; | |
468 | break; | |
469 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
470 | str = "Peer is not a member of this peer-group"; | |
471 | break; | |
472 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
473 | str = "Prefix/distribute list can not co-exist"; | |
474 | break; | |
475 | case BGP_ERR_NOT_INTERNAL_PEER: | |
476 | str = "Invalid command. Not an internal neighbor"; | |
477 | break; | |
478 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
479 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
480 | break; | |
481 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
482 | str = "Local-AS allowed only for EBGP peers"; | |
483 | break; | |
484 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
485 | str = "Cannot have local-as same as BGP AS number"; | |
486 | break; | |
487 | case BGP_ERR_TCPSIG_FAILED: | |
488 | str = "Error while applying TCP-Sig to session(s)"; | |
489 | break; | |
490 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
491 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
492 | break; | |
493 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
494 | str = "ttl-security only allowed for EBGP peers"; | |
495 | break; | |
496 | case BGP_ERR_AS_OVERRIDE: | |
497 | str = "as-override cannot be configured for IBGP peers"; | |
498 | break; | |
499 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
500 | str = "Invalid limit for number of dynamic neighbors"; | |
501 | break; | |
502 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
503 | str = "Dynamic neighbor listen range already exists"; | |
504 | break; | |
505 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
506 | str = "Operation not allowed on a dynamic neighbor"; | |
507 | break; | |
508 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
509 | str = "Operation not allowed on a directly connected neighbor"; | |
510 | break; | |
511 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
512 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; | |
513 | break; | |
514 | } | |
515 | if (str) { | |
516 | vty_out(vty, "%% %s\n", str); | |
517 | return CMD_WARNING_CONFIG_FAILED; | |
518 | } | |
519 | return CMD_SUCCESS; | |
718e3744 | 520 | } |
521 | ||
7aafcaca | 522 | /* BGP clear sort. */ |
d62a17ae | 523 | enum clear_sort { |
524 | clear_all, | |
525 | clear_peer, | |
526 | clear_group, | |
527 | clear_external, | |
528 | clear_as | |
7aafcaca DS |
529 | }; |
530 | ||
d62a17ae | 531 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
532 | safi_t safi, int error) | |
533 | { | |
534 | switch (error) { | |
535 | case BGP_ERR_AF_UNCONFIGURED: | |
536 | vty_out(vty, | |
537 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
538 | afi_safi_print(afi, safi), peer->host); | |
539 | break; | |
540 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
541 | vty_out(vty, | |
542 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
543 | peer->host); | |
544 | break; | |
545 | default: | |
546 | break; | |
547 | } | |
7aafcaca DS |
548 | } |
549 | ||
550 | /* `clear ip bgp' functions. */ | |
d62a17ae | 551 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
552 | enum clear_sort sort, enum bgp_clear_type stype, | |
553 | const char *arg) | |
554 | { | |
555 | int ret; | |
3ae8bfa5 | 556 | bool found = false; |
d62a17ae | 557 | struct peer *peer; |
558 | struct listnode *node, *nnode; | |
559 | ||
560 | /* Clear all neighbors. */ | |
561 | /* | |
562 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
563 | * nodes on the BGP instance as that may get freed if it is a |
564 | * doppelganger | |
d62a17ae | 565 | */ |
566 | if (sort == clear_all) { | |
567 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
3ae8bfa5 PM |
568 | if (!peer->afc[afi][safi]) |
569 | continue; | |
570 | ||
d62a17ae | 571 | if (stype == BGP_CLEAR_SOFT_NONE) |
572 | ret = peer_clear(peer, &nnode); | |
d62a17ae | 573 | else |
3ae8bfa5 | 574 | ret = peer_clear_soft(peer, afi, safi, stype); |
d62a17ae | 575 | |
576 | if (ret < 0) | |
577 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
578 | else |
579 | found = true; | |
04b6bdc0 | 580 | } |
d62a17ae | 581 | |
582 | /* This is to apply read-only mode on this clear. */ | |
583 | if (stype == BGP_CLEAR_SOFT_NONE) | |
584 | bgp->update_delay_over = 0; | |
585 | ||
3ae8bfa5 PM |
586 | if (!found) |
587 | vty_out(vty, "%%BGP: No %s peer configured", | |
588 | afi_safi_print(afi, safi)); | |
589 | ||
d62a17ae | 590 | return CMD_SUCCESS; |
7aafcaca DS |
591 | } |
592 | ||
3ae8bfa5 | 593 | /* Clear specified neighbor. */ |
d62a17ae | 594 | if (sort == clear_peer) { |
595 | union sockunion su; | |
d62a17ae | 596 | |
597 | /* Make sockunion for lookup. */ | |
598 | ret = str2sockunion(arg, &su); | |
599 | if (ret < 0) { | |
600 | peer = peer_lookup_by_conf_if(bgp, arg); | |
601 | if (!peer) { | |
602 | peer = peer_lookup_by_hostname(bgp, arg); | |
603 | if (!peer) { | |
604 | vty_out(vty, | |
605 | "Malformed address or name: %s\n", | |
606 | arg); | |
607 | return CMD_WARNING; | |
608 | } | |
609 | } | |
610 | } else { | |
611 | peer = peer_lookup(bgp, &su); | |
612 | if (!peer) { | |
613 | vty_out(vty, | |
614 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
615 | arg); | |
616 | return CMD_WARNING; | |
617 | } | |
618 | } | |
7aafcaca | 619 | |
3ae8bfa5 PM |
620 | if (!peer->afc[afi][safi]) |
621 | ret = BGP_ERR_AF_UNCONFIGURED; | |
622 | else if (stype == BGP_CLEAR_SOFT_NONE) | |
d62a17ae | 623 | ret = peer_clear(peer, NULL); |
624 | else | |
625 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 626 | |
d62a17ae | 627 | if (ret < 0) |
628 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 629 | |
d62a17ae | 630 | return CMD_SUCCESS; |
7aafcaca | 631 | } |
7aafcaca | 632 | |
3ae8bfa5 | 633 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 634 | if (sort == clear_group) { |
635 | struct peer_group *group; | |
7aafcaca | 636 | |
d62a17ae | 637 | group = peer_group_lookup(bgp, arg); |
638 | if (!group) { | |
639 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
640 | return CMD_WARNING; | |
641 | } | |
642 | ||
643 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
d62a17ae | 644 | if (!peer->afc[afi][safi]) |
645 | continue; | |
646 | ||
3ae8bfa5 PM |
647 | if (stype == BGP_CLEAR_SOFT_NONE) |
648 | ret = peer_clear(peer, NULL); | |
649 | else | |
650 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 651 | |
d62a17ae | 652 | if (ret < 0) |
653 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
654 | else |
655 | found = true; | |
d62a17ae | 656 | } |
3ae8bfa5 PM |
657 | |
658 | if (!found) | |
659 | vty_out(vty, | |
660 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
661 | afi_safi_print(afi, safi), arg); | |
662 | ||
d62a17ae | 663 | return CMD_SUCCESS; |
7aafcaca | 664 | } |
7aafcaca | 665 | |
3ae8bfa5 | 666 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 667 | if (sort == clear_external) { |
668 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
669 | if (peer->sort == BGP_PEER_IBGP) | |
670 | continue; | |
7aafcaca | 671 | |
3ae8bfa5 PM |
672 | if (!peer->afc[afi][safi]) |
673 | continue; | |
674 | ||
d62a17ae | 675 | if (stype == BGP_CLEAR_SOFT_NONE) |
676 | ret = peer_clear(peer, &nnode); | |
677 | else | |
678 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 679 | |
d62a17ae | 680 | if (ret < 0) |
681 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
682 | else |
683 | found = true; | |
d62a17ae | 684 | } |
3ae8bfa5 PM |
685 | |
686 | if (!found) | |
687 | vty_out(vty, | |
688 | "%%BGP: No external %s peer is configured\n", | |
689 | afi_safi_print(afi, safi)); | |
690 | ||
d62a17ae | 691 | return CMD_SUCCESS; |
692 | } | |
693 | ||
3ae8bfa5 | 694 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 695 | if (sort == clear_as) { |
3ae8bfa5 | 696 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 697 | |
698 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
699 | if (peer->as != as) | |
700 | continue; | |
701 | ||
3ae8bfa5 PM |
702 | if (!peer->afc[afi][safi]) |
703 | ret = BGP_ERR_AF_UNCONFIGURED; | |
704 | else if (stype == BGP_CLEAR_SOFT_NONE) | |
d62a17ae | 705 | ret = peer_clear(peer, &nnode); |
706 | else | |
707 | ret = peer_clear_soft(peer, afi, safi, stype); | |
708 | ||
709 | if (ret < 0) | |
710 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
711 | else |
712 | found = true; | |
d62a17ae | 713 | } |
3ae8bfa5 PM |
714 | |
715 | if (!found) | |
d62a17ae | 716 | vty_out(vty, |
3ae8bfa5 PM |
717 | "%%BGP: No %s peer is configured with AS %s\n", |
718 | afi_safi_print(afi, safi), arg); | |
719 | ||
d62a17ae | 720 | return CMD_SUCCESS; |
721 | } | |
722 | ||
723 | return CMD_SUCCESS; | |
724 | } | |
725 | ||
726 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
727 | safi_t safi, enum clear_sort sort, | |
728 | enum bgp_clear_type stype, const char *arg) | |
729 | { | |
730 | struct bgp *bgp; | |
731 | ||
732 | /* BGP structure lookup. */ | |
733 | if (name) { | |
734 | bgp = bgp_lookup_by_name(name); | |
735 | if (bgp == NULL) { | |
736 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
737 | return CMD_WARNING; | |
738 | } | |
739 | } else { | |
740 | bgp = bgp_get_default(); | |
741 | if (bgp == NULL) { | |
742 | vty_out(vty, "No BGP process is configured\n"); | |
743 | return CMD_WARNING; | |
744 | } | |
745 | } | |
746 | ||
747 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
748 | } |
749 | ||
750 | /* clear soft inbound */ | |
d62a17ae | 751 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 752 | { |
d62a17ae | 753 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
754 | BGP_CLEAR_SOFT_IN, NULL); | |
755 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
756 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
757 | } |
758 | ||
759 | /* clear soft outbound */ | |
d62a17ae | 760 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 761 | { |
d62a17ae | 762 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
763 | BGP_CLEAR_SOFT_OUT, NULL); | |
764 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
765 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
766 | } |
767 | ||
768 | ||
f787d7a0 | 769 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 770 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
771 | #endif |
772 | ||
718e3744 | 773 | /* BGP global configuration. */ |
1cc40660 DS |
774 | #if defined(VERSION_TYPE_DEV) && (CONFDATE > 20190601) |
775 | CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance") | |
776 | CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE") | |
777 | #endif | |
778 | DEFUN_HIDDEN (bgp_multiple_instance_func, | |
779 | bgp_multiple_instance_cmd, | |
780 | "bgp multiple-instance", | |
781 | BGP_STR | |
782 | "Enable bgp multiple instance\n") | |
718e3744 | 783 | { |
d62a17ae | 784 | bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE); |
785 | return CMD_SUCCESS; | |
718e3744 | 786 | } |
787 | ||
1cc40660 | 788 | DEFUN_HIDDEN (no_bgp_multiple_instance, |
718e3744 | 789 | no_bgp_multiple_instance_cmd, |
790 | "no bgp multiple-instance", | |
791 | NO_STR | |
792 | BGP_STR | |
793 | "BGP multiple instance\n") | |
794 | { | |
d62a17ae | 795 | int ret; |
718e3744 | 796 | |
1cc40660 DS |
797 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); |
798 | vty_out(vty, "if you are using this please let the developers know\n"); | |
799 | zlog_warn("Deprecated option: `bgp multiple-instance` being used"); | |
d62a17ae | 800 | ret = bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE); |
801 | if (ret < 0) { | |
802 | vty_out(vty, "%% There are more than two BGP instances\n"); | |
803 | return CMD_WARNING_CONFIG_FAILED; | |
804 | } | |
805 | return CMD_SUCCESS; | |
718e3744 | 806 | } |
807 | ||
798467a2 DS |
808 | #if defined(VERSION_TYPE_DEV) && (CONFDATE > 20190601) |
809 | CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco") | |
810 | CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG") | |
811 | #endif | |
812 | DEFUN_HIDDEN (bgp_config_type, | |
813 | bgp_config_type_cmd, | |
814 | "bgp config-type <cisco|zebra>", | |
815 | BGP_STR | |
816 | "Configuration type\n" | |
817 | "cisco\n" | |
818 | "zebra\n") | |
718e3744 | 819 | { |
d62a17ae | 820 | int idx = 0; |
798467a2 DS |
821 | if (argv_find(argv, argc, "cisco", &idx)) { |
822 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
823 | vty_out(vty, "if you are using this please let the developers know!\n"); | |
824 | zlog_warn("Deprecated option: `bgp config-type cisco` being used"); | |
d62a17ae | 825 | bgp_option_set(BGP_OPT_CONFIG_CISCO); |
798467a2 | 826 | } else |
d62a17ae | 827 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
718e3744 | 828 | |
d62a17ae | 829 | return CMD_SUCCESS; |
718e3744 | 830 | } |
831 | ||
798467a2 DS |
832 | DEFUN_HIDDEN (no_bgp_config_type, |
833 | no_bgp_config_type_cmd, | |
834 | "no bgp config-type [<cisco|zebra>]", | |
835 | NO_STR | |
836 | BGP_STR | |
837 | "Display configuration type\n" | |
838 | "cisco\n" | |
839 | "zebra\n") | |
718e3744 | 840 | { |
d62a17ae | 841 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
842 | return CMD_SUCCESS; | |
718e3744 | 843 | } |
844 | ||
813d4307 | 845 | |
718e3744 | 846 | DEFUN (no_synchronization, |
847 | no_synchronization_cmd, | |
848 | "no synchronization", | |
849 | NO_STR | |
850 | "Perform IGP synchronization\n") | |
851 | { | |
d62a17ae | 852 | return CMD_SUCCESS; |
718e3744 | 853 | } |
854 | ||
855 | DEFUN (no_auto_summary, | |
856 | no_auto_summary_cmd, | |
857 | "no auto-summary", | |
858 | NO_STR | |
859 | "Enable automatic network number summarization\n") | |
860 | { | |
d62a17ae | 861 | return CMD_SUCCESS; |
718e3744 | 862 | } |
3d515fd9 | 863 | |
718e3744 | 864 | /* "router bgp" commands. */ |
505e5056 | 865 | DEFUN_NOSH (router_bgp, |
f412b39a | 866 | router_bgp_cmd, |
18c57037 | 867 | "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 868 | ROUTER_STR |
869 | BGP_STR | |
31500417 DW |
870 | AS_STR |
871 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 872 | { |
d62a17ae | 873 | int idx_asn = 2; |
874 | int idx_view_vrf = 3; | |
875 | int idx_vrf = 4; | |
876 | int ret; | |
877 | as_t as; | |
878 | struct bgp *bgp; | |
879 | const char *name = NULL; | |
880 | enum bgp_instance_type inst_type; | |
881 | ||
882 | // "router bgp" without an ASN | |
883 | if (argc == 2) { | |
884 | // Pending: Make VRF option available for ASN less config | |
885 | bgp = bgp_get_default(); | |
886 | ||
887 | if (bgp == NULL) { | |
888 | vty_out(vty, "%% No BGP process is configured\n"); | |
889 | return CMD_WARNING_CONFIG_FAILED; | |
890 | } | |
891 | ||
892 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 893 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 894 | return CMD_WARNING_CONFIG_FAILED; |
895 | } | |
896 | } | |
897 | ||
898 | // "router bgp X" | |
899 | else { | |
900 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
901 | ||
902 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
903 | if (argc > 3) { | |
904 | name = argv[idx_vrf]->arg; | |
905 | ||
906 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) | |
907 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
908 | else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
909 | inst_type = BGP_INSTANCE_TYPE_VIEW; | |
910 | } | |
911 | ||
912 | ret = bgp_get(&bgp, &as, name, inst_type); | |
913 | switch (ret) { | |
914 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
915 | vty_out(vty, | |
916 | "Please specify 'bgp multiple-instance' first\n"); | |
917 | return CMD_WARNING_CONFIG_FAILED; | |
918 | case BGP_ERR_AS_MISMATCH: | |
919 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
920 | return CMD_WARNING_CONFIG_FAILED; | |
921 | case BGP_ERR_INSTANCE_MISMATCH: | |
922 | vty_out(vty, | |
923 | "BGP instance name and AS number mismatch\n"); | |
924 | vty_out(vty, | |
925 | "BGP instance is already running; AS is %u\n", | |
926 | as); | |
927 | return CMD_WARNING_CONFIG_FAILED; | |
928 | } | |
929 | ||
930 | /* Pending: handle when user tries to change a view to vrf n vv. | |
931 | */ | |
932 | } | |
933 | ||
0b5131c9 MK |
934 | /* unset the auto created flag as the user config is now present */ |
935 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 936 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
937 | ||
938 | return CMD_SUCCESS; | |
718e3744 | 939 | } |
940 | ||
718e3744 | 941 | /* "no router bgp" commands. */ |
942 | DEFUN (no_router_bgp, | |
943 | no_router_bgp_cmd, | |
18c57037 | 944 | "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 945 | NO_STR |
946 | ROUTER_STR | |
947 | BGP_STR | |
31500417 DW |
948 | AS_STR |
949 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 950 | { |
d62a17ae | 951 | int idx_asn = 3; |
952 | int idx_vrf = 5; | |
953 | as_t as; | |
954 | struct bgp *bgp; | |
955 | const char *name = NULL; | |
718e3744 | 956 | |
d62a17ae | 957 | // "no router bgp" without an ASN |
958 | if (argc == 3) { | |
959 | // Pending: Make VRF option available for ASN less config | |
960 | bgp = bgp_get_default(); | |
718e3744 | 961 | |
d62a17ae | 962 | if (bgp == NULL) { |
963 | vty_out(vty, "%% No BGP process is configured\n"); | |
964 | return CMD_WARNING_CONFIG_FAILED; | |
965 | } | |
7fb21a9f | 966 | |
d62a17ae | 967 | if (listcount(bm->bgp) > 1) { |
996c9314 | 968 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 969 | return CMD_WARNING_CONFIG_FAILED; |
970 | } | |
0b5131c9 MK |
971 | |
972 | if (bgp->l3vni) { | |
973 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
974 | bgp->l3vni); | |
975 | return CMD_WARNING_CONFIG_FAILED; | |
976 | } | |
d62a17ae | 977 | } else { |
978 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 979 | |
d62a17ae | 980 | if (argc > 4) |
981 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 982 | |
d62a17ae | 983 | /* Lookup bgp structure. */ |
984 | bgp = bgp_lookup(as, name); | |
985 | if (!bgp) { | |
986 | vty_out(vty, "%% Can't find BGP instance\n"); | |
987 | return CMD_WARNING_CONFIG_FAILED; | |
988 | } | |
0b5131c9 MK |
989 | |
990 | if (bgp->l3vni) { | |
991 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
992 | bgp->l3vni); | |
993 | return CMD_WARNING_CONFIG_FAILED; | |
994 | } | |
d62a17ae | 995 | } |
718e3744 | 996 | |
d62a17ae | 997 | bgp_delete(bgp); |
718e3744 | 998 | |
d62a17ae | 999 | return CMD_SUCCESS; |
718e3744 | 1000 | } |
1001 | ||
6b0655a2 | 1002 | |
718e3744 | 1003 | /* BGP router-id. */ |
1004 | ||
f787d7a0 | 1005 | DEFPY (bgp_router_id, |
718e3744 | 1006 | bgp_router_id_cmd, |
1007 | "bgp router-id A.B.C.D", | |
1008 | BGP_STR | |
1009 | "Override configured router identifier\n" | |
1010 | "Manually configured router identifier\n") | |
1011 | { | |
d62a17ae | 1012 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1013 | bgp_router_id_static_set(bgp, router_id); | |
1014 | return CMD_SUCCESS; | |
718e3744 | 1015 | } |
1016 | ||
f787d7a0 | 1017 | DEFPY (no_bgp_router_id, |
718e3744 | 1018 | no_bgp_router_id_cmd, |
31500417 | 1019 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1020 | NO_STR |
1021 | BGP_STR | |
31500417 DW |
1022 | "Override configured router identifier\n" |
1023 | "Manually configured router identifier\n") | |
718e3744 | 1024 | { |
d62a17ae | 1025 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1026 | |
d62a17ae | 1027 | if (router_id_str) { |
1028 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1029 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1030 | return CMD_WARNING_CONFIG_FAILED; | |
1031 | } | |
e018c7cc | 1032 | } |
718e3744 | 1033 | |
d62a17ae | 1034 | router_id.s_addr = 0; |
1035 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1036 | |
d62a17ae | 1037 | return CMD_SUCCESS; |
718e3744 | 1038 | } |
1039 | ||
6b0655a2 | 1040 | |
718e3744 | 1041 | /* BGP Cluster ID. */ |
718e3744 | 1042 | DEFUN (bgp_cluster_id, |
1043 | bgp_cluster_id_cmd, | |
838758ac | 1044 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1045 | BGP_STR |
1046 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1047 | "Route-Reflector Cluster-id in IP address format\n" |
1048 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1049 | { |
d62a17ae | 1050 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1051 | int idx_ipv4 = 2; | |
1052 | int ret; | |
1053 | struct in_addr cluster; | |
718e3744 | 1054 | |
d62a17ae | 1055 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1056 | if (!ret) { | |
1057 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1058 | return CMD_WARNING_CONFIG_FAILED; | |
1059 | } | |
718e3744 | 1060 | |
d62a17ae | 1061 | bgp_cluster_id_set(bgp, &cluster); |
1062 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1063 | |
d62a17ae | 1064 | return CMD_SUCCESS; |
718e3744 | 1065 | } |
1066 | ||
718e3744 | 1067 | DEFUN (no_bgp_cluster_id, |
1068 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1069 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1070 | NO_STR |
1071 | BGP_STR | |
838758ac DW |
1072 | "Configure Route-Reflector Cluster-id\n" |
1073 | "Route-Reflector Cluster-id in IP address format\n" | |
1074 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1075 | { |
d62a17ae | 1076 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1077 | bgp_cluster_id_unset(bgp); | |
1078 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1079 | |
d62a17ae | 1080 | return CMD_SUCCESS; |
718e3744 | 1081 | } |
1082 | ||
718e3744 | 1083 | DEFUN (bgp_confederation_identifier, |
1084 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1085 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1086 | "BGP specific commands\n" |
1087 | "AS confederation parameters\n" | |
1088 | "AS number\n" | |
1089 | "Set routing domain confederation AS\n") | |
1090 | { | |
d62a17ae | 1091 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1092 | int idx_number = 3; | |
1093 | as_t as; | |
718e3744 | 1094 | |
d62a17ae | 1095 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1096 | |
d62a17ae | 1097 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1098 | |
d62a17ae | 1099 | return CMD_SUCCESS; |
718e3744 | 1100 | } |
1101 | ||
1102 | DEFUN (no_bgp_confederation_identifier, | |
1103 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1104 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1105 | NO_STR |
1106 | "BGP specific commands\n" | |
1107 | "AS confederation parameters\n" | |
3a2d747c QY |
1108 | "AS number\n" |
1109 | "Set routing domain confederation AS\n") | |
718e3744 | 1110 | { |
d62a17ae | 1111 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1112 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1113 | |
d62a17ae | 1114 | return CMD_SUCCESS; |
718e3744 | 1115 | } |
1116 | ||
718e3744 | 1117 | DEFUN (bgp_confederation_peers, |
1118 | bgp_confederation_peers_cmd, | |
12dcf78e | 1119 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1120 | "BGP specific commands\n" |
1121 | "AS confederation parameters\n" | |
1122 | "Peer ASs in BGP confederation\n" | |
1123 | AS_STR) | |
1124 | { | |
d62a17ae | 1125 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1126 | int idx_asn = 3; | |
1127 | as_t as; | |
1128 | int i; | |
718e3744 | 1129 | |
d62a17ae | 1130 | for (i = idx_asn; i < argc; i++) { |
1131 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1132 | |
d62a17ae | 1133 | if (bgp->as == as) { |
1134 | vty_out(vty, | |
1135 | "%% Local member-AS not allowed in confed peer list\n"); | |
1136 | continue; | |
1137 | } | |
718e3744 | 1138 | |
d62a17ae | 1139 | bgp_confederation_peers_add(bgp, as); |
1140 | } | |
1141 | return CMD_SUCCESS; | |
718e3744 | 1142 | } |
1143 | ||
1144 | DEFUN (no_bgp_confederation_peers, | |
1145 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1146 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1147 | NO_STR |
1148 | "BGP specific commands\n" | |
1149 | "AS confederation parameters\n" | |
1150 | "Peer ASs in BGP confederation\n" | |
1151 | AS_STR) | |
1152 | { | |
d62a17ae | 1153 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1154 | int idx_asn = 4; | |
1155 | as_t as; | |
1156 | int i; | |
718e3744 | 1157 | |
d62a17ae | 1158 | for (i = idx_asn; i < argc; i++) { |
1159 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1160 | |
d62a17ae | 1161 | bgp_confederation_peers_remove(bgp, as); |
1162 | } | |
1163 | return CMD_SUCCESS; | |
718e3744 | 1164 | } |
6b0655a2 | 1165 | |
5e242b0d DS |
1166 | /** |
1167 | * Central routine for maximum-paths configuration. | |
1168 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1169 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1170 | */ | |
d62a17ae | 1171 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1172 | const char *mpaths, uint16_t options, |
d62a17ae | 1173 | int set) |
1174 | { | |
1175 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1176 | uint16_t maxpaths = 0; |
d62a17ae | 1177 | int ret; |
1178 | afi_t afi; | |
1179 | safi_t safi; | |
1180 | ||
1181 | afi = bgp_node_afi(vty); | |
1182 | safi = bgp_node_safi(vty); | |
1183 | ||
1184 | if (set) { | |
1185 | maxpaths = strtol(mpaths, NULL, 10); | |
1186 | if (maxpaths > multipath_num) { | |
1187 | vty_out(vty, | |
1188 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1189 | maxpaths, multipath_num); | |
1190 | return CMD_WARNING_CONFIG_FAILED; | |
1191 | } | |
1192 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1193 | options); | |
1194 | } else | |
1195 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1196 | ||
1197 | if (ret < 0) { | |
1198 | vty_out(vty, | |
1199 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1200 | (set == 1) ? "" : "un", | |
1201 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1202 | maxpaths, afi, safi); | |
1203 | return CMD_WARNING_CONFIG_FAILED; | |
1204 | } | |
1205 | ||
1206 | bgp_recalculate_all_bestpaths(bgp); | |
1207 | ||
1208 | return CMD_SUCCESS; | |
165b5fff JB |
1209 | } |
1210 | ||
abc920f8 DS |
1211 | DEFUN (bgp_maxmed_admin, |
1212 | bgp_maxmed_admin_cmd, | |
1213 | "bgp max-med administrative ", | |
1214 | BGP_STR | |
1215 | "Advertise routes with max-med\n" | |
1216 | "Administratively applied, for an indefinite period\n") | |
1217 | { | |
d62a17ae | 1218 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1219 | |
d62a17ae | 1220 | bgp->v_maxmed_admin = 1; |
1221 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1222 | |
d62a17ae | 1223 | bgp_maxmed_update(bgp); |
abc920f8 | 1224 | |
d62a17ae | 1225 | return CMD_SUCCESS; |
abc920f8 DS |
1226 | } |
1227 | ||
1228 | DEFUN (bgp_maxmed_admin_medv, | |
1229 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1230 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1231 | BGP_STR |
1232 | "Advertise routes with max-med\n" | |
1233 | "Administratively applied, for an indefinite period\n" | |
1234 | "Max MED value to be used\n") | |
1235 | { | |
d62a17ae | 1236 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1237 | int idx_number = 3; | |
abc920f8 | 1238 | |
d62a17ae | 1239 | bgp->v_maxmed_admin = 1; |
1240 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1241 | |
d62a17ae | 1242 | bgp_maxmed_update(bgp); |
abc920f8 | 1243 | |
d62a17ae | 1244 | return CMD_SUCCESS; |
abc920f8 DS |
1245 | } |
1246 | ||
1247 | DEFUN (no_bgp_maxmed_admin, | |
1248 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1249 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1250 | NO_STR |
1251 | BGP_STR | |
1252 | "Advertise routes with max-med\n" | |
838758ac DW |
1253 | "Administratively applied, for an indefinite period\n" |
1254 | "Max MED value to be used\n") | |
abc920f8 | 1255 | { |
d62a17ae | 1256 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1257 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1258 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1259 | bgp_maxmed_update(bgp); | |
abc920f8 | 1260 | |
d62a17ae | 1261 | return CMD_SUCCESS; |
abc920f8 DS |
1262 | } |
1263 | ||
abc920f8 DS |
1264 | DEFUN (bgp_maxmed_onstartup, |
1265 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1266 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1267 | BGP_STR |
1268 | "Advertise routes with max-med\n" | |
1269 | "Effective on a startup\n" | |
1270 | "Time (seconds) period for max-med\n" | |
1271 | "Max MED value to be used\n") | |
1272 | { | |
d62a17ae | 1273 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1274 | int idx = 0; | |
4668a151 | 1275 | |
d62a17ae | 1276 | argv_find(argv, argc, "(5-86400)", &idx); |
1277 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1278 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1279 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1280 | else | |
1281 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1282 | |
d62a17ae | 1283 | bgp_maxmed_update(bgp); |
abc920f8 | 1284 | |
d62a17ae | 1285 | return CMD_SUCCESS; |
abc920f8 DS |
1286 | } |
1287 | ||
1288 | DEFUN (no_bgp_maxmed_onstartup, | |
1289 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1290 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1291 | NO_STR |
1292 | BGP_STR | |
1293 | "Advertise routes with max-med\n" | |
838758ac DW |
1294 | "Effective on a startup\n" |
1295 | "Time (seconds) period for max-med\n" | |
1296 | "Max MED value to be used\n") | |
abc920f8 | 1297 | { |
d62a17ae | 1298 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1299 | |
d62a17ae | 1300 | /* Cancel max-med onstartup if its on */ |
1301 | if (bgp->t_maxmed_onstartup) { | |
1302 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1303 | bgp->maxmed_onstartup_over = 1; | |
1304 | } | |
abc920f8 | 1305 | |
d62a17ae | 1306 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1307 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1308 | |
d62a17ae | 1309 | bgp_maxmed_update(bgp); |
abc920f8 | 1310 | |
d62a17ae | 1311 | return CMD_SUCCESS; |
abc920f8 DS |
1312 | } |
1313 | ||
d62a17ae | 1314 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1315 | const char *wait) | |
f188f2c4 | 1316 | { |
d62a17ae | 1317 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1318 | uint16_t update_delay; |
1319 | uint16_t establish_wait; | |
f188f2c4 | 1320 | |
d62a17ae | 1321 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1322 | |
d62a17ae | 1323 | if (!wait) /* update-delay <delay> */ |
1324 | { | |
1325 | bgp->v_update_delay = update_delay; | |
1326 | bgp->v_establish_wait = bgp->v_update_delay; | |
1327 | return CMD_SUCCESS; | |
1328 | } | |
f188f2c4 | 1329 | |
d62a17ae | 1330 | /* update-delay <delay> <establish-wait> */ |
1331 | establish_wait = atoi(wait); | |
1332 | if (update_delay < establish_wait) { | |
1333 | vty_out(vty, | |
1334 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1335 | return CMD_WARNING_CONFIG_FAILED; | |
1336 | } | |
f188f2c4 | 1337 | |
d62a17ae | 1338 | bgp->v_update_delay = update_delay; |
1339 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1340 | |
d62a17ae | 1341 | return CMD_SUCCESS; |
f188f2c4 DS |
1342 | } |
1343 | ||
d62a17ae | 1344 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1345 | { |
d62a17ae | 1346 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1347 | |
d62a17ae | 1348 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1349 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1350 | |
d62a17ae | 1351 | return CMD_SUCCESS; |
f188f2c4 DS |
1352 | } |
1353 | ||
2b791107 | 1354 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1355 | { |
d62a17ae | 1356 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1357 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1358 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1359 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1360 | vty_out(vty, "\n"); | |
1361 | } | |
f188f2c4 DS |
1362 | } |
1363 | ||
1364 | ||
1365 | /* Update-delay configuration */ | |
1366 | DEFUN (bgp_update_delay, | |
1367 | bgp_update_delay_cmd, | |
6147e2c6 | 1368 | "update-delay (0-3600)", |
f188f2c4 DS |
1369 | "Force initial delay for best-path and updates\n" |
1370 | "Seconds\n") | |
1371 | { | |
d62a17ae | 1372 | int idx_number = 1; |
1373 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1374 | } |
1375 | ||
1376 | DEFUN (bgp_update_delay_establish_wait, | |
1377 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1378 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1379 | "Force initial delay for best-path and updates\n" |
1380 | "Seconds\n" | |
f188f2c4 DS |
1381 | "Seconds\n") |
1382 | { | |
d62a17ae | 1383 | int idx_number = 1; |
1384 | int idx_number_2 = 2; | |
1385 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1386 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1387 | } |
1388 | ||
1389 | /* Update-delay deconfiguration */ | |
1390 | DEFUN (no_bgp_update_delay, | |
1391 | no_bgp_update_delay_cmd, | |
838758ac DW |
1392 | "no update-delay [(0-3600) [(1-3600)]]", |
1393 | NO_STR | |
f188f2c4 | 1394 | "Force initial delay for best-path and updates\n" |
838758ac | 1395 | "Seconds\n" |
7111c1a0 | 1396 | "Seconds\n") |
f188f2c4 | 1397 | { |
d62a17ae | 1398 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1399 | } |
1400 | ||
5e242b0d | 1401 | |
d62a17ae | 1402 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, const char *num, |
1403 | char set) | |
cb1faec9 | 1404 | { |
d62a17ae | 1405 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1406 | |
555e09d4 QY |
1407 | if (set) { |
1408 | uint32_t quanta = strtoul(num, NULL, 10); | |
1409 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, | |
1410 | memory_order_relaxed); | |
1411 | } else { | |
1412 | atomic_store_explicit(&bgp->wpkt_quanta, BGP_WRITE_PACKET_MAX, | |
1413 | memory_order_relaxed); | |
1414 | } | |
1415 | ||
1416 | return CMD_SUCCESS; | |
1417 | } | |
1418 | ||
1419 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, const char *num, | |
1420 | char set) | |
1421 | { | |
1422 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1423 | ||
1424 | if (set) { | |
1425 | uint32_t quanta = strtoul(num, NULL, 10); | |
1426 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, | |
1427 | memory_order_relaxed); | |
1428 | } else { | |
1429 | atomic_store_explicit(&bgp->rpkt_quanta, BGP_READ_PACKET_MAX, | |
1430 | memory_order_relaxed); | |
1431 | } | |
cb1faec9 | 1432 | |
d62a17ae | 1433 | return CMD_SUCCESS; |
cb1faec9 DS |
1434 | } |
1435 | ||
2b791107 | 1436 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1437 | { |
555e09d4 QY |
1438 | uint32_t quanta = |
1439 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1440 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1441 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1442 | } |
1443 | ||
555e09d4 QY |
1444 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1445 | { | |
1446 | uint32_t quanta = | |
1447 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1448 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1449 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1450 | } |
cb1faec9 | 1451 | |
555e09d4 | 1452 | /* Packet quanta configuration */ |
cb1faec9 DS |
1453 | DEFUN (bgp_wpkt_quanta, |
1454 | bgp_wpkt_quanta_cmd, | |
555e09d4 | 1455 | "write-quanta (1-10)", |
cb1faec9 DS |
1456 | "How many packets to write to peer socket per run\n" |
1457 | "Number of packets\n") | |
1458 | { | |
d62a17ae | 1459 | int idx_number = 1; |
1460 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1461 | } |
1462 | ||
cb1faec9 DS |
1463 | DEFUN (no_bgp_wpkt_quanta, |
1464 | no_bgp_wpkt_quanta_cmd, | |
555e09d4 | 1465 | "no write-quanta (1-10)", |
d7fa34c1 | 1466 | NO_STR |
555e09d4 | 1467 | "How many packets to write to peer socket per I/O cycle\n" |
cb1faec9 DS |
1468 | "Number of packets\n") |
1469 | { | |
d62a17ae | 1470 | int idx_number = 2; |
1471 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1472 | } |
1473 | ||
555e09d4 QY |
1474 | DEFUN (bgp_rpkt_quanta, |
1475 | bgp_rpkt_quanta_cmd, | |
1476 | "read-quanta (1-10)", | |
1477 | "How many packets to read from peer socket per I/O cycle\n" | |
1478 | "Number of packets\n") | |
1479 | { | |
1480 | int idx_number = 1; | |
1481 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
1482 | } | |
1483 | ||
1484 | DEFUN (no_bgp_rpkt_quanta, | |
1485 | no_bgp_rpkt_quanta_cmd, | |
1486 | "no read-quanta (1-10)", | |
1487 | NO_STR | |
1488 | "How many packets to read from peer socket per I/O cycle\n" | |
1489 | "Number of packets\n") | |
1490 | { | |
1491 | int idx_number = 2; | |
1492 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
1493 | } | |
1494 | ||
2b791107 | 1495 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1496 | { |
37a333fe | 1497 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1498 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1499 | } |
1500 | ||
1501 | ||
1502 | DEFUN (bgp_coalesce_time, | |
1503 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1504 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1505 | "Subgroup coalesce timer\n" |
1506 | "Subgroup coalesce timer value (in ms)\n") | |
1507 | { | |
d62a17ae | 1508 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1509 | |
d62a17ae | 1510 | int idx = 0; |
1511 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1512 | bgp->heuristic_coalesce = false; |
d62a17ae | 1513 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1514 | return CMD_SUCCESS; | |
3f9c7369 DS |
1515 | } |
1516 | ||
1517 | DEFUN (no_bgp_coalesce_time, | |
1518 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1519 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1520 | NO_STR |
3f9c7369 DS |
1521 | "Subgroup coalesce timer\n" |
1522 | "Subgroup coalesce timer value (in ms)\n") | |
1523 | { | |
d62a17ae | 1524 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1525 | |
37a333fe | 1526 | bgp->heuristic_coalesce = true; |
d62a17ae | 1527 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1528 | return CMD_SUCCESS; | |
3f9c7369 DS |
1529 | } |
1530 | ||
5e242b0d DS |
1531 | /* Maximum-paths configuration */ |
1532 | DEFUN (bgp_maxpaths, | |
1533 | bgp_maxpaths_cmd, | |
6319fd63 | 1534 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1535 | "Forward packets over multiple paths\n" |
1536 | "Number of paths\n") | |
1537 | { | |
d62a17ae | 1538 | int idx_number = 1; |
1539 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1540 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1541 | } |
1542 | ||
d62a17ae | 1543 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1544 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1545 | "Forward packets over multiple paths\n" | |
1546 | "Number of paths\n") | |
596c17ba | 1547 | |
165b5fff JB |
1548 | DEFUN (bgp_maxpaths_ibgp, |
1549 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1550 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1551 | "Forward packets over multiple paths\n" |
1552 | "iBGP-multipath\n" | |
1553 | "Number of paths\n") | |
1554 | { | |
d62a17ae | 1555 | int idx_number = 2; |
1556 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1557 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1558 | } |
165b5fff | 1559 | |
d62a17ae | 1560 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1561 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1562 | "Forward packets over multiple paths\n" | |
1563 | "iBGP-multipath\n" | |
1564 | "Number of paths\n") | |
596c17ba | 1565 | |
5e242b0d DS |
1566 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1567 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1568 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1569 | "Forward packets over multiple paths\n" |
1570 | "iBGP-multipath\n" | |
1571 | "Number of paths\n" | |
1572 | "Match the cluster length\n") | |
1573 | { | |
d62a17ae | 1574 | int idx_number = 2; |
1575 | return bgp_maxpaths_config_vty( | |
1576 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1577 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1578 | } |
1579 | ||
d62a17ae | 1580 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1581 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1582 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1583 | "Forward packets over multiple paths\n" | |
1584 | "iBGP-multipath\n" | |
1585 | "Number of paths\n" | |
1586 | "Match the cluster length\n") | |
596c17ba | 1587 | |
165b5fff JB |
1588 | DEFUN (no_bgp_maxpaths, |
1589 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1590 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1591 | NO_STR |
1592 | "Forward packets over multiple paths\n" | |
1593 | "Number of paths\n") | |
1594 | { | |
d62a17ae | 1595 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1596 | } |
1597 | ||
d62a17ae | 1598 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1599 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1600 | "Forward packets over multiple paths\n" |
1601 | "Number of paths\n") | |
596c17ba | 1602 | |
165b5fff JB |
1603 | DEFUN (no_bgp_maxpaths_ibgp, |
1604 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1605 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1606 | NO_STR |
1607 | "Forward packets over multiple paths\n" | |
1608 | "iBGP-multipath\n" | |
838758ac DW |
1609 | "Number of paths\n" |
1610 | "Match the cluster length\n") | |
165b5fff | 1611 | { |
d62a17ae | 1612 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1613 | } |
1614 | ||
d62a17ae | 1615 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1616 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1617 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1618 | NO_STR | |
1619 | "Forward packets over multiple paths\n" | |
1620 | "iBGP-multipath\n" | |
1621 | "Number of paths\n" | |
1622 | "Match the cluster length\n") | |
596c17ba | 1623 | |
2b791107 | 1624 | void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 1625 | safi_t safi) |
165b5fff | 1626 | { |
d62a17ae | 1627 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1628 | vty_out(vty, " maximum-paths %d\n", |
1629 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1630 | } | |
165b5fff | 1631 | |
d62a17ae | 1632 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1633 | vty_out(vty, " maximum-paths ibgp %d", |
1634 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1635 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1636 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1637 | vty_out(vty, " equal-cluster-length"); | |
1638 | vty_out(vty, "\n"); | |
1639 | } | |
165b5fff | 1640 | } |
6b0655a2 | 1641 | |
718e3744 | 1642 | /* BGP timers. */ |
1643 | ||
1644 | DEFUN (bgp_timers, | |
1645 | bgp_timers_cmd, | |
6147e2c6 | 1646 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1647 | "Adjust routing timers\n" |
1648 | "BGP timers\n" | |
1649 | "Keepalive interval\n" | |
1650 | "Holdtime\n") | |
1651 | { | |
d62a17ae | 1652 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1653 | int idx_number = 2; | |
1654 | int idx_number_2 = 3; | |
1655 | unsigned long keepalive = 0; | |
1656 | unsigned long holdtime = 0; | |
718e3744 | 1657 | |
d62a17ae | 1658 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1659 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1660 | |
d62a17ae | 1661 | /* Holdtime value check. */ |
1662 | if (holdtime < 3 && holdtime != 0) { | |
1663 | vty_out(vty, | |
1664 | "%% hold time value must be either 0 or greater than 3\n"); | |
1665 | return CMD_WARNING_CONFIG_FAILED; | |
1666 | } | |
718e3744 | 1667 | |
d62a17ae | 1668 | bgp_timers_set(bgp, keepalive, holdtime); |
718e3744 | 1669 | |
d62a17ae | 1670 | return CMD_SUCCESS; |
718e3744 | 1671 | } |
1672 | ||
1673 | DEFUN (no_bgp_timers, | |
1674 | no_bgp_timers_cmd, | |
838758ac | 1675 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1676 | NO_STR |
1677 | "Adjust routing timers\n" | |
838758ac DW |
1678 | "BGP timers\n" |
1679 | "Keepalive interval\n" | |
1680 | "Holdtime\n") | |
718e3744 | 1681 | { |
d62a17ae | 1682 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1683 | bgp_timers_unset(bgp); | |
718e3744 | 1684 | |
d62a17ae | 1685 | return CMD_SUCCESS; |
718e3744 | 1686 | } |
1687 | ||
6b0655a2 | 1688 | |
718e3744 | 1689 | DEFUN (bgp_client_to_client_reflection, |
1690 | bgp_client_to_client_reflection_cmd, | |
1691 | "bgp client-to-client reflection", | |
1692 | "BGP specific commands\n" | |
1693 | "Configure client to client route reflection\n" | |
1694 | "reflection of routes allowed\n") | |
1695 | { | |
d62a17ae | 1696 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1697 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1698 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1699 | |
d62a17ae | 1700 | return CMD_SUCCESS; |
718e3744 | 1701 | } |
1702 | ||
1703 | DEFUN (no_bgp_client_to_client_reflection, | |
1704 | no_bgp_client_to_client_reflection_cmd, | |
1705 | "no bgp client-to-client reflection", | |
1706 | NO_STR | |
1707 | "BGP specific commands\n" | |
1708 | "Configure client to client route reflection\n" | |
1709 | "reflection of routes allowed\n") | |
1710 | { | |
d62a17ae | 1711 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1712 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1713 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1714 | |
d62a17ae | 1715 | return CMD_SUCCESS; |
718e3744 | 1716 | } |
1717 | ||
1718 | /* "bgp always-compare-med" configuration. */ | |
1719 | DEFUN (bgp_always_compare_med, | |
1720 | bgp_always_compare_med_cmd, | |
1721 | "bgp always-compare-med", | |
1722 | "BGP specific commands\n" | |
1723 | "Allow comparing MED from different neighbors\n") | |
1724 | { | |
d62a17ae | 1725 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1726 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1727 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1728 | |
d62a17ae | 1729 | return CMD_SUCCESS; |
718e3744 | 1730 | } |
1731 | ||
1732 | DEFUN (no_bgp_always_compare_med, | |
1733 | no_bgp_always_compare_med_cmd, | |
1734 | "no bgp always-compare-med", | |
1735 | NO_STR | |
1736 | "BGP specific commands\n" | |
1737 | "Allow comparing MED from different neighbors\n") | |
1738 | { | |
d62a17ae | 1739 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1740 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1741 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1742 | |
d62a17ae | 1743 | return CMD_SUCCESS; |
718e3744 | 1744 | } |
6b0655a2 | 1745 | |
718e3744 | 1746 | /* "bgp deterministic-med" configuration. */ |
1747 | DEFUN (bgp_deterministic_med, | |
1748 | bgp_deterministic_med_cmd, | |
1749 | "bgp deterministic-med", | |
1750 | "BGP specific commands\n" | |
1751 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1752 | { | |
d62a17ae | 1753 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 1754 | |
d62a17ae | 1755 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
1756 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1757 | bgp_recalculate_all_bestpaths(bgp); | |
1758 | } | |
7aafcaca | 1759 | |
d62a17ae | 1760 | return CMD_SUCCESS; |
718e3744 | 1761 | } |
1762 | ||
1763 | DEFUN (no_bgp_deterministic_med, | |
1764 | no_bgp_deterministic_med_cmd, | |
1765 | "no bgp deterministic-med", | |
1766 | NO_STR | |
1767 | "BGP specific commands\n" | |
1768 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1769 | { | |
d62a17ae | 1770 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1771 | int bestpath_per_as_used; | |
1772 | afi_t afi; | |
1773 | safi_t safi; | |
1774 | struct peer *peer; | |
1775 | struct listnode *node, *nnode; | |
1776 | ||
1777 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
1778 | bestpath_per_as_used = 0; | |
1779 | ||
1780 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc QY |
1781 | FOREACH_AFI_SAFI (afi, safi) |
1782 | if (CHECK_FLAG( | |
1783 | peer->af_flags[afi][safi], | |
1784 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) { | |
1785 | bestpath_per_as_used = 1; | |
1786 | break; | |
1787 | } | |
d62a17ae | 1788 | |
1789 | if (bestpath_per_as_used) | |
1790 | break; | |
1791 | } | |
1792 | ||
1793 | if (bestpath_per_as_used) { | |
1794 | vty_out(vty, | |
1795 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
1796 | return CMD_WARNING_CONFIG_FAILED; | |
1797 | } else { | |
1798 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1799 | bgp_recalculate_all_bestpaths(bgp); | |
1800 | } | |
1801 | } | |
1802 | ||
1803 | return CMD_SUCCESS; | |
718e3744 | 1804 | } |
538621f2 | 1805 | |
1806 | /* "bgp graceful-restart" configuration. */ | |
1807 | DEFUN (bgp_graceful_restart, | |
1808 | bgp_graceful_restart_cmd, | |
1809 | "bgp graceful-restart", | |
1810 | "BGP specific commands\n" | |
1811 | "Graceful restart capability parameters\n") | |
1812 | { | |
d62a17ae | 1813 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1814 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1815 | return CMD_SUCCESS; | |
538621f2 | 1816 | } |
1817 | ||
1818 | DEFUN (no_bgp_graceful_restart, | |
1819 | no_bgp_graceful_restart_cmd, | |
1820 | "no bgp graceful-restart", | |
1821 | NO_STR | |
1822 | "BGP specific commands\n" | |
1823 | "Graceful restart capability parameters\n") | |
1824 | { | |
d62a17ae | 1825 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1826 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1827 | return CMD_SUCCESS; | |
538621f2 | 1828 | } |
1829 | ||
93406d87 | 1830 | DEFUN (bgp_graceful_restart_stalepath_time, |
1831 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1832 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1833 | "BGP specific commands\n" |
1834 | "Graceful restart capability parameters\n" | |
1835 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1836 | "Delay value (seconds)\n") | |
1837 | { | |
d62a17ae | 1838 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1839 | int idx_number = 3; | |
d7c0a89a | 1840 | uint32_t stalepath; |
93406d87 | 1841 | |
d62a17ae | 1842 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
1843 | bgp->stalepath_time = stalepath; | |
1844 | return CMD_SUCCESS; | |
93406d87 | 1845 | } |
1846 | ||
eb6f1b41 PG |
1847 | DEFUN (bgp_graceful_restart_restart_time, |
1848 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1849 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1850 | "BGP specific commands\n" |
1851 | "Graceful restart capability parameters\n" | |
1852 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1853 | "Delay value (seconds)\n") | |
1854 | { | |
d62a17ae | 1855 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1856 | int idx_number = 3; | |
d7c0a89a | 1857 | uint32_t restart; |
eb6f1b41 | 1858 | |
d62a17ae | 1859 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
1860 | bgp->restart_time = restart; | |
1861 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1862 | } |
1863 | ||
93406d87 | 1864 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1865 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1866 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1867 | NO_STR |
1868 | "BGP specific commands\n" | |
1869 | "Graceful restart capability parameters\n" | |
838758ac DW |
1870 | "Set the max time to hold onto restarting peer's stale paths\n" |
1871 | "Delay value (seconds)\n") | |
93406d87 | 1872 | { |
d62a17ae | 1873 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1874 | |
d62a17ae | 1875 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
1876 | return CMD_SUCCESS; | |
93406d87 | 1877 | } |
1878 | ||
eb6f1b41 PG |
1879 | DEFUN (no_bgp_graceful_restart_restart_time, |
1880 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1881 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1882 | NO_STR |
1883 | "BGP specific commands\n" | |
1884 | "Graceful restart capability parameters\n" | |
838758ac DW |
1885 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1886 | "Delay value (seconds)\n") | |
eb6f1b41 | 1887 | { |
d62a17ae | 1888 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 1889 | |
d62a17ae | 1890 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
1891 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1892 | } |
1893 | ||
43fc21b3 JC |
1894 | DEFUN (bgp_graceful_restart_preserve_fw, |
1895 | bgp_graceful_restart_preserve_fw_cmd, | |
1896 | "bgp graceful-restart preserve-fw-state", | |
1897 | "BGP specific commands\n" | |
1898 | "Graceful restart capability parameters\n" | |
1899 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1900 | { | |
d62a17ae | 1901 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1902 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1903 | return CMD_SUCCESS; | |
43fc21b3 JC |
1904 | } |
1905 | ||
1906 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
1907 | no_bgp_graceful_restart_preserve_fw_cmd, | |
1908 | "no bgp graceful-restart preserve-fw-state", | |
1909 | NO_STR | |
1910 | "BGP specific commands\n" | |
1911 | "Graceful restart capability parameters\n" | |
1912 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1913 | { | |
d62a17ae | 1914 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1915 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1916 | return CMD_SUCCESS; | |
43fc21b3 JC |
1917 | } |
1918 | ||
7f323236 DW |
1919 | static void bgp_redistribute_redo(struct bgp *bgp) |
1920 | { | |
1921 | afi_t afi; | |
1922 | int i; | |
1923 | struct list *red_list; | |
1924 | struct listnode *node; | |
1925 | struct bgp_redist *red; | |
1926 | ||
a4d82a8a PZ |
1927 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { |
1928 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
7f323236 | 1929 | |
a4d82a8a PZ |
1930 | red_list = bgp->redist[afi][i]; |
1931 | if (!red_list) | |
1932 | continue; | |
7f323236 | 1933 | |
a4d82a8a | 1934 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { |
7f323236 DW |
1935 | bgp_redistribute_resend(bgp, afi, i, |
1936 | red->instance); | |
1937 | } | |
1938 | } | |
1939 | } | |
1940 | } | |
1941 | ||
1942 | /* "bgp graceful-shutdown" configuration */ | |
1943 | DEFUN (bgp_graceful_shutdown, | |
1944 | bgp_graceful_shutdown_cmd, | |
1945 | "bgp graceful-shutdown", | |
1946 | BGP_STR | |
1947 | "Graceful shutdown parameters\n") | |
1948 | { | |
1949 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1950 | ||
1951 | if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
1952 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
1953 | bgp_static_redo_import_check(bgp); | |
1954 | bgp_redistribute_redo(bgp); | |
1955 | bgp_clear_star_soft_out(vty, bgp->name); | |
1956 | bgp_clear_star_soft_in(vty, bgp->name); | |
1957 | } | |
1958 | ||
1959 | return CMD_SUCCESS; | |
1960 | } | |
1961 | ||
1962 | DEFUN (no_bgp_graceful_shutdown, | |
1963 | no_bgp_graceful_shutdown_cmd, | |
1964 | "no bgp graceful-shutdown", | |
1965 | NO_STR | |
1966 | BGP_STR | |
1967 | "Graceful shutdown parameters\n") | |
1968 | { | |
1969 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1970 | ||
1971 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
1972 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
1973 | bgp_static_redo_import_check(bgp); | |
1974 | bgp_redistribute_redo(bgp); | |
1975 | bgp_clear_star_soft_out(vty, bgp->name); | |
1976 | bgp_clear_star_soft_in(vty, bgp->name); | |
1977 | } | |
1978 | ||
1979 | return CMD_SUCCESS; | |
1980 | } | |
1981 | ||
718e3744 | 1982 | /* "bgp fast-external-failover" configuration. */ |
1983 | DEFUN (bgp_fast_external_failover, | |
1984 | bgp_fast_external_failover_cmd, | |
1985 | "bgp fast-external-failover", | |
1986 | BGP_STR | |
1987 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1988 | { | |
d62a17ae | 1989 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1990 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
1991 | return CMD_SUCCESS; | |
718e3744 | 1992 | } |
1993 | ||
1994 | DEFUN (no_bgp_fast_external_failover, | |
1995 | no_bgp_fast_external_failover_cmd, | |
1996 | "no bgp fast-external-failover", | |
1997 | NO_STR | |
1998 | BGP_STR | |
1999 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2000 | { | |
d62a17ae | 2001 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2002 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2003 | return CMD_SUCCESS; | |
718e3744 | 2004 | } |
6b0655a2 | 2005 | |
718e3744 | 2006 | /* "bgp enforce-first-as" configuration. */ |
2007 | DEFUN (bgp_enforce_first_as, | |
2008 | bgp_enforce_first_as_cmd, | |
2009 | "bgp enforce-first-as", | |
2010 | BGP_STR | |
2011 | "Enforce the first AS for EBGP routes\n") | |
2012 | { | |
d62a17ae | 2013 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2014 | bgp_flag_set(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
2015 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2016 | |
d62a17ae | 2017 | return CMD_SUCCESS; |
718e3744 | 2018 | } |
2019 | ||
2020 | DEFUN (no_bgp_enforce_first_as, | |
2021 | no_bgp_enforce_first_as_cmd, | |
2022 | "no bgp enforce-first-as", | |
2023 | NO_STR | |
2024 | BGP_STR | |
2025 | "Enforce the first AS for EBGP routes\n") | |
2026 | { | |
d62a17ae | 2027 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2028 | bgp_flag_unset(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
2029 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2030 | |
d62a17ae | 2031 | return CMD_SUCCESS; |
718e3744 | 2032 | } |
6b0655a2 | 2033 | |
718e3744 | 2034 | /* "bgp bestpath compare-routerid" configuration. */ |
2035 | DEFUN (bgp_bestpath_compare_router_id, | |
2036 | bgp_bestpath_compare_router_id_cmd, | |
2037 | "bgp bestpath compare-routerid", | |
2038 | "BGP specific commands\n" | |
2039 | "Change the default bestpath selection\n" | |
2040 | "Compare router-id for identical EBGP paths\n") | |
2041 | { | |
d62a17ae | 2042 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2043 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2044 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2045 | |
d62a17ae | 2046 | return CMD_SUCCESS; |
718e3744 | 2047 | } |
2048 | ||
2049 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2050 | no_bgp_bestpath_compare_router_id_cmd, | |
2051 | "no bgp bestpath compare-routerid", | |
2052 | NO_STR | |
2053 | "BGP specific commands\n" | |
2054 | "Change the default bestpath selection\n" | |
2055 | "Compare router-id for identical EBGP paths\n") | |
2056 | { | |
d62a17ae | 2057 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2058 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2059 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2060 | |
d62a17ae | 2061 | return CMD_SUCCESS; |
718e3744 | 2062 | } |
6b0655a2 | 2063 | |
718e3744 | 2064 | /* "bgp bestpath as-path ignore" configuration. */ |
2065 | DEFUN (bgp_bestpath_aspath_ignore, | |
2066 | bgp_bestpath_aspath_ignore_cmd, | |
2067 | "bgp bestpath as-path ignore", | |
2068 | "BGP specific commands\n" | |
2069 | "Change the default bestpath selection\n" | |
2070 | "AS-path attribute\n" | |
2071 | "Ignore as-path length in selecting a route\n") | |
2072 | { | |
d62a17ae | 2073 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2074 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2075 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2076 | |
d62a17ae | 2077 | return CMD_SUCCESS; |
718e3744 | 2078 | } |
2079 | ||
2080 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2081 | no_bgp_bestpath_aspath_ignore_cmd, | |
2082 | "no bgp bestpath as-path ignore", | |
2083 | NO_STR | |
2084 | "BGP specific commands\n" | |
2085 | "Change the default bestpath selection\n" | |
2086 | "AS-path attribute\n" | |
2087 | "Ignore as-path length in selecting a route\n") | |
2088 | { | |
d62a17ae | 2089 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2090 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2091 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2092 | |
d62a17ae | 2093 | return CMD_SUCCESS; |
718e3744 | 2094 | } |
6b0655a2 | 2095 | |
6811845b | 2096 | /* "bgp bestpath as-path confed" configuration. */ |
2097 | DEFUN (bgp_bestpath_aspath_confed, | |
2098 | bgp_bestpath_aspath_confed_cmd, | |
2099 | "bgp bestpath as-path confed", | |
2100 | "BGP specific commands\n" | |
2101 | "Change the default bestpath selection\n" | |
2102 | "AS-path attribute\n" | |
2103 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2104 | { | |
d62a17ae | 2105 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2106 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
2107 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2108 | |
d62a17ae | 2109 | return CMD_SUCCESS; |
6811845b | 2110 | } |
2111 | ||
2112 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2113 | no_bgp_bestpath_aspath_confed_cmd, | |
2114 | "no bgp bestpath as-path confed", | |
2115 | NO_STR | |
2116 | "BGP specific commands\n" | |
2117 | "Change the default bestpath selection\n" | |
2118 | "AS-path attribute\n" | |
2119 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2120 | { | |
d62a17ae | 2121 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2122 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
2123 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2124 | |
d62a17ae | 2125 | return CMD_SUCCESS; |
6811845b | 2126 | } |
6b0655a2 | 2127 | |
2fdd455c PM |
2128 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2129 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2130 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2131 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2132 | "BGP specific commands\n" |
2133 | "Change the default bestpath selection\n" | |
2134 | "AS-path attribute\n" | |
2135 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2136 | "Generate an AS_SET\n" |
16fc1eec DS |
2137 | "Do not generate an AS_SET\n") |
2138 | { | |
d62a17ae | 2139 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2140 | int idx = 0; | |
2141 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 2142 | |
d62a17ae | 2143 | /* no-as-set is now the default behavior so we can silently |
2144 | * ignore it */ | |
2145 | if (argv_find(argv, argc, "as-set", &idx)) | |
2146 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2147 | else | |
2148 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 2149 | |
d62a17ae | 2150 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2151 | |
d62a17ae | 2152 | return CMD_SUCCESS; |
16fc1eec DS |
2153 | } |
2154 | ||
219178b6 DW |
2155 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2156 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2157 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2158 | NO_STR |
2159 | "BGP specific commands\n" | |
2160 | "Change the default bestpath selection\n" | |
2161 | "AS-path attribute\n" | |
2162 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2163 | "Generate an AS_SET\n" |
16fc1eec DS |
2164 | "Do not generate an AS_SET\n") |
2165 | { | |
d62a17ae | 2166 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2167 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
2168 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2169 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2170 | |
d62a17ae | 2171 | return CMD_SUCCESS; |
2fdd455c | 2172 | } |
6b0655a2 | 2173 | |
848973c7 | 2174 | /* "bgp log-neighbor-changes" configuration. */ |
2175 | DEFUN (bgp_log_neighbor_changes, | |
2176 | bgp_log_neighbor_changes_cmd, | |
2177 | "bgp log-neighbor-changes", | |
2178 | "BGP specific commands\n" | |
2179 | "Log neighbor up/down and reset reason\n") | |
2180 | { | |
d62a17ae | 2181 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2182 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2183 | return CMD_SUCCESS; | |
848973c7 | 2184 | } |
2185 | ||
2186 | DEFUN (no_bgp_log_neighbor_changes, | |
2187 | no_bgp_log_neighbor_changes_cmd, | |
2188 | "no bgp log-neighbor-changes", | |
2189 | NO_STR | |
2190 | "BGP specific commands\n" | |
2191 | "Log neighbor up/down and reset reason\n") | |
2192 | { | |
d62a17ae | 2193 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2194 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2195 | return CMD_SUCCESS; | |
848973c7 | 2196 | } |
6b0655a2 | 2197 | |
718e3744 | 2198 | /* "bgp bestpath med" configuration. */ |
2199 | DEFUN (bgp_bestpath_med, | |
2200 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2201 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2202 | "BGP specific commands\n" |
2203 | "Change the default bestpath selection\n" | |
2204 | "MED attribute\n" | |
2205 | "Compare MED among confederation paths\n" | |
838758ac DW |
2206 | "Treat missing MED as the least preferred one\n" |
2207 | "Treat missing MED as the least preferred one\n" | |
2208 | "Compare MED among confederation paths\n") | |
718e3744 | 2209 | { |
d62a17ae | 2210 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2211 | |
d62a17ae | 2212 | int idx = 0; |
2213 | if (argv_find(argv, argc, "confed", &idx)) | |
2214 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2215 | idx = 0; | |
2216 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2217 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2218 | |
d62a17ae | 2219 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2220 | |
d62a17ae | 2221 | return CMD_SUCCESS; |
718e3744 | 2222 | } |
2223 | ||
718e3744 | 2224 | DEFUN (no_bgp_bestpath_med, |
2225 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2226 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2227 | NO_STR |
2228 | "BGP specific commands\n" | |
2229 | "Change the default bestpath selection\n" | |
2230 | "MED attribute\n" | |
2231 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2232 | "Treat missing MED as the least preferred one\n" |
2233 | "Treat missing MED as the least preferred one\n" | |
2234 | "Compare MED among confederation paths\n") | |
718e3744 | 2235 | { |
d62a17ae | 2236 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2237 | |
d62a17ae | 2238 | int idx = 0; |
2239 | if (argv_find(argv, argc, "confed", &idx)) | |
2240 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2241 | idx = 0; | |
2242 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2243 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2244 | |
d62a17ae | 2245 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2246 | |
d62a17ae | 2247 | return CMD_SUCCESS; |
718e3744 | 2248 | } |
2249 | ||
718e3744 | 2250 | /* "no bgp default ipv4-unicast". */ |
2251 | DEFUN (no_bgp_default_ipv4_unicast, | |
2252 | no_bgp_default_ipv4_unicast_cmd, | |
2253 | "no bgp default ipv4-unicast", | |
2254 | NO_STR | |
2255 | "BGP specific commands\n" | |
2256 | "Configure BGP defaults\n" | |
2257 | "Activate ipv4-unicast for a peer by default\n") | |
2258 | { | |
d62a17ae | 2259 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2260 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2261 | return CMD_SUCCESS; | |
718e3744 | 2262 | } |
2263 | ||
2264 | DEFUN (bgp_default_ipv4_unicast, | |
2265 | bgp_default_ipv4_unicast_cmd, | |
2266 | "bgp default ipv4-unicast", | |
2267 | "BGP specific commands\n" | |
2268 | "Configure BGP defaults\n" | |
2269 | "Activate ipv4-unicast for a peer by default\n") | |
2270 | { | |
d62a17ae | 2271 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2272 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2273 | return CMD_SUCCESS; | |
718e3744 | 2274 | } |
6b0655a2 | 2275 | |
04b6bdc0 DW |
2276 | /* Display hostname in certain command outputs */ |
2277 | DEFUN (bgp_default_show_hostname, | |
2278 | bgp_default_show_hostname_cmd, | |
2279 | "bgp default show-hostname", | |
2280 | "BGP specific commands\n" | |
2281 | "Configure BGP defaults\n" | |
2282 | "Show hostname in certain command ouputs\n") | |
2283 | { | |
d62a17ae | 2284 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2285 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2286 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2287 | } |
2288 | ||
2289 | DEFUN (no_bgp_default_show_hostname, | |
2290 | no_bgp_default_show_hostname_cmd, | |
2291 | "no bgp default show-hostname", | |
2292 | NO_STR | |
2293 | "BGP specific commands\n" | |
2294 | "Configure BGP defaults\n" | |
2295 | "Show hostname in certain command ouputs\n") | |
2296 | { | |
d62a17ae | 2297 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2298 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2299 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2300 | } |
2301 | ||
8233ef81 | 2302 | /* "bgp network import-check" configuration. */ |
718e3744 | 2303 | DEFUN (bgp_network_import_check, |
2304 | bgp_network_import_check_cmd, | |
5623e905 | 2305 | "bgp network import-check", |
718e3744 | 2306 | "BGP specific commands\n" |
2307 | "BGP network command\n" | |
5623e905 | 2308 | "Check BGP network route exists in IGP\n") |
718e3744 | 2309 | { |
d62a17ae | 2310 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2311 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2312 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
2313 | bgp_static_redo_import_check(bgp); | |
2314 | } | |
078430f6 | 2315 | |
d62a17ae | 2316 | return CMD_SUCCESS; |
718e3744 | 2317 | } |
2318 | ||
d62a17ae | 2319 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
2320 | "bgp network import-check exact", | |
2321 | "BGP specific commands\n" | |
2322 | "BGP network command\n" | |
2323 | "Check BGP network route exists in IGP\n" | |
2324 | "Match route precisely\n") | |
8233ef81 | 2325 | |
718e3744 | 2326 | DEFUN (no_bgp_network_import_check, |
2327 | no_bgp_network_import_check_cmd, | |
5623e905 | 2328 | "no bgp network import-check", |
718e3744 | 2329 | NO_STR |
2330 | "BGP specific commands\n" | |
2331 | "BGP network command\n" | |
2332 | "Check BGP network route exists in IGP\n") | |
2333 | { | |
d62a17ae | 2334 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2335 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2336 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
2337 | bgp_static_redo_import_check(bgp); | |
2338 | } | |
5623e905 | 2339 | |
d62a17ae | 2340 | return CMD_SUCCESS; |
718e3744 | 2341 | } |
6b0655a2 | 2342 | |
718e3744 | 2343 | DEFUN (bgp_default_local_preference, |
2344 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2345 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2346 | "BGP specific commands\n" |
2347 | "Configure BGP defaults\n" | |
2348 | "local preference (higher=more preferred)\n" | |
2349 | "Configure default local preference value\n") | |
2350 | { | |
d62a17ae | 2351 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2352 | int idx_number = 3; | |
d7c0a89a | 2353 | uint32_t local_pref; |
718e3744 | 2354 | |
d62a17ae | 2355 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2356 | |
d62a17ae | 2357 | bgp_default_local_preference_set(bgp, local_pref); |
2358 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 2359 | |
d62a17ae | 2360 | return CMD_SUCCESS; |
718e3744 | 2361 | } |
2362 | ||
2363 | DEFUN (no_bgp_default_local_preference, | |
2364 | no_bgp_default_local_preference_cmd, | |
838758ac | 2365 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2366 | NO_STR |
2367 | "BGP specific commands\n" | |
2368 | "Configure BGP defaults\n" | |
838758ac DW |
2369 | "local preference (higher=more preferred)\n" |
2370 | "Configure default local preference value\n") | |
718e3744 | 2371 | { |
d62a17ae | 2372 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2373 | bgp_default_local_preference_unset(bgp); | |
2374 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2375 | |
d62a17ae | 2376 | return CMD_SUCCESS; |
718e3744 | 2377 | } |
2378 | ||
6b0655a2 | 2379 | |
3f9c7369 DS |
2380 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2381 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2382 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2383 | "BGP specific commands\n" |
2384 | "Configure BGP defaults\n" | |
2385 | "subgroup-pkt-queue-max\n" | |
2386 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2387 | { |
d62a17ae | 2388 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2389 | int idx_number = 3; | |
d7c0a89a | 2390 | uint32_t max_size; |
8bd9d948 | 2391 | |
d62a17ae | 2392 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 2393 | |
d62a17ae | 2394 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 2395 | |
d62a17ae | 2396 | return CMD_SUCCESS; |
3f9c7369 DS |
2397 | } |
2398 | ||
2399 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2400 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2401 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2402 | NO_STR |
2403 | "BGP specific commands\n" | |
2404 | "Configure BGP defaults\n" | |
838758ac DW |
2405 | "subgroup-pkt-queue-max\n" |
2406 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2407 | { |
d62a17ae | 2408 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2409 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
2410 | return CMD_SUCCESS; | |
8bd9d948 DS |
2411 | } |
2412 | ||
813d4307 | 2413 | |
8bd9d948 DS |
2414 | DEFUN (bgp_rr_allow_outbound_policy, |
2415 | bgp_rr_allow_outbound_policy_cmd, | |
2416 | "bgp route-reflector allow-outbound-policy", | |
2417 | "BGP specific commands\n" | |
2418 | "Allow modifications made by out route-map\n" | |
2419 | "on ibgp neighbors\n") | |
2420 | { | |
d62a17ae | 2421 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2422 | |
d62a17ae | 2423 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2424 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2425 | update_group_announce_rrclients(bgp); | |
2426 | bgp_clear_star_soft_out(vty, bgp->name); | |
2427 | } | |
8bd9d948 | 2428 | |
d62a17ae | 2429 | return CMD_SUCCESS; |
8bd9d948 DS |
2430 | } |
2431 | ||
2432 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2433 | no_bgp_rr_allow_outbound_policy_cmd, | |
2434 | "no bgp route-reflector allow-outbound-policy", | |
2435 | NO_STR | |
2436 | "BGP specific commands\n" | |
2437 | "Allow modifications made by out route-map\n" | |
2438 | "on ibgp neighbors\n") | |
2439 | { | |
d62a17ae | 2440 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2441 | |
d62a17ae | 2442 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2443 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2444 | update_group_announce_rrclients(bgp); | |
2445 | bgp_clear_star_soft_out(vty, bgp->name); | |
2446 | } | |
8bd9d948 | 2447 | |
d62a17ae | 2448 | return CMD_SUCCESS; |
8bd9d948 DS |
2449 | } |
2450 | ||
f14e6fdb DS |
2451 | DEFUN (bgp_listen_limit, |
2452 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2453 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2454 | "BGP specific commands\n" |
2455 | "Configure BGP defaults\n" | |
2456 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2457 | "Configure Dynamic Neighbors listen limit value\n") | |
2458 | { | |
d62a17ae | 2459 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2460 | int idx_number = 3; | |
2461 | int listen_limit; | |
f14e6fdb | 2462 | |
d62a17ae | 2463 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 2464 | |
d62a17ae | 2465 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 2466 | |
d62a17ae | 2467 | return CMD_SUCCESS; |
f14e6fdb DS |
2468 | } |
2469 | ||
2470 | DEFUN (no_bgp_listen_limit, | |
2471 | no_bgp_listen_limit_cmd, | |
838758ac | 2472 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2473 | "BGP specific commands\n" |
2474 | "Configure BGP defaults\n" | |
2475 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2476 | "Configure Dynamic Neighbors listen limit value to default\n" |
2477 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2478 | { |
d62a17ae | 2479 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2480 | bgp_listen_limit_unset(bgp); | |
2481 | return CMD_SUCCESS; | |
f14e6fdb DS |
2482 | } |
2483 | ||
2484 | ||
20eb8864 | 2485 | /* |
2486 | * Check if this listen range is already configured. Check for exact | |
2487 | * match or overlap based on input. | |
2488 | */ | |
d62a17ae | 2489 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
2490 | struct prefix *range, int exact) | |
2491 | { | |
2492 | struct listnode *node, *nnode; | |
2493 | struct listnode *node1, *nnode1; | |
2494 | struct peer_group *group; | |
2495 | struct prefix *lr; | |
2496 | afi_t afi; | |
2497 | int match; | |
2498 | ||
2499 | afi = family2afi(range->family); | |
2500 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2501 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
2502 | lr)) { | |
2503 | if (exact) | |
2504 | match = prefix_same(range, lr); | |
2505 | else | |
2506 | match = (prefix_match(range, lr) | |
2507 | || prefix_match(lr, range)); | |
2508 | if (match) | |
2509 | return group; | |
2510 | } | |
2511 | } | |
2512 | ||
2513 | return NULL; | |
20eb8864 | 2514 | } |
2515 | ||
f14e6fdb DS |
2516 | DEFUN (bgp_listen_range, |
2517 | bgp_listen_range_cmd, | |
9ccf14f7 | 2518 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2519 | "BGP specific commands\n" |
d7fa34c1 QY |
2520 | "Configure BGP dynamic neighbors listen range\n" |
2521 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2522 | NEIGHBOR_ADDR_STR |
2523 | "Member of the peer-group\n" | |
2524 | "Peer-group name\n") | |
f14e6fdb | 2525 | { |
d62a17ae | 2526 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2527 | struct prefix range; | |
2528 | struct peer_group *group, *existing_group; | |
2529 | afi_t afi; | |
2530 | int ret; | |
2531 | int idx = 0; | |
2532 | ||
2533 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2534 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2535 | char *prefix = argv[idx]->arg; | |
2536 | argv_find(argv, argc, "WORD", &idx); | |
2537 | char *peergroup = argv[idx]->arg; | |
2538 | ||
2539 | /* Convert IP prefix string to struct prefix. */ | |
2540 | ret = str2prefix(prefix, &range); | |
2541 | if (!ret) { | |
2542 | vty_out(vty, "%% Malformed listen range\n"); | |
2543 | return CMD_WARNING_CONFIG_FAILED; | |
2544 | } | |
2545 | ||
2546 | afi = family2afi(range.family); | |
2547 | ||
2548 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2549 | vty_out(vty, | |
2550 | "%% Malformed listen range (link-local address)\n"); | |
2551 | return CMD_WARNING_CONFIG_FAILED; | |
2552 | } | |
2553 | ||
2554 | apply_mask(&range); | |
2555 | ||
2556 | /* Check if same listen range is already configured. */ | |
2557 | existing_group = listen_range_exists(bgp, &range, 1); | |
2558 | if (existing_group) { | |
2559 | if (strcmp(existing_group->name, peergroup) == 0) | |
2560 | return CMD_SUCCESS; | |
2561 | else { | |
2562 | vty_out(vty, | |
2563 | "%% Same listen range is attached to peer-group %s\n", | |
2564 | existing_group->name); | |
2565 | return CMD_WARNING_CONFIG_FAILED; | |
2566 | } | |
2567 | } | |
2568 | ||
2569 | /* Check if an overlapping listen range exists. */ | |
2570 | if (listen_range_exists(bgp, &range, 0)) { | |
2571 | vty_out(vty, | |
2572 | "%% Listen range overlaps with existing listen range\n"); | |
2573 | return CMD_WARNING_CONFIG_FAILED; | |
2574 | } | |
2575 | ||
2576 | group = peer_group_lookup(bgp, peergroup); | |
2577 | if (!group) { | |
2578 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2579 | return CMD_WARNING_CONFIG_FAILED; | |
2580 | } | |
2581 | ||
2582 | ret = peer_group_listen_range_add(group, &range); | |
2583 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
2584 | } |
2585 | ||
2586 | DEFUN (no_bgp_listen_range, | |
2587 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2588 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2589 | NO_STR | |
f14e6fdb | 2590 | "BGP specific commands\n" |
d7fa34c1 QY |
2591 | "Unconfigure BGP dynamic neighbors listen range\n" |
2592 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2593 | NEIGHBOR_ADDR_STR | |
2594 | "Member of the peer-group\n" | |
2595 | "Peer-group name\n") | |
f14e6fdb | 2596 | { |
d62a17ae | 2597 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2598 | struct prefix range; | |
2599 | struct peer_group *group; | |
2600 | afi_t afi; | |
2601 | int ret; | |
2602 | int idx = 0; | |
2603 | ||
2604 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2605 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2606 | char *prefix = argv[idx]->arg; | |
2607 | argv_find(argv, argc, "WORD", &idx); | |
2608 | char *peergroup = argv[idx]->arg; | |
2609 | ||
2610 | /* Convert IP prefix string to struct prefix. */ | |
2611 | ret = str2prefix(prefix, &range); | |
2612 | if (!ret) { | |
2613 | vty_out(vty, "%% Malformed listen range\n"); | |
2614 | return CMD_WARNING_CONFIG_FAILED; | |
2615 | } | |
2616 | ||
2617 | afi = family2afi(range.family); | |
2618 | ||
2619 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2620 | vty_out(vty, | |
2621 | "%% Malformed listen range (link-local address)\n"); | |
2622 | return CMD_WARNING_CONFIG_FAILED; | |
2623 | } | |
2624 | ||
2625 | apply_mask(&range); | |
2626 | ||
2627 | group = peer_group_lookup(bgp, peergroup); | |
2628 | if (!group) { | |
2629 | vty_out(vty, "%% Peer-group does not exist\n"); | |
2630 | return CMD_WARNING_CONFIG_FAILED; | |
2631 | } | |
2632 | ||
2633 | ret = peer_group_listen_range_del(group, &range); | |
2634 | return bgp_vty_return(vty, ret); | |
2635 | } | |
2636 | ||
2b791107 | 2637 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 2638 | { |
2639 | struct peer_group *group; | |
2640 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2641 | struct prefix *range; | |
2642 | afi_t afi; | |
2643 | char buf[PREFIX2STR_BUFFER]; | |
2644 | ||
2645 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2646 | vty_out(vty, " bgp listen limit %d\n", | |
2647 | bgp->dynamic_neighbors_limit); | |
2648 | ||
2649 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2650 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
2651 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
2652 | nrnode, range)) { | |
2653 | prefix2str(range, buf, sizeof(buf)); | |
2654 | vty_out(vty, | |
2655 | " bgp listen range %s peer-group %s\n", | |
2656 | buf, group->name); | |
2657 | } | |
2658 | } | |
2659 | } | |
f14e6fdb DS |
2660 | } |
2661 | ||
2662 | ||
907f92c8 DS |
2663 | DEFUN (bgp_disable_connected_route_check, |
2664 | bgp_disable_connected_route_check_cmd, | |
2665 | "bgp disable-ebgp-connected-route-check", | |
2666 | "BGP specific commands\n" | |
2667 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2668 | { | |
d62a17ae | 2669 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2670 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2671 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2672 | |
d62a17ae | 2673 | return CMD_SUCCESS; |
907f92c8 DS |
2674 | } |
2675 | ||
2676 | DEFUN (no_bgp_disable_connected_route_check, | |
2677 | no_bgp_disable_connected_route_check_cmd, | |
2678 | "no bgp disable-ebgp-connected-route-check", | |
2679 | NO_STR | |
2680 | "BGP specific commands\n" | |
2681 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2682 | { | |
d62a17ae | 2683 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2684 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2685 | bgp_clear_star_soft_in(vty, bgp->name); | |
2686 | ||
2687 | return CMD_SUCCESS; | |
2688 | } | |
2689 | ||
2690 | ||
2691 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
2692 | const char *as_str, afi_t afi, safi_t safi) | |
2693 | { | |
2694 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2695 | int ret; | |
2696 | as_t as; | |
2697 | int as_type = AS_SPECIFIED; | |
2698 | union sockunion su; | |
2699 | ||
2700 | if (as_str[0] == 'i') { | |
2701 | as = 0; | |
2702 | as_type = AS_INTERNAL; | |
2703 | } else if (as_str[0] == 'e') { | |
2704 | as = 0; | |
2705 | as_type = AS_EXTERNAL; | |
2706 | } else { | |
2707 | /* Get AS number. */ | |
2708 | as = strtoul(as_str, NULL, 10); | |
2709 | } | |
2710 | ||
2711 | /* If peer is peer group, call proper function. */ | |
2712 | ret = str2sockunion(peer_str, &su); | |
2713 | if (ret < 0) { | |
2714 | /* Check for peer by interface */ | |
2715 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, | |
2716 | safi); | |
2717 | if (ret < 0) { | |
2718 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); | |
2719 | if (ret < 0) { | |
2720 | vty_out(vty, | |
2721 | "%% Create the peer-group or interface first\n"); | |
2722 | return CMD_WARNING_CONFIG_FAILED; | |
2723 | } | |
2724 | return CMD_SUCCESS; | |
2725 | } | |
2726 | } else { | |
2727 | if (peer_address_self_check(bgp, &su)) { | |
2728 | vty_out(vty, | |
2729 | "%% Can not configure the local system as neighbor\n"); | |
2730 | return CMD_WARNING_CONFIG_FAILED; | |
2731 | } | |
2732 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
2733 | } | |
2734 | ||
2735 | /* This peer belongs to peer group. */ | |
2736 | switch (ret) { | |
2737 | case BGP_ERR_PEER_GROUP_MEMBER: | |
2738 | vty_out(vty, | |
2739 | "%% Peer-group AS %u. Cannot configure remote-as for member\n", | |
2740 | as); | |
2741 | return CMD_WARNING_CONFIG_FAILED; | |
2742 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
2743 | vty_out(vty, | |
2744 | "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n", | |
2745 | as, as_str); | |
2746 | return CMD_WARNING_CONFIG_FAILED; | |
2747 | } | |
2748 | return bgp_vty_return(vty, ret); | |
718e3744 | 2749 | } |
2750 | ||
f26845f9 QY |
2751 | DEFUN (bgp_default_shutdown, |
2752 | bgp_default_shutdown_cmd, | |
2753 | "[no] bgp default shutdown", | |
2754 | NO_STR | |
2755 | BGP_STR | |
2756 | "Configure BGP defaults\n" | |
b012cbe2 | 2757 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
2758 | { |
2759 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2760 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
2761 | return CMD_SUCCESS; | |
2762 | } | |
2763 | ||
718e3744 | 2764 | DEFUN (neighbor_remote_as, |
2765 | neighbor_remote_as_cmd, | |
3a2d747c | 2766 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2767 | NEIGHBOR_STR |
2768 | NEIGHBOR_ADDR_STR2 | |
2769 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2770 | AS_STR |
3a2d747c QY |
2771 | "Internal BGP peer\n" |
2772 | "External BGP peer\n") | |
718e3744 | 2773 | { |
d62a17ae | 2774 | int idx_peer = 1; |
2775 | int idx_remote_as = 3; | |
2776 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
2777 | argv[idx_remote_as]->arg, AFI_IP, | |
2778 | SAFI_UNICAST); | |
2779 | } | |
2780 | ||
2781 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
2782 | afi_t afi, safi_t safi, int v6only, | |
2783 | const char *peer_group_name, | |
2784 | const char *as_str) | |
2785 | { | |
2786 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2787 | as_t as = 0; | |
2788 | int as_type = AS_UNSPECIFIED; | |
2789 | struct peer *peer; | |
2790 | struct peer_group *group; | |
2791 | int ret = 0; | |
2792 | union sockunion su; | |
2793 | ||
2794 | group = peer_group_lookup(bgp, conf_if); | |
2795 | ||
2796 | if (group) { | |
2797 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
2798 | return CMD_WARNING_CONFIG_FAILED; | |
2799 | } | |
2800 | ||
2801 | if (as_str) { | |
2802 | if (as_str[0] == 'i') { | |
2803 | as_type = AS_INTERNAL; | |
2804 | } else if (as_str[0] == 'e') { | |
2805 | as_type = AS_EXTERNAL; | |
2806 | } else { | |
2807 | /* Get AS number. */ | |
2808 | as = strtoul(as_str, NULL, 10); | |
2809 | as_type = AS_SPECIFIED; | |
2810 | } | |
2811 | } | |
2812 | ||
2813 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
2814 | if (peer) { | |
2815 | if (as_str) | |
2816 | ret = peer_remote_as(bgp, &su, conf_if, &as, as_type, | |
2817 | afi, safi); | |
2818 | } else { | |
2819 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2820 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
2821 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2822 | as_type, 0, 0, NULL); | |
2823 | else | |
2824 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2825 | as_type, afi, safi, NULL); | |
2826 | ||
2827 | if (!peer) { | |
2828 | vty_out(vty, "%% BGP failed to create peer\n"); | |
2829 | return CMD_WARNING_CONFIG_FAILED; | |
2830 | } | |
2831 | ||
2832 | if (v6only) | |
2833 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2834 | ||
2835 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
2836 | * this | |
2837 | * any unnumbered peer in order to not worry about run-time | |
2838 | * transitions | |
2839 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
2840 | * address | |
2841 | * gets deleted later etc.) | |
2842 | */ | |
2843 | if (peer->ifp) | |
2844 | bgp_zebra_initiate_radv(bgp, peer); | |
2845 | } | |
2846 | ||
2847 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
2848 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
2849 | if (v6only) | |
2850 | SET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2851 | else | |
2852 | UNSET_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY); | |
2853 | ||
2854 | /* v6only flag changed. Reset bgp seesion */ | |
2855 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2856 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2857 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2858 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2859 | } else | |
2860 | bgp_session_reset(peer); | |
2861 | } | |
2862 | ||
2863 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE)) | |
2864 | peer_flag_set(peer, PEER_FLAG_CAPABILITY_ENHE); | |
2865 | ||
2866 | if (peer_group_name) { | |
2867 | group = peer_group_lookup(bgp, peer_group_name); | |
2868 | if (!group) { | |
2869 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2870 | return CMD_WARNING_CONFIG_FAILED; | |
2871 | } | |
2872 | ||
2873 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
2874 | } | |
2875 | ||
2876 | return bgp_vty_return(vty, ret); | |
a80beece DS |
2877 | } |
2878 | ||
4c48cf63 DW |
2879 | DEFUN (neighbor_interface_config, |
2880 | neighbor_interface_config_cmd, | |
31500417 | 2881 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2882 | NEIGHBOR_STR |
2883 | "Interface name or neighbor tag\n" | |
31500417 DW |
2884 | "Enable BGP on interface\n" |
2885 | "Member of the peer-group\n" | |
16cedbb0 | 2886 | "Peer-group name\n") |
4c48cf63 | 2887 | { |
d62a17ae | 2888 | int idx_word = 1; |
2889 | int idx_peer_group_word = 4; | |
31500417 | 2890 | |
d62a17ae | 2891 | if (argc > idx_peer_group_word) |
2892 | return peer_conf_interface_get( | |
2893 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2894 | argv[idx_peer_group_word]->arg, NULL); | |
2895 | else | |
2896 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2897 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
2898 | } |
2899 | ||
4c48cf63 DW |
2900 | DEFUN (neighbor_interface_config_v6only, |
2901 | neighbor_interface_config_v6only_cmd, | |
31500417 | 2902 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
2903 | NEIGHBOR_STR |
2904 | "Interface name or neighbor tag\n" | |
2905 | "Enable BGP on interface\n" | |
31500417 DW |
2906 | "Enable BGP with v6 link-local only\n" |
2907 | "Member of the peer-group\n" | |
16cedbb0 | 2908 | "Peer-group name\n") |
4c48cf63 | 2909 | { |
d62a17ae | 2910 | int idx_word = 1; |
2911 | int idx_peer_group_word = 5; | |
31500417 | 2912 | |
d62a17ae | 2913 | if (argc > idx_peer_group_word) |
2914 | return peer_conf_interface_get( | |
2915 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2916 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 2917 | |
d62a17ae | 2918 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
2919 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
2920 | } |
2921 | ||
a80beece | 2922 | |
b3a39dc5 DD |
2923 | DEFUN (neighbor_interface_config_remote_as, |
2924 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2925 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2926 | NEIGHBOR_STR |
2927 | "Interface name or neighbor tag\n" | |
2928 | "Enable BGP on interface\n" | |
3a2d747c | 2929 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2930 | AS_STR |
3a2d747c QY |
2931 | "Internal BGP peer\n" |
2932 | "External BGP peer\n") | |
b3a39dc5 | 2933 | { |
d62a17ae | 2934 | int idx_word = 1; |
2935 | int idx_remote_as = 4; | |
2936 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2937 | SAFI_UNICAST, 0, NULL, | |
2938 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2939 | } |
2940 | ||
2941 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
2942 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 2943 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2944 | NEIGHBOR_STR |
2945 | "Interface name or neighbor tag\n" | |
3a2d747c | 2946 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 2947 | "Enable BGP on interface\n" |
3a2d747c | 2948 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2949 | AS_STR |
3a2d747c QY |
2950 | "Internal BGP peer\n" |
2951 | "External BGP peer\n") | |
b3a39dc5 | 2952 | { |
d62a17ae | 2953 | int idx_word = 1; |
2954 | int idx_remote_as = 5; | |
2955 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2956 | SAFI_UNICAST, 1, NULL, | |
2957 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2958 | } |
2959 | ||
718e3744 | 2960 | DEFUN (neighbor_peer_group, |
2961 | neighbor_peer_group_cmd, | |
2962 | "neighbor WORD peer-group", | |
2963 | NEIGHBOR_STR | |
a80beece | 2964 | "Interface name or neighbor tag\n" |
718e3744 | 2965 | "Configure peer-group\n") |
2966 | { | |
d62a17ae | 2967 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2968 | int idx_word = 1; | |
2969 | struct peer *peer; | |
2970 | struct peer_group *group; | |
718e3744 | 2971 | |
d62a17ae | 2972 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
2973 | if (peer) { | |
2974 | vty_out(vty, "%% Name conflict with interface: \n"); | |
2975 | return CMD_WARNING_CONFIG_FAILED; | |
2976 | } | |
718e3744 | 2977 | |
d62a17ae | 2978 | group = peer_group_get(bgp, argv[idx_word]->arg); |
2979 | if (!group) { | |
2980 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
2981 | return CMD_WARNING_CONFIG_FAILED; | |
2982 | } | |
718e3744 | 2983 | |
d62a17ae | 2984 | return CMD_SUCCESS; |
718e3744 | 2985 | } |
2986 | ||
2987 | DEFUN (no_neighbor, | |
2988 | no_neighbor_cmd, | |
dab8cd00 | 2989 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 2990 | NO_STR |
2991 | NEIGHBOR_STR | |
3a2d747c QY |
2992 | NEIGHBOR_ADDR_STR2 |
2993 | "Specify a BGP neighbor\n" | |
2994 | AS_STR | |
2995 | "Internal BGP peer\n" | |
2996 | "External BGP peer\n") | |
718e3744 | 2997 | { |
d62a17ae | 2998 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2999 | int idx_peer = 2; | |
3000 | int ret; | |
3001 | union sockunion su; | |
3002 | struct peer_group *group; | |
3003 | struct peer *peer; | |
3004 | struct peer *other; | |
3005 | ||
3006 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3007 | if (ret < 0) { | |
3008 | /* look up for neighbor by interface name config. */ | |
3009 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3010 | if (peer) { | |
3011 | /* Request zebra to terminate IPv6 RAs on this | |
3012 | * interface. */ | |
3013 | if (peer->ifp) | |
3014 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3015 | peer_delete(peer); | |
3016 | return CMD_SUCCESS; | |
3017 | } | |
f14e6fdb | 3018 | |
d62a17ae | 3019 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
3020 | if (group) | |
3021 | peer_group_delete(group); | |
3022 | else { | |
3023 | vty_out(vty, "%% Create the peer-group first\n"); | |
3024 | return CMD_WARNING_CONFIG_FAILED; | |
3025 | } | |
3026 | } else { | |
3027 | peer = peer_lookup(bgp, &su); | |
3028 | if (peer) { | |
3029 | if (peer_dynamic_neighbor(peer)) { | |
3030 | vty_out(vty, | |
3031 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3032 | return CMD_WARNING_CONFIG_FAILED; | |
3033 | } | |
3034 | ||
3035 | other = peer->doppelganger; | |
3036 | peer_delete(peer); | |
3037 | if (other && other->status != Deleted) | |
3038 | peer_delete(other); | |
3039 | } | |
1ff9a340 | 3040 | } |
718e3744 | 3041 | |
d62a17ae | 3042 | return CMD_SUCCESS; |
718e3744 | 3043 | } |
3044 | ||
a80beece DS |
3045 | DEFUN (no_neighbor_interface_config, |
3046 | no_neighbor_interface_config_cmd, | |
31500417 | 3047 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3048 | NO_STR |
3049 | NEIGHBOR_STR | |
3050 | "Interface name\n" | |
31500417 DW |
3051 | "Configure BGP on interface\n" |
3052 | "Enable BGP with v6 link-local only\n" | |
3053 | "Member of the peer-group\n" | |
16cedbb0 | 3054 | "Peer-group name\n" |
3a2d747c QY |
3055 | "Specify a BGP neighbor\n" |
3056 | AS_STR | |
3057 | "Internal BGP peer\n" | |
3058 | "External BGP peer\n") | |
a80beece | 3059 | { |
d62a17ae | 3060 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3061 | int idx_word = 2; | |
3062 | struct peer *peer; | |
3063 | ||
3064 | /* look up for neighbor by interface name config. */ | |
3065 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3066 | if (peer) { | |
3067 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3068 | if (peer->ifp) | |
3069 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3070 | peer_delete(peer); | |
3071 | } else { | |
3072 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3073 | return CMD_WARNING_CONFIG_FAILED; | |
3074 | } | |
3075 | return CMD_SUCCESS; | |
a80beece DS |
3076 | } |
3077 | ||
718e3744 | 3078 | DEFUN (no_neighbor_peer_group, |
3079 | no_neighbor_peer_group_cmd, | |
3080 | "no neighbor WORD peer-group", | |
3081 | NO_STR | |
3082 | NEIGHBOR_STR | |
3083 | "Neighbor tag\n" | |
3084 | "Configure peer-group\n") | |
3085 | { | |
d62a17ae | 3086 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3087 | int idx_word = 2; | |
3088 | struct peer_group *group; | |
718e3744 | 3089 | |
d62a17ae | 3090 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
3091 | if (group) | |
3092 | peer_group_delete(group); | |
3093 | else { | |
3094 | vty_out(vty, "%% Create the peer-group first\n"); | |
3095 | return CMD_WARNING_CONFIG_FAILED; | |
3096 | } | |
3097 | return CMD_SUCCESS; | |
718e3744 | 3098 | } |
3099 | ||
a80beece DS |
3100 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3101 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3102 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3103 | NO_STR |
3104 | NEIGHBOR_STR | |
a80beece | 3105 | "Interface name or neighbor tag\n" |
718e3744 | 3106 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3107 | AS_STR |
3108 | "Internal BGP peer\n" | |
3109 | "External BGP peer\n") | |
718e3744 | 3110 | { |
d62a17ae | 3111 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3112 | int idx_word = 2; | |
3113 | struct peer_group *group; | |
3114 | struct peer *peer; | |
3115 | ||
3116 | /* look up for neighbor by interface name config. */ | |
3117 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3118 | if (peer) { | |
3119 | peer_as_change(peer, 0, AS_SPECIFIED); | |
3120 | return CMD_SUCCESS; | |
3121 | } | |
3122 | ||
3123 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3124 | if (group) | |
3125 | peer_group_remote_as_delete(group); | |
3126 | else { | |
3127 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3128 | return CMD_WARNING_CONFIG_FAILED; | |
3129 | } | |
3130 | return CMD_SUCCESS; | |
718e3744 | 3131 | } |
6b0655a2 | 3132 | |
718e3744 | 3133 | DEFUN (neighbor_local_as, |
3134 | neighbor_local_as_cmd, | |
9ccf14f7 | 3135 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3136 | NEIGHBOR_STR |
3137 | NEIGHBOR_ADDR_STR2 | |
3138 | "Specify a local-as number\n" | |
3139 | "AS number used as local AS\n") | |
3140 | { | |
d62a17ae | 3141 | int idx_peer = 1; |
3142 | int idx_number = 3; | |
3143 | struct peer *peer; | |
3144 | int ret; | |
3145 | as_t as; | |
718e3744 | 3146 | |
d62a17ae | 3147 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3148 | if (!peer) | |
3149 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3150 | |
d62a17ae | 3151 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3152 | ret = peer_local_as_set(peer, as, 0, 0); | |
3153 | return bgp_vty_return(vty, ret); | |
718e3744 | 3154 | } |
3155 | ||
3156 | DEFUN (neighbor_local_as_no_prepend, | |
3157 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3158 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3159 | NEIGHBOR_STR |
3160 | NEIGHBOR_ADDR_STR2 | |
3161 | "Specify a local-as number\n" | |
3162 | "AS number used as local AS\n" | |
3163 | "Do not prepend local-as to updates from ebgp peers\n") | |
3164 | { | |
d62a17ae | 3165 | int idx_peer = 1; |
3166 | int idx_number = 3; | |
3167 | struct peer *peer; | |
3168 | int ret; | |
3169 | as_t as; | |
718e3744 | 3170 | |
d62a17ae | 3171 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3172 | if (!peer) | |
3173 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3174 | |
d62a17ae | 3175 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3176 | ret = peer_local_as_set(peer, as, 1, 0); | |
3177 | return bgp_vty_return(vty, ret); | |
718e3744 | 3178 | } |
3179 | ||
9d3f9705 AC |
3180 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3181 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3182 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3183 | NEIGHBOR_STR |
3184 | NEIGHBOR_ADDR_STR2 | |
3185 | "Specify a local-as number\n" | |
3186 | "AS number used as local AS\n" | |
3187 | "Do not prepend local-as to updates from ebgp peers\n" | |
3188 | "Do not prepend local-as to updates from ibgp peers\n") | |
3189 | { | |
d62a17ae | 3190 | int idx_peer = 1; |
3191 | int idx_number = 3; | |
3192 | struct peer *peer; | |
3193 | int ret; | |
3194 | as_t as; | |
9d3f9705 | 3195 | |
d62a17ae | 3196 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3197 | if (!peer) | |
3198 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3199 | |
d62a17ae | 3200 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3201 | ret = peer_local_as_set(peer, as, 1, 1); | |
3202 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3203 | } |
3204 | ||
718e3744 | 3205 | DEFUN (no_neighbor_local_as, |
3206 | no_neighbor_local_as_cmd, | |
a636c635 | 3207 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3208 | NO_STR |
3209 | NEIGHBOR_STR | |
3210 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3211 | "Specify a local-as number\n" |
3212 | "AS number used as local AS\n" | |
3213 | "Do not prepend local-as to updates from ebgp peers\n" | |
3214 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3215 | { |
d62a17ae | 3216 | int idx_peer = 2; |
3217 | struct peer *peer; | |
3218 | int ret; | |
718e3744 | 3219 | |
d62a17ae | 3220 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3221 | if (!peer) | |
3222 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3223 | |
d62a17ae | 3224 | ret = peer_local_as_unset(peer); |
3225 | return bgp_vty_return(vty, ret); | |
718e3744 | 3226 | } |
3227 | ||
718e3744 | 3228 | |
3f9c7369 DS |
3229 | DEFUN (neighbor_solo, |
3230 | neighbor_solo_cmd, | |
9ccf14f7 | 3231 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3232 | NEIGHBOR_STR |
3233 | NEIGHBOR_ADDR_STR2 | |
3234 | "Solo peer - part of its own update group\n") | |
3235 | { | |
d62a17ae | 3236 | int idx_peer = 1; |
3237 | struct peer *peer; | |
3238 | int ret; | |
3f9c7369 | 3239 | |
d62a17ae | 3240 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3241 | if (!peer) | |
3242 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3243 | |
d62a17ae | 3244 | ret = update_group_adjust_soloness(peer, 1); |
3245 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3246 | } |
3247 | ||
3248 | DEFUN (no_neighbor_solo, | |
3249 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3250 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3251 | NO_STR |
3252 | NEIGHBOR_STR | |
3253 | NEIGHBOR_ADDR_STR2 | |
3254 | "Solo peer - part of its own update group\n") | |
3255 | { | |
d62a17ae | 3256 | int idx_peer = 2; |
3257 | struct peer *peer; | |
3258 | int ret; | |
3f9c7369 | 3259 | |
d62a17ae | 3260 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3261 | if (!peer) | |
3262 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3263 | |
d62a17ae | 3264 | ret = update_group_adjust_soloness(peer, 0); |
3265 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3266 | } |
3267 | ||
0df7c91f PJ |
3268 | DEFUN (neighbor_password, |
3269 | neighbor_password_cmd, | |
9ccf14f7 | 3270 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3271 | NEIGHBOR_STR |
3272 | NEIGHBOR_ADDR_STR2 | |
3273 | "Set a password\n" | |
3274 | "The password\n") | |
3275 | { | |
d62a17ae | 3276 | int idx_peer = 1; |
3277 | int idx_line = 3; | |
3278 | struct peer *peer; | |
3279 | int ret; | |
0df7c91f | 3280 | |
d62a17ae | 3281 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3282 | if (!peer) | |
3283 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3284 | |
d62a17ae | 3285 | ret = peer_password_set(peer, argv[idx_line]->arg); |
3286 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
3287 | } |
3288 | ||
3289 | DEFUN (no_neighbor_password, | |
3290 | no_neighbor_password_cmd, | |
a636c635 | 3291 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3292 | NO_STR |
3293 | NEIGHBOR_STR | |
3294 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3295 | "Set a password\n" |
3296 | "The password\n") | |
0df7c91f | 3297 | { |
d62a17ae | 3298 | int idx_peer = 2; |
3299 | struct peer *peer; | |
3300 | int ret; | |
0df7c91f | 3301 | |
d62a17ae | 3302 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3303 | if (!peer) | |
3304 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3305 | |
d62a17ae | 3306 | ret = peer_password_unset(peer); |
3307 | return bgp_vty_return(vty, ret); | |
0df7c91f | 3308 | } |
6b0655a2 | 3309 | |
718e3744 | 3310 | DEFUN (neighbor_activate, |
3311 | neighbor_activate_cmd, | |
9ccf14f7 | 3312 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3313 | NEIGHBOR_STR |
3314 | NEIGHBOR_ADDR_STR2 | |
3315 | "Enable the Address Family for this Neighbor\n") | |
3316 | { | |
d62a17ae | 3317 | int idx_peer = 1; |
3318 | int ret; | |
3319 | struct peer *peer; | |
718e3744 | 3320 | |
d62a17ae | 3321 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3322 | if (!peer) | |
3323 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3324 | |
d62a17ae | 3325 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3326 | return bgp_vty_return(vty, ret); | |
718e3744 | 3327 | } |
3328 | ||
d62a17ae | 3329 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
3330 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3331 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3332 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3333 | |
718e3744 | 3334 | DEFUN (no_neighbor_activate, |
3335 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3336 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3337 | NO_STR |
3338 | NEIGHBOR_STR | |
3339 | NEIGHBOR_ADDR_STR2 | |
3340 | "Enable the Address Family for this Neighbor\n") | |
3341 | { | |
d62a17ae | 3342 | int idx_peer = 2; |
3343 | int ret; | |
3344 | struct peer *peer; | |
718e3744 | 3345 | |
d62a17ae | 3346 | /* Lookup peer. */ |
3347 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3348 | if (!peer) | |
3349 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3350 | |
d62a17ae | 3351 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3352 | return bgp_vty_return(vty, ret); | |
718e3744 | 3353 | } |
6b0655a2 | 3354 | |
d62a17ae | 3355 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
3356 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3357 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3358 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3359 | |
718e3744 | 3360 | DEFUN (neighbor_set_peer_group, |
3361 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3362 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3363 | NEIGHBOR_STR |
a80beece | 3364 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3365 | "Member of the peer-group\n" |
16cedbb0 | 3366 | "Peer-group name\n") |
718e3744 | 3367 | { |
d62a17ae | 3368 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3369 | int idx_peer = 1; | |
3370 | int idx_word = 3; | |
3371 | int ret; | |
3372 | as_t as; | |
3373 | union sockunion su; | |
3374 | struct peer *peer; | |
3375 | struct peer_group *group; | |
3376 | ||
3377 | peer = NULL; | |
3378 | ||
3379 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3380 | if (ret < 0) { | |
3381 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3382 | if (!peer) { | |
3383 | vty_out(vty, "%% Malformed address or name: %s\n", | |
3384 | argv[idx_peer]->arg); | |
3385 | return CMD_WARNING_CONFIG_FAILED; | |
3386 | } | |
3387 | } else { | |
3388 | if (peer_address_self_check(bgp, &su)) { | |
3389 | vty_out(vty, | |
3390 | "%% Can not configure the local system as neighbor\n"); | |
3391 | return CMD_WARNING_CONFIG_FAILED; | |
3392 | } | |
3393 | ||
3394 | /* Disallow for dynamic neighbor. */ | |
3395 | peer = peer_lookup(bgp, &su); | |
3396 | if (peer && peer_dynamic_neighbor(peer)) { | |
3397 | vty_out(vty, | |
3398 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3399 | return CMD_WARNING_CONFIG_FAILED; | |
3400 | } | |
3401 | } | |
3402 | ||
3403 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3404 | if (!group) { | |
3405 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3406 | return CMD_WARNING_CONFIG_FAILED; | |
3407 | } | |
3408 | ||
3409 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3410 | ||
3411 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
3412 | vty_out(vty, | |
3413 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
3414 | as); | |
3415 | return CMD_WARNING_CONFIG_FAILED; | |
3416 | } | |
3417 | ||
3418 | return bgp_vty_return(vty, ret); | |
3419 | } | |
3420 | ||
3421 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
3422 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3423 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3424 | "Member of the peer-group\n" | |
3425 | "Peer-group name\n") | |
596c17ba | 3426 | |
718e3744 | 3427 | DEFUN (no_neighbor_set_peer_group, |
3428 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3429 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3430 | NO_STR |
3431 | NEIGHBOR_STR | |
a80beece | 3432 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3433 | "Member of the peer-group\n" |
16cedbb0 | 3434 | "Peer-group name\n") |
718e3744 | 3435 | { |
d62a17ae | 3436 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3437 | int idx_peer = 2; | |
3438 | int idx_word = 4; | |
3439 | int ret; | |
3440 | struct peer *peer; | |
3441 | struct peer_group *group; | |
3442 | ||
3443 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
3444 | if (!peer) | |
3445 | return CMD_WARNING_CONFIG_FAILED; | |
3446 | ||
3447 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3448 | if (!group) { | |
3449 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3450 | return CMD_WARNING_CONFIG_FAILED; | |
3451 | } | |
718e3744 | 3452 | |
827ed707 | 3453 | ret = peer_delete(peer); |
718e3744 | 3454 | |
d62a17ae | 3455 | return bgp_vty_return(vty, ret); |
718e3744 | 3456 | } |
6b0655a2 | 3457 | |
d62a17ae | 3458 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
3459 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3460 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3461 | "Member of the peer-group\n" | |
3462 | "Peer-group name\n") | |
596c17ba | 3463 | |
d62a17ae | 3464 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
d7c0a89a | 3465 | uint16_t flag, int set) |
718e3744 | 3466 | { |
d62a17ae | 3467 | int ret; |
3468 | struct peer *peer; | |
718e3744 | 3469 | |
d62a17ae | 3470 | peer = peer_and_group_lookup_vty(vty, ip_str); |
3471 | if (!peer) | |
3472 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3473 | |
7ebe625c QY |
3474 | /* |
3475 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3476 | * we should not accept disable-connected-check. | |
3477 | */ | |
3478 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3479 | vty_out(vty, | |
3480 | "%s is directly connected peer, cannot accept disable-" | |
3481 | "connected-check\n", | |
3482 | ip_str); | |
3483 | return CMD_WARNING_CONFIG_FAILED; | |
3484 | } | |
3485 | ||
d62a17ae | 3486 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3487 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 3488 | |
d62a17ae | 3489 | if (set) |
3490 | ret = peer_flag_set(peer, flag); | |
3491 | else | |
3492 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 3493 | |
d62a17ae | 3494 | return bgp_vty_return(vty, ret); |
718e3744 | 3495 | } |
3496 | ||
d7c0a89a | 3497 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint16_t flag) |
718e3744 | 3498 | { |
d62a17ae | 3499 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 3500 | } |
3501 | ||
d62a17ae | 3502 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
d7c0a89a | 3503 | uint16_t flag) |
718e3744 | 3504 | { |
d62a17ae | 3505 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 3506 | } |
3507 | ||
3508 | /* neighbor passive. */ | |
3509 | DEFUN (neighbor_passive, | |
3510 | neighbor_passive_cmd, | |
9ccf14f7 | 3511 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3512 | NEIGHBOR_STR |
3513 | NEIGHBOR_ADDR_STR2 | |
3514 | "Don't send open messages to this neighbor\n") | |
3515 | { | |
d62a17ae | 3516 | int idx_peer = 1; |
3517 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3518 | } |
3519 | ||
3520 | DEFUN (no_neighbor_passive, | |
3521 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3522 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3523 | NO_STR |
3524 | NEIGHBOR_STR | |
3525 | NEIGHBOR_ADDR_STR2 | |
3526 | "Don't send open messages to this neighbor\n") | |
3527 | { | |
d62a17ae | 3528 | int idx_peer = 2; |
3529 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3530 | } |
6b0655a2 | 3531 | |
718e3744 | 3532 | /* neighbor shutdown. */ |
73d70fa6 DL |
3533 | DEFUN (neighbor_shutdown_msg, |
3534 | neighbor_shutdown_msg_cmd, | |
3535 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3536 | NEIGHBOR_STR |
3537 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3538 | "Administratively shut down this neighbor\n" |
3539 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3540 | "Shutdown message\n") | |
718e3744 | 3541 | { |
d62a17ae | 3542 | int idx_peer = 1; |
73d70fa6 | 3543 | |
d62a17ae | 3544 | if (argc >= 5) { |
3545 | struct peer *peer = | |
3546 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3547 | char *message; | |
73d70fa6 | 3548 | |
d62a17ae | 3549 | if (!peer) |
3550 | return CMD_WARNING_CONFIG_FAILED; | |
3551 | message = argv_concat(argv, argc, 4); | |
3552 | peer_tx_shutdown_message_set(peer, message); | |
3553 | XFREE(MTYPE_TMP, message); | |
3554 | } | |
73d70fa6 | 3555 | |
d62a17ae | 3556 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3557 | } |
3558 | ||
d62a17ae | 3559 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
3560 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3561 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3562 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3563 | |
3564 | DEFUN (no_neighbor_shutdown_msg, | |
3565 | no_neighbor_shutdown_msg_cmd, | |
3566 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3567 | NO_STR | |
3568 | NEIGHBOR_STR | |
3569 | NEIGHBOR_ADDR_STR2 | |
3570 | "Administratively shut down this neighbor\n" | |
3571 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3572 | "Shutdown message\n") | |
718e3744 | 3573 | { |
d62a17ae | 3574 | int idx_peer = 2; |
73d70fa6 | 3575 | |
d62a17ae | 3576 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
3577 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 3578 | } |
6b0655a2 | 3579 | |
d62a17ae | 3580 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
3581 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3582 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3583 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 3584 | |
718e3744 | 3585 | /* neighbor capability dynamic. */ |
3586 | DEFUN (neighbor_capability_dynamic, | |
3587 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3588 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3589 | NEIGHBOR_STR |
3590 | NEIGHBOR_ADDR_STR2 | |
3591 | "Advertise capability to the peer\n" | |
3592 | "Advertise dynamic capability to this neighbor\n") | |
3593 | { | |
d62a17ae | 3594 | int idx_peer = 1; |
3595 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3596 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3597 | } |
3598 | ||
3599 | DEFUN (no_neighbor_capability_dynamic, | |
3600 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3601 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3602 | NO_STR |
3603 | NEIGHBOR_STR | |
3604 | NEIGHBOR_ADDR_STR2 | |
3605 | "Advertise capability to the peer\n" | |
3606 | "Advertise dynamic capability to this neighbor\n") | |
3607 | { | |
d62a17ae | 3608 | int idx_peer = 2; |
3609 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3610 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3611 | } |
6b0655a2 | 3612 | |
718e3744 | 3613 | /* neighbor dont-capability-negotiate */ |
3614 | DEFUN (neighbor_dont_capability_negotiate, | |
3615 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3616 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3617 | NEIGHBOR_STR |
3618 | NEIGHBOR_ADDR_STR2 | |
3619 | "Do not perform capability negotiation\n") | |
3620 | { | |
d62a17ae | 3621 | int idx_peer = 1; |
3622 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3623 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3624 | } |
3625 | ||
3626 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3627 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3628 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3629 | NO_STR |
3630 | NEIGHBOR_STR | |
3631 | NEIGHBOR_ADDR_STR2 | |
3632 | "Do not perform capability negotiation\n") | |
3633 | { | |
d62a17ae | 3634 | int idx_peer = 2; |
3635 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3636 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3637 | } |
6b0655a2 | 3638 | |
8a92a8a0 DS |
3639 | /* neighbor capability extended next hop encoding */ |
3640 | DEFUN (neighbor_capability_enhe, | |
3641 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3642 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3643 | NEIGHBOR_STR |
3644 | NEIGHBOR_ADDR_STR2 | |
3645 | "Advertise capability to the peer\n" | |
3646 | "Advertise extended next-hop capability to the peer\n") | |
3647 | { | |
d62a17ae | 3648 | int idx_peer = 1; |
3649 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3650 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3651 | } |
3652 | ||
3653 | DEFUN (no_neighbor_capability_enhe, | |
3654 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3655 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3656 | NO_STR |
3657 | NEIGHBOR_STR | |
3658 | NEIGHBOR_ADDR_STR2 | |
3659 | "Advertise capability to the peer\n" | |
3660 | "Advertise extended next-hop capability to the peer\n") | |
3661 | { | |
d62a17ae | 3662 | int idx_peer = 2; |
3663 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3664 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3665 | } |
3666 | ||
d62a17ae | 3667 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3668 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 3669 | int set) |
718e3744 | 3670 | { |
d62a17ae | 3671 | int ret; |
3672 | struct peer *peer; | |
718e3744 | 3673 | |
d62a17ae | 3674 | peer = peer_and_group_lookup_vty(vty, peer_str); |
3675 | if (!peer) | |
3676 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3677 | |
d62a17ae | 3678 | if (set) |
3679 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
3680 | else | |
3681 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 3682 | |
d62a17ae | 3683 | return bgp_vty_return(vty, ret); |
718e3744 | 3684 | } |
3685 | ||
d62a17ae | 3686 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3687 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3688 | { |
d62a17ae | 3689 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 3690 | } |
3691 | ||
d62a17ae | 3692 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3693 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3694 | { |
d62a17ae | 3695 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 3696 | } |
6b0655a2 | 3697 | |
718e3744 | 3698 | /* neighbor capability orf prefix-list. */ |
3699 | DEFUN (neighbor_capability_orf_prefix, | |
3700 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3701 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3702 | NEIGHBOR_STR |
3703 | NEIGHBOR_ADDR_STR2 | |
3704 | "Advertise capability to the peer\n" | |
3705 | "Advertise ORF capability to the peer\n" | |
3706 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3707 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3708 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3709 | "Capability to SEND the ORF to this neighbor\n") | |
3710 | { | |
d62a17ae | 3711 | int idx_peer = 1; |
3712 | int idx_send_recv = 5; | |
d7c0a89a | 3713 | uint16_t flag = 0; |
d62a17ae | 3714 | |
3715 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3716 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3717 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3718 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3719 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3720 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3721 | else { | |
3722 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3723 | return CMD_WARNING_CONFIG_FAILED; | |
3724 | } | |
3725 | ||
3726 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3727 | bgp_node_safi(vty), flag); | |
3728 | } | |
3729 | ||
3730 | ALIAS_HIDDEN( | |
3731 | neighbor_capability_orf_prefix, | |
3732 | neighbor_capability_orf_prefix_hidden_cmd, | |
3733 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3734 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3735 | "Advertise capability to the peer\n" | |
3736 | "Advertise ORF capability to the peer\n" | |
3737 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3738 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3739 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3740 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3741 | |
718e3744 | 3742 | DEFUN (no_neighbor_capability_orf_prefix, |
3743 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3744 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3745 | NO_STR |
3746 | NEIGHBOR_STR | |
3747 | NEIGHBOR_ADDR_STR2 | |
3748 | "Advertise capability to the peer\n" | |
3749 | "Advertise ORF capability to the peer\n" | |
3750 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3751 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3752 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3753 | "Capability to SEND the ORF to this neighbor\n") | |
3754 | { | |
d62a17ae | 3755 | int idx_peer = 2; |
3756 | int idx_send_recv = 6; | |
d7c0a89a | 3757 | uint16_t flag = 0; |
d62a17ae | 3758 | |
3759 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3760 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3761 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3762 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3763 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3764 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3765 | else { | |
3766 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3767 | return CMD_WARNING_CONFIG_FAILED; | |
3768 | } | |
3769 | ||
3770 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3771 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3772 | flag); | |
3773 | } | |
3774 | ||
3775 | ALIAS_HIDDEN( | |
3776 | no_neighbor_capability_orf_prefix, | |
3777 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
3778 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3779 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3780 | "Advertise capability to the peer\n" | |
3781 | "Advertise ORF capability to the peer\n" | |
3782 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3783 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3784 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3785 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3786 | |
718e3744 | 3787 | /* neighbor next-hop-self. */ |
3788 | DEFUN (neighbor_nexthop_self, | |
3789 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3790 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3791 | NEIGHBOR_STR |
3792 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3793 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3794 | { |
d62a17ae | 3795 | int idx_peer = 1; |
3796 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3797 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 3798 | } |
9e7a53c1 | 3799 | |
d62a17ae | 3800 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
3801 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3802 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3803 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3804 | |
a538debe DS |
3805 | /* neighbor next-hop-self. */ |
3806 | DEFUN (neighbor_nexthop_self_force, | |
3807 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3808 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3809 | NEIGHBOR_STR |
3810 | NEIGHBOR_ADDR_STR2 | |
3811 | "Disable the next hop calculation for this neighbor\n" | |
3812 | "Set the next hop to self for reflected routes\n") | |
3813 | { | |
d62a17ae | 3814 | int idx_peer = 1; |
3815 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3816 | bgp_node_safi(vty), | |
3817 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 3818 | } |
3819 | ||
d62a17ae | 3820 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3821 | neighbor_nexthop_self_force_hidden_cmd, | |
3822 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3823 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3824 | "Disable the next hop calculation for this neighbor\n" | |
3825 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3826 | |
718e3744 | 3827 | DEFUN (no_neighbor_nexthop_self, |
3828 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3829 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3830 | NO_STR |
3831 | NEIGHBOR_STR | |
3832 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3833 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 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_NEXTHOP_SELF); | |
718e3744 | 3839 | } |
6b0655a2 | 3840 | |
d62a17ae | 3841 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
3842 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3843 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3844 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3845 | |
88b8ed8d | 3846 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3847 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3848 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3849 | NO_STR |
3850 | NEIGHBOR_STR | |
3851 | NEIGHBOR_ADDR_STR2 | |
3852 | "Disable the next hop calculation for this neighbor\n" | |
3853 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3854 | { |
d62a17ae | 3855 | int idx_peer = 2; |
3856 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3857 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3858 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 3859 | } |
a538debe | 3860 | |
d62a17ae | 3861 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
3862 | no_neighbor_nexthop_self_force_hidden_cmd, | |
3863 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3864 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3865 | "Disable the next hop calculation for this neighbor\n" | |
3866 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3867 | |
c7122e14 DS |
3868 | /* neighbor as-override */ |
3869 | DEFUN (neighbor_as_override, | |
3870 | neighbor_as_override_cmd, | |
9ccf14f7 | 3871 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3872 | NEIGHBOR_STR |
3873 | NEIGHBOR_ADDR_STR2 | |
3874 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3875 | { | |
d62a17ae | 3876 | int idx_peer = 1; |
3877 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3878 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3879 | } |
3880 | ||
d62a17ae | 3881 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
3882 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3883 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3884 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3885 | |
c7122e14 DS |
3886 | DEFUN (no_neighbor_as_override, |
3887 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3888 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3889 | NO_STR |
3890 | NEIGHBOR_STR | |
3891 | NEIGHBOR_ADDR_STR2 | |
3892 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3893 | { | |
d62a17ae | 3894 | int idx_peer = 2; |
3895 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3896 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3897 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3898 | } |
3899 | ||
d62a17ae | 3900 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
3901 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3902 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3903 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3904 | |
718e3744 | 3905 | /* neighbor remove-private-AS. */ |
3906 | DEFUN (neighbor_remove_private_as, | |
3907 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3908 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3909 | NEIGHBOR_STR |
3910 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3911 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3912 | { |
d62a17ae | 3913 | int idx_peer = 1; |
3914 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3915 | bgp_node_safi(vty), | |
3916 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 3917 | } |
3918 | ||
d62a17ae | 3919 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
3920 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
3921 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3922 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 3923 | |
5000f21c DS |
3924 | DEFUN (neighbor_remove_private_as_all, |
3925 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 3926 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3927 | NEIGHBOR_STR |
3928 | NEIGHBOR_ADDR_STR2 | |
3929 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 3930 | "Apply to all AS numbers\n") |
5000f21c | 3931 | { |
d62a17ae | 3932 | int idx_peer = 1; |
3933 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3934 | bgp_node_safi(vty), | |
3935 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
3936 | } |
3937 | ||
d62a17ae | 3938 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
3939 | neighbor_remove_private_as_all_hidden_cmd, | |
3940 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
3941 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3942 | "Remove private ASNs in outbound updates\n" | |
3943 | "Apply to all AS numbers") | |
596c17ba | 3944 | |
5000f21c DS |
3945 | DEFUN (neighbor_remove_private_as_replace_as, |
3946 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 3947 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3948 | NEIGHBOR_STR |
3949 | NEIGHBOR_ADDR_STR2 | |
3950 | "Remove private ASNs in outbound updates\n" | |
3951 | "Replace private ASNs with our ASN in outbound updates\n") | |
3952 | { | |
d62a17ae | 3953 | int idx_peer = 1; |
3954 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3955 | bgp_node_safi(vty), | |
3956 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
3957 | } |
3958 | ||
d62a17ae | 3959 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
3960 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
3961 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
3962 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3963 | "Remove private ASNs in outbound updates\n" | |
3964 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3965 | |
5000f21c DS |
3966 | DEFUN (neighbor_remove_private_as_all_replace_as, |
3967 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 3968 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3969 | NEIGHBOR_STR |
3970 | NEIGHBOR_ADDR_STR2 | |
3971 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3972 | "Apply to all AS numbers\n" |
5000f21c DS |
3973 | "Replace private ASNs with our ASN in outbound updates\n") |
3974 | { | |
d62a17ae | 3975 | int idx_peer = 1; |
3976 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3977 | bgp_node_safi(vty), | |
3978 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
3979 | } |
3980 | ||
d62a17ae | 3981 | ALIAS_HIDDEN( |
3982 | neighbor_remove_private_as_all_replace_as, | |
3983 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
3984 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
3985 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3986 | "Remove private ASNs in outbound updates\n" | |
3987 | "Apply to all AS numbers\n" | |
3988 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3989 | |
718e3744 | 3990 | DEFUN (no_neighbor_remove_private_as, |
3991 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3992 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3993 | NO_STR |
3994 | NEIGHBOR_STR | |
3995 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3996 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3997 | { |
d62a17ae | 3998 | int idx_peer = 2; |
3999 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4000 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4001 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4002 | } |
6b0655a2 | 4003 | |
d62a17ae | 4004 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4005 | no_neighbor_remove_private_as_hidden_cmd, | |
4006 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4007 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4008 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4009 | |
88b8ed8d | 4010 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4011 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4012 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4013 | NO_STR |
4014 | NEIGHBOR_STR | |
4015 | NEIGHBOR_ADDR_STR2 | |
4016 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4017 | "Apply to all AS numbers\n") |
88b8ed8d | 4018 | { |
d62a17ae | 4019 | int idx_peer = 2; |
4020 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4021 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4022 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4023 | } |
5000f21c | 4024 | |
d62a17ae | 4025 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4026 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4027 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4028 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4029 | "Remove private ASNs in outbound updates\n" | |
4030 | "Apply to all AS numbers\n") | |
596c17ba | 4031 | |
88b8ed8d | 4032 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4033 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4034 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4035 | NO_STR |
4036 | NEIGHBOR_STR | |
4037 | NEIGHBOR_ADDR_STR2 | |
4038 | "Remove private ASNs in outbound updates\n" | |
4039 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4040 | { |
d62a17ae | 4041 | int idx_peer = 2; |
4042 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4043 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4044 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4045 | } |
5000f21c | 4046 | |
d62a17ae | 4047 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4048 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4049 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4050 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4051 | "Remove private ASNs in outbound updates\n" | |
4052 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4053 | |
88b8ed8d | 4054 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4055 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4056 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4057 | NO_STR |
4058 | NEIGHBOR_STR | |
4059 | NEIGHBOR_ADDR_STR2 | |
4060 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4061 | "Apply to all AS numbers\n" |
5000f21c | 4062 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4063 | { |
d62a17ae | 4064 | int idx_peer = 2; |
4065 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4066 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4067 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4068 | } |
5000f21c | 4069 | |
d62a17ae | 4070 | ALIAS_HIDDEN( |
4071 | no_neighbor_remove_private_as_all_replace_as, | |
4072 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4073 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4074 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4075 | "Remove private ASNs in outbound updates\n" | |
4076 | "Apply to all AS numbers\n" | |
4077 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4078 | |
5000f21c | 4079 | |
718e3744 | 4080 | /* neighbor send-community. */ |
4081 | DEFUN (neighbor_send_community, | |
4082 | neighbor_send_community_cmd, | |
9ccf14f7 | 4083 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4084 | NEIGHBOR_STR |
4085 | NEIGHBOR_ADDR_STR2 | |
4086 | "Send Community attribute to this neighbor\n") | |
4087 | { | |
d62a17ae | 4088 | int idx_peer = 1; |
4089 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4090 | bgp_node_safi(vty), | |
4091 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4092 | } |
4093 | ||
d62a17ae | 4094 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4095 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4096 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4097 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4098 | |
718e3744 | 4099 | DEFUN (no_neighbor_send_community, |
4100 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4101 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4102 | NO_STR |
4103 | NEIGHBOR_STR | |
4104 | NEIGHBOR_ADDR_STR2 | |
4105 | "Send Community attribute to this neighbor\n") | |
4106 | { | |
d62a17ae | 4107 | int idx_peer = 2; |
4108 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4109 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4110 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4111 | } |
6b0655a2 | 4112 | |
d62a17ae | 4113 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4114 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4115 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4116 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4117 | |
718e3744 | 4118 | /* neighbor send-community extended. */ |
4119 | DEFUN (neighbor_send_community_type, | |
4120 | neighbor_send_community_type_cmd, | |
57d187bc | 4121 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4122 | NEIGHBOR_STR |
4123 | NEIGHBOR_ADDR_STR2 | |
4124 | "Send Community attribute to this neighbor\n" | |
4125 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4126 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4127 | "Send Extended Community attributes\n" |
57d187bc JS |
4128 | "Send Standard Community attributes\n" |
4129 | "Send Large Community attributes\n") | |
718e3744 | 4130 | { |
d62a17ae | 4131 | int idx = 0; |
d7c0a89a | 4132 | uint32_t flag = 0; |
d62a17ae | 4133 | |
4134 | char *peer = argv[1]->arg; | |
4135 | ||
4136 | if (argv_find(argv, argc, "standard", &idx)) | |
4137 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4138 | else if (argv_find(argv, argc, "extended", &idx)) | |
4139 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4140 | else if (argv_find(argv, argc, "large", &idx)) | |
4141 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4142 | else if (argv_find(argv, argc, "both", &idx)) { | |
4143 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4144 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4145 | } else { | |
4146 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4147 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4148 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4149 | } | |
4150 | ||
4151 | return peer_af_flag_set_vty(vty, peer, bgp_node_afi(vty), | |
4152 | bgp_node_safi(vty), flag); | |
4153 | } | |
4154 | ||
4155 | ALIAS_HIDDEN( | |
4156 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4157 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4158 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4159 | "Send Community attribute to this neighbor\n" | |
4160 | "Send Standard and Extended Community attributes\n" | |
4161 | "Send Standard, Large and Extended Community attributes\n" | |
4162 | "Send Extended Community attributes\n" | |
4163 | "Send Standard Community attributes\n" | |
4164 | "Send Large Community attributes\n") | |
596c17ba | 4165 | |
718e3744 | 4166 | DEFUN (no_neighbor_send_community_type, |
4167 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4168 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4169 | NO_STR |
4170 | NEIGHBOR_STR | |
4171 | NEIGHBOR_ADDR_STR2 | |
4172 | "Send Community attribute to this neighbor\n" | |
4173 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4174 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4175 | "Send Extended Community attributes\n" |
57d187bc JS |
4176 | "Send Standard Community attributes\n" |
4177 | "Send Large Community attributes\n") | |
718e3744 | 4178 | { |
d62a17ae | 4179 | int idx_peer = 2; |
4180 | ||
4181 | const char *type = argv[argc - 1]->text; | |
4182 | ||
4183 | if (strmatch(type, "standard")) | |
4184 | return peer_af_flag_unset_vty( | |
4185 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4186 | bgp_node_safi(vty), PEER_FLAG_SEND_COMMUNITY); | |
4187 | if (strmatch(type, "extended")) | |
4188 | return peer_af_flag_unset_vty( | |
4189 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4190 | bgp_node_safi(vty), PEER_FLAG_SEND_EXT_COMMUNITY); | |
4191 | if (strmatch(type, "large")) | |
4192 | return peer_af_flag_unset_vty( | |
4193 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4194 | bgp_node_safi(vty), PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4195 | if (strmatch(type, "both")) | |
4196 | return peer_af_flag_unset_vty( | |
4197 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4198 | bgp_node_safi(vty), | |
4199 | PEER_FLAG_SEND_COMMUNITY | |
4200 | | PEER_FLAG_SEND_EXT_COMMUNITY); | |
4201 | ||
4202 | /* if (strmatch (type, "all")) */ | |
4203 | return peer_af_flag_unset_vty( | |
4204 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4205 | (PEER_FLAG_SEND_COMMUNITY | PEER_FLAG_SEND_EXT_COMMUNITY | |
4206 | | PEER_FLAG_SEND_LARGE_COMMUNITY)); | |
4207 | } | |
4208 | ||
4209 | ALIAS_HIDDEN( | |
4210 | no_neighbor_send_community_type, | |
4211 | no_neighbor_send_community_type_hidden_cmd, | |
4212 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4213 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4214 | "Send Community attribute to this neighbor\n" | |
4215 | "Send Standard and Extended Community attributes\n" | |
4216 | "Send Standard, Large and Extended Community attributes\n" | |
4217 | "Send Extended Community attributes\n" | |
4218 | "Send Standard Community attributes\n" | |
4219 | "Send Large Community attributes\n") | |
596c17ba | 4220 | |
718e3744 | 4221 | /* neighbor soft-reconfig. */ |
4222 | DEFUN (neighbor_soft_reconfiguration, | |
4223 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4224 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4225 | NEIGHBOR_STR |
4226 | NEIGHBOR_ADDR_STR2 | |
4227 | "Per neighbor soft reconfiguration\n" | |
4228 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4229 | { | |
d62a17ae | 4230 | int idx_peer = 1; |
4231 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4232 | bgp_node_safi(vty), | |
4233 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4234 | } |
4235 | ||
d62a17ae | 4236 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4237 | neighbor_soft_reconfiguration_hidden_cmd, | |
4238 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4239 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4240 | "Per neighbor soft reconfiguration\n" | |
4241 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4242 | |
718e3744 | 4243 | DEFUN (no_neighbor_soft_reconfiguration, |
4244 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4245 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4246 | NO_STR |
4247 | NEIGHBOR_STR | |
4248 | NEIGHBOR_ADDR_STR2 | |
4249 | "Per neighbor soft reconfiguration\n" | |
4250 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4251 | { | |
d62a17ae | 4252 | int idx_peer = 2; |
4253 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4254 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4255 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4256 | } |
6b0655a2 | 4257 | |
d62a17ae | 4258 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
4259 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4260 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4261 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4262 | "Per neighbor soft reconfiguration\n" | |
4263 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4264 | |
718e3744 | 4265 | DEFUN (neighbor_route_reflector_client, |
4266 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4267 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4268 | NEIGHBOR_STR |
4269 | NEIGHBOR_ADDR_STR2 | |
4270 | "Configure a neighbor as Route Reflector client\n") | |
4271 | { | |
d62a17ae | 4272 | int idx_peer = 1; |
4273 | struct peer *peer; | |
718e3744 | 4274 | |
4275 | ||
d62a17ae | 4276 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4277 | if (!peer) | |
4278 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4279 | |
d62a17ae | 4280 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4281 | bgp_node_safi(vty), | |
4282 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4283 | } |
4284 | ||
d62a17ae | 4285 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
4286 | neighbor_route_reflector_client_hidden_cmd, | |
4287 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4288 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4289 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4290 | |
718e3744 | 4291 | DEFUN (no_neighbor_route_reflector_client, |
4292 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4293 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4294 | NO_STR |
4295 | NEIGHBOR_STR | |
4296 | NEIGHBOR_ADDR_STR2 | |
4297 | "Configure a neighbor as Route Reflector client\n") | |
4298 | { | |
d62a17ae | 4299 | int idx_peer = 2; |
4300 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4301 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4302 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4303 | } |
6b0655a2 | 4304 | |
d62a17ae | 4305 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
4306 | no_neighbor_route_reflector_client_hidden_cmd, | |
4307 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4308 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4309 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4310 | |
718e3744 | 4311 | /* neighbor route-server-client. */ |
4312 | DEFUN (neighbor_route_server_client, | |
4313 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4314 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4315 | NEIGHBOR_STR |
4316 | NEIGHBOR_ADDR_STR2 | |
4317 | "Configure a neighbor as Route Server client\n") | |
4318 | { | |
d62a17ae | 4319 | int idx_peer = 1; |
4320 | struct peer *peer; | |
2a3d5731 | 4321 | |
d62a17ae | 4322 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4323 | if (!peer) | |
4324 | return CMD_WARNING_CONFIG_FAILED; | |
4325 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4326 | bgp_node_safi(vty), | |
4327 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4328 | } |
4329 | ||
d62a17ae | 4330 | ALIAS_HIDDEN(neighbor_route_server_client, |
4331 | neighbor_route_server_client_hidden_cmd, | |
4332 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4333 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4334 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4335 | |
718e3744 | 4336 | DEFUN (no_neighbor_route_server_client, |
4337 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4338 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4339 | NO_STR |
4340 | NEIGHBOR_STR | |
4341 | NEIGHBOR_ADDR_STR2 | |
4342 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4343 | { |
d62a17ae | 4344 | int idx_peer = 2; |
4345 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4346 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4347 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4348 | } |
6b0655a2 | 4349 | |
d62a17ae | 4350 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
4351 | no_neighbor_route_server_client_hidden_cmd, | |
4352 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4353 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4354 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4355 | |
fee0f4c6 | 4356 | DEFUN (neighbor_nexthop_local_unchanged, |
4357 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4358 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4359 | NEIGHBOR_STR |
4360 | NEIGHBOR_ADDR_STR2 | |
4361 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4362 | "Leave link-local nexthop unchanged for this peer\n") | |
4363 | { | |
d62a17ae | 4364 | int idx_peer = 1; |
4365 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4366 | bgp_node_safi(vty), | |
4367 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 4368 | } |
6b0655a2 | 4369 | |
fee0f4c6 | 4370 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4371 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4372 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4373 | NO_STR |
4374 | NEIGHBOR_STR | |
4375 | NEIGHBOR_ADDR_STR2 | |
4376 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4377 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4378 | { |
d62a17ae | 4379 | int idx_peer = 2; |
4380 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4381 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4382 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 4383 | } |
6b0655a2 | 4384 | |
718e3744 | 4385 | DEFUN (neighbor_attr_unchanged, |
4386 | neighbor_attr_unchanged_cmd, | |
a8206004 | 4387 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 4388 | NEIGHBOR_STR |
4389 | NEIGHBOR_ADDR_STR2 | |
4390 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4391 | "As-path attribute\n" | |
4392 | "Nexthop attribute\n" | |
a8206004 | 4393 | "Med attribute\n") |
718e3744 | 4394 | { |
d62a17ae | 4395 | int idx = 0; |
8eeb0335 DW |
4396 | char *peer_str = argv[1]->arg; |
4397 | struct peer *peer; | |
d7c0a89a | 4398 | uint16_t flags = 0; |
8eeb0335 DW |
4399 | afi_t afi = bgp_node_afi(vty); |
4400 | safi_t safi = bgp_node_safi(vty); | |
4401 | ||
4402 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4403 | if (!peer) | |
4404 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4405 | |
4406 | if (argv_find(argv, argc, "as-path", &idx)) | |
4407 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4408 | idx = 0; | |
4409 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4410 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4411 | idx = 0; | |
4412 | if (argv_find(argv, argc, "med", &idx)) | |
4413 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4414 | ||
8eeb0335 DW |
4415 | /* no flags means all of them! */ |
4416 | if (!flags) { | |
d62a17ae | 4417 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
4418 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4419 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 4420 | } else { |
a4d82a8a PZ |
4421 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
4422 | && peer_af_flag_check(peer, afi, safi, | |
4423 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
4424 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4425 | PEER_FLAG_AS_PATH_UNCHANGED); | |
4426 | } | |
4427 | ||
a4d82a8a PZ |
4428 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
4429 | && peer_af_flag_check(peer, afi, safi, | |
4430 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
4431 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4432 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
4433 | } | |
4434 | ||
a4d82a8a PZ |
4435 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
4436 | && peer_af_flag_check(peer, afi, safi, | |
4437 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
4438 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4439 | PEER_FLAG_MED_UNCHANGED); | |
4440 | } | |
d62a17ae | 4441 | } |
4442 | ||
8eeb0335 | 4443 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 4444 | } |
4445 | ||
4446 | ALIAS_HIDDEN( | |
4447 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
4448 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4449 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4450 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4451 | "As-path attribute\n" | |
4452 | "Nexthop attribute\n" | |
4453 | "Med attribute\n") | |
596c17ba | 4454 | |
718e3744 | 4455 | DEFUN (no_neighbor_attr_unchanged, |
4456 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 4457 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 4458 | NO_STR |
718e3744 | 4459 | NEIGHBOR_STR |
4460 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4461 | "BGP attribute is propagated unchanged to this neighbor\n" |
4462 | "As-path attribute\n" | |
40e718b5 | 4463 | "Nexthop attribute\n" |
a8206004 | 4464 | "Med attribute\n") |
718e3744 | 4465 | { |
d62a17ae | 4466 | int idx = 0; |
4467 | char *peer = argv[2]->arg; | |
d7c0a89a | 4468 | uint16_t flags = 0; |
d62a17ae | 4469 | |
4470 | if (argv_find(argv, argc, "as-path", &idx)) | |
4471 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4472 | idx = 0; | |
4473 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4474 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4475 | idx = 0; | |
4476 | if (argv_find(argv, argc, "med", &idx)) | |
4477 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4478 | ||
4479 | if (!flags) // no flags means all of them! | |
4480 | { | |
4481 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4482 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4483 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4484 | } | |
4485 | ||
4486 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
4487 | bgp_node_safi(vty), flags); | |
4488 | } | |
4489 | ||
4490 | ALIAS_HIDDEN( | |
4491 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
4492 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4493 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4494 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4495 | "As-path attribute\n" | |
4496 | "Nexthop attribute\n" | |
4497 | "Med attribute\n") | |
718e3744 | 4498 | |
718e3744 | 4499 | /* EBGP multihop configuration. */ |
d62a17ae | 4500 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
4501 | const char *ttl_str) | |
718e3744 | 4502 | { |
d62a17ae | 4503 | struct peer *peer; |
4504 | unsigned int ttl; | |
718e3744 | 4505 | |
d62a17ae | 4506 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4507 | if (!peer) | |
4508 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4509 | |
d62a17ae | 4510 | if (peer->conf_if) |
4511 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 4512 | |
d62a17ae | 4513 | if (!ttl_str) |
4514 | ttl = MAXTTL; | |
4515 | else | |
4516 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 4517 | |
d62a17ae | 4518 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 4519 | } |
4520 | ||
d62a17ae | 4521 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4522 | { |
d62a17ae | 4523 | struct peer *peer; |
718e3744 | 4524 | |
d62a17ae | 4525 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4526 | if (!peer) | |
4527 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4528 | |
d62a17ae | 4529 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 4530 | } |
4531 | ||
4532 | /* neighbor ebgp-multihop. */ | |
4533 | DEFUN (neighbor_ebgp_multihop, | |
4534 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4535 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4536 | NEIGHBOR_STR |
4537 | NEIGHBOR_ADDR_STR2 | |
4538 | "Allow EBGP neighbors not on directly connected networks\n") | |
4539 | { | |
d62a17ae | 4540 | int idx_peer = 1; |
4541 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4542 | } |
4543 | ||
4544 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4545 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4546 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4547 | NEIGHBOR_STR |
4548 | NEIGHBOR_ADDR_STR2 | |
4549 | "Allow EBGP neighbors not on directly connected networks\n" | |
4550 | "maximum hop count\n") | |
4551 | { | |
d62a17ae | 4552 | int idx_peer = 1; |
4553 | int idx_number = 3; | |
4554 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
4555 | argv[idx_number]->arg); | |
718e3744 | 4556 | } |
4557 | ||
4558 | DEFUN (no_neighbor_ebgp_multihop, | |
4559 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4560 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4561 | NO_STR |
4562 | NEIGHBOR_STR | |
4563 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4564 | "Allow EBGP neighbors not on directly connected networks\n" |
4565 | "maximum hop count\n") | |
718e3744 | 4566 | { |
d62a17ae | 4567 | int idx_peer = 2; |
4568 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4569 | } |
4570 | ||
6b0655a2 | 4571 | |
6ffd2079 | 4572 | /* disable-connected-check */ |
4573 | DEFUN (neighbor_disable_connected_check, | |
4574 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 4575 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4576 | NEIGHBOR_STR |
7ebe625c | 4577 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4578 | "one-hop away EBGP peer using loopback address\n" |
4579 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4580 | { |
d62a17ae | 4581 | int idx_peer = 1; |
4582 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4583 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4584 | } |
4585 | ||
4586 | DEFUN (no_neighbor_disable_connected_check, | |
4587 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 4588 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4589 | NO_STR |
4590 | NEIGHBOR_STR | |
7ebe625c | 4591 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4592 | "one-hop away EBGP peer using loopback address\n" |
4593 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4594 | { |
d62a17ae | 4595 | int idx_peer = 2; |
4596 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4597 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4598 | } |
4599 | ||
718e3744 | 4600 | DEFUN (neighbor_description, |
4601 | neighbor_description_cmd, | |
e961923c | 4602 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4603 | NEIGHBOR_STR |
4604 | NEIGHBOR_ADDR_STR2 | |
4605 | "Neighbor specific description\n" | |
4606 | "Up to 80 characters describing this neighbor\n") | |
4607 | { | |
d62a17ae | 4608 | int idx_peer = 1; |
4609 | int idx_line = 3; | |
4610 | struct peer *peer; | |
4611 | char *str; | |
718e3744 | 4612 | |
d62a17ae | 4613 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4614 | if (!peer) | |
4615 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4616 | |
d62a17ae | 4617 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4618 | |
d62a17ae | 4619 | peer_description_set(peer, str); |
718e3744 | 4620 | |
d62a17ae | 4621 | XFREE(MTYPE_TMP, str); |
718e3744 | 4622 | |
d62a17ae | 4623 | return CMD_SUCCESS; |
718e3744 | 4624 | } |
4625 | ||
4626 | DEFUN (no_neighbor_description, | |
4627 | no_neighbor_description_cmd, | |
a636c635 | 4628 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]", |
718e3744 | 4629 | NO_STR |
4630 | NEIGHBOR_STR | |
4631 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4632 | "Neighbor specific description\n" |
4633 | "Up to 80 characters describing this neighbor\n") | |
718e3744 | 4634 | { |
d62a17ae | 4635 | int idx_peer = 2; |
4636 | struct peer *peer; | |
718e3744 | 4637 | |
d62a17ae | 4638 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4639 | if (!peer) | |
4640 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4641 | |
d62a17ae | 4642 | peer_description_unset(peer); |
718e3744 | 4643 | |
d62a17ae | 4644 | return CMD_SUCCESS; |
718e3744 | 4645 | } |
4646 | ||
6b0655a2 | 4647 | |
718e3744 | 4648 | /* Neighbor update-source. */ |
d62a17ae | 4649 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
4650 | const char *source_str) | |
4651 | { | |
4652 | struct peer *peer; | |
4653 | struct prefix p; | |
4654 | ||
4655 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4656 | if (!peer) | |
4657 | return CMD_WARNING_CONFIG_FAILED; | |
4658 | ||
4659 | if (peer->conf_if) | |
4660 | return CMD_WARNING; | |
4661 | ||
4662 | if (source_str) { | |
4663 | union sockunion su; | |
4664 | int ret = str2sockunion(source_str, &su); | |
4665 | ||
4666 | if (ret == 0) | |
4667 | peer_update_source_addr_set(peer, &su); | |
4668 | else { | |
4669 | if (str2prefix(source_str, &p)) { | |
4670 | vty_out(vty, | |
4671 | "%% Invalid update-source, remove prefix length \n"); | |
4672 | return CMD_WARNING_CONFIG_FAILED; | |
4673 | } else | |
4674 | peer_update_source_if_set(peer, source_str); | |
4675 | } | |
4676 | } else | |
4677 | peer_update_source_unset(peer); | |
4678 | ||
4679 | return CMD_SUCCESS; | |
4680 | } | |
4681 | ||
4682 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
4683 | "IPv4 address\n" \ | |
4684 | "IPv6 address\n" \ | |
4685 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4686 | |
718e3744 | 4687 | DEFUN (neighbor_update_source, |
4688 | neighbor_update_source_cmd, | |
9ccf14f7 | 4689 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4690 | NEIGHBOR_STR |
4691 | NEIGHBOR_ADDR_STR2 | |
4692 | "Source of routing updates\n" | |
369688c0 | 4693 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4694 | { |
d62a17ae | 4695 | int idx_peer = 1; |
4696 | int idx_peer_2 = 3; | |
4697 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
4698 | argv[idx_peer_2]->arg); | |
718e3744 | 4699 | } |
4700 | ||
4701 | DEFUN (no_neighbor_update_source, | |
4702 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4703 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4704 | NO_STR |
4705 | NEIGHBOR_STR | |
4706 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4707 | "Source of routing updates\n" |
4708 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4709 | { |
d62a17ae | 4710 | int idx_peer = 2; |
4711 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4712 | } |
6b0655a2 | 4713 | |
d62a17ae | 4714 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
4715 | afi_t afi, safi_t safi, | |
4716 | const char *rmap, int set) | |
718e3744 | 4717 | { |
d62a17ae | 4718 | int ret; |
4719 | struct peer *peer; | |
718e3744 | 4720 | |
d62a17ae | 4721 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4722 | if (!peer) | |
4723 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4724 | |
d62a17ae | 4725 | if (set) |
4726 | ret = peer_default_originate_set(peer, afi, safi, rmap); | |
4727 | else | |
4728 | ret = peer_default_originate_unset(peer, afi, safi); | |
718e3744 | 4729 | |
d62a17ae | 4730 | return bgp_vty_return(vty, ret); |
718e3744 | 4731 | } |
4732 | ||
4733 | /* neighbor default-originate. */ | |
4734 | DEFUN (neighbor_default_originate, | |
4735 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4736 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4737 | NEIGHBOR_STR |
4738 | NEIGHBOR_ADDR_STR2 | |
4739 | "Originate default route to this neighbor\n") | |
4740 | { | |
d62a17ae | 4741 | int idx_peer = 1; |
4742 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4743 | bgp_node_afi(vty), | |
4744 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 4745 | } |
4746 | ||
d62a17ae | 4747 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
4748 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
4749 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4750 | "Originate default route to this neighbor\n") | |
596c17ba | 4751 | |
718e3744 | 4752 | DEFUN (neighbor_default_originate_rmap, |
4753 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4754 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4755 | NEIGHBOR_STR |
4756 | NEIGHBOR_ADDR_STR2 | |
4757 | "Originate default route to this neighbor\n" | |
4758 | "Route-map to specify criteria to originate default\n" | |
4759 | "route-map name\n") | |
4760 | { | |
d62a17ae | 4761 | int idx_peer = 1; |
4762 | int idx_word = 4; | |
4763 | return peer_default_originate_set_vty( | |
4764 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4765 | argv[idx_word]->arg, 1); | |
718e3744 | 4766 | } |
4767 | ||
d62a17ae | 4768 | ALIAS_HIDDEN( |
4769 | neighbor_default_originate_rmap, | |
4770 | neighbor_default_originate_rmap_hidden_cmd, | |
4771 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
4772 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4773 | "Originate default route to this neighbor\n" | |
4774 | "Route-map to specify criteria to originate default\n" | |
4775 | "route-map name\n") | |
596c17ba | 4776 | |
718e3744 | 4777 | DEFUN (no_neighbor_default_originate, |
4778 | no_neighbor_default_originate_cmd, | |
a636c635 | 4779 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4780 | NO_STR |
4781 | NEIGHBOR_STR | |
4782 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4783 | "Originate default route to this neighbor\n" |
4784 | "Route-map to specify criteria to originate default\n" | |
4785 | "route-map name\n") | |
718e3744 | 4786 | { |
d62a17ae | 4787 | int idx_peer = 2; |
4788 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4789 | bgp_node_afi(vty), | |
4790 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 4791 | } |
4792 | ||
d62a17ae | 4793 | ALIAS_HIDDEN( |
4794 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
4795 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
4796 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4797 | "Originate default route to this neighbor\n" | |
4798 | "Route-map to specify criteria to originate default\n" | |
4799 | "route-map name\n") | |
596c17ba | 4800 | |
6b0655a2 | 4801 | |
718e3744 | 4802 | /* Set neighbor's BGP port. */ |
d62a17ae | 4803 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
4804 | const char *port_str) | |
4805 | { | |
4806 | struct peer *peer; | |
d7c0a89a | 4807 | uint16_t port; |
d62a17ae | 4808 | struct servent *sp; |
4809 | ||
4810 | peer = peer_lookup_vty(vty, ip_str); | |
4811 | if (!peer) | |
4812 | return CMD_WARNING_CONFIG_FAILED; | |
4813 | ||
4814 | if (!port_str) { | |
4815 | sp = getservbyname("bgp", "tcp"); | |
4816 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
4817 | } else { | |
4818 | port = strtoul(port_str, NULL, 10); | |
4819 | } | |
718e3744 | 4820 | |
d62a17ae | 4821 | peer_port_set(peer, port); |
718e3744 | 4822 | |
d62a17ae | 4823 | return CMD_SUCCESS; |
718e3744 | 4824 | } |
4825 | ||
f418446b | 4826 | /* Set specified peer's BGP port. */ |
718e3744 | 4827 | DEFUN (neighbor_port, |
4828 | neighbor_port_cmd, | |
9ccf14f7 | 4829 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4830 | NEIGHBOR_STR |
4831 | NEIGHBOR_ADDR_STR | |
4832 | "Neighbor's BGP port\n" | |
4833 | "TCP port number\n") | |
4834 | { | |
d62a17ae | 4835 | int idx_ip = 1; |
4836 | int idx_number = 3; | |
4837 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
4838 | argv[idx_number]->arg); | |
718e3744 | 4839 | } |
4840 | ||
4841 | DEFUN (no_neighbor_port, | |
4842 | no_neighbor_port_cmd, | |
9ccf14f7 | 4843 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4844 | NO_STR |
4845 | NEIGHBOR_STR | |
4846 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4847 | "Neighbor's BGP port\n" |
4848 | "TCP port number\n") | |
718e3744 | 4849 | { |
d62a17ae | 4850 | int idx_ip = 2; |
4851 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4852 | } |
4853 | ||
6b0655a2 | 4854 | |
718e3744 | 4855 | /* neighbor weight. */ |
d62a17ae | 4856 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4857 | safi_t safi, const char *weight_str) | |
718e3744 | 4858 | { |
d62a17ae | 4859 | int ret; |
4860 | struct peer *peer; | |
4861 | unsigned long weight; | |
718e3744 | 4862 | |
d62a17ae | 4863 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4864 | if (!peer) | |
4865 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4866 | |
d62a17ae | 4867 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 4868 | |
d62a17ae | 4869 | ret = peer_weight_set(peer, afi, safi, weight); |
4870 | return bgp_vty_return(vty, ret); | |
718e3744 | 4871 | } |
4872 | ||
d62a17ae | 4873 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4874 | safi_t safi) | |
718e3744 | 4875 | { |
d62a17ae | 4876 | int ret; |
4877 | struct peer *peer; | |
718e3744 | 4878 | |
d62a17ae | 4879 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4880 | if (!peer) | |
4881 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4882 | |
d62a17ae | 4883 | ret = peer_weight_unset(peer, afi, safi); |
4884 | return bgp_vty_return(vty, ret); | |
718e3744 | 4885 | } |
4886 | ||
4887 | DEFUN (neighbor_weight, | |
4888 | neighbor_weight_cmd, | |
9ccf14f7 | 4889 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 4890 | NEIGHBOR_STR |
4891 | NEIGHBOR_ADDR_STR2 | |
4892 | "Set default weight for routes from this neighbor\n" | |
4893 | "default weight\n") | |
4894 | { | |
d62a17ae | 4895 | int idx_peer = 1; |
4896 | int idx_number = 3; | |
4897 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4898 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 4899 | } |
4900 | ||
d62a17ae | 4901 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
4902 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
4903 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4904 | "Set default weight for routes from this neighbor\n" | |
4905 | "default weight\n") | |
596c17ba | 4906 | |
718e3744 | 4907 | DEFUN (no_neighbor_weight, |
4908 | no_neighbor_weight_cmd, | |
9ccf14f7 | 4909 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 4910 | NO_STR |
4911 | NEIGHBOR_STR | |
4912 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4913 | "Set default weight for routes from this neighbor\n" |
4914 | "default weight\n") | |
718e3744 | 4915 | { |
d62a17ae | 4916 | int idx_peer = 2; |
4917 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
4918 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 4919 | } |
4920 | ||
d62a17ae | 4921 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
4922 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
4923 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4924 | "Set default weight for routes from this neighbor\n" | |
4925 | "default weight\n") | |
596c17ba | 4926 | |
6b0655a2 | 4927 | |
718e3744 | 4928 | /* Override capability negotiation. */ |
4929 | DEFUN (neighbor_override_capability, | |
4930 | neighbor_override_capability_cmd, | |
9ccf14f7 | 4931 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4932 | NEIGHBOR_STR |
4933 | NEIGHBOR_ADDR_STR2 | |
4934 | "Override capability negotiation result\n") | |
4935 | { | |
d62a17ae | 4936 | int idx_peer = 1; |
4937 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4938 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4939 | } |
4940 | ||
4941 | DEFUN (no_neighbor_override_capability, | |
4942 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 4943 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4944 | NO_STR |
4945 | NEIGHBOR_STR | |
4946 | NEIGHBOR_ADDR_STR2 | |
4947 | "Override capability negotiation result\n") | |
4948 | { | |
d62a17ae | 4949 | int idx_peer = 2; |
4950 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4951 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4952 | } |
6b0655a2 | 4953 | |
718e3744 | 4954 | DEFUN (neighbor_strict_capability, |
4955 | neighbor_strict_capability_cmd, | |
9ccf14f7 | 4956 | "neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4957 | NEIGHBOR_STR |
4958 | NEIGHBOR_ADDR_STR | |
4959 | "Strict capability negotiation match\n") | |
4960 | { | |
d62a17ae | 4961 | int idx_ip = 1; |
4962 | return peer_flag_set_vty(vty, argv[idx_ip]->arg, | |
4963 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4964 | } |
4965 | ||
4966 | DEFUN (no_neighbor_strict_capability, | |
4967 | no_neighbor_strict_capability_cmd, | |
9ccf14f7 | 4968 | "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match", |
718e3744 | 4969 | NO_STR |
4970 | NEIGHBOR_STR | |
4971 | NEIGHBOR_ADDR_STR | |
4972 | "Strict capability negotiation match\n") | |
4973 | { | |
d62a17ae | 4974 | int idx_ip = 2; |
4975 | return peer_flag_unset_vty(vty, argv[idx_ip]->arg, | |
4976 | PEER_FLAG_STRICT_CAP_MATCH); | |
718e3744 | 4977 | } |
6b0655a2 | 4978 | |
d62a17ae | 4979 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
4980 | const char *keep_str, const char *hold_str) | |
718e3744 | 4981 | { |
d62a17ae | 4982 | int ret; |
4983 | struct peer *peer; | |
d7c0a89a QY |
4984 | uint32_t keepalive; |
4985 | uint32_t holdtime; | |
718e3744 | 4986 | |
d62a17ae | 4987 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4988 | if (!peer) | |
4989 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4990 | |
d62a17ae | 4991 | keepalive = strtoul(keep_str, NULL, 10); |
4992 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 4993 | |
d62a17ae | 4994 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 4995 | |
d62a17ae | 4996 | return bgp_vty_return(vty, ret); |
718e3744 | 4997 | } |
6b0655a2 | 4998 | |
d62a17ae | 4999 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5000 | { |
d62a17ae | 5001 | int ret; |
5002 | struct peer *peer; | |
718e3744 | 5003 | |
d62a17ae | 5004 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5005 | if (!peer) | |
5006 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5007 | |
d62a17ae | 5008 | ret = peer_timers_unset(peer); |
718e3744 | 5009 | |
d62a17ae | 5010 | return bgp_vty_return(vty, ret); |
718e3744 | 5011 | } |
5012 | ||
5013 | DEFUN (neighbor_timers, | |
5014 | neighbor_timers_cmd, | |
9ccf14f7 | 5015 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5016 | NEIGHBOR_STR |
5017 | NEIGHBOR_ADDR_STR2 | |
5018 | "BGP per neighbor timers\n" | |
5019 | "Keepalive interval\n" | |
5020 | "Holdtime\n") | |
5021 | { | |
d62a17ae | 5022 | int idx_peer = 1; |
5023 | int idx_number = 3; | |
5024 | int idx_number_2 = 4; | |
5025 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5026 | argv[idx_number]->arg, | |
5027 | argv[idx_number_2]->arg); | |
718e3744 | 5028 | } |
5029 | ||
5030 | DEFUN (no_neighbor_timers, | |
5031 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5032 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5033 | NO_STR |
5034 | NEIGHBOR_STR | |
5035 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5036 | "BGP per neighbor timers\n" |
5037 | "Keepalive interval\n" | |
5038 | "Holdtime\n") | |
718e3744 | 5039 | { |
d62a17ae | 5040 | int idx_peer = 2; |
5041 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5042 | } |
6b0655a2 | 5043 | |
813d4307 | 5044 | |
d62a17ae | 5045 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
5046 | const char *time_str) | |
718e3744 | 5047 | { |
d62a17ae | 5048 | int ret; |
5049 | struct peer *peer; | |
d7c0a89a | 5050 | uint32_t connect; |
718e3744 | 5051 | |
d62a17ae | 5052 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5053 | if (!peer) | |
5054 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5055 | |
d62a17ae | 5056 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5057 | |
d62a17ae | 5058 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5059 | |
d62a17ae | 5060 | return bgp_vty_return(vty, ret); |
718e3744 | 5061 | } |
5062 | ||
d62a17ae | 5063 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5064 | { |
d62a17ae | 5065 | int ret; |
5066 | struct peer *peer; | |
718e3744 | 5067 | |
d62a17ae | 5068 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5069 | if (!peer) | |
5070 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5071 | |
d62a17ae | 5072 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5073 | |
d62a17ae | 5074 | return bgp_vty_return(vty, ret); |
718e3744 | 5075 | } |
5076 | ||
5077 | DEFUN (neighbor_timers_connect, | |
5078 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5079 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5080 | NEIGHBOR_STR |
966f821c | 5081 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5082 | "BGP per neighbor timers\n" |
5083 | "BGP connect timer\n" | |
5084 | "Connect timer\n") | |
5085 | { | |
d62a17ae | 5086 | int idx_peer = 1; |
5087 | int idx_number = 4; | |
5088 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5089 | argv[idx_number]->arg); | |
718e3744 | 5090 | } |
5091 | ||
5092 | DEFUN (no_neighbor_timers_connect, | |
5093 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5094 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5095 | NO_STR |
5096 | NEIGHBOR_STR | |
966f821c | 5097 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5098 | "BGP per neighbor timers\n" |
8334fd5a DW |
5099 | "BGP connect timer\n" |
5100 | "Connect timer\n") | |
718e3744 | 5101 | { |
d62a17ae | 5102 | int idx_peer = 2; |
5103 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5104 | } |
5105 | ||
6b0655a2 | 5106 | |
d62a17ae | 5107 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5108 | const char *time_str, int set) | |
718e3744 | 5109 | { |
d62a17ae | 5110 | int ret; |
5111 | struct peer *peer; | |
d7c0a89a | 5112 | uint32_t routeadv = 0; |
718e3744 | 5113 | |
d62a17ae | 5114 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5115 | if (!peer) | |
5116 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5117 | |
d62a17ae | 5118 | if (time_str) |
5119 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5120 | |
d62a17ae | 5121 | if (set) |
5122 | ret = peer_advertise_interval_set(peer, routeadv); | |
5123 | else | |
5124 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5125 | |
d62a17ae | 5126 | return bgp_vty_return(vty, ret); |
718e3744 | 5127 | } |
5128 | ||
5129 | DEFUN (neighbor_advertise_interval, | |
5130 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5131 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5132 | NEIGHBOR_STR |
966f821c | 5133 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5134 | "Minimum interval between sending BGP routing updates\n" |
5135 | "time in seconds\n") | |
5136 | { | |
d62a17ae | 5137 | int idx_peer = 1; |
5138 | int idx_number = 3; | |
5139 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5140 | argv[idx_number]->arg, 1); | |
718e3744 | 5141 | } |
5142 | ||
5143 | DEFUN (no_neighbor_advertise_interval, | |
5144 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5145 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5146 | NO_STR |
5147 | NEIGHBOR_STR | |
966f821c | 5148 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5149 | "Minimum interval between sending BGP routing updates\n" |
5150 | "time in seconds\n") | |
718e3744 | 5151 | { |
d62a17ae | 5152 | int idx_peer = 2; |
5153 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5154 | } |
5155 | ||
6b0655a2 | 5156 | |
518f0eb1 DS |
5157 | /* Time to wait before processing route-map updates */ |
5158 | DEFUN (bgp_set_route_map_delay_timer, | |
5159 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5160 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5161 | SET_STR |
5162 | "BGP route-map delay timer\n" | |
5163 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5164 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5165 | { |
d62a17ae | 5166 | int idx_number = 3; |
d7c0a89a | 5167 | uint32_t rmap_delay_timer; |
d62a17ae | 5168 | |
5169 | if (argv[idx_number]->arg) { | |
5170 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
5171 | bm->rmap_update_timer = rmap_delay_timer; | |
5172 | ||
5173 | /* if the dynamic update handling is being disabled, and a timer | |
5174 | * is | |
5175 | * running, stop the timer and act as if the timer has already | |
5176 | * fired. | |
5177 | */ | |
5178 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
5179 | BGP_TIMER_OFF(bm->t_rmap_update); | |
5180 | thread_execute(bm->master, bgp_route_map_update_timer, | |
5181 | NULL, 0); | |
5182 | } | |
5183 | return CMD_SUCCESS; | |
5184 | } else { | |
5185 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5186 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5187 | } |
518f0eb1 DS |
5188 | } |
5189 | ||
5190 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5191 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5192 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5193 | NO_STR |
3a2d747c | 5194 | BGP_STR |
518f0eb1 | 5195 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5196 | "Reset to default time to wait for processing route-map changes\n" |
5197 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5198 | { |
518f0eb1 | 5199 | |
d62a17ae | 5200 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 5201 | |
d62a17ae | 5202 | return CMD_SUCCESS; |
518f0eb1 DS |
5203 | } |
5204 | ||
f414725f | 5205 | |
718e3744 | 5206 | /* neighbor interface */ |
d62a17ae | 5207 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
5208 | const char *str) | |
718e3744 | 5209 | { |
d62a17ae | 5210 | struct peer *peer; |
718e3744 | 5211 | |
d62a17ae | 5212 | peer = peer_lookup_vty(vty, ip_str); |
5213 | if (!peer || peer->conf_if) { | |
5214 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
5215 | return CMD_WARNING_CONFIG_FAILED; | |
5216 | } | |
718e3744 | 5217 | |
d62a17ae | 5218 | if (str) |
5219 | peer_interface_set(peer, str); | |
5220 | else | |
5221 | peer_interface_unset(peer); | |
718e3744 | 5222 | |
d62a17ae | 5223 | return CMD_SUCCESS; |
718e3744 | 5224 | } |
5225 | ||
5226 | DEFUN (neighbor_interface, | |
5227 | neighbor_interface_cmd, | |
9ccf14f7 | 5228 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5229 | NEIGHBOR_STR |
5230 | NEIGHBOR_ADDR_STR | |
5231 | "Interface\n" | |
5232 | "Interface name\n") | |
5233 | { | |
d62a17ae | 5234 | int idx_ip = 1; |
5235 | int idx_word = 3; | |
5236 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 5237 | } |
5238 | ||
5239 | DEFUN (no_neighbor_interface, | |
5240 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5241 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5242 | NO_STR |
5243 | NEIGHBOR_STR | |
16cedbb0 | 5244 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5245 | "Interface\n" |
5246 | "Interface name\n") | |
5247 | { | |
d62a17ae | 5248 | int idx_peer = 2; |
5249 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5250 | } |
6b0655a2 | 5251 | |
718e3744 | 5252 | DEFUN (neighbor_distribute_list, |
5253 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5254 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5255 | NEIGHBOR_STR |
5256 | NEIGHBOR_ADDR_STR2 | |
5257 | "Filter updates to/from this neighbor\n" | |
5258 | "IP access-list number\n" | |
5259 | "IP access-list number (expanded range)\n" | |
5260 | "IP Access-list name\n" | |
5261 | "Filter incoming updates\n" | |
5262 | "Filter outgoing updates\n") | |
5263 | { | |
d62a17ae | 5264 | int idx_peer = 1; |
5265 | int idx_acl = 3; | |
5266 | int direct, ret; | |
5267 | struct peer *peer; | |
a8206004 | 5268 | |
d62a17ae | 5269 | const char *pstr = argv[idx_peer]->arg; |
5270 | const char *acl = argv[idx_acl]->arg; | |
5271 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5272 | |
d62a17ae | 5273 | peer = peer_and_group_lookup_vty(vty, pstr); |
5274 | if (!peer) | |
5275 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5276 | |
d62a17ae | 5277 | /* Check filter direction. */ |
5278 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5279 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5280 | direct, acl); | |
a8206004 | 5281 | |
d62a17ae | 5282 | return bgp_vty_return(vty, ret); |
718e3744 | 5283 | } |
5284 | ||
d62a17ae | 5285 | ALIAS_HIDDEN( |
5286 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
5287 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5288 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5289 | "Filter updates to/from this neighbor\n" | |
5290 | "IP access-list number\n" | |
5291 | "IP access-list number (expanded range)\n" | |
5292 | "IP Access-list name\n" | |
5293 | "Filter incoming updates\n" | |
5294 | "Filter outgoing updates\n") | |
596c17ba | 5295 | |
718e3744 | 5296 | DEFUN (no_neighbor_distribute_list, |
5297 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5298 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5299 | NO_STR |
5300 | NEIGHBOR_STR | |
5301 | NEIGHBOR_ADDR_STR2 | |
5302 | "Filter updates to/from this neighbor\n" | |
5303 | "IP access-list number\n" | |
5304 | "IP access-list number (expanded range)\n" | |
5305 | "IP Access-list name\n" | |
5306 | "Filter incoming updates\n" | |
5307 | "Filter outgoing updates\n") | |
5308 | { | |
d62a17ae | 5309 | int idx_peer = 2; |
5310 | int direct, ret; | |
5311 | struct peer *peer; | |
a8206004 | 5312 | |
d62a17ae | 5313 | const char *pstr = argv[idx_peer]->arg; |
5314 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5315 | |
d62a17ae | 5316 | peer = peer_and_group_lookup_vty(vty, pstr); |
5317 | if (!peer) | |
5318 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5319 | |
d62a17ae | 5320 | /* Check filter direction. */ |
5321 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5322 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5323 | direct); | |
a8206004 | 5324 | |
d62a17ae | 5325 | return bgp_vty_return(vty, ret); |
718e3744 | 5326 | } |
6b0655a2 | 5327 | |
d62a17ae | 5328 | ALIAS_HIDDEN( |
5329 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
5330 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5331 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5332 | "Filter updates to/from this neighbor\n" | |
5333 | "IP access-list number\n" | |
5334 | "IP access-list number (expanded range)\n" | |
5335 | "IP Access-list name\n" | |
5336 | "Filter incoming updates\n" | |
5337 | "Filter outgoing updates\n") | |
596c17ba | 5338 | |
718e3744 | 5339 | /* Set prefix list to the peer. */ |
d62a17ae | 5340 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
5341 | afi_t afi, safi_t safi, | |
5342 | const char *name_str, | |
5343 | const char *direct_str) | |
718e3744 | 5344 | { |
d62a17ae | 5345 | int ret; |
5346 | struct peer *peer; | |
5347 | int direct = FILTER_IN; | |
718e3744 | 5348 | |
d62a17ae | 5349 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5350 | if (!peer) | |
5351 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5352 | |
d62a17ae | 5353 | /* Check filter direction. */ |
5354 | if (strncmp(direct_str, "i", 1) == 0) | |
5355 | direct = FILTER_IN; | |
5356 | else if (strncmp(direct_str, "o", 1) == 0) | |
5357 | direct = FILTER_OUT; | |
718e3744 | 5358 | |
d62a17ae | 5359 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 5360 | |
d62a17ae | 5361 | return bgp_vty_return(vty, ret); |
718e3744 | 5362 | } |
5363 | ||
d62a17ae | 5364 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
5365 | afi_t afi, safi_t safi, | |
5366 | const char *direct_str) | |
718e3744 | 5367 | { |
d62a17ae | 5368 | int ret; |
5369 | struct peer *peer; | |
5370 | int direct = FILTER_IN; | |
718e3744 | 5371 | |
d62a17ae | 5372 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5373 | if (!peer) | |
5374 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 5375 | |
d62a17ae | 5376 | /* Check filter direction. */ |
5377 | if (strncmp(direct_str, "i", 1) == 0) | |
5378 | direct = FILTER_IN; | |
5379 | else if (strncmp(direct_str, "o", 1) == 0) | |
5380 | direct = FILTER_OUT; | |
718e3744 | 5381 | |
d62a17ae | 5382 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 5383 | |
d62a17ae | 5384 | return bgp_vty_return(vty, ret); |
718e3744 | 5385 | } |
5386 | ||
5387 | DEFUN (neighbor_prefix_list, | |
5388 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5389 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5390 | NEIGHBOR_STR |
5391 | NEIGHBOR_ADDR_STR2 | |
5392 | "Filter updates to/from this neighbor\n" | |
5393 | "Name of a prefix list\n" | |
5394 | "Filter incoming updates\n" | |
5395 | "Filter outgoing updates\n") | |
5396 | { | |
d62a17ae | 5397 | int idx_peer = 1; |
5398 | int idx_word = 3; | |
5399 | int idx_in_out = 4; | |
5400 | return peer_prefix_list_set_vty( | |
5401 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5402 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5403 | } |
5404 | ||
d62a17ae | 5405 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
5406 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5407 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5408 | "Filter updates to/from this neighbor\n" | |
5409 | "Name of a prefix list\n" | |
5410 | "Filter incoming updates\n" | |
5411 | "Filter outgoing updates\n") | |
596c17ba | 5412 | |
718e3744 | 5413 | DEFUN (no_neighbor_prefix_list, |
5414 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5415 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5416 | NO_STR |
5417 | NEIGHBOR_STR | |
5418 | NEIGHBOR_ADDR_STR2 | |
5419 | "Filter updates to/from this neighbor\n" | |
5420 | "Name of a prefix list\n" | |
5421 | "Filter incoming updates\n" | |
5422 | "Filter outgoing updates\n") | |
5423 | { | |
d62a17ae | 5424 | int idx_peer = 2; |
5425 | int idx_in_out = 5; | |
5426 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
5427 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5428 | argv[idx_in_out]->arg); | |
718e3744 | 5429 | } |
6b0655a2 | 5430 | |
d62a17ae | 5431 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
5432 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5433 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5434 | "Filter updates to/from this neighbor\n" | |
5435 | "Name of a prefix list\n" | |
5436 | "Filter incoming updates\n" | |
5437 | "Filter outgoing updates\n") | |
596c17ba | 5438 | |
d62a17ae | 5439 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5440 | safi_t safi, const char *name_str, | |
5441 | const char *direct_str) | |
718e3744 | 5442 | { |
d62a17ae | 5443 | int ret; |
5444 | struct peer *peer; | |
5445 | int direct = FILTER_IN; | |
718e3744 | 5446 | |
d62a17ae | 5447 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5448 | if (!peer) | |
5449 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5450 | |
d62a17ae | 5451 | /* Check filter direction. */ |
5452 | if (strncmp(direct_str, "i", 1) == 0) | |
5453 | direct = FILTER_IN; | |
5454 | else if (strncmp(direct_str, "o", 1) == 0) | |
5455 | direct = FILTER_OUT; | |
718e3744 | 5456 | |
d62a17ae | 5457 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 5458 | |
d62a17ae | 5459 | return bgp_vty_return(vty, ret); |
718e3744 | 5460 | } |
5461 | ||
d62a17ae | 5462 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5463 | safi_t safi, const char *direct_str) | |
718e3744 | 5464 | { |
d62a17ae | 5465 | int ret; |
5466 | struct peer *peer; | |
5467 | int direct = FILTER_IN; | |
718e3744 | 5468 | |
d62a17ae | 5469 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5470 | if (!peer) | |
5471 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5472 | |
d62a17ae | 5473 | /* Check filter direction. */ |
5474 | if (strncmp(direct_str, "i", 1) == 0) | |
5475 | direct = FILTER_IN; | |
5476 | else if (strncmp(direct_str, "o", 1) == 0) | |
5477 | direct = FILTER_OUT; | |
718e3744 | 5478 | |
d62a17ae | 5479 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 5480 | |
d62a17ae | 5481 | return bgp_vty_return(vty, ret); |
718e3744 | 5482 | } |
5483 | ||
5484 | DEFUN (neighbor_filter_list, | |
5485 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5486 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5487 | NEIGHBOR_STR |
5488 | NEIGHBOR_ADDR_STR2 | |
5489 | "Establish BGP filters\n" | |
5490 | "AS path access-list name\n" | |
5491 | "Filter incoming routes\n" | |
5492 | "Filter outgoing routes\n") | |
5493 | { | |
d62a17ae | 5494 | int idx_peer = 1; |
5495 | int idx_word = 3; | |
5496 | int idx_in_out = 4; | |
5497 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5498 | bgp_node_safi(vty), argv[idx_word]->arg, | |
5499 | argv[idx_in_out]->arg); | |
718e3744 | 5500 | } |
5501 | ||
d62a17ae | 5502 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
5503 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5504 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5505 | "Establish BGP filters\n" | |
5506 | "AS path access-list name\n" | |
5507 | "Filter incoming routes\n" | |
5508 | "Filter outgoing routes\n") | |
596c17ba | 5509 | |
718e3744 | 5510 | DEFUN (no_neighbor_filter_list, |
5511 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5512 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5513 | NO_STR |
5514 | NEIGHBOR_STR | |
5515 | NEIGHBOR_ADDR_STR2 | |
5516 | "Establish BGP filters\n" | |
5517 | "AS path access-list name\n" | |
5518 | "Filter incoming routes\n" | |
5519 | "Filter outgoing routes\n") | |
5520 | { | |
d62a17ae | 5521 | int idx_peer = 2; |
5522 | int idx_in_out = 5; | |
5523 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
5524 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5525 | argv[idx_in_out]->arg); | |
718e3744 | 5526 | } |
6b0655a2 | 5527 | |
d62a17ae | 5528 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
5529 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5530 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5531 | "Establish BGP filters\n" | |
5532 | "AS path access-list name\n" | |
5533 | "Filter incoming routes\n" | |
5534 | "Filter outgoing routes\n") | |
596c17ba | 5535 | |
718e3744 | 5536 | /* Set route-map to the peer. */ |
d62a17ae | 5537 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
5538 | afi_t afi, safi_t safi, const char *name_str, | |
5539 | const char *direct_str) | |
718e3744 | 5540 | { |
d62a17ae | 5541 | int ret; |
5542 | struct peer *peer; | |
5543 | int direct = RMAP_IN; | |
718e3744 | 5544 | |
d62a17ae | 5545 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5546 | if (!peer) | |
5547 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5548 | |
d62a17ae | 5549 | /* Check filter direction. */ |
5550 | if (strncmp(direct_str, "in", 2) == 0) | |
5551 | direct = RMAP_IN; | |
5552 | else if (strncmp(direct_str, "o", 1) == 0) | |
5553 | direct = RMAP_OUT; | |
718e3744 | 5554 | |
d62a17ae | 5555 | ret = peer_route_map_set(peer, afi, safi, direct, name_str); |
718e3744 | 5556 | |
d62a17ae | 5557 | return bgp_vty_return(vty, ret); |
718e3744 | 5558 | } |
5559 | ||
d62a17ae | 5560 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
5561 | afi_t afi, safi_t safi, | |
5562 | const char *direct_str) | |
718e3744 | 5563 | { |
d62a17ae | 5564 | int ret; |
5565 | struct peer *peer; | |
5566 | int direct = RMAP_IN; | |
718e3744 | 5567 | |
d62a17ae | 5568 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5569 | if (!peer) | |
5570 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5571 | |
d62a17ae | 5572 | /* Check filter direction. */ |
5573 | if (strncmp(direct_str, "in", 2) == 0) | |
5574 | direct = RMAP_IN; | |
5575 | else if (strncmp(direct_str, "o", 1) == 0) | |
5576 | direct = RMAP_OUT; | |
718e3744 | 5577 | |
d62a17ae | 5578 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 5579 | |
d62a17ae | 5580 | return bgp_vty_return(vty, ret); |
718e3744 | 5581 | } |
5582 | ||
5583 | DEFUN (neighbor_route_map, | |
5584 | neighbor_route_map_cmd, | |
9ccf14f7 | 5585 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5586 | NEIGHBOR_STR |
5587 | NEIGHBOR_ADDR_STR2 | |
5588 | "Apply route map to neighbor\n" | |
5589 | "Name of route map\n" | |
5590 | "Apply map to incoming routes\n" | |
2a3d5731 | 5591 | "Apply map to outbound routes\n") |
718e3744 | 5592 | { |
d62a17ae | 5593 | int idx_peer = 1; |
5594 | int idx_word = 3; | |
5595 | int idx_in_out = 4; | |
5596 | return peer_route_map_set_vty( | |
5597 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5598 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5599 | } |
5600 | ||
d62a17ae | 5601 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
5602 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5603 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5604 | "Apply route map to neighbor\n" | |
5605 | "Name of route map\n" | |
5606 | "Apply map to incoming routes\n" | |
5607 | "Apply map to outbound routes\n") | |
596c17ba | 5608 | |
718e3744 | 5609 | DEFUN (no_neighbor_route_map, |
5610 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5611 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5612 | NO_STR |
5613 | NEIGHBOR_STR | |
5614 | NEIGHBOR_ADDR_STR2 | |
5615 | "Apply route map to neighbor\n" | |
5616 | "Name of route map\n" | |
5617 | "Apply map to incoming routes\n" | |
2a3d5731 | 5618 | "Apply map to outbound routes\n") |
718e3744 | 5619 | { |
d62a17ae | 5620 | int idx_peer = 2; |
5621 | int idx_in_out = 5; | |
5622 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
5623 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5624 | argv[idx_in_out]->arg); | |
718e3744 | 5625 | } |
6b0655a2 | 5626 | |
d62a17ae | 5627 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
5628 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5629 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5630 | "Apply route map to neighbor\n" | |
5631 | "Name of route map\n" | |
5632 | "Apply map to incoming routes\n" | |
5633 | "Apply map to outbound routes\n") | |
596c17ba | 5634 | |
718e3744 | 5635 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 5636 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
5637 | afi_t afi, safi_t safi, | |
5638 | const char *name_str) | |
718e3744 | 5639 | { |
d62a17ae | 5640 | int ret; |
5641 | struct peer *peer; | |
718e3744 | 5642 | |
d62a17ae | 5643 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5644 | if (!peer) | |
5645 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5646 | |
d62a17ae | 5647 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str); |
718e3744 | 5648 | |
d62a17ae | 5649 | return bgp_vty_return(vty, ret); |
718e3744 | 5650 | } |
5651 | ||
5652 | /* Unset route-map from the peer. */ | |
d62a17ae | 5653 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
5654 | afi_t afi, safi_t safi) | |
718e3744 | 5655 | { |
d62a17ae | 5656 | int ret; |
5657 | struct peer *peer; | |
718e3744 | 5658 | |
d62a17ae | 5659 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5660 | if (!peer) | |
5661 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5662 | |
d62a17ae | 5663 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 5664 | |
d62a17ae | 5665 | return bgp_vty_return(vty, ret); |
718e3744 | 5666 | } |
5667 | ||
5668 | DEFUN (neighbor_unsuppress_map, | |
5669 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5670 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5671 | NEIGHBOR_STR |
5672 | NEIGHBOR_ADDR_STR2 | |
5673 | "Route-map to selectively unsuppress suppressed routes\n" | |
5674 | "Name of route map\n") | |
5675 | { | |
d62a17ae | 5676 | int idx_peer = 1; |
5677 | int idx_word = 3; | |
5678 | return peer_unsuppress_map_set_vty( | |
5679 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5680 | argv[idx_word]->arg); | |
718e3744 | 5681 | } |
5682 | ||
d62a17ae | 5683 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
5684 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5685 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5686 | "Route-map to selectively unsuppress suppressed routes\n" | |
5687 | "Name of route map\n") | |
596c17ba | 5688 | |
718e3744 | 5689 | DEFUN (no_neighbor_unsuppress_map, |
5690 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5691 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5692 | NO_STR |
5693 | NEIGHBOR_STR | |
5694 | NEIGHBOR_ADDR_STR2 | |
5695 | "Route-map to selectively unsuppress suppressed routes\n" | |
5696 | "Name of route map\n") | |
5697 | { | |
d62a17ae | 5698 | int idx_peer = 2; |
5699 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
5700 | bgp_node_afi(vty), | |
5701 | bgp_node_safi(vty)); | |
718e3744 | 5702 | } |
6b0655a2 | 5703 | |
d62a17ae | 5704 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
5705 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5706 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5707 | "Route-map to selectively unsuppress suppressed routes\n" | |
5708 | "Name of route map\n") | |
596c17ba | 5709 | |
d62a17ae | 5710 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
5711 | afi_t afi, safi_t safi, | |
5712 | const char *num_str, | |
5713 | const char *threshold_str, int warning, | |
5714 | const char *restart_str) | |
718e3744 | 5715 | { |
d62a17ae | 5716 | int ret; |
5717 | struct peer *peer; | |
d7c0a89a QY |
5718 | uint32_t max; |
5719 | uint8_t threshold; | |
5720 | uint16_t restart; | |
718e3744 | 5721 | |
d62a17ae | 5722 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5723 | if (!peer) | |
5724 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5725 | |
d62a17ae | 5726 | max = strtoul(num_str, NULL, 10); |
5727 | if (threshold_str) | |
5728 | threshold = atoi(threshold_str); | |
5729 | else | |
5730 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5731 | |
d62a17ae | 5732 | if (restart_str) |
5733 | restart = atoi(restart_str); | |
5734 | else | |
5735 | restart = 0; | |
0a486e5f | 5736 | |
d62a17ae | 5737 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
5738 | restart); | |
718e3744 | 5739 | |
d62a17ae | 5740 | return bgp_vty_return(vty, ret); |
718e3744 | 5741 | } |
5742 | ||
d62a17ae | 5743 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
5744 | afi_t afi, safi_t safi) | |
718e3744 | 5745 | { |
d62a17ae | 5746 | int ret; |
5747 | struct peer *peer; | |
718e3744 | 5748 | |
d62a17ae | 5749 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5750 | if (!peer) | |
5751 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5752 | |
d62a17ae | 5753 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 5754 | |
d62a17ae | 5755 | return bgp_vty_return(vty, ret); |
718e3744 | 5756 | } |
5757 | ||
5758 | /* Maximum number of prefix configuration. prefix count is different | |
5759 | for each peer configuration. So this configuration can be set for | |
5760 | each peer configuration. */ | |
5761 | DEFUN (neighbor_maximum_prefix, | |
5762 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5763 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5764 | NEIGHBOR_STR |
5765 | NEIGHBOR_ADDR_STR2 | |
5766 | "Maximum number of prefix accept from this peer\n" | |
5767 | "maximum no. of prefix limit\n") | |
5768 | { | |
d62a17ae | 5769 | int idx_peer = 1; |
5770 | int idx_number = 3; | |
5771 | return peer_maximum_prefix_set_vty( | |
5772 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5773 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 5774 | } |
5775 | ||
d62a17ae | 5776 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
5777 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
5778 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5779 | "Maximum number of prefix accept from this peer\n" | |
5780 | "maximum no. of prefix limit\n") | |
596c17ba | 5781 | |
e0701b79 | 5782 | DEFUN (neighbor_maximum_prefix_threshold, |
5783 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5784 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5785 | NEIGHBOR_STR |
5786 | NEIGHBOR_ADDR_STR2 | |
5787 | "Maximum number of prefix accept from this peer\n" | |
5788 | "maximum no. of prefix limit\n" | |
5789 | "Threshold value (%) at which to generate a warning msg\n") | |
5790 | { | |
d62a17ae | 5791 | int idx_peer = 1; |
5792 | int idx_number = 3; | |
5793 | int idx_number_2 = 4; | |
5794 | return peer_maximum_prefix_set_vty( | |
5795 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5796 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 5797 | } |
e0701b79 | 5798 | |
d62a17ae | 5799 | ALIAS_HIDDEN( |
5800 | neighbor_maximum_prefix_threshold, | |
5801 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
5802 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
5803 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5804 | "Maximum number of prefix accept from this peer\n" | |
5805 | "maximum no. of prefix limit\n" | |
5806 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 5807 | |
718e3744 | 5808 | DEFUN (neighbor_maximum_prefix_warning, |
5809 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5810 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5811 | NEIGHBOR_STR |
5812 | NEIGHBOR_ADDR_STR2 | |
5813 | "Maximum number of prefix accept from this peer\n" | |
5814 | "maximum no. of prefix limit\n" | |
5815 | "Only give warning message when limit is exceeded\n") | |
5816 | { | |
d62a17ae | 5817 | int idx_peer = 1; |
5818 | int idx_number = 3; | |
5819 | return peer_maximum_prefix_set_vty( | |
5820 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5821 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 5822 | } |
5823 | ||
d62a17ae | 5824 | ALIAS_HIDDEN( |
5825 | neighbor_maximum_prefix_warning, | |
5826 | neighbor_maximum_prefix_warning_hidden_cmd, | |
5827 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
5828 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5829 | "Maximum number of prefix accept from this peer\n" | |
5830 | "maximum no. of prefix limit\n" | |
5831 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5832 | |
e0701b79 | 5833 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5834 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5835 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5836 | NEIGHBOR_STR |
5837 | NEIGHBOR_ADDR_STR2 | |
5838 | "Maximum number of prefix accept from this peer\n" | |
5839 | "maximum no. of prefix limit\n" | |
5840 | "Threshold value (%) at which to generate a warning msg\n" | |
5841 | "Only give warning message when limit is exceeded\n") | |
5842 | { | |
d62a17ae | 5843 | int idx_peer = 1; |
5844 | int idx_number = 3; | |
5845 | int idx_number_2 = 4; | |
5846 | return peer_maximum_prefix_set_vty( | |
5847 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5848 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5849 | } |
5850 | ||
d62a17ae | 5851 | ALIAS_HIDDEN( |
5852 | neighbor_maximum_prefix_threshold_warning, | |
5853 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
5854 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
5855 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5856 | "Maximum number of prefix accept from this peer\n" | |
5857 | "maximum no. of prefix limit\n" | |
5858 | "Threshold value (%) at which to generate a warning msg\n" | |
5859 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5860 | |
0a486e5f | 5861 | DEFUN (neighbor_maximum_prefix_restart, |
5862 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5863 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 5864 | NEIGHBOR_STR |
5865 | NEIGHBOR_ADDR_STR2 | |
5866 | "Maximum number of prefix accept from this peer\n" | |
5867 | "maximum no. of prefix limit\n" | |
5868 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 5869 | "Restart interval in minutes\n") |
0a486e5f | 5870 | { |
d62a17ae | 5871 | int idx_peer = 1; |
5872 | int idx_number = 3; | |
5873 | int idx_number_2 = 5; | |
5874 | return peer_maximum_prefix_set_vty( | |
5875 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5876 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 5877 | } |
5878 | ||
d62a17ae | 5879 | ALIAS_HIDDEN( |
5880 | neighbor_maximum_prefix_restart, | |
5881 | neighbor_maximum_prefix_restart_hidden_cmd, | |
5882 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
5883 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5884 | "Maximum number of prefix accept from this peer\n" | |
5885 | "maximum no. of prefix limit\n" | |
5886 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 5887 | "Restart interval in minutes\n") |
596c17ba | 5888 | |
0a486e5f | 5889 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
5890 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 5891 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 5892 | NEIGHBOR_STR |
5893 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5894 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 5895 | "maximum no. of prefix limit\n" |
5896 | "Threshold value (%) at which to generate a warning msg\n" | |
5897 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5898 | "Restart interval in minutes\n") |
0a486e5f | 5899 | { |
d62a17ae | 5900 | int idx_peer = 1; |
5901 | int idx_number = 3; | |
5902 | int idx_number_2 = 4; | |
5903 | int idx_number_3 = 6; | |
5904 | return peer_maximum_prefix_set_vty( | |
5905 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5906 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
5907 | argv[idx_number_3]->arg); | |
5908 | } | |
5909 | ||
5910 | ALIAS_HIDDEN( | |
5911 | neighbor_maximum_prefix_threshold_restart, | |
5912 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
5913 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
5914 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5915 | "Maximum number of prefixes to accept from this peer\n" | |
5916 | "maximum no. of prefix limit\n" | |
5917 | "Threshold value (%) at which to generate a warning msg\n" | |
5918 | "Restart bgp connection after limit is exceeded\n" | |
5919 | "Restart interval in minutes\n") | |
596c17ba | 5920 | |
718e3744 | 5921 | DEFUN (no_neighbor_maximum_prefix, |
5922 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 5923 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 5924 | NO_STR |
5925 | NEIGHBOR_STR | |
5926 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5927 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
5928 | "maximum no. of prefix limit\n" |
5929 | "Threshold value (%) at which to generate a warning msg\n" | |
5930 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5931 | "Restart interval in minutes\n" |
31500417 | 5932 | "Only give warning message when limit is exceeded\n") |
718e3744 | 5933 | { |
d62a17ae | 5934 | int idx_peer = 2; |
5935 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
5936 | bgp_node_afi(vty), | |
5937 | bgp_node_safi(vty)); | |
718e3744 | 5938 | } |
e52702f2 | 5939 | |
d62a17ae | 5940 | ALIAS_HIDDEN( |
5941 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
5942 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
5943 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5944 | "Maximum number of prefixes to accept from this peer\n" | |
5945 | "maximum no. of prefix limit\n" | |
5946 | "Threshold value (%) at which to generate a warning msg\n" | |
5947 | "Restart bgp connection after limit is exceeded\n" | |
5948 | "Restart interval in minutes\n" | |
5949 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5950 | |
718e3744 | 5951 | |
718e3744 | 5952 | /* "neighbor allowas-in" */ |
5953 | DEFUN (neighbor_allowas_in, | |
5954 | neighbor_allowas_in_cmd, | |
fd8503f5 | 5955 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5956 | NEIGHBOR_STR |
5957 | NEIGHBOR_ADDR_STR2 | |
31500417 | 5958 | "Accept as-path with my AS present in it\n" |
fd8503f5 QY |
5959 | "Number of occurances of AS number\n" |
5960 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5961 | { |
d62a17ae | 5962 | int idx_peer = 1; |
5963 | int idx_number_origin = 3; | |
5964 | int ret; | |
5965 | int origin = 0; | |
5966 | struct peer *peer; | |
5967 | int allow_num = 0; | |
5968 | ||
5969 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5970 | if (!peer) | |
5971 | return CMD_WARNING_CONFIG_FAILED; | |
5972 | ||
5973 | if (argc <= idx_number_origin) | |
5974 | allow_num = 3; | |
5975 | else { | |
5976 | if (argv[idx_number_origin]->type == WORD_TKN) | |
5977 | origin = 1; | |
5978 | else | |
5979 | allow_num = atoi(argv[idx_number_origin]->arg); | |
5980 | } | |
5981 | ||
5982 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5983 | allow_num, origin); | |
5984 | ||
5985 | return bgp_vty_return(vty, ret); | |
5986 | } | |
5987 | ||
5988 | ALIAS_HIDDEN( | |
5989 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
5990 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
5991 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5992 | "Accept as-path with my AS present in it\n" | |
5993 | "Number of occurances of AS number\n" | |
5994 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
596c17ba | 5995 | |
718e3744 | 5996 | DEFUN (no_neighbor_allowas_in, |
5997 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 5998 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5999 | NO_STR |
6000 | NEIGHBOR_STR | |
6001 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6002 | "allow local ASN appears in aspath attribute\n" |
fd8503f5 QY |
6003 | "Number of occurances of AS number\n" |
6004 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 6005 | { |
d62a17ae | 6006 | int idx_peer = 2; |
6007 | int ret; | |
6008 | struct peer *peer; | |
718e3744 | 6009 | |
d62a17ae | 6010 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6011 | if (!peer) | |
6012 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6013 | |
d62a17ae | 6014 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6015 | bgp_node_safi(vty)); | |
718e3744 | 6016 | |
d62a17ae | 6017 | return bgp_vty_return(vty, ret); |
718e3744 | 6018 | } |
6b0655a2 | 6019 | |
d62a17ae | 6020 | ALIAS_HIDDEN( |
6021 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6022 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6023 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6024 | "allow local ASN appears in aspath attribute\n" | |
6025 | "Number of occurances of AS number\n" | |
6026 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
596c17ba | 6027 | |
fa411a21 NH |
6028 | DEFUN (neighbor_ttl_security, |
6029 | neighbor_ttl_security_cmd, | |
7ebe625c | 6030 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6031 | NEIGHBOR_STR |
7ebe625c | 6032 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6033 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6034 | "Specify the maximum number of hops to the BGP peer\n" |
6035 | "Number of hops to BGP peer\n") | |
fa411a21 | 6036 | { |
d62a17ae | 6037 | int idx_peer = 1; |
6038 | int idx_number = 4; | |
6039 | struct peer *peer; | |
6040 | int gtsm_hops; | |
6041 | ||
6042 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6043 | if (!peer) | |
6044 | return CMD_WARNING_CONFIG_FAILED; | |
6045 | ||
6046 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6047 | ||
7ebe625c QY |
6048 | /* |
6049 | * If 'neighbor swpX', then this is for directly connected peers, | |
6050 | * we should not accept a ttl-security hops value greater than 1. | |
6051 | */ | |
6052 | if (peer->conf_if && (gtsm_hops > 1)) { | |
6053 | vty_out(vty, | |
6054 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6055 | argv[idx_peer]->arg); | |
6056 | return CMD_WARNING_CONFIG_FAILED; | |
6057 | } | |
6058 | ||
d62a17ae | 6059 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6060 | } |
6061 | ||
6062 | DEFUN (no_neighbor_ttl_security, | |
6063 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6064 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6065 | NO_STR |
6066 | NEIGHBOR_STR | |
7ebe625c | 6067 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6068 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6069 | "Specify the maximum number of hops to the BGP peer\n" |
6070 | "Number of hops to BGP peer\n") | |
fa411a21 | 6071 | { |
d62a17ae | 6072 | int idx_peer = 2; |
6073 | struct peer *peer; | |
fa411a21 | 6074 | |
d62a17ae | 6075 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6076 | if (!peer) | |
6077 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6078 | |
d62a17ae | 6079 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6080 | } |
6b0655a2 | 6081 | |
adbac85e DW |
6082 | DEFUN (neighbor_addpath_tx_all_paths, |
6083 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6084 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6085 | NEIGHBOR_STR |
6086 | NEIGHBOR_ADDR_STR2 | |
6087 | "Use addpath to advertise all paths to a neighbor\n") | |
6088 | { | |
d62a17ae | 6089 | int idx_peer = 1; |
6090 | struct peer *peer; | |
adbac85e | 6091 | |
d62a17ae | 6092 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6093 | if (!peer) | |
6094 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6095 | |
d62a17ae | 6096 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6097 | bgp_node_safi(vty), | |
6098 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
adbac85e DW |
6099 | } |
6100 | ||
d62a17ae | 6101 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6102 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6103 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6104 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6105 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6106 | |
adbac85e DW |
6107 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6108 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6109 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6110 | NO_STR |
6111 | NEIGHBOR_STR | |
6112 | NEIGHBOR_ADDR_STR2 | |
6113 | "Use addpath to advertise all paths to a neighbor\n") | |
6114 | { | |
d62a17ae | 6115 | int idx_peer = 2; |
6116 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6117 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6118 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
adbac85e DW |
6119 | } |
6120 | ||
d62a17ae | 6121 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6122 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6123 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6124 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6125 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6126 | |
06370dac DW |
6127 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6128 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6129 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6130 | NEIGHBOR_STR |
6131 | NEIGHBOR_ADDR_STR2 | |
6132 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6133 | { | |
d62a17ae | 6134 | int idx_peer = 1; |
6135 | struct peer *peer; | |
06370dac | 6136 | |
d62a17ae | 6137 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6138 | if (!peer) | |
6139 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 6140 | |
d62a17ae | 6141 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6142 | bgp_node_safi(vty), | |
6143 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
06370dac DW |
6144 | } |
6145 | ||
d62a17ae | 6146 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
6147 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6148 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6149 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6150 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6151 | |
06370dac DW |
6152 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
6153 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6154 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6155 | NO_STR |
6156 | NEIGHBOR_STR | |
6157 | NEIGHBOR_ADDR_STR2 | |
6158 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6159 | { | |
d62a17ae | 6160 | int idx_peer = 2; |
6161 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6162 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6163 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
06370dac DW |
6164 | } |
6165 | ||
d62a17ae | 6166 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
6167 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6168 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6169 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6170 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6171 | |
b9c7bc5a PZ |
6172 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
6173 | struct ecommunity **list) | |
ddb5b488 | 6174 | { |
b9c7bc5a PZ |
6175 | struct ecommunity *ecom = NULL; |
6176 | struct ecommunity *ecomadd; | |
ddb5b488 | 6177 | |
b9c7bc5a | 6178 | for (; argc; --argc, ++argv) { |
ddb5b488 | 6179 | |
b9c7bc5a PZ |
6180 | ecomadd = ecommunity_str2com(argv[0]->arg, |
6181 | ECOMMUNITY_ROUTE_TARGET, 0); | |
6182 | if (!ecomadd) { | |
6183 | vty_out(vty, "Malformed community-list value\n"); | |
6184 | if (ecom) | |
6185 | ecommunity_free(&ecom); | |
6186 | return CMD_WARNING_CONFIG_FAILED; | |
6187 | } | |
ddb5b488 | 6188 | |
b9c7bc5a PZ |
6189 | if (ecom) { |
6190 | ecommunity_merge(ecom, ecomadd); | |
6191 | ecommunity_free(&ecomadd); | |
6192 | } else { | |
6193 | ecom = ecomadd; | |
6194 | } | |
6195 | } | |
6196 | ||
6197 | if (*list) { | |
6198 | ecommunity_free(&*list); | |
ddb5b488 | 6199 | } |
b9c7bc5a PZ |
6200 | *list = ecom; |
6201 | ||
6202 | return CMD_SUCCESS; | |
ddb5b488 PZ |
6203 | } |
6204 | ||
0ca70ba5 DS |
6205 | /* |
6206 | * v2vimport is true if we are handling a `import vrf ...` command | |
6207 | */ | |
6208 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 6209 | { |
0ca70ba5 DS |
6210 | afi_t afi; |
6211 | ||
ddb5b488 | 6212 | switch (vty->node) { |
b9c7bc5a | 6213 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
6214 | afi = AFI_IP; |
6215 | break; | |
b9c7bc5a | 6216 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
6217 | afi = AFI_IP6; |
6218 | break; | |
ddb5b488 PZ |
6219 | default: |
6220 | vty_out(vty, | |
b9c7bc5a | 6221 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 6222 | return AFI_MAX; |
ddb5b488 | 6223 | } |
69b07479 | 6224 | |
0ca70ba5 DS |
6225 | if (!v2vimport) { |
6226 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6227 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
6228 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6229 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
6230 | vty_out(vty, | |
6231 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
6232 | return AFI_MAX; | |
6233 | } | |
6234 | } else { | |
6235 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6236 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
6237 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6238 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
6239 | vty_out(vty, | |
6240 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
6241 | return AFI_MAX; | |
6242 | } | |
6243 | } | |
6244 | return afi; | |
ddb5b488 PZ |
6245 | } |
6246 | ||
b9c7bc5a PZ |
6247 | DEFPY (af_rd_vpn_export, |
6248 | af_rd_vpn_export_cmd, | |
6249 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
6250 | NO_STR | |
ddb5b488 | 6251 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
6252 | "Between current address-family and vpn\n" |
6253 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6254 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
6255 | { | |
6256 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6257 | struct prefix_rd prd; | |
6258 | int ret; | |
ddb5b488 | 6259 | afi_t afi; |
b9c7bc5a PZ |
6260 | int idx = 0; |
6261 | int yes = 1; | |
ddb5b488 | 6262 | |
b9c7bc5a | 6263 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6264 | yes = 0; |
b9c7bc5a PZ |
6265 | |
6266 | if (yes) { | |
6267 | ret = str2prefix_rd(rd_str, &prd); | |
6268 | if (!ret) { | |
6269 | vty_out(vty, "%% Malformed rd\n"); | |
6270 | return CMD_WARNING_CONFIG_FAILED; | |
6271 | } | |
ddb5b488 PZ |
6272 | } |
6273 | ||
0ca70ba5 | 6274 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6275 | if (afi == AFI_MAX) |
6276 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6277 | |
69b07479 DS |
6278 | /* |
6279 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6280 | */ | |
6281 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6282 | bgp_get_default(), bgp); | |
ddb5b488 | 6283 | |
69b07479 DS |
6284 | if (yes) { |
6285 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
6286 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6287 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
6288 | } else { | |
6289 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6290 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
6291 | } |
6292 | ||
69b07479 DS |
6293 | /* post-change: re-export vpn routes */ |
6294 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6295 | bgp_get_default(), bgp); | |
6296 | ||
ddb5b488 PZ |
6297 | return CMD_SUCCESS; |
6298 | } | |
6299 | ||
b9c7bc5a PZ |
6300 | ALIAS (af_rd_vpn_export, |
6301 | af_no_rd_vpn_export_cmd, | |
6302 | "no rd vpn export", | |
ddb5b488 | 6303 | NO_STR |
b9c7bc5a PZ |
6304 | "Specify route distinguisher\n" |
6305 | "Between current address-family and vpn\n" | |
6306 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6307 | |
b9c7bc5a PZ |
6308 | DEFPY (af_label_vpn_export, |
6309 | af_label_vpn_export_cmd, | |
e70e9f8e | 6310 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 6311 | NO_STR |
ddb5b488 | 6312 | "label value for VRF\n" |
b9c7bc5a PZ |
6313 | "Between current address-family and vpn\n" |
6314 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
6315 | "Label Value <0-1048575>\n" |
6316 | "Automatically assign a label\n") | |
ddb5b488 PZ |
6317 | { |
6318 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6319 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 6320 | afi_t afi; |
b9c7bc5a PZ |
6321 | int idx = 0; |
6322 | int yes = 1; | |
6323 | ||
6324 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 6325 | yes = 0; |
ddb5b488 | 6326 | |
21a16cc2 PZ |
6327 | /* If "no ...", squash trailing parameter */ |
6328 | if (!yes) | |
6329 | label_auto = NULL; | |
6330 | ||
e70e9f8e PZ |
6331 | if (yes) { |
6332 | if (!label_auto) | |
6333 | label = label_val; /* parser should force unsigned */ | |
6334 | } | |
ddb5b488 | 6335 | |
0ca70ba5 | 6336 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6337 | if (afi == AFI_MAX) |
6338 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 6339 | |
e70e9f8e | 6340 | |
69b07479 DS |
6341 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
6342 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
6343 | /* no change */ | |
6344 | return CMD_SUCCESS; | |
e70e9f8e | 6345 | |
69b07479 DS |
6346 | /* |
6347 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6348 | */ | |
6349 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6350 | bgp_get_default(), bgp); | |
6351 | ||
6352 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
6353 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
6354 | ||
6355 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
6356 | ||
6357 | /* | |
6358 | * label has previously been automatically | |
6359 | * assigned by labelpool: release it | |
6360 | * | |
6361 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
6362 | * means the automatic assignment is in flight | |
6363 | * and therefore the labelpool callback must | |
6364 | * detect that the auto label is not needed. | |
6365 | */ | |
6366 | ||
6367 | bgp_lp_release(LP_TYPE_VRF, | |
6368 | &bgp->vpn_policy[afi], | |
6369 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 6370 | } |
69b07479 DS |
6371 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
6372 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6373 | } | |
ddb5b488 | 6374 | |
69b07479 DS |
6375 | bgp->vpn_policy[afi].tovpn_label = label; |
6376 | if (label_auto) { | |
6377 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6378 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6379 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
6380 | vpn_leak_label_callback); | |
ddb5b488 PZ |
6381 | } |
6382 | ||
69b07479 DS |
6383 | /* post-change: re-export vpn routes */ |
6384 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6385 | bgp_get_default(), bgp); | |
6386 | ||
ddb5b488 PZ |
6387 | return CMD_SUCCESS; |
6388 | } | |
6389 | ||
b9c7bc5a PZ |
6390 | ALIAS (af_label_vpn_export, |
6391 | af_no_label_vpn_export_cmd, | |
6392 | "no label vpn export", | |
6393 | NO_STR | |
6394 | "label value for VRF\n" | |
6395 | "Between current address-family and vpn\n" | |
6396 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6397 | |
b9c7bc5a PZ |
6398 | DEFPY (af_nexthop_vpn_export, |
6399 | af_nexthop_vpn_export_cmd, | |
6400 | "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str", | |
6401 | NO_STR | |
ddb5b488 | 6402 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
6403 | "Between current address-family and vpn\n" |
6404 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6405 | "IPv4 prefix\n" |
6406 | "IPv6 prefix\n") | |
6407 | { | |
6408 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 6409 | afi_t afi; |
ddb5b488 | 6410 | struct prefix p; |
b9c7bc5a PZ |
6411 | int idx = 0; |
6412 | int yes = 1; | |
ddb5b488 | 6413 | |
b9c7bc5a | 6414 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6415 | yes = 0; |
b9c7bc5a PZ |
6416 | |
6417 | if (yes) { | |
6418 | if (!sockunion2hostprefix(nexthop_str, &p)) | |
6419 | return CMD_WARNING_CONFIG_FAILED; | |
6420 | } | |
ddb5b488 | 6421 | |
0ca70ba5 | 6422 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6423 | if (afi == AFI_MAX) |
6424 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6425 | |
69b07479 DS |
6426 | /* |
6427 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6428 | */ | |
6429 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6430 | bgp_get_default(), bgp); | |
ddb5b488 | 6431 | |
69b07479 DS |
6432 | if (yes) { |
6433 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
6434 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6435 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
6436 | } else { | |
6437 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6438 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
6439 | } |
6440 | ||
69b07479 DS |
6441 | /* post-change: re-export vpn routes */ |
6442 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6443 | bgp_get_default(), bgp); | |
6444 | ||
ddb5b488 PZ |
6445 | return CMD_SUCCESS; |
6446 | } | |
6447 | ||
b9c7bc5a PZ |
6448 | ALIAS (af_nexthop_vpn_export, |
6449 | af_no_nexthop_vpn_export_cmd, | |
6450 | "no nexthop vpn export", | |
ddb5b488 | 6451 | NO_STR |
b9c7bc5a PZ |
6452 | "Specify next hop to use for VRF advertised prefixes\n" |
6453 | "Between current address-family and vpn\n" | |
6454 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6455 | |
b9c7bc5a | 6456 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 6457 | { |
b9c7bc5a PZ |
6458 | if (!strcmp(dstr, "import")) { |
6459 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6460 | } else if (!strcmp(dstr, "export")) { | |
6461 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6462 | } else if (!strcmp(dstr, "both")) { | |
6463 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6464 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6465 | } else { | |
6466 | vty_out(vty, "%% direction parse error\n"); | |
6467 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6468 | } |
ddb5b488 PZ |
6469 | return CMD_SUCCESS; |
6470 | } | |
6471 | ||
b9c7bc5a PZ |
6472 | DEFPY (af_rt_vpn_imexport, |
6473 | af_rt_vpn_imexport_cmd, | |
6474 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
6475 | NO_STR | |
6476 | "Specify route target list\n" | |
ddb5b488 | 6477 | "Specify route target list\n" |
b9c7bc5a PZ |
6478 | "Between current address-family and vpn\n" |
6479 | "For routes leaked from vpn to current address-family: match any\n" | |
6480 | "For routes leaked from current address-family to vpn: set\n" | |
6481 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
6482 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
6483 | { | |
6484 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6485 | int ret; | |
6486 | struct ecommunity *ecom = NULL; | |
6487 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6488 | vpn_policy_direction_t dir; |
6489 | afi_t afi; | |
6490 | int idx = 0; | |
b9c7bc5a | 6491 | int yes = 1; |
ddb5b488 | 6492 | |
b9c7bc5a | 6493 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6494 | yes = 0; |
b9c7bc5a | 6495 | |
0ca70ba5 | 6496 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6497 | if (afi == AFI_MAX) |
6498 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6499 | |
b9c7bc5a | 6500 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6501 | if (ret != CMD_SUCCESS) |
6502 | return ret; | |
6503 | ||
b9c7bc5a PZ |
6504 | if (yes) { |
6505 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
6506 | vty_out(vty, "%% Missing RTLIST\n"); | |
6507 | return CMD_WARNING_CONFIG_FAILED; | |
6508 | } | |
6509 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
6510 | if (ret != CMD_SUCCESS) { | |
6511 | return ret; | |
6512 | } | |
ddb5b488 PZ |
6513 | } |
6514 | ||
69b07479 DS |
6515 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6516 | if (!dodir[dir]) | |
ddb5b488 | 6517 | continue; |
ddb5b488 | 6518 | |
69b07479 | 6519 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6520 | |
69b07479 DS |
6521 | if (yes) { |
6522 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6523 | ecommunity_free( | |
6524 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6525 | bgp->vpn_policy[afi].rtlist[dir] = | |
6526 | ecommunity_dup(ecom); | |
6527 | } else { | |
6528 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6529 | ecommunity_free( | |
6530 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6531 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 6532 | } |
69b07479 DS |
6533 | |
6534 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 6535 | } |
69b07479 | 6536 | |
d555f3e9 PZ |
6537 | if (ecom) |
6538 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
6539 | |
6540 | return CMD_SUCCESS; | |
6541 | } | |
6542 | ||
b9c7bc5a PZ |
6543 | ALIAS (af_rt_vpn_imexport, |
6544 | af_no_rt_vpn_imexport_cmd, | |
6545 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
6546 | NO_STR |
6547 | "Specify route target list\n" | |
b9c7bc5a PZ |
6548 | "Specify route target list\n" |
6549 | "Between current address-family and vpn\n" | |
6550 | "For routes leaked from vpn to current address-family\n" | |
6551 | "For routes leaked from current address-family to vpn\n" | |
6552 | "both import and export\n") | |
6553 | ||
6554 | DEFPY (af_route_map_vpn_imexport, | |
6555 | af_route_map_vpn_imexport_cmd, | |
6556 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
6557 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
6558 | NO_STR | |
ddb5b488 | 6559 | "Specify route map\n" |
b9c7bc5a PZ |
6560 | "Between current address-family and vpn\n" |
6561 | "For routes leaked from vpn to current address-family\n" | |
6562 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6563 | "name of route-map\n") |
6564 | { | |
6565 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6566 | int ret; | |
6567 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6568 | vpn_policy_direction_t dir; |
6569 | afi_t afi; | |
ddb5b488 | 6570 | int idx = 0; |
b9c7bc5a | 6571 | int yes = 1; |
ddb5b488 | 6572 | |
b9c7bc5a | 6573 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6574 | yes = 0; |
b9c7bc5a | 6575 | |
0ca70ba5 | 6576 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6577 | if (afi == AFI_MAX) |
6578 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6579 | |
b9c7bc5a | 6580 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6581 | if (ret != CMD_SUCCESS) |
6582 | return ret; | |
6583 | ||
69b07479 DS |
6584 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6585 | if (!dodir[dir]) | |
ddb5b488 | 6586 | continue; |
ddb5b488 | 6587 | |
69b07479 | 6588 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6589 | |
69b07479 DS |
6590 | if (yes) { |
6591 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6592 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6593 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6594 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
6595 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6596 | bgp->vpn_policy[afi].rmap[dir] = | |
6597 | route_map_lookup_by_name(rmap_str); | |
6598 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
6599 | return CMD_SUCCESS; | |
6600 | } else { | |
6601 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6602 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6603 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6604 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6605 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 6606 | } |
69b07479 DS |
6607 | |
6608 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
6609 | } |
6610 | ||
6611 | return CMD_SUCCESS; | |
6612 | } | |
6613 | ||
b9c7bc5a PZ |
6614 | ALIAS (af_route_map_vpn_imexport, |
6615 | af_no_route_map_vpn_imexport_cmd, | |
6616 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
6617 | NO_STR |
6618 | "Specify route map\n" | |
b9c7bc5a PZ |
6619 | "Between current address-family and vpn\n" |
6620 | "For routes leaked from vpn to current address-family\n" | |
6621 | "For routes leaked from current address-family to vpn\n") | |
6622 | ||
bb4f6190 DS |
6623 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
6624 | "[no] import vrf route-map RMAP$rmap_str", | |
6625 | NO_STR | |
6626 | "Import routes from another VRF\n" | |
6627 | "Vrf routes being filtered\n" | |
6628 | "Specify route map\n" | |
6629 | "name of route-map\n") | |
6630 | { | |
6631 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
6632 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
6633 | afi_t afi; | |
6634 | int idx = 0; | |
6635 | int yes = 1; | |
6636 | struct bgp *bgp_default; | |
6637 | ||
6638 | if (argv_find(argv, argc, "no", &idx)) | |
6639 | yes = 0; | |
6640 | ||
0ca70ba5 | 6641 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
6642 | if (afi == AFI_MAX) |
6643 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
6644 | |
6645 | bgp_default = bgp_get_default(); | |
6646 | if (!bgp_default) { | |
6647 | int32_t ret; | |
6648 | as_t as = bgp->as; | |
6649 | ||
6650 | /* Auto-create assuming the same AS */ | |
6651 | ret = bgp_get(&bgp_default, &as, NULL, | |
6652 | BGP_INSTANCE_TYPE_DEFAULT); | |
6653 | ||
6654 | if (ret) { | |
6655 | vty_out(vty, | |
6656 | "VRF default is not configured as a bgp instance\n"); | |
6657 | return CMD_WARNING; | |
6658 | } | |
6659 | } | |
6660 | ||
69b07479 | 6661 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 6662 | |
69b07479 DS |
6663 | if (yes) { |
6664 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6665 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6666 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6667 | bgp->vpn_policy[afi].rmap_name[dir] = | |
6668 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6669 | bgp->vpn_policy[afi].rmap[dir] = | |
6670 | route_map_lookup_by_name(rmap_str); | |
6671 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
6672 | return CMD_SUCCESS; | |
6673 | } else { | |
6674 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6675 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6676 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6677 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6678 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
bb4f6190 DS |
6679 | } |
6680 | ||
69b07479 DS |
6681 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
6682 | ||
bb4f6190 DS |
6683 | return CMD_SUCCESS; |
6684 | } | |
6685 | ||
6686 | ALIAS(af_import_vrf_route_map, af_no_import_vrf_route_map_cmd, | |
6687 | "no import vrf route-map", | |
6688 | NO_STR | |
6689 | "Import routes from another VRF\n" | |
6690 | "Vrf routes being filtered\n" | |
6691 | "Specify route map\n") | |
6692 | ||
12a844a5 DS |
6693 | DEFPY (bgp_imexport_vrf, |
6694 | bgp_imexport_vrf_cmd, | |
6695 | "[no] import vrf NAME$import_name", | |
6696 | NO_STR | |
6697 | "Import routes from another VRF\n" | |
6698 | "VRF to import from\n" | |
6699 | "The name of the VRF\n") | |
6700 | { | |
6701 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6702 | struct listnode *node; | |
79ef8664 DS |
6703 | struct bgp *vrf_bgp, *bgp_default; |
6704 | int32_t ret = 0; | |
6705 | as_t as = bgp->as; | |
12a844a5 DS |
6706 | bool remove = false; |
6707 | int32_t idx = 0; | |
6708 | char *vname; | |
a8dadcf6 | 6709 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
6710 | safi_t safi; |
6711 | afi_t afi; | |
6712 | ||
6713 | if (argv_find(argv, argc, "no", &idx)) | |
6714 | remove = true; | |
6715 | ||
0ca70ba5 DS |
6716 | afi = vpn_policy_getafi(vty, bgp, true); |
6717 | if (afi == AFI_MAX) | |
6718 | return CMD_WARNING_CONFIG_FAILED; | |
6719 | ||
12a844a5 DS |
6720 | safi = bgp_node_safi(vty); |
6721 | ||
25679caa DS |
6722 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
6723 | && (strcmp(import_name, BGP_DEFAULT_NAME) == 0)) | |
6724 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { | |
6725 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
6726 | remove ? "unimport" : "import", import_name); | |
6727 | return CMD_WARNING; | |
6728 | } | |
6729 | ||
79ef8664 DS |
6730 | bgp_default = bgp_get_default(); |
6731 | if (!bgp_default) { | |
6732 | /* Auto-create assuming the same AS */ | |
6733 | ret = bgp_get(&bgp_default, &as, NULL, | |
6734 | BGP_INSTANCE_TYPE_DEFAULT); | |
6735 | ||
6736 | if (ret) { | |
6737 | vty_out(vty, | |
6738 | "VRF default is not configured as a bgp instance\n"); | |
6739 | return CMD_WARNING; | |
6740 | } | |
6741 | } | |
6742 | ||
12a844a5 DS |
6743 | vrf_bgp = bgp_lookup_by_name(import_name); |
6744 | if (!vrf_bgp) { | |
79ef8664 DS |
6745 | if (strcmp(import_name, BGP_DEFAULT_NAME) == 0) |
6746 | vrf_bgp = bgp_default; | |
6747 | else | |
0fb8d6e6 DS |
6748 | /* Auto-create assuming the same AS */ |
6749 | ret = bgp_get(&vrf_bgp, &as, import_name, bgp_type); | |
a8dadcf6 | 6750 | |
6e2c7fe6 | 6751 | if (ret) { |
020a3f60 DS |
6752 | vty_out(vty, |
6753 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
6754 | import_name); |
6755 | return CMD_WARNING; | |
6756 | } | |
12a844a5 DS |
6757 | } |
6758 | ||
12a844a5 | 6759 | if (remove) { |
44338987 | 6760 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 6761 | } else { |
44338987 | 6762 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
6763 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
6764 | vname)) { | |
6765 | if (strcmp(vname, import_name) == 0) | |
6766 | return CMD_WARNING; | |
6767 | } | |
6768 | ||
44338987 | 6769 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
6770 | } |
6771 | ||
6772 | return CMD_SUCCESS; | |
6773 | } | |
6774 | ||
b9c7bc5a PZ |
6775 | /* This command is valid only in a bgp vrf instance or the default instance */ |
6776 | DEFPY (bgp_imexport_vpn, | |
6777 | bgp_imexport_vpn_cmd, | |
6778 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
6779 | NO_STR |
6780 | "Import routes to this address-family\n" | |
6781 | "Export routes from this address-family\n" | |
6782 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
6783 | { |
6784 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6785 | int previous_state; |
ddb5b488 | 6786 | afi_t afi; |
b9c7bc5a | 6787 | safi_t safi; |
ddb5b488 | 6788 | int idx = 0; |
b9c7bc5a PZ |
6789 | int yes = 1; |
6790 | int flag; | |
6791 | vpn_policy_direction_t dir; | |
ddb5b488 | 6792 | |
b9c7bc5a | 6793 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6794 | yes = 0; |
ddb5b488 | 6795 | |
b9c7bc5a PZ |
6796 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
6797 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 6798 | |
b9c7bc5a PZ |
6799 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
6800 | return CMD_WARNING_CONFIG_FAILED; | |
6801 | } | |
ddb5b488 | 6802 | |
b9c7bc5a PZ |
6803 | afi = bgp_node_afi(vty); |
6804 | safi = bgp_node_safi(vty); | |
6805 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
6806 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
6807 | return CMD_WARNING_CONFIG_FAILED; | |
6808 | } | |
ddb5b488 | 6809 | |
b9c7bc5a PZ |
6810 | if (!strcmp(direction_str, "import")) { |
6811 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
6812 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
6813 | } else if (!strcmp(direction_str, "export")) { | |
6814 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
6815 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
6816 | } else { | |
6817 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
6818 | return CMD_WARNING_CONFIG_FAILED; | |
6819 | } | |
6820 | ||
6821 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 6822 | |
b9c7bc5a PZ |
6823 | if (yes) { |
6824 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
6825 | if (!previous_state) { | |
6826 | /* trigger export current vrf */ | |
ddb5b488 PZ |
6827 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
6828 | } | |
b9c7bc5a PZ |
6829 | } else { |
6830 | if (previous_state) { | |
6831 | /* trigger un-export current vrf */ | |
6832 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
6833 | } | |
6834 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
6835 | } |
6836 | ||
6837 | return CMD_SUCCESS; | |
6838 | } | |
6839 | ||
301ad80a PG |
6840 | DEFPY (af_routetarget_import, |
6841 | af_routetarget_import_cmd, | |
6842 | "[no] <rt|route-target> redirect import RTLIST...", | |
6843 | NO_STR | |
6844 | "Specify route target list\n" | |
6845 | "Specify route target list\n" | |
6846 | "Flow-spec redirect type route target\n" | |
6847 | "Import routes to this address-family\n" | |
6848 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
6849 | { | |
6850 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6851 | int ret; | |
6852 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
6853 | afi_t afi; |
6854 | int idx = 0; | |
6855 | int yes = 1; | |
6856 | ||
6857 | if (argv_find(argv, argc, "no", &idx)) | |
6858 | yes = 0; | |
6859 | ||
0ca70ba5 | 6860 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6861 | if (afi == AFI_MAX) |
6862 | return CMD_WARNING_CONFIG_FAILED; | |
6863 | ||
301ad80a PG |
6864 | if (yes) { |
6865 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
6866 | vty_out(vty, "%% Missing RTLIST\n"); | |
6867 | return CMD_WARNING_CONFIG_FAILED; | |
6868 | } | |
6869 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
6870 | if (ret != CMD_SUCCESS) | |
6871 | return ret; | |
6872 | } | |
69b07479 DS |
6873 | |
6874 | if (yes) { | |
6875 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
6876 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 6877 | .import_redirect_rtlist); |
69b07479 DS |
6878 | bgp->vpn_policy[afi].import_redirect_rtlist = |
6879 | ecommunity_dup(ecom); | |
6880 | } else { | |
6881 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
6882 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 6883 | .import_redirect_rtlist); |
69b07479 | 6884 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 6885 | } |
69b07479 | 6886 | |
301ad80a PG |
6887 | if (ecom) |
6888 | ecommunity_free(&ecom); | |
6889 | ||
6890 | return CMD_SUCCESS; | |
6891 | } | |
6892 | ||
505e5056 | 6893 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 6894 | address_family_ipv4_safi_cmd, |
6895 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
6896 | "Enter Address Family command mode\n" | |
6897 | "Address Family\n" | |
6898 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 6899 | { |
f51bae9c | 6900 | |
d62a17ae | 6901 | if (argc == 3) { |
2131d5cf | 6902 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 6903 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
6904 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
6905 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 6906 | && safi != SAFI_EVPN) { |
31947174 MK |
6907 | vty_out(vty, |
6908 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
6909 | return CMD_WARNING_CONFIG_FAILED; |
6910 | } | |
d62a17ae | 6911 | vty->node = bgp_node_type(AFI_IP, safi); |
6912 | } else | |
6913 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 6914 | |
d62a17ae | 6915 | return CMD_SUCCESS; |
718e3744 | 6916 | } |
6917 | ||
505e5056 | 6918 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 6919 | address_family_ipv6_safi_cmd, |
6920 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
6921 | "Enter Address Family command mode\n" | |
6922 | "Address Family\n" | |
6923 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 6924 | { |
d62a17ae | 6925 | if (argc == 3) { |
2131d5cf | 6926 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 6927 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
6928 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
6929 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 6930 | && safi != SAFI_EVPN) { |
31947174 MK |
6931 | vty_out(vty, |
6932 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
6933 | return CMD_WARNING_CONFIG_FAILED; |
6934 | } | |
d62a17ae | 6935 | vty->node = bgp_node_type(AFI_IP6, safi); |
6936 | } else | |
6937 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 6938 | |
d62a17ae | 6939 | return CMD_SUCCESS; |
25ffbdc1 | 6940 | } |
718e3744 | 6941 | |
d6902373 | 6942 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 6943 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 6944 | address_family_vpnv4_cmd, |
8334fd5a | 6945 | "address-family vpnv4 [unicast]", |
718e3744 | 6946 | "Enter Address Family command mode\n" |
8c3deaae | 6947 | "Address Family\n" |
3a2d747c | 6948 | "Address Family modifier\n") |
718e3744 | 6949 | { |
d62a17ae | 6950 | vty->node = BGP_VPNV4_NODE; |
6951 | return CMD_SUCCESS; | |
718e3744 | 6952 | } |
6953 | ||
505e5056 | 6954 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 6955 | address_family_vpnv6_cmd, |
8334fd5a | 6956 | "address-family vpnv6 [unicast]", |
8ecd3266 | 6957 | "Enter Address Family command mode\n" |
8c3deaae | 6958 | "Address Family\n" |
3a2d747c | 6959 | "Address Family modifier\n") |
8ecd3266 | 6960 | { |
d62a17ae | 6961 | vty->node = BGP_VPNV6_NODE; |
6962 | return CMD_SUCCESS; | |
8ecd3266 | 6963 | } |
c016b6c7 | 6964 | #endif |
d6902373 | 6965 | |
505e5056 | 6966 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 6967 | address_family_evpn_cmd, |
7111c1a0 | 6968 | "address-family l2vpn evpn", |
4e0b7b6d | 6969 | "Enter Address Family command mode\n" |
7111c1a0 QY |
6970 | "Address Family\n" |
6971 | "Address Family modifier\n") | |
4e0b7b6d | 6972 | { |
2131d5cf | 6973 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 6974 | vty->node = BGP_EVPN_NODE; |
6975 | return CMD_SUCCESS; | |
4e0b7b6d PG |
6976 | } |
6977 | ||
505e5056 | 6978 | DEFUN_NOSH (exit_address_family, |
718e3744 | 6979 | exit_address_family_cmd, |
6980 | "exit-address-family", | |
6981 | "Exit from Address Family configuration mode\n") | |
6982 | { | |
d62a17ae | 6983 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
6984 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
6985 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
6986 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
6987 | || vty->node == BGP_EVPN_NODE |
6988 | || vty->node == BGP_FLOWSPECV4_NODE | |
6989 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 6990 | vty->node = BGP_NODE; |
6991 | return CMD_SUCCESS; | |
718e3744 | 6992 | } |
6b0655a2 | 6993 | |
8ad7271d | 6994 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 6995 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
6996 | const char *ip_str, afi_t afi, safi_t safi, | |
6997 | struct prefix_rd *prd) | |
6998 | { | |
6999 | int ret; | |
7000 | struct prefix match; | |
7001 | struct bgp_node *rn; | |
7002 | struct bgp_node *rm; | |
7003 | struct bgp *bgp; | |
7004 | struct bgp_table *table; | |
7005 | struct bgp_table *rib; | |
7006 | ||
7007 | /* BGP structure lookup. */ | |
7008 | if (view_name) { | |
7009 | bgp = bgp_lookup_by_name(view_name); | |
7010 | if (bgp == NULL) { | |
7011 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
7012 | view_name); | |
7013 | return CMD_WARNING; | |
7014 | } | |
7015 | } else { | |
7016 | bgp = bgp_get_default(); | |
7017 | if (bgp == NULL) { | |
7018 | vty_out(vty, "%% No BGP process is configured\n"); | |
7019 | return CMD_WARNING; | |
7020 | } | |
7021 | } | |
7022 | ||
7023 | /* Check IP address argument. */ | |
7024 | ret = str2prefix(ip_str, &match); | |
7025 | if (!ret) { | |
7026 | vty_out(vty, "%% address is malformed\n"); | |
7027 | return CMD_WARNING; | |
7028 | } | |
7029 | ||
7030 | match.family = afi2family(afi); | |
7031 | rib = bgp->rib[afi][safi]; | |
7032 | ||
7033 | if (safi == SAFI_MPLS_VPN) { | |
7034 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
7035 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
7036 | continue; | |
7037 | ||
7038 | if ((table = rn->info) != NULL) { | |
7039 | if ((rm = bgp_node_match(table, &match)) | |
7040 | != NULL) { | |
7041 | if (rm->p.prefixlen | |
7042 | == match.prefixlen) { | |
7043 | SET_FLAG(rn->flags, | |
7044 | BGP_NODE_USER_CLEAR); | |
7045 | bgp_process(bgp, rm, afi, safi); | |
7046 | } | |
7047 | bgp_unlock_node(rm); | |
7048 | } | |
7049 | } | |
7050 | } | |
7051 | } else { | |
7052 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
7053 | if (rn->p.prefixlen == match.prefixlen) { | |
7054 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
7055 | bgp_process(bgp, rn, afi, safi); | |
7056 | } | |
7057 | bgp_unlock_node(rn); | |
7058 | } | |
7059 | } | |
7060 | ||
7061 | return CMD_SUCCESS; | |
8ad7271d DS |
7062 | } |
7063 | ||
b09b5ae0 | 7064 | /* one clear bgp command to rule them all */ |
718e3744 | 7065 | DEFUN (clear_ip_bgp_all, |
7066 | clear_ip_bgp_all_cmd, | |
c1a44e43 | 7067 | "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 | 7068 | CLEAR_STR |
7069 | IP_STR | |
7070 | BGP_STR | |
838758ac | 7071 | BGP_INSTANCE_HELP_STR |
510afcd6 DS |
7072 | BGP_AFI_HELP_STR |
7073 | BGP_SAFI_WITH_LABEL_HELP_STR | |
b09b5ae0 DW |
7074 | "Clear all peers\n" |
7075 | "BGP neighbor address to clear\n" | |
a80beece | 7076 | "BGP IPv6 neighbor to clear\n" |
838758ac | 7077 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
7078 | "Clear peers with the AS number\n" |
7079 | "Clear all external peers\n" | |
718e3744 | 7080 | "Clear all members of peer-group\n" |
b09b5ae0 | 7081 | "BGP peer-group name\n" |
b09b5ae0 DW |
7082 | BGP_SOFT_STR |
7083 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
7084 | BGP_SOFT_OUT_STR |
7085 | BGP_SOFT_IN_STR | |
7086 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 7087 | BGP_SOFT_OUT_STR) |
718e3744 | 7088 | { |
d62a17ae | 7089 | char *vrf = NULL; |
7090 | ||
7091 | afi_t afi = AFI_IP6; | |
7092 | safi_t safi = SAFI_UNICAST; | |
7093 | enum clear_sort clr_sort = clear_peer; | |
7094 | enum bgp_clear_type clr_type; | |
7095 | char *clr_arg = NULL; | |
7096 | ||
7097 | int idx = 0; | |
7098 | ||
7099 | /* clear [ip] bgp */ | |
7100 | if (argv_find(argv, argc, "ip", &idx)) | |
7101 | afi = AFI_IP; | |
7102 | ||
7103 | /* [<view|vrf> VIEWVRFNAME] */ | |
7104 | if (argv_find(argv, argc, "view", &idx) | |
7105 | || argv_find(argv, argc, "vrf", &idx)) { | |
7106 | vrf = argv[idx + 1]->arg; | |
7107 | idx += 2; | |
7108 | } | |
7109 | ||
7110 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
7111 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
7112 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
7113 | ||
7114 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ | |
7115 | if (argv_find(argv, argc, "*", &idx)) { | |
7116 | clr_sort = clear_all; | |
7117 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
7118 | clr_sort = clear_peer; | |
7119 | clr_arg = argv[idx]->arg; | |
7120 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
7121 | clr_sort = clear_peer; | |
7122 | clr_arg = argv[idx]->arg; | |
7123 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
7124 | clr_sort = clear_group; | |
7125 | idx++; | |
7126 | clr_arg = argv[idx]->arg; | |
7127 | } else if (argv_find(argv, argc, "WORD", &idx)) { | |
7128 | clr_sort = clear_peer; | |
7129 | clr_arg = argv[idx]->arg; | |
7130 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { | |
7131 | clr_sort = clear_as; | |
7132 | clr_arg = argv[idx]->arg; | |
7133 | } else if (argv_find(argv, argc, "external", &idx)) { | |
7134 | clr_sort = clear_external; | |
7135 | } | |
7136 | ||
7137 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
7138 | if (argv_find(argv, argc, "soft", &idx)) { | |
7139 | if (argv_find(argv, argc, "in", &idx) | |
7140 | || argv_find(argv, argc, "out", &idx)) | |
7141 | clr_type = strmatch(argv[idx]->text, "in") | |
7142 | ? BGP_CLEAR_SOFT_IN | |
7143 | : BGP_CLEAR_SOFT_OUT; | |
7144 | else | |
7145 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
7146 | } else if (argv_find(argv, argc, "in", &idx)) { | |
7147 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
7148 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
7149 | : BGP_CLEAR_SOFT_IN; | |
7150 | } else if (argv_find(argv, argc, "out", &idx)) { | |
7151 | clr_type = BGP_CLEAR_SOFT_OUT; | |
7152 | } else | |
7153 | clr_type = BGP_CLEAR_SOFT_NONE; | |
7154 | ||
7155 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 7156 | } |
01080f7c | 7157 | |
8ad7271d DS |
7158 | DEFUN (clear_ip_bgp_prefix, |
7159 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 7160 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
7161 | CLEAR_STR |
7162 | IP_STR | |
7163 | BGP_STR | |
838758ac | 7164 | BGP_INSTANCE_HELP_STR |
8ad7271d | 7165 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7166 | "IPv4 prefix\n") |
8ad7271d | 7167 | { |
d62a17ae | 7168 | char *vrf = NULL; |
7169 | char *prefix = NULL; | |
8ad7271d | 7170 | |
d62a17ae | 7171 | int idx = 0; |
01080f7c | 7172 | |
d62a17ae | 7173 | /* [<view|vrf> VIEWVRFNAME] */ |
1d35f218 | 7174 | if (argv_find(argv, argc, "VIEWVRFNAME", &idx)) |
d62a17ae | 7175 | vrf = argv[idx]->arg; |
0c7b1b01 | 7176 | |
d62a17ae | 7177 | prefix = argv[argc - 1]->arg; |
8ad7271d | 7178 | |
d62a17ae | 7179 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 7180 | } |
8ad7271d | 7181 | |
b09b5ae0 DW |
7182 | DEFUN (clear_bgp_ipv6_safi_prefix, |
7183 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 7184 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7185 | CLEAR_STR |
3a2d747c | 7186 | IP_STR |
718e3744 | 7187 | BGP_STR |
8c3deaae | 7188 | "Address Family\n" |
46f296b4 | 7189 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7190 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7191 | "IPv6 prefix\n") |
718e3744 | 7192 | { |
9b475e76 PG |
7193 | int idx_safi = 0; |
7194 | int idx_ipv6_prefix = 0; | |
7195 | safi_t safi = SAFI_UNICAST; | |
7196 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7197 | argv[idx_ipv6_prefix]->arg : NULL; | |
7198 | ||
7199 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 7200 | return bgp_clear_prefix( |
9b475e76 PG |
7201 | vty, NULL, prefix, AFI_IP6, |
7202 | safi, NULL); | |
838758ac | 7203 | } |
01080f7c | 7204 | |
b09b5ae0 DW |
7205 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
7206 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 7207 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7208 | CLEAR_STR |
3a2d747c | 7209 | IP_STR |
718e3744 | 7210 | BGP_STR |
838758ac | 7211 | BGP_INSTANCE_HELP_STR |
8c3deaae | 7212 | "Address Family\n" |
46f296b4 | 7213 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7214 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7215 | "IPv6 prefix\n") |
718e3744 | 7216 | { |
d62a17ae | 7217 | int idx_word = 3; |
9b475e76 PG |
7218 | int idx_safi = 0; |
7219 | int idx_ipv6_prefix = 0; | |
7220 | safi_t safi = SAFI_UNICAST; | |
7221 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7222 | argv[idx_ipv6_prefix]->arg : NULL; | |
7223 | /* [<view|vrf> VIEWVRFNAME] */ | |
7224 | char *vrfview = argv_find(argv, argc, "VIEWVRFNAME", &idx_word) ? | |
7225 | argv[idx_word]->arg : NULL; | |
7226 | ||
7227 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
7228 | ||
d62a17ae | 7229 | return bgp_clear_prefix( |
9b475e76 PG |
7230 | vty, vrfview, prefix, |
7231 | AFI_IP6, safi, NULL); | |
718e3744 | 7232 | } |
7233 | ||
b09b5ae0 DW |
7234 | DEFUN (show_bgp_views, |
7235 | show_bgp_views_cmd, | |
d6e3c605 | 7236 | "show [ip] bgp views", |
b09b5ae0 | 7237 | SHOW_STR |
d6e3c605 | 7238 | IP_STR |
01080f7c | 7239 | BGP_STR |
b09b5ae0 | 7240 | "Show the defined BGP views\n") |
01080f7c | 7241 | { |
d62a17ae | 7242 | struct list *inst = bm->bgp; |
7243 | struct listnode *node; | |
7244 | struct bgp *bgp; | |
01080f7c | 7245 | |
d62a17ae | 7246 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { |
7247 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
7248 | return CMD_WARNING; | |
7249 | } | |
e52702f2 | 7250 | |
d62a17ae | 7251 | vty_out(vty, "Defined BGP views:\n"); |
7252 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7253 | /* Skip VRFs. */ | |
7254 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
7255 | continue; | |
7256 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
7257 | bgp->as); | |
7258 | } | |
e52702f2 | 7259 | |
d62a17ae | 7260 | return CMD_SUCCESS; |
e0081f70 ML |
7261 | } |
7262 | ||
8386ac43 | 7263 | DEFUN (show_bgp_vrfs, |
7264 | show_bgp_vrfs_cmd, | |
d6e3c605 | 7265 | "show [ip] bgp vrfs [json]", |
8386ac43 | 7266 | SHOW_STR |
d6e3c605 | 7267 | IP_STR |
8386ac43 | 7268 | BGP_STR |
7269 | "Show BGP VRFs\n" | |
9973d184 | 7270 | JSON_STR) |
8386ac43 | 7271 | { |
fe1dc5a3 | 7272 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 7273 | struct list *inst = bm->bgp; |
7274 | struct listnode *node; | |
7275 | struct bgp *bgp; | |
d7c0a89a | 7276 | uint8_t uj = use_json(argc, argv); |
d62a17ae | 7277 | json_object *json = NULL; |
7278 | json_object *json_vrfs = NULL; | |
7279 | int count = 0; | |
d62a17ae | 7280 | |
7281 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { | |
7282 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
7283 | return CMD_WARNING; | |
7284 | } | |
7285 | ||
7286 | if (uj) { | |
7287 | json = json_object_new_object(); | |
7288 | json_vrfs = json_object_new_object(); | |
7289 | } | |
7290 | ||
7291 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7292 | const char *name, *type; | |
7293 | struct peer *peer; | |
7294 | struct listnode *node, *nnode; | |
7295 | int peers_cfg, peers_estb; | |
7296 | json_object *json_vrf = NULL; | |
d62a17ae | 7297 | |
7298 | /* Skip Views. */ | |
7299 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
7300 | continue; | |
7301 | ||
7302 | count++; | |
7303 | if (!uj && count == 1) | |
fe1dc5a3 MK |
7304 | vty_out(vty, |
7305 | "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n", | |
a4d82a8a PZ |
7306 | "Type", "Id", "routerId", "#PeersVfg", |
7307 | "#PeersEstb", "Name", "L3-VNI", "Rmac"); | |
d62a17ae | 7308 | |
7309 | peers_cfg = peers_estb = 0; | |
7310 | if (uj) | |
7311 | json_vrf = json_object_new_object(); | |
7312 | ||
7313 | ||
7314 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
7315 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7316 | continue; | |
7317 | peers_cfg++; | |
7318 | if (peer->status == Established) | |
7319 | peers_estb++; | |
7320 | } | |
7321 | ||
7322 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
7323 | name = "Default"; | |
7324 | type = "DFLT"; | |
7325 | } else { | |
7326 | name = bgp->name; | |
7327 | type = "VRF"; | |
7328 | } | |
7329 | ||
a8bf7d9c | 7330 | |
d62a17ae | 7331 | if (uj) { |
a4d82a8a PZ |
7332 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7333 | ? -1 | |
7334 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 7335 | json_object_string_add(json_vrf, "type", type); |
7336 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
7337 | json_object_string_add(json_vrf, "routerId", | |
7338 | inet_ntoa(bgp->router_id)); | |
7339 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
7340 | peers_cfg); | |
7341 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
7342 | peers_estb); | |
7343 | ||
fe1dc5a3 | 7344 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
7345 | json_object_string_add( |
7346 | json_vrf, "rmac", | |
7347 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
d62a17ae | 7348 | json_object_object_add(json_vrfs, name, json_vrf); |
7349 | } else | |
fe1dc5a3 MK |
7350 | vty_out(vty, |
7351 | "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n", | |
a4d82a8a PZ |
7352 | type, |
7353 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
7354 | : (int)bgp->vrf_id, | |
7355 | inet_ntoa(bgp->router_id), peers_cfg, | |
7356 | peers_estb, name, bgp->l3vni, | |
fe1dc5a3 | 7357 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); |
d62a17ae | 7358 | } |
7359 | ||
7360 | if (uj) { | |
7361 | json_object_object_add(json, "vrfs", json_vrfs); | |
7362 | ||
7363 | json_object_int_add(json, "totalVrfs", count); | |
7364 | ||
996c9314 LB |
7365 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
7366 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 7367 | json_object_free(json); |
7368 | } else { | |
7369 | if (count) | |
7370 | vty_out(vty, | |
7371 | "\nTotal number of VRFs (including default): %d\n", | |
7372 | count); | |
7373 | } | |
7374 | ||
7375 | return CMD_SUCCESS; | |
8386ac43 | 7376 | } |
7377 | ||
acf71666 MK |
7378 | static void show_address_entry(struct hash_backet *backet, void *args) |
7379 | { | |
60466a63 QY |
7380 | struct vty *vty = (struct vty *)args; |
7381 | struct bgp_addr *addr = (struct bgp_addr *)backet->data; | |
acf71666 | 7382 | |
60466a63 | 7383 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(addr->addr), |
acf71666 MK |
7384 | addr->refcnt); |
7385 | } | |
7386 | ||
7387 | static void show_tip_entry(struct hash_backet *backet, void *args) | |
7388 | { | |
0291c246 | 7389 | struct vty *vty = (struct vty *)args; |
60466a63 | 7390 | struct tip_addr *tip = (struct tip_addr *)backet->data; |
acf71666 | 7391 | |
60466a63 | 7392 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
7393 | tip->refcnt); |
7394 | } | |
7395 | ||
7396 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
7397 | { | |
7398 | vty_out(vty, "self nexthop database:\n"); | |
7399 | hash_iterate(bgp->address_hash, | |
7400 | (void (*)(struct hash_backet *, void *))show_address_entry, | |
7401 | vty); | |
7402 | ||
7403 | vty_out(vty, "Tunnel-ip database:\n"); | |
7404 | hash_iterate(bgp->tip_hash, | |
7405 | (void (*)(struct hash_backet *, void *))show_tip_entry, | |
7406 | vty); | |
7407 | } | |
7408 | ||
15c81ca4 DS |
7409 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
7410 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
7411 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
7412 | "martian next-hops\n" |
7413 | "martian next-hop database\n") | |
acf71666 | 7414 | { |
0291c246 | 7415 | struct bgp *bgp = NULL; |
15c81ca4 DS |
7416 | int idx = 0; |
7417 | ||
7418 | if (argv_find(argv, argc, "view", &idx) | |
7419 | || argv_find(argv, argc, "vrf", &idx)) | |
7420 | bgp = bgp_lookup_by_name(argv[idx + 1]->arg); | |
7421 | else | |
7422 | bgp = bgp_get_default(); | |
acf71666 | 7423 | |
acf71666 MK |
7424 | if (!bgp) { |
7425 | vty_out(vty, "%% No BGP process is configured\n"); | |
7426 | return CMD_WARNING; | |
7427 | } | |
7428 | bgp_show_martian_nexthops(vty, bgp); | |
7429 | ||
7430 | return CMD_SUCCESS; | |
7431 | } | |
7432 | ||
f412b39a | 7433 | DEFUN (show_bgp_memory, |
4bf6a362 | 7434 | show_bgp_memory_cmd, |
7fa12b13 | 7435 | "show [ip] bgp memory", |
4bf6a362 | 7436 | SHOW_STR |
3a2d747c | 7437 | IP_STR |
4bf6a362 PJ |
7438 | BGP_STR |
7439 | "Global BGP memory statistics\n") | |
7440 | { | |
d62a17ae | 7441 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
7442 | unsigned long count; | |
7443 | ||
7444 | /* RIB related usage stats */ | |
7445 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
7446 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
7447 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7448 | count * sizeof(struct bgp_node))); | |
7449 | ||
7450 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
7451 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
7452 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7453 | count * sizeof(struct bgp_info))); | |
7454 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) | |
7455 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
7456 | count, | |
7457 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7458 | count * sizeof(struct bgp_info_extra))); | |
7459 | ||
7460 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
7461 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
7462 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7463 | count * sizeof(struct bgp_static))); | |
7464 | ||
7465 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
7466 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
7467 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7468 | count * sizeof(struct bpacket))); | |
7469 | ||
7470 | /* Adj-In/Out */ | |
7471 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
7472 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
7473 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7474 | count * sizeof(struct bgp_adj_in))); | |
7475 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
7476 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
7477 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7478 | count * sizeof(struct bgp_adj_out))); | |
7479 | ||
7480 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
7481 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
7482 | count, | |
7483 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7484 | count * sizeof(struct bgp_nexthop_cache))); | |
7485 | ||
7486 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
7487 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
7488 | count, | |
7489 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7490 | count * sizeof(struct bgp_damp_info))); | |
7491 | ||
7492 | /* Attributes */ | |
7493 | count = attr_count(); | |
7494 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
7495 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7496 | count * sizeof(struct attr))); | |
7497 | ||
7498 | if ((count = attr_unknown_count())) | |
7499 | vty_out(vty, "%ld unknown attributes\n", count); | |
7500 | ||
7501 | /* AS_PATH attributes */ | |
7502 | count = aspath_count(); | |
7503 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
7504 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7505 | count * sizeof(struct aspath))); | |
7506 | ||
7507 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
7508 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
7509 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7510 | count * sizeof(struct assegment))); | |
7511 | ||
7512 | /* Other attributes */ | |
7513 | if ((count = community_count())) | |
7514 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7515 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7516 | count * sizeof(struct community))); | |
d62a17ae | 7517 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
7518 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7519 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7520 | count * sizeof(struct ecommunity))); | |
d62a17ae | 7521 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
7522 | vty_out(vty, | |
7523 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
7524 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7525 | count * sizeof(struct lcommunity))); | |
d62a17ae | 7526 | |
7527 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
7528 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
7529 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7530 | count * sizeof(struct cluster_list))); | |
7531 | ||
7532 | /* Peer related usage */ | |
7533 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
7534 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
7535 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7536 | count * sizeof(struct peer))); | |
7537 | ||
7538 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
7539 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
7540 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7541 | count * sizeof(struct peer_group))); | |
7542 | ||
7543 | /* Other */ | |
7544 | if ((count = mtype_stats_alloc(MTYPE_HASH))) | |
7545 | vty_out(vty, "%ld hash tables, using %s of memory\n", count, | |
7546 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7547 | count * sizeof(struct hash))); | |
7548 | if ((count = mtype_stats_alloc(MTYPE_HASH_BACKET))) | |
7549 | vty_out(vty, "%ld hash buckets, using %s of memory\n", count, | |
7550 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7551 | count * sizeof(struct hash_backet))); | |
7552 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) | |
7553 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
7554 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7555 | count * sizeof(regex_t))); | |
d62a17ae | 7556 | return CMD_SUCCESS; |
4bf6a362 | 7557 | } |
fee0f4c6 | 7558 | |
57a9c8a8 DS |
7559 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
7560 | { | |
7561 | json_object *bestpath = json_object_new_object(); | |
7562 | ||
7563 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
7564 | json_object_string_add(bestpath, "asPath", "ignore"); | |
7565 | ||
7566 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
7567 | json_object_string_add(bestpath, "asPath", "confed"); | |
7568 | ||
7569 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
a4d82a8a PZ |
7570 | if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) |
7571 | json_object_string_add(bestpath, "multiPathRelax", | |
57a9c8a8 DS |
7572 | "as-set"); |
7573 | else | |
a4d82a8a | 7574 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
7575 | "true"); |
7576 | } else | |
a4d82a8a | 7577 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 DS |
7578 | |
7579 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
7580 | json_object_string_add(bestpath, "compareRouterId", "true"); | |
7581 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
7582 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
7583 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 7584 | json_object_string_add(bestpath, "med", "confed"); |
57a9c8a8 DS |
7585 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
7586 | json_object_string_add(bestpath, "med", | |
7587 | "missing-as-worst"); | |
7588 | else | |
7589 | json_object_string_add(bestpath, "med", "true"); | |
7590 | } | |
7591 | ||
7592 | json_object_object_add(json, "bestPath", bestpath); | |
7593 | } | |
7594 | ||
718e3744 | 7595 | /* Show BGP peer's summary information. */ |
d62a17ae | 7596 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
d7c0a89a | 7597 | uint8_t use_json, json_object *json) |
d62a17ae | 7598 | { |
7599 | struct peer *peer; | |
7600 | struct listnode *node, *nnode; | |
7601 | unsigned int count = 0, dn_count = 0; | |
7602 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
7603 | char neighbor_buf[VTY_BUFSIZ]; | |
7604 | int neighbor_col_default_width = 16; | |
7605 | int len; | |
7606 | int max_neighbor_width = 0; | |
7607 | int pfx_rcd_safi; | |
7608 | json_object *json_peer = NULL; | |
7609 | json_object *json_peers = NULL; | |
7610 | ||
7611 | /* labeled-unicast routes are installed in the unicast table so in order | |
7612 | * to | |
7613 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
7614 | */ | |
7615 | if (safi == SAFI_LABELED_UNICAST) | |
7616 | pfx_rcd_safi = SAFI_UNICAST; | |
7617 | else | |
7618 | pfx_rcd_safi = safi; | |
7619 | ||
7620 | if (use_json) { | |
7621 | if (json == NULL) | |
7622 | json = json_object_new_object(); | |
7623 | ||
7624 | json_peers = json_object_new_object(); | |
7625 | } else { | |
7626 | /* Loop over all neighbors that will be displayed to determine | |
7627 | * how many | |
7628 | * characters are needed for the Neighbor column | |
7629 | */ | |
7630 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
7631 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7632 | continue; | |
7633 | ||
7634 | if (peer->afc[afi][safi]) { | |
7635 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7636 | if (peer_dynamic_neighbor(peer)) | |
7637 | dn_flag[0] = '*'; | |
7638 | ||
7639 | if (peer->hostname | |
7640 | && bgp_flag_check(bgp, | |
7641 | BGP_FLAG_SHOW_HOSTNAME)) | |
7642 | sprintf(neighbor_buf, "%s%s(%s) ", | |
7643 | dn_flag, peer->hostname, | |
7644 | peer->host); | |
7645 | else | |
7646 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
7647 | peer->host); | |
7648 | ||
7649 | len = strlen(neighbor_buf); | |
7650 | ||
7651 | if (len > max_neighbor_width) | |
7652 | max_neighbor_width = len; | |
7653 | } | |
7654 | } | |
f933309e | 7655 | |
d62a17ae | 7656 | /* Originally we displayed the Neighbor column as 16 |
7657 | * characters wide so make that the default | |
7658 | */ | |
7659 | if (max_neighbor_width < neighbor_col_default_width) | |
7660 | max_neighbor_width = neighbor_col_default_width; | |
7661 | } | |
f933309e | 7662 | |
d62a17ae | 7663 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
7664 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7665 | continue; | |
7666 | ||
ea47320b DL |
7667 | if (!peer->afc[afi][safi]) |
7668 | continue; | |
d62a17ae | 7669 | |
ea47320b DL |
7670 | if (!count) { |
7671 | unsigned long ents; | |
7672 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 7673 | int64_t vrf_id_ui; |
d62a17ae | 7674 | |
a4d82a8a PZ |
7675 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7676 | ? -1 | |
7677 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
7678 | |
7679 | /* Usage summary and header */ | |
7680 | if (use_json) { | |
7681 | json_object_string_add( | |
7682 | json, "routerId", | |
7683 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
7684 | json_object_int_add(json, "as", bgp->as); |
7685 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
7686 | json_object_string_add( |
7687 | json, "vrfName", | |
7688 | (bgp->inst_type | |
7689 | == BGP_INSTANCE_TYPE_DEFAULT) | |
7690 | ? "Default" | |
7691 | : bgp->name); | |
7692 | } else { | |
7693 | vty_out(vty, | |
7694 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 7695 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
7696 | bgp->vrf_id == VRF_UNKNOWN |
7697 | ? -1 | |
7698 | : (int)bgp->vrf_id); | |
ea47320b DL |
7699 | vty_out(vty, "\n"); |
7700 | } | |
d62a17ae | 7701 | |
ea47320b | 7702 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 7703 | if (use_json) { |
ea47320b | 7704 | json_object_int_add( |
60466a63 | 7705 | json, "updateDelayLimit", |
ea47320b | 7706 | bgp->v_update_delay); |
d62a17ae | 7707 | |
ea47320b DL |
7708 | if (bgp->v_update_delay |
7709 | != bgp->v_establish_wait) | |
d62a17ae | 7710 | json_object_int_add( |
7711 | json, | |
ea47320b DL |
7712 | "updateDelayEstablishWait", |
7713 | bgp->v_establish_wait); | |
d62a17ae | 7714 | |
60466a63 | 7715 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
7716 | json_object_string_add( |
7717 | json, | |
7718 | "updateDelayFirstNeighbor", | |
7719 | bgp->update_delay_begin_time); | |
7720 | json_object_boolean_true_add( | |
7721 | json, | |
7722 | "updateDelayInProgress"); | |
7723 | } else { | |
7724 | if (bgp->update_delay_over) { | |
d62a17ae | 7725 | json_object_string_add( |
7726 | json, | |
7727 | "updateDelayFirstNeighbor", | |
7728 | bgp->update_delay_begin_time); | |
ea47320b | 7729 | json_object_string_add( |
d62a17ae | 7730 | json, |
ea47320b DL |
7731 | "updateDelayBestpathResumed", |
7732 | bgp->update_delay_end_time); | |
7733 | json_object_string_add( | |
d62a17ae | 7734 | json, |
ea47320b DL |
7735 | "updateDelayZebraUpdateResume", |
7736 | bgp->update_delay_zebra_resume_time); | |
7737 | json_object_string_add( | |
7738 | json, | |
7739 | "updateDelayPeerUpdateResume", | |
7740 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 7741 | } |
ea47320b DL |
7742 | } |
7743 | } else { | |
7744 | vty_out(vty, | |
7745 | "Read-only mode update-delay limit: %d seconds\n", | |
7746 | bgp->v_update_delay); | |
7747 | if (bgp->v_update_delay | |
7748 | != bgp->v_establish_wait) | |
d62a17ae | 7749 | vty_out(vty, |
ea47320b DL |
7750 | " Establish wait: %d seconds\n", |
7751 | bgp->v_establish_wait); | |
d62a17ae | 7752 | |
60466a63 | 7753 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
7754 | vty_out(vty, |
7755 | " First neighbor established: %s\n", | |
7756 | bgp->update_delay_begin_time); | |
7757 | vty_out(vty, | |
7758 | " Delay in progress\n"); | |
7759 | } else { | |
7760 | if (bgp->update_delay_over) { | |
d62a17ae | 7761 | vty_out(vty, |
7762 | " First neighbor established: %s\n", | |
7763 | bgp->update_delay_begin_time); | |
7764 | vty_out(vty, | |
ea47320b DL |
7765 | " Best-paths resumed: %s\n", |
7766 | bgp->update_delay_end_time); | |
7767 | vty_out(vty, | |
7768 | " zebra update resumed: %s\n", | |
7769 | bgp->update_delay_zebra_resume_time); | |
7770 | vty_out(vty, | |
7771 | " peers update resumed: %s\n", | |
7772 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 7773 | } |
7774 | } | |
7775 | } | |
ea47320b | 7776 | } |
d62a17ae | 7777 | |
ea47320b DL |
7778 | if (use_json) { |
7779 | if (bgp_maxmed_onstartup_configured(bgp) | |
7780 | && bgp->maxmed_active) | |
7781 | json_object_boolean_true_add( | |
60466a63 | 7782 | json, "maxMedOnStartup"); |
ea47320b DL |
7783 | if (bgp->v_maxmed_admin) |
7784 | json_object_boolean_true_add( | |
60466a63 | 7785 | json, "maxMedAdministrative"); |
d62a17ae | 7786 | |
ea47320b DL |
7787 | json_object_int_add( |
7788 | json, "tableVersion", | |
60466a63 | 7789 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 7790 | |
60466a63 QY |
7791 | ents = bgp_table_count(bgp->rib[afi][safi]); |
7792 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
7793 | json_object_int_add( |
7794 | json, "ribMemory", | |
7795 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 7796 | |
ea47320b | 7797 | ents = listcount(bgp->peer); |
60466a63 QY |
7798 | json_object_int_add(json, "peerCount", ents); |
7799 | json_object_int_add(json, "peerMemory", | |
7800 | ents * sizeof(struct peer)); | |
d62a17ae | 7801 | |
ea47320b DL |
7802 | if ((ents = listcount(bgp->group))) { |
7803 | json_object_int_add( | |
60466a63 | 7804 | json, "peerGroupCount", ents); |
ea47320b DL |
7805 | json_object_int_add( |
7806 | json, "peerGroupMemory", | |
996c9314 LB |
7807 | ents * sizeof(struct |
7808 | peer_group)); | |
ea47320b | 7809 | } |
d62a17ae | 7810 | |
ea47320b DL |
7811 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
7812 | BGP_CONFIG_DAMPENING)) | |
7813 | json_object_boolean_true_add( | |
60466a63 | 7814 | json, "dampeningEnabled"); |
ea47320b DL |
7815 | } else { |
7816 | if (bgp_maxmed_onstartup_configured(bgp) | |
7817 | && bgp->maxmed_active) | |
d62a17ae | 7818 | vty_out(vty, |
ea47320b DL |
7819 | "Max-med on-startup active\n"); |
7820 | if (bgp->v_maxmed_admin) | |
d62a17ae | 7821 | vty_out(vty, |
ea47320b | 7822 | "Max-med administrative active\n"); |
d62a17ae | 7823 | |
60466a63 QY |
7824 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
7825 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 7826 | |
60466a63 | 7827 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
7828 | vty_out(vty, |
7829 | "RIB entries %ld, using %s of memory\n", | |
7830 | ents, | |
996c9314 LB |
7831 | mtype_memstr(memstrbuf, |
7832 | sizeof(memstrbuf), | |
7833 | ents * sizeof(struct | |
7834 | bgp_node))); | |
ea47320b DL |
7835 | |
7836 | /* Peer related usage */ | |
7837 | ents = listcount(bgp->peer); | |
60466a63 | 7838 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
7839 | ents, |
7840 | mtype_memstr( | |
60466a63 QY |
7841 | memstrbuf, sizeof(memstrbuf), |
7842 | ents * sizeof(struct peer))); | |
ea47320b DL |
7843 | |
7844 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 7845 | vty_out(vty, |
ea47320b | 7846 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 7847 | ents, |
7848 | mtype_memstr( | |
7849 | memstrbuf, | |
7850 | sizeof(memstrbuf), | |
996c9314 LB |
7851 | ents * sizeof(struct |
7852 | peer_group))); | |
d62a17ae | 7853 | |
ea47320b DL |
7854 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
7855 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 7856 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 7857 | vty_out(vty, "\n"); |
d62a17ae | 7858 | |
ea47320b DL |
7859 | /* Subtract 8 here because 'Neighbor' is |
7860 | * 8 characters */ | |
7861 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
7862 | vty_out(vty, "%*s", max_neighbor_width - 8, |
7863 | " "); | |
ea47320b DL |
7864 | vty_out(vty, |
7865 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); | |
d62a17ae | 7866 | } |
ea47320b | 7867 | } |
d62a17ae | 7868 | |
ea47320b | 7869 | count++; |
d62a17ae | 7870 | |
ea47320b DL |
7871 | if (use_json) { |
7872 | json_peer = json_object_new_object(); | |
d62a17ae | 7873 | |
ea47320b | 7874 | if (peer_dynamic_neighbor(peer)) |
60466a63 QY |
7875 | json_object_boolean_true_add(json_peer, |
7876 | "dynamicPeer"); | |
d62a17ae | 7877 | |
ea47320b | 7878 | if (peer->hostname) |
60466a63 | 7879 | json_object_string_add(json_peer, "hostname", |
ea47320b | 7880 | peer->hostname); |
d62a17ae | 7881 | |
ea47320b | 7882 | if (peer->domainname) |
60466a63 QY |
7883 | json_object_string_add(json_peer, "domainname", |
7884 | peer->domainname); | |
d62a17ae | 7885 | |
60466a63 | 7886 | json_object_int_add(json_peer, "remoteAs", peer->as); |
ea47320b | 7887 | json_object_int_add(json_peer, "version", 4); |
60466a63 | 7888 | json_object_int_add(json_peer, "msgRcvd", |
0112e9e0 | 7889 | PEER_TOTAL_RX(peer)); |
60466a63 | 7890 | json_object_int_add(json_peer, "msgSent", |
0112e9e0 | 7891 | PEER_TOTAL_TX(peer)); |
ea47320b DL |
7892 | |
7893 | json_object_int_add(json_peer, "tableVersion", | |
7894 | peer->version[afi][safi]); | |
7895 | json_object_int_add(json_peer, "outq", | |
7896 | peer->obuf->count); | |
7897 | json_object_int_add(json_peer, "inq", 0); | |
60466a63 QY |
7898 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
7899 | use_json, json_peer); | |
7900 | json_object_int_add(json_peer, "prefixReceivedCount", | |
7901 | peer->pcount[afi][pfx_rcd_safi]); | |
d62a17ae | 7902 | |
ea47320b | 7903 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
60466a63 | 7904 | json_object_string_add(json_peer, "state", |
ea47320b | 7905 | "Idle (Admin)"); |
60466a63 QY |
7906 | else if (CHECK_FLAG(peer->sflags, |
7907 | PEER_STATUS_PREFIX_OVERFLOW)) | |
7908 | json_object_string_add(json_peer, "state", | |
ea47320b DL |
7909 | "Idle (PfxCt)"); |
7910 | else | |
7911 | json_object_string_add( | |
7912 | json_peer, "state", | |
60466a63 QY |
7913 | lookup_msg(bgp_status_msg, peer->status, |
7914 | NULL)); | |
ea47320b DL |
7915 | |
7916 | if (peer->conf_if) | |
60466a63 | 7917 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
7918 | "interface"); |
7919 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
7920 | json_object_string_add(json_peer, "idType", |
7921 | "ipv4"); | |
ea47320b | 7922 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
7923 | json_object_string_add(json_peer, "idType", |
7924 | "ipv6"); | |
d62a17ae | 7925 | |
ea47320b DL |
7926 | json_object_object_add(json_peers, peer->host, |
7927 | json_peer); | |
7928 | } else { | |
7929 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7930 | if (peer_dynamic_neighbor(peer)) { | |
7931 | dn_count++; | |
7932 | dn_flag[0] = '*'; | |
7933 | } | |
d62a17ae | 7934 | |
ea47320b | 7935 | if (peer->hostname |
60466a63 | 7936 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
ea47320b | 7937 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
60466a63 | 7938 | peer->hostname, peer->host); |
ea47320b | 7939 | else |
60466a63 | 7940 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
ea47320b DL |
7941 | |
7942 | /* pad the neighbor column with spaces */ | |
7943 | if (len < max_neighbor_width) | |
60466a63 QY |
7944 | vty_out(vty, "%*s", max_neighbor_width - len, |
7945 | " "); | |
ea47320b | 7946 | |
86a55b99 | 7947 | vty_out(vty, "4 %10u %7u %7u %8" PRIu64 " %4d %4zd %8s", |
0112e9e0 QY |
7948 | peer->as, PEER_TOTAL_RX(peer), |
7949 | PEER_TOTAL_TX(peer), peer->version[afi][safi], | |
7950 | 0, peer->obuf->count, | |
d62a17ae | 7951 | peer_uptime(peer->uptime, timebuf, |
ea47320b | 7952 | BGP_UPTIME_LEN, 0, NULL)); |
d62a17ae | 7953 | |
ea47320b | 7954 | if (peer->status == Established) |
95077abf DW |
7955 | if (peer->afc_recv[afi][pfx_rcd_safi]) |
7956 | vty_out(vty, " %12ld", | |
a4d82a8a PZ |
7957 | peer->pcount[afi] |
7958 | [pfx_rcd_safi]); | |
95077abf DW |
7959 | else |
7960 | vty_out(vty, " NoNeg"); | |
ea47320b | 7961 | else { |
60466a63 | 7962 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
ea47320b | 7963 | vty_out(vty, " Idle (Admin)"); |
60466a63 QY |
7964 | else if (CHECK_FLAG( |
7965 | peer->sflags, | |
7966 | PEER_STATUS_PREFIX_OVERFLOW)) | |
ea47320b | 7967 | vty_out(vty, " Idle (PfxCt)"); |
d62a17ae | 7968 | else |
ea47320b | 7969 | vty_out(vty, " %12s", |
60466a63 QY |
7970 | lookup_msg(bgp_status_msg, |
7971 | peer->status, NULL)); | |
d62a17ae | 7972 | } |
ea47320b | 7973 | vty_out(vty, "\n"); |
d62a17ae | 7974 | } |
7975 | } | |
f933309e | 7976 | |
d62a17ae | 7977 | if (use_json) { |
7978 | json_object_object_add(json, "peers", json_peers); | |
7979 | ||
7980 | json_object_int_add(json, "totalPeers", count); | |
7981 | json_object_int_add(json, "dynamicPeers", dn_count); | |
7982 | ||
57a9c8a8 DS |
7983 | bgp_show_bestpath_json(bgp, json); |
7984 | ||
996c9314 LB |
7985 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
7986 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 7987 | json_object_free(json); |
7988 | } else { | |
7989 | if (count) | |
7990 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
7991 | else { | |
7992 | if (use_json) | |
7993 | vty_out(vty, | |
7994 | "{\"error\": {\"message\": \"No %s neighbor configured\"}}\n", | |
7995 | afi_safi_print(afi, safi)); | |
7996 | else | |
7997 | vty_out(vty, "No %s neighbor is configured\n", | |
7998 | afi_safi_print(afi, safi)); | |
7999 | } | |
b05a1c8b | 8000 | |
d62a17ae | 8001 | if (dn_count && !use_json) { |
8002 | vty_out(vty, "* - dynamic neighbor\n"); | |
8003 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
8004 | dn_count, bgp->dynamic_neighbors_limit); | |
8005 | } | |
8006 | } | |
1ff9a340 | 8007 | |
d62a17ae | 8008 | return CMD_SUCCESS; |
718e3744 | 8009 | } |
8010 | ||
d62a17ae | 8011 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
d7c0a89a | 8012 | int safi, uint8_t use_json, |
d62a17ae | 8013 | json_object *json) |
8014 | { | |
8015 | int is_first = 1; | |
8016 | int afi_wildcard = (afi == AFI_MAX); | |
8017 | int safi_wildcard = (safi == SAFI_MAX); | |
8018 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
8019 | bool json_output = false; | |
8020 | ||
8021 | if (use_json && is_wildcard) | |
8022 | vty_out(vty, "{\n"); | |
8023 | if (afi_wildcard) | |
8024 | afi = 1; /* AFI_IP */ | |
8025 | while (afi < AFI_MAX) { | |
8026 | if (safi_wildcard) | |
8027 | safi = 1; /* SAFI_UNICAST */ | |
8028 | while (safi < SAFI_MAX) { | |
318cac96 | 8029 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
d62a17ae | 8030 | json_output = true; |
8031 | if (is_wildcard) { | |
8032 | /* | |
8033 | * So limit output to those afi/safi | |
8034 | * pairs that | |
8035 | * actualy have something interesting in | |
8036 | * them | |
8037 | */ | |
8038 | if (use_json) { | |
8039 | json = json_object_new_object(); | |
8040 | ||
8041 | if (!is_first) | |
8042 | vty_out(vty, ",\n"); | |
8043 | else | |
8044 | is_first = 0; | |
8045 | ||
8046 | vty_out(vty, "\"%s\":", | |
8047 | afi_safi_json(afi, | |
8048 | safi)); | |
8049 | } else { | |
8050 | vty_out(vty, "\n%s Summary:\n", | |
8051 | afi_safi_print(afi, | |
8052 | safi)); | |
8053 | } | |
8054 | } | |
8055 | bgp_show_summary(vty, bgp, afi, safi, use_json, | |
8056 | json); | |
8057 | } | |
8058 | safi++; | |
d62a17ae | 8059 | if (!safi_wildcard) |
8060 | safi = SAFI_MAX; | |
8061 | } | |
8062 | afi++; | |
ee851c8c | 8063 | if (!afi_wildcard) |
d62a17ae | 8064 | afi = AFI_MAX; |
8065 | } | |
8066 | ||
8067 | if (use_json && is_wildcard) | |
8068 | vty_out(vty, "}\n"); | |
8069 | else if (use_json && !json_output) | |
8070 | vty_out(vty, "{}\n"); | |
8071 | } | |
8072 | ||
8073 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
d7c0a89a | 8074 | safi_t safi, uint8_t use_json) |
d62a17ae | 8075 | { |
8076 | struct listnode *node, *nnode; | |
8077 | struct bgp *bgp; | |
8078 | json_object *json = NULL; | |
8079 | int is_first = 1; | |
8080 | ||
8081 | if (use_json) | |
8082 | vty_out(vty, "{\n"); | |
8083 | ||
8084 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
8085 | if (use_json) { | |
8086 | json = json_object_new_object(); | |
8087 | ||
8088 | if (!is_first) | |
8089 | vty_out(vty, ",\n"); | |
8090 | else | |
8091 | is_first = 0; | |
8092 | ||
8093 | vty_out(vty, "\"%s\":", | |
8094 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8095 | ? "Default" | |
8096 | : bgp->name); | |
8097 | } else { | |
8098 | vty_out(vty, "\nInstance %s:\n", | |
8099 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8100 | ? "Default" | |
8101 | : bgp->name); | |
8102 | } | |
8103 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, json); | |
8104 | } | |
8105 | ||
8106 | if (use_json) | |
8107 | vty_out(vty, "}\n"); | |
8108 | } | |
8109 | ||
8110 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
d7c0a89a | 8111 | safi_t safi, uint8_t use_json) |
d62a17ae | 8112 | { |
8113 | struct bgp *bgp; | |
8114 | ||
8115 | if (name) { | |
8116 | if (strmatch(name, "all")) { | |
8117 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
8118 | use_json); | |
8119 | return CMD_SUCCESS; | |
8120 | } else { | |
8121 | bgp = bgp_lookup_by_name(name); | |
8122 | ||
8123 | if (!bgp) { | |
8124 | if (use_json) | |
8125 | vty_out(vty, "{}\n"); | |
8126 | else | |
8127 | vty_out(vty, | |
8128 | "%% No such BGP instance exist\n"); | |
8129 | return CMD_WARNING; | |
8130 | } | |
8131 | ||
8132 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, | |
8133 | NULL); | |
8134 | return CMD_SUCCESS; | |
8135 | } | |
8136 | } | |
8137 | ||
8138 | bgp = bgp_get_default(); | |
8139 | ||
8140 | if (bgp) | |
8141 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, NULL); | |
8142 | ||
8143 | return CMD_SUCCESS; | |
4fb25c53 DW |
8144 | } |
8145 | ||
716b2d8a | 8146 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 8147 | DEFUN (show_ip_bgp_summary, |
718e3744 | 8148 | show_ip_bgp_summary_cmd, |
dd6bd0f1 | 8149 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [json]", |
718e3744 | 8150 | SHOW_STR |
8151 | IP_STR | |
8152 | BGP_STR | |
8386ac43 | 8153 | BGP_INSTANCE_HELP_STR |
46f296b4 | 8154 | BGP_AFI_HELP_STR |
dd6bd0f1 | 8155 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 8156 | "Summary of BGP neighbor status\n" |
9973d184 | 8157 | JSON_STR) |
718e3744 | 8158 | { |
d62a17ae | 8159 | char *vrf = NULL; |
8160 | afi_t afi = AFI_MAX; | |
8161 | safi_t safi = SAFI_MAX; | |
8162 | ||
8163 | int idx = 0; | |
8164 | ||
8165 | /* show [ip] bgp */ | |
8166 | if (argv_find(argv, argc, "ip", &idx)) | |
8167 | afi = AFI_IP; | |
8168 | /* [<view|vrf> VIEWVRFNAME] */ | |
8169 | if (argv_find(argv, argc, "view", &idx) | |
8170 | || argv_find(argv, argc, "vrf", &idx)) | |
8171 | vrf = argv[++idx]->arg; | |
8172 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
8173 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
8174 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8175 | } | |
8176 | ||
8177 | int uj = use_json(argc, argv); | |
8178 | ||
8179 | return bgp_show_summary_vty(vty, vrf, afi, safi, uj); | |
8180 | } | |
8181 | ||
8182 | const char *afi_safi_print(afi_t afi, safi_t safi) | |
8183 | { | |
8184 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8185 | return "IPv4 Unicast"; | |
8186 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8187 | return "IPv4 Multicast"; | |
8188 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8189 | return "IPv4 Labeled Unicast"; | |
8190 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8191 | return "IPv4 VPN"; | |
8192 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8193 | return "IPv4 Encap"; | |
7c40bf39 | 8194 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8195 | return "IPv4 Flowspec"; | |
d62a17ae | 8196 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8197 | return "IPv6 Unicast"; | |
8198 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8199 | return "IPv6 Multicast"; | |
8200 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8201 | return "IPv6 Labeled Unicast"; | |
8202 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8203 | return "IPv6 VPN"; | |
8204 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8205 | return "IPv6 Encap"; | |
7c40bf39 | 8206 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8207 | return "IPv6 Flowspec"; | |
d62a17ae | 8208 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8209 | return "L2VPN EVPN"; | |
8210 | else | |
8211 | return "Unknown"; | |
538621f2 | 8212 | } |
8213 | ||
b9f77ec8 DS |
8214 | /* |
8215 | * Please note that we have intentionally camelCased | |
8216 | * the return strings here. So if you want | |
8217 | * to use this function, please ensure you | |
8218 | * are doing this within json output | |
8219 | */ | |
d62a17ae | 8220 | const char *afi_safi_json(afi_t afi, safi_t safi) |
8221 | { | |
8222 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8223 | return "ipv4Unicast"; | |
8224 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8225 | return "ipv4Multicast"; | |
8226 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8227 | return "ipv4LabeledUnicast"; | |
8228 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8229 | return "ipv4Vpn"; | |
8230 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8231 | return "ipv4Encap"; | |
7c40bf39 | 8232 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8233 | return "ipv4Flowspec"; | |
d62a17ae | 8234 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8235 | return "ipv6Unicast"; | |
8236 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8237 | return "ipv6Multicast"; | |
8238 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8239 | return "ipv6LabeledUnicast"; | |
8240 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8241 | return "ipv6Vpn"; | |
8242 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8243 | return "ipv6Encap"; | |
7c40bf39 | 8244 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8245 | return "ipv6Flowspec"; | |
d62a17ae | 8246 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8247 | return "l2VpnEvpn"; | |
8248 | else | |
8249 | return "Unknown"; | |
27162734 LB |
8250 | } |
8251 | ||
718e3744 | 8252 | /* Show BGP peer's information. */ |
d62a17ae | 8253 | enum show_type { show_all, show_peer }; |
8254 | ||
8255 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
8256 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
8257 | uint16_t adv_smcap, uint16_t adv_rmcap, |
8258 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
8259 | uint8_t use_json, json_object *json_pref) | |
d62a17ae | 8260 | { |
8261 | /* Send-Mode */ | |
8262 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8263 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
8264 | if (use_json) { | |
8265 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8266 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8267 | json_object_string_add(json_pref, "sendMode", | |
8268 | "advertisedAndReceived"); | |
8269 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8270 | json_object_string_add(json_pref, "sendMode", | |
8271 | "advertised"); | |
8272 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8273 | json_object_string_add(json_pref, "sendMode", | |
8274 | "received"); | |
8275 | } else { | |
8276 | vty_out(vty, " Send-mode: "); | |
8277 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8278 | vty_out(vty, "advertised"); | |
8279 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8280 | vty_out(vty, "%sreceived", | |
8281 | CHECK_FLAG(p->af_cap[afi][safi], | |
8282 | adv_smcap) | |
8283 | ? ", " | |
8284 | : ""); | |
8285 | vty_out(vty, "\n"); | |
8286 | } | |
8287 | } | |
8288 | ||
8289 | /* Receive-Mode */ | |
8290 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8291 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
8292 | if (use_json) { | |
8293 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8294 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8295 | json_object_string_add(json_pref, "recvMode", | |
8296 | "advertisedAndReceived"); | |
8297 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8298 | json_object_string_add(json_pref, "recvMode", | |
8299 | "advertised"); | |
8300 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8301 | json_object_string_add(json_pref, "recvMode", | |
8302 | "received"); | |
8303 | } else { | |
8304 | vty_out(vty, " Receive-mode: "); | |
8305 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8306 | vty_out(vty, "advertised"); | |
8307 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8308 | vty_out(vty, "%sreceived", | |
8309 | CHECK_FLAG(p->af_cap[afi][safi], | |
8310 | adv_rmcap) | |
8311 | ? ", " | |
8312 | : ""); | |
8313 | vty_out(vty, "\n"); | |
8314 | } | |
8315 | } | |
8316 | } | |
8317 | ||
8318 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, | |
d7c0a89a | 8319 | safi_t safi, uint8_t use_json, |
d62a17ae | 8320 | json_object *json_neigh) |
8321 | { | |
0291c246 MK |
8322 | struct bgp_filter *filter; |
8323 | struct peer_af *paf; | |
8324 | char orf_pfx_name[BUFSIZ]; | |
8325 | int orf_pfx_count; | |
8326 | json_object *json_af = NULL; | |
8327 | json_object *json_prefA = NULL; | |
8328 | json_object *json_prefB = NULL; | |
8329 | json_object *json_addr = NULL; | |
d62a17ae | 8330 | |
8331 | if (use_json) { | |
8332 | json_addr = json_object_new_object(); | |
8333 | json_af = json_object_new_object(); | |
8334 | filter = &p->filter[afi][safi]; | |
8335 | ||
8336 | if (peer_group_active(p)) | |
8337 | json_object_string_add(json_addr, "peerGroupMember", | |
8338 | p->group->name); | |
8339 | ||
8340 | paf = peer_af_find(p, afi, safi); | |
8341 | if (paf && PAF_SUBGRP(paf)) { | |
8342 | json_object_int_add(json_addr, "updateGroupId", | |
8343 | PAF_UPDGRP(paf)->id); | |
8344 | json_object_int_add(json_addr, "subGroupId", | |
8345 | PAF_SUBGRP(paf)->id); | |
8346 | json_object_int_add(json_addr, "packetQueueLength", | |
8347 | bpacket_queue_virtual_length(paf)); | |
8348 | } | |
8349 | ||
8350 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8351 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8352 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8353 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8354 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8355 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8356 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8357 | json_object_int_add(json_af, "orfType", | |
8358 | ORF_TYPE_PREFIX); | |
8359 | json_prefA = json_object_new_object(); | |
8360 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
8361 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
8362 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8363 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8364 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
8365 | use_json, json_prefA); | |
8366 | json_object_object_add(json_af, "orfPrefixList", | |
8367 | json_prefA); | |
8368 | } | |
8369 | ||
8370 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8371 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8372 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8373 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8374 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8375 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8376 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8377 | json_object_int_add(json_af, "orfOldType", | |
8378 | ORF_TYPE_PREFIX_OLD); | |
8379 | json_prefB = json_object_new_object(); | |
8380 | bgp_show_peer_afi_orf_cap( | |
8381 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8382 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8383 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8384 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
8385 | json_prefB); | |
8386 | json_object_object_add(json_af, "orfOldPrefixList", | |
8387 | json_prefB); | |
8388 | } | |
8389 | ||
8390 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8391 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8392 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8393 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8394 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8395 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8396 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8397 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8398 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8399 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8400 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8401 | json_object_object_add(json_addr, "afDependentCap", | |
8402 | json_af); | |
8403 | else | |
8404 | json_object_free(json_af); | |
8405 | ||
8406 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8407 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8408 | NULL, afi, orf_pfx_name, use_json); | |
8409 | ||
8410 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8411 | PEER_STATUS_ORF_PREFIX_SEND) | |
8412 | || orf_pfx_count) { | |
8413 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8414 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8415 | json_object_boolean_true_add(json_neigh, | |
8416 | "orfSent"); | |
8417 | if (orf_pfx_count) | |
8418 | json_object_int_add(json_addr, "orfRecvCounter", | |
8419 | orf_pfx_count); | |
8420 | } | |
8421 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8422 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8423 | json_object_string_add( | |
8424 | json_addr, "orfFirstUpdate", | |
8425 | "deferredUntilORFOrRouteRefreshRecvd"); | |
8426 | ||
8427 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8428 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8429 | json_object_boolean_true_add(json_addr, | |
8430 | "routeReflectorClient"); | |
8431 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8432 | PEER_FLAG_RSERVER_CLIENT)) | |
8433 | json_object_boolean_true_add(json_addr, | |
8434 | "routeServerClient"); | |
8435 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8436 | json_object_boolean_true_add(json_addr, | |
8437 | "inboundSoftConfigPermit"); | |
8438 | ||
8439 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8440 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8441 | json_object_boolean_true_add( | |
8442 | json_addr, | |
8443 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
8444 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8445 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8446 | json_object_boolean_true_add( | |
8447 | json_addr, | |
8448 | "privateAsNumsReplacedInUpdatesToNbr"); | |
8449 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8450 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8451 | json_object_boolean_true_add( | |
8452 | json_addr, | |
8453 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
8454 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8455 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8456 | json_object_boolean_true_add( | |
8457 | json_addr, | |
8458 | "privateAsNumsRemovedInUpdatesToNbr"); | |
8459 | ||
8460 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8461 | PEER_FLAG_ADDPATH_TX_ALL_PATHS)) | |
8462 | json_object_boolean_true_add(json_addr, | |
8463 | "addpathTxAllPaths"); | |
8464 | ||
8465 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8466 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
8467 | json_object_boolean_true_add(json_addr, | |
8468 | "addpathTxBestpathPerAS"); | |
8469 | ||
8470 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8471 | json_object_string_add(json_addr, | |
8472 | "overrideASNsInOutboundUpdates", | |
8473 | "ifAspathEqualRemoteAs"); | |
8474 | ||
8475 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8476 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8477 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8478 | json_object_boolean_true_add(json_addr, | |
8479 | "routerAlwaysNextHop"); | |
8480 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8481 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8482 | json_object_boolean_true_add( | |
8483 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
8484 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8485 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
8486 | json_object_boolean_true_add( | |
8487 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
8488 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
8489 | json_object_boolean_true_add( | |
8490 | json_addr, "unchangedMedPropogatedToNbr"); | |
8491 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
8492 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8493 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
8494 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8495 | PEER_FLAG_SEND_COMMUNITY) | |
8496 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8497 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8498 | json_object_string_add(json_addr, | |
8499 | "commAttriSentToNbr", | |
8500 | "extendedAndStandard"); | |
8501 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8502 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8503 | json_object_string_add(json_addr, | |
8504 | "commAttriSentToNbr", | |
8505 | "extended"); | |
8506 | else | |
8507 | json_object_string_add(json_addr, | |
8508 | "commAttriSentToNbr", | |
8509 | "standard"); | |
8510 | } | |
8511 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8512 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
8513 | if (p->default_rmap[afi][safi].name) | |
8514 | json_object_string_add( | |
8515 | json_addr, "defaultRouteMap", | |
8516 | p->default_rmap[afi][safi].name); | |
8517 | ||
8518 | if (paf && PAF_SUBGRP(paf) | |
8519 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
8520 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
8521 | json_object_boolean_true_add(json_addr, | |
8522 | "defaultSent"); | |
8523 | else | |
8524 | json_object_boolean_true_add(json_addr, | |
8525 | "defaultNotSent"); | |
8526 | } | |
8527 | ||
dff8f48d | 8528 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 8529 | if (is_evpn_enabled()) |
60466a63 QY |
8530 | json_object_boolean_true_add( |
8531 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
8532 | } |
8533 | ||
d62a17ae | 8534 | if (filter->plist[FILTER_IN].name |
8535 | || filter->dlist[FILTER_IN].name | |
8536 | || filter->aslist[FILTER_IN].name | |
8537 | || filter->map[RMAP_IN].name) | |
8538 | json_object_boolean_true_add(json_addr, | |
8539 | "inboundPathPolicyConfig"); | |
8540 | if (filter->plist[FILTER_OUT].name | |
8541 | || filter->dlist[FILTER_OUT].name | |
8542 | || filter->aslist[FILTER_OUT].name | |
8543 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
8544 | json_object_boolean_true_add( | |
8545 | json_addr, "outboundPathPolicyConfig"); | |
8546 | ||
8547 | /* prefix-list */ | |
8548 | if (filter->plist[FILTER_IN].name) | |
8549 | json_object_string_add(json_addr, | |
8550 | "incomingUpdatePrefixFilterList", | |
8551 | filter->plist[FILTER_IN].name); | |
8552 | if (filter->plist[FILTER_OUT].name) | |
8553 | json_object_string_add(json_addr, | |
8554 | "outgoingUpdatePrefixFilterList", | |
8555 | filter->plist[FILTER_OUT].name); | |
8556 | ||
8557 | /* distribute-list */ | |
8558 | if (filter->dlist[FILTER_IN].name) | |
8559 | json_object_string_add( | |
8560 | json_addr, "incomingUpdateNetworkFilterList", | |
8561 | filter->dlist[FILTER_IN].name); | |
8562 | if (filter->dlist[FILTER_OUT].name) | |
8563 | json_object_string_add( | |
8564 | json_addr, "outgoingUpdateNetworkFilterList", | |
8565 | filter->dlist[FILTER_OUT].name); | |
8566 | ||
8567 | /* filter-list. */ | |
8568 | if (filter->aslist[FILTER_IN].name) | |
8569 | json_object_string_add(json_addr, | |
8570 | "incomingUpdateAsPathFilterList", | |
8571 | filter->aslist[FILTER_IN].name); | |
8572 | if (filter->aslist[FILTER_OUT].name) | |
8573 | json_object_string_add(json_addr, | |
8574 | "outgoingUpdateAsPathFilterList", | |
8575 | filter->aslist[FILTER_OUT].name); | |
8576 | ||
8577 | /* route-map. */ | |
8578 | if (filter->map[RMAP_IN].name) | |
8579 | json_object_string_add( | |
8580 | json_addr, "routeMapForIncomingAdvertisements", | |
8581 | filter->map[RMAP_IN].name); | |
8582 | if (filter->map[RMAP_OUT].name) | |
8583 | json_object_string_add( | |
8584 | json_addr, "routeMapForOutgoingAdvertisements", | |
8585 | filter->map[RMAP_OUT].name); | |
8586 | ||
8587 | /* unsuppress-map */ | |
8588 | if (filter->usmap.name) | |
8589 | json_object_string_add(json_addr, | |
8590 | "selectiveUnsuppressRouteMap", | |
8591 | filter->usmap.name); | |
8592 | ||
8593 | /* Receive prefix count */ | |
8594 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
8595 | p->pcount[afi][safi]); | |
8596 | ||
8597 | /* Maximum prefix */ | |
8598 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
8599 | json_object_int_add(json_addr, "prefixAllowedMax", | |
8600 | p->pmax[afi][safi]); | |
8601 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8602 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
8603 | json_object_boolean_true_add( | |
8604 | json_addr, "prefixAllowedMaxWarning"); | |
8605 | json_object_int_add(json_addr, | |
8606 | "prefixAllowedWarningThresh", | |
8607 | p->pmax_threshold[afi][safi]); | |
8608 | if (p->pmax_restart[afi][safi]) | |
8609 | json_object_int_add( | |
8610 | json_addr, | |
8611 | "prefixAllowedRestartIntervalMsecs", | |
8612 | p->pmax_restart[afi][safi] * 60000); | |
8613 | } | |
8614 | json_object_object_add(json_neigh, afi_safi_print(afi, safi), | |
8615 | json_addr); | |
8616 | ||
8617 | } else { | |
8618 | filter = &p->filter[afi][safi]; | |
8619 | ||
8620 | vty_out(vty, " For address family: %s\n", | |
8621 | afi_safi_print(afi, safi)); | |
8622 | ||
8623 | if (peer_group_active(p)) | |
8624 | vty_out(vty, " %s peer-group member\n", | |
8625 | p->group->name); | |
8626 | ||
8627 | paf = peer_af_find(p, afi, safi); | |
8628 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
8629 | vty_out(vty, " Update group %" PRIu64 |
8630 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 8631 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
8632 | vty_out(vty, " Packet Queue length %d\n", | |
8633 | bpacket_queue_virtual_length(paf)); | |
8634 | } else { | |
8635 | vty_out(vty, " Not part of any update group\n"); | |
8636 | } | |
8637 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8638 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8639 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8640 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8641 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8642 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8643 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8644 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8645 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8646 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8647 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8648 | vty_out(vty, " AF-dependant capabilities:\n"); | |
8649 | ||
8650 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8651 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8652 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8653 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8654 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8655 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8656 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8657 | vty_out(vty, | |
8658 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8659 | ORF_TYPE_PREFIX); | |
8660 | bgp_show_peer_afi_orf_cap( | |
8661 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8662 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8663 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8664 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
8665 | } | |
8666 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8667 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8668 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8669 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8670 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8671 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8672 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8673 | vty_out(vty, | |
8674 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8675 | ORF_TYPE_PREFIX_OLD); | |
8676 | bgp_show_peer_afi_orf_cap( | |
8677 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8678 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8679 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8680 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
8681 | } | |
8682 | ||
8683 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8684 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8685 | NULL, afi, orf_pfx_name, use_json); | |
8686 | ||
8687 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8688 | PEER_STATUS_ORF_PREFIX_SEND) | |
8689 | || orf_pfx_count) { | |
8690 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
8691 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8692 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8693 | vty_out(vty, " sent;"); | |
8694 | if (orf_pfx_count) | |
8695 | vty_out(vty, " received (%d entries)", | |
8696 | orf_pfx_count); | |
8697 | vty_out(vty, "\n"); | |
8698 | } | |
8699 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8700 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8701 | vty_out(vty, | |
8702 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
8703 | ||
8704 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8705 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8706 | vty_out(vty, " Route-Reflector Client\n"); | |
8707 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8708 | PEER_FLAG_RSERVER_CLIENT)) | |
8709 | vty_out(vty, " Route-Server Client\n"); | |
8710 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8711 | vty_out(vty, | |
8712 | " Inbound soft reconfiguration allowed\n"); | |
8713 | ||
8714 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8715 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8716 | vty_out(vty, | |
8717 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
8718 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8719 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8720 | vty_out(vty, | |
8721 | " Private AS numbers replaced in updates to this neighbor\n"); | |
8722 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8723 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8724 | vty_out(vty, | |
8725 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
8726 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8727 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8728 | vty_out(vty, | |
8729 | " Private AS numbers removed in updates to this neighbor\n"); | |
8730 | ||
8731 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8732 | PEER_FLAG_ADDPATH_TX_ALL_PATHS)) | |
8733 | vty_out(vty, " Advertise all paths via addpath\n"); | |
8734 | ||
8735 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8736 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
8737 | vty_out(vty, | |
8738 | " Advertise bestpath per AS via addpath\n"); | |
8739 | ||
8740 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8741 | vty_out(vty, | |
8742 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
8743 | ||
8744 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8745 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8746 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8747 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
8748 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8749 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8750 | vty_out(vty, | |
8751 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
8752 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8753 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
8754 | vty_out(vty, | |
8755 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
8756 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
8757 | vty_out(vty, | |
8758 | " MED is propagated unchanged to this neighbor\n"); | |
8759 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
8760 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8761 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
8762 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8763 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
8764 | vty_out(vty, | |
8765 | " Community attribute sent to this neighbor"); | |
8766 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8767 | PEER_FLAG_SEND_COMMUNITY) | |
8768 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8769 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
8770 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8771 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
8772 | vty_out(vty, "(all)\n"); | |
8773 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8774 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
8775 | vty_out(vty, "(large)\n"); | |
8776 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8777 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8778 | vty_out(vty, "(extended)\n"); | |
8779 | else | |
8780 | vty_out(vty, "(standard)\n"); | |
8781 | } | |
8782 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8783 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
8784 | vty_out(vty, " Default information originate,"); | |
8785 | ||
8786 | if (p->default_rmap[afi][safi].name) | |
8787 | vty_out(vty, " default route-map %s%s,", | |
8788 | p->default_rmap[afi][safi].map ? "*" | |
8789 | : "", | |
8790 | p->default_rmap[afi][safi].name); | |
8791 | if (paf && PAF_SUBGRP(paf) | |
8792 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
8793 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
8794 | vty_out(vty, " default sent\n"); | |
8795 | else | |
8796 | vty_out(vty, " default not sent\n"); | |
8797 | } | |
8798 | ||
dff8f48d MK |
8799 | /* advertise-vni-all */ |
8800 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 8801 | if (is_evpn_enabled()) |
dff8f48d MK |
8802 | vty_out(vty, " advertise-all-vni\n"); |
8803 | } | |
8804 | ||
d62a17ae | 8805 | if (filter->plist[FILTER_IN].name |
8806 | || filter->dlist[FILTER_IN].name | |
8807 | || filter->aslist[FILTER_IN].name | |
8808 | || filter->map[RMAP_IN].name) | |
8809 | vty_out(vty, " Inbound path policy configured\n"); | |
8810 | if (filter->plist[FILTER_OUT].name | |
8811 | || filter->dlist[FILTER_OUT].name | |
8812 | || filter->aslist[FILTER_OUT].name | |
8813 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
8814 | vty_out(vty, " Outbound path policy configured\n"); | |
8815 | ||
8816 | /* prefix-list */ | |
8817 | if (filter->plist[FILTER_IN].name) | |
8818 | vty_out(vty, | |
8819 | " Incoming update prefix filter list is %s%s\n", | |
8820 | filter->plist[FILTER_IN].plist ? "*" : "", | |
8821 | filter->plist[FILTER_IN].name); | |
8822 | if (filter->plist[FILTER_OUT].name) | |
8823 | vty_out(vty, | |
8824 | " Outgoing update prefix filter list is %s%s\n", | |
8825 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
8826 | filter->plist[FILTER_OUT].name); | |
8827 | ||
8828 | /* distribute-list */ | |
8829 | if (filter->dlist[FILTER_IN].name) | |
8830 | vty_out(vty, | |
8831 | " Incoming update network filter list is %s%s\n", | |
8832 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
8833 | filter->dlist[FILTER_IN].name); | |
8834 | if (filter->dlist[FILTER_OUT].name) | |
8835 | vty_out(vty, | |
8836 | " Outgoing update network filter list is %s%s\n", | |
8837 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
8838 | filter->dlist[FILTER_OUT].name); | |
8839 | ||
8840 | /* filter-list. */ | |
8841 | if (filter->aslist[FILTER_IN].name) | |
8842 | vty_out(vty, | |
8843 | " Incoming update AS path filter list is %s%s\n", | |
8844 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
8845 | filter->aslist[FILTER_IN].name); | |
8846 | if (filter->aslist[FILTER_OUT].name) | |
8847 | vty_out(vty, | |
8848 | " Outgoing update AS path filter list is %s%s\n", | |
8849 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
8850 | filter->aslist[FILTER_OUT].name); | |
8851 | ||
8852 | /* route-map. */ | |
8853 | if (filter->map[RMAP_IN].name) | |
8854 | vty_out(vty, | |
8855 | " Route map for incoming advertisements is %s%s\n", | |
8856 | filter->map[RMAP_IN].map ? "*" : "", | |
8857 | filter->map[RMAP_IN].name); | |
8858 | if (filter->map[RMAP_OUT].name) | |
8859 | vty_out(vty, | |
8860 | " Route map for outgoing advertisements is %s%s\n", | |
8861 | filter->map[RMAP_OUT].map ? "*" : "", | |
8862 | filter->map[RMAP_OUT].name); | |
8863 | ||
8864 | /* unsuppress-map */ | |
8865 | if (filter->usmap.name) | |
8866 | vty_out(vty, | |
8867 | " Route map for selective unsuppress is %s%s\n", | |
8868 | filter->usmap.map ? "*" : "", | |
8869 | filter->usmap.name); | |
8870 | ||
8871 | /* Receive prefix count */ | |
8872 | vty_out(vty, " %ld accepted prefixes\n", p->pcount[afi][safi]); | |
8873 | ||
8874 | /* Maximum prefix */ | |
8875 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
8876 | vty_out(vty, " Maximum prefixes allowed %ld%s\n", | |
8877 | p->pmax[afi][safi], | |
8878 | CHECK_FLAG(p->af_flags[afi][safi], | |
8879 | PEER_FLAG_MAX_PREFIX_WARNING) | |
8880 | ? " (warning-only)" | |
8881 | : ""); | |
8882 | vty_out(vty, " Threshold for warning message %d%%", | |
8883 | p->pmax_threshold[afi][safi]); | |
8884 | if (p->pmax_restart[afi][safi]) | |
8885 | vty_out(vty, ", restart interval %d min", | |
8886 | p->pmax_restart[afi][safi]); | |
8887 | vty_out(vty, "\n"); | |
8888 | } | |
8889 | ||
8890 | vty_out(vty, "\n"); | |
8891 | } | |
8892 | } | |
8893 | ||
d7c0a89a | 8894 | static void bgp_show_peer(struct vty *vty, struct peer *p, uint8_t use_json, |
d62a17ae | 8895 | json_object *json) |
718e3744 | 8896 | { |
d62a17ae | 8897 | struct bgp *bgp; |
8898 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
8899 | char timebuf[BGP_UPTIME_LEN]; | |
8900 | char dn_flag[2]; | |
8901 | const char *subcode_str; | |
8902 | const char *code_str; | |
8903 | afi_t afi; | |
8904 | safi_t safi; | |
d7c0a89a QY |
8905 | uint16_t i; |
8906 | uint8_t *msg; | |
d62a17ae | 8907 | json_object *json_neigh = NULL; |
8908 | time_t epoch_tbuf; | |
718e3744 | 8909 | |
d62a17ae | 8910 | bgp = p->bgp; |
8911 | ||
8912 | if (use_json) | |
8913 | json_neigh = json_object_new_object(); | |
8914 | ||
8915 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8916 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
8917 | dn_flag[0] = '*'; | |
8918 | ||
8919 | if (!use_json) { | |
8920 | if (p->conf_if) /* Configured interface name. */ | |
8921 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
8922 | BGP_PEER_SU_UNSPEC(p) | |
8923 | ? "None" | |
8924 | : sockunion2str(&p->su, buf, | |
8925 | SU_ADDRSTRLEN)); | |
8926 | else /* Configured IP address. */ | |
8927 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
8928 | p->host); | |
8929 | } | |
8930 | ||
8931 | if (use_json) { | |
8932 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
8933 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
8934 | "none"); | |
8935 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
8936 | json_object_string_add( | |
8937 | json_neigh, "bgpNeighborAddr", | |
8938 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
8939 | ||
8940 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
8941 | ||
8942 | if (p->change_local_as) | |
8943 | json_object_int_add(json_neigh, "localAs", | |
8944 | p->change_local_as); | |
8945 | else | |
8946 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
8947 | ||
8948 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
8949 | json_object_boolean_true_add(json_neigh, | |
8950 | "localAsNoPrepend"); | |
8951 | ||
8952 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
8953 | json_object_boolean_true_add(json_neigh, | |
8954 | "localAsReplaceAs"); | |
8955 | } else { | |
8956 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
8957 | || (p->as_type == AS_INTERNAL)) | |
8958 | vty_out(vty, "remote AS %u, ", p->as); | |
8959 | else | |
8960 | vty_out(vty, "remote AS Unspecified, "); | |
8961 | vty_out(vty, "local AS %u%s%s, ", | |
8962 | p->change_local_as ? p->change_local_as : p->local_as, | |
8963 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
8964 | ? " no-prepend" | |
8965 | : "", | |
8966 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
8967 | ? " replace-as" | |
8968 | : ""); | |
8969 | } | |
8970 | /* peer type internal, external, confed-internal or confed-external */ | |
8971 | if (p->as == p->local_as) { | |
8972 | if (use_json) { | |
8973 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
8974 | json_object_boolean_true_add( | |
8975 | json_neigh, "nbrConfedInternalLink"); | |
8976 | else | |
8977 | json_object_boolean_true_add(json_neigh, | |
8978 | "nbrInternalLink"); | |
8979 | } else { | |
8980 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
8981 | vty_out(vty, "confed-internal link\n"); | |
8982 | else | |
8983 | vty_out(vty, "internal link\n"); | |
8984 | } | |
8985 | } else { | |
8986 | if (use_json) { | |
8987 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
8988 | json_object_boolean_true_add( | |
8989 | json_neigh, "nbrConfedExternalLink"); | |
8990 | else | |
8991 | json_object_boolean_true_add(json_neigh, | |
8992 | "nbrExternalLink"); | |
8993 | } else { | |
8994 | if (bgp_confederation_peers_check(bgp, p->as)) | |
8995 | vty_out(vty, "confed-external link\n"); | |
8996 | else | |
8997 | vty_out(vty, "external link\n"); | |
8998 | } | |
8999 | } | |
9000 | ||
9001 | /* Description. */ | |
9002 | if (p->desc) { | |
9003 | if (use_json) | |
9004 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
9005 | else | |
9006 | vty_out(vty, " Description: %s\n", p->desc); | |
9007 | } | |
9008 | ||
9009 | if (p->hostname) { | |
9010 | if (use_json) { | |
9011 | if (p->hostname) | |
9012 | json_object_string_add(json_neigh, "hostname", | |
9013 | p->hostname); | |
9014 | ||
9015 | if (p->domainname) | |
9016 | json_object_string_add(json_neigh, "domainname", | |
9017 | p->domainname); | |
9018 | } else { | |
9019 | if (p->domainname && (p->domainname[0] != '\0')) | |
9020 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
9021 | p->domainname); | |
9022 | else | |
9023 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
9024 | } | |
9025 | } | |
9026 | ||
9027 | /* Peer-group */ | |
9028 | if (p->group) { | |
9029 | if (use_json) { | |
9030 | json_object_string_add(json_neigh, "peerGroup", | |
9031 | p->group->name); | |
9032 | ||
9033 | if (dn_flag[0]) { | |
9034 | struct prefix prefix, *range = NULL; | |
9035 | ||
9036 | sockunion2hostprefix(&(p->su), &prefix); | |
9037 | range = peer_group_lookup_dynamic_neighbor_range( | |
9038 | p->group, &prefix); | |
9039 | ||
9040 | if (range) { | |
9041 | prefix2str(range, buf1, sizeof(buf1)); | |
9042 | json_object_string_add( | |
9043 | json_neigh, | |
9044 | "peerSubnetRangeGroup", buf1); | |
9045 | } | |
9046 | } | |
9047 | } else { | |
9048 | vty_out(vty, | |
9049 | " Member of peer-group %s for session parameters\n", | |
9050 | p->group->name); | |
9051 | ||
9052 | if (dn_flag[0]) { | |
9053 | struct prefix prefix, *range = NULL; | |
9054 | ||
9055 | sockunion2hostprefix(&(p->su), &prefix); | |
9056 | range = peer_group_lookup_dynamic_neighbor_range( | |
9057 | p->group, &prefix); | |
9058 | ||
9059 | if (range) { | |
9060 | prefix2str(range, buf1, sizeof(buf1)); | |
9061 | vty_out(vty, | |
9062 | " Belongs to the subnet range group: %s\n", | |
9063 | buf1); | |
9064 | } | |
9065 | } | |
9066 | } | |
9067 | } | |
9068 | ||
9069 | if (use_json) { | |
9070 | /* Administrative shutdown. */ | |
9071 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9072 | json_object_boolean_true_add(json_neigh, | |
9073 | "adminShutDown"); | |
9074 | ||
9075 | /* BGP Version. */ | |
9076 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
9077 | json_object_string_add( | |
9078 | json_neigh, "remoteRouterId", | |
9079 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
9080 | ||
9081 | /* Confederation */ | |
9082 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9083 | && bgp_confederation_peers_check(bgp, p->as)) | |
9084 | json_object_boolean_true_add(json_neigh, | |
9085 | "nbrCommonAdmin"); | |
9086 | ||
9087 | /* Status. */ | |
9088 | json_object_string_add( | |
9089 | json_neigh, "bgpState", | |
9090 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9091 | ||
9092 | if (p->status == Established) { | |
9093 | time_t uptime; | |
d62a17ae | 9094 | |
9095 | uptime = bgp_clock(); | |
9096 | uptime -= p->uptime; | |
d62a17ae | 9097 | epoch_tbuf = time(NULL) - uptime; |
9098 | ||
e24be241 | 9099 | #if defined(VERSION_TYPE_DEV) && CONFDATE > 20200101 |
a4d82a8a PZ |
9100 | CPP_NOTICE( |
9101 | "bgpTimerUp should be deprecated and can be removed now"); | |
d3c7efed DS |
9102 | #endif |
9103 | /* | |
9104 | * bgpTimerUp was miliseconds that was accurate | |
9105 | * up to 1 day, then the value returned | |
9106 | * became garbage. So in order to provide | |
9107 | * some level of backwards compatability, | |
9108 | * we still provde the data, but now | |
9109 | * we are returning the correct value | |
9110 | * and also adding a new bgpTimerUpMsec | |
9111 | * which will allow us to deprecate | |
9112 | * this eventually | |
9113 | */ | |
d62a17ae | 9114 | json_object_int_add(json_neigh, "bgpTimerUp", |
e0330274 | 9115 | uptime * 1000); |
d3c7efed DS |
9116 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
9117 | uptime * 1000); | |
d62a17ae | 9118 | json_object_string_add(json_neigh, "bgpTimerUpString", |
9119 | peer_uptime(p->uptime, timebuf, | |
9120 | BGP_UPTIME_LEN, 0, | |
9121 | NULL)); | |
9122 | json_object_int_add(json_neigh, | |
9123 | "bgpTimerUpEstablishedEpoch", | |
9124 | epoch_tbuf); | |
9125 | } | |
9126 | ||
9127 | else if (p->status == Active) { | |
9128 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9129 | json_object_string_add(json_neigh, "bgpStateIs", | |
9130 | "passive"); | |
9131 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9132 | json_object_string_add(json_neigh, "bgpStateIs", | |
9133 | "passiveNSF"); | |
9134 | } | |
9135 | ||
9136 | /* read timer */ | |
9137 | time_t uptime; | |
9138 | struct tm *tm; | |
9139 | ||
9140 | uptime = bgp_clock(); | |
9141 | uptime -= p->readtime; | |
9142 | tm = gmtime(&uptime); | |
9143 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
9144 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9145 | + (tm->tm_hour * 3600000)); | |
9146 | ||
9147 | uptime = bgp_clock(); | |
9148 | uptime -= p->last_write; | |
9149 | tm = gmtime(&uptime); | |
9150 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
9151 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9152 | + (tm->tm_hour * 3600000)); | |
9153 | ||
9154 | uptime = bgp_clock(); | |
9155 | uptime -= p->update_time; | |
9156 | tm = gmtime(&uptime); | |
9157 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
9158 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9159 | + (tm->tm_hour * 3600000)); | |
9160 | ||
9161 | /* Configured timer values. */ | |
9162 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
9163 | p->v_holdtime * 1000); | |
9164 | json_object_int_add(json_neigh, | |
9165 | "bgpTimerKeepAliveIntervalMsecs", | |
9166 | p->v_keepalive * 1000); | |
9167 | ||
d25e4efc | 9168 | if (PEER_OR_GROUP_TIMER_SET(p)) { |
d62a17ae | 9169 | json_object_int_add(json_neigh, |
9170 | "bgpTimerConfiguredHoldTimeMsecs", | |
9171 | p->holdtime * 1000); | |
9172 | json_object_int_add( | |
9173 | json_neigh, | |
9174 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9175 | p->keepalive * 1000); | |
d25e4efc | 9176 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9177 | || (bgp->default_keepalive |
9178 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9179 | json_object_int_add(json_neigh, |
9180 | "bgpTimerConfiguredHoldTimeMsecs", | |
9181 | bgp->default_holdtime); | |
9182 | json_object_int_add( | |
9183 | json_neigh, | |
9184 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9185 | bgp->default_keepalive); | |
d62a17ae | 9186 | } |
9187 | } else { | |
9188 | /* Administrative shutdown. */ | |
9189 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9190 | vty_out(vty, " Administratively shut down\n"); | |
9191 | ||
9192 | /* BGP Version. */ | |
9193 | vty_out(vty, " BGP version 4"); | |
9194 | vty_out(vty, ", remote router ID %s\n", | |
9195 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
9196 | ||
9197 | /* Confederation */ | |
9198 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9199 | && bgp_confederation_peers_check(bgp, p->as)) | |
9200 | vty_out(vty, | |
9201 | " Neighbor under common administration\n"); | |
9202 | ||
9203 | /* Status. */ | |
9204 | vty_out(vty, " BGP state = %s", | |
9205 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9206 | ||
9207 | if (p->status == Established) | |
9208 | vty_out(vty, ", up for %8s", | |
9209 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
9210 | 0, NULL)); | |
9211 | ||
9212 | else if (p->status == Active) { | |
9213 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9214 | vty_out(vty, " (passive)"); | |
9215 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9216 | vty_out(vty, " (NSF passive)"); | |
9217 | } | |
9218 | vty_out(vty, "\n"); | |
9219 | ||
9220 | /* read timer */ | |
9221 | vty_out(vty, " Last read %s", | |
9222 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
9223 | NULL)); | |
9224 | vty_out(vty, ", Last write %s\n", | |
9225 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
9226 | NULL)); | |
9227 | ||
9228 | /* Configured timer values. */ | |
9229 | vty_out(vty, | |
9230 | " Hold time is %d, keepalive interval is %d seconds\n", | |
9231 | p->v_holdtime, p->v_keepalive); | |
d25e4efc | 9232 | if (PEER_OR_GROUP_TIMER_SET(p)) { |
d62a17ae | 9233 | vty_out(vty, " Configured hold time is %d", |
9234 | p->holdtime); | |
9235 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9236 | p->keepalive); | |
d25e4efc | 9237 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9238 | || (bgp->default_keepalive |
9239 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9240 | vty_out(vty, " Configured hold time is %d", |
9241 | bgp->default_holdtime); | |
9242 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9243 | bgp->default_keepalive); | |
d62a17ae | 9244 | } |
9245 | } | |
9246 | /* Capability. */ | |
9247 | if (p->status == Established) { | |
9248 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
9249 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
9250 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
9251 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
9252 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
9253 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
9254 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
9255 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
9256 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
9257 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
9258 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
9259 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 9260 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
9261 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 9262 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
9263 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 9264 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
9265 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 9266 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
9267 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
9268 | if (use_json) { | |
9269 | json_object *json_cap = NULL; | |
9270 | ||
9271 | json_cap = json_object_new_object(); | |
9272 | ||
9273 | /* AS4 */ | |
9274 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9275 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9276 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
9277 | && CHECK_FLAG(p->cap, | |
9278 | PEER_CAP_AS4_RCV)) | |
9279 | json_object_string_add( | |
9280 | json_cap, "4byteAs", | |
9281 | "advertisedAndReceived"); | |
9282 | else if (CHECK_FLAG(p->cap, | |
9283 | PEER_CAP_AS4_ADV)) | |
9284 | json_object_string_add( | |
9285 | json_cap, "4byteAs", | |
9286 | "advertised"); | |
9287 | else if (CHECK_FLAG(p->cap, | |
9288 | PEER_CAP_AS4_RCV)) | |
9289 | json_object_string_add( | |
9290 | json_cap, "4byteAs", | |
9291 | "received"); | |
9292 | } | |
9293 | ||
9294 | /* AddPath */ | |
9295 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9296 | || CHECK_FLAG(p->cap, | |
9297 | PEER_CAP_ADDPATH_ADV)) { | |
9298 | json_object *json_add = NULL; | |
9299 | const char *print_store; | |
9300 | ||
9301 | json_add = json_object_new_object(); | |
9302 | ||
05c7a1cc QY |
9303 | FOREACH_AFI_SAFI (afi, safi) { |
9304 | json_object *json_sub = NULL; | |
9305 | json_sub = | |
9306 | json_object_new_object(); | |
9307 | print_store = afi_safi_print( | |
9308 | afi, safi); | |
d62a17ae | 9309 | |
05c7a1cc QY |
9310 | if (CHECK_FLAG( |
9311 | p->af_cap[afi] | |
9312 | [safi], | |
9313 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9314 | || CHECK_FLAG( | |
9315 | p->af_cap[afi] | |
9316 | [safi], | |
9317 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 9318 | if (CHECK_FLAG( |
9319 | p->af_cap | |
9320 | [afi] | |
9321 | [safi], | |
9322 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 9323 | && CHECK_FLAG( |
d62a17ae | 9324 | p->af_cap |
9325 | [afi] | |
9326 | [safi], | |
05c7a1cc QY |
9327 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
9328 | json_object_boolean_true_add( | |
9329 | json_sub, | |
9330 | "txAdvertisedAndReceived"); | |
9331 | else if ( | |
9332 | CHECK_FLAG( | |
9333 | p->af_cap | |
9334 | [afi] | |
9335 | [safi], | |
9336 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
9337 | json_object_boolean_true_add( | |
9338 | json_sub, | |
9339 | "txAdvertised"); | |
9340 | else if ( | |
9341 | CHECK_FLAG( | |
9342 | p->af_cap | |
9343 | [afi] | |
9344 | [safi], | |
9345 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
9346 | json_object_boolean_true_add( | |
9347 | json_sub, | |
9348 | "txReceived"); | |
9349 | } | |
d62a17ae | 9350 | |
05c7a1cc QY |
9351 | if (CHECK_FLAG( |
9352 | p->af_cap[afi] | |
9353 | [safi], | |
9354 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9355 | || CHECK_FLAG( | |
9356 | p->af_cap[afi] | |
9357 | [safi], | |
9358 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 9359 | if (CHECK_FLAG( |
9360 | p->af_cap | |
9361 | [afi] | |
9362 | [safi], | |
9363 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 9364 | && CHECK_FLAG( |
d62a17ae | 9365 | p->af_cap |
9366 | [afi] | |
9367 | [safi], | |
9368 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
9369 | json_object_boolean_true_add( |
9370 | json_sub, | |
9371 | "rxAdvertisedAndReceived"); | |
9372 | else if ( | |
9373 | CHECK_FLAG( | |
9374 | p->af_cap | |
9375 | [afi] | |
9376 | [safi], | |
9377 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
9378 | json_object_boolean_true_add( | |
9379 | json_sub, | |
9380 | "rxAdvertised"); | |
9381 | else if ( | |
9382 | CHECK_FLAG( | |
9383 | p->af_cap | |
9384 | [afi] | |
9385 | [safi], | |
9386 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9387 | json_object_boolean_true_add( | |
9388 | json_sub, | |
9389 | "rxReceived"); | |
d62a17ae | 9390 | } |
9391 | ||
05c7a1cc QY |
9392 | if (CHECK_FLAG( |
9393 | p->af_cap[afi] | |
9394 | [safi], | |
9395 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9396 | || CHECK_FLAG( | |
9397 | p->af_cap[afi] | |
9398 | [safi], | |
9399 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
9400 | || CHECK_FLAG( | |
9401 | p->af_cap[afi] | |
9402 | [safi], | |
9403 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9404 | || CHECK_FLAG( | |
9405 | p->af_cap[afi] | |
9406 | [safi], | |
9407 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9408 | json_object_object_add( | |
9409 | json_add, | |
9410 | print_store, | |
9411 | json_sub); | |
9412 | else | |
9413 | json_object_free( | |
9414 | json_sub); | |
9415 | } | |
9416 | ||
d62a17ae | 9417 | json_object_object_add( |
9418 | json_cap, "addPath", json_add); | |
9419 | } | |
9420 | ||
9421 | /* Dynamic */ | |
9422 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
9423 | || CHECK_FLAG(p->cap, | |
9424 | PEER_CAP_DYNAMIC_ADV)) { | |
9425 | if (CHECK_FLAG(p->cap, | |
9426 | PEER_CAP_DYNAMIC_ADV) | |
9427 | && CHECK_FLAG(p->cap, | |
9428 | PEER_CAP_DYNAMIC_RCV)) | |
9429 | json_object_string_add( | |
9430 | json_cap, "dynamic", | |
9431 | "advertisedAndReceived"); | |
9432 | else if (CHECK_FLAG( | |
9433 | p->cap, | |
9434 | PEER_CAP_DYNAMIC_ADV)) | |
9435 | json_object_string_add( | |
9436 | json_cap, "dynamic", | |
9437 | "advertised"); | |
9438 | else if (CHECK_FLAG( | |
9439 | p->cap, | |
9440 | PEER_CAP_DYNAMIC_RCV)) | |
9441 | json_object_string_add( | |
9442 | json_cap, "dynamic", | |
9443 | "received"); | |
9444 | } | |
9445 | ||
9446 | /* Extended nexthop */ | |
9447 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
9448 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
9449 | json_object *json_nxt = NULL; | |
9450 | const char *print_store; | |
9451 | ||
9452 | ||
9453 | if (CHECK_FLAG(p->cap, | |
9454 | PEER_CAP_ENHE_ADV) | |
9455 | && CHECK_FLAG(p->cap, | |
9456 | PEER_CAP_ENHE_RCV)) | |
9457 | json_object_string_add( | |
9458 | json_cap, | |
9459 | "extendedNexthop", | |
9460 | "advertisedAndReceived"); | |
9461 | else if (CHECK_FLAG(p->cap, | |
9462 | PEER_CAP_ENHE_ADV)) | |
9463 | json_object_string_add( | |
9464 | json_cap, | |
9465 | "extendedNexthop", | |
9466 | "advertised"); | |
9467 | else if (CHECK_FLAG(p->cap, | |
9468 | PEER_CAP_ENHE_RCV)) | |
9469 | json_object_string_add( | |
9470 | json_cap, | |
9471 | "extendedNexthop", | |
9472 | "received"); | |
9473 | ||
9474 | if (CHECK_FLAG(p->cap, | |
9475 | PEER_CAP_ENHE_RCV)) { | |
9476 | json_nxt = | |
9477 | json_object_new_object(); | |
9478 | ||
9479 | for (safi = SAFI_UNICAST; | |
9480 | safi < SAFI_MAX; safi++) { | |
9481 | if (CHECK_FLAG( | |
9482 | p->af_cap | |
9483 | [AFI_IP] | |
9484 | [safi], | |
9485 | PEER_CAP_ENHE_AF_RCV)) { | |
9486 | print_store = afi_safi_print( | |
9487 | AFI_IP, | |
9488 | safi); | |
9489 | json_object_string_add( | |
9490 | json_nxt, | |
9491 | print_store, | |
9492 | "recieved"); | |
9493 | } | |
9494 | } | |
9495 | json_object_object_add( | |
9496 | json_cap, | |
9497 | "extendedNexthopFamililesByPeer", | |
9498 | json_nxt); | |
9499 | } | |
9500 | } | |
9501 | ||
9502 | /* Route Refresh */ | |
9503 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
9504 | || CHECK_FLAG(p->cap, | |
9505 | PEER_CAP_REFRESH_NEW_RCV) | |
9506 | || CHECK_FLAG(p->cap, | |
9507 | PEER_CAP_REFRESH_OLD_RCV)) { | |
9508 | if (CHECK_FLAG(p->cap, | |
9509 | PEER_CAP_REFRESH_ADV) | |
9510 | && (CHECK_FLAG( | |
9511 | p->cap, | |
9512 | PEER_CAP_REFRESH_NEW_RCV) | |
9513 | || CHECK_FLAG( | |
9514 | p->cap, | |
9515 | PEER_CAP_REFRESH_OLD_RCV))) { | |
9516 | if (CHECK_FLAG( | |
9517 | p->cap, | |
9518 | PEER_CAP_REFRESH_OLD_RCV) | |
9519 | && CHECK_FLAG( | |
9520 | p->cap, | |
9521 | PEER_CAP_REFRESH_NEW_RCV)) | |
9522 | json_object_string_add( | |
9523 | json_cap, | |
9524 | "routeRefresh", | |
9525 | "advertisedAndReceivedOldNew"); | |
9526 | else { | |
9527 | if (CHECK_FLAG( | |
9528 | p->cap, | |
9529 | PEER_CAP_REFRESH_OLD_RCV)) | |
9530 | json_object_string_add( | |
9531 | json_cap, | |
9532 | "routeRefresh", | |
9533 | "advertisedAndReceivedOld"); | |
9534 | else | |
9535 | json_object_string_add( | |
9536 | json_cap, | |
9537 | "routeRefresh", | |
9538 | "advertisedAndReceivedNew"); | |
9539 | } | |
9540 | } else if ( | |
9541 | CHECK_FLAG( | |
9542 | p->cap, | |
9543 | PEER_CAP_REFRESH_ADV)) | |
9544 | json_object_string_add( | |
9545 | json_cap, | |
9546 | "routeRefresh", | |
9547 | "advertised"); | |
9548 | else if ( | |
9549 | CHECK_FLAG( | |
9550 | p->cap, | |
9551 | PEER_CAP_REFRESH_NEW_RCV) | |
9552 | || CHECK_FLAG( | |
9553 | p->cap, | |
9554 | PEER_CAP_REFRESH_OLD_RCV)) | |
9555 | json_object_string_add( | |
9556 | json_cap, | |
9557 | "routeRefresh", | |
9558 | "received"); | |
9559 | } | |
9560 | ||
9561 | /* Multiprotocol Extensions */ | |
9562 | json_object *json_multi = NULL; | |
9563 | json_multi = json_object_new_object(); | |
9564 | ||
05c7a1cc QY |
9565 | FOREACH_AFI_SAFI (afi, safi) { |
9566 | if (p->afc_adv[afi][safi] | |
9567 | || p->afc_recv[afi][safi]) { | |
9568 | json_object *json_exten = NULL; | |
9569 | json_exten = | |
9570 | json_object_new_object(); | |
9571 | ||
d62a17ae | 9572 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
9573 | && p->afc_recv[afi][safi]) |
9574 | json_object_boolean_true_add( | |
9575 | json_exten, | |
9576 | "advertisedAndReceived"); | |
9577 | else if (p->afc_adv[afi][safi]) | |
9578 | json_object_boolean_true_add( | |
9579 | json_exten, | |
9580 | "advertised"); | |
9581 | else if (p->afc_recv[afi][safi]) | |
9582 | json_object_boolean_true_add( | |
9583 | json_exten, | |
9584 | "received"); | |
d62a17ae | 9585 | |
05c7a1cc QY |
9586 | json_object_object_add( |
9587 | json_multi, | |
9588 | afi_safi_print(afi, | |
9589 | safi), | |
9590 | json_exten); | |
d62a17ae | 9591 | } |
9592 | } | |
9593 | json_object_object_add( | |
9594 | json_cap, "multiprotocolExtensions", | |
9595 | json_multi); | |
9596 | ||
d77114b7 | 9597 | /* Hostname capabilities */ |
60466a63 | 9598 | json_object *json_hname = NULL; |
d77114b7 MK |
9599 | |
9600 | json_hname = json_object_new_object(); | |
9601 | ||
9602 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
9603 | json_object_string_add( | |
60466a63 QY |
9604 | json_hname, "advHostName", |
9605 | bgp->peer_self->hostname | |
9606 | ? bgp->peer_self | |
9607 | ->hostname | |
d77114b7 MK |
9608 | : "n/a"); |
9609 | json_object_string_add( | |
60466a63 QY |
9610 | json_hname, "advDomainName", |
9611 | bgp->peer_self->domainname | |
9612 | ? bgp->peer_self | |
9613 | ->domainname | |
d77114b7 MK |
9614 | : "n/a"); |
9615 | } | |
9616 | ||
9617 | ||
9618 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
9619 | json_object_string_add( | |
60466a63 QY |
9620 | json_hname, "rcvHostName", |
9621 | p->hostname ? p->hostname | |
9622 | : "n/a"); | |
d77114b7 | 9623 | json_object_string_add( |
60466a63 QY |
9624 | json_hname, "rcvDomainName", |
9625 | p->domainname ? p->domainname | |
9626 | : "n/a"); | |
d77114b7 MK |
9627 | } |
9628 | ||
60466a63 | 9629 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
9630 | json_hname); |
9631 | ||
d62a17ae | 9632 | /* Gracefull Restart */ |
9633 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
9634 | || CHECK_FLAG(p->cap, | |
9635 | PEER_CAP_RESTART_ADV)) { | |
9636 | if (CHECK_FLAG(p->cap, | |
9637 | PEER_CAP_RESTART_ADV) | |
9638 | && CHECK_FLAG(p->cap, | |
9639 | PEER_CAP_RESTART_RCV)) | |
9640 | json_object_string_add( | |
9641 | json_cap, | |
9642 | "gracefulRestart", | |
9643 | "advertisedAndReceived"); | |
9644 | else if (CHECK_FLAG( | |
9645 | p->cap, | |
9646 | PEER_CAP_RESTART_ADV)) | |
9647 | json_object_string_add( | |
9648 | json_cap, | |
9649 | "gracefulRestartCapability", | |
9650 | "advertised"); | |
9651 | else if (CHECK_FLAG( | |
9652 | p->cap, | |
9653 | PEER_CAP_RESTART_RCV)) | |
9654 | json_object_string_add( | |
9655 | json_cap, | |
9656 | "gracefulRestartCapability", | |
9657 | "received"); | |
9658 | ||
9659 | if (CHECK_FLAG(p->cap, | |
9660 | PEER_CAP_RESTART_RCV)) { | |
9661 | int restart_af_count = 0; | |
9662 | json_object *json_restart = | |
9663 | NULL; | |
9664 | json_restart = | |
9665 | json_object_new_object(); | |
9666 | ||
9667 | json_object_int_add( | |
9668 | json_cap, | |
9669 | "gracefulRestartRemoteTimerMsecs", | |
9670 | p->v_gr_restart * 1000); | |
9671 | ||
05c7a1cc QY |
9672 | FOREACH_AFI_SAFI (afi, safi) { |
9673 | if (CHECK_FLAG( | |
9674 | p->af_cap | |
9675 | [afi] | |
9676 | [safi], | |
9677 | PEER_CAP_RESTART_AF_RCV)) { | |
9678 | json_object * | |
9679 | json_sub = | |
9680 | NULL; | |
9681 | json_sub = | |
9682 | json_object_new_object(); | |
9683 | ||
d62a17ae | 9684 | if (CHECK_FLAG( |
9685 | p->af_cap | |
9686 | [afi] | |
9687 | [safi], | |
05c7a1cc QY |
9688 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
9689 | json_object_boolean_true_add( | |
9690 | json_sub, | |
9691 | "preserved"); | |
9692 | restart_af_count++; | |
9693 | json_object_object_add( | |
9694 | json_restart, | |
9695 | afi_safi_print( | |
9696 | afi, | |
9697 | safi), | |
9698 | json_sub); | |
d62a17ae | 9699 | } |
9700 | } | |
9701 | if (!restart_af_count) { | |
9702 | json_object_string_add( | |
9703 | json_cap, | |
9704 | "addressFamiliesByPeer", | |
9705 | "none"); | |
9706 | json_object_free( | |
9707 | json_restart); | |
9708 | } else | |
9709 | json_object_object_add( | |
9710 | json_cap, | |
9711 | "addressFamiliesByPeer", | |
9712 | json_restart); | |
9713 | } | |
9714 | } | |
9715 | json_object_object_add(json_neigh, | |
9716 | "neighborCapabilities", | |
9717 | json_cap); | |
9718 | } else { | |
9719 | vty_out(vty, " Neighbor capabilities:\n"); | |
9720 | ||
9721 | /* AS4 */ | |
9722 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9723 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9724 | vty_out(vty, " 4 Byte AS:"); | |
9725 | if (CHECK_FLAG(p->cap, | |
9726 | PEER_CAP_AS4_ADV)) | |
9727 | vty_out(vty, " advertised"); | |
9728 | if (CHECK_FLAG(p->cap, | |
9729 | PEER_CAP_AS4_RCV)) | |
9730 | vty_out(vty, " %sreceived", | |
9731 | CHECK_FLAG( | |
9732 | p->cap, | |
9733 | PEER_CAP_AS4_ADV) | |
9734 | ? "and " | |
9735 | : ""); | |
9736 | vty_out(vty, "\n"); | |
9737 | } | |
9738 | ||
9739 | /* AddPath */ | |
9740 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9741 | || CHECK_FLAG(p->cap, | |
9742 | PEER_CAP_ADDPATH_ADV)) { | |
9743 | vty_out(vty, " AddPath:\n"); | |
9744 | ||
05c7a1cc QY |
9745 | FOREACH_AFI_SAFI (afi, safi) { |
9746 | if (CHECK_FLAG( | |
9747 | p->af_cap[afi] | |
9748 | [safi], | |
9749 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9750 | || CHECK_FLAG( | |
9751 | p->af_cap[afi] | |
9752 | [safi], | |
9753 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
9754 | vty_out(vty, | |
9755 | " %s: TX ", | |
9756 | afi_safi_print( | |
9757 | afi, | |
9758 | safi)); | |
9759 | ||
d62a17ae | 9760 | if (CHECK_FLAG( |
9761 | p->af_cap | |
9762 | [afi] | |
9763 | [safi], | |
05c7a1cc | 9764 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 9765 | vty_out(vty, |
05c7a1cc | 9766 | "advertised %s", |
d62a17ae | 9767 | afi_safi_print( |
9768 | afi, | |
9769 | safi)); | |
9770 | ||
05c7a1cc QY |
9771 | if (CHECK_FLAG( |
9772 | p->af_cap | |
9773 | [afi] | |
9774 | [safi], | |
9775 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
9776 | vty_out(vty, | |
9777 | "%sreceived", | |
9778 | CHECK_FLAG( | |
9779 | p->af_cap | |
9780 | [afi] | |
9781 | [safi], | |
9782 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9783 | ? " and " | |
9784 | : ""); | |
d62a17ae | 9785 | |
05c7a1cc QY |
9786 | vty_out(vty, "\n"); |
9787 | } | |
d62a17ae | 9788 | |
05c7a1cc QY |
9789 | if (CHECK_FLAG( |
9790 | p->af_cap[afi] | |
9791 | [safi], | |
9792 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9793 | || CHECK_FLAG( | |
9794 | p->af_cap[afi] | |
9795 | [safi], | |
9796 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
9797 | vty_out(vty, | |
9798 | " %s: RX ", | |
9799 | afi_safi_print( | |
9800 | afi, | |
9801 | safi)); | |
d62a17ae | 9802 | |
9803 | if (CHECK_FLAG( | |
9804 | p->af_cap | |
9805 | [afi] | |
9806 | [safi], | |
05c7a1cc | 9807 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 9808 | vty_out(vty, |
05c7a1cc | 9809 | "advertised %s", |
d62a17ae | 9810 | afi_safi_print( |
9811 | afi, | |
9812 | safi)); | |
9813 | ||
05c7a1cc QY |
9814 | if (CHECK_FLAG( |
9815 | p->af_cap | |
9816 | [afi] | |
9817 | [safi], | |
9818 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 9819 | vty_out(vty, |
05c7a1cc QY |
9820 | "%sreceived", |
9821 | CHECK_FLAG( | |
9822 | p->af_cap | |
9823 | [afi] | |
9824 | [safi], | |
9825 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9826 | ? " and " | |
9827 | : ""); | |
9828 | ||
9829 | vty_out(vty, "\n"); | |
d62a17ae | 9830 | } |
05c7a1cc | 9831 | } |
d62a17ae | 9832 | } |
9833 | ||
9834 | /* Dynamic */ | |
9835 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
9836 | || CHECK_FLAG(p->cap, | |
9837 | PEER_CAP_DYNAMIC_ADV)) { | |
9838 | vty_out(vty, " Dynamic:"); | |
9839 | if (CHECK_FLAG(p->cap, | |
9840 | PEER_CAP_DYNAMIC_ADV)) | |
9841 | vty_out(vty, " advertised"); | |
9842 | if (CHECK_FLAG(p->cap, | |
9843 | PEER_CAP_DYNAMIC_RCV)) | |
9844 | vty_out(vty, " %sreceived", | |
9845 | CHECK_FLAG( | |
9846 | p->cap, | |
9847 | PEER_CAP_DYNAMIC_ADV) | |
9848 | ? "and " | |
9849 | : ""); | |
9850 | vty_out(vty, "\n"); | |
9851 | } | |
9852 | ||
9853 | /* Extended nexthop */ | |
9854 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
9855 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
9856 | vty_out(vty, " Extended nexthop:"); | |
9857 | if (CHECK_FLAG(p->cap, | |
9858 | PEER_CAP_ENHE_ADV)) | |
9859 | vty_out(vty, " advertised"); | |
9860 | if (CHECK_FLAG(p->cap, | |
9861 | PEER_CAP_ENHE_RCV)) | |
9862 | vty_out(vty, " %sreceived", | |
9863 | CHECK_FLAG( | |
9864 | p->cap, | |
9865 | PEER_CAP_ENHE_ADV) | |
9866 | ? "and " | |
9867 | : ""); | |
9868 | vty_out(vty, "\n"); | |
9869 | ||
9870 | if (CHECK_FLAG(p->cap, | |
9871 | PEER_CAP_ENHE_RCV)) { | |
9872 | vty_out(vty, | |
9873 | " Address families by peer:\n "); | |
9874 | for (safi = SAFI_UNICAST; | |
9875 | safi < SAFI_MAX; safi++) | |
9876 | if (CHECK_FLAG( | |
9877 | p->af_cap | |
9878 | [AFI_IP] | |
9879 | [safi], | |
9880 | PEER_CAP_ENHE_AF_RCV)) | |
9881 | vty_out(vty, | |
9882 | " %s\n", | |
9883 | afi_safi_print( | |
9884 | AFI_IP, | |
9885 | safi)); | |
9886 | } | |
9887 | } | |
9888 | ||
9889 | /* Route Refresh */ | |
9890 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
9891 | || CHECK_FLAG(p->cap, | |
9892 | PEER_CAP_REFRESH_NEW_RCV) | |
9893 | || CHECK_FLAG(p->cap, | |
9894 | PEER_CAP_REFRESH_OLD_RCV)) { | |
9895 | vty_out(vty, " Route refresh:"); | |
9896 | if (CHECK_FLAG(p->cap, | |
9897 | PEER_CAP_REFRESH_ADV)) | |
9898 | vty_out(vty, " advertised"); | |
9899 | if (CHECK_FLAG(p->cap, | |
9900 | PEER_CAP_REFRESH_NEW_RCV) | |
9901 | || CHECK_FLAG( | |
9902 | p->cap, | |
9903 | PEER_CAP_REFRESH_OLD_RCV)) | |
9904 | vty_out(vty, " %sreceived(%s)", | |
9905 | CHECK_FLAG( | |
9906 | p->cap, | |
9907 | PEER_CAP_REFRESH_ADV) | |
9908 | ? "and " | |
9909 | : "", | |
9910 | (CHECK_FLAG( | |
9911 | p->cap, | |
9912 | PEER_CAP_REFRESH_OLD_RCV) | |
9913 | && CHECK_FLAG( | |
9914 | p->cap, | |
9915 | PEER_CAP_REFRESH_NEW_RCV)) | |
9916 | ? "old & new" | |
9917 | : CHECK_FLAG( | |
9918 | p->cap, | |
9919 | PEER_CAP_REFRESH_OLD_RCV) | |
9920 | ? "old" | |
9921 | : "new"); | |
9922 | ||
9923 | vty_out(vty, "\n"); | |
9924 | } | |
9925 | ||
9926 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
9927 | FOREACH_AFI_SAFI (afi, safi) |
9928 | if (p->afc_adv[afi][safi] | |
9929 | || p->afc_recv[afi][safi]) { | |
9930 | vty_out(vty, | |
9931 | " Address Family %s:", | |
9932 | afi_safi_print(afi, | |
9933 | safi)); | |
9934 | if (p->afc_adv[afi][safi]) | |
d62a17ae | 9935 | vty_out(vty, |
05c7a1cc QY |
9936 | " advertised"); |
9937 | if (p->afc_recv[afi][safi]) | |
9938 | vty_out(vty, | |
9939 | " %sreceived", | |
9940 | p->afc_adv[afi] | |
9941 | [safi] | |
9942 | ? "and " | |
9943 | : ""); | |
9944 | vty_out(vty, "\n"); | |
9945 | } | |
d62a17ae | 9946 | |
9947 | /* Hostname capability */ | |
60466a63 | 9948 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
9949 | |
9950 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
9951 | vty_out(vty, |
9952 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
9953 | bgp->peer_self->hostname |
9954 | ? bgp->peer_self | |
9955 | ->hostname | |
d77114b7 | 9956 | : "n/a", |
60466a63 QY |
9957 | bgp->peer_self->domainname |
9958 | ? bgp->peer_self | |
9959 | ->domainname | |
d77114b7 MK |
9960 | : "n/a"); |
9961 | } else { | |
9962 | vty_out(vty, " not advertised"); | |
d62a17ae | 9963 | } |
9964 | ||
d77114b7 | 9965 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
9966 | vty_out(vty, |
9967 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
9968 | p->hostname ? p->hostname |
9969 | : "n/a", | |
9970 | p->domainname ? p->domainname | |
9971 | : "n/a"); | |
d77114b7 MK |
9972 | } else { |
9973 | vty_out(vty, " not received"); | |
9974 | } | |
9975 | ||
9976 | vty_out(vty, "\n"); | |
9977 | ||
d62a17ae | 9978 | /* Gracefull Restart */ |
9979 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
9980 | || CHECK_FLAG(p->cap, | |
9981 | PEER_CAP_RESTART_ADV)) { | |
9982 | vty_out(vty, | |
9983 | " Graceful Restart Capabilty:"); | |
9984 | if (CHECK_FLAG(p->cap, | |
9985 | PEER_CAP_RESTART_ADV)) | |
9986 | vty_out(vty, " advertised"); | |
9987 | if (CHECK_FLAG(p->cap, | |
9988 | PEER_CAP_RESTART_RCV)) | |
9989 | vty_out(vty, " %sreceived", | |
9990 | CHECK_FLAG( | |
9991 | p->cap, | |
9992 | PEER_CAP_RESTART_ADV) | |
9993 | ? "and " | |
9994 | : ""); | |
9995 | vty_out(vty, "\n"); | |
9996 | ||
9997 | if (CHECK_FLAG(p->cap, | |
9998 | PEER_CAP_RESTART_RCV)) { | |
9999 | int restart_af_count = 0; | |
10000 | ||
10001 | vty_out(vty, | |
10002 | " Remote Restart timer is %d seconds\n", | |
10003 | p->v_gr_restart); | |
10004 | vty_out(vty, | |
10005 | " Address families by peer:\n "); | |
10006 | ||
05c7a1cc QY |
10007 | FOREACH_AFI_SAFI (afi, safi) |
10008 | if (CHECK_FLAG( | |
10009 | p->af_cap | |
10010 | [afi] | |
10011 | [safi], | |
10012 | PEER_CAP_RESTART_AF_RCV)) { | |
10013 | vty_out(vty, | |
10014 | "%s%s(%s)", | |
10015 | restart_af_count | |
10016 | ? ", " | |
10017 | : "", | |
10018 | afi_safi_print( | |
10019 | afi, | |
10020 | safi), | |
10021 | CHECK_FLAG( | |
10022 | p->af_cap | |
10023 | [afi] | |
10024 | [safi], | |
10025 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
10026 | ? "preserved" | |
10027 | : "not preserved"); | |
10028 | restart_af_count++; | |
10029 | } | |
d62a17ae | 10030 | if (!restart_af_count) |
10031 | vty_out(vty, "none"); | |
10032 | vty_out(vty, "\n"); | |
10033 | } | |
10034 | } | |
10035 | } | |
10036 | } | |
10037 | } | |
10038 | ||
10039 | /* graceful restart information */ | |
10040 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || p->t_gr_restart | |
10041 | || p->t_gr_stale) { | |
10042 | json_object *json_grace = NULL; | |
10043 | json_object *json_grace_send = NULL; | |
10044 | json_object *json_grace_recv = NULL; | |
10045 | int eor_send_af_count = 0; | |
10046 | int eor_receive_af_count = 0; | |
10047 | ||
10048 | if (use_json) { | |
10049 | json_grace = json_object_new_object(); | |
10050 | json_grace_send = json_object_new_object(); | |
10051 | json_grace_recv = json_object_new_object(); | |
10052 | ||
10053 | if (p->status == Established) { | |
05c7a1cc QY |
10054 | FOREACH_AFI_SAFI (afi, safi) { |
10055 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10056 | PEER_STATUS_EOR_SEND)) { | |
10057 | json_object_boolean_true_add( | |
10058 | json_grace_send, | |
10059 | afi_safi_print(afi, | |
10060 | safi)); | |
10061 | eor_send_af_count++; | |
d62a17ae | 10062 | } |
10063 | } | |
05c7a1cc QY |
10064 | FOREACH_AFI_SAFI (afi, safi) { |
10065 | if (CHECK_FLAG( | |
10066 | p->af_sflags[afi][safi], | |
10067 | PEER_STATUS_EOR_RECEIVED)) { | |
10068 | json_object_boolean_true_add( | |
10069 | json_grace_recv, | |
10070 | afi_safi_print(afi, | |
10071 | safi)); | |
10072 | eor_receive_af_count++; | |
d62a17ae | 10073 | } |
10074 | } | |
10075 | } | |
10076 | ||
10077 | json_object_object_add(json_grace, "endOfRibSend", | |
10078 | json_grace_send); | |
10079 | json_object_object_add(json_grace, "endOfRibRecv", | |
10080 | json_grace_recv); | |
10081 | ||
10082 | if (p->t_gr_restart) | |
10083 | json_object_int_add(json_grace, | |
10084 | "gracefulRestartTimerMsecs", | |
10085 | thread_timer_remain_second( | |
10086 | p->t_gr_restart) | |
10087 | * 1000); | |
10088 | ||
10089 | if (p->t_gr_stale) | |
10090 | json_object_int_add( | |
10091 | json_grace, | |
10092 | "gracefulStalepathTimerMsecs", | |
10093 | thread_timer_remain_second( | |
10094 | p->t_gr_stale) | |
10095 | * 1000); | |
10096 | ||
10097 | json_object_object_add( | |
10098 | json_neigh, "gracefulRestartInfo", json_grace); | |
10099 | } else { | |
10100 | vty_out(vty, " Graceful restart informations:\n"); | |
10101 | if (p->status == Established) { | |
10102 | vty_out(vty, " End-of-RIB send: "); | |
05c7a1cc QY |
10103 | FOREACH_AFI_SAFI (afi, safi) { |
10104 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10105 | PEER_STATUS_EOR_SEND)) { | |
10106 | vty_out(vty, "%s%s", | |
10107 | eor_send_af_count ? ", " | |
10108 | : "", | |
10109 | afi_safi_print(afi, | |
10110 | safi)); | |
10111 | eor_send_af_count++; | |
d62a17ae | 10112 | } |
10113 | } | |
10114 | vty_out(vty, "\n"); | |
10115 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
10116 | FOREACH_AFI_SAFI (afi, safi) { |
10117 | if (CHECK_FLAG( | |
10118 | p->af_sflags[afi][safi], | |
10119 | PEER_STATUS_EOR_RECEIVED)) { | |
10120 | vty_out(vty, "%s%s", | |
10121 | eor_receive_af_count | |
10122 | ? ", " | |
10123 | : "", | |
10124 | afi_safi_print(afi, | |
10125 | safi)); | |
10126 | eor_receive_af_count++; | |
d62a17ae | 10127 | } |
10128 | } | |
10129 | vty_out(vty, "\n"); | |
10130 | } | |
10131 | ||
10132 | if (p->t_gr_restart) | |
10133 | vty_out(vty, | |
10134 | " The remaining time of restart timer is %ld\n", | |
10135 | thread_timer_remain_second( | |
10136 | p->t_gr_restart)); | |
10137 | ||
10138 | if (p->t_gr_stale) | |
10139 | vty_out(vty, | |
10140 | " The remaining time of stalepath timer is %ld\n", | |
10141 | thread_timer_remain_second( | |
10142 | p->t_gr_stale)); | |
10143 | } | |
10144 | } | |
10145 | if (use_json) { | |
10146 | json_object *json_stat = NULL; | |
10147 | json_stat = json_object_new_object(); | |
10148 | /* Packet counts. */ | |
10149 | json_object_int_add(json_stat, "depthInq", 0); | |
10150 | json_object_int_add(json_stat, "depthOutq", | |
10151 | (unsigned long)p->obuf->count); | |
0112e9e0 QY |
10152 | json_object_int_add(json_stat, "opensSent", |
10153 | atomic_load_explicit(&p->open_out, | |
10154 | memory_order_relaxed)); | |
10155 | json_object_int_add(json_stat, "opensRecv", | |
10156 | atomic_load_explicit(&p->open_in, | |
10157 | memory_order_relaxed)); | |
d62a17ae | 10158 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
10159 | atomic_load_explicit(&p->notify_out, |
10160 | memory_order_relaxed)); | |
d62a17ae | 10161 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
10162 | atomic_load_explicit(&p->notify_in, |
10163 | memory_order_relaxed)); | |
10164 | json_object_int_add(json_stat, "updatesSent", | |
10165 | atomic_load_explicit(&p->update_out, | |
10166 | memory_order_relaxed)); | |
10167 | json_object_int_add(json_stat, "updatesRecv", | |
10168 | atomic_load_explicit(&p->update_in, | |
10169 | memory_order_relaxed)); | |
d62a17ae | 10170 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
10171 | atomic_load_explicit(&p->keepalive_out, |
10172 | memory_order_relaxed)); | |
d62a17ae | 10173 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
10174 | atomic_load_explicit(&p->keepalive_in, |
10175 | memory_order_relaxed)); | |
d62a17ae | 10176 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
10177 | atomic_load_explicit(&p->refresh_out, |
10178 | memory_order_relaxed)); | |
d62a17ae | 10179 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
10180 | atomic_load_explicit(&p->refresh_in, |
10181 | memory_order_relaxed)); | |
d62a17ae | 10182 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
10183 | atomic_load_explicit(&p->dynamic_cap_out, |
10184 | memory_order_relaxed)); | |
d62a17ae | 10185 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
10186 | atomic_load_explicit(&p->dynamic_cap_in, |
10187 | memory_order_relaxed)); | |
10188 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
10189 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 10190 | json_object_object_add(json_neigh, "messageStats", json_stat); |
10191 | } else { | |
10192 | /* Packet counts. */ | |
10193 | vty_out(vty, " Message statistics:\n"); | |
10194 | vty_out(vty, " Inq depth is 0\n"); | |
10195 | vty_out(vty, " Outq depth is %lu\n", | |
10196 | (unsigned long)p->obuf->count); | |
10197 | vty_out(vty, " Sent Rcvd\n"); | |
0112e9e0 QY |
10198 | vty_out(vty, " Opens: %10d %10d\n", |
10199 | atomic_load_explicit(&p->open_out, | |
10200 | memory_order_relaxed), | |
10201 | atomic_load_explicit(&p->open_in, | |
10202 | memory_order_relaxed)); | |
10203 | vty_out(vty, " Notifications: %10d %10d\n", | |
10204 | atomic_load_explicit(&p->notify_out, | |
10205 | memory_order_relaxed), | |
10206 | atomic_load_explicit(&p->notify_in, | |
10207 | memory_order_relaxed)); | |
10208 | vty_out(vty, " Updates: %10d %10d\n", | |
10209 | atomic_load_explicit(&p->update_out, | |
10210 | memory_order_relaxed), | |
10211 | atomic_load_explicit(&p->update_in, | |
10212 | memory_order_relaxed)); | |
10213 | vty_out(vty, " Keepalives: %10d %10d\n", | |
10214 | atomic_load_explicit(&p->keepalive_out, | |
10215 | memory_order_relaxed), | |
10216 | atomic_load_explicit(&p->keepalive_in, | |
10217 | memory_order_relaxed)); | |
10218 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
10219 | atomic_load_explicit(&p->refresh_out, | |
10220 | memory_order_relaxed), | |
10221 | atomic_load_explicit(&p->refresh_in, | |
10222 | memory_order_relaxed)); | |
d62a17ae | 10223 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
10224 | atomic_load_explicit(&p->dynamic_cap_out, |
10225 | memory_order_relaxed), | |
10226 | atomic_load_explicit(&p->dynamic_cap_in, | |
10227 | memory_order_relaxed)); | |
10228 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
10229 | PEER_TOTAL_RX(p)); | |
d62a17ae | 10230 | } |
10231 | ||
10232 | if (use_json) { | |
10233 | /* advertisement-interval */ | |
10234 | json_object_int_add(json_neigh, | |
10235 | "minBtwnAdvertisementRunsTimerMsecs", | |
10236 | p->v_routeadv * 1000); | |
10237 | ||
10238 | /* Update-source. */ | |
10239 | if (p->update_if || p->update_source) { | |
10240 | if (p->update_if) | |
10241 | json_object_string_add(json_neigh, | |
10242 | "updateSource", | |
10243 | p->update_if); | |
10244 | else if (p->update_source) | |
10245 | json_object_string_add( | |
10246 | json_neigh, "updateSource", | |
10247 | sockunion2str(p->update_source, buf1, | |
10248 | SU_ADDRSTRLEN)); | |
10249 | } | |
10250 | } else { | |
10251 | /* advertisement-interval */ | |
10252 | vty_out(vty, | |
10253 | " Minimum time between advertisement runs is %d seconds\n", | |
10254 | p->v_routeadv); | |
10255 | ||
10256 | /* Update-source. */ | |
10257 | if (p->update_if || p->update_source) { | |
10258 | vty_out(vty, " Update source is "); | |
10259 | if (p->update_if) | |
10260 | vty_out(vty, "%s", p->update_if); | |
10261 | else if (p->update_source) | |
10262 | vty_out(vty, "%s", | |
10263 | sockunion2str(p->update_source, buf1, | |
10264 | SU_ADDRSTRLEN)); | |
10265 | vty_out(vty, "\n"); | |
10266 | } | |
10267 | ||
10268 | vty_out(vty, "\n"); | |
10269 | } | |
10270 | ||
10271 | /* Address Family Information */ | |
10272 | json_object *json_hold = NULL; | |
10273 | ||
10274 | if (use_json) | |
10275 | json_hold = json_object_new_object(); | |
10276 | ||
05c7a1cc QY |
10277 | FOREACH_AFI_SAFI (afi, safi) |
10278 | if (p->afc[afi][safi]) | |
10279 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
10280 | json_hold); | |
d62a17ae | 10281 | |
10282 | if (use_json) { | |
10283 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
10284 | json_hold); | |
10285 | json_object_int_add(json_neigh, "connectionsEstablished", | |
10286 | p->established); | |
10287 | json_object_int_add(json_neigh, "connectionsDropped", | |
10288 | p->dropped); | |
10289 | } else | |
10290 | vty_out(vty, " Connections established %d; dropped %d\n", | |
10291 | p->established, p->dropped); | |
10292 | ||
10293 | if (!p->last_reset) { | |
10294 | if (use_json) | |
10295 | json_object_string_add(json_neigh, "lastReset", | |
10296 | "never"); | |
10297 | else | |
10298 | vty_out(vty, " Last reset never\n"); | |
10299 | } else { | |
10300 | if (use_json) { | |
10301 | time_t uptime; | |
10302 | struct tm *tm; | |
10303 | ||
10304 | uptime = bgp_clock(); | |
10305 | uptime -= p->resettime; | |
10306 | tm = gmtime(&uptime); | |
10307 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
10308 | (tm->tm_sec * 1000) | |
10309 | + (tm->tm_min * 60000) | |
10310 | + (tm->tm_hour * 3600000)); | |
10311 | json_object_string_add( | |
10312 | json_neigh, "lastResetDueTo", | |
10313 | peer_down_str[(int)p->last_reset]); | |
10314 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10315 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10316 | char errorcodesubcode_hexstr[5]; | |
10317 | char errorcodesubcode_str[256]; | |
10318 | ||
10319 | code_str = bgp_notify_code_str(p->notify.code); | |
10320 | subcode_str = bgp_notify_subcode_str( | |
10321 | p->notify.code, p->notify.subcode); | |
10322 | ||
10323 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
10324 | p->notify.code, p->notify.subcode); | |
10325 | json_object_string_add(json_neigh, | |
10326 | "lastErrorCodeSubcode", | |
10327 | errorcodesubcode_hexstr); | |
10328 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10329 | code_str, subcode_str); | |
10330 | json_object_string_add(json_neigh, | |
10331 | "lastNotificationReason", | |
10332 | errorcodesubcode_str); | |
10333 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10334 | && p->notify.code == BGP_NOTIFY_CEASE | |
10335 | && (p->notify.subcode | |
10336 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10337 | || p->notify.subcode | |
10338 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10339 | && p->notify.length) { | |
10340 | char msgbuf[1024]; | |
10341 | const char *msg_str; | |
10342 | ||
10343 | msg_str = bgp_notify_admin_message( | |
10344 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10345 | (uint8_t *)p->notify.data, |
d62a17ae | 10346 | p->notify.length); |
10347 | if (msg_str) | |
10348 | json_object_string_add( | |
10349 | json_neigh, | |
10350 | "lastShutdownDescription", | |
10351 | msg_str); | |
10352 | } | |
10353 | } | |
10354 | } else { | |
10355 | vty_out(vty, " Last reset %s, ", | |
10356 | peer_uptime(p->resettime, timebuf, | |
10357 | BGP_UPTIME_LEN, 0, NULL)); | |
10358 | ||
10359 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10360 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10361 | code_str = bgp_notify_code_str(p->notify.code); | |
10362 | subcode_str = bgp_notify_subcode_str( | |
10363 | p->notify.code, p->notify.subcode); | |
10364 | vty_out(vty, "due to NOTIFICATION %s (%s%s)\n", | |
10365 | p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10366 | ? "sent" | |
10367 | : "received", | |
10368 | code_str, subcode_str); | |
10369 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10370 | && p->notify.code == BGP_NOTIFY_CEASE | |
10371 | && (p->notify.subcode | |
10372 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10373 | || p->notify.subcode | |
10374 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10375 | && p->notify.length) { | |
10376 | char msgbuf[1024]; | |
10377 | const char *msg_str; | |
10378 | ||
10379 | msg_str = bgp_notify_admin_message( | |
10380 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10381 | (uint8_t *)p->notify.data, |
d62a17ae | 10382 | p->notify.length); |
10383 | if (msg_str) | |
10384 | vty_out(vty, | |
10385 | " Message: \"%s\"\n", | |
10386 | msg_str); | |
10387 | } | |
10388 | } else { | |
10389 | vty_out(vty, "due to %s\n", | |
10390 | peer_down_str[(int)p->last_reset]); | |
10391 | } | |
10392 | ||
10393 | if (p->last_reset_cause_size) { | |
10394 | msg = p->last_reset_cause; | |
10395 | vty_out(vty, | |
10396 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
10397 | for (i = 1; i <= p->last_reset_cause_size; | |
10398 | i++) { | |
10399 | vty_out(vty, "%02X", *msg++); | |
10400 | ||
10401 | if (i != p->last_reset_cause_size) { | |
10402 | if (i % 16 == 0) { | |
10403 | vty_out(vty, "\n "); | |
10404 | } else if (i % 4 == 0) { | |
10405 | vty_out(vty, " "); | |
10406 | } | |
10407 | } | |
10408 | } | |
10409 | vty_out(vty, "\n"); | |
10410 | } | |
10411 | } | |
10412 | } | |
10413 | ||
10414 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
10415 | if (use_json) | |
10416 | json_object_boolean_true_add(json_neigh, | |
10417 | "prefixesConfigExceedMax"); | |
10418 | else | |
10419 | vty_out(vty, | |
10420 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
10421 | ||
10422 | if (p->t_pmax_restart) { | |
10423 | if (use_json) { | |
10424 | json_object_boolean_true_add( | |
10425 | json_neigh, "reducePrefixNumFrom"); | |
10426 | json_object_int_add(json_neigh, | |
10427 | "restartInTimerMsec", | |
10428 | thread_timer_remain_second( | |
10429 | p->t_pmax_restart) | |
10430 | * 1000); | |
10431 | } else | |
10432 | vty_out(vty, | |
10433 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
10434 | p->host, thread_timer_remain_second( |
10435 | p->t_pmax_restart)); | |
d62a17ae | 10436 | } else { |
10437 | if (use_json) | |
10438 | json_object_boolean_true_add( | |
10439 | json_neigh, | |
10440 | "reducePrefixNumAndClearIpBgp"); | |
10441 | else | |
10442 | vty_out(vty, | |
10443 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
10444 | p->host); | |
10445 | } | |
10446 | } | |
10447 | ||
10448 | /* EBGP Multihop and GTSM */ | |
10449 | if (p->sort != BGP_PEER_IBGP) { | |
10450 | if (use_json) { | |
10451 | if (p->gtsm_hops > 0) | |
10452 | json_object_int_add(json_neigh, | |
10453 | "externalBgpNbrMaxHopsAway", | |
10454 | p->gtsm_hops); | |
10455 | else if (p->ttl > 1) | |
10456 | json_object_int_add(json_neigh, | |
10457 | "externalBgpNbrMaxHopsAway", | |
10458 | p->ttl); | |
10459 | } else { | |
10460 | if (p->gtsm_hops > 0) | |
10461 | vty_out(vty, | |
10462 | " External BGP neighbor may be up to %d hops away.\n", | |
10463 | p->gtsm_hops); | |
10464 | else if (p->ttl > 1) | |
10465 | vty_out(vty, | |
10466 | " External BGP neighbor may be up to %d hops away.\n", | |
10467 | p->ttl); | |
10468 | } | |
10469 | } else { | |
10470 | if (p->gtsm_hops > 0) { | |
10471 | if (use_json) | |
10472 | json_object_int_add(json_neigh, | |
10473 | "internalBgpNbrMaxHopsAway", | |
10474 | p->gtsm_hops); | |
10475 | else | |
10476 | vty_out(vty, | |
10477 | " Internal BGP neighbor may be up to %d hops away.\n", | |
10478 | p->gtsm_hops); | |
10479 | } | |
10480 | } | |
10481 | ||
10482 | /* Local address. */ | |
10483 | if (p->su_local) { | |
10484 | if (use_json) { | |
10485 | json_object_string_add(json_neigh, "hostLocal", | |
10486 | sockunion2str(p->su_local, buf1, | |
10487 | SU_ADDRSTRLEN)); | |
10488 | json_object_int_add(json_neigh, "portLocal", | |
10489 | ntohs(p->su_local->sin.sin_port)); | |
10490 | } else | |
10491 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
10492 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
10493 | ntohs(p->su_local->sin.sin_port)); | |
10494 | } | |
10495 | ||
10496 | /* Remote address. */ | |
10497 | if (p->su_remote) { | |
10498 | if (use_json) { | |
10499 | json_object_string_add(json_neigh, "hostForeign", | |
10500 | sockunion2str(p->su_remote, buf1, | |
10501 | SU_ADDRSTRLEN)); | |
10502 | json_object_int_add(json_neigh, "portForeign", | |
10503 | ntohs(p->su_remote->sin.sin_port)); | |
10504 | } else | |
10505 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
10506 | sockunion2str(p->su_remote, buf1, | |
10507 | SU_ADDRSTRLEN), | |
10508 | ntohs(p->su_remote->sin.sin_port)); | |
10509 | } | |
10510 | ||
10511 | /* Nexthop display. */ | |
10512 | if (p->su_local) { | |
10513 | if (use_json) { | |
10514 | json_object_string_add(json_neigh, "nexthop", | |
10515 | inet_ntop(AF_INET, | |
10516 | &p->nexthop.v4, buf1, | |
10517 | sizeof(buf1))); | |
10518 | json_object_string_add(json_neigh, "nexthopGlobal", | |
10519 | inet_ntop(AF_INET6, | |
10520 | &p->nexthop.v6_global, | |
10521 | buf1, sizeof(buf1))); | |
10522 | json_object_string_add(json_neigh, "nexthopLocal", | |
10523 | inet_ntop(AF_INET6, | |
10524 | &p->nexthop.v6_local, | |
10525 | buf1, sizeof(buf1))); | |
10526 | if (p->shared_network) | |
10527 | json_object_string_add(json_neigh, | |
10528 | "bgpConnection", | |
10529 | "sharedNetwork"); | |
10530 | else | |
10531 | json_object_string_add(json_neigh, | |
10532 | "bgpConnection", | |
10533 | "nonSharedNetwork"); | |
10534 | } else { | |
10535 | vty_out(vty, "Nexthop: %s\n", | |
10536 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
10537 | sizeof(buf1))); | |
10538 | vty_out(vty, "Nexthop global: %s\n", | |
10539 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
10540 | sizeof(buf1))); | |
10541 | vty_out(vty, "Nexthop local: %s\n", | |
10542 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
10543 | sizeof(buf1))); | |
10544 | vty_out(vty, "BGP connection: %s\n", | |
10545 | p->shared_network ? "shared network" | |
10546 | : "non shared network"); | |
10547 | } | |
10548 | } | |
10549 | ||
10550 | /* Timer information. */ | |
10551 | if (use_json) { | |
10552 | json_object_int_add(json_neigh, "connectRetryTimer", | |
10553 | p->v_connect); | |
10554 | if (p->status == Established && p->rtt) | |
10555 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
10556 | p->rtt); | |
10557 | if (p->t_start) | |
10558 | json_object_int_add( | |
10559 | json_neigh, "nextStartTimerDueInMsecs", | |
10560 | thread_timer_remain_second(p->t_start) * 1000); | |
10561 | if (p->t_connect) | |
10562 | json_object_int_add( | |
10563 | json_neigh, "nextConnectTimerDueInMsecs", | |
10564 | thread_timer_remain_second(p->t_connect) | |
10565 | * 1000); | |
10566 | if (p->t_routeadv) { | |
10567 | json_object_int_add(json_neigh, "mraiInterval", | |
10568 | p->v_routeadv); | |
10569 | json_object_int_add( | |
10570 | json_neigh, "mraiTimerExpireInMsecs", | |
10571 | thread_timer_remain_second(p->t_routeadv) | |
10572 | * 1000); | |
10573 | } | |
10574 | if (p->password) | |
10575 | json_object_int_add(json_neigh, "authenticationEnabled", | |
10576 | 1); | |
10577 | ||
10578 | if (p->t_read) | |
10579 | json_object_string_add(json_neigh, "readThread", "on"); | |
10580 | else | |
10581 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
10582 | |
10583 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 10584 | json_object_string_add(json_neigh, "writeThread", "on"); |
10585 | else | |
10586 | json_object_string_add(json_neigh, "writeThread", | |
10587 | "off"); | |
10588 | } else { | |
10589 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
10590 | p->v_connect); | |
10591 | if (p->status == Established && p->rtt) | |
10592 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
10593 | p->rtt); | |
10594 | if (p->t_start) | |
10595 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
10596 | thread_timer_remain_second(p->t_start)); | |
10597 | if (p->t_connect) | |
10598 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
10599 | thread_timer_remain_second(p->t_connect)); | |
10600 | if (p->t_routeadv) | |
10601 | vty_out(vty, | |
10602 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
10603 | p->v_routeadv, | |
10604 | thread_timer_remain_second(p->t_routeadv)); | |
10605 | if (p->password) | |
10606 | vty_out(vty, "Peer Authentication Enabled\n"); | |
10607 | ||
10608 | vty_out(vty, "Read thread: %s Write thread: %s\n", | |
49507a6f QY |
10609 | p->t_read ? "on" : "off", |
10610 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
10611 | ? "on" | |
10612 | : "off"); | |
d62a17ae | 10613 | } |
10614 | ||
10615 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
10616 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
10617 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
10618 | ||
10619 | if (!use_json) | |
10620 | vty_out(vty, "\n"); | |
10621 | ||
10622 | /* BFD information. */ | |
10623 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
10624 | ||
10625 | if (use_json) { | |
10626 | if (p->conf_if) /* Configured interface name. */ | |
10627 | json_object_object_add(json, p->conf_if, json_neigh); | |
10628 | else /* Configured IP address. */ | |
10629 | json_object_object_add(json, p->host, json_neigh); | |
10630 | } | |
10631 | } | |
10632 | ||
10633 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, | |
10634 | enum show_type type, union sockunion *su, | |
d7c0a89a | 10635 | const char *conf_if, uint8_t use_json, |
d62a17ae | 10636 | json_object *json) |
10637 | { | |
10638 | struct listnode *node, *nnode; | |
10639 | struct peer *peer; | |
10640 | int find = 0; | |
10641 | ||
10642 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
10643 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10644 | continue; | |
10645 | ||
10646 | switch (type) { | |
10647 | case show_all: | |
10648 | bgp_show_peer(vty, peer, use_json, json); | |
10649 | break; | |
10650 | case show_peer: | |
10651 | if (conf_if) { | |
10652 | if ((peer->conf_if | |
10653 | && !strcmp(peer->conf_if, conf_if)) | |
10654 | || (peer->hostname | |
10655 | && !strcmp(peer->hostname, conf_if))) { | |
10656 | find = 1; | |
10657 | bgp_show_peer(vty, peer, use_json, | |
10658 | json); | |
10659 | } | |
10660 | } else { | |
10661 | if (sockunion_same(&peer->su, su)) { | |
10662 | find = 1; | |
10663 | bgp_show_peer(vty, peer, use_json, | |
10664 | json); | |
10665 | } | |
10666 | } | |
10667 | break; | |
10668 | } | |
10669 | } | |
10670 | ||
10671 | if (type == show_peer && !find) { | |
10672 | if (use_json) | |
10673 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
10674 | else | |
88b7d255 | 10675 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 10676 | } |
10677 | ||
10678 | if (use_json) { | |
996c9314 LB |
10679 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
10680 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 10681 | json_object_free(json); |
10682 | } else { | |
10683 | vty_out(vty, "\n"); | |
10684 | } | |
10685 | ||
10686 | return CMD_SUCCESS; | |
10687 | } | |
10688 | ||
10689 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, | |
71aedaa3 DS |
10690 | enum show_type type, |
10691 | const char *ip_str, | |
d7c0a89a | 10692 | uint8_t use_json) |
d62a17ae | 10693 | { |
0291c246 MK |
10694 | struct listnode *node, *nnode; |
10695 | struct bgp *bgp; | |
71aedaa3 | 10696 | union sockunion su; |
0291c246 | 10697 | json_object *json = NULL; |
71aedaa3 | 10698 | int ret, is_first = 1; |
d62a17ae | 10699 | |
10700 | if (use_json) | |
10701 | vty_out(vty, "{\n"); | |
10702 | ||
10703 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
10704 | if (use_json) { | |
10705 | if (!(json = json_object_new_object())) { | |
10706 | zlog_err( | |
10707 | "Unable to allocate memory for JSON object"); | |
10708 | vty_out(vty, | |
10709 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
10710 | return; | |
10711 | } | |
10712 | ||
10713 | json_object_int_add(json, "vrfId", | |
10714 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
10715 | ? -1 |
10716 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 10717 | json_object_string_add( |
10718 | json, "vrfName", | |
10719 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
10720 | ? "Default" | |
10721 | : bgp->name); | |
10722 | ||
10723 | if (!is_first) | |
10724 | vty_out(vty, ",\n"); | |
10725 | else | |
10726 | is_first = 0; | |
10727 | ||
10728 | vty_out(vty, "\"%s\":", | |
10729 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
10730 | ? "Default" | |
10731 | : bgp->name); | |
10732 | } else { | |
10733 | vty_out(vty, "\nInstance %s:\n", | |
10734 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
10735 | ? "Default" | |
10736 | : bgp->name); | |
10737 | } | |
71aedaa3 DS |
10738 | |
10739 | if (type == show_peer) { | |
10740 | ret = str2sockunion(ip_str, &su); | |
10741 | if (ret < 0) | |
10742 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
10743 | use_json, json); | |
10744 | else | |
10745 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
10746 | use_json, json); | |
10747 | } else { | |
10748 | bgp_show_neighbor(vty, bgp, show_all, NULL, NULL, | |
10749 | use_json, json); | |
10750 | } | |
d62a17ae | 10751 | } |
10752 | ||
10753 | if (use_json) | |
10754 | vty_out(vty, "}\n"); | |
10755 | } | |
10756 | ||
10757 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
10758 | enum show_type type, const char *ip_str, | |
d7c0a89a | 10759 | uint8_t use_json) |
d62a17ae | 10760 | { |
10761 | int ret; | |
10762 | struct bgp *bgp; | |
10763 | union sockunion su; | |
10764 | json_object *json = NULL; | |
10765 | ||
10766 | if (name) { | |
10767 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
10768 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
10769 | use_json); | |
d62a17ae | 10770 | return CMD_SUCCESS; |
10771 | } else { | |
10772 | bgp = bgp_lookup_by_name(name); | |
10773 | if (!bgp) { | |
10774 | if (use_json) { | |
10775 | json = json_object_new_object(); | |
10776 | json_object_boolean_true_add( | |
10777 | json, "bgpNoSuchInstance"); | |
10778 | vty_out(vty, "%s\n", | |
10779 | json_object_to_json_string_ext( | |
10780 | json, | |
10781 | JSON_C_TO_STRING_PRETTY)); | |
10782 | json_object_free(json); | |
10783 | } else | |
10784 | vty_out(vty, | |
10785 | "%% No such BGP instance exist\n"); | |
10786 | ||
10787 | return CMD_WARNING; | |
10788 | } | |
10789 | } | |
10790 | } else { | |
10791 | bgp = bgp_get_default(); | |
10792 | } | |
10793 | ||
10794 | if (bgp) { | |
10795 | json = json_object_new_object(); | |
10796 | if (ip_str) { | |
10797 | ret = str2sockunion(ip_str, &su); | |
10798 | if (ret < 0) | |
10799 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
10800 | use_json, json); | |
10801 | else | |
10802 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
10803 | use_json, json); | |
10804 | } else { | |
10805 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
10806 | json); | |
10807 | } | |
10808 | json_object_free(json); | |
10809 | } | |
10810 | ||
10811 | return CMD_SUCCESS; | |
4fb25c53 DW |
10812 | } |
10813 | ||
716b2d8a | 10814 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 10815 | DEFUN (show_ip_bgp_neighbors, |
10816 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 10817 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 10818 | SHOW_STR |
10819 | IP_STR | |
10820 | BGP_STR | |
f2a8972b | 10821 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
10822 | "Address Family\n" |
10823 | "Address Family\n" | |
718e3744 | 10824 | "Detailed information on TCP and BGP neighbor connections\n" |
10825 | "Neighbor to display information about\n" | |
a80beece | 10826 | "Neighbor to display information about\n" |
91d37724 | 10827 | "Neighbor on BGP configured interface\n" |
9973d184 | 10828 | JSON_STR) |
718e3744 | 10829 | { |
d62a17ae | 10830 | char *vrf = NULL; |
10831 | char *sh_arg = NULL; | |
10832 | enum show_type sh_type; | |
718e3744 | 10833 | |
d7c0a89a | 10834 | uint8_t uj = use_json(argc, argv); |
718e3744 | 10835 | |
d62a17ae | 10836 | int idx = 0; |
718e3744 | 10837 | |
d62a17ae | 10838 | if (argv_find(argv, argc, "view", &idx) |
10839 | || argv_find(argv, argc, "vrf", &idx)) | |
10840 | vrf = argv[idx + 1]->arg; | |
718e3744 | 10841 | |
d62a17ae | 10842 | idx++; |
10843 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
10844 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
10845 | || argv_find(argv, argc, "WORD", &idx)) { | |
10846 | sh_type = show_peer; | |
10847 | sh_arg = argv[idx]->arg; | |
10848 | } else | |
10849 | sh_type = show_all; | |
856ca177 | 10850 | |
d62a17ae | 10851 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 10852 | } |
10853 | ||
716b2d8a | 10854 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 10855 | paths' and `show ip mbgp paths'. Those functions results are the |
10856 | same.*/ | |
f412b39a | 10857 | DEFUN (show_ip_bgp_paths, |
718e3744 | 10858 | show_ip_bgp_paths_cmd, |
46f296b4 | 10859 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 10860 | SHOW_STR |
10861 | IP_STR | |
10862 | BGP_STR | |
46f296b4 | 10863 | BGP_SAFI_HELP_STR |
718e3744 | 10864 | "Path information\n") |
10865 | { | |
d62a17ae | 10866 | vty_out(vty, "Address Refcnt Path\n"); |
10867 | aspath_print_all_vty(vty); | |
10868 | return CMD_SUCCESS; | |
718e3744 | 10869 | } |
10870 | ||
718e3744 | 10871 | #include "hash.h" |
10872 | ||
d62a17ae | 10873 | static void community_show_all_iterator(struct hash_backet *backet, |
10874 | struct vty *vty) | |
718e3744 | 10875 | { |
d62a17ae | 10876 | struct community *com; |
718e3744 | 10877 | |
d62a17ae | 10878 | com = (struct community *)backet->data; |
3f65c5b1 | 10879 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 10880 | community_str(com, false)); |
718e3744 | 10881 | } |
10882 | ||
10883 | /* Show BGP's community internal data. */ | |
f412b39a | 10884 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 10885 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 10886 | "show [ip] bgp community-info", |
718e3744 | 10887 | SHOW_STR |
10888 | IP_STR | |
10889 | BGP_STR | |
10890 | "List all bgp community information\n") | |
10891 | { | |
d62a17ae | 10892 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 10893 | |
d62a17ae | 10894 | hash_iterate(community_hash(), |
10895 | (void (*)(struct hash_backet *, | |
10896 | void *))community_show_all_iterator, | |
10897 | vty); | |
718e3744 | 10898 | |
d62a17ae | 10899 | return CMD_SUCCESS; |
718e3744 | 10900 | } |
10901 | ||
d62a17ae | 10902 | static void lcommunity_show_all_iterator(struct hash_backet *backet, |
10903 | struct vty *vty) | |
57d187bc | 10904 | { |
d62a17ae | 10905 | struct lcommunity *lcom; |
57d187bc | 10906 | |
d62a17ae | 10907 | lcom = (struct lcommunity *)backet->data; |
3f65c5b1 | 10908 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 10909 | lcommunity_str(lcom, false)); |
57d187bc JS |
10910 | } |
10911 | ||
10912 | /* Show BGP's community internal data. */ | |
10913 | DEFUN (show_ip_bgp_lcommunity_info, | |
10914 | show_ip_bgp_lcommunity_info_cmd, | |
10915 | "show ip bgp large-community-info", | |
10916 | SHOW_STR | |
10917 | IP_STR | |
10918 | BGP_STR | |
10919 | "List all bgp large-community information\n") | |
10920 | { | |
d62a17ae | 10921 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 10922 | |
d62a17ae | 10923 | hash_iterate(lcommunity_hash(), |
10924 | (void (*)(struct hash_backet *, | |
10925 | void *))lcommunity_show_all_iterator, | |
10926 | vty); | |
57d187bc | 10927 | |
d62a17ae | 10928 | return CMD_SUCCESS; |
57d187bc JS |
10929 | } |
10930 | ||
10931 | ||
f412b39a | 10932 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 10933 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 10934 | "show [ip] bgp attribute-info", |
718e3744 | 10935 | SHOW_STR |
10936 | IP_STR | |
10937 | BGP_STR | |
10938 | "List all bgp attribute information\n") | |
10939 | { | |
d62a17ae | 10940 | attr_show_all(vty); |
10941 | return CMD_SUCCESS; | |
718e3744 | 10942 | } |
6b0655a2 | 10943 | |
53089bec | 10944 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
10945 | afi_t afi, safi_t safi) | |
10946 | { | |
10947 | struct bgp *bgp; | |
10948 | struct listnode *node; | |
10949 | char *vname; | |
10950 | char buf1[INET6_ADDRSTRLEN]; | |
10951 | char *ecom_str; | |
10952 | vpn_policy_direction_t dir; | |
10953 | ||
10954 | if (name) { | |
10955 | bgp = bgp_lookup_by_name(name); | |
10956 | if (!bgp) { | |
10957 | vty_out(vty, "%% No such BGP instance exist\n"); | |
10958 | return CMD_WARNING; | |
10959 | } | |
10960 | } else { | |
10961 | bgp = bgp_get_default(); | |
10962 | if (!bgp) { | |
020a3f60 DS |
10963 | vty_out(vty, |
10964 | "%% Default BGP instance does not exist\n"); | |
53089bec | 10965 | return CMD_WARNING; |
10966 | } | |
10967 | } | |
10968 | ||
10969 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
10970 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
020a3f60 DS |
10971 | vty_out(vty, |
10972 | "This VRF is not importing %s routes from any other VRF\n", | |
53089bec | 10973 | afi_safi_print(afi, safi)); |
10974 | } else { | |
020a3f60 DS |
10975 | vty_out(vty, |
10976 | "This VRF is importing %s routes from the following VRFs:\n", | |
53089bec | 10977 | afi_safi_print(afi, safi)); |
10978 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, | |
10979 | vname)) { | |
10980 | vty_out(vty, " %s\n", vname); | |
10981 | } | |
10982 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
10983 | ecom_str = ecommunity_ecom2str( | |
10984 | bgp->vpn_policy[afi].rtlist[dir], | |
10985 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
10986 | vty_out(vty, "Import RT(s): %s\n", ecom_str); | |
10987 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
10988 | } | |
10989 | ||
10990 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
10991 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
020a3f60 DS |
10992 | vty_out(vty, |
10993 | "This VRF is not exporting %s routes to any other VRF\n", | |
53089bec | 10994 | afi_safi_print(afi, safi)); |
10995 | } else { | |
020a3f60 DS |
10996 | vty_out(vty, |
10997 | "This VRF is exporting %s routes to the following VRFs:\n", | |
53089bec | 10998 | afi_safi_print(afi, safi)); |
10999 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].export_vrf, node, | |
11000 | vname)) { | |
11001 | vty_out(vty, " %s\n", vname); | |
11002 | } | |
11003 | vty_out(vty, "RD: %s\n", | |
11004 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11005 | buf1, RD_ADDRSTRLEN)); | |
11006 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
11007 | ecom_str = ecommunity_ecom2str( | |
11008 | bgp->vpn_policy[afi].rtlist[dir], | |
11009 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11010 | vty_out(vty, "Emport RT: %s\n", ecom_str); | |
11011 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11012 | } | |
11013 | ||
11014 | return CMD_SUCCESS; | |
11015 | } | |
11016 | ||
11017 | /* "show [ip] bgp route-leak" command. */ | |
11018 | DEFUN (show_ip_bgp_route_leak, | |
11019 | show_ip_bgp_route_leak_cmd, | |
11020 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak", | |
11021 | SHOW_STR | |
11022 | IP_STR | |
11023 | BGP_STR | |
11024 | BGP_INSTANCE_HELP_STR | |
11025 | BGP_AFI_HELP_STR | |
11026 | BGP_SAFI_HELP_STR | |
11027 | "Route leaking information\n") | |
11028 | { | |
11029 | char *vrf = NULL; | |
11030 | afi_t afi = AFI_MAX; | |
11031 | safi_t safi = SAFI_MAX; | |
11032 | ||
11033 | int idx = 0; | |
11034 | ||
11035 | /* show [ip] bgp */ | |
11036 | if (argv_find(argv, argc, "ip", &idx)) { | |
11037 | afi = AFI_IP; | |
11038 | safi = SAFI_UNICAST; | |
11039 | } | |
11040 | /* [vrf VIEWVRFNAME] */ | |
11041 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
11042 | vty_out(vty, |
11043 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 11044 | return CMD_WARNING; |
11045 | } | |
11046 | ||
11047 | if (argv_find(argv, argc, "vrf", &idx)) | |
11048 | vrf = argv[++idx]->arg; | |
11049 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
11050 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11051 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11052 | } | |
11053 | ||
11054 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
11055 | vty_out(vty, |
11056 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 11057 | return CMD_WARNING; |
11058 | } | |
11059 | ||
11060 | return bgp_show_route_leak_vty(vty, vrf, afi, safi); | |
11061 | } | |
11062 | ||
d62a17ae | 11063 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
11064 | safi_t safi) | |
f186de26 | 11065 | { |
d62a17ae | 11066 | struct listnode *node, *nnode; |
11067 | struct bgp *bgp; | |
f186de26 | 11068 | |
d62a17ae | 11069 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
11070 | vty_out(vty, "\nInstance %s:\n", | |
11071 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
11072 | ? "Default" | |
11073 | : bgp->name); | |
11074 | update_group_show(bgp, afi, safi, vty, 0); | |
11075 | } | |
f186de26 | 11076 | } |
11077 | ||
d62a17ae | 11078 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
11079 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 11080 | { |
d62a17ae | 11081 | struct bgp *bgp; |
4fb25c53 | 11082 | |
d62a17ae | 11083 | if (name) { |
11084 | if (strmatch(name, "all")) { | |
11085 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
11086 | return CMD_SUCCESS; | |
11087 | } else { | |
11088 | bgp = bgp_lookup_by_name(name); | |
11089 | } | |
11090 | } else { | |
11091 | bgp = bgp_get_default(); | |
11092 | } | |
4fb25c53 | 11093 | |
d62a17ae | 11094 | if (bgp) |
11095 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
11096 | return CMD_SUCCESS; | |
4fb25c53 DW |
11097 | } |
11098 | ||
8fe8a7f6 DS |
11099 | DEFUN (show_ip_bgp_updgrps, |
11100 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 11101 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 11102 | SHOW_STR |
11103 | IP_STR | |
11104 | BGP_STR | |
11105 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 11106 | BGP_AFI_HELP_STR |
9bedbb1e | 11107 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
11108 | "Detailed info about dynamic update groups\n" |
11109 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 11110 | { |
d62a17ae | 11111 | char *vrf = NULL; |
11112 | afi_t afi = AFI_IP6; | |
11113 | safi_t safi = SAFI_UNICAST; | |
11114 | uint64_t subgrp_id = 0; | |
11115 | ||
11116 | int idx = 0; | |
11117 | ||
11118 | /* show [ip] bgp */ | |
11119 | if (argv_find(argv, argc, "ip", &idx)) | |
11120 | afi = AFI_IP; | |
11121 | /* [<view|vrf> VIEWVRFNAME] */ | |
11122 | if (argv_find(argv, argc, "view", &idx) | |
11123 | || argv_find(argv, argc, "vrf", &idx)) | |
11124 | vrf = argv[++idx]->arg; | |
11125 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
11126 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11127 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11128 | } | |
5bf15956 | 11129 | |
d62a17ae | 11130 | /* get subgroup id, if provided */ |
11131 | idx = argc - 1; | |
11132 | if (argv[idx]->type == VARIABLE_TKN) | |
11133 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 11134 | |
d62a17ae | 11135 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
11136 | } |
11137 | ||
f186de26 | 11138 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
11139 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 11140 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 11141 | SHOW_STR |
716b2d8a | 11142 | IP_STR |
f186de26 | 11143 | BGP_STR |
11144 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 11145 | "Detailed info about dynamic update groups\n") |
f186de26 | 11146 | { |
d62a17ae | 11147 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
11148 | return CMD_SUCCESS; | |
f186de26 | 11149 | } |
11150 | ||
5bf15956 DW |
11151 | DEFUN (show_bgp_updgrps_stats, |
11152 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 11153 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 11154 | SHOW_STR |
716b2d8a | 11155 | IP_STR |
3f9c7369 | 11156 | BGP_STR |
0c7b1b01 | 11157 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
11158 | "Statistics\n") |
11159 | { | |
d62a17ae | 11160 | struct bgp *bgp; |
3f9c7369 | 11161 | |
d62a17ae | 11162 | bgp = bgp_get_default(); |
11163 | if (bgp) | |
11164 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 11165 | |
d62a17ae | 11166 | return CMD_SUCCESS; |
3f9c7369 DS |
11167 | } |
11168 | ||
8386ac43 | 11169 | DEFUN (show_bgp_instance_updgrps_stats, |
11170 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 11171 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 11172 | SHOW_STR |
716b2d8a | 11173 | IP_STR |
8386ac43 | 11174 | BGP_STR |
11175 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 11176 | "Detailed info about dynamic update groups\n" |
8386ac43 | 11177 | "Statistics\n") |
11178 | { | |
d62a17ae | 11179 | int idx_word = 3; |
11180 | struct bgp *bgp; | |
8386ac43 | 11181 | |
d62a17ae | 11182 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
11183 | if (bgp) | |
11184 | update_group_show_stats(bgp, vty); | |
8386ac43 | 11185 | |
d62a17ae | 11186 | return CMD_SUCCESS; |
8386ac43 | 11187 | } |
11188 | ||
d62a17ae | 11189 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
11190 | afi_t afi, safi_t safi, | |
11191 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 11192 | { |
d62a17ae | 11193 | struct bgp *bgp; |
8386ac43 | 11194 | |
d62a17ae | 11195 | if (name) |
11196 | bgp = bgp_lookup_by_name(name); | |
11197 | else | |
11198 | bgp = bgp_get_default(); | |
8386ac43 | 11199 | |
d62a17ae | 11200 | if (bgp) { |
11201 | if (!strcmp(what, "advertise-queue")) | |
11202 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
11203 | subgrp_id); | |
11204 | else if (!strcmp(what, "advertised-routes")) | |
11205 | update_group_show_advertised(bgp, afi, safi, vty, | |
11206 | subgrp_id); | |
11207 | else if (!strcmp(what, "packet-queue")) | |
11208 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
11209 | subgrp_id); | |
11210 | } | |
3f9c7369 DS |
11211 | } |
11212 | ||
dc64bdec QY |
11213 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
11214 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
11215 | "show [ip]$ip bgp [<view|vrf> VIEWVRFNAME$vrf] [<ipv4|ipv6>$afi <unicast|multicast|vpn>$safi] update-groups [SUBGROUP-ID]$sgid <advertise-queue|advertised-routes|packet-queue>$rtq", | |
11216 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
11217 | BGP_SAFI_HELP_STR | |
11218 | "Detailed info about dynamic update groups\n" | |
11219 | "Specific subgroup to display info for\n" | |
11220 | "Advertisement queue\n" | |
11221 | "Announced routes\n" | |
11222 | "Packet queue\n") | |
3f9c7369 | 11223 | { |
dc64bdec QY |
11224 | uint64_t subgrp_id = 0; |
11225 | afi_t afiz; | |
11226 | safi_t safiz; | |
11227 | if (sgid) | |
11228 | subgrp_id = strtoull(sgid, NULL, 10); | |
11229 | ||
11230 | if (!ip && !afi) | |
11231 | afiz = AFI_IP6; | |
11232 | if (!ip && afi) | |
11233 | afiz = bgp_vty_afi_from_str(afi); | |
11234 | if (ip && !afi) | |
11235 | afiz = AFI_IP; | |
11236 | if (ip && afi) { | |
11237 | afiz = bgp_vty_afi_from_str(afi); | |
11238 | if (afiz != AFI_IP) | |
11239 | vty_out(vty, | |
11240 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
11241 | return CMD_WARNING; | |
11242 | } | |
d62a17ae | 11243 | |
dc64bdec | 11244 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 11245 | |
dc64bdec | 11246 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 11247 | return CMD_SUCCESS; |
11248 | } | |
11249 | ||
d62a17ae | 11250 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
11251 | { | |
11252 | struct listnode *node, *nnode; | |
11253 | struct prefix *range; | |
11254 | struct peer *conf; | |
11255 | struct peer *peer; | |
11256 | char buf[PREFIX2STR_BUFFER]; | |
11257 | afi_t afi; | |
11258 | safi_t safi; | |
11259 | const char *peer_status; | |
11260 | const char *af_str; | |
11261 | int lr_count; | |
11262 | int dynamic; | |
11263 | int af_cfgd; | |
11264 | ||
11265 | conf = group->conf; | |
11266 | ||
11267 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
11268 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
11269 | conf->as); | |
11270 | } else if (conf->as_type == AS_INTERNAL) { | |
11271 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
11272 | group->bgp->as); | |
11273 | } else { | |
11274 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
11275 | } | |
f14e6fdb | 11276 | |
d62a17ae | 11277 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
11278 | vty_out(vty, " Peer-group type is internal\n"); | |
11279 | else | |
11280 | vty_out(vty, " Peer-group type is external\n"); | |
11281 | ||
11282 | /* Display AFs configured. */ | |
11283 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
11284 | FOREACH_AFI_SAFI (afi, safi) { |
11285 | if (conf->afc[afi][safi]) { | |
11286 | af_cfgd = 1; | |
11287 | vty_out(vty, " %s;", afi_safi_print(afi, safi)); | |
d62a17ae | 11288 | } |
05c7a1cc | 11289 | } |
d62a17ae | 11290 | if (!af_cfgd) |
11291 | vty_out(vty, " none\n"); | |
11292 | else | |
11293 | vty_out(vty, "\n"); | |
11294 | ||
11295 | /* Display listen ranges (for dynamic neighbors), if any */ | |
11296 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
11297 | if (afi == AFI_IP) | |
11298 | af_str = "IPv4"; | |
11299 | else if (afi == AFI_IP6) | |
11300 | af_str = "IPv6"; | |
11301 | else | |
11302 | af_str = "???"; | |
11303 | lr_count = listcount(group->listen_range[afi]); | |
11304 | if (lr_count) { | |
11305 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
11306 | af_str); | |
11307 | ||
11308 | ||
11309 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
11310 | nnode, range)) { | |
11311 | prefix2str(range, buf, sizeof(buf)); | |
11312 | vty_out(vty, " %s\n", buf); | |
11313 | } | |
11314 | } | |
11315 | } | |
f14e6fdb | 11316 | |
d62a17ae | 11317 | /* Display group members and their status */ |
11318 | if (listcount(group->peer)) { | |
11319 | vty_out(vty, " Peer-group members:\n"); | |
11320 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
11321 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
11322 | peer_status = "Idle (Admin)"; | |
11323 | else if (CHECK_FLAG(peer->sflags, | |
11324 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11325 | peer_status = "Idle (PfxCt)"; | |
11326 | else | |
11327 | peer_status = lookup_msg(bgp_status_msg, | |
11328 | peer->status, NULL); | |
11329 | ||
11330 | dynamic = peer_dynamic_neighbor(peer); | |
11331 | vty_out(vty, " %s %s %s \n", peer->host, | |
11332 | dynamic ? "(dynamic)" : "", peer_status); | |
11333 | } | |
11334 | } | |
f14e6fdb | 11335 | |
d62a17ae | 11336 | return CMD_SUCCESS; |
11337 | } | |
11338 | ||
ff9959b0 QY |
11339 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
11340 | const char *group_name) | |
d62a17ae | 11341 | { |
ff9959b0 | 11342 | struct bgp *bgp; |
d62a17ae | 11343 | struct listnode *node, *nnode; |
11344 | struct peer_group *group; | |
ff9959b0 QY |
11345 | bool found = false; |
11346 | ||
11347 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
11348 | ||
11349 | if (!bgp) { | |
11350 | vty_out(vty, "%% No such BGP instance exists\n"); | |
11351 | return CMD_WARNING; | |
11352 | } | |
d62a17ae | 11353 | |
11354 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
11355 | if (group_name) { |
11356 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 11357 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
11358 | found = true; |
11359 | break; | |
d62a17ae | 11360 | } |
ff9959b0 QY |
11361 | } else { |
11362 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 11363 | } |
f14e6fdb | 11364 | } |
f14e6fdb | 11365 | |
ff9959b0 | 11366 | if (group_name && !found) |
d62a17ae | 11367 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 11368 | |
d62a17ae | 11369 | return CMD_SUCCESS; |
f14e6fdb DS |
11370 | } |
11371 | ||
f14e6fdb DS |
11372 | DEFUN (show_ip_bgp_peer_groups, |
11373 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 11374 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
11375 | SHOW_STR |
11376 | IP_STR | |
11377 | BGP_STR | |
8386ac43 | 11378 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
11379 | "Detailed information on BGP peer groups\n" |
11380 | "Peer group name\n") | |
f14e6fdb | 11381 | { |
d62a17ae | 11382 | char *vrf, *pg; |
11383 | vrf = pg = NULL; | |
11384 | int idx = 0; | |
f14e6fdb | 11385 | |
a4d82a8a PZ |
11386 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
11387 | : NULL; | |
d62a17ae | 11388 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 11389 | |
ff9959b0 | 11390 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 11391 | } |
3f9c7369 | 11392 | |
d6e3c605 | 11393 | |
718e3744 | 11394 | /* Redistribute VTY commands. */ |
11395 | ||
718e3744 | 11396 | DEFUN (bgp_redistribute_ipv4, |
11397 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 11398 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 11399 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11400 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 11401 | { |
d62a17ae | 11402 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11403 | int idx_protocol = 1; | |
11404 | int type; | |
718e3744 | 11405 | |
d62a17ae | 11406 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
11407 | if (type < 0) { | |
11408 | vty_out(vty, "%% Invalid route type\n"); | |
11409 | return CMD_WARNING_CONFIG_FAILED; | |
11410 | } | |
7f323236 | 11411 | |
d62a17ae | 11412 | bgp_redist_add(bgp, AFI_IP, type, 0); |
11413 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
718e3744 | 11414 | } |
11415 | ||
d62a17ae | 11416 | ALIAS_HIDDEN( |
11417 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
11418 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
11419 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 11420 | |
718e3744 | 11421 | DEFUN (bgp_redistribute_ipv4_rmap, |
11422 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 11423 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 11424 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11425 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11426 | "Route map reference\n" |
11427 | "Pointer to route-map entries\n") | |
11428 | { | |
d62a17ae | 11429 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11430 | int idx_protocol = 1; | |
11431 | int idx_word = 3; | |
11432 | int type; | |
11433 | struct bgp_redist *red; | |
718e3744 | 11434 | |
d62a17ae | 11435 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
11436 | if (type < 0) { | |
11437 | vty_out(vty, "%% Invalid route type\n"); | |
11438 | return CMD_WARNING_CONFIG_FAILED; | |
11439 | } | |
718e3744 | 11440 | |
d62a17ae | 11441 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
11442 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11443 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
718e3744 | 11444 | } |
11445 | ||
d62a17ae | 11446 | ALIAS_HIDDEN( |
11447 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
11448 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
11449 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11450 | "Route map reference\n" | |
11451 | "Pointer to route-map entries\n") | |
596c17ba | 11452 | |
718e3744 | 11453 | DEFUN (bgp_redistribute_ipv4_metric, |
11454 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 11455 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 11456 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11457 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11458 | "Metric for redistributed routes\n" |
11459 | "Default metric\n") | |
11460 | { | |
d62a17ae | 11461 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11462 | int idx_protocol = 1; | |
11463 | int idx_number = 3; | |
11464 | int type; | |
d7c0a89a | 11465 | uint32_t metric; |
d62a17ae | 11466 | struct bgp_redist *red; |
11467 | ||
11468 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11469 | if (type < 0) { | |
11470 | vty_out(vty, "%% Invalid route type\n"); | |
11471 | return CMD_WARNING_CONFIG_FAILED; | |
11472 | } | |
11473 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11474 | ||
11475 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
11476 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
11477 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
11478 | } | |
11479 | ||
11480 | ALIAS_HIDDEN( | |
11481 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
11482 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
11483 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11484 | "Metric for redistributed routes\n" | |
11485 | "Default metric\n") | |
596c17ba | 11486 | |
718e3744 | 11487 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
11488 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 11489 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 11490 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11491 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11492 | "Route map reference\n" |
11493 | "Pointer to route-map entries\n" | |
11494 | "Metric for redistributed routes\n" | |
11495 | "Default metric\n") | |
11496 | { | |
d62a17ae | 11497 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11498 | int idx_protocol = 1; | |
11499 | int idx_word = 3; | |
11500 | int idx_number = 5; | |
11501 | int type; | |
d7c0a89a | 11502 | uint32_t metric; |
d62a17ae | 11503 | struct bgp_redist *red; |
11504 | ||
11505 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11506 | if (type < 0) { | |
11507 | vty_out(vty, "%% Invalid route type\n"); | |
11508 | return CMD_WARNING_CONFIG_FAILED; | |
11509 | } | |
11510 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11511 | ||
11512 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
11513 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11514 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
11515 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
11516 | } | |
11517 | ||
11518 | ALIAS_HIDDEN( | |
11519 | bgp_redistribute_ipv4_rmap_metric, | |
11520 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
11521 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
11522 | " route-map WORD metric (0-4294967295)", | |
11523 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11524 | "Route map reference\n" | |
11525 | "Pointer to route-map entries\n" | |
11526 | "Metric for redistributed routes\n" | |
11527 | "Default metric\n") | |
596c17ba | 11528 | |
718e3744 | 11529 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
11530 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 11531 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 11532 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11533 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11534 | "Metric for redistributed routes\n" |
11535 | "Default metric\n" | |
11536 | "Route map reference\n" | |
11537 | "Pointer to route-map entries\n") | |
11538 | { | |
d62a17ae | 11539 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11540 | int idx_protocol = 1; | |
11541 | int idx_number = 3; | |
11542 | int idx_word = 5; | |
11543 | int type; | |
d7c0a89a | 11544 | uint32_t metric; |
d62a17ae | 11545 | struct bgp_redist *red; |
11546 | ||
11547 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11548 | if (type < 0) { | |
11549 | vty_out(vty, "%% Invalid route type\n"); | |
11550 | return CMD_WARNING_CONFIG_FAILED; | |
11551 | } | |
11552 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11553 | ||
11554 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
11555 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
11556 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11557 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
11558 | } | |
11559 | ||
11560 | ALIAS_HIDDEN( | |
11561 | bgp_redistribute_ipv4_metric_rmap, | |
11562 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
11563 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
11564 | " metric (0-4294967295) route-map WORD", | |
11565 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11566 | "Metric for redistributed routes\n" | |
11567 | "Default metric\n" | |
11568 | "Route map reference\n" | |
11569 | "Pointer to route-map entries\n") | |
596c17ba | 11570 | |
7c8ff89e DS |
11571 | DEFUN (bgp_redistribute_ipv4_ospf, |
11572 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 11573 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
11574 | "Redistribute information from another routing protocol\n" |
11575 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11576 | "Non-main Kernel Routing Table\n" |
11577 | "Instance ID/Table ID\n") | |
7c8ff89e | 11578 | { |
d62a17ae | 11579 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11580 | int idx_ospf_table = 1; | |
11581 | int idx_number = 2; | |
d7c0a89a QY |
11582 | unsigned short instance; |
11583 | unsigned short protocol; | |
7c8ff89e | 11584 | |
d62a17ae | 11585 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 11586 | |
d62a17ae | 11587 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
11588 | protocol = ZEBRA_ROUTE_OSPF; | |
11589 | else | |
11590 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 11591 | |
d62a17ae | 11592 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
11593 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
11594 | } |
11595 | ||
d62a17ae | 11596 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
11597 | "redistribute <ospf|table> (1-65535)", | |
11598 | "Redistribute information from another routing protocol\n" | |
11599 | "Open Shortest Path First (OSPFv2)\n" | |
11600 | "Non-main Kernel Routing Table\n" | |
11601 | "Instance ID/Table ID\n") | |
596c17ba | 11602 | |
7c8ff89e DS |
11603 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
11604 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 11605 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
11606 | "Redistribute information from another routing protocol\n" |
11607 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11608 | "Non-main Kernel Routing Table\n" |
11609 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
11610 | "Route map reference\n" |
11611 | "Pointer to route-map entries\n") | |
11612 | { | |
d62a17ae | 11613 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11614 | int idx_ospf_table = 1; | |
11615 | int idx_number = 2; | |
11616 | int idx_word = 4; | |
11617 | struct bgp_redist *red; | |
d7c0a89a | 11618 | unsigned short instance; |
d62a17ae | 11619 | int protocol; |
11620 | ||
11621 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11622 | protocol = ZEBRA_ROUTE_OSPF; | |
11623 | else | |
11624 | protocol = ZEBRA_ROUTE_TABLE; | |
11625 | ||
11626 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11627 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
11628 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11629 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
11630 | } | |
11631 | ||
11632 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
11633 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
11634 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
11635 | "Redistribute information from another routing protocol\n" | |
11636 | "Open Shortest Path First (OSPFv2)\n" | |
11637 | "Non-main Kernel Routing Table\n" | |
11638 | "Instance ID/Table ID\n" | |
11639 | "Route map reference\n" | |
11640 | "Pointer to route-map entries\n") | |
596c17ba | 11641 | |
7c8ff89e DS |
11642 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
11643 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 11644 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
11645 | "Redistribute information from another routing protocol\n" |
11646 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11647 | "Non-main Kernel Routing Table\n" |
11648 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
11649 | "Metric for redistributed routes\n" |
11650 | "Default metric\n") | |
11651 | { | |
d62a17ae | 11652 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11653 | int idx_ospf_table = 1; | |
11654 | int idx_number = 2; | |
11655 | int idx_number_2 = 4; | |
d7c0a89a | 11656 | uint32_t metric; |
d62a17ae | 11657 | struct bgp_redist *red; |
d7c0a89a | 11658 | unsigned short instance; |
d62a17ae | 11659 | int protocol; |
11660 | ||
11661 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11662 | protocol = ZEBRA_ROUTE_OSPF; | |
11663 | else | |
11664 | protocol = ZEBRA_ROUTE_TABLE; | |
11665 | ||
11666 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11667 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
11668 | ||
11669 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
11670 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
11671 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
11672 | } | |
11673 | ||
11674 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
11675 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
11676 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
11677 | "Redistribute information from another routing protocol\n" | |
11678 | "Open Shortest Path First (OSPFv2)\n" | |
11679 | "Non-main Kernel Routing Table\n" | |
11680 | "Instance ID/Table ID\n" | |
11681 | "Metric for redistributed routes\n" | |
11682 | "Default metric\n") | |
596c17ba | 11683 | |
7c8ff89e DS |
11684 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
11685 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 11686 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
11687 | "Redistribute information from another routing protocol\n" |
11688 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11689 | "Non-main Kernel Routing Table\n" |
11690 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
11691 | "Route map reference\n" |
11692 | "Pointer to route-map entries\n" | |
11693 | "Metric for redistributed routes\n" | |
11694 | "Default metric\n") | |
11695 | { | |
d62a17ae | 11696 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11697 | int idx_ospf_table = 1; | |
11698 | int idx_number = 2; | |
11699 | int idx_word = 4; | |
11700 | int idx_number_2 = 6; | |
d7c0a89a | 11701 | uint32_t metric; |
d62a17ae | 11702 | struct bgp_redist *red; |
d7c0a89a | 11703 | unsigned short instance; |
d62a17ae | 11704 | int protocol; |
11705 | ||
11706 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11707 | protocol = ZEBRA_ROUTE_OSPF; | |
11708 | else | |
11709 | protocol = ZEBRA_ROUTE_TABLE; | |
11710 | ||
11711 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11712 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
11713 | ||
11714 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
11715 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11716 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
11717 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
11718 | } | |
11719 | ||
11720 | ALIAS_HIDDEN( | |
11721 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
11722 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
11723 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
11724 | "Redistribute information from another routing protocol\n" | |
11725 | "Open Shortest Path First (OSPFv2)\n" | |
11726 | "Non-main Kernel Routing Table\n" | |
11727 | "Instance ID/Table ID\n" | |
11728 | "Route map reference\n" | |
11729 | "Pointer to route-map entries\n" | |
11730 | "Metric for redistributed routes\n" | |
11731 | "Default metric\n") | |
596c17ba | 11732 | |
7c8ff89e DS |
11733 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
11734 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 11735 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
11736 | "Redistribute information from another routing protocol\n" |
11737 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11738 | "Non-main Kernel Routing Table\n" |
11739 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
11740 | "Metric for redistributed routes\n" |
11741 | "Default metric\n" | |
11742 | "Route map reference\n" | |
11743 | "Pointer to route-map entries\n") | |
11744 | { | |
d62a17ae | 11745 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11746 | int idx_ospf_table = 1; | |
11747 | int idx_number = 2; | |
11748 | int idx_number_2 = 4; | |
11749 | int idx_word = 6; | |
d7c0a89a | 11750 | uint32_t metric; |
d62a17ae | 11751 | struct bgp_redist *red; |
d7c0a89a | 11752 | unsigned short instance; |
d62a17ae | 11753 | int protocol; |
11754 | ||
11755 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11756 | protocol = ZEBRA_ROUTE_OSPF; | |
11757 | else | |
11758 | protocol = ZEBRA_ROUTE_TABLE; | |
11759 | ||
11760 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11761 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
11762 | ||
11763 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
11764 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
11765 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11766 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
11767 | } | |
11768 | ||
11769 | ALIAS_HIDDEN( | |
11770 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
11771 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
11772 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
11773 | "Redistribute information from another routing protocol\n" | |
11774 | "Open Shortest Path First (OSPFv2)\n" | |
11775 | "Non-main Kernel Routing Table\n" | |
11776 | "Instance ID/Table ID\n" | |
11777 | "Metric for redistributed routes\n" | |
11778 | "Default metric\n" | |
11779 | "Route map reference\n" | |
11780 | "Pointer to route-map entries\n") | |
596c17ba | 11781 | |
7c8ff89e DS |
11782 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
11783 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 11784 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
11785 | NO_STR |
11786 | "Redistribute information from another routing protocol\n" | |
11787 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 11788 | "Non-main Kernel Routing Table\n" |
31500417 DW |
11789 | "Instance ID/Table ID\n" |
11790 | "Metric for redistributed routes\n" | |
11791 | "Default metric\n" | |
11792 | "Route map reference\n" | |
11793 | "Pointer to route-map entries\n") | |
7c8ff89e | 11794 | { |
d62a17ae | 11795 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11796 | int idx_ospf_table = 2; | |
11797 | int idx_number = 3; | |
d7c0a89a | 11798 | unsigned short instance; |
d62a17ae | 11799 | int protocol; |
11800 | ||
11801 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11802 | protocol = ZEBRA_ROUTE_OSPF; | |
11803 | else | |
11804 | protocol = ZEBRA_ROUTE_TABLE; | |
11805 | ||
11806 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11807 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
11808 | } | |
11809 | ||
11810 | ALIAS_HIDDEN( | |
11811 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
11812 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", | |
11813 | NO_STR | |
11814 | "Redistribute information from another routing protocol\n" | |
11815 | "Open Shortest Path First (OSPFv2)\n" | |
11816 | "Non-main Kernel Routing Table\n" | |
11817 | "Instance ID/Table ID\n" | |
11818 | "Metric for redistributed routes\n" | |
11819 | "Default metric\n" | |
11820 | "Route map reference\n" | |
11821 | "Pointer to route-map entries\n") | |
596c17ba | 11822 | |
718e3744 | 11823 | DEFUN (no_bgp_redistribute_ipv4, |
11824 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 11825 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 11826 | NO_STR |
11827 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 11828 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
11829 | "Metric for redistributed routes\n" |
11830 | "Default metric\n" | |
11831 | "Route map reference\n" | |
11832 | "Pointer to route-map entries\n") | |
718e3744 | 11833 | { |
d62a17ae | 11834 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11835 | int idx_protocol = 2; | |
11836 | int type; | |
11837 | ||
11838 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11839 | if (type < 0) { | |
11840 | vty_out(vty, "%% Invalid route type\n"); | |
11841 | return CMD_WARNING_CONFIG_FAILED; | |
11842 | } | |
11843 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
11844 | } | |
11845 | ||
11846 | ALIAS_HIDDEN( | |
11847 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
11848 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
11849 | " [metric (0-4294967295)] [route-map WORD]", | |
11850 | NO_STR | |
11851 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11852 | "Metric for redistributed routes\n" | |
11853 | "Default metric\n" | |
11854 | "Route map reference\n" | |
11855 | "Pointer to route-map entries\n") | |
596c17ba | 11856 | |
718e3744 | 11857 | DEFUN (bgp_redistribute_ipv6, |
11858 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 11859 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 11860 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11861 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 11862 | { |
d62a17ae | 11863 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11864 | int idx_protocol = 1; | |
11865 | int type; | |
718e3744 | 11866 | |
d62a17ae | 11867 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
11868 | if (type < 0) { | |
11869 | vty_out(vty, "%% Invalid route type\n"); | |
11870 | return CMD_WARNING_CONFIG_FAILED; | |
11871 | } | |
718e3744 | 11872 | |
d62a17ae | 11873 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
11874 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11875 | } |
11876 | ||
11877 | DEFUN (bgp_redistribute_ipv6_rmap, | |
11878 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 11879 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 11880 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11881 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11882 | "Route map reference\n" |
11883 | "Pointer to route-map entries\n") | |
11884 | { | |
d62a17ae | 11885 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11886 | int idx_protocol = 1; | |
11887 | int idx_word = 3; | |
11888 | int type; | |
11889 | struct bgp_redist *red; | |
718e3744 | 11890 | |
d62a17ae | 11891 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
11892 | if (type < 0) { | |
11893 | vty_out(vty, "%% Invalid route type\n"); | |
11894 | return CMD_WARNING_CONFIG_FAILED; | |
11895 | } | |
718e3744 | 11896 | |
d62a17ae | 11897 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11898 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11899 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11900 | } |
11901 | ||
11902 | DEFUN (bgp_redistribute_ipv6_metric, | |
11903 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 11904 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 11905 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11906 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11907 | "Metric for redistributed routes\n" |
11908 | "Default metric\n") | |
11909 | { | |
d62a17ae | 11910 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11911 | int idx_protocol = 1; | |
11912 | int idx_number = 3; | |
11913 | int type; | |
d7c0a89a | 11914 | uint32_t metric; |
d62a17ae | 11915 | struct bgp_redist *red; |
11916 | ||
11917 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
11918 | if (type < 0) { | |
11919 | vty_out(vty, "%% Invalid route type\n"); | |
11920 | return CMD_WARNING_CONFIG_FAILED; | |
11921 | } | |
11922 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 11923 | |
d62a17ae | 11924 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11925 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
11926 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11927 | } |
11928 | ||
11929 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
11930 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 11931 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 11932 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11933 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11934 | "Route map reference\n" |
11935 | "Pointer to route-map entries\n" | |
11936 | "Metric for redistributed routes\n" | |
11937 | "Default metric\n") | |
11938 | { | |
d62a17ae | 11939 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11940 | int idx_protocol = 1; | |
11941 | int idx_word = 3; | |
11942 | int idx_number = 5; | |
11943 | int type; | |
d7c0a89a | 11944 | uint32_t metric; |
d62a17ae | 11945 | struct bgp_redist *red; |
11946 | ||
11947 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
11948 | if (type < 0) { | |
11949 | vty_out(vty, "%% Invalid route type\n"); | |
11950 | return CMD_WARNING_CONFIG_FAILED; | |
11951 | } | |
11952 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 11953 | |
d62a17ae | 11954 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11955 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11956 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
11957 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11958 | } |
11959 | ||
11960 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
11961 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 11962 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 11963 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11964 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11965 | "Metric for redistributed routes\n" |
11966 | "Default metric\n" | |
11967 | "Route map reference\n" | |
11968 | "Pointer to route-map entries\n") | |
11969 | { | |
d62a17ae | 11970 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11971 | int idx_protocol = 1; | |
11972 | int idx_number = 3; | |
11973 | int idx_word = 5; | |
11974 | int type; | |
d7c0a89a | 11975 | uint32_t metric; |
d62a17ae | 11976 | struct bgp_redist *red; |
11977 | ||
11978 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
11979 | if (type < 0) { | |
11980 | vty_out(vty, "%% Invalid route type\n"); | |
11981 | return CMD_WARNING_CONFIG_FAILED; | |
11982 | } | |
11983 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 11984 | |
d62a17ae | 11985 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11986 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric); | |
11987 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11988 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11989 | } |
11990 | ||
11991 | DEFUN (no_bgp_redistribute_ipv6, | |
11992 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 11993 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 11994 | NO_STR |
11995 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 11996 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
11997 | "Metric for redistributed routes\n" |
11998 | "Default metric\n" | |
11999 | "Route map reference\n" | |
12000 | "Pointer to route-map entries\n") | |
718e3744 | 12001 | { |
d62a17ae | 12002 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12003 | int idx_protocol = 2; | |
12004 | int type; | |
718e3744 | 12005 | |
d62a17ae | 12006 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12007 | if (type < 0) { | |
12008 | vty_out(vty, "%% Invalid route type\n"); | |
12009 | return CMD_WARNING_CONFIG_FAILED; | |
12010 | } | |
718e3744 | 12011 | |
d62a17ae | 12012 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
12013 | } | |
12014 | ||
2b791107 | 12015 | void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 12016 | safi_t safi) |
d62a17ae | 12017 | { |
12018 | int i; | |
12019 | ||
12020 | /* Unicast redistribution only. */ | |
12021 | if (safi != SAFI_UNICAST) | |
2b791107 | 12022 | return; |
d62a17ae | 12023 | |
12024 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
12025 | /* Redistribute BGP does not make sense. */ | |
12026 | if (i != ZEBRA_ROUTE_BGP) { | |
12027 | struct list *red_list; | |
12028 | struct listnode *node; | |
12029 | struct bgp_redist *red; | |
12030 | ||
12031 | red_list = bgp->redist[afi][i]; | |
12032 | if (!red_list) | |
12033 | continue; | |
12034 | ||
12035 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 12036 | /* "redistribute" configuration. */ |
12037 | vty_out(vty, " redistribute %s", | |
12038 | zebra_route_string(i)); | |
12039 | if (red->instance) | |
12040 | vty_out(vty, " %d", red->instance); | |
12041 | if (red->redist_metric_flag) | |
12042 | vty_out(vty, " metric %u", | |
12043 | red->redist_metric); | |
12044 | if (red->rmap.name) | |
12045 | vty_out(vty, " route-map %s", | |
12046 | red->rmap.name); | |
12047 | vty_out(vty, "\n"); | |
12048 | } | |
12049 | } | |
12050 | } | |
718e3744 | 12051 | } |
6b0655a2 | 12052 | |
b9c7bc5a PZ |
12053 | /* This is part of the address-family block (unicast only) */ |
12054 | void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, | |
ddb5b488 PZ |
12055 | afi_t afi) |
12056 | { | |
b9c7bc5a | 12057 | int indent = 2; |
ddb5b488 | 12058 | |
bb4f6190 DS |
12059 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) |
12060 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", | |
12061 | bgp->vpn_policy[afi] | |
12062 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
12063 | ||
12a844a5 DS |
12064 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
12065 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
12066 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
12067 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
12068 | return; | |
12069 | ||
e70e9f8e PZ |
12070 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
12071 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
12072 | ||
12073 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
12074 | ||
12075 | } else { | |
12076 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
12077 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
12078 | bgp->vpn_policy[afi].tovpn_label); | |
12079 | } | |
ddb5b488 PZ |
12080 | } |
12081 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12082 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
12083 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 12084 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
12085 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
12086 | sizeof(buf))); | |
12087 | } | |
12088 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12089 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
12090 | ||
12091 | char buf[PREFIX_STRLEN]; | |
12092 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
12093 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
12094 | sizeof(buf))) { | |
12095 | ||
b9c7bc5a PZ |
12096 | vty_out(vty, "%*snexthop vpn export %s\n", |
12097 | indent, "", buf); | |
ddb5b488 PZ |
12098 | } |
12099 | } | |
12100 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
12101 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
12102 | && ecommunity_cmp( | |
12103 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12104 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
12105 | ||
12106 | char *b = ecommunity_ecom2str( | |
12107 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12108 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12109 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
12110 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12111 | } else { | |
12112 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
12113 | char *b = ecommunity_ecom2str( | |
12114 | bgp->vpn_policy[afi] | |
12115 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12116 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12117 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12118 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
12119 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12120 | } | |
12121 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
12122 | char *b = ecommunity_ecom2str( | |
12123 | bgp->vpn_policy[afi] | |
12124 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12125 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12126 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12127 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
12128 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12129 | } | |
12130 | } | |
bb4f6190 DS |
12131 | |
12132 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 12133 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
12134 | bgp->vpn_policy[afi] |
12135 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 12136 | |
301ad80a PG |
12137 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
12138 | char *b = ecommunity_ecom2str( | |
12139 | bgp->vpn_policy[afi] | |
12140 | .import_redirect_rtlist, | |
12141 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12142 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 12143 | |
301ad80a PG |
12144 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
12145 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
12146 | } | |
ddb5b488 PZ |
12147 | } |
12148 | ||
12149 | ||
718e3744 | 12150 | /* BGP node structure. */ |
d62a17ae | 12151 | static struct cmd_node bgp_node = { |
9d303b37 | 12152 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 12153 | }; |
12154 | ||
d62a17ae | 12155 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 12156 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12157 | }; |
12158 | ||
d62a17ae | 12159 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 12160 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12161 | }; |
12162 | ||
d62a17ae | 12163 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 12164 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12165 | }; |
12166 | ||
d62a17ae | 12167 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 12168 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12169 | }; |
12170 | ||
d62a17ae | 12171 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 12172 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 12173 | }; |
12174 | ||
d62a17ae | 12175 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 12176 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12177 | }; |
12178 | ||
d62a17ae | 12179 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
12180 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 12181 | |
d62a17ae | 12182 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
12183 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 12184 | |
d62a17ae | 12185 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
12186 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 12187 | |
d62a17ae | 12188 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
12189 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 12190 | |
7c40bf39 | 12191 | static struct cmd_node bgp_flowspecv4_node = {BGP_FLOWSPECV4_NODE, |
12192 | "%s(config-router-af)# ", 1}; | |
12193 | ||
12194 | static struct cmd_node bgp_flowspecv6_node = {BGP_FLOWSPECV6_NODE, | |
12195 | "%s(config-router-af-vpnv6)# ", 1}; | |
12196 | ||
d62a17ae | 12197 | static void community_list_vty(void); |
1f8ae70b | 12198 | |
d62a17ae | 12199 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 12200 | { |
d62a17ae | 12201 | struct bgp *bgp; |
12202 | struct peer *peer; | |
d62a17ae | 12203 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 12204 | |
d62a17ae | 12205 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
12206 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
12207 | /* only provide suggestions on the appropriate input | |
12208 | * token type, | |
12209 | * they'll otherwise show up multiple times */ | |
12210 | enum cmd_token_type match_type; | |
12211 | char *name = peer->host; | |
d48ed3e0 | 12212 | |
d62a17ae | 12213 | if (peer->conf_if) { |
12214 | match_type = VARIABLE_TKN; | |
12215 | name = peer->conf_if; | |
12216 | } else if (strchr(peer->host, ':')) | |
12217 | match_type = IPV6_TKN; | |
12218 | else | |
12219 | match_type = IPV4_TKN; | |
d48ed3e0 | 12220 | |
d62a17ae | 12221 | if (token->type != match_type) |
12222 | continue; | |
d48ed3e0 | 12223 | |
d62a17ae | 12224 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
12225 | } | |
d62a17ae | 12226 | } |
b8a815e5 DL |
12227 | } |
12228 | ||
12229 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 12230 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
12231 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 12232 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 12233 | {.completions = NULL}}; |
12234 | ||
47a306a0 DS |
12235 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
12236 | { | |
12237 | struct bgp *bgp; | |
12238 | struct peer_group *group; | |
12239 | struct listnode *lnbgp, *lnpeer; | |
12240 | ||
12241 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
12242 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
12243 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
12244 | group->name)); | |
12245 | } | |
12246 | } | |
12247 | ||
12248 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
12249 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
12250 | {.completions = NULL} }; | |
12251 | ||
d62a17ae | 12252 | void bgp_vty_init(void) |
12253 | { | |
12254 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 12255 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 12256 | |
12257 | /* Install bgp top node. */ | |
12258 | install_node(&bgp_node, bgp_config_write); | |
12259 | install_node(&bgp_ipv4_unicast_node, NULL); | |
12260 | install_node(&bgp_ipv4_multicast_node, NULL); | |
12261 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
12262 | install_node(&bgp_ipv6_unicast_node, NULL); | |
12263 | install_node(&bgp_ipv6_multicast_node, NULL); | |
12264 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
12265 | install_node(&bgp_vpnv4_node, NULL); | |
12266 | install_node(&bgp_vpnv6_node, NULL); | |
12267 | install_node(&bgp_evpn_node, NULL); | |
12268 | install_node(&bgp_evpn_vni_node, NULL); | |
7c40bf39 | 12269 | install_node(&bgp_flowspecv4_node, NULL); |
12270 | install_node(&bgp_flowspecv6_node, NULL); | |
d62a17ae | 12271 | |
12272 | /* Install default VTY commands to new nodes. */ | |
12273 | install_default(BGP_NODE); | |
12274 | install_default(BGP_IPV4_NODE); | |
12275 | install_default(BGP_IPV4M_NODE); | |
12276 | install_default(BGP_IPV4L_NODE); | |
12277 | install_default(BGP_IPV6_NODE); | |
12278 | install_default(BGP_IPV6M_NODE); | |
12279 | install_default(BGP_IPV6L_NODE); | |
12280 | install_default(BGP_VPNV4_NODE); | |
12281 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 12282 | install_default(BGP_FLOWSPECV4_NODE); |
12283 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 12284 | install_default(BGP_EVPN_NODE); |
12285 | install_default(BGP_EVPN_VNI_NODE); | |
12286 | ||
12287 | /* "bgp multiple-instance" commands. */ | |
12288 | install_element(CONFIG_NODE, &bgp_multiple_instance_cmd); | |
12289 | install_element(CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
12290 | ||
12291 | /* "bgp config-type" commands. */ | |
12292 | install_element(CONFIG_NODE, &bgp_config_type_cmd); | |
12293 | install_element(CONFIG_NODE, &no_bgp_config_type_cmd); | |
12294 | ||
12295 | /* bgp route-map delay-timer commands. */ | |
12296 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
12297 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
12298 | ||
12299 | /* Dummy commands (Currently not supported) */ | |
12300 | install_element(BGP_NODE, &no_synchronization_cmd); | |
12301 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
12302 | ||
12303 | /* "router bgp" commands. */ | |
12304 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
12305 | ||
12306 | /* "no router bgp" commands. */ | |
12307 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
12308 | ||
12309 | /* "bgp router-id" commands. */ | |
12310 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
12311 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
12312 | ||
12313 | /* "bgp cluster-id" commands. */ | |
12314 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
12315 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
12316 | ||
12317 | /* "bgp confederation" commands. */ | |
12318 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
12319 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
12320 | ||
12321 | /* "bgp confederation peers" commands. */ | |
12322 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
12323 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
12324 | ||
12325 | /* bgp max-med command */ | |
12326 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
12327 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
12328 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
12329 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
12330 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
12331 | ||
12332 | /* bgp disable-ebgp-connected-nh-check */ | |
12333 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
12334 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
12335 | ||
12336 | /* bgp update-delay command */ | |
12337 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
12338 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
12339 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
12340 | ||
12341 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
12342 | install_element(BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
555e09d4 QY |
12343 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
12344 | install_element(BGP_NODE, &no_bgp_rpkt_quanta_cmd); | |
d62a17ae | 12345 | |
12346 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
12347 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
12348 | ||
12349 | /* "maximum-paths" commands. */ | |
12350 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
12351 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
12352 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
12353 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
12354 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
12355 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
12356 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
12357 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
12358 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
12359 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
12360 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12361 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12362 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
12363 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12364 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12365 | ||
12366 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
12367 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
12368 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
12369 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12370 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12371 | ||
12372 | /* "timers bgp" commands. */ | |
12373 | install_element(BGP_NODE, &bgp_timers_cmd); | |
12374 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
12375 | ||
12376 | /* route-map delay-timer commands - per instance for backwards compat. | |
12377 | */ | |
12378 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
12379 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
12380 | ||
12381 | /* "bgp client-to-client reflection" commands */ | |
12382 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
12383 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
12384 | ||
12385 | /* "bgp always-compare-med" commands */ | |
12386 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
12387 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
12388 | ||
12389 | /* "bgp deterministic-med" commands */ | |
12390 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
12391 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
12392 | ||
12393 | /* "bgp graceful-restart" commands */ | |
12394 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); | |
12395 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
12396 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); | |
12397 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
12398 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
12399 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
12400 | ||
12401 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); | |
12402 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
12403 | ||
7f323236 DW |
12404 | /* "bgp graceful-shutdown" commands */ |
12405 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
12406 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
12407 | ||
d62a17ae | 12408 | /* "bgp fast-external-failover" commands */ |
12409 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
12410 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
12411 | ||
12412 | /* "bgp enforce-first-as" commands */ | |
12413 | install_element(BGP_NODE, &bgp_enforce_first_as_cmd); | |
12414 | install_element(BGP_NODE, &no_bgp_enforce_first_as_cmd); | |
12415 | ||
12416 | /* "bgp bestpath compare-routerid" commands */ | |
12417 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
12418 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
12419 | ||
12420 | /* "bgp bestpath as-path ignore" commands */ | |
12421 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
12422 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
12423 | ||
12424 | /* "bgp bestpath as-path confed" commands */ | |
12425 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
12426 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
12427 | ||
12428 | /* "bgp bestpath as-path multipath-relax" commands */ | |
12429 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
12430 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
12431 | ||
12432 | /* "bgp log-neighbor-changes" commands */ | |
12433 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
12434 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
12435 | ||
12436 | /* "bgp bestpath med" commands */ | |
12437 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
12438 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
12439 | ||
12440 | /* "no bgp default ipv4-unicast" commands. */ | |
12441 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
12442 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
12443 | ||
12444 | /* "bgp network import-check" commands. */ | |
12445 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
12446 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
12447 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
12448 | ||
12449 | /* "bgp default local-preference" commands. */ | |
12450 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
12451 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
12452 | ||
12453 | /* bgp default show-hostname */ | |
12454 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
12455 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
12456 | ||
12457 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
12458 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
12459 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
12460 | ||
12461 | /* bgp ibgp-allow-policy-mods command */ | |
12462 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
12463 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
12464 | ||
12465 | /* "bgp listen limit" commands. */ | |
12466 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
12467 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
12468 | ||
12469 | /* "bgp listen range" commands. */ | |
12470 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
12471 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
12472 | ||
8175f54a | 12473 | /* "bgp default shutdown" command */ |
f26845f9 QY |
12474 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
12475 | ||
d62a17ae | 12476 | /* "neighbor remote-as" commands. */ |
12477 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
12478 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
12479 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
12480 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
12481 | install_element(BGP_NODE, | |
12482 | &neighbor_interface_v6only_config_remote_as_cmd); | |
12483 | install_element(BGP_NODE, &no_neighbor_cmd); | |
12484 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
12485 | ||
12486 | /* "neighbor peer-group" commands. */ | |
12487 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
12488 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
12489 | install_element(BGP_NODE, | |
12490 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
12491 | ||
12492 | /* "neighbor local-as" commands. */ | |
12493 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
12494 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
12495 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
12496 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
12497 | ||
12498 | /* "neighbor solo" commands. */ | |
12499 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
12500 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
12501 | ||
12502 | /* "neighbor password" commands. */ | |
12503 | install_element(BGP_NODE, &neighbor_password_cmd); | |
12504 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
12505 | ||
12506 | /* "neighbor activate" commands. */ | |
12507 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
12508 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
12509 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
12510 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
12511 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
12512 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
12513 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
12514 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
12515 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 12516 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
12517 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 12518 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
12519 | ||
12520 | /* "no neighbor activate" commands. */ | |
12521 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
12522 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
12523 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
12524 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
12525 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
12526 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
12527 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
12528 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
12529 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 12530 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
12531 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 12532 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
12533 | ||
12534 | /* "neighbor peer-group" set commands. */ | |
12535 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
12536 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12537 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12538 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12539 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12540 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12541 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12542 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 12543 | install_element(BGP_FLOWSPECV4_NODE, |
12544 | &neighbor_set_peer_group_hidden_cmd); | |
12545 | install_element(BGP_FLOWSPECV6_NODE, | |
12546 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 12547 | |
12548 | /* "no neighbor peer-group unset" commands. */ | |
12549 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
12550 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12551 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12552 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12553 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12554 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12555 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12556 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 12557 | install_element(BGP_FLOWSPECV4_NODE, |
12558 | &no_neighbor_set_peer_group_hidden_cmd); | |
12559 | install_element(BGP_FLOWSPECV6_NODE, | |
12560 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 12561 | |
12562 | /* "neighbor softreconfiguration inbound" commands.*/ | |
12563 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
12564 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
12565 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
12566 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12567 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
12568 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12569 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
12570 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12571 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
12572 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12573 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
12574 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12575 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
12576 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12577 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
12578 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12579 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
12580 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 12581 | install_element(BGP_FLOWSPECV4_NODE, |
12582 | &neighbor_soft_reconfiguration_cmd); | |
12583 | install_element(BGP_FLOWSPECV4_NODE, | |
12584 | &no_neighbor_soft_reconfiguration_cmd); | |
12585 | install_element(BGP_FLOWSPECV6_NODE, | |
12586 | &neighbor_soft_reconfiguration_cmd); | |
12587 | install_element(BGP_FLOWSPECV6_NODE, | |
12588 | &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 12589 | |
12590 | /* "neighbor attribute-unchanged" commands. */ | |
12591 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
12592 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
12593 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
12594 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
12595 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
12596 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
12597 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
12598 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
12599 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
12600 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
12601 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
12602 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
12603 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
12604 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
12605 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
12606 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
12607 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
12608 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
12609 | ||
12610 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
12611 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
12612 | ||
12613 | /* "nexthop-local unchanged" commands */ | |
12614 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
12615 | install_element(BGP_IPV6_NODE, | |
12616 | &no_neighbor_nexthop_local_unchanged_cmd); | |
12617 | ||
12618 | /* "neighbor next-hop-self" commands. */ | |
12619 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
12620 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
12621 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
12622 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
12623 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
12624 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
12625 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
12626 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
12627 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
12628 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
12629 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
12630 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
12631 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
12632 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
12633 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
12634 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
12635 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
12636 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
12637 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
12638 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 12639 | |
12640 | /* "neighbor next-hop-self force" commands. */ | |
12641 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
12642 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
12643 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
12644 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12645 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
12646 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12647 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); | |
12648 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12649 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
12650 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12651 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
12652 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12653 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); | |
12654 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12655 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
12656 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12657 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); | |
12658 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12659 | ||
12660 | /* "neighbor as-override" commands. */ | |
12661 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
12662 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
12663 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
12664 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
12665 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
12666 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
12667 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
12668 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
12669 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
12670 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
12671 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
12672 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
12673 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
12674 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
12675 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
12676 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
12677 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
12678 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
12679 | ||
12680 | /* "neighbor remove-private-AS" commands. */ | |
12681 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
12682 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
12683 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
12684 | install_element(BGP_NODE, | |
12685 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
12686 | install_element(BGP_NODE, | |
12687 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
12688 | install_element(BGP_NODE, | |
12689 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
12690 | install_element(BGP_NODE, | |
12691 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
12692 | install_element( | |
12693 | BGP_NODE, | |
12694 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
12695 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
12696 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
12697 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
12698 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12699 | install_element(BGP_IPV4_NODE, | |
12700 | &neighbor_remove_private_as_replace_as_cmd); | |
12701 | install_element(BGP_IPV4_NODE, | |
12702 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12703 | install_element(BGP_IPV4_NODE, | |
12704 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12705 | install_element(BGP_IPV4_NODE, | |
12706 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12707 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
12708 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
12709 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
12710 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12711 | install_element(BGP_IPV4M_NODE, | |
12712 | &neighbor_remove_private_as_replace_as_cmd); | |
12713 | install_element(BGP_IPV4M_NODE, | |
12714 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12715 | install_element(BGP_IPV4M_NODE, | |
12716 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12717 | install_element(BGP_IPV4M_NODE, | |
12718 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12719 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
12720 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
12721 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
12722 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12723 | install_element(BGP_IPV4L_NODE, | |
12724 | &neighbor_remove_private_as_replace_as_cmd); | |
12725 | install_element(BGP_IPV4L_NODE, | |
12726 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12727 | install_element(BGP_IPV4L_NODE, | |
12728 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12729 | install_element(BGP_IPV4L_NODE, | |
12730 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12731 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
12732 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
12733 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
12734 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12735 | install_element(BGP_IPV6_NODE, | |
12736 | &neighbor_remove_private_as_replace_as_cmd); | |
12737 | install_element(BGP_IPV6_NODE, | |
12738 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12739 | install_element(BGP_IPV6_NODE, | |
12740 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12741 | install_element(BGP_IPV6_NODE, | |
12742 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12743 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
12744 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
12745 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
12746 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12747 | install_element(BGP_IPV6M_NODE, | |
12748 | &neighbor_remove_private_as_replace_as_cmd); | |
12749 | install_element(BGP_IPV6M_NODE, | |
12750 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12751 | install_element(BGP_IPV6M_NODE, | |
12752 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12753 | install_element(BGP_IPV6M_NODE, | |
12754 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12755 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
12756 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
12757 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
12758 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12759 | install_element(BGP_IPV6L_NODE, | |
12760 | &neighbor_remove_private_as_replace_as_cmd); | |
12761 | install_element(BGP_IPV6L_NODE, | |
12762 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12763 | install_element(BGP_IPV6L_NODE, | |
12764 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12765 | install_element(BGP_IPV6L_NODE, | |
12766 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12767 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
12768 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
12769 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
12770 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12771 | install_element(BGP_VPNV4_NODE, | |
12772 | &neighbor_remove_private_as_replace_as_cmd); | |
12773 | install_element(BGP_VPNV4_NODE, | |
12774 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12775 | install_element(BGP_VPNV4_NODE, | |
12776 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12777 | install_element(BGP_VPNV4_NODE, | |
12778 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12779 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
12780 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
12781 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
12782 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12783 | install_element(BGP_VPNV6_NODE, | |
12784 | &neighbor_remove_private_as_replace_as_cmd); | |
12785 | install_element(BGP_VPNV6_NODE, | |
12786 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12787 | install_element(BGP_VPNV6_NODE, | |
12788 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12789 | install_element(BGP_VPNV6_NODE, | |
12790 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12791 | ||
12792 | /* "neighbor send-community" commands.*/ | |
12793 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
12794 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
12795 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
12796 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
12797 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
12798 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
12799 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
12800 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
12801 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
12802 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
12803 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
12804 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
12805 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
12806 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
12807 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
12808 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
12809 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
12810 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
12811 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
12812 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
12813 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
12814 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
12815 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
12816 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
12817 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
12818 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
12819 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
12820 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
12821 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
12822 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
12823 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
12824 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
12825 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
12826 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
12827 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
12828 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
12829 | ||
12830 | /* "neighbor route-reflector" commands.*/ | |
12831 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
12832 | install_element(BGP_NODE, | |
12833 | &no_neighbor_route_reflector_client_hidden_cmd); | |
12834 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
12835 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
12836 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
12837 | install_element(BGP_IPV4M_NODE, | |
12838 | &no_neighbor_route_reflector_client_cmd); | |
12839 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
12840 | install_element(BGP_IPV4L_NODE, | |
12841 | &no_neighbor_route_reflector_client_cmd); | |
12842 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
12843 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
12844 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
12845 | install_element(BGP_IPV6M_NODE, | |
12846 | &no_neighbor_route_reflector_client_cmd); | |
12847 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
12848 | install_element(BGP_IPV6L_NODE, | |
12849 | &no_neighbor_route_reflector_client_cmd); | |
12850 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
12851 | install_element(BGP_VPNV4_NODE, | |
12852 | &no_neighbor_route_reflector_client_cmd); | |
12853 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
12854 | install_element(BGP_VPNV6_NODE, | |
12855 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 12856 | install_element(BGP_FLOWSPECV4_NODE, |
12857 | &neighbor_route_reflector_client_cmd); | |
12858 | install_element(BGP_FLOWSPECV4_NODE, | |
12859 | &no_neighbor_route_reflector_client_cmd); | |
12860 | install_element(BGP_FLOWSPECV6_NODE, | |
12861 | &neighbor_route_reflector_client_cmd); | |
12862 | install_element(BGP_FLOWSPECV6_NODE, | |
12863 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 12864 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
12865 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
12866 | ||
12867 | /* "neighbor route-server" commands.*/ | |
12868 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
12869 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
12870 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
12871 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
12872 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
12873 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
12874 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
12875 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
12876 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
12877 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
12878 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
12879 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
12880 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
12881 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
12882 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
12883 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
12884 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
12885 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 12886 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
12887 | install_element(BGP_FLOWSPECV4_NODE, | |
12888 | &no_neighbor_route_server_client_cmd); | |
12889 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
12890 | install_element(BGP_FLOWSPECV6_NODE, | |
12891 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 12892 | |
12893 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
12894 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
12895 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
12896 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12897 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12898 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12899 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12900 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12901 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12902 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12903 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12904 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12905 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12906 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12907 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12908 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12909 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12910 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12911 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12912 | ||
12913 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
12914 | install_element(BGP_NODE, | |
12915 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
12916 | install_element(BGP_NODE, | |
12917 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
12918 | install_element(BGP_IPV4_NODE, | |
12919 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12920 | install_element(BGP_IPV4_NODE, | |
12921 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12922 | install_element(BGP_IPV4M_NODE, | |
12923 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12924 | install_element(BGP_IPV4M_NODE, | |
12925 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12926 | install_element(BGP_IPV4L_NODE, | |
12927 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12928 | install_element(BGP_IPV4L_NODE, | |
12929 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12930 | install_element(BGP_IPV6_NODE, | |
12931 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12932 | install_element(BGP_IPV6_NODE, | |
12933 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12934 | install_element(BGP_IPV6M_NODE, | |
12935 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12936 | install_element(BGP_IPV6M_NODE, | |
12937 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12938 | install_element(BGP_IPV6L_NODE, | |
12939 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12940 | install_element(BGP_IPV6L_NODE, | |
12941 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12942 | install_element(BGP_VPNV4_NODE, | |
12943 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12944 | install_element(BGP_VPNV4_NODE, | |
12945 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12946 | install_element(BGP_VPNV6_NODE, | |
12947 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12948 | install_element(BGP_VPNV6_NODE, | |
12949 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12950 | ||
12951 | /* "neighbor passive" commands. */ | |
12952 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
12953 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
12954 | ||
12955 | ||
12956 | /* "neighbor shutdown" commands. */ | |
12957 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
12958 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
12959 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
12960 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
12961 | ||
12962 | /* "neighbor capability extended-nexthop" commands.*/ | |
12963 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
12964 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
12965 | ||
12966 | /* "neighbor capability orf prefix-list" commands.*/ | |
12967 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
12968 | install_element(BGP_NODE, | |
12969 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
12970 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
12971 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
12972 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
12973 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
12974 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
12975 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
12976 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
12977 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
12978 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
12979 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
12980 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
12981 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
12982 | ||
12983 | /* "neighbor capability dynamic" commands.*/ | |
12984 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
12985 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
12986 | ||
12987 | /* "neighbor dont-capability-negotiate" commands. */ | |
12988 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
12989 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
12990 | ||
12991 | /* "neighbor ebgp-multihop" commands. */ | |
12992 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
12993 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
12994 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
12995 | ||
12996 | /* "neighbor disable-connected-check" commands. */ | |
12997 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
12998 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
12999 | ||
13000 | /* "neighbor description" commands. */ | |
13001 | install_element(BGP_NODE, &neighbor_description_cmd); | |
13002 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
13003 | ||
13004 | /* "neighbor update-source" commands. "*/ | |
13005 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
13006 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
13007 | ||
13008 | /* "neighbor default-originate" commands. */ | |
13009 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
13010 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
13011 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
13012 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
13013 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
13014 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
13015 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
13016 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
13017 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
13018 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
13019 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
13020 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
13021 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
13022 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
13023 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
13024 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
13025 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
13026 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
13027 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
13028 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
13029 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
13030 | ||
13031 | /* "neighbor port" commands. */ | |
13032 | install_element(BGP_NODE, &neighbor_port_cmd); | |
13033 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
13034 | ||
13035 | /* "neighbor weight" commands. */ | |
13036 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
13037 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
13038 | ||
13039 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
13040 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
13041 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
13042 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
13043 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
13044 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
13045 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
13046 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
13047 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
13048 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
13049 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
13050 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
13051 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
13052 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
13053 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
13054 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
13055 | ||
13056 | /* "neighbor override-capability" commands. */ | |
13057 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
13058 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
13059 | ||
13060 | /* "neighbor strict-capability-match" commands. */ | |
13061 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
13062 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
13063 | ||
13064 | /* "neighbor timers" commands. */ | |
13065 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
13066 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
13067 | ||
13068 | /* "neighbor timers connect" commands. */ | |
13069 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
13070 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
13071 | ||
13072 | /* "neighbor advertisement-interval" commands. */ | |
13073 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
13074 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
13075 | ||
13076 | /* "neighbor interface" commands. */ | |
13077 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
13078 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
13079 | ||
13080 | /* "neighbor distribute" commands. */ | |
13081 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
13082 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
13083 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
13084 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
13085 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
13086 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
13087 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
13088 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
13089 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
13090 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
13091 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
13092 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
13093 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
13094 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
13095 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
13096 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
13097 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
13098 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
13099 | ||
13100 | /* "neighbor prefix-list" commands. */ | |
13101 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
13102 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
13103 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
13104 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
13105 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
13106 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
13107 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
13108 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
13109 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
13110 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
13111 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
13112 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
13113 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
13114 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
13115 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
13116 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
13117 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
13118 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 13119 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
13120 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
13121 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
13122 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 13123 | |
13124 | /* "neighbor filter-list" commands. */ | |
13125 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
13126 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
13127 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
13128 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
13129 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
13130 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
13131 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
13132 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
13133 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
13134 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
13135 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
13136 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
13137 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
13138 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
13139 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
13140 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
13141 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
13142 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 13143 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
13144 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
13145 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
13146 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 13147 | |
13148 | /* "neighbor route-map" commands. */ | |
13149 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
13150 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
13151 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
13152 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
13153 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
13154 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
13155 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
13156 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
13157 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
13158 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
13159 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
13160 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
13161 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
13162 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
13163 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
13164 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
13165 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
13166 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 13167 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
13168 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
13169 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
13170 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
13171 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
13172 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 13173 | |
13174 | /* "neighbor unsuppress-map" commands. */ | |
13175 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
13176 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
13177 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
13178 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13179 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
13180 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13181 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
13182 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13183 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
13184 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13185 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
13186 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13187 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
13188 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13189 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
13190 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13191 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
13192 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13193 | ||
13194 | /* "neighbor maximum-prefix" commands. */ | |
13195 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
13196 | install_element(BGP_NODE, | |
13197 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
13198 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
13199 | install_element(BGP_NODE, | |
13200 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
13201 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
13202 | install_element(BGP_NODE, | |
13203 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
13204 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
13205 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
13206 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13207 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13208 | install_element(BGP_IPV4_NODE, | |
13209 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13210 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13211 | install_element(BGP_IPV4_NODE, | |
13212 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13213 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13214 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
13215 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13216 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13217 | install_element(BGP_IPV4M_NODE, | |
13218 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13219 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13220 | install_element(BGP_IPV4M_NODE, | |
13221 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13222 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13223 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
13224 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13225 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13226 | install_element(BGP_IPV4L_NODE, | |
13227 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13228 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13229 | install_element(BGP_IPV4L_NODE, | |
13230 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13231 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13232 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
13233 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13234 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13235 | install_element(BGP_IPV6_NODE, | |
13236 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13237 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13238 | install_element(BGP_IPV6_NODE, | |
13239 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13240 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13241 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
13242 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13243 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13244 | install_element(BGP_IPV6M_NODE, | |
13245 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13246 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13247 | install_element(BGP_IPV6M_NODE, | |
13248 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13249 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13250 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
13251 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13252 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13253 | install_element(BGP_IPV6L_NODE, | |
13254 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13255 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13256 | install_element(BGP_IPV6L_NODE, | |
13257 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13258 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13259 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
13260 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13261 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13262 | install_element(BGP_VPNV4_NODE, | |
13263 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13264 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13265 | install_element(BGP_VPNV4_NODE, | |
13266 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13267 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13268 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
13269 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13270 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13271 | install_element(BGP_VPNV6_NODE, | |
13272 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13273 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13274 | install_element(BGP_VPNV6_NODE, | |
13275 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13276 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13277 | ||
13278 | /* "neighbor allowas-in" */ | |
13279 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
13280 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
13281 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
13282 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
13283 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
13284 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
13285 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
13286 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
13287 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
13288 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
13289 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
13290 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
13291 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
13292 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
13293 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
13294 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
13295 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
13296 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
13297 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
13298 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
13299 | ||
13300 | /* address-family commands. */ | |
13301 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
13302 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 13303 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 13304 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
13305 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 13306 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 13307 | |
d62a17ae | 13308 | install_element(BGP_NODE, &address_family_evpn_cmd); |
13309 | ||
13310 | /* "exit-address-family" command. */ | |
13311 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
13312 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
13313 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
13314 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
13315 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
13316 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
13317 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
13318 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 13319 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
13320 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 13321 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
13322 | ||
13323 | /* "clear ip bgp commands" */ | |
13324 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
13325 | ||
13326 | /* clear ip bgp prefix */ | |
13327 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
13328 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
13329 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
13330 | ||
13331 | /* "show [ip] bgp summary" commands. */ | |
13332 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
d62a17ae | 13333 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 13334 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 13335 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
13336 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 13337 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
13338 | ||
13339 | /* "show [ip] bgp neighbors" commands. */ | |
13340 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
13341 | ||
13342 | /* "show [ip] bgp peer-group" commands. */ | |
13343 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
13344 | ||
13345 | /* "show [ip] bgp paths" commands. */ | |
13346 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
13347 | ||
13348 | /* "show [ip] bgp community" commands. */ | |
13349 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
13350 | ||
13351 | /* "show ip bgp large-community" commands. */ | |
13352 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
13353 | /* "show [ip] bgp attribute-info" commands. */ | |
13354 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 13355 | /* "show [ip] bgp route-leak" command */ |
13356 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 13357 | |
13358 | /* "redistribute" commands. */ | |
13359 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
13360 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
13361 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
13362 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
13363 | install_element(BGP_NODE, | |
13364 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
13365 | install_element(BGP_NODE, | |
13366 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
13367 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
13368 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
13369 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
13370 | install_element(BGP_NODE, | |
13371 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
13372 | install_element(BGP_NODE, | |
13373 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
13374 | install_element(BGP_NODE, | |
13375 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
13376 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
13377 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
13378 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
13379 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
13380 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
13381 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
13382 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
13383 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
13384 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
13385 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
13386 | install_element(BGP_IPV4_NODE, | |
13387 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
13388 | install_element(BGP_IPV4_NODE, | |
13389 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
13390 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
13391 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
13392 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
13393 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
13394 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
13395 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
13396 | ||
b9c7bc5a PZ |
13397 | /* import|export vpn [route-map WORD] */ |
13398 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
13399 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 13400 | |
12a844a5 DS |
13401 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
13402 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
13403 | ||
d62a17ae | 13404 | /* ttl_security commands */ |
13405 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
13406 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
13407 | ||
13408 | /* "show [ip] bgp memory" commands. */ | |
13409 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
13410 | ||
acf71666 MK |
13411 | /* "show bgp martian next-hop" */ |
13412 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
13413 | ||
d62a17ae | 13414 | /* "show [ip] bgp views" commands. */ |
13415 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
13416 | ||
13417 | /* "show [ip] bgp vrfs" commands. */ | |
13418 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
13419 | ||
13420 | /* Community-list. */ | |
13421 | community_list_vty(); | |
ddb5b488 PZ |
13422 | |
13423 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
13424 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
13425 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
13426 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
13427 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
13428 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
13429 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
13430 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
13431 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
13432 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
13433 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
13434 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
13435 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 13436 | |
301ad80a PG |
13437 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
13438 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
13439 | ||
b9c7bc5a PZ |
13440 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
13441 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
13442 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
13443 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
13444 | install_element(BGP_IPV4_NODE, &af_no_nexthop_vpn_export_cmd); | |
13445 | install_element(BGP_IPV6_NODE, &af_no_nexthop_vpn_export_cmd); | |
13446 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); | |
13447 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
13448 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
13449 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
13450 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
13451 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 13452 | } |
6b0655a2 | 13453 | |
718e3744 | 13454 | #include "memory.h" |
13455 | #include "bgp_regex.h" | |
13456 | #include "bgp_clist.h" | |
13457 | #include "bgp_ecommunity.h" | |
13458 | ||
13459 | /* VTY functions. */ | |
13460 | ||
13461 | /* Direction value to string conversion. */ | |
d62a17ae | 13462 | static const char *community_direct_str(int direct) |
13463 | { | |
13464 | switch (direct) { | |
13465 | case COMMUNITY_DENY: | |
13466 | return "deny"; | |
13467 | case COMMUNITY_PERMIT: | |
13468 | return "permit"; | |
13469 | default: | |
13470 | return "unknown"; | |
13471 | } | |
718e3744 | 13472 | } |
13473 | ||
13474 | /* Display error string. */ | |
d62a17ae | 13475 | static void community_list_perror(struct vty *vty, int ret) |
13476 | { | |
13477 | switch (ret) { | |
13478 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
13479 | vty_out(vty, "%% Can't find community-list\n"); | |
13480 | break; | |
13481 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
13482 | vty_out(vty, "%% Malformed community-list value\n"); | |
13483 | break; | |
13484 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
13485 | vty_out(vty, | |
13486 | "%% Community name conflict, previously defined as standard community\n"); | |
13487 | break; | |
13488 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
13489 | vty_out(vty, | |
13490 | "%% Community name conflict, previously defined as expanded community\n"); | |
13491 | break; | |
13492 | } | |
718e3744 | 13493 | } |
13494 | ||
5bf15956 DW |
13495 | /* "community-list" keyword help string. */ |
13496 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
13497 | ||
5bf15956 | 13498 | /* ip community-list standard */ |
718e3744 | 13499 | DEFUN (ip_community_list_standard, |
13500 | ip_community_list_standard_cmd, | |
e961923c | 13501 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 13502 | IP_STR |
13503 | COMMUNITY_LIST_STR | |
13504 | "Community list number (standard)\n" | |
5bf15956 | 13505 | "Add an standard community-list entry\n" |
718e3744 | 13506 | "Community list name\n" |
13507 | "Specify community to reject\n" | |
13508 | "Specify community to accept\n" | |
13509 | COMMUNITY_VAL_STR) | |
13510 | { | |
d62a17ae | 13511 | char *cl_name_or_number = NULL; |
13512 | int direct = 0; | |
13513 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 13514 | |
d62a17ae | 13515 | int idx = 0; |
13516 | argv_find(argv, argc, "(1-99)", &idx); | |
13517 | argv_find(argv, argc, "WORD", &idx); | |
13518 | cl_name_or_number = argv[idx]->arg; | |
13519 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13520 | : COMMUNITY_DENY; | |
13521 | argv_find(argv, argc, "AA:NN", &idx); | |
13522 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13523 | |
d62a17ae | 13524 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
13525 | style); | |
42f914d4 | 13526 | |
d62a17ae | 13527 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13528 | |
d62a17ae | 13529 | if (ret < 0) { |
13530 | /* Display error string. */ | |
13531 | community_list_perror(vty, ret); | |
13532 | return CMD_WARNING_CONFIG_FAILED; | |
13533 | } | |
42f914d4 | 13534 | |
d62a17ae | 13535 | return CMD_SUCCESS; |
718e3744 | 13536 | } |
13537 | ||
fee6e4e4 | 13538 | DEFUN (no_ip_community_list_standard_all, |
13539 | no_ip_community_list_standard_all_cmd, | |
e961923c | 13540 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 13541 | NO_STR |
13542 | IP_STR | |
13543 | COMMUNITY_LIST_STR | |
13544 | "Community list number (standard)\n" | |
5bf15956 DW |
13545 | "Add an standard community-list entry\n" |
13546 | "Community list name\n" | |
718e3744 | 13547 | "Specify community to reject\n" |
13548 | "Specify community to accept\n" | |
13549 | COMMUNITY_VAL_STR) | |
13550 | { | |
d62a17ae | 13551 | char *cl_name_or_number = NULL; |
13552 | int direct = 0; | |
13553 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 13554 | |
d62a17ae | 13555 | int idx = 0; |
13556 | argv_find(argv, argc, "(1-99)", &idx); | |
13557 | argv_find(argv, argc, "WORD", &idx); | |
13558 | cl_name_or_number = argv[idx]->arg; | |
13559 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13560 | : COMMUNITY_DENY; | |
13561 | argv_find(argv, argc, "AA:NN", &idx); | |
13562 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13563 | |
d62a17ae | 13564 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 13565 | direct, style); |
42f914d4 | 13566 | |
d62a17ae | 13567 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 13568 | |
d62a17ae | 13569 | if (ret < 0) { |
13570 | community_list_perror(vty, ret); | |
13571 | return CMD_WARNING_CONFIG_FAILED; | |
13572 | } | |
42f914d4 | 13573 | |
d62a17ae | 13574 | return CMD_SUCCESS; |
718e3744 | 13575 | } |
13576 | ||
5bf15956 DW |
13577 | /* ip community-list expanded */ |
13578 | DEFUN (ip_community_list_expanded_all, | |
13579 | ip_community_list_expanded_all_cmd, | |
42f914d4 | 13580 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 13581 | IP_STR |
13582 | COMMUNITY_LIST_STR | |
13583 | "Community list number (expanded)\n" | |
5bf15956 | 13584 | "Add an expanded community-list entry\n" |
718e3744 | 13585 | "Community list name\n" |
13586 | "Specify community to reject\n" | |
13587 | "Specify community to accept\n" | |
13588 | COMMUNITY_VAL_STR) | |
13589 | { | |
d62a17ae | 13590 | char *cl_name_or_number = NULL; |
13591 | int direct = 0; | |
13592 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 13593 | |
d62a17ae | 13594 | int idx = 0; |
13595 | argv_find(argv, argc, "(100-500)", &idx); | |
13596 | argv_find(argv, argc, "WORD", &idx); | |
13597 | cl_name_or_number = argv[idx]->arg; | |
13598 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13599 | : COMMUNITY_DENY; | |
13600 | argv_find(argv, argc, "AA:NN", &idx); | |
13601 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13602 | |
d62a17ae | 13603 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
13604 | style); | |
42f914d4 | 13605 | |
d62a17ae | 13606 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13607 | |
d62a17ae | 13608 | if (ret < 0) { |
13609 | /* Display error string. */ | |
13610 | community_list_perror(vty, ret); | |
13611 | return CMD_WARNING_CONFIG_FAILED; | |
13612 | } | |
42f914d4 | 13613 | |
d62a17ae | 13614 | return CMD_SUCCESS; |
718e3744 | 13615 | } |
13616 | ||
5bf15956 DW |
13617 | DEFUN (no_ip_community_list_expanded_all, |
13618 | no_ip_community_list_expanded_all_cmd, | |
42f914d4 | 13619 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 13620 | NO_STR |
13621 | IP_STR | |
13622 | COMMUNITY_LIST_STR | |
5bf15956 DW |
13623 | "Community list number (expanded)\n" |
13624 | "Add an expanded community-list entry\n" | |
718e3744 | 13625 | "Community list name\n" |
13626 | "Specify community to reject\n" | |
13627 | "Specify community to accept\n" | |
5bf15956 | 13628 | COMMUNITY_VAL_STR) |
718e3744 | 13629 | { |
d62a17ae | 13630 | char *cl_name_or_number = NULL; |
13631 | int direct = 0; | |
13632 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 13633 | |
d62a17ae | 13634 | int idx = 0; |
13635 | argv_find(argv, argc, "(100-500)", &idx); | |
13636 | argv_find(argv, argc, "WORD", &idx); | |
13637 | cl_name_or_number = argv[idx]->arg; | |
13638 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13639 | : COMMUNITY_DENY; | |
13640 | argv_find(argv, argc, "AA:NN", &idx); | |
13641 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13642 | |
d62a17ae | 13643 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 13644 | direct, style); |
42f914d4 | 13645 | |
d62a17ae | 13646 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 13647 | |
d62a17ae | 13648 | if (ret < 0) { |
13649 | community_list_perror(vty, ret); | |
13650 | return CMD_WARNING_CONFIG_FAILED; | |
13651 | } | |
42f914d4 | 13652 | |
d62a17ae | 13653 | return CMD_SUCCESS; |
718e3744 | 13654 | } |
13655 | ||
8d9b8ed9 PM |
13656 | /* Return configuration string of community-list entry. */ |
13657 | static const char *community_list_config_str(struct community_entry *entry) | |
13658 | { | |
13659 | const char *str; | |
13660 | ||
13661 | if (entry->any) | |
13662 | str = ""; | |
13663 | else { | |
13664 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
13665 | str = community_str(entry->u.com, false); | |
13666 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
13667 | str = lcommunity_str(entry->u.lcom, false); | |
13668 | else | |
13669 | str = entry->config; | |
13670 | } | |
13671 | return str; | |
13672 | } | |
13673 | ||
d62a17ae | 13674 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 13675 | { |
d62a17ae | 13676 | struct community_entry *entry; |
718e3744 | 13677 | |
d62a17ae | 13678 | for (entry = list->head; entry; entry = entry->next) { |
13679 | if (entry == list->head) { | |
13680 | if (all_digit(list->name)) | |
13681 | vty_out(vty, "Community %s list %s\n", | |
13682 | entry->style == COMMUNITY_LIST_STANDARD | |
13683 | ? "standard" | |
13684 | : "(expanded) access", | |
13685 | list->name); | |
13686 | else | |
13687 | vty_out(vty, "Named Community %s list %s\n", | |
13688 | entry->style == COMMUNITY_LIST_STANDARD | |
13689 | ? "standard" | |
13690 | : "expanded", | |
13691 | list->name); | |
13692 | } | |
13693 | if (entry->any) | |
13694 | vty_out(vty, " %s\n", | |
13695 | community_direct_str(entry->direct)); | |
13696 | else | |
13697 | vty_out(vty, " %s %s\n", | |
13698 | community_direct_str(entry->direct), | |
8d9b8ed9 | 13699 | community_list_config_str(entry)); |
d62a17ae | 13700 | } |
718e3744 | 13701 | } |
13702 | ||
13703 | DEFUN (show_ip_community_list, | |
13704 | show_ip_community_list_cmd, | |
13705 | "show ip community-list", | |
13706 | SHOW_STR | |
13707 | IP_STR | |
13708 | "List community-list\n") | |
13709 | { | |
d62a17ae | 13710 | struct community_list *list; |
13711 | struct community_list_master *cm; | |
718e3744 | 13712 | |
d62a17ae | 13713 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
13714 | if (!cm) | |
13715 | return CMD_SUCCESS; | |
718e3744 | 13716 | |
d62a17ae | 13717 | for (list = cm->num.head; list; list = list->next) |
13718 | community_list_show(vty, list); | |
718e3744 | 13719 | |
d62a17ae | 13720 | for (list = cm->str.head; list; list = list->next) |
13721 | community_list_show(vty, list); | |
718e3744 | 13722 | |
d62a17ae | 13723 | return CMD_SUCCESS; |
718e3744 | 13724 | } |
13725 | ||
13726 | DEFUN (show_ip_community_list_arg, | |
13727 | show_ip_community_list_arg_cmd, | |
6147e2c6 | 13728 | "show ip community-list <(1-500)|WORD>", |
718e3744 | 13729 | SHOW_STR |
13730 | IP_STR | |
13731 | "List community-list\n" | |
13732 | "Community-list number\n" | |
13733 | "Community-list name\n") | |
13734 | { | |
d62a17ae | 13735 | int idx_comm_list = 3; |
13736 | struct community_list *list; | |
718e3744 | 13737 | |
d62a17ae | 13738 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
13739 | COMMUNITY_LIST_MASTER); | |
13740 | if (!list) { | |
13741 | vty_out(vty, "%% Can't find community-list\n"); | |
13742 | return CMD_WARNING; | |
13743 | } | |
718e3744 | 13744 | |
d62a17ae | 13745 | community_list_show(vty, list); |
718e3744 | 13746 | |
d62a17ae | 13747 | return CMD_SUCCESS; |
718e3744 | 13748 | } |
6b0655a2 | 13749 | |
57d187bc JS |
13750 | /* |
13751 | * Large Community code. | |
13752 | */ | |
d62a17ae | 13753 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
13754 | struct cmd_token **argv, int style, | |
13755 | int reject_all_digit_name) | |
13756 | { | |
13757 | int ret; | |
13758 | int direct; | |
13759 | char *str; | |
13760 | int idx = 0; | |
13761 | char *cl_name; | |
13762 | ||
13763 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13764 | : COMMUNITY_DENY; | |
13765 | ||
13766 | /* All digit name check. */ | |
13767 | idx = 0; | |
13768 | argv_find(argv, argc, "WORD", &idx); | |
13769 | argv_find(argv, argc, "(1-99)", &idx); | |
13770 | argv_find(argv, argc, "(100-500)", &idx); | |
13771 | cl_name = argv[idx]->arg; | |
13772 | if (reject_all_digit_name && all_digit(cl_name)) { | |
13773 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
13774 | return CMD_WARNING_CONFIG_FAILED; | |
13775 | } | |
13776 | ||
13777 | idx = 0; | |
13778 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
13779 | argv_find(argv, argc, "LINE", &idx); | |
13780 | /* Concat community string argument. */ | |
13781 | if (idx) | |
13782 | str = argv_concat(argv, argc, idx); | |
13783 | else | |
13784 | str = NULL; | |
13785 | ||
13786 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
13787 | ||
13788 | /* Free temporary community list string allocated by | |
13789 | argv_concat(). */ | |
13790 | if (str) | |
13791 | XFREE(MTYPE_TMP, str); | |
13792 | ||
13793 | if (ret < 0) { | |
13794 | community_list_perror(vty, ret); | |
13795 | return CMD_WARNING_CONFIG_FAILED; | |
13796 | } | |
13797 | return CMD_SUCCESS; | |
13798 | } | |
13799 | ||
13800 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
13801 | struct cmd_token **argv, int style) | |
13802 | { | |
13803 | int ret; | |
13804 | int direct = 0; | |
13805 | char *str = NULL; | |
13806 | int idx = 0; | |
13807 | ||
13808 | argv_find(argv, argc, "permit", &idx); | |
13809 | argv_find(argv, argc, "deny", &idx); | |
13810 | ||
13811 | if (idx) { | |
13812 | /* Check the list direct. */ | |
13813 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
13814 | direct = COMMUNITY_PERMIT; | |
13815 | else | |
13816 | direct = COMMUNITY_DENY; | |
13817 | ||
13818 | idx = 0; | |
13819 | argv_find(argv, argc, "LINE", &idx); | |
13820 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
13821 | /* Concat community string argument. */ | |
13822 | str = argv_concat(argv, argc, idx); | |
13823 | } | |
13824 | ||
13825 | idx = 0; | |
13826 | argv_find(argv, argc, "(1-99)", &idx); | |
13827 | argv_find(argv, argc, "(100-500)", &idx); | |
13828 | argv_find(argv, argc, "WORD", &idx); | |
13829 | ||
13830 | /* Unset community list. */ | |
13831 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
13832 | style); | |
13833 | ||
13834 | /* Free temporary community list string allocated by | |
13835 | argv_concat(). */ | |
13836 | if (str) | |
13837 | XFREE(MTYPE_TMP, str); | |
13838 | ||
13839 | if (ret < 0) { | |
13840 | community_list_perror(vty, ret); | |
13841 | return CMD_WARNING_CONFIG_FAILED; | |
13842 | } | |
13843 | ||
13844 | return CMD_SUCCESS; | |
57d187bc JS |
13845 | } |
13846 | ||
13847 | /* "large-community-list" keyword help string. */ | |
13848 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
13849 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
13850 | ||
13851 | DEFUN (ip_lcommunity_list_standard, | |
13852 | ip_lcommunity_list_standard_cmd, | |
52951b63 DS |
13853 | "ip large-community-list (1-99) <deny|permit>", |
13854 | IP_STR | |
13855 | LCOMMUNITY_LIST_STR | |
13856 | "Large Community list number (standard)\n" | |
13857 | "Specify large community to reject\n" | |
7111c1a0 | 13858 | "Specify large community to accept\n") |
52951b63 | 13859 | { |
d62a17ae | 13860 | return lcommunity_list_set_vty(vty, argc, argv, |
13861 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
13862 | } |
13863 | ||
13864 | DEFUN (ip_lcommunity_list_standard1, | |
13865 | ip_lcommunity_list_standard1_cmd, | |
13866 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
13867 | IP_STR |
13868 | LCOMMUNITY_LIST_STR | |
13869 | "Large Community list number (standard)\n" | |
13870 | "Specify large community to reject\n" | |
13871 | "Specify large community to accept\n" | |
13872 | LCOMMUNITY_VAL_STR) | |
13873 | { | |
d62a17ae | 13874 | return lcommunity_list_set_vty(vty, argc, argv, |
13875 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
57d187bc JS |
13876 | } |
13877 | ||
13878 | DEFUN (ip_lcommunity_list_expanded, | |
13879 | ip_lcommunity_list_expanded_cmd, | |
13880 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
13881 | IP_STR | |
13882 | LCOMMUNITY_LIST_STR | |
13883 | "Large Community list number (expanded)\n" | |
13884 | "Specify large community to reject\n" | |
13885 | "Specify large community to accept\n" | |
13886 | "An ordered list as a regular-expression\n") | |
13887 | { | |
d62a17ae | 13888 | return lcommunity_list_set_vty(vty, argc, argv, |
13889 | LARGE_COMMUNITY_LIST_EXPANDED, 0); | |
57d187bc JS |
13890 | } |
13891 | ||
13892 | DEFUN (ip_lcommunity_list_name_standard, | |
13893 | ip_lcommunity_list_name_standard_cmd, | |
52951b63 DS |
13894 | "ip large-community-list standard WORD <deny|permit>", |
13895 | IP_STR | |
13896 | LCOMMUNITY_LIST_STR | |
13897 | "Specify standard large-community-list\n" | |
13898 | "Large Community list name\n" | |
13899 | "Specify large community to reject\n" | |
13900 | "Specify large community to accept\n") | |
13901 | { | |
d62a17ae | 13902 | return lcommunity_list_set_vty(vty, argc, argv, |
13903 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
13904 | } |
13905 | ||
13906 | DEFUN (ip_lcommunity_list_name_standard1, | |
13907 | ip_lcommunity_list_name_standard1_cmd, | |
13908 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
13909 | IP_STR |
13910 | LCOMMUNITY_LIST_STR | |
13911 | "Specify standard large-community-list\n" | |
13912 | "Large Community list name\n" | |
13913 | "Specify large community to reject\n" | |
13914 | "Specify large community to accept\n" | |
13915 | LCOMMUNITY_VAL_STR) | |
13916 | { | |
d62a17ae | 13917 | return lcommunity_list_set_vty(vty, argc, argv, |
13918 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
57d187bc JS |
13919 | } |
13920 | ||
13921 | DEFUN (ip_lcommunity_list_name_expanded, | |
13922 | ip_lcommunity_list_name_expanded_cmd, | |
13923 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
13924 | IP_STR | |
13925 | LCOMMUNITY_LIST_STR | |
13926 | "Specify expanded large-community-list\n" | |
13927 | "Large Community list name\n" | |
13928 | "Specify large community to reject\n" | |
13929 | "Specify large community to accept\n" | |
13930 | "An ordered list as a regular-expression\n") | |
13931 | { | |
d62a17ae | 13932 | return lcommunity_list_set_vty(vty, argc, argv, |
13933 | LARGE_COMMUNITY_LIST_EXPANDED, 1); | |
57d187bc JS |
13934 | } |
13935 | ||
13936 | DEFUN (no_ip_lcommunity_list_standard_all, | |
13937 | no_ip_lcommunity_list_standard_all_cmd, | |
13938 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
13939 | NO_STR | |
13940 | IP_STR | |
13941 | LCOMMUNITY_LIST_STR | |
13942 | "Large Community list number (standard)\n" | |
13943 | "Large Community list number (expanded)\n" | |
13944 | "Large Community list name\n") | |
13945 | { | |
d62a17ae | 13946 | return lcommunity_list_unset_vty(vty, argc, argv, |
13947 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
13948 | } |
13949 | ||
13950 | DEFUN (no_ip_lcommunity_list_name_expanded_all, | |
13951 | no_ip_lcommunity_list_name_expanded_all_cmd, | |
13952 | "no ip large-community-list expanded WORD", | |
13953 | NO_STR | |
13954 | IP_STR | |
13955 | LCOMMUNITY_LIST_STR | |
13956 | "Specify expanded large-community-list\n" | |
13957 | "Large Community list name\n") | |
13958 | { | |
d62a17ae | 13959 | return lcommunity_list_unset_vty(vty, argc, argv, |
13960 | LARGE_COMMUNITY_LIST_EXPANDED); | |
57d187bc JS |
13961 | } |
13962 | ||
13963 | DEFUN (no_ip_lcommunity_list_standard, | |
13964 | no_ip_lcommunity_list_standard_cmd, | |
13965 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
13966 | NO_STR | |
13967 | IP_STR | |
13968 | LCOMMUNITY_LIST_STR | |
13969 | "Large Community list number (standard)\n" | |
13970 | "Specify large community to reject\n" | |
13971 | "Specify large community to accept\n" | |
13972 | LCOMMUNITY_VAL_STR) | |
13973 | { | |
d62a17ae | 13974 | return lcommunity_list_unset_vty(vty, argc, argv, |
13975 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
13976 | } |
13977 | ||
13978 | DEFUN (no_ip_lcommunity_list_expanded, | |
13979 | no_ip_lcommunity_list_expanded_cmd, | |
13980 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
13981 | NO_STR | |
13982 | IP_STR | |
13983 | LCOMMUNITY_LIST_STR | |
13984 | "Large Community list number (expanded)\n" | |
13985 | "Specify large community to reject\n" | |
13986 | "Specify large community to accept\n" | |
13987 | "An ordered list as a regular-expression\n") | |
13988 | { | |
d62a17ae | 13989 | return lcommunity_list_unset_vty(vty, argc, argv, |
13990 | LARGE_COMMUNITY_LIST_EXPANDED); | |
57d187bc JS |
13991 | } |
13992 | ||
13993 | DEFUN (no_ip_lcommunity_list_name_standard, | |
13994 | no_ip_lcommunity_list_name_standard_cmd, | |
13995 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
13996 | NO_STR | |
13997 | IP_STR | |
13998 | LCOMMUNITY_LIST_STR | |
13999 | "Specify standard large-community-list\n" | |
14000 | "Large Community list name\n" | |
14001 | "Specify large community to reject\n" | |
14002 | "Specify large community to accept\n" | |
14003 | LCOMMUNITY_VAL_STR) | |
14004 | { | |
d62a17ae | 14005 | return lcommunity_list_unset_vty(vty, argc, argv, |
14006 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
14007 | } |
14008 | ||
14009 | DEFUN (no_ip_lcommunity_list_name_expanded, | |
14010 | no_ip_lcommunity_list_name_expanded_cmd, | |
14011 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
14012 | NO_STR | |
14013 | IP_STR | |
14014 | LCOMMUNITY_LIST_STR | |
14015 | "Specify expanded large-community-list\n" | |
14016 | "Large community list name\n" | |
14017 | "Specify large community to reject\n" | |
14018 | "Specify large community to accept\n" | |
14019 | "An ordered list as a regular-expression\n") | |
14020 | { | |
d62a17ae | 14021 | return lcommunity_list_unset_vty(vty, argc, argv, |
14022 | LARGE_COMMUNITY_LIST_EXPANDED); | |
14023 | } | |
14024 | ||
14025 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) | |
14026 | { | |
14027 | struct community_entry *entry; | |
14028 | ||
14029 | for (entry = list->head; entry; entry = entry->next) { | |
14030 | if (entry == list->head) { | |
14031 | if (all_digit(list->name)) | |
14032 | vty_out(vty, "Large community %s list %s\n", | |
14033 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14034 | ? "standard" | |
14035 | : "(expanded) access", | |
14036 | list->name); | |
14037 | else | |
14038 | vty_out(vty, | |
14039 | "Named large community %s list %s\n", | |
14040 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14041 | ? "standard" | |
14042 | : "expanded", | |
14043 | list->name); | |
14044 | } | |
14045 | if (entry->any) | |
14046 | vty_out(vty, " %s\n", | |
14047 | community_direct_str(entry->direct)); | |
14048 | else | |
14049 | vty_out(vty, " %s %s\n", | |
14050 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14051 | community_list_config_str(entry)); |
d62a17ae | 14052 | } |
57d187bc JS |
14053 | } |
14054 | ||
14055 | DEFUN (show_ip_lcommunity_list, | |
14056 | show_ip_lcommunity_list_cmd, | |
14057 | "show ip large-community-list", | |
14058 | SHOW_STR | |
14059 | IP_STR | |
14060 | "List large-community list\n") | |
14061 | { | |
d62a17ae | 14062 | struct community_list *list; |
14063 | struct community_list_master *cm; | |
57d187bc | 14064 | |
d62a17ae | 14065 | cm = community_list_master_lookup(bgp_clist, |
14066 | LARGE_COMMUNITY_LIST_MASTER); | |
14067 | if (!cm) | |
14068 | return CMD_SUCCESS; | |
57d187bc | 14069 | |
d62a17ae | 14070 | for (list = cm->num.head; list; list = list->next) |
14071 | lcommunity_list_show(vty, list); | |
57d187bc | 14072 | |
d62a17ae | 14073 | for (list = cm->str.head; list; list = list->next) |
14074 | lcommunity_list_show(vty, list); | |
57d187bc | 14075 | |
d62a17ae | 14076 | return CMD_SUCCESS; |
57d187bc JS |
14077 | } |
14078 | ||
14079 | DEFUN (show_ip_lcommunity_list_arg, | |
14080 | show_ip_lcommunity_list_arg_cmd, | |
14081 | "show ip large-community-list <(1-500)|WORD>", | |
14082 | SHOW_STR | |
14083 | IP_STR | |
14084 | "List large-community list\n" | |
14085 | "large-community-list number\n" | |
14086 | "large-community-list name\n") | |
14087 | { | |
d62a17ae | 14088 | struct community_list *list; |
57d187bc | 14089 | |
d62a17ae | 14090 | list = community_list_lookup(bgp_clist, argv[3]->arg, |
14091 | LARGE_COMMUNITY_LIST_MASTER); | |
14092 | if (!list) { | |
14093 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
14094 | return CMD_WARNING; | |
14095 | } | |
57d187bc | 14096 | |
d62a17ae | 14097 | lcommunity_list_show(vty, list); |
57d187bc | 14098 | |
d62a17ae | 14099 | return CMD_SUCCESS; |
57d187bc JS |
14100 | } |
14101 | ||
718e3744 | 14102 | /* "extcommunity-list" keyword help string. */ |
14103 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
14104 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
14105 | ||
14106 | DEFUN (ip_extcommunity_list_standard, | |
14107 | ip_extcommunity_list_standard_cmd, | |
e961923c | 14108 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 14109 | IP_STR |
14110 | EXTCOMMUNITY_LIST_STR | |
14111 | "Extended Community list number (standard)\n" | |
718e3744 | 14112 | "Specify standard extcommunity-list\n" |
5bf15956 | 14113 | "Community list name\n" |
718e3744 | 14114 | "Specify community to reject\n" |
14115 | "Specify community to accept\n" | |
14116 | EXTCOMMUNITY_VAL_STR) | |
14117 | { | |
d62a17ae | 14118 | int style = EXTCOMMUNITY_LIST_STANDARD; |
14119 | int direct = 0; | |
14120 | char *cl_number_or_name = NULL; | |
42f914d4 | 14121 | |
d62a17ae | 14122 | int idx = 0; |
14123 | argv_find(argv, argc, "(1-99)", &idx); | |
14124 | argv_find(argv, argc, "WORD", &idx); | |
14125 | cl_number_or_name = argv[idx]->arg; | |
14126 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14127 | : COMMUNITY_DENY; | |
14128 | argv_find(argv, argc, "AA:NN", &idx); | |
14129 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14130 | |
d62a17ae | 14131 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
14132 | direct, style); | |
42f914d4 | 14133 | |
d62a17ae | 14134 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14135 | |
d62a17ae | 14136 | if (ret < 0) { |
14137 | community_list_perror(vty, ret); | |
14138 | return CMD_WARNING_CONFIG_FAILED; | |
14139 | } | |
42f914d4 | 14140 | |
d62a17ae | 14141 | return CMD_SUCCESS; |
718e3744 | 14142 | } |
14143 | ||
718e3744 | 14144 | DEFUN (ip_extcommunity_list_name_expanded, |
14145 | ip_extcommunity_list_name_expanded_cmd, | |
e961923c | 14146 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 14147 | IP_STR |
14148 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 14149 | "Extended Community list number (expanded)\n" |
718e3744 | 14150 | "Specify expanded extcommunity-list\n" |
14151 | "Extended Community list name\n" | |
14152 | "Specify community to reject\n" | |
14153 | "Specify community to accept\n" | |
14154 | "An ordered list as a regular-expression\n") | |
14155 | { | |
d62a17ae | 14156 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
14157 | int direct = 0; | |
14158 | char *cl_number_or_name = NULL; | |
42f914d4 | 14159 | |
d62a17ae | 14160 | int idx = 0; |
14161 | argv_find(argv, argc, "(100-500)", &idx); | |
14162 | argv_find(argv, argc, "WORD", &idx); | |
14163 | cl_number_or_name = argv[idx]->arg; | |
14164 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14165 | : COMMUNITY_DENY; | |
14166 | argv_find(argv, argc, "LINE", &idx); | |
14167 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14168 | |
d62a17ae | 14169 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
14170 | direct, style); | |
42f914d4 | 14171 | |
d62a17ae | 14172 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14173 | |
d62a17ae | 14174 | if (ret < 0) { |
14175 | community_list_perror(vty, ret); | |
14176 | return CMD_WARNING_CONFIG_FAILED; | |
14177 | } | |
42f914d4 | 14178 | |
d62a17ae | 14179 | return CMD_SUCCESS; |
718e3744 | 14180 | } |
14181 | ||
fee6e4e4 | 14182 | DEFUN (no_ip_extcommunity_list_standard_all, |
14183 | no_ip_extcommunity_list_standard_all_cmd, | |
e961923c | 14184 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
813d4307 DW |
14185 | NO_STR |
14186 | IP_STR | |
14187 | EXTCOMMUNITY_LIST_STR | |
14188 | "Extended Community list number (standard)\n" | |
718e3744 | 14189 | "Specify standard extcommunity-list\n" |
5bf15956 | 14190 | "Community list name\n" |
718e3744 | 14191 | "Specify community to reject\n" |
14192 | "Specify community to accept\n" | |
14193 | EXTCOMMUNITY_VAL_STR) | |
14194 | { | |
d62a17ae | 14195 | int style = EXTCOMMUNITY_LIST_STANDARD; |
14196 | int direct = 0; | |
14197 | char *cl_number_or_name = NULL; | |
42f914d4 | 14198 | |
d62a17ae | 14199 | int idx = 0; |
14200 | argv_find(argv, argc, "(1-99)", &idx); | |
14201 | argv_find(argv, argc, "WORD", &idx); | |
14202 | cl_number_or_name = argv[idx]->arg; | |
14203 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14204 | : COMMUNITY_DENY; | |
14205 | argv_find(argv, argc, "AA:NN", &idx); | |
14206 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14207 | |
d62a17ae | 14208 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 14209 | direct, style); |
42f914d4 | 14210 | |
d62a17ae | 14211 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14212 | |
d62a17ae | 14213 | if (ret < 0) { |
14214 | community_list_perror(vty, ret); | |
14215 | return CMD_WARNING_CONFIG_FAILED; | |
14216 | } | |
42f914d4 | 14217 | |
d62a17ae | 14218 | return CMD_SUCCESS; |
718e3744 | 14219 | } |
14220 | ||
5bf15956 DW |
14221 | DEFUN (no_ip_extcommunity_list_expanded_all, |
14222 | no_ip_extcommunity_list_expanded_all_cmd, | |
e961923c | 14223 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 14224 | NO_STR |
14225 | IP_STR | |
14226 | EXTCOMMUNITY_LIST_STR | |
14227 | "Extended Community list number (expanded)\n" | |
718e3744 | 14228 | "Specify expanded extcommunity-list\n" |
5bf15956 | 14229 | "Extended Community list name\n" |
718e3744 | 14230 | "Specify community to reject\n" |
14231 | "Specify community to accept\n" | |
14232 | "An ordered list as a regular-expression\n") | |
14233 | { | |
d62a17ae | 14234 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
14235 | int direct = 0; | |
14236 | char *cl_number_or_name = NULL; | |
42f914d4 | 14237 | |
d62a17ae | 14238 | int idx = 0; |
14239 | argv_find(argv, argc, "(100-500)", &idx); | |
14240 | argv_find(argv, argc, "WORD", &idx); | |
14241 | cl_number_or_name = argv[idx]->arg; | |
14242 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14243 | : COMMUNITY_DENY; | |
14244 | argv_find(argv, argc, "LINE", &idx); | |
14245 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14246 | |
d62a17ae | 14247 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 14248 | direct, style); |
42f914d4 | 14249 | |
d62a17ae | 14250 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14251 | |
d62a17ae | 14252 | if (ret < 0) { |
14253 | community_list_perror(vty, ret); | |
14254 | return CMD_WARNING_CONFIG_FAILED; | |
14255 | } | |
42f914d4 | 14256 | |
d62a17ae | 14257 | return CMD_SUCCESS; |
718e3744 | 14258 | } |
14259 | ||
d62a17ae | 14260 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 14261 | { |
d62a17ae | 14262 | struct community_entry *entry; |
718e3744 | 14263 | |
d62a17ae | 14264 | for (entry = list->head; entry; entry = entry->next) { |
14265 | if (entry == list->head) { | |
14266 | if (all_digit(list->name)) | |
14267 | vty_out(vty, "Extended community %s list %s\n", | |
14268 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14269 | ? "standard" | |
14270 | : "(expanded) access", | |
14271 | list->name); | |
14272 | else | |
14273 | vty_out(vty, | |
14274 | "Named extended community %s list %s\n", | |
14275 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14276 | ? "standard" | |
14277 | : "expanded", | |
14278 | list->name); | |
14279 | } | |
14280 | if (entry->any) | |
14281 | vty_out(vty, " %s\n", | |
14282 | community_direct_str(entry->direct)); | |
14283 | else | |
14284 | vty_out(vty, " %s %s\n", | |
14285 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14286 | community_list_config_str(entry)); |
d62a17ae | 14287 | } |
718e3744 | 14288 | } |
14289 | ||
14290 | DEFUN (show_ip_extcommunity_list, | |
14291 | show_ip_extcommunity_list_cmd, | |
14292 | "show ip extcommunity-list", | |
14293 | SHOW_STR | |
14294 | IP_STR | |
14295 | "List extended-community list\n") | |
14296 | { | |
d62a17ae | 14297 | struct community_list *list; |
14298 | struct community_list_master *cm; | |
718e3744 | 14299 | |
d62a17ae | 14300 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
14301 | if (!cm) | |
14302 | return CMD_SUCCESS; | |
718e3744 | 14303 | |
d62a17ae | 14304 | for (list = cm->num.head; list; list = list->next) |
14305 | extcommunity_list_show(vty, list); | |
718e3744 | 14306 | |
d62a17ae | 14307 | for (list = cm->str.head; list; list = list->next) |
14308 | extcommunity_list_show(vty, list); | |
718e3744 | 14309 | |
d62a17ae | 14310 | return CMD_SUCCESS; |
718e3744 | 14311 | } |
14312 | ||
14313 | DEFUN (show_ip_extcommunity_list_arg, | |
14314 | show_ip_extcommunity_list_arg_cmd, | |
6147e2c6 | 14315 | "show ip extcommunity-list <(1-500)|WORD>", |
718e3744 | 14316 | SHOW_STR |
14317 | IP_STR | |
14318 | "List extended-community list\n" | |
14319 | "Extcommunity-list number\n" | |
14320 | "Extcommunity-list name\n") | |
14321 | { | |
d62a17ae | 14322 | int idx_comm_list = 3; |
14323 | struct community_list *list; | |
718e3744 | 14324 | |
d62a17ae | 14325 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
14326 | EXTCOMMUNITY_LIST_MASTER); | |
14327 | if (!list) { | |
14328 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
14329 | return CMD_WARNING; | |
14330 | } | |
718e3744 | 14331 | |
d62a17ae | 14332 | extcommunity_list_show(vty, list); |
718e3744 | 14333 | |
d62a17ae | 14334 | return CMD_SUCCESS; |
718e3744 | 14335 | } |
6b0655a2 | 14336 | |
718e3744 | 14337 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 14338 | static int community_list_config_write(struct vty *vty) |
14339 | { | |
14340 | struct community_list *list; | |
14341 | struct community_entry *entry; | |
14342 | struct community_list_master *cm; | |
14343 | int write = 0; | |
14344 | ||
14345 | /* Community-list. */ | |
14346 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
14347 | ||
14348 | for (list = cm->num.head; list; list = list->next) | |
14349 | for (entry = list->head; entry; entry = entry->next) { | |
14350 | vty_out(vty, "ip community-list %s %s %s\n", list->name, | |
14351 | community_direct_str(entry->direct), | |
14352 | community_list_config_str(entry)); | |
14353 | write++; | |
14354 | } | |
14355 | for (list = cm->str.head; list; list = list->next) | |
14356 | for (entry = list->head; entry; entry = entry->next) { | |
14357 | vty_out(vty, "ip community-list %s %s %s %s\n", | |
14358 | entry->style == COMMUNITY_LIST_STANDARD | |
14359 | ? "standard" | |
14360 | : "expanded", | |
14361 | list->name, community_direct_str(entry->direct), | |
14362 | community_list_config_str(entry)); | |
14363 | write++; | |
14364 | } | |
14365 | ||
14366 | /* Extcommunity-list. */ | |
14367 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
14368 | ||
14369 | for (list = cm->num.head; list; list = list->next) | |
14370 | for (entry = list->head; entry; entry = entry->next) { | |
14371 | vty_out(vty, "ip extcommunity-list %s %s %s\n", | |
14372 | list->name, community_direct_str(entry->direct), | |
14373 | community_list_config_str(entry)); | |
14374 | write++; | |
14375 | } | |
14376 | for (list = cm->str.head; list; list = list->next) | |
14377 | for (entry = list->head; entry; entry = entry->next) { | |
14378 | vty_out(vty, "ip extcommunity-list %s %s %s %s\n", | |
14379 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14380 | ? "standard" | |
14381 | : "expanded", | |
14382 | list->name, community_direct_str(entry->direct), | |
14383 | community_list_config_str(entry)); | |
14384 | write++; | |
14385 | } | |
14386 | ||
14387 | ||
14388 | /* lcommunity-list. */ | |
14389 | cm = community_list_master_lookup(bgp_clist, | |
14390 | LARGE_COMMUNITY_LIST_MASTER); | |
14391 | ||
14392 | for (list = cm->num.head; list; list = list->next) | |
14393 | for (entry = list->head; entry; entry = entry->next) { | |
14394 | vty_out(vty, "ip large-community-list %s %s %s\n", | |
14395 | list->name, community_direct_str(entry->direct), | |
14396 | community_list_config_str(entry)); | |
14397 | write++; | |
14398 | } | |
14399 | for (list = cm->str.head; list; list = list->next) | |
14400 | for (entry = list->head; entry; entry = entry->next) { | |
14401 | vty_out(vty, "ip large-community-list %s %s %s %s\n", | |
14402 | entry->style == LARGE_COMMUNITY_LIST_STANDARD | |
14403 | ? "standard" | |
14404 | : "expanded", | |
14405 | list->name, community_direct_str(entry->direct), | |
14406 | community_list_config_str(entry)); | |
14407 | write++; | |
14408 | } | |
14409 | ||
14410 | return write; | |
14411 | } | |
14412 | ||
14413 | static struct cmd_node community_list_node = { | |
14414 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 14415 | }; |
14416 | ||
d62a17ae | 14417 | static void community_list_vty(void) |
14418 | { | |
14419 | install_node(&community_list_node, community_list_config_write); | |
14420 | ||
14421 | /* Community-list. */ | |
14422 | install_element(CONFIG_NODE, &ip_community_list_standard_cmd); | |
14423 | install_element(CONFIG_NODE, &ip_community_list_expanded_all_cmd); | |
14424 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_cmd); | |
14425 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); | |
14426 | install_element(VIEW_NODE, &show_ip_community_list_cmd); | |
14427 | install_element(VIEW_NODE, &show_ip_community_list_arg_cmd); | |
14428 | ||
14429 | /* Extcommunity-list. */ | |
14430 | install_element(CONFIG_NODE, &ip_extcommunity_list_standard_cmd); | |
14431 | install_element(CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); | |
14432 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); | |
14433 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
14434 | install_element(VIEW_NODE, &show_ip_extcommunity_list_cmd); | |
14435 | install_element(VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
14436 | ||
14437 | /* Large Community List */ | |
14438 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard_cmd); | |
14439 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); | |
14440 | install_element(CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); | |
14441 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
14442 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); | |
14443 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); | |
14444 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
14445 | install_element(CONFIG_NODE, | |
14446 | &no_ip_lcommunity_list_name_expanded_all_cmd); | |
14447 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
14448 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
14449 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
14450 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
14451 | install_element(VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
14452 | install_element(VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 14453 | } |