]>
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" |
5d5ba018 | 37 | #include "frrstr.h" |
718e3744 | 38 | |
39 | #include "bgpd/bgpd.h" | |
4bf6a362 | 40 | #include "bgpd/bgp_advertise.h" |
718e3744 | 41 | #include "bgpd/bgp_attr.h" |
42 | #include "bgpd/bgp_aspath.h" | |
43 | #include "bgpd/bgp_community.h" | |
4bf6a362 | 44 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 45 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 46 | #include "bgpd/bgp_damp.h" |
718e3744 | 47 | #include "bgpd/bgp_debug.h" |
e0701b79 | 48 | #include "bgpd/bgp_fsm.h" |
4bf6a362 | 49 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 50 | #include "bgpd/bgp_open.h" |
4bf6a362 | 51 | #include "bgpd/bgp_regex.h" |
718e3744 | 52 | #include "bgpd/bgp_route.h" |
c016b6c7 | 53 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 54 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 55 | #include "bgpd/bgp_table.h" |
94f2b392 | 56 | #include "bgpd/bgp_vty.h" |
165b5fff | 57 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 58 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 59 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 60 | #include "bgpd/bgp_bfd.h" |
555e09d4 | 61 | #include "bgpd/bgp_io.h" |
94c2f693 | 62 | #include "bgpd/bgp_evpn.h" |
718e3744 | 63 | |
d62a17ae | 64 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
65 | struct prefix *range, int exact); | |
66 | ||
67 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) | |
68 | { | |
69 | switch (afi) { | |
70 | case AFI_IP: | |
71 | switch (safi) { | |
72 | case SAFI_UNICAST: | |
73 | return BGP_IPV4_NODE; | |
74 | break; | |
75 | case SAFI_MULTICAST: | |
76 | return BGP_IPV4M_NODE; | |
77 | break; | |
78 | case SAFI_LABELED_UNICAST: | |
79 | return BGP_IPV4L_NODE; | |
80 | break; | |
81 | case SAFI_MPLS_VPN: | |
82 | return BGP_VPNV4_NODE; | |
83 | break; | |
7c40bf39 | 84 | case SAFI_FLOWSPEC: |
85 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
86 | default: |
87 | /* not expected */ | |
88 | return BGP_IPV4_NODE; | |
89 | break; | |
d62a17ae | 90 | } |
91 | break; | |
92 | case AFI_IP6: | |
93 | switch (safi) { | |
94 | case SAFI_UNICAST: | |
95 | return BGP_IPV6_NODE; | |
96 | break; | |
97 | case SAFI_MULTICAST: | |
98 | return BGP_IPV6M_NODE; | |
99 | break; | |
100 | case SAFI_LABELED_UNICAST: | |
101 | return BGP_IPV6L_NODE; | |
102 | break; | |
103 | case SAFI_MPLS_VPN: | |
104 | return BGP_VPNV6_NODE; | |
105 | break; | |
7c40bf39 | 106 | case SAFI_FLOWSPEC: |
107 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
108 | default: |
109 | /* not expected */ | |
110 | return BGP_IPV4_NODE; | |
111 | break; | |
d62a17ae | 112 | } |
113 | break; | |
114 | case AFI_L2VPN: | |
115 | return BGP_EVPN_NODE; | |
116 | break; | |
117 | case AFI_MAX: | |
118 | // We should never be here but to clarify the switch statement.. | |
119 | return BGP_IPV4_NODE; | |
120 | break; | |
121 | } | |
122 | ||
123 | // Impossible to happen | |
124 | return BGP_IPV4_NODE; | |
f51bae9c | 125 | } |
20eb8864 | 126 | |
718e3744 | 127 | /* Utility function to get address family from current node. */ |
d62a17ae | 128 | afi_t bgp_node_afi(struct vty *vty) |
129 | { | |
130 | afi_t afi; | |
131 | switch (vty->node) { | |
132 | case BGP_IPV6_NODE: | |
133 | case BGP_IPV6M_NODE: | |
134 | case BGP_IPV6L_NODE: | |
135 | case BGP_VPNV6_NODE: | |
7c40bf39 | 136 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 137 | afi = AFI_IP6; |
138 | break; | |
139 | case BGP_EVPN_NODE: | |
140 | afi = AFI_L2VPN; | |
141 | break; | |
142 | default: | |
143 | afi = AFI_IP; | |
144 | break; | |
145 | } | |
146 | return afi; | |
718e3744 | 147 | } |
148 | ||
149 | /* Utility function to get subsequent address family from current | |
150 | node. */ | |
d62a17ae | 151 | safi_t bgp_node_safi(struct vty *vty) |
152 | { | |
153 | safi_t safi; | |
154 | switch (vty->node) { | |
155 | case BGP_VPNV4_NODE: | |
156 | case BGP_VPNV6_NODE: | |
157 | safi = SAFI_MPLS_VPN; | |
158 | break; | |
159 | case BGP_IPV4M_NODE: | |
160 | case BGP_IPV6M_NODE: | |
161 | safi = SAFI_MULTICAST; | |
162 | break; | |
163 | case BGP_EVPN_NODE: | |
164 | safi = SAFI_EVPN; | |
165 | break; | |
166 | case BGP_IPV4L_NODE: | |
167 | case BGP_IPV6L_NODE: | |
168 | safi = SAFI_LABELED_UNICAST; | |
169 | break; | |
7c40bf39 | 170 | case BGP_FLOWSPECV4_NODE: |
171 | case BGP_FLOWSPECV6_NODE: | |
172 | safi = SAFI_FLOWSPEC; | |
173 | break; | |
d62a17ae | 174 | default: |
175 | safi = SAFI_UNICAST; | |
176 | break; | |
177 | } | |
178 | return safi; | |
718e3744 | 179 | } |
180 | ||
55f91488 QY |
181 | /** |
182 | * Converts an AFI in string form to afi_t | |
183 | * | |
184 | * @param afi string, one of | |
185 | * - "ipv4" | |
186 | * - "ipv6" | |
187 | * @return the corresponding afi_t | |
188 | */ | |
d62a17ae | 189 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
190 | { | |
191 | afi_t afi = AFI_MAX; /* unknown */ | |
192 | if (strmatch(afi_str, "ipv4")) | |
193 | afi = AFI_IP; | |
194 | else if (strmatch(afi_str, "ipv6")) | |
195 | afi = AFI_IP6; | |
196 | return afi; | |
197 | } | |
198 | ||
199 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
200 | afi_t *afi) | |
201 | { | |
202 | int ret = 0; | |
203 | if (argv_find(argv, argc, "ipv4", index)) { | |
204 | ret = 1; | |
205 | if (afi) | |
206 | *afi = AFI_IP; | |
207 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
208 | ret = 1; | |
209 | if (afi) | |
210 | *afi = AFI_IP6; | |
211 | } | |
212 | return ret; | |
46f296b4 LB |
213 | } |
214 | ||
375a2e67 | 215 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 216 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
217 | { | |
218 | safi_t safi = SAFI_MAX; /* unknown */ | |
219 | if (strmatch(safi_str, "multicast")) | |
220 | safi = SAFI_MULTICAST; | |
221 | else if (strmatch(safi_str, "unicast")) | |
222 | safi = SAFI_UNICAST; | |
223 | else if (strmatch(safi_str, "vpn")) | |
224 | safi = SAFI_MPLS_VPN; | |
225 | else if (strmatch(safi_str, "labeled-unicast")) | |
226 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 227 | else if (strmatch(safi_str, "flowspec")) |
228 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 229 | return safi; |
230 | } | |
231 | ||
232 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
233 | safi_t *safi) | |
234 | { | |
235 | int ret = 0; | |
236 | if (argv_find(argv, argc, "unicast", index)) { | |
237 | ret = 1; | |
238 | if (safi) | |
239 | *safi = SAFI_UNICAST; | |
240 | } else if (argv_find(argv, argc, "multicast", index)) { | |
241 | ret = 1; | |
242 | if (safi) | |
243 | *safi = SAFI_MULTICAST; | |
244 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
245 | ret = 1; | |
246 | if (safi) | |
247 | *safi = SAFI_LABELED_UNICAST; | |
248 | } else if (argv_find(argv, argc, "vpn", index)) { | |
249 | ret = 1; | |
250 | if (safi) | |
251 | *safi = SAFI_MPLS_VPN; | |
7c40bf39 | 252 | } else if (argv_find(argv, argc, "flowspec", index)) { |
253 | ret = 1; | |
254 | if (safi) | |
255 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 256 | } |
257 | return ret; | |
46f296b4 LB |
258 | } |
259 | ||
7eeee51e | 260 | /* |
f212a857 | 261 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 262 | * |
f212a857 DS |
263 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
264 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
265 | * to appropriate values for the calling function. This is to allow the |
266 | * calling function to make decisions appropriate for the show command | |
267 | * that is being parsed. | |
268 | * | |
269 | * The show commands are generally of the form: | |
d62a17ae | 270 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
271 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
272 | * |
273 | * Since we use argv_find if the show command in particular doesn't have: | |
274 | * [ip] | |
18c57037 | 275 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 276 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
277 | * The command parsing should still be ok. |
278 | * | |
279 | * vty -> The vty for the command so we can output some useful data in | |
280 | * the event of a parse error in the vrf. | |
281 | * argv -> The command tokens | |
282 | * argc -> How many command tokens we have | |
d62a17ae | 283 | * idx -> The current place in the command, generally should be 0 for this |
284 | * function | |
7eeee51e DS |
285 | * afi -> The parsed afi if it was included in the show command, returned here |
286 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 287 | * bgp -> Pointer to the bgp data structure we need to fill in. |
7eeee51e DS |
288 | * |
289 | * The function returns the correct location in the parse tree for the | |
290 | * last token found. | |
0e37c258 DS |
291 | * |
292 | * Returns 0 for failure to parse correctly, else the idx position of where | |
293 | * it found the last token. | |
7eeee51e | 294 | */ |
d62a17ae | 295 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
296 | struct cmd_token **argv, int argc, | |
297 | int *idx, afi_t *afi, safi_t *safi, | |
298 | struct bgp **bgp) | |
299 | { | |
300 | char *vrf_name = NULL; | |
301 | ||
302 | assert(afi); | |
303 | assert(safi); | |
304 | assert(bgp); | |
305 | ||
306 | if (argv_find(argv, argc, "ip", idx)) | |
307 | *afi = AFI_IP; | |
308 | ||
309 | if (argv_find(argv, argc, "view", idx) | |
310 | || argv_find(argv, argc, "vrf", idx)) { | |
311 | vrf_name = argv[*idx + 1]->arg; | |
312 | ||
313 | if (strmatch(vrf_name, "all")) | |
314 | *bgp = NULL; | |
315 | else { | |
316 | *bgp = bgp_lookup_by_name(vrf_name); | |
317 | if (!*bgp) { | |
318 | vty_out(vty, | |
319 | "View/Vrf specified is unknown: %s\n", | |
320 | vrf_name); | |
321 | *idx = 0; | |
322 | return 0; | |
323 | } | |
324 | } | |
325 | } else { | |
326 | *bgp = bgp_get_default(); | |
327 | if (!*bgp) { | |
328 | vty_out(vty, "Unable to find default BGP instance\n"); | |
329 | *idx = 0; | |
330 | return 0; | |
331 | } | |
332 | } | |
333 | ||
334 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
335 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
336 | ||
337 | *idx += 1; | |
338 | return *idx; | |
339 | } | |
340 | ||
341 | static int peer_address_self_check(struct bgp *bgp, union sockunion *su) | |
342 | { | |
343 | struct interface *ifp = NULL; | |
344 | ||
345 | if (su->sa.sa_family == AF_INET) | |
346 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
347 | else if (su->sa.sa_family == AF_INET6) | |
348 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
349 | su->sin6.sin6_scope_id, | |
350 | bgp->vrf_id); | |
351 | ||
352 | if (ifp) | |
353 | return 1; | |
354 | ||
355 | return 0; | |
718e3744 | 356 | } |
357 | ||
358 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
359 | /* This is used only for configuration, so disallow if attempted on |
360 | * a dynamic neighbor. | |
361 | */ | |
d62a17ae | 362 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
363 | { | |
364 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
365 | int ret; | |
366 | union sockunion su; | |
367 | struct peer *peer; | |
368 | ||
369 | if (!bgp) { | |
370 | return NULL; | |
371 | } | |
372 | ||
373 | ret = str2sockunion(ip_str, &su); | |
374 | if (ret < 0) { | |
375 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
376 | if (!peer) { | |
377 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
378 | == NULL) { | |
379 | vty_out(vty, | |
380 | "%% Malformed address or name: %s\n", | |
381 | ip_str); | |
382 | return NULL; | |
383 | } | |
384 | } | |
385 | } else { | |
386 | peer = peer_lookup(bgp, &su); | |
387 | if (!peer) { | |
388 | vty_out(vty, | |
389 | "%% Specify remote-as or peer-group commands first\n"); | |
390 | return NULL; | |
391 | } | |
392 | if (peer_dynamic_neighbor(peer)) { | |
393 | vty_out(vty, | |
394 | "%% Operation not allowed on a dynamic neighbor\n"); | |
395 | return NULL; | |
396 | } | |
397 | } | |
398 | return peer; | |
718e3744 | 399 | } |
400 | ||
401 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
402 | /* This is used only for configuration, so disallow if attempted on |
403 | * a dynamic neighbor. | |
404 | */ | |
d62a17ae | 405 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
406 | { | |
407 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
408 | int ret; | |
409 | union sockunion su; | |
410 | struct peer *peer = NULL; | |
411 | struct peer_group *group = NULL; | |
412 | ||
413 | if (!bgp) { | |
414 | return NULL; | |
415 | } | |
416 | ||
417 | ret = str2sockunion(peer_str, &su); | |
418 | if (ret == 0) { | |
419 | /* IP address, locate peer. */ | |
420 | peer = peer_lookup(bgp, &su); | |
421 | } else { | |
422 | /* Not IP, could match either peer configured on interface or a | |
423 | * group. */ | |
424 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
425 | if (!peer) | |
426 | group = peer_group_lookup(bgp, peer_str); | |
427 | } | |
428 | ||
429 | if (peer) { | |
430 | if (peer_dynamic_neighbor(peer)) { | |
431 | vty_out(vty, | |
432 | "%% Operation not allowed on a dynamic neighbor\n"); | |
433 | return NULL; | |
434 | } | |
435 | ||
436 | return peer; | |
437 | } | |
438 | ||
439 | if (group) | |
440 | return group->conf; | |
441 | ||
442 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
443 | ||
444 | return NULL; | |
445 | } | |
446 | ||
447 | int bgp_vty_return(struct vty *vty, int ret) | |
448 | { | |
449 | const char *str = NULL; | |
450 | ||
451 | switch (ret) { | |
452 | case BGP_ERR_INVALID_VALUE: | |
453 | str = "Invalid value"; | |
454 | break; | |
455 | case BGP_ERR_INVALID_FLAG: | |
456 | str = "Invalid flag"; | |
457 | break; | |
458 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
459 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
460 | break; | |
461 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
462 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
463 | break; | |
464 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
465 | str = "Specify remote-as or peer-group remote AS first"; | |
466 | break; | |
467 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
468 | str = "Cannot change the peer-group. Deconfigure first"; | |
469 | break; | |
470 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
471 | str = "Peer is not a member of this peer-group"; | |
472 | break; | |
473 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
474 | str = "Prefix/distribute list can not co-exist"; | |
475 | break; | |
476 | case BGP_ERR_NOT_INTERNAL_PEER: | |
477 | str = "Invalid command. Not an internal neighbor"; | |
478 | break; | |
479 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
480 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
481 | break; | |
482 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
483 | str = "Local-AS allowed only for EBGP peers"; | |
484 | break; | |
485 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
486 | str = "Cannot have local-as same as BGP AS number"; | |
487 | break; | |
488 | case BGP_ERR_TCPSIG_FAILED: | |
489 | str = "Error while applying TCP-Sig to session(s)"; | |
490 | break; | |
491 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
492 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
493 | break; | |
494 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
495 | str = "ttl-security only allowed for EBGP peers"; | |
496 | break; | |
497 | case BGP_ERR_AS_OVERRIDE: | |
498 | str = "as-override cannot be configured for IBGP peers"; | |
499 | break; | |
500 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
501 | str = "Invalid limit for number of dynamic neighbors"; | |
502 | break; | |
503 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
504 | str = "Dynamic neighbor listen range already exists"; | |
505 | break; | |
506 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
507 | str = "Operation not allowed on a dynamic neighbor"; | |
508 | break; | |
509 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
510 | str = "Operation not allowed on a directly connected neighbor"; | |
511 | break; | |
512 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
513 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; | |
514 | break; | |
515 | } | |
516 | if (str) { | |
517 | vty_out(vty, "%% %s\n", str); | |
518 | return CMD_WARNING_CONFIG_FAILED; | |
519 | } | |
520 | return CMD_SUCCESS; | |
718e3744 | 521 | } |
522 | ||
7aafcaca | 523 | /* BGP clear sort. */ |
d62a17ae | 524 | enum clear_sort { |
525 | clear_all, | |
526 | clear_peer, | |
527 | clear_group, | |
528 | clear_external, | |
529 | clear_as | |
7aafcaca DS |
530 | }; |
531 | ||
d62a17ae | 532 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
533 | safi_t safi, int error) | |
534 | { | |
535 | switch (error) { | |
536 | case BGP_ERR_AF_UNCONFIGURED: | |
537 | vty_out(vty, | |
538 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
539 | afi_safi_print(afi, safi), peer->host); | |
540 | break; | |
541 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
542 | vty_out(vty, | |
543 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
544 | peer->host); | |
545 | break; | |
546 | default: | |
547 | break; | |
548 | } | |
7aafcaca DS |
549 | } |
550 | ||
551 | /* `clear ip bgp' functions. */ | |
d62a17ae | 552 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
553 | enum clear_sort sort, enum bgp_clear_type stype, | |
554 | const char *arg) | |
555 | { | |
556 | int ret; | |
3ae8bfa5 | 557 | bool found = false; |
d62a17ae | 558 | struct peer *peer; |
559 | struct listnode *node, *nnode; | |
560 | ||
561 | /* Clear all neighbors. */ | |
562 | /* | |
563 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
564 | * nodes on the BGP instance as that may get freed if it is a |
565 | * doppelganger | |
d62a17ae | 566 | */ |
567 | if (sort == clear_all) { | |
568 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
3ae8bfa5 PM |
569 | if (!peer->afc[afi][safi]) |
570 | continue; | |
571 | ||
d62a17ae | 572 | if (stype == BGP_CLEAR_SOFT_NONE) |
573 | ret = peer_clear(peer, &nnode); | |
d62a17ae | 574 | else |
3ae8bfa5 | 575 | ret = peer_clear_soft(peer, afi, safi, stype); |
d62a17ae | 576 | |
577 | if (ret < 0) | |
578 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
579 | else |
580 | found = true; | |
04b6bdc0 | 581 | } |
d62a17ae | 582 | |
583 | /* This is to apply read-only mode on this clear. */ | |
584 | if (stype == BGP_CLEAR_SOFT_NONE) | |
585 | bgp->update_delay_over = 0; | |
586 | ||
3ae8bfa5 PM |
587 | if (!found) |
588 | vty_out(vty, "%%BGP: No %s peer configured", | |
589 | afi_safi_print(afi, safi)); | |
590 | ||
d62a17ae | 591 | return CMD_SUCCESS; |
7aafcaca DS |
592 | } |
593 | ||
3ae8bfa5 | 594 | /* Clear specified neighbor. */ |
d62a17ae | 595 | if (sort == clear_peer) { |
596 | union sockunion su; | |
d62a17ae | 597 | |
598 | /* Make sockunion for lookup. */ | |
599 | ret = str2sockunion(arg, &su); | |
600 | if (ret < 0) { | |
601 | peer = peer_lookup_by_conf_if(bgp, arg); | |
602 | if (!peer) { | |
603 | peer = peer_lookup_by_hostname(bgp, arg); | |
604 | if (!peer) { | |
605 | vty_out(vty, | |
606 | "Malformed address or name: %s\n", | |
607 | arg); | |
608 | return CMD_WARNING; | |
609 | } | |
610 | } | |
611 | } else { | |
612 | peer = peer_lookup(bgp, &su); | |
613 | if (!peer) { | |
614 | vty_out(vty, | |
615 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
616 | arg); | |
617 | return CMD_WARNING; | |
618 | } | |
619 | } | |
7aafcaca | 620 | |
3ae8bfa5 PM |
621 | if (!peer->afc[afi][safi]) |
622 | ret = BGP_ERR_AF_UNCONFIGURED; | |
623 | else if (stype == BGP_CLEAR_SOFT_NONE) | |
d62a17ae | 624 | ret = peer_clear(peer, NULL); |
625 | else | |
626 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 627 | |
d62a17ae | 628 | if (ret < 0) |
629 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 630 | |
d62a17ae | 631 | return CMD_SUCCESS; |
7aafcaca | 632 | } |
7aafcaca | 633 | |
3ae8bfa5 | 634 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 635 | if (sort == clear_group) { |
636 | struct peer_group *group; | |
7aafcaca | 637 | |
d62a17ae | 638 | group = peer_group_lookup(bgp, arg); |
639 | if (!group) { | |
640 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
641 | return CMD_WARNING; | |
642 | } | |
643 | ||
644 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
d62a17ae | 645 | if (!peer->afc[afi][safi]) |
646 | continue; | |
647 | ||
3ae8bfa5 PM |
648 | if (stype == BGP_CLEAR_SOFT_NONE) |
649 | ret = peer_clear(peer, NULL); | |
650 | else | |
651 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 652 | |
d62a17ae | 653 | if (ret < 0) |
654 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
655 | else |
656 | found = true; | |
d62a17ae | 657 | } |
3ae8bfa5 PM |
658 | |
659 | if (!found) | |
660 | vty_out(vty, | |
661 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
662 | afi_safi_print(afi, safi), arg); | |
663 | ||
d62a17ae | 664 | return CMD_SUCCESS; |
7aafcaca | 665 | } |
7aafcaca | 666 | |
3ae8bfa5 | 667 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 668 | if (sort == clear_external) { |
669 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
670 | if (peer->sort == BGP_PEER_IBGP) | |
671 | continue; | |
7aafcaca | 672 | |
3ae8bfa5 PM |
673 | if (!peer->afc[afi][safi]) |
674 | continue; | |
675 | ||
d62a17ae | 676 | if (stype == BGP_CLEAR_SOFT_NONE) |
677 | ret = peer_clear(peer, &nnode); | |
678 | else | |
679 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 680 | |
d62a17ae | 681 | if (ret < 0) |
682 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
683 | else |
684 | found = true; | |
d62a17ae | 685 | } |
3ae8bfa5 PM |
686 | |
687 | if (!found) | |
688 | vty_out(vty, | |
689 | "%%BGP: No external %s peer is configured\n", | |
690 | afi_safi_print(afi, safi)); | |
691 | ||
d62a17ae | 692 | return CMD_SUCCESS; |
693 | } | |
694 | ||
3ae8bfa5 | 695 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 696 | if (sort == clear_as) { |
3ae8bfa5 | 697 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 698 | |
699 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
700 | if (peer->as != as) | |
701 | continue; | |
702 | ||
3ae8bfa5 PM |
703 | if (!peer->afc[afi][safi]) |
704 | ret = BGP_ERR_AF_UNCONFIGURED; | |
705 | else if (stype == BGP_CLEAR_SOFT_NONE) | |
d62a17ae | 706 | ret = peer_clear(peer, &nnode); |
707 | else | |
708 | ret = peer_clear_soft(peer, afi, safi, stype); | |
709 | ||
710 | if (ret < 0) | |
711 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
712 | else |
713 | found = true; | |
d62a17ae | 714 | } |
3ae8bfa5 PM |
715 | |
716 | if (!found) | |
d62a17ae | 717 | vty_out(vty, |
3ae8bfa5 PM |
718 | "%%BGP: No %s peer is configured with AS %s\n", |
719 | afi_safi_print(afi, safi), arg); | |
720 | ||
d62a17ae | 721 | return CMD_SUCCESS; |
722 | } | |
723 | ||
724 | return CMD_SUCCESS; | |
725 | } | |
726 | ||
727 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
728 | safi_t safi, enum clear_sort sort, | |
729 | enum bgp_clear_type stype, const char *arg) | |
730 | { | |
731 | struct bgp *bgp; | |
732 | ||
733 | /* BGP structure lookup. */ | |
734 | if (name) { | |
735 | bgp = bgp_lookup_by_name(name); | |
736 | if (bgp == NULL) { | |
737 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
738 | return CMD_WARNING; | |
739 | } | |
740 | } else { | |
741 | bgp = bgp_get_default(); | |
742 | if (bgp == NULL) { | |
743 | vty_out(vty, "No BGP process is configured\n"); | |
744 | return CMD_WARNING; | |
745 | } | |
746 | } | |
747 | ||
748 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
749 | } |
750 | ||
751 | /* clear soft inbound */ | |
d62a17ae | 752 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 753 | { |
d62a17ae | 754 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
755 | BGP_CLEAR_SOFT_IN, NULL); | |
756 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
757 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
758 | } |
759 | ||
760 | /* clear soft outbound */ | |
d62a17ae | 761 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 762 | { |
d62a17ae | 763 | bgp_clear_vty(vty, name, AFI_IP, SAFI_UNICAST, clear_all, |
764 | BGP_CLEAR_SOFT_OUT, NULL); | |
765 | bgp_clear_vty(vty, name, AFI_IP6, SAFI_UNICAST, clear_all, | |
766 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
767 | } |
768 | ||
769 | ||
f787d7a0 | 770 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 771 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
772 | #endif |
773 | ||
718e3744 | 774 | /* BGP global configuration. */ |
1cc40660 DS |
775 | #if defined(VERSION_TYPE_DEV) && (CONFDATE > 20190601) |
776 | CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance") | |
777 | CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE") | |
778 | #endif | |
779 | DEFUN_HIDDEN (bgp_multiple_instance_func, | |
780 | bgp_multiple_instance_cmd, | |
781 | "bgp multiple-instance", | |
782 | BGP_STR | |
783 | "Enable bgp multiple instance\n") | |
718e3744 | 784 | { |
d62a17ae | 785 | bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE); |
786 | return CMD_SUCCESS; | |
718e3744 | 787 | } |
788 | ||
1cc40660 | 789 | DEFUN_HIDDEN (no_bgp_multiple_instance, |
718e3744 | 790 | no_bgp_multiple_instance_cmd, |
791 | "no bgp multiple-instance", | |
792 | NO_STR | |
793 | BGP_STR | |
794 | "BGP multiple instance\n") | |
795 | { | |
d62a17ae | 796 | int ret; |
718e3744 | 797 | |
1cc40660 DS |
798 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); |
799 | vty_out(vty, "if you are using this please let the developers know\n"); | |
800 | zlog_warn("Deprecated option: `bgp multiple-instance` being used"); | |
d62a17ae | 801 | ret = bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE); |
802 | if (ret < 0) { | |
803 | vty_out(vty, "%% There are more than two BGP instances\n"); | |
804 | return CMD_WARNING_CONFIG_FAILED; | |
805 | } | |
806 | return CMD_SUCCESS; | |
718e3744 | 807 | } |
808 | ||
798467a2 DS |
809 | #if defined(VERSION_TYPE_DEV) && (CONFDATE > 20190601) |
810 | CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco") | |
811 | CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG") | |
812 | #endif | |
813 | DEFUN_HIDDEN (bgp_config_type, | |
814 | bgp_config_type_cmd, | |
815 | "bgp config-type <cisco|zebra>", | |
816 | BGP_STR | |
817 | "Configuration type\n" | |
818 | "cisco\n" | |
819 | "zebra\n") | |
718e3744 | 820 | { |
d62a17ae | 821 | int idx = 0; |
798467a2 DS |
822 | if (argv_find(argv, argc, "cisco", &idx)) { |
823 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
824 | vty_out(vty, "if you are using this please let the developers know!\n"); | |
825 | zlog_warn("Deprecated option: `bgp config-type cisco` being used"); | |
d62a17ae | 826 | bgp_option_set(BGP_OPT_CONFIG_CISCO); |
798467a2 | 827 | } else |
d62a17ae | 828 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
718e3744 | 829 | |
d62a17ae | 830 | return CMD_SUCCESS; |
718e3744 | 831 | } |
832 | ||
798467a2 DS |
833 | DEFUN_HIDDEN (no_bgp_config_type, |
834 | no_bgp_config_type_cmd, | |
835 | "no bgp config-type [<cisco|zebra>]", | |
836 | NO_STR | |
837 | BGP_STR | |
838 | "Display configuration type\n" | |
839 | "cisco\n" | |
840 | "zebra\n") | |
718e3744 | 841 | { |
d62a17ae | 842 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
843 | return CMD_SUCCESS; | |
718e3744 | 844 | } |
845 | ||
813d4307 | 846 | |
718e3744 | 847 | DEFUN (no_synchronization, |
848 | no_synchronization_cmd, | |
849 | "no synchronization", | |
850 | NO_STR | |
851 | "Perform IGP synchronization\n") | |
852 | { | |
d62a17ae | 853 | return CMD_SUCCESS; |
718e3744 | 854 | } |
855 | ||
856 | DEFUN (no_auto_summary, | |
857 | no_auto_summary_cmd, | |
858 | "no auto-summary", | |
859 | NO_STR | |
860 | "Enable automatic network number summarization\n") | |
861 | { | |
d62a17ae | 862 | return CMD_SUCCESS; |
718e3744 | 863 | } |
3d515fd9 | 864 | |
718e3744 | 865 | /* "router bgp" commands. */ |
505e5056 | 866 | DEFUN_NOSH (router_bgp, |
f412b39a | 867 | router_bgp_cmd, |
18c57037 | 868 | "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 869 | ROUTER_STR |
870 | BGP_STR | |
31500417 DW |
871 | AS_STR |
872 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 873 | { |
d62a17ae | 874 | int idx_asn = 2; |
875 | int idx_view_vrf = 3; | |
876 | int idx_vrf = 4; | |
877 | int ret; | |
878 | as_t as; | |
879 | struct bgp *bgp; | |
880 | const char *name = NULL; | |
881 | enum bgp_instance_type inst_type; | |
882 | ||
883 | // "router bgp" without an ASN | |
884 | if (argc == 2) { | |
885 | // Pending: Make VRF option available for ASN less config | |
886 | bgp = bgp_get_default(); | |
887 | ||
888 | if (bgp == NULL) { | |
889 | vty_out(vty, "%% No BGP process is configured\n"); | |
890 | return CMD_WARNING_CONFIG_FAILED; | |
891 | } | |
892 | ||
893 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 894 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 895 | return CMD_WARNING_CONFIG_FAILED; |
896 | } | |
897 | } | |
898 | ||
899 | // "router bgp X" | |
900 | else { | |
901 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
902 | ||
903 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
904 | if (argc > 3) { | |
905 | name = argv[idx_vrf]->arg; | |
906 | ||
907 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) | |
908 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
909 | else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
910 | inst_type = BGP_INSTANCE_TYPE_VIEW; | |
911 | } | |
912 | ||
913 | ret = bgp_get(&bgp, &as, name, inst_type); | |
914 | switch (ret) { | |
915 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
916 | vty_out(vty, | |
917 | "Please specify 'bgp multiple-instance' first\n"); | |
918 | return CMD_WARNING_CONFIG_FAILED; | |
919 | case BGP_ERR_AS_MISMATCH: | |
920 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
921 | return CMD_WARNING_CONFIG_FAILED; | |
922 | case BGP_ERR_INSTANCE_MISMATCH: | |
923 | vty_out(vty, | |
924 | "BGP instance name and AS number mismatch\n"); | |
925 | vty_out(vty, | |
926 | "BGP instance is already running; AS is %u\n", | |
927 | as); | |
928 | return CMD_WARNING_CONFIG_FAILED; | |
929 | } | |
930 | ||
931 | /* Pending: handle when user tries to change a view to vrf n vv. | |
932 | */ | |
933 | } | |
934 | ||
0b5131c9 MK |
935 | /* unset the auto created flag as the user config is now present */ |
936 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 937 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
938 | ||
939 | return CMD_SUCCESS; | |
718e3744 | 940 | } |
941 | ||
718e3744 | 942 | /* "no router bgp" commands. */ |
943 | DEFUN (no_router_bgp, | |
944 | no_router_bgp_cmd, | |
18c57037 | 945 | "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 946 | NO_STR |
947 | ROUTER_STR | |
948 | BGP_STR | |
31500417 DW |
949 | AS_STR |
950 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 951 | { |
d62a17ae | 952 | int idx_asn = 3; |
953 | int idx_vrf = 5; | |
954 | as_t as; | |
955 | struct bgp *bgp; | |
956 | const char *name = NULL; | |
718e3744 | 957 | |
d62a17ae | 958 | // "no router bgp" without an ASN |
959 | if (argc == 3) { | |
960 | // Pending: Make VRF option available for ASN less config | |
961 | bgp = bgp_get_default(); | |
718e3744 | 962 | |
d62a17ae | 963 | if (bgp == NULL) { |
964 | vty_out(vty, "%% No BGP process is configured\n"); | |
965 | return CMD_WARNING_CONFIG_FAILED; | |
966 | } | |
7fb21a9f | 967 | |
d62a17ae | 968 | if (listcount(bm->bgp) > 1) { |
996c9314 | 969 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 970 | return CMD_WARNING_CONFIG_FAILED; |
971 | } | |
0b5131c9 MK |
972 | |
973 | if (bgp->l3vni) { | |
974 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
975 | bgp->l3vni); | |
976 | return CMD_WARNING_CONFIG_FAILED; | |
977 | } | |
d62a17ae | 978 | } else { |
979 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 980 | |
d62a17ae | 981 | if (argc > 4) |
982 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 983 | |
d62a17ae | 984 | /* Lookup bgp structure. */ |
985 | bgp = bgp_lookup(as, name); | |
986 | if (!bgp) { | |
987 | vty_out(vty, "%% Can't find BGP instance\n"); | |
988 | return CMD_WARNING_CONFIG_FAILED; | |
989 | } | |
0b5131c9 MK |
990 | |
991 | if (bgp->l3vni) { | |
992 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
993 | bgp->l3vni); | |
994 | return CMD_WARNING_CONFIG_FAILED; | |
995 | } | |
d62a17ae | 996 | } |
718e3744 | 997 | |
d62a17ae | 998 | bgp_delete(bgp); |
718e3744 | 999 | |
d62a17ae | 1000 | return CMD_SUCCESS; |
718e3744 | 1001 | } |
1002 | ||
6b0655a2 | 1003 | |
718e3744 | 1004 | /* BGP router-id. */ |
1005 | ||
f787d7a0 | 1006 | DEFPY (bgp_router_id, |
718e3744 | 1007 | bgp_router_id_cmd, |
1008 | "bgp router-id A.B.C.D", | |
1009 | BGP_STR | |
1010 | "Override configured router identifier\n" | |
1011 | "Manually configured router identifier\n") | |
1012 | { | |
d62a17ae | 1013 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1014 | bgp_router_id_static_set(bgp, router_id); | |
1015 | return CMD_SUCCESS; | |
718e3744 | 1016 | } |
1017 | ||
f787d7a0 | 1018 | DEFPY (no_bgp_router_id, |
718e3744 | 1019 | no_bgp_router_id_cmd, |
31500417 | 1020 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1021 | NO_STR |
1022 | BGP_STR | |
31500417 DW |
1023 | "Override configured router identifier\n" |
1024 | "Manually configured router identifier\n") | |
718e3744 | 1025 | { |
d62a17ae | 1026 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1027 | |
d62a17ae | 1028 | if (router_id_str) { |
1029 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1030 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1031 | return CMD_WARNING_CONFIG_FAILED; | |
1032 | } | |
e018c7cc | 1033 | } |
718e3744 | 1034 | |
d62a17ae | 1035 | router_id.s_addr = 0; |
1036 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1037 | |
d62a17ae | 1038 | return CMD_SUCCESS; |
718e3744 | 1039 | } |
1040 | ||
6b0655a2 | 1041 | |
718e3744 | 1042 | /* BGP Cluster ID. */ |
718e3744 | 1043 | DEFUN (bgp_cluster_id, |
1044 | bgp_cluster_id_cmd, | |
838758ac | 1045 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1046 | BGP_STR |
1047 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1048 | "Route-Reflector Cluster-id in IP address format\n" |
1049 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1050 | { |
d62a17ae | 1051 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1052 | int idx_ipv4 = 2; | |
1053 | int ret; | |
1054 | struct in_addr cluster; | |
718e3744 | 1055 | |
d62a17ae | 1056 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1057 | if (!ret) { | |
1058 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1059 | return CMD_WARNING_CONFIG_FAILED; | |
1060 | } | |
718e3744 | 1061 | |
d62a17ae | 1062 | bgp_cluster_id_set(bgp, &cluster); |
1063 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1064 | |
d62a17ae | 1065 | return CMD_SUCCESS; |
718e3744 | 1066 | } |
1067 | ||
718e3744 | 1068 | DEFUN (no_bgp_cluster_id, |
1069 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1070 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1071 | NO_STR |
1072 | BGP_STR | |
838758ac DW |
1073 | "Configure Route-Reflector Cluster-id\n" |
1074 | "Route-Reflector Cluster-id in IP address format\n" | |
1075 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1076 | { |
d62a17ae | 1077 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1078 | bgp_cluster_id_unset(bgp); | |
1079 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1080 | |
d62a17ae | 1081 | return CMD_SUCCESS; |
718e3744 | 1082 | } |
1083 | ||
718e3744 | 1084 | DEFUN (bgp_confederation_identifier, |
1085 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1086 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1087 | "BGP specific commands\n" |
1088 | "AS confederation parameters\n" | |
1089 | "AS number\n" | |
1090 | "Set routing domain confederation AS\n") | |
1091 | { | |
d62a17ae | 1092 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1093 | int idx_number = 3; | |
1094 | as_t as; | |
718e3744 | 1095 | |
d62a17ae | 1096 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1097 | |
d62a17ae | 1098 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1099 | |
d62a17ae | 1100 | return CMD_SUCCESS; |
718e3744 | 1101 | } |
1102 | ||
1103 | DEFUN (no_bgp_confederation_identifier, | |
1104 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1105 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1106 | NO_STR |
1107 | "BGP specific commands\n" | |
1108 | "AS confederation parameters\n" | |
3a2d747c QY |
1109 | "AS number\n" |
1110 | "Set routing domain confederation AS\n") | |
718e3744 | 1111 | { |
d62a17ae | 1112 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1113 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1114 | |
d62a17ae | 1115 | return CMD_SUCCESS; |
718e3744 | 1116 | } |
1117 | ||
718e3744 | 1118 | DEFUN (bgp_confederation_peers, |
1119 | bgp_confederation_peers_cmd, | |
12dcf78e | 1120 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1121 | "BGP specific commands\n" |
1122 | "AS confederation parameters\n" | |
1123 | "Peer ASs in BGP confederation\n" | |
1124 | AS_STR) | |
1125 | { | |
d62a17ae | 1126 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1127 | int idx_asn = 3; | |
1128 | as_t as; | |
1129 | int i; | |
718e3744 | 1130 | |
d62a17ae | 1131 | for (i = idx_asn; i < argc; i++) { |
1132 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1133 | |
d62a17ae | 1134 | if (bgp->as == as) { |
1135 | vty_out(vty, | |
1136 | "%% Local member-AS not allowed in confed peer list\n"); | |
1137 | continue; | |
1138 | } | |
718e3744 | 1139 | |
d62a17ae | 1140 | bgp_confederation_peers_add(bgp, as); |
1141 | } | |
1142 | return CMD_SUCCESS; | |
718e3744 | 1143 | } |
1144 | ||
1145 | DEFUN (no_bgp_confederation_peers, | |
1146 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1147 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1148 | NO_STR |
1149 | "BGP specific commands\n" | |
1150 | "AS confederation parameters\n" | |
1151 | "Peer ASs in BGP confederation\n" | |
1152 | AS_STR) | |
1153 | { | |
d62a17ae | 1154 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1155 | int idx_asn = 4; | |
1156 | as_t as; | |
1157 | int i; | |
718e3744 | 1158 | |
d62a17ae | 1159 | for (i = idx_asn; i < argc; i++) { |
1160 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1161 | |
d62a17ae | 1162 | bgp_confederation_peers_remove(bgp, as); |
1163 | } | |
1164 | return CMD_SUCCESS; | |
718e3744 | 1165 | } |
6b0655a2 | 1166 | |
5e242b0d DS |
1167 | /** |
1168 | * Central routine for maximum-paths configuration. | |
1169 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1170 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1171 | */ | |
d62a17ae | 1172 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1173 | const char *mpaths, uint16_t options, |
d62a17ae | 1174 | int set) |
1175 | { | |
1176 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1177 | uint16_t maxpaths = 0; |
d62a17ae | 1178 | int ret; |
1179 | afi_t afi; | |
1180 | safi_t safi; | |
1181 | ||
1182 | afi = bgp_node_afi(vty); | |
1183 | safi = bgp_node_safi(vty); | |
1184 | ||
1185 | if (set) { | |
1186 | maxpaths = strtol(mpaths, NULL, 10); | |
1187 | if (maxpaths > multipath_num) { | |
1188 | vty_out(vty, | |
1189 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1190 | maxpaths, multipath_num); | |
1191 | return CMD_WARNING_CONFIG_FAILED; | |
1192 | } | |
1193 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1194 | options); | |
1195 | } else | |
1196 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1197 | ||
1198 | if (ret < 0) { | |
1199 | vty_out(vty, | |
1200 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1201 | (set == 1) ? "" : "un", | |
1202 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1203 | maxpaths, afi, safi); | |
1204 | return CMD_WARNING_CONFIG_FAILED; | |
1205 | } | |
1206 | ||
1207 | bgp_recalculate_all_bestpaths(bgp); | |
1208 | ||
1209 | return CMD_SUCCESS; | |
165b5fff JB |
1210 | } |
1211 | ||
abc920f8 DS |
1212 | DEFUN (bgp_maxmed_admin, |
1213 | bgp_maxmed_admin_cmd, | |
1214 | "bgp max-med administrative ", | |
1215 | BGP_STR | |
1216 | "Advertise routes with max-med\n" | |
1217 | "Administratively applied, for an indefinite period\n") | |
1218 | { | |
d62a17ae | 1219 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1220 | |
d62a17ae | 1221 | bgp->v_maxmed_admin = 1; |
1222 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1223 | |
d62a17ae | 1224 | bgp_maxmed_update(bgp); |
abc920f8 | 1225 | |
d62a17ae | 1226 | return CMD_SUCCESS; |
abc920f8 DS |
1227 | } |
1228 | ||
1229 | DEFUN (bgp_maxmed_admin_medv, | |
1230 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1231 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1232 | BGP_STR |
1233 | "Advertise routes with max-med\n" | |
1234 | "Administratively applied, for an indefinite period\n" | |
1235 | "Max MED value to be used\n") | |
1236 | { | |
d62a17ae | 1237 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1238 | int idx_number = 3; | |
abc920f8 | 1239 | |
d62a17ae | 1240 | bgp->v_maxmed_admin = 1; |
1241 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1242 | |
d62a17ae | 1243 | bgp_maxmed_update(bgp); |
abc920f8 | 1244 | |
d62a17ae | 1245 | return CMD_SUCCESS; |
abc920f8 DS |
1246 | } |
1247 | ||
1248 | DEFUN (no_bgp_maxmed_admin, | |
1249 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1250 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1251 | NO_STR |
1252 | BGP_STR | |
1253 | "Advertise routes with max-med\n" | |
838758ac DW |
1254 | "Administratively applied, for an indefinite period\n" |
1255 | "Max MED value to be used\n") | |
abc920f8 | 1256 | { |
d62a17ae | 1257 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1258 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1259 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1260 | bgp_maxmed_update(bgp); | |
abc920f8 | 1261 | |
d62a17ae | 1262 | return CMD_SUCCESS; |
abc920f8 DS |
1263 | } |
1264 | ||
abc920f8 DS |
1265 | DEFUN (bgp_maxmed_onstartup, |
1266 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1267 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1268 | BGP_STR |
1269 | "Advertise routes with max-med\n" | |
1270 | "Effective on a startup\n" | |
1271 | "Time (seconds) period for max-med\n" | |
1272 | "Max MED value to be used\n") | |
1273 | { | |
d62a17ae | 1274 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1275 | int idx = 0; | |
4668a151 | 1276 | |
d62a17ae | 1277 | argv_find(argv, argc, "(5-86400)", &idx); |
1278 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1279 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1280 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1281 | else | |
1282 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1283 | |
d62a17ae | 1284 | bgp_maxmed_update(bgp); |
abc920f8 | 1285 | |
d62a17ae | 1286 | return CMD_SUCCESS; |
abc920f8 DS |
1287 | } |
1288 | ||
1289 | DEFUN (no_bgp_maxmed_onstartup, | |
1290 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1291 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1292 | NO_STR |
1293 | BGP_STR | |
1294 | "Advertise routes with max-med\n" | |
838758ac DW |
1295 | "Effective on a startup\n" |
1296 | "Time (seconds) period for max-med\n" | |
1297 | "Max MED value to be used\n") | |
abc920f8 | 1298 | { |
d62a17ae | 1299 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1300 | |
d62a17ae | 1301 | /* Cancel max-med onstartup if its on */ |
1302 | if (bgp->t_maxmed_onstartup) { | |
1303 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1304 | bgp->maxmed_onstartup_over = 1; | |
1305 | } | |
abc920f8 | 1306 | |
d62a17ae | 1307 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1308 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1309 | |
d62a17ae | 1310 | bgp_maxmed_update(bgp); |
abc920f8 | 1311 | |
d62a17ae | 1312 | return CMD_SUCCESS; |
abc920f8 DS |
1313 | } |
1314 | ||
d62a17ae | 1315 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1316 | const char *wait) | |
f188f2c4 | 1317 | { |
d62a17ae | 1318 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1319 | uint16_t update_delay; |
1320 | uint16_t establish_wait; | |
f188f2c4 | 1321 | |
d62a17ae | 1322 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1323 | |
d62a17ae | 1324 | if (!wait) /* update-delay <delay> */ |
1325 | { | |
1326 | bgp->v_update_delay = update_delay; | |
1327 | bgp->v_establish_wait = bgp->v_update_delay; | |
1328 | return CMD_SUCCESS; | |
1329 | } | |
f188f2c4 | 1330 | |
d62a17ae | 1331 | /* update-delay <delay> <establish-wait> */ |
1332 | establish_wait = atoi(wait); | |
1333 | if (update_delay < establish_wait) { | |
1334 | vty_out(vty, | |
1335 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1336 | return CMD_WARNING_CONFIG_FAILED; | |
1337 | } | |
f188f2c4 | 1338 | |
d62a17ae | 1339 | bgp->v_update_delay = update_delay; |
1340 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1341 | |
d62a17ae | 1342 | return CMD_SUCCESS; |
f188f2c4 DS |
1343 | } |
1344 | ||
d62a17ae | 1345 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1346 | { |
d62a17ae | 1347 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1348 | |
d62a17ae | 1349 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1350 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1351 | |
d62a17ae | 1352 | return CMD_SUCCESS; |
f188f2c4 DS |
1353 | } |
1354 | ||
2b791107 | 1355 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1356 | { |
d62a17ae | 1357 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1358 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1359 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1360 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1361 | vty_out(vty, "\n"); | |
1362 | } | |
f188f2c4 DS |
1363 | } |
1364 | ||
1365 | ||
1366 | /* Update-delay configuration */ | |
1367 | DEFUN (bgp_update_delay, | |
1368 | bgp_update_delay_cmd, | |
6147e2c6 | 1369 | "update-delay (0-3600)", |
f188f2c4 DS |
1370 | "Force initial delay for best-path and updates\n" |
1371 | "Seconds\n") | |
1372 | { | |
d62a17ae | 1373 | int idx_number = 1; |
1374 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1375 | } |
1376 | ||
1377 | DEFUN (bgp_update_delay_establish_wait, | |
1378 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1379 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1380 | "Force initial delay for best-path and updates\n" |
1381 | "Seconds\n" | |
f188f2c4 DS |
1382 | "Seconds\n") |
1383 | { | |
d62a17ae | 1384 | int idx_number = 1; |
1385 | int idx_number_2 = 2; | |
1386 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1387 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1388 | } |
1389 | ||
1390 | /* Update-delay deconfiguration */ | |
1391 | DEFUN (no_bgp_update_delay, | |
1392 | no_bgp_update_delay_cmd, | |
838758ac DW |
1393 | "no update-delay [(0-3600) [(1-3600)]]", |
1394 | NO_STR | |
f188f2c4 | 1395 | "Force initial delay for best-path and updates\n" |
838758ac | 1396 | "Seconds\n" |
7111c1a0 | 1397 | "Seconds\n") |
f188f2c4 | 1398 | { |
d62a17ae | 1399 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1400 | } |
1401 | ||
5e242b0d | 1402 | |
d62a17ae | 1403 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, const char *num, |
1404 | char set) | |
cb1faec9 | 1405 | { |
d62a17ae | 1406 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1407 | |
555e09d4 QY |
1408 | if (set) { |
1409 | uint32_t quanta = strtoul(num, NULL, 10); | |
1410 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, | |
1411 | memory_order_relaxed); | |
1412 | } else { | |
1413 | atomic_store_explicit(&bgp->wpkt_quanta, BGP_WRITE_PACKET_MAX, | |
1414 | memory_order_relaxed); | |
1415 | } | |
1416 | ||
1417 | return CMD_SUCCESS; | |
1418 | } | |
1419 | ||
1420 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, const char *num, | |
1421 | char set) | |
1422 | { | |
1423 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1424 | ||
1425 | if (set) { | |
1426 | uint32_t quanta = strtoul(num, NULL, 10); | |
1427 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, | |
1428 | memory_order_relaxed); | |
1429 | } else { | |
1430 | atomic_store_explicit(&bgp->rpkt_quanta, BGP_READ_PACKET_MAX, | |
1431 | memory_order_relaxed); | |
1432 | } | |
cb1faec9 | 1433 | |
d62a17ae | 1434 | return CMD_SUCCESS; |
cb1faec9 DS |
1435 | } |
1436 | ||
2b791107 | 1437 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1438 | { |
555e09d4 QY |
1439 | uint32_t quanta = |
1440 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1441 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1442 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1443 | } |
1444 | ||
555e09d4 QY |
1445 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1446 | { | |
1447 | uint32_t quanta = | |
1448 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1449 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1450 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1451 | } |
cb1faec9 | 1452 | |
555e09d4 | 1453 | /* Packet quanta configuration */ |
cb1faec9 DS |
1454 | DEFUN (bgp_wpkt_quanta, |
1455 | bgp_wpkt_quanta_cmd, | |
555e09d4 | 1456 | "write-quanta (1-10)", |
cb1faec9 DS |
1457 | "How many packets to write to peer socket per run\n" |
1458 | "Number of packets\n") | |
1459 | { | |
d62a17ae | 1460 | int idx_number = 1; |
1461 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1462 | } |
1463 | ||
cb1faec9 DS |
1464 | DEFUN (no_bgp_wpkt_quanta, |
1465 | no_bgp_wpkt_quanta_cmd, | |
555e09d4 | 1466 | "no write-quanta (1-10)", |
d7fa34c1 | 1467 | NO_STR |
555e09d4 | 1468 | "How many packets to write to peer socket per I/O cycle\n" |
cb1faec9 DS |
1469 | "Number of packets\n") |
1470 | { | |
d62a17ae | 1471 | int idx_number = 2; |
1472 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1473 | } |
1474 | ||
555e09d4 QY |
1475 | DEFUN (bgp_rpkt_quanta, |
1476 | bgp_rpkt_quanta_cmd, | |
1477 | "read-quanta (1-10)", | |
1478 | "How many packets to read from peer socket per I/O cycle\n" | |
1479 | "Number of packets\n") | |
1480 | { | |
1481 | int idx_number = 1; | |
1482 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
1483 | } | |
1484 | ||
1485 | DEFUN (no_bgp_rpkt_quanta, | |
1486 | no_bgp_rpkt_quanta_cmd, | |
1487 | "no read-quanta (1-10)", | |
1488 | NO_STR | |
1489 | "How many packets to read from peer socket per I/O cycle\n" | |
1490 | "Number of packets\n") | |
1491 | { | |
1492 | int idx_number = 2; | |
1493 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
1494 | } | |
1495 | ||
2b791107 | 1496 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1497 | { |
37a333fe | 1498 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1499 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1500 | } |
1501 | ||
1502 | ||
1503 | DEFUN (bgp_coalesce_time, | |
1504 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1505 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1506 | "Subgroup coalesce timer\n" |
1507 | "Subgroup coalesce timer value (in ms)\n") | |
1508 | { | |
d62a17ae | 1509 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1510 | |
d62a17ae | 1511 | int idx = 0; |
1512 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1513 | bgp->heuristic_coalesce = false; |
d62a17ae | 1514 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1515 | return CMD_SUCCESS; | |
3f9c7369 DS |
1516 | } |
1517 | ||
1518 | DEFUN (no_bgp_coalesce_time, | |
1519 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1520 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1521 | NO_STR |
3f9c7369 DS |
1522 | "Subgroup coalesce timer\n" |
1523 | "Subgroup coalesce timer value (in ms)\n") | |
1524 | { | |
d62a17ae | 1525 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1526 | |
37a333fe | 1527 | bgp->heuristic_coalesce = true; |
d62a17ae | 1528 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1529 | return CMD_SUCCESS; | |
3f9c7369 DS |
1530 | } |
1531 | ||
5e242b0d DS |
1532 | /* Maximum-paths configuration */ |
1533 | DEFUN (bgp_maxpaths, | |
1534 | bgp_maxpaths_cmd, | |
6319fd63 | 1535 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1536 | "Forward packets over multiple paths\n" |
1537 | "Number of paths\n") | |
1538 | { | |
d62a17ae | 1539 | int idx_number = 1; |
1540 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1541 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1542 | } |
1543 | ||
d62a17ae | 1544 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1545 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1546 | "Forward packets over multiple paths\n" | |
1547 | "Number of paths\n") | |
596c17ba | 1548 | |
165b5fff JB |
1549 | DEFUN (bgp_maxpaths_ibgp, |
1550 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1551 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1552 | "Forward packets over multiple paths\n" |
1553 | "iBGP-multipath\n" | |
1554 | "Number of paths\n") | |
1555 | { | |
d62a17ae | 1556 | int idx_number = 2; |
1557 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1558 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1559 | } |
165b5fff | 1560 | |
d62a17ae | 1561 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1562 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1563 | "Forward packets over multiple paths\n" | |
1564 | "iBGP-multipath\n" | |
1565 | "Number of paths\n") | |
596c17ba | 1566 | |
5e242b0d DS |
1567 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1568 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1569 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1570 | "Forward packets over multiple paths\n" |
1571 | "iBGP-multipath\n" | |
1572 | "Number of paths\n" | |
1573 | "Match the cluster length\n") | |
1574 | { | |
d62a17ae | 1575 | int idx_number = 2; |
1576 | return bgp_maxpaths_config_vty( | |
1577 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1578 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1579 | } |
1580 | ||
d62a17ae | 1581 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1582 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1583 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1584 | "Forward packets over multiple paths\n" | |
1585 | "iBGP-multipath\n" | |
1586 | "Number of paths\n" | |
1587 | "Match the cluster length\n") | |
596c17ba | 1588 | |
165b5fff JB |
1589 | DEFUN (no_bgp_maxpaths, |
1590 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1591 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1592 | NO_STR |
1593 | "Forward packets over multiple paths\n" | |
1594 | "Number of paths\n") | |
1595 | { | |
d62a17ae | 1596 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1597 | } |
1598 | ||
d62a17ae | 1599 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1600 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1601 | "Forward packets over multiple paths\n" |
1602 | "Number of paths\n") | |
596c17ba | 1603 | |
165b5fff JB |
1604 | DEFUN (no_bgp_maxpaths_ibgp, |
1605 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1606 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1607 | NO_STR |
1608 | "Forward packets over multiple paths\n" | |
1609 | "iBGP-multipath\n" | |
838758ac DW |
1610 | "Number of paths\n" |
1611 | "Match the cluster length\n") | |
165b5fff | 1612 | { |
d62a17ae | 1613 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1614 | } |
1615 | ||
d62a17ae | 1616 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1617 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1618 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1619 | NO_STR | |
1620 | "Forward packets over multiple paths\n" | |
1621 | "iBGP-multipath\n" | |
1622 | "Number of paths\n" | |
1623 | "Match the cluster length\n") | |
596c17ba | 1624 | |
2b791107 | 1625 | void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 1626 | safi_t safi) |
165b5fff | 1627 | { |
d62a17ae | 1628 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1629 | vty_out(vty, " maximum-paths %d\n", |
1630 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1631 | } | |
165b5fff | 1632 | |
d62a17ae | 1633 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1634 | vty_out(vty, " maximum-paths ibgp %d", |
1635 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1636 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1637 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1638 | vty_out(vty, " equal-cluster-length"); | |
1639 | vty_out(vty, "\n"); | |
1640 | } | |
165b5fff | 1641 | } |
6b0655a2 | 1642 | |
718e3744 | 1643 | /* BGP timers. */ |
1644 | ||
1645 | DEFUN (bgp_timers, | |
1646 | bgp_timers_cmd, | |
6147e2c6 | 1647 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1648 | "Adjust routing timers\n" |
1649 | "BGP timers\n" | |
1650 | "Keepalive interval\n" | |
1651 | "Holdtime\n") | |
1652 | { | |
d62a17ae | 1653 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1654 | int idx_number = 2; | |
1655 | int idx_number_2 = 3; | |
1656 | unsigned long keepalive = 0; | |
1657 | unsigned long holdtime = 0; | |
718e3744 | 1658 | |
d62a17ae | 1659 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1660 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1661 | |
d62a17ae | 1662 | /* Holdtime value check. */ |
1663 | if (holdtime < 3 && holdtime != 0) { | |
1664 | vty_out(vty, | |
1665 | "%% hold time value must be either 0 or greater than 3\n"); | |
1666 | return CMD_WARNING_CONFIG_FAILED; | |
1667 | } | |
718e3744 | 1668 | |
d62a17ae | 1669 | bgp_timers_set(bgp, keepalive, holdtime); |
718e3744 | 1670 | |
d62a17ae | 1671 | return CMD_SUCCESS; |
718e3744 | 1672 | } |
1673 | ||
1674 | DEFUN (no_bgp_timers, | |
1675 | no_bgp_timers_cmd, | |
838758ac | 1676 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1677 | NO_STR |
1678 | "Adjust routing timers\n" | |
838758ac DW |
1679 | "BGP timers\n" |
1680 | "Keepalive interval\n" | |
1681 | "Holdtime\n") | |
718e3744 | 1682 | { |
d62a17ae | 1683 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1684 | bgp_timers_unset(bgp); | |
718e3744 | 1685 | |
d62a17ae | 1686 | return CMD_SUCCESS; |
718e3744 | 1687 | } |
1688 | ||
6b0655a2 | 1689 | |
718e3744 | 1690 | DEFUN (bgp_client_to_client_reflection, |
1691 | bgp_client_to_client_reflection_cmd, | |
1692 | "bgp client-to-client reflection", | |
1693 | "BGP specific commands\n" | |
1694 | "Configure client to client route reflection\n" | |
1695 | "reflection of routes allowed\n") | |
1696 | { | |
d62a17ae | 1697 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1698 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1699 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1700 | |
d62a17ae | 1701 | return CMD_SUCCESS; |
718e3744 | 1702 | } |
1703 | ||
1704 | DEFUN (no_bgp_client_to_client_reflection, | |
1705 | no_bgp_client_to_client_reflection_cmd, | |
1706 | "no bgp client-to-client reflection", | |
1707 | NO_STR | |
1708 | "BGP specific commands\n" | |
1709 | "Configure client to client route reflection\n" | |
1710 | "reflection of routes allowed\n") | |
1711 | { | |
d62a17ae | 1712 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1713 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1714 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1715 | |
d62a17ae | 1716 | return CMD_SUCCESS; |
718e3744 | 1717 | } |
1718 | ||
1719 | /* "bgp always-compare-med" configuration. */ | |
1720 | DEFUN (bgp_always_compare_med, | |
1721 | bgp_always_compare_med_cmd, | |
1722 | "bgp always-compare-med", | |
1723 | "BGP specific commands\n" | |
1724 | "Allow comparing MED from different neighbors\n") | |
1725 | { | |
d62a17ae | 1726 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1727 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1728 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1729 | |
d62a17ae | 1730 | return CMD_SUCCESS; |
718e3744 | 1731 | } |
1732 | ||
1733 | DEFUN (no_bgp_always_compare_med, | |
1734 | no_bgp_always_compare_med_cmd, | |
1735 | "no bgp always-compare-med", | |
1736 | NO_STR | |
1737 | "BGP specific commands\n" | |
1738 | "Allow comparing MED from different neighbors\n") | |
1739 | { | |
d62a17ae | 1740 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1741 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1742 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1743 | |
d62a17ae | 1744 | return CMD_SUCCESS; |
718e3744 | 1745 | } |
6b0655a2 | 1746 | |
718e3744 | 1747 | /* "bgp deterministic-med" configuration. */ |
1748 | DEFUN (bgp_deterministic_med, | |
1749 | bgp_deterministic_med_cmd, | |
1750 | "bgp deterministic-med", | |
1751 | "BGP specific commands\n" | |
1752 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1753 | { | |
d62a17ae | 1754 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 1755 | |
d62a17ae | 1756 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
1757 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1758 | bgp_recalculate_all_bestpaths(bgp); | |
1759 | } | |
7aafcaca | 1760 | |
d62a17ae | 1761 | return CMD_SUCCESS; |
718e3744 | 1762 | } |
1763 | ||
1764 | DEFUN (no_bgp_deterministic_med, | |
1765 | no_bgp_deterministic_med_cmd, | |
1766 | "no bgp deterministic-med", | |
1767 | NO_STR | |
1768 | "BGP specific commands\n" | |
1769 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1770 | { | |
d62a17ae | 1771 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1772 | int bestpath_per_as_used; | |
1773 | afi_t afi; | |
1774 | safi_t safi; | |
1775 | struct peer *peer; | |
1776 | struct listnode *node, *nnode; | |
1777 | ||
1778 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
1779 | bestpath_per_as_used = 0; | |
1780 | ||
1781 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc QY |
1782 | FOREACH_AFI_SAFI (afi, safi) |
1783 | if (CHECK_FLAG( | |
1784 | peer->af_flags[afi][safi], | |
1785 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) { | |
1786 | bestpath_per_as_used = 1; | |
1787 | break; | |
1788 | } | |
d62a17ae | 1789 | |
1790 | if (bestpath_per_as_used) | |
1791 | break; | |
1792 | } | |
1793 | ||
1794 | if (bestpath_per_as_used) { | |
1795 | vty_out(vty, | |
1796 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
1797 | return CMD_WARNING_CONFIG_FAILED; | |
1798 | } else { | |
1799 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1800 | bgp_recalculate_all_bestpaths(bgp); | |
1801 | } | |
1802 | } | |
1803 | ||
1804 | return CMD_SUCCESS; | |
718e3744 | 1805 | } |
538621f2 | 1806 | |
1807 | /* "bgp graceful-restart" configuration. */ | |
1808 | DEFUN (bgp_graceful_restart, | |
1809 | bgp_graceful_restart_cmd, | |
1810 | "bgp graceful-restart", | |
1811 | "BGP specific commands\n" | |
1812 | "Graceful restart capability parameters\n") | |
1813 | { | |
d62a17ae | 1814 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1815 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1816 | return CMD_SUCCESS; | |
538621f2 | 1817 | } |
1818 | ||
1819 | DEFUN (no_bgp_graceful_restart, | |
1820 | no_bgp_graceful_restart_cmd, | |
1821 | "no bgp graceful-restart", | |
1822 | NO_STR | |
1823 | "BGP specific commands\n" | |
1824 | "Graceful restart capability parameters\n") | |
1825 | { | |
d62a17ae | 1826 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1827 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1828 | return CMD_SUCCESS; | |
538621f2 | 1829 | } |
1830 | ||
93406d87 | 1831 | DEFUN (bgp_graceful_restart_stalepath_time, |
1832 | bgp_graceful_restart_stalepath_time_cmd, | |
6147e2c6 | 1833 | "bgp graceful-restart stalepath-time (1-3600)", |
93406d87 | 1834 | "BGP specific commands\n" |
1835 | "Graceful restart capability parameters\n" | |
1836 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1837 | "Delay value (seconds)\n") | |
1838 | { | |
d62a17ae | 1839 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1840 | int idx_number = 3; | |
d7c0a89a | 1841 | uint32_t stalepath; |
93406d87 | 1842 | |
d62a17ae | 1843 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
1844 | bgp->stalepath_time = stalepath; | |
1845 | return CMD_SUCCESS; | |
93406d87 | 1846 | } |
1847 | ||
eb6f1b41 PG |
1848 | DEFUN (bgp_graceful_restart_restart_time, |
1849 | bgp_graceful_restart_restart_time_cmd, | |
6147e2c6 | 1850 | "bgp graceful-restart restart-time (1-3600)", |
eb6f1b41 PG |
1851 | "BGP specific commands\n" |
1852 | "Graceful restart capability parameters\n" | |
1853 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1854 | "Delay value (seconds)\n") | |
1855 | { | |
d62a17ae | 1856 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1857 | int idx_number = 3; | |
d7c0a89a | 1858 | uint32_t restart; |
eb6f1b41 | 1859 | |
d62a17ae | 1860 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
1861 | bgp->restart_time = restart; | |
1862 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1863 | } |
1864 | ||
93406d87 | 1865 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1866 | no_bgp_graceful_restart_stalepath_time_cmd, | |
838758ac | 1867 | "no bgp graceful-restart stalepath-time [(1-3600)]", |
93406d87 | 1868 | NO_STR |
1869 | "BGP specific commands\n" | |
1870 | "Graceful restart capability parameters\n" | |
838758ac DW |
1871 | "Set the max time to hold onto restarting peer's stale paths\n" |
1872 | "Delay value (seconds)\n") | |
93406d87 | 1873 | { |
d62a17ae | 1874 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1875 | |
d62a17ae | 1876 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
1877 | return CMD_SUCCESS; | |
93406d87 | 1878 | } |
1879 | ||
eb6f1b41 PG |
1880 | DEFUN (no_bgp_graceful_restart_restart_time, |
1881 | no_bgp_graceful_restart_restart_time_cmd, | |
838758ac | 1882 | "no bgp graceful-restart restart-time [(1-3600)]", |
eb6f1b41 PG |
1883 | NO_STR |
1884 | "BGP specific commands\n" | |
1885 | "Graceful restart capability parameters\n" | |
838758ac DW |
1886 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1887 | "Delay value (seconds)\n") | |
eb6f1b41 | 1888 | { |
d62a17ae | 1889 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 1890 | |
d62a17ae | 1891 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
1892 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1893 | } |
1894 | ||
43fc21b3 JC |
1895 | DEFUN (bgp_graceful_restart_preserve_fw, |
1896 | bgp_graceful_restart_preserve_fw_cmd, | |
1897 | "bgp graceful-restart preserve-fw-state", | |
1898 | "BGP specific commands\n" | |
1899 | "Graceful restart capability parameters\n" | |
1900 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1901 | { | |
d62a17ae | 1902 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1903 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1904 | return CMD_SUCCESS; | |
43fc21b3 JC |
1905 | } |
1906 | ||
1907 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
1908 | no_bgp_graceful_restart_preserve_fw_cmd, | |
1909 | "no bgp graceful-restart preserve-fw-state", | |
1910 | NO_STR | |
1911 | "BGP specific commands\n" | |
1912 | "Graceful restart capability parameters\n" | |
1913 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
1914 | { | |
d62a17ae | 1915 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1916 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
1917 | return CMD_SUCCESS; | |
43fc21b3 JC |
1918 | } |
1919 | ||
7f323236 DW |
1920 | static void bgp_redistribute_redo(struct bgp *bgp) |
1921 | { | |
1922 | afi_t afi; | |
1923 | int i; | |
1924 | struct list *red_list; | |
1925 | struct listnode *node; | |
1926 | struct bgp_redist *red; | |
1927 | ||
a4d82a8a PZ |
1928 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { |
1929 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
7f323236 | 1930 | |
a4d82a8a PZ |
1931 | red_list = bgp->redist[afi][i]; |
1932 | if (!red_list) | |
1933 | continue; | |
7f323236 | 1934 | |
a4d82a8a | 1935 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { |
7f323236 DW |
1936 | bgp_redistribute_resend(bgp, afi, i, |
1937 | red->instance); | |
1938 | } | |
1939 | } | |
1940 | } | |
1941 | } | |
1942 | ||
1943 | /* "bgp graceful-shutdown" configuration */ | |
1944 | DEFUN (bgp_graceful_shutdown, | |
1945 | bgp_graceful_shutdown_cmd, | |
1946 | "bgp graceful-shutdown", | |
1947 | BGP_STR | |
1948 | "Graceful shutdown parameters\n") | |
1949 | { | |
1950 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1951 | ||
1952 | if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
1953 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
1954 | bgp_static_redo_import_check(bgp); | |
1955 | bgp_redistribute_redo(bgp); | |
1956 | bgp_clear_star_soft_out(vty, bgp->name); | |
1957 | bgp_clear_star_soft_in(vty, bgp->name); | |
1958 | } | |
1959 | ||
1960 | return CMD_SUCCESS; | |
1961 | } | |
1962 | ||
1963 | DEFUN (no_bgp_graceful_shutdown, | |
1964 | no_bgp_graceful_shutdown_cmd, | |
1965 | "no bgp graceful-shutdown", | |
1966 | NO_STR | |
1967 | BGP_STR | |
1968 | "Graceful shutdown parameters\n") | |
1969 | { | |
1970 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1971 | ||
1972 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
1973 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
1974 | bgp_static_redo_import_check(bgp); | |
1975 | bgp_redistribute_redo(bgp); | |
1976 | bgp_clear_star_soft_out(vty, bgp->name); | |
1977 | bgp_clear_star_soft_in(vty, bgp->name); | |
1978 | } | |
1979 | ||
1980 | return CMD_SUCCESS; | |
1981 | } | |
1982 | ||
718e3744 | 1983 | /* "bgp fast-external-failover" configuration. */ |
1984 | DEFUN (bgp_fast_external_failover, | |
1985 | bgp_fast_external_failover_cmd, | |
1986 | "bgp fast-external-failover", | |
1987 | BGP_STR | |
1988 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
1989 | { | |
d62a17ae | 1990 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1991 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
1992 | return CMD_SUCCESS; | |
718e3744 | 1993 | } |
1994 | ||
1995 | DEFUN (no_bgp_fast_external_failover, | |
1996 | no_bgp_fast_external_failover_cmd, | |
1997 | "no bgp fast-external-failover", | |
1998 | NO_STR | |
1999 | BGP_STR | |
2000 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2001 | { | |
d62a17ae | 2002 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2003 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2004 | return CMD_SUCCESS; | |
718e3744 | 2005 | } |
6b0655a2 | 2006 | |
718e3744 | 2007 | /* "bgp enforce-first-as" configuration. */ |
47cbc09b PM |
2008 | #if defined(VERSION_TYPE_DEV) && CONFDATE > 20180517 |
2009 | CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands") | |
2010 | #endif | |
2011 | ||
f07e1c4f QY |
2012 | DEFUN_HIDDEN (bgp_enforce_first_as, |
2013 | bgp_enforce_first_as_cmd, | |
2014 | "[no] bgp enforce-first-as", | |
2015 | NO_STR | |
2016 | BGP_STR | |
2017 | "Enforce the first AS for EBGP routes\n") | |
718e3744 | 2018 | { |
d62a17ae | 2019 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2020 | |
f07e1c4f QY |
2021 | if (strmatch(argv[0]->text, "no")) |
2022 | bgp_flag_unset(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
2023 | else | |
2024 | bgp_flag_set(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
7aafcaca | 2025 | |
d62a17ae | 2026 | return CMD_SUCCESS; |
718e3744 | 2027 | } |
6b0655a2 | 2028 | |
718e3744 | 2029 | /* "bgp bestpath compare-routerid" configuration. */ |
2030 | DEFUN (bgp_bestpath_compare_router_id, | |
2031 | bgp_bestpath_compare_router_id_cmd, | |
2032 | "bgp bestpath compare-routerid", | |
2033 | "BGP specific commands\n" | |
2034 | "Change the default bestpath selection\n" | |
2035 | "Compare router-id for identical EBGP paths\n") | |
2036 | { | |
d62a17ae | 2037 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2038 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2039 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2040 | |
d62a17ae | 2041 | return CMD_SUCCESS; |
718e3744 | 2042 | } |
2043 | ||
2044 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2045 | no_bgp_bestpath_compare_router_id_cmd, | |
2046 | "no bgp bestpath compare-routerid", | |
2047 | NO_STR | |
2048 | "BGP specific commands\n" | |
2049 | "Change the default bestpath selection\n" | |
2050 | "Compare router-id for identical EBGP paths\n") | |
2051 | { | |
d62a17ae | 2052 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2053 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2054 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2055 | |
d62a17ae | 2056 | return CMD_SUCCESS; |
718e3744 | 2057 | } |
6b0655a2 | 2058 | |
718e3744 | 2059 | /* "bgp bestpath as-path ignore" configuration. */ |
2060 | DEFUN (bgp_bestpath_aspath_ignore, | |
2061 | bgp_bestpath_aspath_ignore_cmd, | |
2062 | "bgp bestpath as-path ignore", | |
2063 | "BGP specific commands\n" | |
2064 | "Change the default bestpath selection\n" | |
2065 | "AS-path attribute\n" | |
2066 | "Ignore as-path length in selecting a route\n") | |
2067 | { | |
d62a17ae | 2068 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2069 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2070 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2071 | |
d62a17ae | 2072 | return CMD_SUCCESS; |
718e3744 | 2073 | } |
2074 | ||
2075 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2076 | no_bgp_bestpath_aspath_ignore_cmd, | |
2077 | "no bgp bestpath as-path ignore", | |
2078 | NO_STR | |
2079 | "BGP specific commands\n" | |
2080 | "Change the default bestpath selection\n" | |
2081 | "AS-path attribute\n" | |
2082 | "Ignore as-path length in selecting a route\n") | |
2083 | { | |
d62a17ae | 2084 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2085 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2086 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2087 | |
d62a17ae | 2088 | return CMD_SUCCESS; |
718e3744 | 2089 | } |
6b0655a2 | 2090 | |
6811845b | 2091 | /* "bgp bestpath as-path confed" configuration. */ |
2092 | DEFUN (bgp_bestpath_aspath_confed, | |
2093 | bgp_bestpath_aspath_confed_cmd, | |
2094 | "bgp bestpath as-path confed", | |
2095 | "BGP specific commands\n" | |
2096 | "Change the default bestpath selection\n" | |
2097 | "AS-path attribute\n" | |
2098 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2099 | { | |
d62a17ae | 2100 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2101 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
2102 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2103 | |
d62a17ae | 2104 | return CMD_SUCCESS; |
6811845b | 2105 | } |
2106 | ||
2107 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2108 | no_bgp_bestpath_aspath_confed_cmd, | |
2109 | "no bgp bestpath as-path confed", | |
2110 | NO_STR | |
2111 | "BGP specific commands\n" | |
2112 | "Change the default bestpath selection\n" | |
2113 | "AS-path attribute\n" | |
2114 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2115 | { | |
d62a17ae | 2116 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2117 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
2118 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2119 | |
d62a17ae | 2120 | return CMD_SUCCESS; |
6811845b | 2121 | } |
6b0655a2 | 2122 | |
2fdd455c PM |
2123 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2124 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2125 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2126 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2127 | "BGP specific commands\n" |
2128 | "Change the default bestpath selection\n" | |
2129 | "AS-path attribute\n" | |
2130 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2131 | "Generate an AS_SET\n" |
16fc1eec DS |
2132 | "Do not generate an AS_SET\n") |
2133 | { | |
d62a17ae | 2134 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2135 | int idx = 0; | |
2136 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 2137 | |
d62a17ae | 2138 | /* no-as-set is now the default behavior so we can silently |
2139 | * ignore it */ | |
2140 | if (argv_find(argv, argc, "as-set", &idx)) | |
2141 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2142 | else | |
2143 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 2144 | |
d62a17ae | 2145 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2146 | |
d62a17ae | 2147 | return CMD_SUCCESS; |
16fc1eec DS |
2148 | } |
2149 | ||
219178b6 DW |
2150 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2151 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2152 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2153 | NO_STR |
2154 | "BGP specific commands\n" | |
2155 | "Change the default bestpath selection\n" | |
2156 | "AS-path attribute\n" | |
2157 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2158 | "Generate an AS_SET\n" |
16fc1eec DS |
2159 | "Do not generate an AS_SET\n") |
2160 | { | |
d62a17ae | 2161 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2162 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
2163 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2164 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2165 | |
d62a17ae | 2166 | return CMD_SUCCESS; |
2fdd455c | 2167 | } |
6b0655a2 | 2168 | |
848973c7 | 2169 | /* "bgp log-neighbor-changes" configuration. */ |
2170 | DEFUN (bgp_log_neighbor_changes, | |
2171 | bgp_log_neighbor_changes_cmd, | |
2172 | "bgp log-neighbor-changes", | |
2173 | "BGP specific commands\n" | |
2174 | "Log neighbor up/down and reset reason\n") | |
2175 | { | |
d62a17ae | 2176 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2177 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2178 | return CMD_SUCCESS; | |
848973c7 | 2179 | } |
2180 | ||
2181 | DEFUN (no_bgp_log_neighbor_changes, | |
2182 | no_bgp_log_neighbor_changes_cmd, | |
2183 | "no bgp log-neighbor-changes", | |
2184 | NO_STR | |
2185 | "BGP specific commands\n" | |
2186 | "Log neighbor up/down and reset reason\n") | |
2187 | { | |
d62a17ae | 2188 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2189 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2190 | return CMD_SUCCESS; | |
848973c7 | 2191 | } |
6b0655a2 | 2192 | |
718e3744 | 2193 | /* "bgp bestpath med" configuration. */ |
2194 | DEFUN (bgp_bestpath_med, | |
2195 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2196 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2197 | "BGP specific commands\n" |
2198 | "Change the default bestpath selection\n" | |
2199 | "MED attribute\n" | |
2200 | "Compare MED among confederation paths\n" | |
838758ac DW |
2201 | "Treat missing MED as the least preferred one\n" |
2202 | "Treat missing MED as the least preferred one\n" | |
2203 | "Compare MED among confederation paths\n") | |
718e3744 | 2204 | { |
d62a17ae | 2205 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2206 | |
d62a17ae | 2207 | int idx = 0; |
2208 | if (argv_find(argv, argc, "confed", &idx)) | |
2209 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2210 | idx = 0; | |
2211 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2212 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2213 | |
d62a17ae | 2214 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2215 | |
d62a17ae | 2216 | return CMD_SUCCESS; |
718e3744 | 2217 | } |
2218 | ||
718e3744 | 2219 | DEFUN (no_bgp_bestpath_med, |
2220 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2221 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2222 | NO_STR |
2223 | "BGP specific commands\n" | |
2224 | "Change the default bestpath selection\n" | |
2225 | "MED attribute\n" | |
2226 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2227 | "Treat missing MED as the least preferred one\n" |
2228 | "Treat missing MED as the least preferred one\n" | |
2229 | "Compare MED among confederation paths\n") | |
718e3744 | 2230 | { |
d62a17ae | 2231 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2232 | |
d62a17ae | 2233 | int idx = 0; |
2234 | if (argv_find(argv, argc, "confed", &idx)) | |
2235 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2236 | idx = 0; | |
2237 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2238 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2239 | |
d62a17ae | 2240 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2241 | |
d62a17ae | 2242 | return CMD_SUCCESS; |
718e3744 | 2243 | } |
2244 | ||
718e3744 | 2245 | /* "no bgp default ipv4-unicast". */ |
2246 | DEFUN (no_bgp_default_ipv4_unicast, | |
2247 | no_bgp_default_ipv4_unicast_cmd, | |
2248 | "no bgp default ipv4-unicast", | |
2249 | NO_STR | |
2250 | "BGP specific commands\n" | |
2251 | "Configure BGP defaults\n" | |
2252 | "Activate ipv4-unicast for a peer by default\n") | |
2253 | { | |
d62a17ae | 2254 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2255 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2256 | return CMD_SUCCESS; | |
718e3744 | 2257 | } |
2258 | ||
2259 | DEFUN (bgp_default_ipv4_unicast, | |
2260 | bgp_default_ipv4_unicast_cmd, | |
2261 | "bgp default ipv4-unicast", | |
2262 | "BGP specific commands\n" | |
2263 | "Configure BGP defaults\n" | |
2264 | "Activate ipv4-unicast for a peer by default\n") | |
2265 | { | |
d62a17ae | 2266 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2267 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2268 | return CMD_SUCCESS; | |
718e3744 | 2269 | } |
6b0655a2 | 2270 | |
04b6bdc0 DW |
2271 | /* Display hostname in certain command outputs */ |
2272 | DEFUN (bgp_default_show_hostname, | |
2273 | bgp_default_show_hostname_cmd, | |
2274 | "bgp default show-hostname", | |
2275 | "BGP specific commands\n" | |
2276 | "Configure BGP defaults\n" | |
2277 | "Show hostname in certain command ouputs\n") | |
2278 | { | |
d62a17ae | 2279 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2280 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2281 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2282 | } |
2283 | ||
2284 | DEFUN (no_bgp_default_show_hostname, | |
2285 | no_bgp_default_show_hostname_cmd, | |
2286 | "no bgp default show-hostname", | |
2287 | NO_STR | |
2288 | "BGP specific commands\n" | |
2289 | "Configure BGP defaults\n" | |
2290 | "Show hostname in certain command ouputs\n") | |
2291 | { | |
d62a17ae | 2292 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2293 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2294 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2295 | } |
2296 | ||
8233ef81 | 2297 | /* "bgp network import-check" configuration. */ |
718e3744 | 2298 | DEFUN (bgp_network_import_check, |
2299 | bgp_network_import_check_cmd, | |
5623e905 | 2300 | "bgp network import-check", |
718e3744 | 2301 | "BGP specific commands\n" |
2302 | "BGP network command\n" | |
5623e905 | 2303 | "Check BGP network route exists in IGP\n") |
718e3744 | 2304 | { |
d62a17ae | 2305 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2306 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2307 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
2308 | bgp_static_redo_import_check(bgp); | |
2309 | } | |
078430f6 | 2310 | |
d62a17ae | 2311 | return CMD_SUCCESS; |
718e3744 | 2312 | } |
2313 | ||
d62a17ae | 2314 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
2315 | "bgp network import-check exact", | |
2316 | "BGP specific commands\n" | |
2317 | "BGP network command\n" | |
2318 | "Check BGP network route exists in IGP\n" | |
2319 | "Match route precisely\n") | |
8233ef81 | 2320 | |
718e3744 | 2321 | DEFUN (no_bgp_network_import_check, |
2322 | no_bgp_network_import_check_cmd, | |
5623e905 | 2323 | "no bgp network import-check", |
718e3744 | 2324 | NO_STR |
2325 | "BGP specific commands\n" | |
2326 | "BGP network command\n" | |
2327 | "Check BGP network route exists in IGP\n") | |
2328 | { | |
d62a17ae | 2329 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2330 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2331 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
2332 | bgp_static_redo_import_check(bgp); | |
2333 | } | |
5623e905 | 2334 | |
d62a17ae | 2335 | return CMD_SUCCESS; |
718e3744 | 2336 | } |
6b0655a2 | 2337 | |
718e3744 | 2338 | DEFUN (bgp_default_local_preference, |
2339 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2340 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2341 | "BGP specific commands\n" |
2342 | "Configure BGP defaults\n" | |
2343 | "local preference (higher=more preferred)\n" | |
2344 | "Configure default local preference value\n") | |
2345 | { | |
d62a17ae | 2346 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2347 | int idx_number = 3; | |
d7c0a89a | 2348 | uint32_t local_pref; |
718e3744 | 2349 | |
d62a17ae | 2350 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2351 | |
d62a17ae | 2352 | bgp_default_local_preference_set(bgp, local_pref); |
2353 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 2354 | |
d62a17ae | 2355 | return CMD_SUCCESS; |
718e3744 | 2356 | } |
2357 | ||
2358 | DEFUN (no_bgp_default_local_preference, | |
2359 | no_bgp_default_local_preference_cmd, | |
838758ac | 2360 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2361 | NO_STR |
2362 | "BGP specific commands\n" | |
2363 | "Configure BGP defaults\n" | |
838758ac DW |
2364 | "local preference (higher=more preferred)\n" |
2365 | "Configure default local preference value\n") | |
718e3744 | 2366 | { |
d62a17ae | 2367 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2368 | bgp_default_local_preference_unset(bgp); | |
2369 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2370 | |
d62a17ae | 2371 | return CMD_SUCCESS; |
718e3744 | 2372 | } |
2373 | ||
6b0655a2 | 2374 | |
3f9c7369 DS |
2375 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2376 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2377 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2378 | "BGP specific commands\n" |
2379 | "Configure BGP defaults\n" | |
2380 | "subgroup-pkt-queue-max\n" | |
2381 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2382 | { |
d62a17ae | 2383 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2384 | int idx_number = 3; | |
d7c0a89a | 2385 | uint32_t max_size; |
8bd9d948 | 2386 | |
d62a17ae | 2387 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 2388 | |
d62a17ae | 2389 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 2390 | |
d62a17ae | 2391 | return CMD_SUCCESS; |
3f9c7369 DS |
2392 | } |
2393 | ||
2394 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2395 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2396 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2397 | NO_STR |
2398 | "BGP specific commands\n" | |
2399 | "Configure BGP defaults\n" | |
838758ac DW |
2400 | "subgroup-pkt-queue-max\n" |
2401 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2402 | { |
d62a17ae | 2403 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2404 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
2405 | return CMD_SUCCESS; | |
8bd9d948 DS |
2406 | } |
2407 | ||
813d4307 | 2408 | |
8bd9d948 DS |
2409 | DEFUN (bgp_rr_allow_outbound_policy, |
2410 | bgp_rr_allow_outbound_policy_cmd, | |
2411 | "bgp route-reflector allow-outbound-policy", | |
2412 | "BGP specific commands\n" | |
2413 | "Allow modifications made by out route-map\n" | |
2414 | "on ibgp neighbors\n") | |
2415 | { | |
d62a17ae | 2416 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2417 | |
d62a17ae | 2418 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2419 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2420 | update_group_announce_rrclients(bgp); | |
2421 | bgp_clear_star_soft_out(vty, bgp->name); | |
2422 | } | |
8bd9d948 | 2423 | |
d62a17ae | 2424 | return CMD_SUCCESS; |
8bd9d948 DS |
2425 | } |
2426 | ||
2427 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2428 | no_bgp_rr_allow_outbound_policy_cmd, | |
2429 | "no bgp route-reflector allow-outbound-policy", | |
2430 | NO_STR | |
2431 | "BGP specific commands\n" | |
2432 | "Allow modifications made by out route-map\n" | |
2433 | "on ibgp neighbors\n") | |
2434 | { | |
d62a17ae | 2435 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2436 | |
d62a17ae | 2437 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2438 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2439 | update_group_announce_rrclients(bgp); | |
2440 | bgp_clear_star_soft_out(vty, bgp->name); | |
2441 | } | |
8bd9d948 | 2442 | |
d62a17ae | 2443 | return CMD_SUCCESS; |
8bd9d948 DS |
2444 | } |
2445 | ||
f14e6fdb DS |
2446 | DEFUN (bgp_listen_limit, |
2447 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2448 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2449 | "BGP specific commands\n" |
2450 | "Configure BGP defaults\n" | |
2451 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2452 | "Configure Dynamic Neighbors listen limit value\n") | |
2453 | { | |
d62a17ae | 2454 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2455 | int idx_number = 3; | |
2456 | int listen_limit; | |
f14e6fdb | 2457 | |
d62a17ae | 2458 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 2459 | |
d62a17ae | 2460 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 2461 | |
d62a17ae | 2462 | return CMD_SUCCESS; |
f14e6fdb DS |
2463 | } |
2464 | ||
2465 | DEFUN (no_bgp_listen_limit, | |
2466 | no_bgp_listen_limit_cmd, | |
838758ac | 2467 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2468 | "BGP specific commands\n" |
2469 | "Configure BGP defaults\n" | |
2470 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2471 | "Configure Dynamic Neighbors listen limit value to default\n" |
2472 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2473 | { |
d62a17ae | 2474 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2475 | bgp_listen_limit_unset(bgp); | |
2476 | return CMD_SUCCESS; | |
f14e6fdb DS |
2477 | } |
2478 | ||
2479 | ||
20eb8864 | 2480 | /* |
2481 | * Check if this listen range is already configured. Check for exact | |
2482 | * match or overlap based on input. | |
2483 | */ | |
d62a17ae | 2484 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
2485 | struct prefix *range, int exact) | |
2486 | { | |
2487 | struct listnode *node, *nnode; | |
2488 | struct listnode *node1, *nnode1; | |
2489 | struct peer_group *group; | |
2490 | struct prefix *lr; | |
2491 | afi_t afi; | |
2492 | int match; | |
2493 | ||
2494 | afi = family2afi(range->family); | |
2495 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2496 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
2497 | lr)) { | |
2498 | if (exact) | |
2499 | match = prefix_same(range, lr); | |
2500 | else | |
2501 | match = (prefix_match(range, lr) | |
2502 | || prefix_match(lr, range)); | |
2503 | if (match) | |
2504 | return group; | |
2505 | } | |
2506 | } | |
2507 | ||
2508 | return NULL; | |
20eb8864 | 2509 | } |
2510 | ||
f14e6fdb DS |
2511 | DEFUN (bgp_listen_range, |
2512 | bgp_listen_range_cmd, | |
9ccf14f7 | 2513 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
f14e6fdb | 2514 | "BGP specific commands\n" |
d7fa34c1 QY |
2515 | "Configure BGP dynamic neighbors listen range\n" |
2516 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2517 | NEIGHBOR_ADDR_STR |
2518 | "Member of the peer-group\n" | |
2519 | "Peer-group name\n") | |
f14e6fdb | 2520 | { |
d62a17ae | 2521 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2522 | struct prefix range; | |
2523 | struct peer_group *group, *existing_group; | |
2524 | afi_t afi; | |
2525 | int ret; | |
2526 | int idx = 0; | |
2527 | ||
2528 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2529 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2530 | char *prefix = argv[idx]->arg; | |
2531 | argv_find(argv, argc, "WORD", &idx); | |
2532 | char *peergroup = argv[idx]->arg; | |
2533 | ||
2534 | /* Convert IP prefix string to struct prefix. */ | |
2535 | ret = str2prefix(prefix, &range); | |
2536 | if (!ret) { | |
2537 | vty_out(vty, "%% Malformed listen range\n"); | |
2538 | return CMD_WARNING_CONFIG_FAILED; | |
2539 | } | |
2540 | ||
2541 | afi = family2afi(range.family); | |
2542 | ||
2543 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2544 | vty_out(vty, | |
2545 | "%% Malformed listen range (link-local address)\n"); | |
2546 | return CMD_WARNING_CONFIG_FAILED; | |
2547 | } | |
2548 | ||
2549 | apply_mask(&range); | |
2550 | ||
2551 | /* Check if same listen range is already configured. */ | |
2552 | existing_group = listen_range_exists(bgp, &range, 1); | |
2553 | if (existing_group) { | |
2554 | if (strcmp(existing_group->name, peergroup) == 0) | |
2555 | return CMD_SUCCESS; | |
2556 | else { | |
2557 | vty_out(vty, | |
2558 | "%% Same listen range is attached to peer-group %s\n", | |
2559 | existing_group->name); | |
2560 | return CMD_WARNING_CONFIG_FAILED; | |
2561 | } | |
2562 | } | |
2563 | ||
2564 | /* Check if an overlapping listen range exists. */ | |
2565 | if (listen_range_exists(bgp, &range, 0)) { | |
2566 | vty_out(vty, | |
2567 | "%% Listen range overlaps with existing listen range\n"); | |
2568 | return CMD_WARNING_CONFIG_FAILED; | |
2569 | } | |
2570 | ||
2571 | group = peer_group_lookup(bgp, peergroup); | |
2572 | if (!group) { | |
2573 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2574 | return CMD_WARNING_CONFIG_FAILED; | |
2575 | } | |
2576 | ||
2577 | ret = peer_group_listen_range_add(group, &range); | |
2578 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
2579 | } |
2580 | ||
2581 | DEFUN (no_bgp_listen_range, | |
2582 | no_bgp_listen_range_cmd, | |
d7fa34c1 QY |
2583 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD", |
2584 | NO_STR | |
f14e6fdb | 2585 | "BGP specific commands\n" |
d7fa34c1 QY |
2586 | "Unconfigure BGP dynamic neighbors listen range\n" |
2587 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2588 | NEIGHBOR_ADDR_STR | |
2589 | "Member of the peer-group\n" | |
2590 | "Peer-group name\n") | |
f14e6fdb | 2591 | { |
d62a17ae | 2592 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2593 | struct prefix range; | |
2594 | struct peer_group *group; | |
2595 | afi_t afi; | |
2596 | int ret; | |
2597 | int idx = 0; | |
2598 | ||
2599 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2600 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2601 | char *prefix = argv[idx]->arg; | |
2602 | argv_find(argv, argc, "WORD", &idx); | |
2603 | char *peergroup = argv[idx]->arg; | |
2604 | ||
2605 | /* Convert IP prefix string to struct prefix. */ | |
2606 | ret = str2prefix(prefix, &range); | |
2607 | if (!ret) { | |
2608 | vty_out(vty, "%% Malformed listen range\n"); | |
2609 | return CMD_WARNING_CONFIG_FAILED; | |
2610 | } | |
2611 | ||
2612 | afi = family2afi(range.family); | |
2613 | ||
2614 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2615 | vty_out(vty, | |
2616 | "%% Malformed listen range (link-local address)\n"); | |
2617 | return CMD_WARNING_CONFIG_FAILED; | |
2618 | } | |
2619 | ||
2620 | apply_mask(&range); | |
2621 | ||
2622 | group = peer_group_lookup(bgp, peergroup); | |
2623 | if (!group) { | |
2624 | vty_out(vty, "%% Peer-group does not exist\n"); | |
2625 | return CMD_WARNING_CONFIG_FAILED; | |
2626 | } | |
2627 | ||
2628 | ret = peer_group_listen_range_del(group, &range); | |
2629 | return bgp_vty_return(vty, ret); | |
2630 | } | |
2631 | ||
2b791107 | 2632 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 2633 | { |
2634 | struct peer_group *group; | |
2635 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2636 | struct prefix *range; | |
2637 | afi_t afi; | |
2638 | char buf[PREFIX2STR_BUFFER]; | |
2639 | ||
2640 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2641 | vty_out(vty, " bgp listen limit %d\n", | |
2642 | bgp->dynamic_neighbors_limit); | |
2643 | ||
2644 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2645 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
2646 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
2647 | nrnode, range)) { | |
2648 | prefix2str(range, buf, sizeof(buf)); | |
2649 | vty_out(vty, | |
2650 | " bgp listen range %s peer-group %s\n", | |
2651 | buf, group->name); | |
2652 | } | |
2653 | } | |
2654 | } | |
f14e6fdb DS |
2655 | } |
2656 | ||
2657 | ||
907f92c8 DS |
2658 | DEFUN (bgp_disable_connected_route_check, |
2659 | bgp_disable_connected_route_check_cmd, | |
2660 | "bgp disable-ebgp-connected-route-check", | |
2661 | "BGP specific commands\n" | |
2662 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2663 | { | |
d62a17ae | 2664 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2665 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2666 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2667 | |
d62a17ae | 2668 | return CMD_SUCCESS; |
907f92c8 DS |
2669 | } |
2670 | ||
2671 | DEFUN (no_bgp_disable_connected_route_check, | |
2672 | no_bgp_disable_connected_route_check_cmd, | |
2673 | "no bgp disable-ebgp-connected-route-check", | |
2674 | NO_STR | |
2675 | "BGP specific commands\n" | |
2676 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2677 | { | |
d62a17ae | 2678 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2679 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2680 | bgp_clear_star_soft_in(vty, bgp->name); | |
2681 | ||
2682 | return CMD_SUCCESS; | |
2683 | } | |
2684 | ||
2685 | ||
2686 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
2687 | const char *as_str, afi_t afi, safi_t safi) | |
2688 | { | |
2689 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2690 | int ret; | |
2691 | as_t as; | |
2692 | int as_type = AS_SPECIFIED; | |
2693 | union sockunion su; | |
2694 | ||
2695 | if (as_str[0] == 'i') { | |
2696 | as = 0; | |
2697 | as_type = AS_INTERNAL; | |
2698 | } else if (as_str[0] == 'e') { | |
2699 | as = 0; | |
2700 | as_type = AS_EXTERNAL; | |
2701 | } else { | |
2702 | /* Get AS number. */ | |
2703 | as = strtoul(as_str, NULL, 10); | |
2704 | } | |
2705 | ||
2706 | /* If peer is peer group, call proper function. */ | |
2707 | ret = str2sockunion(peer_str, &su); | |
2708 | if (ret < 0) { | |
2709 | /* Check for peer by interface */ | |
2710 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, | |
2711 | safi); | |
2712 | if (ret < 0) { | |
2713 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); | |
2714 | if (ret < 0) { | |
2715 | vty_out(vty, | |
2716 | "%% Create the peer-group or interface first\n"); | |
2717 | return CMD_WARNING_CONFIG_FAILED; | |
2718 | } | |
2719 | return CMD_SUCCESS; | |
2720 | } | |
2721 | } else { | |
2722 | if (peer_address_self_check(bgp, &su)) { | |
2723 | vty_out(vty, | |
2724 | "%% Can not configure the local system as neighbor\n"); | |
2725 | return CMD_WARNING_CONFIG_FAILED; | |
2726 | } | |
2727 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
2728 | } | |
2729 | ||
2730 | /* This peer belongs to peer group. */ | |
2731 | switch (ret) { | |
2732 | case BGP_ERR_PEER_GROUP_MEMBER: | |
2733 | vty_out(vty, | |
2734 | "%% Peer-group AS %u. Cannot configure remote-as for member\n", | |
2735 | as); | |
2736 | return CMD_WARNING_CONFIG_FAILED; | |
2737 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
2738 | vty_out(vty, | |
2739 | "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n", | |
2740 | as, as_str); | |
2741 | return CMD_WARNING_CONFIG_FAILED; | |
2742 | } | |
2743 | return bgp_vty_return(vty, ret); | |
718e3744 | 2744 | } |
2745 | ||
f26845f9 QY |
2746 | DEFUN (bgp_default_shutdown, |
2747 | bgp_default_shutdown_cmd, | |
2748 | "[no] bgp default shutdown", | |
2749 | NO_STR | |
2750 | BGP_STR | |
2751 | "Configure BGP defaults\n" | |
b012cbe2 | 2752 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
2753 | { |
2754 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2755 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
2756 | return CMD_SUCCESS; | |
2757 | } | |
2758 | ||
718e3744 | 2759 | DEFUN (neighbor_remote_as, |
2760 | neighbor_remote_as_cmd, | |
3a2d747c | 2761 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2762 | NEIGHBOR_STR |
2763 | NEIGHBOR_ADDR_STR2 | |
2764 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2765 | AS_STR |
3a2d747c QY |
2766 | "Internal BGP peer\n" |
2767 | "External BGP peer\n") | |
718e3744 | 2768 | { |
d62a17ae | 2769 | int idx_peer = 1; |
2770 | int idx_remote_as = 3; | |
2771 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
2772 | argv[idx_remote_as]->arg, AFI_IP, | |
2773 | SAFI_UNICAST); | |
2774 | } | |
2775 | ||
2776 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
2777 | afi_t afi, safi_t safi, int v6only, | |
2778 | const char *peer_group_name, | |
2779 | const char *as_str) | |
2780 | { | |
2781 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2782 | as_t as = 0; | |
2783 | int as_type = AS_UNSPECIFIED; | |
2784 | struct peer *peer; | |
2785 | struct peer_group *group; | |
2786 | int ret = 0; | |
2787 | union sockunion su; | |
2788 | ||
2789 | group = peer_group_lookup(bgp, conf_if); | |
2790 | ||
2791 | if (group) { | |
2792 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
2793 | return CMD_WARNING_CONFIG_FAILED; | |
2794 | } | |
2795 | ||
2796 | if (as_str) { | |
2797 | if (as_str[0] == 'i') { | |
2798 | as_type = AS_INTERNAL; | |
2799 | } else if (as_str[0] == 'e') { | |
2800 | as_type = AS_EXTERNAL; | |
2801 | } else { | |
2802 | /* Get AS number. */ | |
2803 | as = strtoul(as_str, NULL, 10); | |
2804 | as_type = AS_SPECIFIED; | |
2805 | } | |
2806 | } | |
2807 | ||
2808 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
2809 | if (peer) { | |
2810 | if (as_str) | |
2811 | ret = peer_remote_as(bgp, &su, conf_if, &as, as_type, | |
2812 | afi, safi); | |
2813 | } else { | |
2814 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2815 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
2816 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2817 | as_type, 0, 0, NULL); | |
2818 | else | |
2819 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2820 | as_type, afi, safi, NULL); | |
2821 | ||
2822 | if (!peer) { | |
2823 | vty_out(vty, "%% BGP failed to create peer\n"); | |
2824 | return CMD_WARNING_CONFIG_FAILED; | |
2825 | } | |
2826 | ||
2827 | if (v6only) | |
527de3dc | 2828 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2829 | |
2830 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
2831 | * this | |
2832 | * any unnumbered peer in order to not worry about run-time | |
2833 | * transitions | |
2834 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
2835 | * address | |
2836 | * gets deleted later etc.) | |
2837 | */ | |
2838 | if (peer->ifp) | |
2839 | bgp_zebra_initiate_radv(bgp, peer); | |
2840 | } | |
2841 | ||
2842 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
2843 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
2844 | if (v6only) | |
527de3dc | 2845 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2846 | else |
527de3dc | 2847 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2848 | |
2849 | /* v6only flag changed. Reset bgp seesion */ | |
2850 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2851 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2852 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2853 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2854 | } else | |
2855 | bgp_session_reset(peer); | |
2856 | } | |
2857 | ||
9fb964de PM |
2858 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
2859 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
2860 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
2861 | UNSET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); | |
2862 | } | |
d62a17ae | 2863 | |
2864 | if (peer_group_name) { | |
2865 | group = peer_group_lookup(bgp, peer_group_name); | |
2866 | if (!group) { | |
2867 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2868 | return CMD_WARNING_CONFIG_FAILED; | |
2869 | } | |
2870 | ||
2871 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
2872 | } | |
2873 | ||
2874 | return bgp_vty_return(vty, ret); | |
a80beece DS |
2875 | } |
2876 | ||
4c48cf63 DW |
2877 | DEFUN (neighbor_interface_config, |
2878 | neighbor_interface_config_cmd, | |
31500417 | 2879 | "neighbor WORD interface [peer-group WORD]", |
4c48cf63 DW |
2880 | NEIGHBOR_STR |
2881 | "Interface name or neighbor tag\n" | |
31500417 DW |
2882 | "Enable BGP on interface\n" |
2883 | "Member of the peer-group\n" | |
16cedbb0 | 2884 | "Peer-group name\n") |
4c48cf63 | 2885 | { |
d62a17ae | 2886 | int idx_word = 1; |
2887 | int idx_peer_group_word = 4; | |
31500417 | 2888 | |
d62a17ae | 2889 | if (argc > idx_peer_group_word) |
2890 | return peer_conf_interface_get( | |
2891 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2892 | argv[idx_peer_group_word]->arg, NULL); | |
2893 | else | |
2894 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2895 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
2896 | } |
2897 | ||
4c48cf63 DW |
2898 | DEFUN (neighbor_interface_config_v6only, |
2899 | neighbor_interface_config_v6only_cmd, | |
31500417 | 2900 | "neighbor WORD interface v6only [peer-group WORD]", |
4c48cf63 DW |
2901 | NEIGHBOR_STR |
2902 | "Interface name or neighbor tag\n" | |
2903 | "Enable BGP on interface\n" | |
31500417 DW |
2904 | "Enable BGP with v6 link-local only\n" |
2905 | "Member of the peer-group\n" | |
16cedbb0 | 2906 | "Peer-group name\n") |
4c48cf63 | 2907 | { |
d62a17ae | 2908 | int idx_word = 1; |
2909 | int idx_peer_group_word = 5; | |
31500417 | 2910 | |
d62a17ae | 2911 | if (argc > idx_peer_group_word) |
2912 | return peer_conf_interface_get( | |
2913 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2914 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 2915 | |
d62a17ae | 2916 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
2917 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
2918 | } |
2919 | ||
a80beece | 2920 | |
b3a39dc5 DD |
2921 | DEFUN (neighbor_interface_config_remote_as, |
2922 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2923 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2924 | NEIGHBOR_STR |
2925 | "Interface name or neighbor tag\n" | |
2926 | "Enable BGP on interface\n" | |
3a2d747c | 2927 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2928 | AS_STR |
3a2d747c QY |
2929 | "Internal BGP peer\n" |
2930 | "External BGP peer\n") | |
b3a39dc5 | 2931 | { |
d62a17ae | 2932 | int idx_word = 1; |
2933 | int idx_remote_as = 4; | |
2934 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2935 | SAFI_UNICAST, 0, NULL, | |
2936 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2937 | } |
2938 | ||
2939 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
2940 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 2941 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2942 | NEIGHBOR_STR |
2943 | "Interface name or neighbor tag\n" | |
3a2d747c | 2944 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 2945 | "Enable BGP on interface\n" |
3a2d747c | 2946 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2947 | AS_STR |
3a2d747c QY |
2948 | "Internal BGP peer\n" |
2949 | "External BGP peer\n") | |
b3a39dc5 | 2950 | { |
d62a17ae | 2951 | int idx_word = 1; |
2952 | int idx_remote_as = 5; | |
2953 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2954 | SAFI_UNICAST, 1, NULL, | |
2955 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
2956 | } |
2957 | ||
718e3744 | 2958 | DEFUN (neighbor_peer_group, |
2959 | neighbor_peer_group_cmd, | |
2960 | "neighbor WORD peer-group", | |
2961 | NEIGHBOR_STR | |
a80beece | 2962 | "Interface name or neighbor tag\n" |
718e3744 | 2963 | "Configure peer-group\n") |
2964 | { | |
d62a17ae | 2965 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2966 | int idx_word = 1; | |
2967 | struct peer *peer; | |
2968 | struct peer_group *group; | |
718e3744 | 2969 | |
d62a17ae | 2970 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
2971 | if (peer) { | |
2972 | vty_out(vty, "%% Name conflict with interface: \n"); | |
2973 | return CMD_WARNING_CONFIG_FAILED; | |
2974 | } | |
718e3744 | 2975 | |
d62a17ae | 2976 | group = peer_group_get(bgp, argv[idx_word]->arg); |
2977 | if (!group) { | |
2978 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
2979 | return CMD_WARNING_CONFIG_FAILED; | |
2980 | } | |
718e3744 | 2981 | |
d62a17ae | 2982 | return CMD_SUCCESS; |
718e3744 | 2983 | } |
2984 | ||
2985 | DEFUN (no_neighbor, | |
2986 | no_neighbor_cmd, | |
dab8cd00 | 2987 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 2988 | NO_STR |
2989 | NEIGHBOR_STR | |
3a2d747c QY |
2990 | NEIGHBOR_ADDR_STR2 |
2991 | "Specify a BGP neighbor\n" | |
2992 | AS_STR | |
2993 | "Internal BGP peer\n" | |
2994 | "External BGP peer\n") | |
718e3744 | 2995 | { |
d62a17ae | 2996 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2997 | int idx_peer = 2; | |
2998 | int ret; | |
2999 | union sockunion su; | |
3000 | struct peer_group *group; | |
3001 | struct peer *peer; | |
3002 | struct peer *other; | |
3003 | ||
3004 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3005 | if (ret < 0) { | |
3006 | /* look up for neighbor by interface name config. */ | |
3007 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3008 | if (peer) { | |
3009 | /* Request zebra to terminate IPv6 RAs on this | |
3010 | * interface. */ | |
3011 | if (peer->ifp) | |
3012 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3013 | peer_delete(peer); | |
3014 | return CMD_SUCCESS; | |
3015 | } | |
f14e6fdb | 3016 | |
d62a17ae | 3017 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
3018 | if (group) | |
3019 | peer_group_delete(group); | |
3020 | else { | |
3021 | vty_out(vty, "%% Create the peer-group first\n"); | |
3022 | return CMD_WARNING_CONFIG_FAILED; | |
3023 | } | |
3024 | } else { | |
3025 | peer = peer_lookup(bgp, &su); | |
3026 | if (peer) { | |
3027 | if (peer_dynamic_neighbor(peer)) { | |
3028 | vty_out(vty, | |
3029 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3030 | return CMD_WARNING_CONFIG_FAILED; | |
3031 | } | |
3032 | ||
3033 | other = peer->doppelganger; | |
3034 | peer_delete(peer); | |
3035 | if (other && other->status != Deleted) | |
3036 | peer_delete(other); | |
3037 | } | |
1ff9a340 | 3038 | } |
718e3744 | 3039 | |
d62a17ae | 3040 | return CMD_SUCCESS; |
718e3744 | 3041 | } |
3042 | ||
a80beece DS |
3043 | DEFUN (no_neighbor_interface_config, |
3044 | no_neighbor_interface_config_cmd, | |
31500417 | 3045 | "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3046 | NO_STR |
3047 | NEIGHBOR_STR | |
3048 | "Interface name\n" | |
31500417 DW |
3049 | "Configure BGP on interface\n" |
3050 | "Enable BGP with v6 link-local only\n" | |
3051 | "Member of the peer-group\n" | |
16cedbb0 | 3052 | "Peer-group name\n" |
3a2d747c QY |
3053 | "Specify a BGP neighbor\n" |
3054 | AS_STR | |
3055 | "Internal BGP peer\n" | |
3056 | "External BGP peer\n") | |
a80beece | 3057 | { |
d62a17ae | 3058 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3059 | int idx_word = 2; | |
3060 | struct peer *peer; | |
3061 | ||
3062 | /* look up for neighbor by interface name config. */ | |
3063 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3064 | if (peer) { | |
3065 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3066 | if (peer->ifp) | |
3067 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3068 | peer_delete(peer); | |
3069 | } else { | |
3070 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3071 | return CMD_WARNING_CONFIG_FAILED; | |
3072 | } | |
3073 | return CMD_SUCCESS; | |
a80beece DS |
3074 | } |
3075 | ||
718e3744 | 3076 | DEFUN (no_neighbor_peer_group, |
3077 | no_neighbor_peer_group_cmd, | |
3078 | "no neighbor WORD peer-group", | |
3079 | NO_STR | |
3080 | NEIGHBOR_STR | |
3081 | "Neighbor tag\n" | |
3082 | "Configure peer-group\n") | |
3083 | { | |
d62a17ae | 3084 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3085 | int idx_word = 2; | |
3086 | struct peer_group *group; | |
718e3744 | 3087 | |
d62a17ae | 3088 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
3089 | if (group) | |
3090 | peer_group_delete(group); | |
3091 | else { | |
3092 | vty_out(vty, "%% Create the peer-group first\n"); | |
3093 | return CMD_WARNING_CONFIG_FAILED; | |
3094 | } | |
3095 | return CMD_SUCCESS; | |
718e3744 | 3096 | } |
3097 | ||
a80beece DS |
3098 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3099 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3100 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3101 | NO_STR |
3102 | NEIGHBOR_STR | |
a80beece | 3103 | "Interface name or neighbor tag\n" |
718e3744 | 3104 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3105 | AS_STR |
3106 | "Internal BGP peer\n" | |
3107 | "External BGP peer\n") | |
718e3744 | 3108 | { |
d62a17ae | 3109 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3110 | int idx_word = 2; | |
3111 | struct peer_group *group; | |
3112 | struct peer *peer; | |
3113 | ||
3114 | /* look up for neighbor by interface name config. */ | |
3115 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3116 | if (peer) { | |
3117 | peer_as_change(peer, 0, AS_SPECIFIED); | |
3118 | return CMD_SUCCESS; | |
3119 | } | |
3120 | ||
3121 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3122 | if (group) | |
3123 | peer_group_remote_as_delete(group); | |
3124 | else { | |
3125 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3126 | return CMD_WARNING_CONFIG_FAILED; | |
3127 | } | |
3128 | return CMD_SUCCESS; | |
718e3744 | 3129 | } |
6b0655a2 | 3130 | |
718e3744 | 3131 | DEFUN (neighbor_local_as, |
3132 | neighbor_local_as_cmd, | |
9ccf14f7 | 3133 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3134 | NEIGHBOR_STR |
3135 | NEIGHBOR_ADDR_STR2 | |
3136 | "Specify a local-as number\n" | |
3137 | "AS number used as local AS\n") | |
3138 | { | |
d62a17ae | 3139 | int idx_peer = 1; |
3140 | int idx_number = 3; | |
3141 | struct peer *peer; | |
3142 | int ret; | |
3143 | as_t as; | |
718e3744 | 3144 | |
d62a17ae | 3145 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3146 | if (!peer) | |
3147 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3148 | |
d62a17ae | 3149 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3150 | ret = peer_local_as_set(peer, as, 0, 0); | |
3151 | return bgp_vty_return(vty, ret); | |
718e3744 | 3152 | } |
3153 | ||
3154 | DEFUN (neighbor_local_as_no_prepend, | |
3155 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3156 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3157 | NEIGHBOR_STR |
3158 | NEIGHBOR_ADDR_STR2 | |
3159 | "Specify a local-as number\n" | |
3160 | "AS number used as local AS\n" | |
3161 | "Do not prepend local-as to updates from ebgp peers\n") | |
3162 | { | |
d62a17ae | 3163 | int idx_peer = 1; |
3164 | int idx_number = 3; | |
3165 | struct peer *peer; | |
3166 | int ret; | |
3167 | as_t as; | |
718e3744 | 3168 | |
d62a17ae | 3169 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3170 | if (!peer) | |
3171 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3172 | |
d62a17ae | 3173 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3174 | ret = peer_local_as_set(peer, as, 1, 0); | |
3175 | return bgp_vty_return(vty, ret); | |
718e3744 | 3176 | } |
3177 | ||
9d3f9705 AC |
3178 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3179 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3180 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3181 | NEIGHBOR_STR |
3182 | NEIGHBOR_ADDR_STR2 | |
3183 | "Specify a local-as number\n" | |
3184 | "AS number used as local AS\n" | |
3185 | "Do not prepend local-as to updates from ebgp peers\n" | |
3186 | "Do not prepend local-as to updates from ibgp peers\n") | |
3187 | { | |
d62a17ae | 3188 | int idx_peer = 1; |
3189 | int idx_number = 3; | |
3190 | struct peer *peer; | |
3191 | int ret; | |
3192 | as_t as; | |
9d3f9705 | 3193 | |
d62a17ae | 3194 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3195 | if (!peer) | |
3196 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3197 | |
d62a17ae | 3198 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3199 | ret = peer_local_as_set(peer, as, 1, 1); | |
3200 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3201 | } |
3202 | ||
718e3744 | 3203 | DEFUN (no_neighbor_local_as, |
3204 | no_neighbor_local_as_cmd, | |
a636c635 | 3205 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3206 | NO_STR |
3207 | NEIGHBOR_STR | |
3208 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3209 | "Specify a local-as number\n" |
3210 | "AS number used as local AS\n" | |
3211 | "Do not prepend local-as to updates from ebgp peers\n" | |
3212 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3213 | { |
d62a17ae | 3214 | int idx_peer = 2; |
3215 | struct peer *peer; | |
3216 | int ret; | |
718e3744 | 3217 | |
d62a17ae | 3218 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3219 | if (!peer) | |
3220 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3221 | |
d62a17ae | 3222 | ret = peer_local_as_unset(peer); |
3223 | return bgp_vty_return(vty, ret); | |
718e3744 | 3224 | } |
3225 | ||
718e3744 | 3226 | |
3f9c7369 DS |
3227 | DEFUN (neighbor_solo, |
3228 | neighbor_solo_cmd, | |
9ccf14f7 | 3229 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3230 | NEIGHBOR_STR |
3231 | NEIGHBOR_ADDR_STR2 | |
3232 | "Solo peer - part of its own update group\n") | |
3233 | { | |
d62a17ae | 3234 | int idx_peer = 1; |
3235 | struct peer *peer; | |
3236 | int ret; | |
3f9c7369 | 3237 | |
d62a17ae | 3238 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3239 | if (!peer) | |
3240 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3241 | |
d62a17ae | 3242 | ret = update_group_adjust_soloness(peer, 1); |
3243 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3244 | } |
3245 | ||
3246 | DEFUN (no_neighbor_solo, | |
3247 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3248 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3249 | NO_STR |
3250 | NEIGHBOR_STR | |
3251 | NEIGHBOR_ADDR_STR2 | |
3252 | "Solo peer - part of its own update group\n") | |
3253 | { | |
d62a17ae | 3254 | int idx_peer = 2; |
3255 | struct peer *peer; | |
3256 | int ret; | |
3f9c7369 | 3257 | |
d62a17ae | 3258 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3259 | if (!peer) | |
3260 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3261 | |
d62a17ae | 3262 | ret = update_group_adjust_soloness(peer, 0); |
3263 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3264 | } |
3265 | ||
0df7c91f PJ |
3266 | DEFUN (neighbor_password, |
3267 | neighbor_password_cmd, | |
9ccf14f7 | 3268 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3269 | NEIGHBOR_STR |
3270 | NEIGHBOR_ADDR_STR2 | |
3271 | "Set a password\n" | |
3272 | "The password\n") | |
3273 | { | |
d62a17ae | 3274 | int idx_peer = 1; |
3275 | int idx_line = 3; | |
3276 | struct peer *peer; | |
3277 | int ret; | |
0df7c91f | 3278 | |
d62a17ae | 3279 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3280 | if (!peer) | |
3281 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3282 | |
d62a17ae | 3283 | ret = peer_password_set(peer, argv[idx_line]->arg); |
3284 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
3285 | } |
3286 | ||
3287 | DEFUN (no_neighbor_password, | |
3288 | no_neighbor_password_cmd, | |
a636c635 | 3289 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3290 | NO_STR |
3291 | NEIGHBOR_STR | |
3292 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3293 | "Set a password\n" |
3294 | "The password\n") | |
0df7c91f | 3295 | { |
d62a17ae | 3296 | int idx_peer = 2; |
3297 | struct peer *peer; | |
3298 | int ret; | |
0df7c91f | 3299 | |
d62a17ae | 3300 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3301 | if (!peer) | |
3302 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3303 | |
d62a17ae | 3304 | ret = peer_password_unset(peer); |
3305 | return bgp_vty_return(vty, ret); | |
0df7c91f | 3306 | } |
6b0655a2 | 3307 | |
718e3744 | 3308 | DEFUN (neighbor_activate, |
3309 | neighbor_activate_cmd, | |
9ccf14f7 | 3310 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3311 | NEIGHBOR_STR |
3312 | NEIGHBOR_ADDR_STR2 | |
3313 | "Enable the Address Family for this Neighbor\n") | |
3314 | { | |
d62a17ae | 3315 | int idx_peer = 1; |
3316 | int ret; | |
3317 | struct peer *peer; | |
718e3744 | 3318 | |
d62a17ae | 3319 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3320 | if (!peer) | |
3321 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3322 | |
d62a17ae | 3323 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3324 | return bgp_vty_return(vty, ret); | |
718e3744 | 3325 | } |
3326 | ||
d62a17ae | 3327 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
3328 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3329 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3330 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3331 | |
718e3744 | 3332 | DEFUN (no_neighbor_activate, |
3333 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3334 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3335 | NO_STR |
3336 | NEIGHBOR_STR | |
3337 | NEIGHBOR_ADDR_STR2 | |
3338 | "Enable the Address Family for this Neighbor\n") | |
3339 | { | |
d62a17ae | 3340 | int idx_peer = 2; |
3341 | int ret; | |
3342 | struct peer *peer; | |
718e3744 | 3343 | |
d62a17ae | 3344 | /* Lookup peer. */ |
3345 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3346 | if (!peer) | |
3347 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3348 | |
d62a17ae | 3349 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3350 | return bgp_vty_return(vty, ret); | |
718e3744 | 3351 | } |
6b0655a2 | 3352 | |
d62a17ae | 3353 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
3354 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3355 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3356 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3357 | |
718e3744 | 3358 | DEFUN (neighbor_set_peer_group, |
3359 | neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3360 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3361 | NEIGHBOR_STR |
a80beece | 3362 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3363 | "Member of the peer-group\n" |
16cedbb0 | 3364 | "Peer-group name\n") |
718e3744 | 3365 | { |
d62a17ae | 3366 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3367 | int idx_peer = 1; | |
3368 | int idx_word = 3; | |
3369 | int ret; | |
3370 | as_t as; | |
3371 | union sockunion su; | |
3372 | struct peer *peer; | |
3373 | struct peer_group *group; | |
3374 | ||
d62a17ae | 3375 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
3376 | if (ret < 0) { | |
3377 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3378 | if (!peer) { | |
3379 | vty_out(vty, "%% Malformed address or name: %s\n", | |
3380 | argv[idx_peer]->arg); | |
3381 | return CMD_WARNING_CONFIG_FAILED; | |
3382 | } | |
3383 | } else { | |
3384 | if (peer_address_self_check(bgp, &su)) { | |
3385 | vty_out(vty, | |
3386 | "%% Can not configure the local system as neighbor\n"); | |
3387 | return CMD_WARNING_CONFIG_FAILED; | |
3388 | } | |
3389 | ||
3390 | /* Disallow for dynamic neighbor. */ | |
3391 | peer = peer_lookup(bgp, &su); | |
3392 | if (peer && peer_dynamic_neighbor(peer)) { | |
3393 | vty_out(vty, | |
3394 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3395 | return CMD_WARNING_CONFIG_FAILED; | |
3396 | } | |
3397 | } | |
3398 | ||
3399 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3400 | if (!group) { | |
3401 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3402 | return CMD_WARNING_CONFIG_FAILED; | |
3403 | } | |
3404 | ||
3405 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3406 | ||
3407 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
3408 | vty_out(vty, | |
3409 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
3410 | as); | |
3411 | return CMD_WARNING_CONFIG_FAILED; | |
3412 | } | |
3413 | ||
3414 | return bgp_vty_return(vty, ret); | |
3415 | } | |
3416 | ||
3417 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
3418 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3419 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3420 | "Member of the peer-group\n" | |
3421 | "Peer-group name\n") | |
596c17ba | 3422 | |
718e3744 | 3423 | DEFUN (no_neighbor_set_peer_group, |
3424 | no_neighbor_set_peer_group_cmd, | |
9ccf14f7 | 3425 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", |
718e3744 | 3426 | NO_STR |
3427 | NEIGHBOR_STR | |
a80beece | 3428 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3429 | "Member of the peer-group\n" |
16cedbb0 | 3430 | "Peer-group name\n") |
718e3744 | 3431 | { |
d62a17ae | 3432 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3433 | int idx_peer = 2; | |
3434 | int idx_word = 4; | |
3435 | int ret; | |
3436 | struct peer *peer; | |
3437 | struct peer_group *group; | |
3438 | ||
3439 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
3440 | if (!peer) | |
3441 | return CMD_WARNING_CONFIG_FAILED; | |
3442 | ||
3443 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3444 | if (!group) { | |
3445 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3446 | return CMD_WARNING_CONFIG_FAILED; | |
3447 | } | |
718e3744 | 3448 | |
827ed707 | 3449 | ret = peer_delete(peer); |
718e3744 | 3450 | |
d62a17ae | 3451 | return bgp_vty_return(vty, ret); |
718e3744 | 3452 | } |
6b0655a2 | 3453 | |
d62a17ae | 3454 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
3455 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD", | |
3456 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3457 | "Member of the peer-group\n" | |
3458 | "Peer-group name\n") | |
596c17ba | 3459 | |
d62a17ae | 3460 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3461 | uint32_t flag, int set) |
718e3744 | 3462 | { |
d62a17ae | 3463 | int ret; |
3464 | struct peer *peer; | |
718e3744 | 3465 | |
d62a17ae | 3466 | peer = peer_and_group_lookup_vty(vty, ip_str); |
3467 | if (!peer) | |
3468 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3469 | |
7ebe625c QY |
3470 | /* |
3471 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3472 | * we should not accept disable-connected-check. | |
3473 | */ | |
3474 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3475 | vty_out(vty, | |
3476 | "%s is directly connected peer, cannot accept disable-" | |
3477 | "connected-check\n", | |
3478 | ip_str); | |
3479 | return CMD_WARNING_CONFIG_FAILED; | |
3480 | } | |
3481 | ||
d62a17ae | 3482 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3483 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 3484 | |
d62a17ae | 3485 | if (set) |
3486 | ret = peer_flag_set(peer, flag); | |
3487 | else | |
3488 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 3489 | |
d62a17ae | 3490 | return bgp_vty_return(vty, ret); |
718e3744 | 3491 | } |
3492 | ||
47cbc09b | 3493 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 3494 | { |
d62a17ae | 3495 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 3496 | } |
3497 | ||
d62a17ae | 3498 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3499 | uint32_t flag) |
718e3744 | 3500 | { |
d62a17ae | 3501 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 3502 | } |
3503 | ||
3504 | /* neighbor passive. */ | |
3505 | DEFUN (neighbor_passive, | |
3506 | neighbor_passive_cmd, | |
9ccf14f7 | 3507 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3508 | NEIGHBOR_STR |
3509 | NEIGHBOR_ADDR_STR2 | |
3510 | "Don't send open messages to this neighbor\n") | |
3511 | { | |
d62a17ae | 3512 | int idx_peer = 1; |
3513 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3514 | } |
3515 | ||
3516 | DEFUN (no_neighbor_passive, | |
3517 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3518 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3519 | NO_STR |
3520 | NEIGHBOR_STR | |
3521 | NEIGHBOR_ADDR_STR2 | |
3522 | "Don't send open messages to this neighbor\n") | |
3523 | { | |
d62a17ae | 3524 | int idx_peer = 2; |
3525 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3526 | } |
6b0655a2 | 3527 | |
718e3744 | 3528 | /* neighbor shutdown. */ |
73d70fa6 DL |
3529 | DEFUN (neighbor_shutdown_msg, |
3530 | neighbor_shutdown_msg_cmd, | |
3531 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3532 | NEIGHBOR_STR |
3533 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3534 | "Administratively shut down this neighbor\n" |
3535 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3536 | "Shutdown message\n") | |
718e3744 | 3537 | { |
d62a17ae | 3538 | int idx_peer = 1; |
73d70fa6 | 3539 | |
d62a17ae | 3540 | if (argc >= 5) { |
3541 | struct peer *peer = | |
3542 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3543 | char *message; | |
73d70fa6 | 3544 | |
d62a17ae | 3545 | if (!peer) |
3546 | return CMD_WARNING_CONFIG_FAILED; | |
3547 | message = argv_concat(argv, argc, 4); | |
3548 | peer_tx_shutdown_message_set(peer, message); | |
3549 | XFREE(MTYPE_TMP, message); | |
3550 | } | |
73d70fa6 | 3551 | |
d62a17ae | 3552 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3553 | } |
3554 | ||
d62a17ae | 3555 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
3556 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3557 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3558 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3559 | |
3560 | DEFUN (no_neighbor_shutdown_msg, | |
3561 | no_neighbor_shutdown_msg_cmd, | |
3562 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3563 | NO_STR | |
3564 | NEIGHBOR_STR | |
3565 | NEIGHBOR_ADDR_STR2 | |
3566 | "Administratively shut down this neighbor\n" | |
3567 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3568 | "Shutdown message\n") | |
718e3744 | 3569 | { |
d62a17ae | 3570 | int idx_peer = 2; |
73d70fa6 | 3571 | |
d62a17ae | 3572 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
3573 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 3574 | } |
6b0655a2 | 3575 | |
d62a17ae | 3576 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
3577 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3578 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3579 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 3580 | |
718e3744 | 3581 | /* neighbor capability dynamic. */ |
3582 | DEFUN (neighbor_capability_dynamic, | |
3583 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3584 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3585 | NEIGHBOR_STR |
3586 | NEIGHBOR_ADDR_STR2 | |
3587 | "Advertise capability to the peer\n" | |
3588 | "Advertise dynamic capability to this neighbor\n") | |
3589 | { | |
d62a17ae | 3590 | int idx_peer = 1; |
3591 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3592 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3593 | } |
3594 | ||
3595 | DEFUN (no_neighbor_capability_dynamic, | |
3596 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3597 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3598 | NO_STR |
3599 | NEIGHBOR_STR | |
3600 | NEIGHBOR_ADDR_STR2 | |
3601 | "Advertise capability to the peer\n" | |
3602 | "Advertise dynamic capability to this neighbor\n") | |
3603 | { | |
d62a17ae | 3604 | int idx_peer = 2; |
3605 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3606 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3607 | } |
6b0655a2 | 3608 | |
718e3744 | 3609 | /* neighbor dont-capability-negotiate */ |
3610 | DEFUN (neighbor_dont_capability_negotiate, | |
3611 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3612 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3613 | NEIGHBOR_STR |
3614 | NEIGHBOR_ADDR_STR2 | |
3615 | "Do not perform capability negotiation\n") | |
3616 | { | |
d62a17ae | 3617 | int idx_peer = 1; |
3618 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3619 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3620 | } |
3621 | ||
3622 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3623 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3624 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3625 | NO_STR |
3626 | NEIGHBOR_STR | |
3627 | NEIGHBOR_ADDR_STR2 | |
3628 | "Do not perform capability negotiation\n") | |
3629 | { | |
d62a17ae | 3630 | int idx_peer = 2; |
3631 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3632 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3633 | } |
6b0655a2 | 3634 | |
8a92a8a0 DS |
3635 | /* neighbor capability extended next hop encoding */ |
3636 | DEFUN (neighbor_capability_enhe, | |
3637 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3638 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3639 | NEIGHBOR_STR |
3640 | NEIGHBOR_ADDR_STR2 | |
3641 | "Advertise capability to the peer\n" | |
3642 | "Advertise extended next-hop capability to the peer\n") | |
3643 | { | |
d62a17ae | 3644 | int idx_peer = 1; |
3645 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3646 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3647 | } |
3648 | ||
3649 | DEFUN (no_neighbor_capability_enhe, | |
3650 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3651 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3652 | NO_STR |
3653 | NEIGHBOR_STR | |
3654 | NEIGHBOR_ADDR_STR2 | |
3655 | "Advertise capability to the peer\n" | |
3656 | "Advertise extended next-hop capability to the peer\n") | |
3657 | { | |
d62a17ae | 3658 | int idx_peer = 2; |
3659 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3660 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3661 | } |
3662 | ||
d62a17ae | 3663 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3664 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 3665 | int set) |
718e3744 | 3666 | { |
d62a17ae | 3667 | int ret; |
3668 | struct peer *peer; | |
718e3744 | 3669 | |
d62a17ae | 3670 | peer = peer_and_group_lookup_vty(vty, peer_str); |
3671 | if (!peer) | |
3672 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3673 | |
d62a17ae | 3674 | if (set) |
3675 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
3676 | else | |
3677 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 3678 | |
d62a17ae | 3679 | return bgp_vty_return(vty, ret); |
718e3744 | 3680 | } |
3681 | ||
d62a17ae | 3682 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3683 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3684 | { |
d62a17ae | 3685 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 3686 | } |
3687 | ||
d62a17ae | 3688 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3689 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3690 | { |
d62a17ae | 3691 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 3692 | } |
6b0655a2 | 3693 | |
718e3744 | 3694 | /* neighbor capability orf prefix-list. */ |
3695 | DEFUN (neighbor_capability_orf_prefix, | |
3696 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3697 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3698 | NEIGHBOR_STR |
3699 | NEIGHBOR_ADDR_STR2 | |
3700 | "Advertise capability to the peer\n" | |
3701 | "Advertise ORF capability to the peer\n" | |
3702 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3703 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3704 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3705 | "Capability to SEND the ORF to this neighbor\n") | |
3706 | { | |
d62a17ae | 3707 | int idx_peer = 1; |
3708 | int idx_send_recv = 5; | |
d7c0a89a | 3709 | uint16_t flag = 0; |
d62a17ae | 3710 | |
3711 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3712 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3713 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3714 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3715 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3716 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3717 | else { | |
3718 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3719 | return CMD_WARNING_CONFIG_FAILED; | |
3720 | } | |
3721 | ||
3722 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3723 | bgp_node_safi(vty), flag); | |
3724 | } | |
3725 | ||
3726 | ALIAS_HIDDEN( | |
3727 | neighbor_capability_orf_prefix, | |
3728 | neighbor_capability_orf_prefix_hidden_cmd, | |
3729 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3730 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3731 | "Advertise capability to the peer\n" | |
3732 | "Advertise ORF capability to the peer\n" | |
3733 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3734 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3735 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3736 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3737 | |
718e3744 | 3738 | DEFUN (no_neighbor_capability_orf_prefix, |
3739 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3740 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3741 | NO_STR |
3742 | NEIGHBOR_STR | |
3743 | NEIGHBOR_ADDR_STR2 | |
3744 | "Advertise capability to the peer\n" | |
3745 | "Advertise ORF capability to the peer\n" | |
3746 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3747 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3748 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3749 | "Capability to SEND the ORF to this neighbor\n") | |
3750 | { | |
d62a17ae | 3751 | int idx_peer = 2; |
3752 | int idx_send_recv = 6; | |
d7c0a89a | 3753 | uint16_t flag = 0; |
d62a17ae | 3754 | |
3755 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3756 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3757 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3758 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3759 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3760 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3761 | else { | |
3762 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3763 | return CMD_WARNING_CONFIG_FAILED; | |
3764 | } | |
3765 | ||
3766 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3767 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3768 | flag); | |
3769 | } | |
3770 | ||
3771 | ALIAS_HIDDEN( | |
3772 | no_neighbor_capability_orf_prefix, | |
3773 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
3774 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3775 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3776 | "Advertise capability to the peer\n" | |
3777 | "Advertise ORF capability to the peer\n" | |
3778 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3779 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3780 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3781 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3782 | |
718e3744 | 3783 | /* neighbor next-hop-self. */ |
3784 | DEFUN (neighbor_nexthop_self, | |
3785 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3786 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3787 | NEIGHBOR_STR |
3788 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3789 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3790 | { |
d62a17ae | 3791 | int idx_peer = 1; |
3792 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3793 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 3794 | } |
9e7a53c1 | 3795 | |
d62a17ae | 3796 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
3797 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3798 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3799 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3800 | |
a538debe DS |
3801 | /* neighbor next-hop-self. */ |
3802 | DEFUN (neighbor_nexthop_self_force, | |
3803 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3804 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3805 | NEIGHBOR_STR |
3806 | NEIGHBOR_ADDR_STR2 | |
3807 | "Disable the next hop calculation for this neighbor\n" | |
3808 | "Set the next hop to self for reflected routes\n") | |
3809 | { | |
d62a17ae | 3810 | int idx_peer = 1; |
3811 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3812 | bgp_node_safi(vty), | |
3813 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 3814 | } |
3815 | ||
d62a17ae | 3816 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3817 | neighbor_nexthop_self_force_hidden_cmd, | |
3818 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3819 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3820 | "Disable the next hop calculation for this neighbor\n" | |
3821 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3822 | |
718e3744 | 3823 | DEFUN (no_neighbor_nexthop_self, |
3824 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3825 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3826 | NO_STR |
3827 | NEIGHBOR_STR | |
3828 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3829 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3830 | { |
d62a17ae | 3831 | int idx_peer = 2; |
3832 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3833 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3834 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 3835 | } |
6b0655a2 | 3836 | |
d62a17ae | 3837 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
3838 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3839 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3840 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3841 | |
88b8ed8d | 3842 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3843 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3844 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3845 | NO_STR |
3846 | NEIGHBOR_STR | |
3847 | NEIGHBOR_ADDR_STR2 | |
3848 | "Disable the next hop calculation for this neighbor\n" | |
3849 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3850 | { |
d62a17ae | 3851 | int idx_peer = 2; |
3852 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3853 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3854 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 3855 | } |
a538debe | 3856 | |
d62a17ae | 3857 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
3858 | no_neighbor_nexthop_self_force_hidden_cmd, | |
3859 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3860 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3861 | "Disable the next hop calculation for this neighbor\n" | |
3862 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3863 | |
c7122e14 DS |
3864 | /* neighbor as-override */ |
3865 | DEFUN (neighbor_as_override, | |
3866 | neighbor_as_override_cmd, | |
9ccf14f7 | 3867 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3868 | NEIGHBOR_STR |
3869 | NEIGHBOR_ADDR_STR2 | |
3870 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3871 | { | |
d62a17ae | 3872 | int idx_peer = 1; |
3873 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3874 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3875 | } |
3876 | ||
d62a17ae | 3877 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
3878 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3879 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3880 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3881 | |
c7122e14 DS |
3882 | DEFUN (no_neighbor_as_override, |
3883 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3884 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3885 | NO_STR |
3886 | NEIGHBOR_STR | |
3887 | NEIGHBOR_ADDR_STR2 | |
3888 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3889 | { | |
d62a17ae | 3890 | int idx_peer = 2; |
3891 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3892 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3893 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3894 | } |
3895 | ||
d62a17ae | 3896 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
3897 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3898 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3899 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3900 | |
718e3744 | 3901 | /* neighbor remove-private-AS. */ |
3902 | DEFUN (neighbor_remove_private_as, | |
3903 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3904 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3905 | NEIGHBOR_STR |
3906 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3907 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3908 | { |
d62a17ae | 3909 | int idx_peer = 1; |
3910 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3911 | bgp_node_safi(vty), | |
3912 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 3913 | } |
3914 | ||
d62a17ae | 3915 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
3916 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
3917 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3918 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 3919 | |
5000f21c DS |
3920 | DEFUN (neighbor_remove_private_as_all, |
3921 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 3922 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
3923 | NEIGHBOR_STR |
3924 | NEIGHBOR_ADDR_STR2 | |
3925 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 3926 | "Apply to all AS numbers\n") |
5000f21c | 3927 | { |
d62a17ae | 3928 | int idx_peer = 1; |
3929 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3930 | bgp_node_safi(vty), | |
3931 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
3932 | } |
3933 | ||
d62a17ae | 3934 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
3935 | neighbor_remove_private_as_all_hidden_cmd, | |
3936 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
3937 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3938 | "Remove private ASNs in outbound updates\n" | |
3939 | "Apply to all AS numbers") | |
596c17ba | 3940 | |
5000f21c DS |
3941 | DEFUN (neighbor_remove_private_as_replace_as, |
3942 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 3943 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
3944 | NEIGHBOR_STR |
3945 | NEIGHBOR_ADDR_STR2 | |
3946 | "Remove private ASNs in outbound updates\n" | |
3947 | "Replace private ASNs with our ASN in outbound updates\n") | |
3948 | { | |
d62a17ae | 3949 | int idx_peer = 1; |
3950 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3951 | bgp_node_safi(vty), | |
3952 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
3953 | } |
3954 | ||
d62a17ae | 3955 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
3956 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
3957 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
3958 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3959 | "Remove private ASNs in outbound updates\n" | |
3960 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3961 | |
5000f21c DS |
3962 | DEFUN (neighbor_remove_private_as_all_replace_as, |
3963 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 3964 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
3965 | NEIGHBOR_STR |
3966 | NEIGHBOR_ADDR_STR2 | |
3967 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 3968 | "Apply to all AS numbers\n" |
5000f21c DS |
3969 | "Replace private ASNs with our ASN in outbound updates\n") |
3970 | { | |
d62a17ae | 3971 | int idx_peer = 1; |
3972 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3973 | bgp_node_safi(vty), | |
3974 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
3975 | } |
3976 | ||
d62a17ae | 3977 | ALIAS_HIDDEN( |
3978 | neighbor_remove_private_as_all_replace_as, | |
3979 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
3980 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
3981 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3982 | "Remove private ASNs in outbound updates\n" | |
3983 | "Apply to all AS numbers\n" | |
3984 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 3985 | |
718e3744 | 3986 | DEFUN (no_neighbor_remove_private_as, |
3987 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3988 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3989 | NO_STR |
3990 | NEIGHBOR_STR | |
3991 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3992 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3993 | { |
d62a17ae | 3994 | int idx_peer = 2; |
3995 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3996 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3997 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 3998 | } |
6b0655a2 | 3999 | |
d62a17ae | 4000 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4001 | no_neighbor_remove_private_as_hidden_cmd, | |
4002 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4003 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4004 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4005 | |
88b8ed8d | 4006 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4007 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4008 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4009 | NO_STR |
4010 | NEIGHBOR_STR | |
4011 | NEIGHBOR_ADDR_STR2 | |
4012 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4013 | "Apply to all AS numbers\n") |
88b8ed8d | 4014 | { |
d62a17ae | 4015 | int idx_peer = 2; |
4016 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4017 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4018 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4019 | } |
5000f21c | 4020 | |
d62a17ae | 4021 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4022 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4023 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4024 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4025 | "Remove private ASNs in outbound updates\n" | |
4026 | "Apply to all AS numbers\n") | |
596c17ba | 4027 | |
88b8ed8d | 4028 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4029 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4030 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4031 | NO_STR |
4032 | NEIGHBOR_STR | |
4033 | NEIGHBOR_ADDR_STR2 | |
4034 | "Remove private ASNs in outbound updates\n" | |
4035 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4036 | { |
d62a17ae | 4037 | int idx_peer = 2; |
4038 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4039 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4040 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4041 | } |
5000f21c | 4042 | |
d62a17ae | 4043 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4044 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4045 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4046 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4047 | "Remove private ASNs in outbound updates\n" | |
4048 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4049 | |
88b8ed8d | 4050 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4051 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4052 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4053 | NO_STR |
4054 | NEIGHBOR_STR | |
4055 | NEIGHBOR_ADDR_STR2 | |
4056 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4057 | "Apply to all AS numbers\n" |
5000f21c | 4058 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4059 | { |
d62a17ae | 4060 | int idx_peer = 2; |
4061 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4062 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4063 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4064 | } |
5000f21c | 4065 | |
d62a17ae | 4066 | ALIAS_HIDDEN( |
4067 | no_neighbor_remove_private_as_all_replace_as, | |
4068 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4069 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4070 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4071 | "Remove private ASNs in outbound updates\n" | |
4072 | "Apply to all AS numbers\n" | |
4073 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4074 | |
5000f21c | 4075 | |
718e3744 | 4076 | /* neighbor send-community. */ |
4077 | DEFUN (neighbor_send_community, | |
4078 | neighbor_send_community_cmd, | |
9ccf14f7 | 4079 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4080 | NEIGHBOR_STR |
4081 | NEIGHBOR_ADDR_STR2 | |
4082 | "Send Community attribute to this neighbor\n") | |
4083 | { | |
d62a17ae | 4084 | int idx_peer = 1; |
27c05d4d | 4085 | |
d62a17ae | 4086 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4087 | bgp_node_safi(vty), | |
4088 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4089 | } |
4090 | ||
d62a17ae | 4091 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4092 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4093 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4094 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4095 | |
718e3744 | 4096 | DEFUN (no_neighbor_send_community, |
4097 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4098 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4099 | NO_STR |
4100 | NEIGHBOR_STR | |
4101 | NEIGHBOR_ADDR_STR2 | |
4102 | "Send Community attribute to this neighbor\n") | |
4103 | { | |
d62a17ae | 4104 | int idx_peer = 2; |
27c05d4d | 4105 | |
d62a17ae | 4106 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4107 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4108 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4109 | } |
6b0655a2 | 4110 | |
d62a17ae | 4111 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4112 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4113 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4114 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4115 | |
718e3744 | 4116 | /* neighbor send-community extended. */ |
4117 | DEFUN (neighbor_send_community_type, | |
4118 | neighbor_send_community_type_cmd, | |
57d187bc | 4119 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4120 | NEIGHBOR_STR |
4121 | NEIGHBOR_ADDR_STR2 | |
4122 | "Send Community attribute to this neighbor\n" | |
4123 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4124 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4125 | "Send Extended Community attributes\n" |
57d187bc JS |
4126 | "Send Standard Community attributes\n" |
4127 | "Send Large Community attributes\n") | |
718e3744 | 4128 | { |
27c05d4d | 4129 | int idx_peer = 1; |
d7c0a89a | 4130 | uint32_t flag = 0; |
27c05d4d | 4131 | const char *type = argv[argc - 1]->text; |
d62a17ae | 4132 | |
27c05d4d | 4133 | if (strmatch(type, "standard")) { |
d62a17ae | 4134 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
27c05d4d | 4135 | } else if (strmatch(type, "extended")) { |
d62a17ae | 4136 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); |
27c05d4d | 4137 | } else if (strmatch(type, "large")) { |
d62a17ae | 4138 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); |
27c05d4d | 4139 | } else if (strmatch(type, "both")) { |
d62a17ae | 4140 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4141 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d | 4142 | } else { /* if (strmatch(type, "all")) */ |
d62a17ae | 4143 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4144 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4145 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4146 | } | |
4147 | ||
27c05d4d | 4148 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
d62a17ae | 4149 | bgp_node_safi(vty), flag); |
4150 | } | |
4151 | ||
4152 | ALIAS_HIDDEN( | |
4153 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4154 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4155 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4156 | "Send Community attribute to this neighbor\n" | |
4157 | "Send Standard and Extended Community attributes\n" | |
4158 | "Send Standard, Large and Extended Community attributes\n" | |
4159 | "Send Extended Community attributes\n" | |
4160 | "Send Standard Community attributes\n" | |
4161 | "Send Large Community attributes\n") | |
596c17ba | 4162 | |
718e3744 | 4163 | DEFUN (no_neighbor_send_community_type, |
4164 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4165 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4166 | NO_STR |
4167 | NEIGHBOR_STR | |
4168 | NEIGHBOR_ADDR_STR2 | |
4169 | "Send Community attribute to this neighbor\n" | |
4170 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4171 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4172 | "Send Extended Community attributes\n" |
57d187bc JS |
4173 | "Send Standard Community attributes\n" |
4174 | "Send Large Community attributes\n") | |
718e3744 | 4175 | { |
d62a17ae | 4176 | int idx_peer = 2; |
27c05d4d | 4177 | uint32_t flag = 0; |
d62a17ae | 4178 | const char *type = argv[argc - 1]->text; |
4179 | ||
27c05d4d PM |
4180 | if (strmatch(type, "standard")) { |
4181 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4182 | } else if (strmatch(type, "extended")) { | |
4183 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4184 | } else if (strmatch(type, "large")) { | |
4185 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4186 | } else if (strmatch(type, "both")) { | |
4187 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4188 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4189 | } else { /* if (strmatch(type, "all")) */ | |
4190 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4191 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4192 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4193 | } | |
4194 | ||
4195 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4196 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4197 | flag); | |
d62a17ae | 4198 | } |
4199 | ||
4200 | ALIAS_HIDDEN( | |
4201 | no_neighbor_send_community_type, | |
4202 | no_neighbor_send_community_type_hidden_cmd, | |
4203 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4204 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4205 | "Send Community attribute to this neighbor\n" | |
4206 | "Send Standard and Extended Community attributes\n" | |
4207 | "Send Standard, Large and Extended Community attributes\n" | |
4208 | "Send Extended Community attributes\n" | |
4209 | "Send Standard Community attributes\n" | |
4210 | "Send Large Community attributes\n") | |
596c17ba | 4211 | |
718e3744 | 4212 | /* neighbor soft-reconfig. */ |
4213 | DEFUN (neighbor_soft_reconfiguration, | |
4214 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4215 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4216 | NEIGHBOR_STR |
4217 | NEIGHBOR_ADDR_STR2 | |
4218 | "Per neighbor soft reconfiguration\n" | |
4219 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4220 | { | |
d62a17ae | 4221 | int idx_peer = 1; |
4222 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4223 | bgp_node_safi(vty), | |
4224 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4225 | } |
4226 | ||
d62a17ae | 4227 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4228 | neighbor_soft_reconfiguration_hidden_cmd, | |
4229 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4230 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4231 | "Per neighbor soft reconfiguration\n" | |
4232 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4233 | |
718e3744 | 4234 | DEFUN (no_neighbor_soft_reconfiguration, |
4235 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4236 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4237 | NO_STR |
4238 | NEIGHBOR_STR | |
4239 | NEIGHBOR_ADDR_STR2 | |
4240 | "Per neighbor soft reconfiguration\n" | |
4241 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4242 | { | |
d62a17ae | 4243 | int idx_peer = 2; |
4244 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4245 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4246 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4247 | } |
6b0655a2 | 4248 | |
d62a17ae | 4249 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
4250 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4251 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4252 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4253 | "Per neighbor soft reconfiguration\n" | |
4254 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4255 | |
718e3744 | 4256 | DEFUN (neighbor_route_reflector_client, |
4257 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4258 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4259 | NEIGHBOR_STR |
4260 | NEIGHBOR_ADDR_STR2 | |
4261 | "Configure a neighbor as Route Reflector client\n") | |
4262 | { | |
d62a17ae | 4263 | int idx_peer = 1; |
4264 | struct peer *peer; | |
718e3744 | 4265 | |
4266 | ||
d62a17ae | 4267 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4268 | if (!peer) | |
4269 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4270 | |
d62a17ae | 4271 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4272 | bgp_node_safi(vty), | |
4273 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4274 | } |
4275 | ||
d62a17ae | 4276 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
4277 | neighbor_route_reflector_client_hidden_cmd, | |
4278 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4279 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4280 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4281 | |
718e3744 | 4282 | DEFUN (no_neighbor_route_reflector_client, |
4283 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4284 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4285 | NO_STR |
4286 | NEIGHBOR_STR | |
4287 | NEIGHBOR_ADDR_STR2 | |
4288 | "Configure a neighbor as Route Reflector client\n") | |
4289 | { | |
d62a17ae | 4290 | int idx_peer = 2; |
4291 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4292 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4293 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4294 | } |
6b0655a2 | 4295 | |
d62a17ae | 4296 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
4297 | no_neighbor_route_reflector_client_hidden_cmd, | |
4298 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4299 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4300 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4301 | |
718e3744 | 4302 | /* neighbor route-server-client. */ |
4303 | DEFUN (neighbor_route_server_client, | |
4304 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4305 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4306 | NEIGHBOR_STR |
4307 | NEIGHBOR_ADDR_STR2 | |
4308 | "Configure a neighbor as Route Server client\n") | |
4309 | { | |
d62a17ae | 4310 | int idx_peer = 1; |
4311 | struct peer *peer; | |
2a3d5731 | 4312 | |
d62a17ae | 4313 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4314 | if (!peer) | |
4315 | return CMD_WARNING_CONFIG_FAILED; | |
4316 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4317 | bgp_node_safi(vty), | |
4318 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4319 | } |
4320 | ||
d62a17ae | 4321 | ALIAS_HIDDEN(neighbor_route_server_client, |
4322 | neighbor_route_server_client_hidden_cmd, | |
4323 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4324 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4325 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4326 | |
718e3744 | 4327 | DEFUN (no_neighbor_route_server_client, |
4328 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4329 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4330 | NO_STR |
4331 | NEIGHBOR_STR | |
4332 | NEIGHBOR_ADDR_STR2 | |
4333 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4334 | { |
d62a17ae | 4335 | int idx_peer = 2; |
4336 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4337 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4338 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4339 | } |
6b0655a2 | 4340 | |
d62a17ae | 4341 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
4342 | no_neighbor_route_server_client_hidden_cmd, | |
4343 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4344 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4345 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4346 | |
fee0f4c6 | 4347 | DEFUN (neighbor_nexthop_local_unchanged, |
4348 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4349 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4350 | NEIGHBOR_STR |
4351 | NEIGHBOR_ADDR_STR2 | |
4352 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4353 | "Leave link-local nexthop unchanged for this peer\n") | |
4354 | { | |
d62a17ae | 4355 | int idx_peer = 1; |
4356 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4357 | bgp_node_safi(vty), | |
4358 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 4359 | } |
6b0655a2 | 4360 | |
fee0f4c6 | 4361 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4362 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4363 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4364 | NO_STR |
4365 | NEIGHBOR_STR | |
4366 | NEIGHBOR_ADDR_STR2 | |
4367 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4368 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4369 | { |
d62a17ae | 4370 | int idx_peer = 2; |
4371 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4372 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4373 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 4374 | } |
6b0655a2 | 4375 | |
718e3744 | 4376 | DEFUN (neighbor_attr_unchanged, |
4377 | neighbor_attr_unchanged_cmd, | |
a8206004 | 4378 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 4379 | NEIGHBOR_STR |
4380 | NEIGHBOR_ADDR_STR2 | |
4381 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4382 | "As-path attribute\n" | |
4383 | "Nexthop attribute\n" | |
a8206004 | 4384 | "Med attribute\n") |
718e3744 | 4385 | { |
d62a17ae | 4386 | int idx = 0; |
8eeb0335 DW |
4387 | char *peer_str = argv[1]->arg; |
4388 | struct peer *peer; | |
d7c0a89a | 4389 | uint16_t flags = 0; |
8eeb0335 DW |
4390 | afi_t afi = bgp_node_afi(vty); |
4391 | safi_t safi = bgp_node_safi(vty); | |
4392 | ||
4393 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4394 | if (!peer) | |
4395 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4396 | |
4397 | if (argv_find(argv, argc, "as-path", &idx)) | |
4398 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4399 | idx = 0; | |
4400 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4401 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4402 | idx = 0; | |
4403 | if (argv_find(argv, argc, "med", &idx)) | |
4404 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4405 | ||
8eeb0335 DW |
4406 | /* no flags means all of them! */ |
4407 | if (!flags) { | |
d62a17ae | 4408 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
4409 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4410 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 4411 | } else { |
a4d82a8a PZ |
4412 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
4413 | && peer_af_flag_check(peer, afi, safi, | |
4414 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
4415 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4416 | PEER_FLAG_AS_PATH_UNCHANGED); | |
4417 | } | |
4418 | ||
a4d82a8a PZ |
4419 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
4420 | && peer_af_flag_check(peer, afi, safi, | |
4421 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
4422 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4423 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
4424 | } | |
4425 | ||
a4d82a8a PZ |
4426 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
4427 | && peer_af_flag_check(peer, afi, safi, | |
4428 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
4429 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4430 | PEER_FLAG_MED_UNCHANGED); | |
4431 | } | |
d62a17ae | 4432 | } |
4433 | ||
8eeb0335 | 4434 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 4435 | } |
4436 | ||
4437 | ALIAS_HIDDEN( | |
4438 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
4439 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4440 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4441 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4442 | "As-path attribute\n" | |
4443 | "Nexthop attribute\n" | |
4444 | "Med attribute\n") | |
596c17ba | 4445 | |
718e3744 | 4446 | DEFUN (no_neighbor_attr_unchanged, |
4447 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 4448 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 4449 | NO_STR |
718e3744 | 4450 | NEIGHBOR_STR |
4451 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4452 | "BGP attribute is propagated unchanged to this neighbor\n" |
4453 | "As-path attribute\n" | |
40e718b5 | 4454 | "Nexthop attribute\n" |
a8206004 | 4455 | "Med attribute\n") |
718e3744 | 4456 | { |
d62a17ae | 4457 | int idx = 0; |
4458 | char *peer = argv[2]->arg; | |
d7c0a89a | 4459 | uint16_t flags = 0; |
d62a17ae | 4460 | |
4461 | if (argv_find(argv, argc, "as-path", &idx)) | |
4462 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4463 | idx = 0; | |
4464 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4465 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4466 | idx = 0; | |
4467 | if (argv_find(argv, argc, "med", &idx)) | |
4468 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4469 | ||
4470 | if (!flags) // no flags means all of them! | |
4471 | { | |
4472 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4473 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4474 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4475 | } | |
4476 | ||
4477 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
4478 | bgp_node_safi(vty), flags); | |
4479 | } | |
4480 | ||
4481 | ALIAS_HIDDEN( | |
4482 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
4483 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4484 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4485 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4486 | "As-path attribute\n" | |
4487 | "Nexthop attribute\n" | |
4488 | "Med attribute\n") | |
718e3744 | 4489 | |
718e3744 | 4490 | /* EBGP multihop configuration. */ |
d62a17ae | 4491 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
4492 | const char *ttl_str) | |
718e3744 | 4493 | { |
d62a17ae | 4494 | struct peer *peer; |
4495 | unsigned int ttl; | |
718e3744 | 4496 | |
d62a17ae | 4497 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4498 | if (!peer) | |
4499 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4500 | |
d62a17ae | 4501 | if (peer->conf_if) |
4502 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 4503 | |
d62a17ae | 4504 | if (!ttl_str) |
4505 | ttl = MAXTTL; | |
4506 | else | |
4507 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 4508 | |
d62a17ae | 4509 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 4510 | } |
4511 | ||
d62a17ae | 4512 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4513 | { |
d62a17ae | 4514 | struct peer *peer; |
718e3744 | 4515 | |
d62a17ae | 4516 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4517 | if (!peer) | |
4518 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4519 | |
d62a17ae | 4520 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 4521 | } |
4522 | ||
4523 | /* neighbor ebgp-multihop. */ | |
4524 | DEFUN (neighbor_ebgp_multihop, | |
4525 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4526 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4527 | NEIGHBOR_STR |
4528 | NEIGHBOR_ADDR_STR2 | |
4529 | "Allow EBGP neighbors not on directly connected networks\n") | |
4530 | { | |
d62a17ae | 4531 | int idx_peer = 1; |
4532 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4533 | } |
4534 | ||
4535 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4536 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4537 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4538 | NEIGHBOR_STR |
4539 | NEIGHBOR_ADDR_STR2 | |
4540 | "Allow EBGP neighbors not on directly connected networks\n" | |
4541 | "maximum hop count\n") | |
4542 | { | |
d62a17ae | 4543 | int idx_peer = 1; |
4544 | int idx_number = 3; | |
4545 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
4546 | argv[idx_number]->arg); | |
718e3744 | 4547 | } |
4548 | ||
4549 | DEFUN (no_neighbor_ebgp_multihop, | |
4550 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4551 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4552 | NO_STR |
4553 | NEIGHBOR_STR | |
4554 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4555 | "Allow EBGP neighbors not on directly connected networks\n" |
4556 | "maximum hop count\n") | |
718e3744 | 4557 | { |
d62a17ae | 4558 | int idx_peer = 2; |
4559 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4560 | } |
4561 | ||
6b0655a2 | 4562 | |
6ffd2079 | 4563 | /* disable-connected-check */ |
4564 | DEFUN (neighbor_disable_connected_check, | |
4565 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 4566 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4567 | NEIGHBOR_STR |
7ebe625c | 4568 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4569 | "one-hop away EBGP peer using loopback address\n" |
4570 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4571 | { |
d62a17ae | 4572 | int idx_peer = 1; |
4573 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4574 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4575 | } |
4576 | ||
4577 | DEFUN (no_neighbor_disable_connected_check, | |
4578 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 4579 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4580 | NO_STR |
4581 | NEIGHBOR_STR | |
7ebe625c | 4582 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4583 | "one-hop away EBGP peer using loopback address\n" |
4584 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4585 | { |
d62a17ae | 4586 | int idx_peer = 2; |
4587 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4588 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4589 | } |
4590 | ||
47cbc09b PM |
4591 | |
4592 | /* enforce-first-as */ | |
4593 | DEFUN (neighbor_enforce_first_as, | |
4594 | neighbor_enforce_first_as_cmd, | |
4595 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4596 | NEIGHBOR_STR | |
4597 | NEIGHBOR_ADDR_STR2 | |
4598 | "Enforce the first AS for EBGP routes\n") | |
4599 | { | |
4600 | int idx_peer = 1; | |
4601 | ||
4602 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4603 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4604 | } | |
4605 | ||
4606 | DEFUN (no_neighbor_enforce_first_as, | |
4607 | no_neighbor_enforce_first_as_cmd, | |
4608 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4609 | NO_STR | |
4610 | NEIGHBOR_STR | |
4611 | NEIGHBOR_ADDR_STR2 | |
4612 | "Enforce the first AS for EBGP routes\n") | |
4613 | { | |
4614 | int idx_peer = 2; | |
4615 | ||
4616 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4617 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4618 | } | |
4619 | ||
4620 | ||
718e3744 | 4621 | DEFUN (neighbor_description, |
4622 | neighbor_description_cmd, | |
e961923c | 4623 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4624 | NEIGHBOR_STR |
4625 | NEIGHBOR_ADDR_STR2 | |
4626 | "Neighbor specific description\n" | |
4627 | "Up to 80 characters describing this neighbor\n") | |
4628 | { | |
d62a17ae | 4629 | int idx_peer = 1; |
4630 | int idx_line = 3; | |
4631 | struct peer *peer; | |
4632 | char *str; | |
718e3744 | 4633 | |
d62a17ae | 4634 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4635 | if (!peer) | |
4636 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4637 | |
d62a17ae | 4638 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4639 | |
d62a17ae | 4640 | peer_description_set(peer, str); |
718e3744 | 4641 | |
d62a17ae | 4642 | XFREE(MTYPE_TMP, str); |
718e3744 | 4643 | |
d62a17ae | 4644 | return CMD_SUCCESS; |
718e3744 | 4645 | } |
4646 | ||
4647 | DEFUN (no_neighbor_description, | |
4648 | no_neighbor_description_cmd, | |
a14810f4 | 4649 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 4650 | NO_STR |
4651 | NEIGHBOR_STR | |
4652 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 4653 | "Neighbor specific description\n") |
718e3744 | 4654 | { |
d62a17ae | 4655 | int idx_peer = 2; |
4656 | struct peer *peer; | |
718e3744 | 4657 | |
d62a17ae | 4658 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4659 | if (!peer) | |
4660 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4661 | |
d62a17ae | 4662 | peer_description_unset(peer); |
718e3744 | 4663 | |
d62a17ae | 4664 | return CMD_SUCCESS; |
718e3744 | 4665 | } |
4666 | ||
a14810f4 PM |
4667 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
4668 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
4669 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4670 | "Neighbor specific description\n" | |
4671 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 4672 | |
718e3744 | 4673 | /* Neighbor update-source. */ |
d62a17ae | 4674 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
4675 | const char *source_str) | |
4676 | { | |
4677 | struct peer *peer; | |
4678 | struct prefix p; | |
a14810f4 | 4679 | union sockunion su; |
d62a17ae | 4680 | |
4681 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4682 | if (!peer) | |
4683 | return CMD_WARNING_CONFIG_FAILED; | |
4684 | ||
4685 | if (peer->conf_if) | |
4686 | return CMD_WARNING; | |
4687 | ||
4688 | if (source_str) { | |
a14810f4 | 4689 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 4690 | peer_update_source_addr_set(peer, &su); |
4691 | else { | |
4692 | if (str2prefix(source_str, &p)) { | |
4693 | vty_out(vty, | |
4694 | "%% Invalid update-source, remove prefix length \n"); | |
4695 | return CMD_WARNING_CONFIG_FAILED; | |
4696 | } else | |
4697 | peer_update_source_if_set(peer, source_str); | |
4698 | } | |
4699 | } else | |
4700 | peer_update_source_unset(peer); | |
4701 | ||
4702 | return CMD_SUCCESS; | |
4703 | } | |
4704 | ||
4705 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
4706 | "IPv4 address\n" \ | |
4707 | "IPv6 address\n" \ | |
4708 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4709 | |
718e3744 | 4710 | DEFUN (neighbor_update_source, |
4711 | neighbor_update_source_cmd, | |
9ccf14f7 | 4712 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4713 | NEIGHBOR_STR |
4714 | NEIGHBOR_ADDR_STR2 | |
4715 | "Source of routing updates\n" | |
369688c0 | 4716 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4717 | { |
d62a17ae | 4718 | int idx_peer = 1; |
4719 | int idx_peer_2 = 3; | |
4720 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
4721 | argv[idx_peer_2]->arg); | |
718e3744 | 4722 | } |
4723 | ||
4724 | DEFUN (no_neighbor_update_source, | |
4725 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4726 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4727 | NO_STR |
4728 | NEIGHBOR_STR | |
4729 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4730 | "Source of routing updates\n" |
4731 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4732 | { |
d62a17ae | 4733 | int idx_peer = 2; |
4734 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4735 | } |
6b0655a2 | 4736 | |
d62a17ae | 4737 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
4738 | afi_t afi, safi_t safi, | |
4739 | const char *rmap, int set) | |
718e3744 | 4740 | { |
d62a17ae | 4741 | int ret; |
4742 | struct peer *peer; | |
718e3744 | 4743 | |
d62a17ae | 4744 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4745 | if (!peer) | |
4746 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4747 | |
d62a17ae | 4748 | if (set) |
4749 | ret = peer_default_originate_set(peer, afi, safi, rmap); | |
4750 | else | |
4751 | ret = peer_default_originate_unset(peer, afi, safi); | |
718e3744 | 4752 | |
d62a17ae | 4753 | return bgp_vty_return(vty, ret); |
718e3744 | 4754 | } |
4755 | ||
4756 | /* neighbor default-originate. */ | |
4757 | DEFUN (neighbor_default_originate, | |
4758 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4759 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4760 | NEIGHBOR_STR |
4761 | NEIGHBOR_ADDR_STR2 | |
4762 | "Originate default route to this neighbor\n") | |
4763 | { | |
d62a17ae | 4764 | int idx_peer = 1; |
4765 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4766 | bgp_node_afi(vty), | |
4767 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 4768 | } |
4769 | ||
d62a17ae | 4770 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
4771 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
4772 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4773 | "Originate default route to this neighbor\n") | |
596c17ba | 4774 | |
718e3744 | 4775 | DEFUN (neighbor_default_originate_rmap, |
4776 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4777 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4778 | NEIGHBOR_STR |
4779 | NEIGHBOR_ADDR_STR2 | |
4780 | "Originate default route to this neighbor\n" | |
4781 | "Route-map to specify criteria to originate default\n" | |
4782 | "route-map name\n") | |
4783 | { | |
d62a17ae | 4784 | int idx_peer = 1; |
4785 | int idx_word = 4; | |
4786 | return peer_default_originate_set_vty( | |
4787 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4788 | argv[idx_word]->arg, 1); | |
718e3744 | 4789 | } |
4790 | ||
d62a17ae | 4791 | ALIAS_HIDDEN( |
4792 | neighbor_default_originate_rmap, | |
4793 | neighbor_default_originate_rmap_hidden_cmd, | |
4794 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
4795 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4796 | "Originate default route to this neighbor\n" | |
4797 | "Route-map to specify criteria to originate default\n" | |
4798 | "route-map name\n") | |
596c17ba | 4799 | |
718e3744 | 4800 | DEFUN (no_neighbor_default_originate, |
4801 | no_neighbor_default_originate_cmd, | |
a636c635 | 4802 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4803 | NO_STR |
4804 | NEIGHBOR_STR | |
4805 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4806 | "Originate default route to this neighbor\n" |
4807 | "Route-map to specify criteria to originate default\n" | |
4808 | "route-map name\n") | |
718e3744 | 4809 | { |
d62a17ae | 4810 | int idx_peer = 2; |
4811 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4812 | bgp_node_afi(vty), | |
4813 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 4814 | } |
4815 | ||
d62a17ae | 4816 | ALIAS_HIDDEN( |
4817 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
4818 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
4819 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4820 | "Originate default route to this neighbor\n" | |
4821 | "Route-map to specify criteria to originate default\n" | |
4822 | "route-map name\n") | |
596c17ba | 4823 | |
6b0655a2 | 4824 | |
718e3744 | 4825 | /* Set neighbor's BGP port. */ |
d62a17ae | 4826 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
4827 | const char *port_str) | |
4828 | { | |
4829 | struct peer *peer; | |
d7c0a89a | 4830 | uint16_t port; |
d62a17ae | 4831 | struct servent *sp; |
4832 | ||
4833 | peer = peer_lookup_vty(vty, ip_str); | |
4834 | if (!peer) | |
4835 | return CMD_WARNING_CONFIG_FAILED; | |
4836 | ||
4837 | if (!port_str) { | |
4838 | sp = getservbyname("bgp", "tcp"); | |
4839 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
4840 | } else { | |
4841 | port = strtoul(port_str, NULL, 10); | |
4842 | } | |
718e3744 | 4843 | |
d62a17ae | 4844 | peer_port_set(peer, port); |
718e3744 | 4845 | |
d62a17ae | 4846 | return CMD_SUCCESS; |
718e3744 | 4847 | } |
4848 | ||
f418446b | 4849 | /* Set specified peer's BGP port. */ |
718e3744 | 4850 | DEFUN (neighbor_port, |
4851 | neighbor_port_cmd, | |
9ccf14f7 | 4852 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4853 | NEIGHBOR_STR |
4854 | NEIGHBOR_ADDR_STR | |
4855 | "Neighbor's BGP port\n" | |
4856 | "TCP port number\n") | |
4857 | { | |
d62a17ae | 4858 | int idx_ip = 1; |
4859 | int idx_number = 3; | |
4860 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
4861 | argv[idx_number]->arg); | |
718e3744 | 4862 | } |
4863 | ||
4864 | DEFUN (no_neighbor_port, | |
4865 | no_neighbor_port_cmd, | |
9ccf14f7 | 4866 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4867 | NO_STR |
4868 | NEIGHBOR_STR | |
4869 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4870 | "Neighbor's BGP port\n" |
4871 | "TCP port number\n") | |
718e3744 | 4872 | { |
d62a17ae | 4873 | int idx_ip = 2; |
4874 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4875 | } |
4876 | ||
6b0655a2 | 4877 | |
718e3744 | 4878 | /* neighbor weight. */ |
d62a17ae | 4879 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4880 | safi_t safi, const char *weight_str) | |
718e3744 | 4881 | { |
d62a17ae | 4882 | int ret; |
4883 | struct peer *peer; | |
4884 | unsigned long weight; | |
718e3744 | 4885 | |
d62a17ae | 4886 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4887 | if (!peer) | |
4888 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4889 | |
d62a17ae | 4890 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 4891 | |
d62a17ae | 4892 | ret = peer_weight_set(peer, afi, safi, weight); |
4893 | return bgp_vty_return(vty, ret); | |
718e3744 | 4894 | } |
4895 | ||
d62a17ae | 4896 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4897 | safi_t safi) | |
718e3744 | 4898 | { |
d62a17ae | 4899 | int ret; |
4900 | struct peer *peer; | |
718e3744 | 4901 | |
d62a17ae | 4902 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4903 | if (!peer) | |
4904 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4905 | |
d62a17ae | 4906 | ret = peer_weight_unset(peer, afi, safi); |
4907 | return bgp_vty_return(vty, ret); | |
718e3744 | 4908 | } |
4909 | ||
4910 | DEFUN (neighbor_weight, | |
4911 | neighbor_weight_cmd, | |
9ccf14f7 | 4912 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 4913 | NEIGHBOR_STR |
4914 | NEIGHBOR_ADDR_STR2 | |
4915 | "Set default weight for routes from this neighbor\n" | |
4916 | "default weight\n") | |
4917 | { | |
d62a17ae | 4918 | int idx_peer = 1; |
4919 | int idx_number = 3; | |
4920 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4921 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 4922 | } |
4923 | ||
d62a17ae | 4924 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
4925 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
4926 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4927 | "Set default weight for routes from this neighbor\n" | |
4928 | "default weight\n") | |
596c17ba | 4929 | |
718e3744 | 4930 | DEFUN (no_neighbor_weight, |
4931 | no_neighbor_weight_cmd, | |
9ccf14f7 | 4932 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 4933 | NO_STR |
4934 | NEIGHBOR_STR | |
4935 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
4936 | "Set default weight for routes from this neighbor\n" |
4937 | "default weight\n") | |
718e3744 | 4938 | { |
d62a17ae | 4939 | int idx_peer = 2; |
4940 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
4941 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 4942 | } |
4943 | ||
d62a17ae | 4944 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
4945 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
4946 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4947 | "Set default weight for routes from this neighbor\n" | |
4948 | "default weight\n") | |
596c17ba | 4949 | |
6b0655a2 | 4950 | |
718e3744 | 4951 | /* Override capability negotiation. */ |
4952 | DEFUN (neighbor_override_capability, | |
4953 | neighbor_override_capability_cmd, | |
9ccf14f7 | 4954 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4955 | NEIGHBOR_STR |
4956 | NEIGHBOR_ADDR_STR2 | |
4957 | "Override capability negotiation result\n") | |
4958 | { | |
d62a17ae | 4959 | int idx_peer = 1; |
4960 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4961 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4962 | } |
4963 | ||
4964 | DEFUN (no_neighbor_override_capability, | |
4965 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 4966 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 4967 | NO_STR |
4968 | NEIGHBOR_STR | |
4969 | NEIGHBOR_ADDR_STR2 | |
4970 | "Override capability negotiation result\n") | |
4971 | { | |
d62a17ae | 4972 | int idx_peer = 2; |
4973 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4974 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 4975 | } |
6b0655a2 | 4976 | |
718e3744 | 4977 | DEFUN (neighbor_strict_capability, |
4978 | neighbor_strict_capability_cmd, | |
9fb964de | 4979 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 4980 | NEIGHBOR_STR |
9fb964de | 4981 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4982 | "Strict capability negotiation match\n") |
4983 | { | |
9fb964de PM |
4984 | int idx_peer = 1; |
4985 | ||
4986 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 4987 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 4988 | } |
4989 | ||
4990 | DEFUN (no_neighbor_strict_capability, | |
4991 | no_neighbor_strict_capability_cmd, | |
9fb964de | 4992 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 4993 | NO_STR |
4994 | NEIGHBOR_STR | |
9fb964de | 4995 | NEIGHBOR_ADDR_STR2 |
718e3744 | 4996 | "Strict capability negotiation match\n") |
4997 | { | |
9fb964de PM |
4998 | int idx_peer = 2; |
4999 | ||
5000 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5001 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5002 | } |
6b0655a2 | 5003 | |
d62a17ae | 5004 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5005 | const char *keep_str, const char *hold_str) | |
718e3744 | 5006 | { |
d62a17ae | 5007 | int ret; |
5008 | struct peer *peer; | |
d7c0a89a QY |
5009 | uint32_t keepalive; |
5010 | uint32_t holdtime; | |
718e3744 | 5011 | |
d62a17ae | 5012 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5013 | if (!peer) | |
5014 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5015 | |
d62a17ae | 5016 | keepalive = strtoul(keep_str, NULL, 10); |
5017 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5018 | |
d62a17ae | 5019 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5020 | |
d62a17ae | 5021 | return bgp_vty_return(vty, ret); |
718e3744 | 5022 | } |
6b0655a2 | 5023 | |
d62a17ae | 5024 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5025 | { |
d62a17ae | 5026 | int ret; |
5027 | struct peer *peer; | |
718e3744 | 5028 | |
d62a17ae | 5029 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5030 | if (!peer) | |
5031 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5032 | |
d62a17ae | 5033 | ret = peer_timers_unset(peer); |
718e3744 | 5034 | |
d62a17ae | 5035 | return bgp_vty_return(vty, ret); |
718e3744 | 5036 | } |
5037 | ||
5038 | DEFUN (neighbor_timers, | |
5039 | neighbor_timers_cmd, | |
9ccf14f7 | 5040 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5041 | NEIGHBOR_STR |
5042 | NEIGHBOR_ADDR_STR2 | |
5043 | "BGP per neighbor timers\n" | |
5044 | "Keepalive interval\n" | |
5045 | "Holdtime\n") | |
5046 | { | |
d62a17ae | 5047 | int idx_peer = 1; |
5048 | int idx_number = 3; | |
5049 | int idx_number_2 = 4; | |
5050 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5051 | argv[idx_number]->arg, | |
5052 | argv[idx_number_2]->arg); | |
718e3744 | 5053 | } |
5054 | ||
5055 | DEFUN (no_neighbor_timers, | |
5056 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5057 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5058 | NO_STR |
5059 | NEIGHBOR_STR | |
5060 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5061 | "BGP per neighbor timers\n" |
5062 | "Keepalive interval\n" | |
5063 | "Holdtime\n") | |
718e3744 | 5064 | { |
d62a17ae | 5065 | int idx_peer = 2; |
5066 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5067 | } |
6b0655a2 | 5068 | |
813d4307 | 5069 | |
d62a17ae | 5070 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
5071 | const char *time_str) | |
718e3744 | 5072 | { |
d62a17ae | 5073 | int ret; |
5074 | struct peer *peer; | |
d7c0a89a | 5075 | uint32_t connect; |
718e3744 | 5076 | |
d62a17ae | 5077 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5078 | if (!peer) | |
5079 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5080 | |
d62a17ae | 5081 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5082 | |
d62a17ae | 5083 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5084 | |
d62a17ae | 5085 | return bgp_vty_return(vty, ret); |
718e3744 | 5086 | } |
5087 | ||
d62a17ae | 5088 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5089 | { |
d62a17ae | 5090 | int ret; |
5091 | struct peer *peer; | |
718e3744 | 5092 | |
d62a17ae | 5093 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5094 | if (!peer) | |
5095 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5096 | |
d62a17ae | 5097 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5098 | |
d62a17ae | 5099 | return bgp_vty_return(vty, ret); |
718e3744 | 5100 | } |
5101 | ||
5102 | DEFUN (neighbor_timers_connect, | |
5103 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5104 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5105 | NEIGHBOR_STR |
966f821c | 5106 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5107 | "BGP per neighbor timers\n" |
5108 | "BGP connect timer\n" | |
5109 | "Connect timer\n") | |
5110 | { | |
d62a17ae | 5111 | int idx_peer = 1; |
5112 | int idx_number = 4; | |
5113 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5114 | argv[idx_number]->arg); | |
718e3744 | 5115 | } |
5116 | ||
5117 | DEFUN (no_neighbor_timers_connect, | |
5118 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5119 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5120 | NO_STR |
5121 | NEIGHBOR_STR | |
966f821c | 5122 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5123 | "BGP per neighbor timers\n" |
8334fd5a DW |
5124 | "BGP connect timer\n" |
5125 | "Connect timer\n") | |
718e3744 | 5126 | { |
d62a17ae | 5127 | int idx_peer = 2; |
5128 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5129 | } |
5130 | ||
6b0655a2 | 5131 | |
d62a17ae | 5132 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5133 | const char *time_str, int set) | |
718e3744 | 5134 | { |
d62a17ae | 5135 | int ret; |
5136 | struct peer *peer; | |
d7c0a89a | 5137 | uint32_t routeadv = 0; |
718e3744 | 5138 | |
d62a17ae | 5139 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5140 | if (!peer) | |
5141 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5142 | |
d62a17ae | 5143 | if (time_str) |
5144 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5145 | |
d62a17ae | 5146 | if (set) |
5147 | ret = peer_advertise_interval_set(peer, routeadv); | |
5148 | else | |
5149 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5150 | |
d62a17ae | 5151 | return bgp_vty_return(vty, ret); |
718e3744 | 5152 | } |
5153 | ||
5154 | DEFUN (neighbor_advertise_interval, | |
5155 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5156 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5157 | NEIGHBOR_STR |
966f821c | 5158 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5159 | "Minimum interval between sending BGP routing updates\n" |
5160 | "time in seconds\n") | |
5161 | { | |
d62a17ae | 5162 | int idx_peer = 1; |
5163 | int idx_number = 3; | |
5164 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5165 | argv[idx_number]->arg, 1); | |
718e3744 | 5166 | } |
5167 | ||
5168 | DEFUN (no_neighbor_advertise_interval, | |
5169 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5170 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5171 | NO_STR |
5172 | NEIGHBOR_STR | |
966f821c | 5173 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5174 | "Minimum interval between sending BGP routing updates\n" |
5175 | "time in seconds\n") | |
718e3744 | 5176 | { |
d62a17ae | 5177 | int idx_peer = 2; |
5178 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5179 | } |
5180 | ||
6b0655a2 | 5181 | |
518f0eb1 DS |
5182 | /* Time to wait before processing route-map updates */ |
5183 | DEFUN (bgp_set_route_map_delay_timer, | |
5184 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5185 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5186 | SET_STR |
5187 | "BGP route-map delay timer\n" | |
5188 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5189 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5190 | { |
d62a17ae | 5191 | int idx_number = 3; |
d7c0a89a | 5192 | uint32_t rmap_delay_timer; |
d62a17ae | 5193 | |
5194 | if (argv[idx_number]->arg) { | |
5195 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
5196 | bm->rmap_update_timer = rmap_delay_timer; | |
5197 | ||
5198 | /* if the dynamic update handling is being disabled, and a timer | |
5199 | * is | |
5200 | * running, stop the timer and act as if the timer has already | |
5201 | * fired. | |
5202 | */ | |
5203 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
5204 | BGP_TIMER_OFF(bm->t_rmap_update); | |
5205 | thread_execute(bm->master, bgp_route_map_update_timer, | |
5206 | NULL, 0); | |
5207 | } | |
5208 | return CMD_SUCCESS; | |
5209 | } else { | |
5210 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5211 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5212 | } |
518f0eb1 DS |
5213 | } |
5214 | ||
5215 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5216 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5217 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5218 | NO_STR |
3a2d747c | 5219 | BGP_STR |
518f0eb1 | 5220 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5221 | "Reset to default time to wait for processing route-map changes\n" |
5222 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5223 | { |
518f0eb1 | 5224 | |
d62a17ae | 5225 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 5226 | |
d62a17ae | 5227 | return CMD_SUCCESS; |
518f0eb1 DS |
5228 | } |
5229 | ||
f414725f | 5230 | |
718e3744 | 5231 | /* neighbor interface */ |
d62a17ae | 5232 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
5233 | const char *str) | |
718e3744 | 5234 | { |
d62a17ae | 5235 | struct peer *peer; |
718e3744 | 5236 | |
d62a17ae | 5237 | peer = peer_lookup_vty(vty, ip_str); |
5238 | if (!peer || peer->conf_if) { | |
5239 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
5240 | return CMD_WARNING_CONFIG_FAILED; | |
5241 | } | |
718e3744 | 5242 | |
d62a17ae | 5243 | if (str) |
5244 | peer_interface_set(peer, str); | |
5245 | else | |
5246 | peer_interface_unset(peer); | |
718e3744 | 5247 | |
d62a17ae | 5248 | return CMD_SUCCESS; |
718e3744 | 5249 | } |
5250 | ||
5251 | DEFUN (neighbor_interface, | |
5252 | neighbor_interface_cmd, | |
9ccf14f7 | 5253 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5254 | NEIGHBOR_STR |
5255 | NEIGHBOR_ADDR_STR | |
5256 | "Interface\n" | |
5257 | "Interface name\n") | |
5258 | { | |
d62a17ae | 5259 | int idx_ip = 1; |
5260 | int idx_word = 3; | |
5261 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 5262 | } |
5263 | ||
5264 | DEFUN (no_neighbor_interface, | |
5265 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5266 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5267 | NO_STR |
5268 | NEIGHBOR_STR | |
16cedbb0 | 5269 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5270 | "Interface\n" |
5271 | "Interface name\n") | |
5272 | { | |
d62a17ae | 5273 | int idx_peer = 2; |
5274 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5275 | } |
6b0655a2 | 5276 | |
718e3744 | 5277 | DEFUN (neighbor_distribute_list, |
5278 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5279 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5280 | NEIGHBOR_STR |
5281 | NEIGHBOR_ADDR_STR2 | |
5282 | "Filter updates to/from this neighbor\n" | |
5283 | "IP access-list number\n" | |
5284 | "IP access-list number (expanded range)\n" | |
5285 | "IP Access-list name\n" | |
5286 | "Filter incoming updates\n" | |
5287 | "Filter outgoing updates\n") | |
5288 | { | |
d62a17ae | 5289 | int idx_peer = 1; |
5290 | int idx_acl = 3; | |
5291 | int direct, ret; | |
5292 | struct peer *peer; | |
a8206004 | 5293 | |
d62a17ae | 5294 | const char *pstr = argv[idx_peer]->arg; |
5295 | const char *acl = argv[idx_acl]->arg; | |
5296 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5297 | |
d62a17ae | 5298 | peer = peer_and_group_lookup_vty(vty, pstr); |
5299 | if (!peer) | |
5300 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5301 | |
d62a17ae | 5302 | /* Check filter direction. */ |
5303 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5304 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5305 | direct, acl); | |
a8206004 | 5306 | |
d62a17ae | 5307 | return bgp_vty_return(vty, ret); |
718e3744 | 5308 | } |
5309 | ||
d62a17ae | 5310 | ALIAS_HIDDEN( |
5311 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
5312 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5313 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5314 | "Filter updates to/from this neighbor\n" | |
5315 | "IP access-list number\n" | |
5316 | "IP access-list number (expanded range)\n" | |
5317 | "IP Access-list name\n" | |
5318 | "Filter incoming updates\n" | |
5319 | "Filter outgoing updates\n") | |
596c17ba | 5320 | |
718e3744 | 5321 | DEFUN (no_neighbor_distribute_list, |
5322 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5323 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5324 | NO_STR |
5325 | NEIGHBOR_STR | |
5326 | NEIGHBOR_ADDR_STR2 | |
5327 | "Filter updates to/from this neighbor\n" | |
5328 | "IP access-list number\n" | |
5329 | "IP access-list number (expanded range)\n" | |
5330 | "IP Access-list name\n" | |
5331 | "Filter incoming updates\n" | |
5332 | "Filter outgoing updates\n") | |
5333 | { | |
d62a17ae | 5334 | int idx_peer = 2; |
5335 | int direct, ret; | |
5336 | struct peer *peer; | |
a8206004 | 5337 | |
d62a17ae | 5338 | const char *pstr = argv[idx_peer]->arg; |
5339 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5340 | |
d62a17ae | 5341 | peer = peer_and_group_lookup_vty(vty, pstr); |
5342 | if (!peer) | |
5343 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5344 | |
d62a17ae | 5345 | /* Check filter direction. */ |
5346 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5347 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5348 | direct); | |
a8206004 | 5349 | |
d62a17ae | 5350 | return bgp_vty_return(vty, ret); |
718e3744 | 5351 | } |
6b0655a2 | 5352 | |
d62a17ae | 5353 | ALIAS_HIDDEN( |
5354 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
5355 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5356 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5357 | "Filter updates to/from this neighbor\n" | |
5358 | "IP access-list number\n" | |
5359 | "IP access-list number (expanded range)\n" | |
5360 | "IP Access-list name\n" | |
5361 | "Filter incoming updates\n" | |
5362 | "Filter outgoing updates\n") | |
596c17ba | 5363 | |
718e3744 | 5364 | /* Set prefix list to the peer. */ |
d62a17ae | 5365 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
5366 | afi_t afi, safi_t safi, | |
5367 | const char *name_str, | |
5368 | const char *direct_str) | |
718e3744 | 5369 | { |
d62a17ae | 5370 | int ret; |
d62a17ae | 5371 | int direct = FILTER_IN; |
cf9ac8bf | 5372 | struct peer *peer; |
718e3744 | 5373 | |
d62a17ae | 5374 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5375 | if (!peer) | |
5376 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5377 | |
d62a17ae | 5378 | /* Check filter direction. */ |
5379 | if (strncmp(direct_str, "i", 1) == 0) | |
5380 | direct = FILTER_IN; | |
5381 | else if (strncmp(direct_str, "o", 1) == 0) | |
5382 | direct = FILTER_OUT; | |
718e3744 | 5383 | |
d62a17ae | 5384 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 5385 | |
d62a17ae | 5386 | return bgp_vty_return(vty, ret); |
718e3744 | 5387 | } |
5388 | ||
d62a17ae | 5389 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
5390 | afi_t afi, safi_t safi, | |
5391 | const char *direct_str) | |
718e3744 | 5392 | { |
d62a17ae | 5393 | int ret; |
5394 | struct peer *peer; | |
5395 | int direct = FILTER_IN; | |
718e3744 | 5396 | |
d62a17ae | 5397 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5398 | if (!peer) | |
5399 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 5400 | |
d62a17ae | 5401 | /* Check filter direction. */ |
5402 | if (strncmp(direct_str, "i", 1) == 0) | |
5403 | direct = FILTER_IN; | |
5404 | else if (strncmp(direct_str, "o", 1) == 0) | |
5405 | direct = FILTER_OUT; | |
718e3744 | 5406 | |
d62a17ae | 5407 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 5408 | |
d62a17ae | 5409 | return bgp_vty_return(vty, ret); |
718e3744 | 5410 | } |
5411 | ||
5412 | DEFUN (neighbor_prefix_list, | |
5413 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5414 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5415 | NEIGHBOR_STR |
5416 | NEIGHBOR_ADDR_STR2 | |
5417 | "Filter updates to/from this neighbor\n" | |
5418 | "Name of a prefix list\n" | |
5419 | "Filter incoming updates\n" | |
5420 | "Filter outgoing updates\n") | |
5421 | { | |
d62a17ae | 5422 | int idx_peer = 1; |
5423 | int idx_word = 3; | |
5424 | int idx_in_out = 4; | |
5425 | return peer_prefix_list_set_vty( | |
5426 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5427 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5428 | } |
5429 | ||
d62a17ae | 5430 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
5431 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5432 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5433 | "Filter updates to/from this neighbor\n" | |
5434 | "Name of a prefix list\n" | |
5435 | "Filter incoming updates\n" | |
5436 | "Filter outgoing updates\n") | |
596c17ba | 5437 | |
718e3744 | 5438 | DEFUN (no_neighbor_prefix_list, |
5439 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5440 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5441 | NO_STR |
5442 | NEIGHBOR_STR | |
5443 | NEIGHBOR_ADDR_STR2 | |
5444 | "Filter updates to/from this neighbor\n" | |
5445 | "Name of a prefix list\n" | |
5446 | "Filter incoming updates\n" | |
5447 | "Filter outgoing updates\n") | |
5448 | { | |
d62a17ae | 5449 | int idx_peer = 2; |
5450 | int idx_in_out = 5; | |
5451 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
5452 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5453 | argv[idx_in_out]->arg); | |
718e3744 | 5454 | } |
6b0655a2 | 5455 | |
d62a17ae | 5456 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
5457 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5458 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5459 | "Filter updates to/from this neighbor\n" | |
5460 | "Name of a prefix list\n" | |
5461 | "Filter incoming updates\n" | |
5462 | "Filter outgoing updates\n") | |
596c17ba | 5463 | |
d62a17ae | 5464 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5465 | safi_t safi, const char *name_str, | |
5466 | const char *direct_str) | |
718e3744 | 5467 | { |
d62a17ae | 5468 | int ret; |
5469 | struct peer *peer; | |
5470 | int direct = FILTER_IN; | |
718e3744 | 5471 | |
d62a17ae | 5472 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5473 | if (!peer) | |
5474 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5475 | |
d62a17ae | 5476 | /* Check filter direction. */ |
5477 | if (strncmp(direct_str, "i", 1) == 0) | |
5478 | direct = FILTER_IN; | |
5479 | else if (strncmp(direct_str, "o", 1) == 0) | |
5480 | direct = FILTER_OUT; | |
718e3744 | 5481 | |
d62a17ae | 5482 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 5483 | |
d62a17ae | 5484 | return bgp_vty_return(vty, ret); |
718e3744 | 5485 | } |
5486 | ||
d62a17ae | 5487 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5488 | safi_t safi, const char *direct_str) | |
718e3744 | 5489 | { |
d62a17ae | 5490 | int ret; |
5491 | struct peer *peer; | |
5492 | int direct = FILTER_IN; | |
718e3744 | 5493 | |
d62a17ae | 5494 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5495 | if (!peer) | |
5496 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5497 | |
d62a17ae | 5498 | /* Check filter direction. */ |
5499 | if (strncmp(direct_str, "i", 1) == 0) | |
5500 | direct = FILTER_IN; | |
5501 | else if (strncmp(direct_str, "o", 1) == 0) | |
5502 | direct = FILTER_OUT; | |
718e3744 | 5503 | |
d62a17ae | 5504 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 5505 | |
d62a17ae | 5506 | return bgp_vty_return(vty, ret); |
718e3744 | 5507 | } |
5508 | ||
5509 | DEFUN (neighbor_filter_list, | |
5510 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5511 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5512 | NEIGHBOR_STR |
5513 | NEIGHBOR_ADDR_STR2 | |
5514 | "Establish BGP filters\n" | |
5515 | "AS path access-list name\n" | |
5516 | "Filter incoming routes\n" | |
5517 | "Filter outgoing routes\n") | |
5518 | { | |
d62a17ae | 5519 | int idx_peer = 1; |
5520 | int idx_word = 3; | |
5521 | int idx_in_out = 4; | |
5522 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5523 | bgp_node_safi(vty), argv[idx_word]->arg, | |
5524 | argv[idx_in_out]->arg); | |
718e3744 | 5525 | } |
5526 | ||
d62a17ae | 5527 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
5528 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5529 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5530 | "Establish BGP filters\n" | |
5531 | "AS path access-list name\n" | |
5532 | "Filter incoming routes\n" | |
5533 | "Filter outgoing routes\n") | |
596c17ba | 5534 | |
718e3744 | 5535 | DEFUN (no_neighbor_filter_list, |
5536 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5537 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5538 | NO_STR |
5539 | NEIGHBOR_STR | |
5540 | NEIGHBOR_ADDR_STR2 | |
5541 | "Establish BGP filters\n" | |
5542 | "AS path access-list name\n" | |
5543 | "Filter incoming routes\n" | |
5544 | "Filter outgoing routes\n") | |
5545 | { | |
d62a17ae | 5546 | int idx_peer = 2; |
5547 | int idx_in_out = 5; | |
5548 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
5549 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5550 | argv[idx_in_out]->arg); | |
718e3744 | 5551 | } |
6b0655a2 | 5552 | |
d62a17ae | 5553 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
5554 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5555 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5556 | "Establish BGP filters\n" | |
5557 | "AS path access-list name\n" | |
5558 | "Filter incoming routes\n" | |
5559 | "Filter outgoing routes\n") | |
596c17ba | 5560 | |
718e3744 | 5561 | /* Set route-map to the peer. */ |
d62a17ae | 5562 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
5563 | afi_t afi, safi_t safi, const char *name_str, | |
5564 | const char *direct_str) | |
718e3744 | 5565 | { |
d62a17ae | 5566 | int ret; |
5567 | struct peer *peer; | |
5568 | int direct = RMAP_IN; | |
718e3744 | 5569 | |
d62a17ae | 5570 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5571 | if (!peer) | |
5572 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5573 | |
d62a17ae | 5574 | /* Check filter direction. */ |
5575 | if (strncmp(direct_str, "in", 2) == 0) | |
5576 | direct = RMAP_IN; | |
5577 | else if (strncmp(direct_str, "o", 1) == 0) | |
5578 | direct = RMAP_OUT; | |
718e3744 | 5579 | |
d62a17ae | 5580 | ret = peer_route_map_set(peer, afi, safi, direct, name_str); |
718e3744 | 5581 | |
d62a17ae | 5582 | return bgp_vty_return(vty, ret); |
718e3744 | 5583 | } |
5584 | ||
d62a17ae | 5585 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
5586 | afi_t afi, safi_t safi, | |
5587 | const char *direct_str) | |
718e3744 | 5588 | { |
d62a17ae | 5589 | int ret; |
5590 | struct peer *peer; | |
5591 | int direct = RMAP_IN; | |
718e3744 | 5592 | |
d62a17ae | 5593 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5594 | if (!peer) | |
5595 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5596 | |
d62a17ae | 5597 | /* Check filter direction. */ |
5598 | if (strncmp(direct_str, "in", 2) == 0) | |
5599 | direct = RMAP_IN; | |
5600 | else if (strncmp(direct_str, "o", 1) == 0) | |
5601 | direct = RMAP_OUT; | |
718e3744 | 5602 | |
d62a17ae | 5603 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 5604 | |
d62a17ae | 5605 | return bgp_vty_return(vty, ret); |
718e3744 | 5606 | } |
5607 | ||
5608 | DEFUN (neighbor_route_map, | |
5609 | neighbor_route_map_cmd, | |
9ccf14f7 | 5610 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5611 | NEIGHBOR_STR |
5612 | NEIGHBOR_ADDR_STR2 | |
5613 | "Apply route map to neighbor\n" | |
5614 | "Name of route map\n" | |
5615 | "Apply map to incoming routes\n" | |
2a3d5731 | 5616 | "Apply map to outbound routes\n") |
718e3744 | 5617 | { |
d62a17ae | 5618 | int idx_peer = 1; |
5619 | int idx_word = 3; | |
5620 | int idx_in_out = 4; | |
5621 | return peer_route_map_set_vty( | |
5622 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5623 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5624 | } |
5625 | ||
d62a17ae | 5626 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
5627 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5628 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5629 | "Apply route map to neighbor\n" | |
5630 | "Name of route map\n" | |
5631 | "Apply map to incoming routes\n" | |
5632 | "Apply map to outbound routes\n") | |
596c17ba | 5633 | |
718e3744 | 5634 | DEFUN (no_neighbor_route_map, |
5635 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5636 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5637 | NO_STR |
5638 | NEIGHBOR_STR | |
5639 | NEIGHBOR_ADDR_STR2 | |
5640 | "Apply route map to neighbor\n" | |
5641 | "Name of route map\n" | |
5642 | "Apply map to incoming routes\n" | |
2a3d5731 | 5643 | "Apply map to outbound routes\n") |
718e3744 | 5644 | { |
d62a17ae | 5645 | int idx_peer = 2; |
5646 | int idx_in_out = 5; | |
5647 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
5648 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5649 | argv[idx_in_out]->arg); | |
718e3744 | 5650 | } |
6b0655a2 | 5651 | |
d62a17ae | 5652 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
5653 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5654 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5655 | "Apply route map to neighbor\n" | |
5656 | "Name of route map\n" | |
5657 | "Apply map to incoming routes\n" | |
5658 | "Apply map to outbound routes\n") | |
596c17ba | 5659 | |
718e3744 | 5660 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 5661 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
5662 | afi_t afi, safi_t safi, | |
5663 | const char *name_str) | |
718e3744 | 5664 | { |
d62a17ae | 5665 | int ret; |
5666 | struct peer *peer; | |
718e3744 | 5667 | |
d62a17ae | 5668 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5669 | if (!peer) | |
5670 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5671 | |
d62a17ae | 5672 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str); |
718e3744 | 5673 | |
d62a17ae | 5674 | return bgp_vty_return(vty, ret); |
718e3744 | 5675 | } |
5676 | ||
5677 | /* Unset route-map from the peer. */ | |
d62a17ae | 5678 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
5679 | afi_t afi, safi_t safi) | |
718e3744 | 5680 | { |
d62a17ae | 5681 | int ret; |
5682 | struct peer *peer; | |
718e3744 | 5683 | |
d62a17ae | 5684 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5685 | if (!peer) | |
5686 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5687 | |
d62a17ae | 5688 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 5689 | |
d62a17ae | 5690 | return bgp_vty_return(vty, ret); |
718e3744 | 5691 | } |
5692 | ||
5693 | DEFUN (neighbor_unsuppress_map, | |
5694 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5695 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5696 | NEIGHBOR_STR |
5697 | NEIGHBOR_ADDR_STR2 | |
5698 | "Route-map to selectively unsuppress suppressed routes\n" | |
5699 | "Name of route map\n") | |
5700 | { | |
d62a17ae | 5701 | int idx_peer = 1; |
5702 | int idx_word = 3; | |
5703 | return peer_unsuppress_map_set_vty( | |
5704 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5705 | argv[idx_word]->arg); | |
718e3744 | 5706 | } |
5707 | ||
d62a17ae | 5708 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
5709 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5710 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5711 | "Route-map to selectively unsuppress suppressed routes\n" | |
5712 | "Name of route map\n") | |
596c17ba | 5713 | |
718e3744 | 5714 | DEFUN (no_neighbor_unsuppress_map, |
5715 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5716 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5717 | NO_STR |
5718 | NEIGHBOR_STR | |
5719 | NEIGHBOR_ADDR_STR2 | |
5720 | "Route-map to selectively unsuppress suppressed routes\n" | |
5721 | "Name of route map\n") | |
5722 | { | |
d62a17ae | 5723 | int idx_peer = 2; |
5724 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
5725 | bgp_node_afi(vty), | |
5726 | bgp_node_safi(vty)); | |
718e3744 | 5727 | } |
6b0655a2 | 5728 | |
d62a17ae | 5729 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
5730 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5731 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5732 | "Route-map to selectively unsuppress suppressed routes\n" | |
5733 | "Name of route map\n") | |
596c17ba | 5734 | |
d62a17ae | 5735 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
5736 | afi_t afi, safi_t safi, | |
5737 | const char *num_str, | |
5738 | const char *threshold_str, int warning, | |
5739 | const char *restart_str) | |
718e3744 | 5740 | { |
d62a17ae | 5741 | int ret; |
5742 | struct peer *peer; | |
d7c0a89a QY |
5743 | uint32_t max; |
5744 | uint8_t threshold; | |
5745 | uint16_t restart; | |
718e3744 | 5746 | |
d62a17ae | 5747 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5748 | if (!peer) | |
5749 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5750 | |
d62a17ae | 5751 | max = strtoul(num_str, NULL, 10); |
5752 | if (threshold_str) | |
5753 | threshold = atoi(threshold_str); | |
5754 | else | |
5755 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5756 | |
d62a17ae | 5757 | if (restart_str) |
5758 | restart = atoi(restart_str); | |
5759 | else | |
5760 | restart = 0; | |
0a486e5f | 5761 | |
d62a17ae | 5762 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
5763 | restart); | |
718e3744 | 5764 | |
d62a17ae | 5765 | return bgp_vty_return(vty, ret); |
718e3744 | 5766 | } |
5767 | ||
d62a17ae | 5768 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
5769 | afi_t afi, safi_t safi) | |
718e3744 | 5770 | { |
d62a17ae | 5771 | int ret; |
5772 | struct peer *peer; | |
718e3744 | 5773 | |
d62a17ae | 5774 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5775 | if (!peer) | |
5776 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5777 | |
d62a17ae | 5778 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 5779 | |
d62a17ae | 5780 | return bgp_vty_return(vty, ret); |
718e3744 | 5781 | } |
5782 | ||
5783 | /* Maximum number of prefix configuration. prefix count is different | |
5784 | for each peer configuration. So this configuration can be set for | |
5785 | each peer configuration. */ | |
5786 | DEFUN (neighbor_maximum_prefix, | |
5787 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5788 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5789 | NEIGHBOR_STR |
5790 | NEIGHBOR_ADDR_STR2 | |
5791 | "Maximum number of prefix accept from this peer\n" | |
5792 | "maximum no. of prefix limit\n") | |
5793 | { | |
d62a17ae | 5794 | int idx_peer = 1; |
5795 | int idx_number = 3; | |
5796 | return peer_maximum_prefix_set_vty( | |
5797 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5798 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 5799 | } |
5800 | ||
d62a17ae | 5801 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
5802 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
5803 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5804 | "Maximum number of prefix accept from this peer\n" | |
5805 | "maximum no. of prefix limit\n") | |
596c17ba | 5806 | |
e0701b79 | 5807 | DEFUN (neighbor_maximum_prefix_threshold, |
5808 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5809 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5810 | NEIGHBOR_STR |
5811 | NEIGHBOR_ADDR_STR2 | |
5812 | "Maximum number of prefix accept from this peer\n" | |
5813 | "maximum no. of prefix limit\n" | |
5814 | "Threshold value (%) at which to generate a warning msg\n") | |
5815 | { | |
d62a17ae | 5816 | int idx_peer = 1; |
5817 | int idx_number = 3; | |
5818 | int idx_number_2 = 4; | |
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, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 5822 | } |
e0701b79 | 5823 | |
d62a17ae | 5824 | ALIAS_HIDDEN( |
5825 | neighbor_maximum_prefix_threshold, | |
5826 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
5827 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
5828 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5829 | "Maximum number of prefix accept from this peer\n" | |
5830 | "maximum no. of prefix limit\n" | |
5831 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 5832 | |
718e3744 | 5833 | DEFUN (neighbor_maximum_prefix_warning, |
5834 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5835 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 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 | "Only give warning message when limit is exceeded\n") | |
5841 | { | |
d62a17ae | 5842 | int idx_peer = 1; |
5843 | int idx_number = 3; | |
5844 | return peer_maximum_prefix_set_vty( | |
5845 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5846 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 5847 | } |
5848 | ||
d62a17ae | 5849 | ALIAS_HIDDEN( |
5850 | neighbor_maximum_prefix_warning, | |
5851 | neighbor_maximum_prefix_warning_hidden_cmd, | |
5852 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
5853 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5854 | "Maximum number of prefix accept from this peer\n" | |
5855 | "maximum no. of prefix limit\n" | |
5856 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5857 | |
e0701b79 | 5858 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5859 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5860 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5861 | NEIGHBOR_STR |
5862 | NEIGHBOR_ADDR_STR2 | |
5863 | "Maximum number of prefix accept from this peer\n" | |
5864 | "maximum no. of prefix limit\n" | |
5865 | "Threshold value (%) at which to generate a warning msg\n" | |
5866 | "Only give warning message when limit is exceeded\n") | |
5867 | { | |
d62a17ae | 5868 | int idx_peer = 1; |
5869 | int idx_number = 3; | |
5870 | int idx_number_2 = 4; | |
5871 | return peer_maximum_prefix_set_vty( | |
5872 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5873 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5874 | } |
5875 | ||
d62a17ae | 5876 | ALIAS_HIDDEN( |
5877 | neighbor_maximum_prefix_threshold_warning, | |
5878 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
5879 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
5880 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5881 | "Maximum number of prefix accept from this peer\n" | |
5882 | "maximum no. of prefix limit\n" | |
5883 | "Threshold value (%) at which to generate a warning msg\n" | |
5884 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5885 | |
0a486e5f | 5886 | DEFUN (neighbor_maximum_prefix_restart, |
5887 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5888 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 5889 | NEIGHBOR_STR |
5890 | NEIGHBOR_ADDR_STR2 | |
5891 | "Maximum number of prefix accept from this peer\n" | |
5892 | "maximum no. of prefix limit\n" | |
5893 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 5894 | "Restart interval in minutes\n") |
0a486e5f | 5895 | { |
d62a17ae | 5896 | int idx_peer = 1; |
5897 | int idx_number = 3; | |
5898 | int idx_number_2 = 5; | |
5899 | return peer_maximum_prefix_set_vty( | |
5900 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5901 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 5902 | } |
5903 | ||
d62a17ae | 5904 | ALIAS_HIDDEN( |
5905 | neighbor_maximum_prefix_restart, | |
5906 | neighbor_maximum_prefix_restart_hidden_cmd, | |
5907 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
5908 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5909 | "Maximum number of prefix accept from this peer\n" | |
5910 | "maximum no. of prefix limit\n" | |
5911 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 5912 | "Restart interval in minutes\n") |
596c17ba | 5913 | |
0a486e5f | 5914 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
5915 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 5916 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 5917 | NEIGHBOR_STR |
5918 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5919 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 5920 | "maximum no. of prefix limit\n" |
5921 | "Threshold value (%) at which to generate a warning msg\n" | |
5922 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5923 | "Restart interval in minutes\n") |
0a486e5f | 5924 | { |
d62a17ae | 5925 | int idx_peer = 1; |
5926 | int idx_number = 3; | |
5927 | int idx_number_2 = 4; | |
5928 | int idx_number_3 = 6; | |
5929 | return peer_maximum_prefix_set_vty( | |
5930 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5931 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
5932 | argv[idx_number_3]->arg); | |
5933 | } | |
5934 | ||
5935 | ALIAS_HIDDEN( | |
5936 | neighbor_maximum_prefix_threshold_restart, | |
5937 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
5938 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
5939 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5940 | "Maximum number of prefixes to accept from this peer\n" | |
5941 | "maximum no. of prefix limit\n" | |
5942 | "Threshold value (%) at which to generate a warning msg\n" | |
5943 | "Restart bgp connection after limit is exceeded\n" | |
5944 | "Restart interval in minutes\n") | |
596c17ba | 5945 | |
718e3744 | 5946 | DEFUN (no_neighbor_maximum_prefix, |
5947 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 5948 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 5949 | NO_STR |
5950 | NEIGHBOR_STR | |
5951 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 5952 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
5953 | "maximum no. of prefix limit\n" |
5954 | "Threshold value (%) at which to generate a warning msg\n" | |
5955 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 5956 | "Restart interval in minutes\n" |
31500417 | 5957 | "Only give warning message when limit is exceeded\n") |
718e3744 | 5958 | { |
d62a17ae | 5959 | int idx_peer = 2; |
5960 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
5961 | bgp_node_afi(vty), | |
5962 | bgp_node_safi(vty)); | |
718e3744 | 5963 | } |
e52702f2 | 5964 | |
d62a17ae | 5965 | ALIAS_HIDDEN( |
5966 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
5967 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
5968 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5969 | "Maximum number of prefixes to accept from this peer\n" | |
5970 | "maximum no. of prefix limit\n" | |
5971 | "Threshold value (%) at which to generate a warning msg\n" | |
5972 | "Restart bgp connection after limit is exceeded\n" | |
5973 | "Restart interval in minutes\n" | |
5974 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5975 | |
718e3744 | 5976 | |
718e3744 | 5977 | /* "neighbor allowas-in" */ |
5978 | DEFUN (neighbor_allowas_in, | |
5979 | neighbor_allowas_in_cmd, | |
fd8503f5 | 5980 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 5981 | NEIGHBOR_STR |
5982 | NEIGHBOR_ADDR_STR2 | |
31500417 | 5983 | "Accept as-path with my AS present in it\n" |
fd8503f5 QY |
5984 | "Number of occurances of AS number\n" |
5985 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 5986 | { |
d62a17ae | 5987 | int idx_peer = 1; |
5988 | int idx_number_origin = 3; | |
5989 | int ret; | |
5990 | int origin = 0; | |
5991 | struct peer *peer; | |
5992 | int allow_num = 0; | |
5993 | ||
5994 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
5995 | if (!peer) | |
5996 | return CMD_WARNING_CONFIG_FAILED; | |
5997 | ||
5998 | if (argc <= idx_number_origin) | |
5999 | allow_num = 3; | |
6000 | else { | |
6001 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6002 | origin = 1; | |
6003 | else | |
6004 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6005 | } | |
6006 | ||
6007 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6008 | allow_num, origin); | |
6009 | ||
6010 | return bgp_vty_return(vty, ret); | |
6011 | } | |
6012 | ||
6013 | ALIAS_HIDDEN( | |
6014 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
6015 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6016 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6017 | "Accept as-path with my AS present in it\n" | |
6018 | "Number of occurances of AS number\n" | |
6019 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
596c17ba | 6020 | |
718e3744 | 6021 | DEFUN (no_neighbor_allowas_in, |
6022 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6023 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6024 | NO_STR |
6025 | NEIGHBOR_STR | |
6026 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6027 | "allow local ASN appears in aspath attribute\n" |
fd8503f5 QY |
6028 | "Number of occurances of AS number\n" |
6029 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
718e3744 | 6030 | { |
d62a17ae | 6031 | int idx_peer = 2; |
6032 | int ret; | |
6033 | struct peer *peer; | |
718e3744 | 6034 | |
d62a17ae | 6035 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6036 | if (!peer) | |
6037 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6038 | |
d62a17ae | 6039 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6040 | bgp_node_safi(vty)); | |
718e3744 | 6041 | |
d62a17ae | 6042 | return bgp_vty_return(vty, ret); |
718e3744 | 6043 | } |
6b0655a2 | 6044 | |
d62a17ae | 6045 | ALIAS_HIDDEN( |
6046 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6047 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6048 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6049 | "allow local ASN appears in aspath attribute\n" | |
6050 | "Number of occurances of AS number\n" | |
6051 | "Only accept my AS in the as-path if the route was originated in my AS\n") | |
596c17ba | 6052 | |
fa411a21 NH |
6053 | DEFUN (neighbor_ttl_security, |
6054 | neighbor_ttl_security_cmd, | |
7ebe625c | 6055 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6056 | NEIGHBOR_STR |
7ebe625c | 6057 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6058 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6059 | "Specify the maximum number of hops to the BGP peer\n" |
6060 | "Number of hops to BGP peer\n") | |
fa411a21 | 6061 | { |
d62a17ae | 6062 | int idx_peer = 1; |
6063 | int idx_number = 4; | |
6064 | struct peer *peer; | |
6065 | int gtsm_hops; | |
6066 | ||
6067 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6068 | if (!peer) | |
6069 | return CMD_WARNING_CONFIG_FAILED; | |
6070 | ||
6071 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6072 | ||
7ebe625c QY |
6073 | /* |
6074 | * If 'neighbor swpX', then this is for directly connected peers, | |
6075 | * we should not accept a ttl-security hops value greater than 1. | |
6076 | */ | |
6077 | if (peer->conf_if && (gtsm_hops > 1)) { | |
6078 | vty_out(vty, | |
6079 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6080 | argv[idx_peer]->arg); | |
6081 | return CMD_WARNING_CONFIG_FAILED; | |
6082 | } | |
6083 | ||
d62a17ae | 6084 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6085 | } |
6086 | ||
6087 | DEFUN (no_neighbor_ttl_security, | |
6088 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6089 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6090 | NO_STR |
6091 | NEIGHBOR_STR | |
7ebe625c | 6092 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6093 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6094 | "Specify the maximum number of hops to the BGP peer\n" |
6095 | "Number of hops to BGP peer\n") | |
fa411a21 | 6096 | { |
d62a17ae | 6097 | int idx_peer = 2; |
6098 | struct peer *peer; | |
fa411a21 | 6099 | |
d62a17ae | 6100 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6101 | if (!peer) | |
6102 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6103 | |
d62a17ae | 6104 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6105 | } |
6b0655a2 | 6106 | |
adbac85e DW |
6107 | DEFUN (neighbor_addpath_tx_all_paths, |
6108 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6109 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6110 | NEIGHBOR_STR |
6111 | NEIGHBOR_ADDR_STR2 | |
6112 | "Use addpath to advertise all paths to a neighbor\n") | |
6113 | { | |
d62a17ae | 6114 | int idx_peer = 1; |
6115 | struct peer *peer; | |
adbac85e | 6116 | |
d62a17ae | 6117 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6118 | if (!peer) | |
6119 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6120 | |
d62a17ae | 6121 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6122 | bgp_node_safi(vty), | |
6123 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
adbac85e DW |
6124 | } |
6125 | ||
d62a17ae | 6126 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6127 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6128 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6129 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6130 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6131 | |
adbac85e DW |
6132 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6133 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6134 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6135 | NO_STR |
6136 | NEIGHBOR_STR | |
6137 | NEIGHBOR_ADDR_STR2 | |
6138 | "Use addpath to advertise all paths to a neighbor\n") | |
6139 | { | |
d62a17ae | 6140 | int idx_peer = 2; |
6141 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6142 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6143 | PEER_FLAG_ADDPATH_TX_ALL_PATHS); | |
adbac85e DW |
6144 | } |
6145 | ||
d62a17ae | 6146 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6147 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6148 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6149 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6150 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6151 | |
06370dac DW |
6152 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6153 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6154 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6155 | NEIGHBOR_STR |
6156 | NEIGHBOR_ADDR_STR2 | |
6157 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6158 | { | |
d62a17ae | 6159 | int idx_peer = 1; |
6160 | struct peer *peer; | |
06370dac | 6161 | |
d62a17ae | 6162 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6163 | if (!peer) | |
6164 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 6165 | |
d62a17ae | 6166 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
6167 | bgp_node_safi(vty), | |
6168 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
06370dac DW |
6169 | } |
6170 | ||
d62a17ae | 6171 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
6172 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6173 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6174 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6175 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6176 | |
06370dac DW |
6177 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
6178 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6179 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6180 | NO_STR |
6181 | NEIGHBOR_STR | |
6182 | NEIGHBOR_ADDR_STR2 | |
6183 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6184 | { | |
d62a17ae | 6185 | int idx_peer = 2; |
6186 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
6187 | bgp_node_afi(vty), bgp_node_safi(vty), | |
6188 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS); | |
06370dac DW |
6189 | } |
6190 | ||
d62a17ae | 6191 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
6192 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6193 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6194 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6195 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6196 | |
b9c7bc5a PZ |
6197 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
6198 | struct ecommunity **list) | |
ddb5b488 | 6199 | { |
b9c7bc5a PZ |
6200 | struct ecommunity *ecom = NULL; |
6201 | struct ecommunity *ecomadd; | |
ddb5b488 | 6202 | |
b9c7bc5a | 6203 | for (; argc; --argc, ++argv) { |
ddb5b488 | 6204 | |
b9c7bc5a PZ |
6205 | ecomadd = ecommunity_str2com(argv[0]->arg, |
6206 | ECOMMUNITY_ROUTE_TARGET, 0); | |
6207 | if (!ecomadd) { | |
6208 | vty_out(vty, "Malformed community-list value\n"); | |
6209 | if (ecom) | |
6210 | ecommunity_free(&ecom); | |
6211 | return CMD_WARNING_CONFIG_FAILED; | |
6212 | } | |
ddb5b488 | 6213 | |
b9c7bc5a PZ |
6214 | if (ecom) { |
6215 | ecommunity_merge(ecom, ecomadd); | |
6216 | ecommunity_free(&ecomadd); | |
6217 | } else { | |
6218 | ecom = ecomadd; | |
6219 | } | |
6220 | } | |
6221 | ||
6222 | if (*list) { | |
6223 | ecommunity_free(&*list); | |
ddb5b488 | 6224 | } |
b9c7bc5a PZ |
6225 | *list = ecom; |
6226 | ||
6227 | return CMD_SUCCESS; | |
ddb5b488 PZ |
6228 | } |
6229 | ||
0ca70ba5 DS |
6230 | /* |
6231 | * v2vimport is true if we are handling a `import vrf ...` command | |
6232 | */ | |
6233 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 6234 | { |
0ca70ba5 DS |
6235 | afi_t afi; |
6236 | ||
ddb5b488 | 6237 | switch (vty->node) { |
b9c7bc5a | 6238 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
6239 | afi = AFI_IP; |
6240 | break; | |
b9c7bc5a | 6241 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
6242 | afi = AFI_IP6; |
6243 | break; | |
ddb5b488 PZ |
6244 | default: |
6245 | vty_out(vty, | |
b9c7bc5a | 6246 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 6247 | return AFI_MAX; |
ddb5b488 | 6248 | } |
69b07479 | 6249 | |
0ca70ba5 DS |
6250 | if (!v2vimport) { |
6251 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6252 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
6253 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6254 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
6255 | vty_out(vty, | |
6256 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
6257 | return AFI_MAX; | |
6258 | } | |
6259 | } else { | |
6260 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6261 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
6262 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6263 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
6264 | vty_out(vty, | |
6265 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
6266 | return AFI_MAX; | |
6267 | } | |
6268 | } | |
6269 | return afi; | |
ddb5b488 PZ |
6270 | } |
6271 | ||
b9c7bc5a PZ |
6272 | DEFPY (af_rd_vpn_export, |
6273 | af_rd_vpn_export_cmd, | |
6274 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
6275 | NO_STR | |
ddb5b488 | 6276 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
6277 | "Between current address-family and vpn\n" |
6278 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6279 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
6280 | { | |
6281 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6282 | struct prefix_rd prd; | |
6283 | int ret; | |
ddb5b488 | 6284 | afi_t afi; |
b9c7bc5a PZ |
6285 | int idx = 0; |
6286 | int yes = 1; | |
ddb5b488 | 6287 | |
b9c7bc5a | 6288 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6289 | yes = 0; |
b9c7bc5a PZ |
6290 | |
6291 | if (yes) { | |
6292 | ret = str2prefix_rd(rd_str, &prd); | |
6293 | if (!ret) { | |
6294 | vty_out(vty, "%% Malformed rd\n"); | |
6295 | return CMD_WARNING_CONFIG_FAILED; | |
6296 | } | |
ddb5b488 PZ |
6297 | } |
6298 | ||
0ca70ba5 | 6299 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6300 | if (afi == AFI_MAX) |
6301 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6302 | |
69b07479 DS |
6303 | /* |
6304 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6305 | */ | |
6306 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6307 | bgp_get_default(), bgp); | |
ddb5b488 | 6308 | |
69b07479 DS |
6309 | if (yes) { |
6310 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
6311 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6312 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
6313 | } else { | |
6314 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6315 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
6316 | } |
6317 | ||
69b07479 DS |
6318 | /* post-change: re-export vpn routes */ |
6319 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6320 | bgp_get_default(), bgp); | |
6321 | ||
ddb5b488 PZ |
6322 | return CMD_SUCCESS; |
6323 | } | |
6324 | ||
b9c7bc5a PZ |
6325 | ALIAS (af_rd_vpn_export, |
6326 | af_no_rd_vpn_export_cmd, | |
6327 | "no rd vpn export", | |
ddb5b488 | 6328 | NO_STR |
b9c7bc5a PZ |
6329 | "Specify route distinguisher\n" |
6330 | "Between current address-family and vpn\n" | |
6331 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6332 | |
b9c7bc5a PZ |
6333 | DEFPY (af_label_vpn_export, |
6334 | af_label_vpn_export_cmd, | |
e70e9f8e | 6335 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 6336 | NO_STR |
ddb5b488 | 6337 | "label value for VRF\n" |
b9c7bc5a PZ |
6338 | "Between current address-family and vpn\n" |
6339 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
6340 | "Label Value <0-1048575>\n" |
6341 | "Automatically assign a label\n") | |
ddb5b488 PZ |
6342 | { |
6343 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6344 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 6345 | afi_t afi; |
b9c7bc5a PZ |
6346 | int idx = 0; |
6347 | int yes = 1; | |
6348 | ||
6349 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 6350 | yes = 0; |
ddb5b488 | 6351 | |
21a16cc2 PZ |
6352 | /* If "no ...", squash trailing parameter */ |
6353 | if (!yes) | |
6354 | label_auto = NULL; | |
6355 | ||
e70e9f8e PZ |
6356 | if (yes) { |
6357 | if (!label_auto) | |
6358 | label = label_val; /* parser should force unsigned */ | |
6359 | } | |
ddb5b488 | 6360 | |
0ca70ba5 | 6361 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6362 | if (afi == AFI_MAX) |
6363 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 6364 | |
e70e9f8e | 6365 | |
69b07479 DS |
6366 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
6367 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
6368 | /* no change */ | |
6369 | return CMD_SUCCESS; | |
e70e9f8e | 6370 | |
69b07479 DS |
6371 | /* |
6372 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6373 | */ | |
6374 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6375 | bgp_get_default(), bgp); | |
6376 | ||
6377 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
6378 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
6379 | ||
6380 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
6381 | ||
6382 | /* | |
6383 | * label has previously been automatically | |
6384 | * assigned by labelpool: release it | |
6385 | * | |
6386 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
6387 | * means the automatic assignment is in flight | |
6388 | * and therefore the labelpool callback must | |
6389 | * detect that the auto label is not needed. | |
6390 | */ | |
6391 | ||
6392 | bgp_lp_release(LP_TYPE_VRF, | |
6393 | &bgp->vpn_policy[afi], | |
6394 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 6395 | } |
69b07479 DS |
6396 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
6397 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6398 | } | |
ddb5b488 | 6399 | |
69b07479 DS |
6400 | bgp->vpn_policy[afi].tovpn_label = label; |
6401 | if (label_auto) { | |
6402 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6403 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6404 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
6405 | vpn_leak_label_callback); | |
ddb5b488 PZ |
6406 | } |
6407 | ||
69b07479 DS |
6408 | /* post-change: re-export vpn routes */ |
6409 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6410 | bgp_get_default(), bgp); | |
6411 | ||
ddb5b488 PZ |
6412 | return CMD_SUCCESS; |
6413 | } | |
6414 | ||
b9c7bc5a PZ |
6415 | ALIAS (af_label_vpn_export, |
6416 | af_no_label_vpn_export_cmd, | |
6417 | "no label vpn export", | |
6418 | NO_STR | |
6419 | "label value for VRF\n" | |
6420 | "Between current address-family and vpn\n" | |
6421 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6422 | |
b9c7bc5a PZ |
6423 | DEFPY (af_nexthop_vpn_export, |
6424 | af_nexthop_vpn_export_cmd, | |
6425 | "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str", | |
6426 | NO_STR | |
ddb5b488 | 6427 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
6428 | "Between current address-family and vpn\n" |
6429 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6430 | "IPv4 prefix\n" |
6431 | "IPv6 prefix\n") | |
6432 | { | |
6433 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 6434 | afi_t afi; |
ddb5b488 | 6435 | struct prefix p; |
b9c7bc5a PZ |
6436 | int idx = 0; |
6437 | int yes = 1; | |
ddb5b488 | 6438 | |
b9c7bc5a | 6439 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6440 | yes = 0; |
b9c7bc5a PZ |
6441 | |
6442 | if (yes) { | |
6443 | if (!sockunion2hostprefix(nexthop_str, &p)) | |
6444 | return CMD_WARNING_CONFIG_FAILED; | |
6445 | } | |
ddb5b488 | 6446 | |
0ca70ba5 | 6447 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6448 | if (afi == AFI_MAX) |
6449 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6450 | |
69b07479 DS |
6451 | /* |
6452 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6453 | */ | |
6454 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6455 | bgp_get_default(), bgp); | |
ddb5b488 | 6456 | |
69b07479 DS |
6457 | if (yes) { |
6458 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
6459 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6460 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
6461 | } else { | |
6462 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6463 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
6464 | } |
6465 | ||
69b07479 DS |
6466 | /* post-change: re-export vpn routes */ |
6467 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6468 | bgp_get_default(), bgp); | |
6469 | ||
ddb5b488 PZ |
6470 | return CMD_SUCCESS; |
6471 | } | |
6472 | ||
b9c7bc5a PZ |
6473 | ALIAS (af_nexthop_vpn_export, |
6474 | af_no_nexthop_vpn_export_cmd, | |
6475 | "no nexthop vpn export", | |
ddb5b488 | 6476 | NO_STR |
b9c7bc5a PZ |
6477 | "Specify next hop to use for VRF advertised prefixes\n" |
6478 | "Between current address-family and vpn\n" | |
6479 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6480 | |
b9c7bc5a | 6481 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 6482 | { |
b9c7bc5a PZ |
6483 | if (!strcmp(dstr, "import")) { |
6484 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6485 | } else if (!strcmp(dstr, "export")) { | |
6486 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6487 | } else if (!strcmp(dstr, "both")) { | |
6488 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6489 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6490 | } else { | |
6491 | vty_out(vty, "%% direction parse error\n"); | |
6492 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6493 | } |
ddb5b488 PZ |
6494 | return CMD_SUCCESS; |
6495 | } | |
6496 | ||
b9c7bc5a PZ |
6497 | DEFPY (af_rt_vpn_imexport, |
6498 | af_rt_vpn_imexport_cmd, | |
6499 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
6500 | NO_STR | |
6501 | "Specify route target list\n" | |
ddb5b488 | 6502 | "Specify route target list\n" |
b9c7bc5a PZ |
6503 | "Between current address-family and vpn\n" |
6504 | "For routes leaked from vpn to current address-family: match any\n" | |
6505 | "For routes leaked from current address-family to vpn: set\n" | |
6506 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
6507 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
6508 | { | |
6509 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6510 | int ret; | |
6511 | struct ecommunity *ecom = NULL; | |
6512 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6513 | vpn_policy_direction_t dir; |
6514 | afi_t afi; | |
6515 | int idx = 0; | |
b9c7bc5a | 6516 | int yes = 1; |
ddb5b488 | 6517 | |
b9c7bc5a | 6518 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6519 | yes = 0; |
b9c7bc5a | 6520 | |
0ca70ba5 | 6521 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6522 | if (afi == AFI_MAX) |
6523 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6524 | |
b9c7bc5a | 6525 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6526 | if (ret != CMD_SUCCESS) |
6527 | return ret; | |
6528 | ||
b9c7bc5a PZ |
6529 | if (yes) { |
6530 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
6531 | vty_out(vty, "%% Missing RTLIST\n"); | |
6532 | return CMD_WARNING_CONFIG_FAILED; | |
6533 | } | |
6534 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
6535 | if (ret != CMD_SUCCESS) { | |
6536 | return ret; | |
6537 | } | |
ddb5b488 PZ |
6538 | } |
6539 | ||
69b07479 DS |
6540 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6541 | if (!dodir[dir]) | |
ddb5b488 | 6542 | continue; |
ddb5b488 | 6543 | |
69b07479 | 6544 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6545 | |
69b07479 DS |
6546 | if (yes) { |
6547 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6548 | ecommunity_free( | |
6549 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6550 | bgp->vpn_policy[afi].rtlist[dir] = | |
6551 | ecommunity_dup(ecom); | |
6552 | } else { | |
6553 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6554 | ecommunity_free( | |
6555 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6556 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 6557 | } |
69b07479 DS |
6558 | |
6559 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 6560 | } |
69b07479 | 6561 | |
d555f3e9 PZ |
6562 | if (ecom) |
6563 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
6564 | |
6565 | return CMD_SUCCESS; | |
6566 | } | |
6567 | ||
b9c7bc5a PZ |
6568 | ALIAS (af_rt_vpn_imexport, |
6569 | af_no_rt_vpn_imexport_cmd, | |
6570 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
6571 | NO_STR |
6572 | "Specify route target list\n" | |
b9c7bc5a PZ |
6573 | "Specify route target list\n" |
6574 | "Between current address-family and vpn\n" | |
6575 | "For routes leaked from vpn to current address-family\n" | |
6576 | "For routes leaked from current address-family to vpn\n" | |
6577 | "both import and export\n") | |
6578 | ||
6579 | DEFPY (af_route_map_vpn_imexport, | |
6580 | af_route_map_vpn_imexport_cmd, | |
6581 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
6582 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
6583 | NO_STR | |
ddb5b488 | 6584 | "Specify route map\n" |
b9c7bc5a PZ |
6585 | "Between current address-family and vpn\n" |
6586 | "For routes leaked from vpn to current address-family\n" | |
6587 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6588 | "name of route-map\n") |
6589 | { | |
6590 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6591 | int ret; | |
6592 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6593 | vpn_policy_direction_t dir; |
6594 | afi_t afi; | |
ddb5b488 | 6595 | int idx = 0; |
b9c7bc5a | 6596 | int yes = 1; |
ddb5b488 | 6597 | |
b9c7bc5a | 6598 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6599 | yes = 0; |
b9c7bc5a | 6600 | |
0ca70ba5 | 6601 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6602 | if (afi == AFI_MAX) |
6603 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6604 | |
b9c7bc5a | 6605 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6606 | if (ret != CMD_SUCCESS) |
6607 | return ret; | |
6608 | ||
69b07479 DS |
6609 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6610 | if (!dodir[dir]) | |
ddb5b488 | 6611 | continue; |
ddb5b488 | 6612 | |
69b07479 | 6613 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6614 | |
69b07479 DS |
6615 | if (yes) { |
6616 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6617 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6618 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6619 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
6620 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6621 | bgp->vpn_policy[afi].rmap[dir] = | |
6622 | route_map_lookup_by_name(rmap_str); | |
6623 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
6624 | return CMD_SUCCESS; | |
6625 | } else { | |
6626 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6627 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6628 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6629 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6630 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 6631 | } |
69b07479 DS |
6632 | |
6633 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
6634 | } |
6635 | ||
6636 | return CMD_SUCCESS; | |
6637 | } | |
6638 | ||
b9c7bc5a PZ |
6639 | ALIAS (af_route_map_vpn_imexport, |
6640 | af_no_route_map_vpn_imexport_cmd, | |
6641 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
6642 | NO_STR |
6643 | "Specify route map\n" | |
b9c7bc5a PZ |
6644 | "Between current address-family and vpn\n" |
6645 | "For routes leaked from vpn to current address-family\n" | |
6646 | "For routes leaked from current address-family to vpn\n") | |
6647 | ||
bb4f6190 DS |
6648 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
6649 | "[no] import vrf route-map RMAP$rmap_str", | |
6650 | NO_STR | |
6651 | "Import routes from another VRF\n" | |
6652 | "Vrf routes being filtered\n" | |
6653 | "Specify route map\n" | |
6654 | "name of route-map\n") | |
6655 | { | |
6656 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
6657 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
6658 | afi_t afi; | |
6659 | int idx = 0; | |
6660 | int yes = 1; | |
6661 | struct bgp *bgp_default; | |
6662 | ||
6663 | if (argv_find(argv, argc, "no", &idx)) | |
6664 | yes = 0; | |
6665 | ||
0ca70ba5 | 6666 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
6667 | if (afi == AFI_MAX) |
6668 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
6669 | |
6670 | bgp_default = bgp_get_default(); | |
6671 | if (!bgp_default) { | |
6672 | int32_t ret; | |
6673 | as_t as = bgp->as; | |
6674 | ||
6675 | /* Auto-create assuming the same AS */ | |
6676 | ret = bgp_get(&bgp_default, &as, NULL, | |
6677 | BGP_INSTANCE_TYPE_DEFAULT); | |
6678 | ||
6679 | if (ret) { | |
6680 | vty_out(vty, | |
6681 | "VRF default is not configured as a bgp instance\n"); | |
6682 | return CMD_WARNING; | |
6683 | } | |
6684 | } | |
6685 | ||
69b07479 | 6686 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 6687 | |
69b07479 DS |
6688 | if (yes) { |
6689 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6690 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6691 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6692 | bgp->vpn_policy[afi].rmap_name[dir] = | |
6693 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6694 | bgp->vpn_policy[afi].rmap[dir] = | |
6695 | route_map_lookup_by_name(rmap_str); | |
6696 | if (!bgp->vpn_policy[afi].rmap[dir]) | |
6697 | return CMD_SUCCESS; | |
6698 | } else { | |
6699 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6700 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6701 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6702 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6703 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
bb4f6190 DS |
6704 | } |
6705 | ||
69b07479 DS |
6706 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
6707 | ||
bb4f6190 DS |
6708 | return CMD_SUCCESS; |
6709 | } | |
6710 | ||
6711 | ALIAS(af_import_vrf_route_map, af_no_import_vrf_route_map_cmd, | |
6712 | "no import vrf route-map", | |
6713 | NO_STR | |
6714 | "Import routes from another VRF\n" | |
6715 | "Vrf routes being filtered\n" | |
6716 | "Specify route map\n") | |
6717 | ||
12a844a5 DS |
6718 | DEFPY (bgp_imexport_vrf, |
6719 | bgp_imexport_vrf_cmd, | |
6720 | "[no] import vrf NAME$import_name", | |
6721 | NO_STR | |
6722 | "Import routes from another VRF\n" | |
6723 | "VRF to import from\n" | |
6724 | "The name of the VRF\n") | |
6725 | { | |
6726 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6727 | struct listnode *node; | |
79ef8664 DS |
6728 | struct bgp *vrf_bgp, *bgp_default; |
6729 | int32_t ret = 0; | |
6730 | as_t as = bgp->as; | |
12a844a5 DS |
6731 | bool remove = false; |
6732 | int32_t idx = 0; | |
6733 | char *vname; | |
a8dadcf6 | 6734 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
6735 | safi_t safi; |
6736 | afi_t afi; | |
6737 | ||
867f0cca | 6738 | if (import_name == NULL) { |
6739 | vty_out(vty, "%% Missing import name\n"); | |
6740 | return CMD_WARNING; | |
6741 | } | |
6742 | ||
12a844a5 DS |
6743 | if (argv_find(argv, argc, "no", &idx)) |
6744 | remove = true; | |
6745 | ||
0ca70ba5 DS |
6746 | afi = vpn_policy_getafi(vty, bgp, true); |
6747 | if (afi == AFI_MAX) | |
6748 | return CMD_WARNING_CONFIG_FAILED; | |
6749 | ||
12a844a5 DS |
6750 | safi = bgp_node_safi(vty); |
6751 | ||
25679caa DS |
6752 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
6753 | && (strcmp(import_name, BGP_DEFAULT_NAME) == 0)) | |
6754 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { | |
6755 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
6756 | remove ? "unimport" : "import", import_name); | |
6757 | return CMD_WARNING; | |
6758 | } | |
6759 | ||
79ef8664 DS |
6760 | bgp_default = bgp_get_default(); |
6761 | if (!bgp_default) { | |
6762 | /* Auto-create assuming the same AS */ | |
6763 | ret = bgp_get(&bgp_default, &as, NULL, | |
6764 | BGP_INSTANCE_TYPE_DEFAULT); | |
6765 | ||
6766 | if (ret) { | |
6767 | vty_out(vty, | |
6768 | "VRF default is not configured as a bgp instance\n"); | |
6769 | return CMD_WARNING; | |
6770 | } | |
6771 | } | |
6772 | ||
12a844a5 DS |
6773 | vrf_bgp = bgp_lookup_by_name(import_name); |
6774 | if (!vrf_bgp) { | |
79ef8664 DS |
6775 | if (strcmp(import_name, BGP_DEFAULT_NAME) == 0) |
6776 | vrf_bgp = bgp_default; | |
6777 | else | |
0fb8d6e6 DS |
6778 | /* Auto-create assuming the same AS */ |
6779 | ret = bgp_get(&vrf_bgp, &as, import_name, bgp_type); | |
a8dadcf6 | 6780 | |
6e2c7fe6 | 6781 | if (ret) { |
020a3f60 DS |
6782 | vty_out(vty, |
6783 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
6784 | import_name); |
6785 | return CMD_WARNING; | |
6786 | } | |
12a844a5 DS |
6787 | } |
6788 | ||
12a844a5 | 6789 | if (remove) { |
44338987 | 6790 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 6791 | } else { |
44338987 | 6792 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
6793 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
6794 | vname)) { | |
6795 | if (strcmp(vname, import_name) == 0) | |
6796 | return CMD_WARNING; | |
6797 | } | |
6798 | ||
44338987 | 6799 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
6800 | } |
6801 | ||
6802 | return CMD_SUCCESS; | |
6803 | } | |
6804 | ||
b9c7bc5a PZ |
6805 | /* This command is valid only in a bgp vrf instance or the default instance */ |
6806 | DEFPY (bgp_imexport_vpn, | |
6807 | bgp_imexport_vpn_cmd, | |
6808 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
6809 | NO_STR |
6810 | "Import routes to this address-family\n" | |
6811 | "Export routes from this address-family\n" | |
6812 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
6813 | { |
6814 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6815 | int previous_state; |
ddb5b488 | 6816 | afi_t afi; |
b9c7bc5a | 6817 | safi_t safi; |
ddb5b488 | 6818 | int idx = 0; |
b9c7bc5a PZ |
6819 | int yes = 1; |
6820 | int flag; | |
6821 | vpn_policy_direction_t dir; | |
ddb5b488 | 6822 | |
b9c7bc5a | 6823 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6824 | yes = 0; |
ddb5b488 | 6825 | |
b9c7bc5a PZ |
6826 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
6827 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 6828 | |
b9c7bc5a PZ |
6829 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
6830 | return CMD_WARNING_CONFIG_FAILED; | |
6831 | } | |
ddb5b488 | 6832 | |
b9c7bc5a PZ |
6833 | afi = bgp_node_afi(vty); |
6834 | safi = bgp_node_safi(vty); | |
6835 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
6836 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
6837 | return CMD_WARNING_CONFIG_FAILED; | |
6838 | } | |
ddb5b488 | 6839 | |
b9c7bc5a PZ |
6840 | if (!strcmp(direction_str, "import")) { |
6841 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
6842 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
6843 | } else if (!strcmp(direction_str, "export")) { | |
6844 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
6845 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
6846 | } else { | |
6847 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
6848 | return CMD_WARNING_CONFIG_FAILED; | |
6849 | } | |
6850 | ||
6851 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 6852 | |
b9c7bc5a PZ |
6853 | if (yes) { |
6854 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
6855 | if (!previous_state) { | |
6856 | /* trigger export current vrf */ | |
ddb5b488 PZ |
6857 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
6858 | } | |
b9c7bc5a PZ |
6859 | } else { |
6860 | if (previous_state) { | |
6861 | /* trigger un-export current vrf */ | |
6862 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
6863 | } | |
6864 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
6865 | } |
6866 | ||
6867 | return CMD_SUCCESS; | |
6868 | } | |
6869 | ||
301ad80a PG |
6870 | DEFPY (af_routetarget_import, |
6871 | af_routetarget_import_cmd, | |
6872 | "[no] <rt|route-target> redirect import RTLIST...", | |
6873 | NO_STR | |
6874 | "Specify route target list\n" | |
6875 | "Specify route target list\n" | |
6876 | "Flow-spec redirect type route target\n" | |
6877 | "Import routes to this address-family\n" | |
6878 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
6879 | { | |
6880 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6881 | int ret; | |
6882 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
6883 | afi_t afi; |
6884 | int idx = 0; | |
6885 | int yes = 1; | |
6886 | ||
6887 | if (argv_find(argv, argc, "no", &idx)) | |
6888 | yes = 0; | |
6889 | ||
0ca70ba5 | 6890 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6891 | if (afi == AFI_MAX) |
6892 | return CMD_WARNING_CONFIG_FAILED; | |
6893 | ||
301ad80a PG |
6894 | if (yes) { |
6895 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
6896 | vty_out(vty, "%% Missing RTLIST\n"); | |
6897 | return CMD_WARNING_CONFIG_FAILED; | |
6898 | } | |
6899 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
6900 | if (ret != CMD_SUCCESS) | |
6901 | return ret; | |
6902 | } | |
69b07479 DS |
6903 | |
6904 | if (yes) { | |
6905 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
6906 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 6907 | .import_redirect_rtlist); |
69b07479 DS |
6908 | bgp->vpn_policy[afi].import_redirect_rtlist = |
6909 | ecommunity_dup(ecom); | |
6910 | } else { | |
6911 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
6912 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 6913 | .import_redirect_rtlist); |
69b07479 | 6914 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 6915 | } |
69b07479 | 6916 | |
301ad80a PG |
6917 | if (ecom) |
6918 | ecommunity_free(&ecom); | |
6919 | ||
6920 | return CMD_SUCCESS; | |
6921 | } | |
6922 | ||
505e5056 | 6923 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 6924 | address_family_ipv4_safi_cmd, |
6925 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
6926 | "Enter Address Family command mode\n" | |
6927 | "Address Family\n" | |
6928 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 6929 | { |
f51bae9c | 6930 | |
d62a17ae | 6931 | if (argc == 3) { |
2131d5cf | 6932 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 6933 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
6934 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
6935 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 6936 | && safi != SAFI_EVPN) { |
31947174 MK |
6937 | vty_out(vty, |
6938 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
6939 | return CMD_WARNING_CONFIG_FAILED; |
6940 | } | |
d62a17ae | 6941 | vty->node = bgp_node_type(AFI_IP, safi); |
6942 | } else | |
6943 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 6944 | |
d62a17ae | 6945 | return CMD_SUCCESS; |
718e3744 | 6946 | } |
6947 | ||
505e5056 | 6948 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 6949 | address_family_ipv6_safi_cmd, |
6950 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
6951 | "Enter Address Family command mode\n" | |
6952 | "Address Family\n" | |
6953 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 6954 | { |
d62a17ae | 6955 | if (argc == 3) { |
2131d5cf | 6956 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 6957 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
6958 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
6959 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 6960 | && safi != SAFI_EVPN) { |
31947174 MK |
6961 | vty_out(vty, |
6962 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
6963 | return CMD_WARNING_CONFIG_FAILED; |
6964 | } | |
d62a17ae | 6965 | vty->node = bgp_node_type(AFI_IP6, safi); |
6966 | } else | |
6967 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 6968 | |
d62a17ae | 6969 | return CMD_SUCCESS; |
25ffbdc1 | 6970 | } |
718e3744 | 6971 | |
d6902373 | 6972 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 6973 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 6974 | address_family_vpnv4_cmd, |
8334fd5a | 6975 | "address-family vpnv4 [unicast]", |
718e3744 | 6976 | "Enter Address Family command mode\n" |
8c3deaae | 6977 | "Address Family\n" |
3a2d747c | 6978 | "Address Family modifier\n") |
718e3744 | 6979 | { |
d62a17ae | 6980 | vty->node = BGP_VPNV4_NODE; |
6981 | return CMD_SUCCESS; | |
718e3744 | 6982 | } |
6983 | ||
505e5056 | 6984 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 6985 | address_family_vpnv6_cmd, |
8334fd5a | 6986 | "address-family vpnv6 [unicast]", |
8ecd3266 | 6987 | "Enter Address Family command mode\n" |
8c3deaae | 6988 | "Address Family\n" |
3a2d747c | 6989 | "Address Family modifier\n") |
8ecd3266 | 6990 | { |
d62a17ae | 6991 | vty->node = BGP_VPNV6_NODE; |
6992 | return CMD_SUCCESS; | |
8ecd3266 | 6993 | } |
c016b6c7 | 6994 | #endif |
d6902373 | 6995 | |
505e5056 | 6996 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 6997 | address_family_evpn_cmd, |
7111c1a0 | 6998 | "address-family l2vpn evpn", |
4e0b7b6d | 6999 | "Enter Address Family command mode\n" |
7111c1a0 QY |
7000 | "Address Family\n" |
7001 | "Address Family modifier\n") | |
4e0b7b6d | 7002 | { |
2131d5cf | 7003 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7004 | vty->node = BGP_EVPN_NODE; |
7005 | return CMD_SUCCESS; | |
4e0b7b6d PG |
7006 | } |
7007 | ||
505e5056 | 7008 | DEFUN_NOSH (exit_address_family, |
718e3744 | 7009 | exit_address_family_cmd, |
7010 | "exit-address-family", | |
7011 | "Exit from Address Family configuration mode\n") | |
7012 | { | |
d62a17ae | 7013 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
7014 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
7015 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
7016 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
7017 | || vty->node == BGP_EVPN_NODE |
7018 | || vty->node == BGP_FLOWSPECV4_NODE | |
7019 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 7020 | vty->node = BGP_NODE; |
7021 | return CMD_SUCCESS; | |
718e3744 | 7022 | } |
6b0655a2 | 7023 | |
8ad7271d | 7024 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 7025 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
7026 | const char *ip_str, afi_t afi, safi_t safi, | |
7027 | struct prefix_rd *prd) | |
7028 | { | |
7029 | int ret; | |
7030 | struct prefix match; | |
7031 | struct bgp_node *rn; | |
7032 | struct bgp_node *rm; | |
7033 | struct bgp *bgp; | |
7034 | struct bgp_table *table; | |
7035 | struct bgp_table *rib; | |
7036 | ||
7037 | /* BGP structure lookup. */ | |
7038 | if (view_name) { | |
7039 | bgp = bgp_lookup_by_name(view_name); | |
7040 | if (bgp == NULL) { | |
7041 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
7042 | view_name); | |
7043 | return CMD_WARNING; | |
7044 | } | |
7045 | } else { | |
7046 | bgp = bgp_get_default(); | |
7047 | if (bgp == NULL) { | |
7048 | vty_out(vty, "%% No BGP process is configured\n"); | |
7049 | return CMD_WARNING; | |
7050 | } | |
7051 | } | |
7052 | ||
7053 | /* Check IP address argument. */ | |
7054 | ret = str2prefix(ip_str, &match); | |
7055 | if (!ret) { | |
7056 | vty_out(vty, "%% address is malformed\n"); | |
7057 | return CMD_WARNING; | |
7058 | } | |
7059 | ||
7060 | match.family = afi2family(afi); | |
7061 | rib = bgp->rib[afi][safi]; | |
7062 | ||
7063 | if (safi == SAFI_MPLS_VPN) { | |
7064 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
7065 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
7066 | continue; | |
7067 | ||
7068 | if ((table = rn->info) != NULL) { | |
7069 | if ((rm = bgp_node_match(table, &match)) | |
7070 | != NULL) { | |
7071 | if (rm->p.prefixlen | |
7072 | == match.prefixlen) { | |
343cdb61 | 7073 | SET_FLAG(rm->flags, |
d62a17ae | 7074 | BGP_NODE_USER_CLEAR); |
7075 | bgp_process(bgp, rm, afi, safi); | |
7076 | } | |
7077 | bgp_unlock_node(rm); | |
7078 | } | |
7079 | } | |
7080 | } | |
7081 | } else { | |
7082 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
7083 | if (rn->p.prefixlen == match.prefixlen) { | |
7084 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
7085 | bgp_process(bgp, rn, afi, safi); | |
7086 | } | |
7087 | bgp_unlock_node(rn); | |
7088 | } | |
7089 | } | |
7090 | ||
7091 | return CMD_SUCCESS; | |
8ad7271d DS |
7092 | } |
7093 | ||
b09b5ae0 | 7094 | /* one clear bgp command to rule them all */ |
718e3744 | 7095 | DEFUN (clear_ip_bgp_all, |
7096 | clear_ip_bgp_all_cmd, | |
c1a44e43 | 7097 | "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 | 7098 | CLEAR_STR |
7099 | IP_STR | |
7100 | BGP_STR | |
838758ac | 7101 | BGP_INSTANCE_HELP_STR |
510afcd6 DS |
7102 | BGP_AFI_HELP_STR |
7103 | BGP_SAFI_WITH_LABEL_HELP_STR | |
b09b5ae0 DW |
7104 | "Clear all peers\n" |
7105 | "BGP neighbor address to clear\n" | |
a80beece | 7106 | "BGP IPv6 neighbor to clear\n" |
838758ac | 7107 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
7108 | "Clear peers with the AS number\n" |
7109 | "Clear all external peers\n" | |
718e3744 | 7110 | "Clear all members of peer-group\n" |
b09b5ae0 | 7111 | "BGP peer-group name\n" |
b09b5ae0 DW |
7112 | BGP_SOFT_STR |
7113 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
7114 | BGP_SOFT_OUT_STR |
7115 | BGP_SOFT_IN_STR | |
7116 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 7117 | BGP_SOFT_OUT_STR) |
718e3744 | 7118 | { |
d62a17ae | 7119 | char *vrf = NULL; |
7120 | ||
7121 | afi_t afi = AFI_IP6; | |
7122 | safi_t safi = SAFI_UNICAST; | |
7123 | enum clear_sort clr_sort = clear_peer; | |
7124 | enum bgp_clear_type clr_type; | |
7125 | char *clr_arg = NULL; | |
7126 | ||
7127 | int idx = 0; | |
7128 | ||
7129 | /* clear [ip] bgp */ | |
7130 | if (argv_find(argv, argc, "ip", &idx)) | |
7131 | afi = AFI_IP; | |
7132 | ||
7133 | /* [<view|vrf> VIEWVRFNAME] */ | |
7134 | if (argv_find(argv, argc, "view", &idx) | |
7135 | || argv_find(argv, argc, "vrf", &idx)) { | |
7136 | vrf = argv[idx + 1]->arg; | |
7137 | idx += 2; | |
7138 | } | |
7139 | ||
7140 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
7141 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
7142 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
7143 | ||
7144 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */ | |
7145 | if (argv_find(argv, argc, "*", &idx)) { | |
7146 | clr_sort = clear_all; | |
7147 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
7148 | clr_sort = clear_peer; | |
7149 | clr_arg = argv[idx]->arg; | |
7150 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
7151 | clr_sort = clear_peer; | |
7152 | clr_arg = argv[idx]->arg; | |
7153 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
7154 | clr_sort = clear_group; | |
7155 | idx++; | |
7156 | clr_arg = argv[idx]->arg; | |
7157 | } else if (argv_find(argv, argc, "WORD", &idx)) { | |
7158 | clr_sort = clear_peer; | |
7159 | clr_arg = argv[idx]->arg; | |
7160 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { | |
7161 | clr_sort = clear_as; | |
7162 | clr_arg = argv[idx]->arg; | |
7163 | } else if (argv_find(argv, argc, "external", &idx)) { | |
7164 | clr_sort = clear_external; | |
7165 | } | |
7166 | ||
7167 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
7168 | if (argv_find(argv, argc, "soft", &idx)) { | |
7169 | if (argv_find(argv, argc, "in", &idx) | |
7170 | || argv_find(argv, argc, "out", &idx)) | |
7171 | clr_type = strmatch(argv[idx]->text, "in") | |
7172 | ? BGP_CLEAR_SOFT_IN | |
7173 | : BGP_CLEAR_SOFT_OUT; | |
7174 | else | |
7175 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
7176 | } else if (argv_find(argv, argc, "in", &idx)) { | |
7177 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
7178 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
7179 | : BGP_CLEAR_SOFT_IN; | |
7180 | } else if (argv_find(argv, argc, "out", &idx)) { | |
7181 | clr_type = BGP_CLEAR_SOFT_OUT; | |
7182 | } else | |
7183 | clr_type = BGP_CLEAR_SOFT_NONE; | |
7184 | ||
7185 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 7186 | } |
01080f7c | 7187 | |
8ad7271d DS |
7188 | DEFUN (clear_ip_bgp_prefix, |
7189 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 7190 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
7191 | CLEAR_STR |
7192 | IP_STR | |
7193 | BGP_STR | |
838758ac | 7194 | BGP_INSTANCE_HELP_STR |
8ad7271d | 7195 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7196 | "IPv4 prefix\n") |
8ad7271d | 7197 | { |
d62a17ae | 7198 | char *vrf = NULL; |
7199 | char *prefix = NULL; | |
8ad7271d | 7200 | |
d62a17ae | 7201 | int idx = 0; |
01080f7c | 7202 | |
d62a17ae | 7203 | /* [<view|vrf> VIEWVRFNAME] */ |
1d35f218 | 7204 | if (argv_find(argv, argc, "VIEWVRFNAME", &idx)) |
d62a17ae | 7205 | vrf = argv[idx]->arg; |
0c7b1b01 | 7206 | |
d62a17ae | 7207 | prefix = argv[argc - 1]->arg; |
8ad7271d | 7208 | |
d62a17ae | 7209 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 7210 | } |
8ad7271d | 7211 | |
b09b5ae0 DW |
7212 | DEFUN (clear_bgp_ipv6_safi_prefix, |
7213 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 7214 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7215 | CLEAR_STR |
3a2d747c | 7216 | IP_STR |
718e3744 | 7217 | BGP_STR |
8c3deaae | 7218 | "Address Family\n" |
46f296b4 | 7219 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7220 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7221 | "IPv6 prefix\n") |
718e3744 | 7222 | { |
9b475e76 PG |
7223 | int idx_safi = 0; |
7224 | int idx_ipv6_prefix = 0; | |
7225 | safi_t safi = SAFI_UNICAST; | |
7226 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7227 | argv[idx_ipv6_prefix]->arg : NULL; | |
7228 | ||
7229 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 7230 | return bgp_clear_prefix( |
9b475e76 PG |
7231 | vty, NULL, prefix, AFI_IP6, |
7232 | safi, NULL); | |
838758ac | 7233 | } |
01080f7c | 7234 | |
b09b5ae0 DW |
7235 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
7236 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 7237 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7238 | CLEAR_STR |
3a2d747c | 7239 | IP_STR |
718e3744 | 7240 | BGP_STR |
838758ac | 7241 | BGP_INSTANCE_HELP_STR |
8c3deaae | 7242 | "Address Family\n" |
46f296b4 | 7243 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7244 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7245 | "IPv6 prefix\n") |
718e3744 | 7246 | { |
d62a17ae | 7247 | int idx_word = 3; |
9b475e76 PG |
7248 | int idx_safi = 0; |
7249 | int idx_ipv6_prefix = 0; | |
7250 | safi_t safi = SAFI_UNICAST; | |
7251 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7252 | argv[idx_ipv6_prefix]->arg : NULL; | |
7253 | /* [<view|vrf> VIEWVRFNAME] */ | |
7254 | char *vrfview = argv_find(argv, argc, "VIEWVRFNAME", &idx_word) ? | |
7255 | argv[idx_word]->arg : NULL; | |
7256 | ||
7257 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
7258 | ||
d62a17ae | 7259 | return bgp_clear_prefix( |
9b475e76 PG |
7260 | vty, vrfview, prefix, |
7261 | AFI_IP6, safi, NULL); | |
718e3744 | 7262 | } |
7263 | ||
b09b5ae0 DW |
7264 | DEFUN (show_bgp_views, |
7265 | show_bgp_views_cmd, | |
d6e3c605 | 7266 | "show [ip] bgp views", |
b09b5ae0 | 7267 | SHOW_STR |
d6e3c605 | 7268 | IP_STR |
01080f7c | 7269 | BGP_STR |
b09b5ae0 | 7270 | "Show the defined BGP views\n") |
01080f7c | 7271 | { |
d62a17ae | 7272 | struct list *inst = bm->bgp; |
7273 | struct listnode *node; | |
7274 | struct bgp *bgp; | |
01080f7c | 7275 | |
d62a17ae | 7276 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { |
7277 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
7278 | return CMD_WARNING; | |
7279 | } | |
e52702f2 | 7280 | |
d62a17ae | 7281 | vty_out(vty, "Defined BGP views:\n"); |
7282 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7283 | /* Skip VRFs. */ | |
7284 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
7285 | continue; | |
7286 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
7287 | bgp->as); | |
7288 | } | |
e52702f2 | 7289 | |
d62a17ae | 7290 | return CMD_SUCCESS; |
e0081f70 ML |
7291 | } |
7292 | ||
8386ac43 | 7293 | DEFUN (show_bgp_vrfs, |
7294 | show_bgp_vrfs_cmd, | |
d6e3c605 | 7295 | "show [ip] bgp vrfs [json]", |
8386ac43 | 7296 | SHOW_STR |
d6e3c605 | 7297 | IP_STR |
8386ac43 | 7298 | BGP_STR |
7299 | "Show BGP VRFs\n" | |
9973d184 | 7300 | JSON_STR) |
8386ac43 | 7301 | { |
fe1dc5a3 | 7302 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 7303 | struct list *inst = bm->bgp; |
7304 | struct listnode *node; | |
7305 | struct bgp *bgp; | |
d7c0a89a | 7306 | uint8_t uj = use_json(argc, argv); |
d62a17ae | 7307 | json_object *json = NULL; |
7308 | json_object *json_vrfs = NULL; | |
7309 | int count = 0; | |
d62a17ae | 7310 | |
7311 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { | |
7312 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
7313 | return CMD_WARNING; | |
7314 | } | |
7315 | ||
7316 | if (uj) { | |
7317 | json = json_object_new_object(); | |
7318 | json_vrfs = json_object_new_object(); | |
7319 | } | |
7320 | ||
7321 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7322 | const char *name, *type; | |
7323 | struct peer *peer; | |
7324 | struct listnode *node, *nnode; | |
7325 | int peers_cfg, peers_estb; | |
7326 | json_object *json_vrf = NULL; | |
d62a17ae | 7327 | |
7328 | /* Skip Views. */ | |
7329 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
7330 | continue; | |
7331 | ||
7332 | count++; | |
7333 | if (!uj && count == 1) | |
fe1dc5a3 MK |
7334 | vty_out(vty, |
7335 | "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n", | |
a4d82a8a PZ |
7336 | "Type", "Id", "routerId", "#PeersVfg", |
7337 | "#PeersEstb", "Name", "L3-VNI", "Rmac"); | |
d62a17ae | 7338 | |
7339 | peers_cfg = peers_estb = 0; | |
7340 | if (uj) | |
7341 | json_vrf = json_object_new_object(); | |
7342 | ||
7343 | ||
7344 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
7345 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7346 | continue; | |
7347 | peers_cfg++; | |
7348 | if (peer->status == Established) | |
7349 | peers_estb++; | |
7350 | } | |
7351 | ||
7352 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
7353 | name = "Default"; | |
7354 | type = "DFLT"; | |
7355 | } else { | |
7356 | name = bgp->name; | |
7357 | type = "VRF"; | |
7358 | } | |
7359 | ||
a8bf7d9c | 7360 | |
d62a17ae | 7361 | if (uj) { |
a4d82a8a PZ |
7362 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7363 | ? -1 | |
7364 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 7365 | json_object_string_add(json_vrf, "type", type); |
7366 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
7367 | json_object_string_add(json_vrf, "routerId", | |
7368 | inet_ntoa(bgp->router_id)); | |
7369 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
7370 | peers_cfg); | |
7371 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
7372 | peers_estb); | |
7373 | ||
fe1dc5a3 | 7374 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
7375 | json_object_string_add( |
7376 | json_vrf, "rmac", | |
7377 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
d62a17ae | 7378 | json_object_object_add(json_vrfs, name, json_vrf); |
7379 | } else | |
fe1dc5a3 MK |
7380 | vty_out(vty, |
7381 | "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n", | |
a4d82a8a PZ |
7382 | type, |
7383 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
7384 | : (int)bgp->vrf_id, | |
7385 | inet_ntoa(bgp->router_id), peers_cfg, | |
7386 | peers_estb, name, bgp->l3vni, | |
fe1dc5a3 | 7387 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); |
d62a17ae | 7388 | } |
7389 | ||
7390 | if (uj) { | |
7391 | json_object_object_add(json, "vrfs", json_vrfs); | |
7392 | ||
7393 | json_object_int_add(json, "totalVrfs", count); | |
7394 | ||
996c9314 LB |
7395 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
7396 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 7397 | json_object_free(json); |
7398 | } else { | |
7399 | if (count) | |
7400 | vty_out(vty, | |
7401 | "\nTotal number of VRFs (including default): %d\n", | |
7402 | count); | |
7403 | } | |
7404 | ||
7405 | return CMD_SUCCESS; | |
8386ac43 | 7406 | } |
7407 | ||
acf71666 MK |
7408 | static void show_address_entry(struct hash_backet *backet, void *args) |
7409 | { | |
60466a63 QY |
7410 | struct vty *vty = (struct vty *)args; |
7411 | struct bgp_addr *addr = (struct bgp_addr *)backet->data; | |
acf71666 | 7412 | |
60466a63 | 7413 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(addr->addr), |
acf71666 MK |
7414 | addr->refcnt); |
7415 | } | |
7416 | ||
7417 | static void show_tip_entry(struct hash_backet *backet, void *args) | |
7418 | { | |
0291c246 | 7419 | struct vty *vty = (struct vty *)args; |
60466a63 | 7420 | struct tip_addr *tip = (struct tip_addr *)backet->data; |
acf71666 | 7421 | |
60466a63 | 7422 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
7423 | tip->refcnt); |
7424 | } | |
7425 | ||
7426 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
7427 | { | |
7428 | vty_out(vty, "self nexthop database:\n"); | |
7429 | hash_iterate(bgp->address_hash, | |
7430 | (void (*)(struct hash_backet *, void *))show_address_entry, | |
7431 | vty); | |
7432 | ||
7433 | vty_out(vty, "Tunnel-ip database:\n"); | |
7434 | hash_iterate(bgp->tip_hash, | |
7435 | (void (*)(struct hash_backet *, void *))show_tip_entry, | |
7436 | vty); | |
7437 | } | |
7438 | ||
15c81ca4 DS |
7439 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
7440 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
7441 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
7442 | "martian next-hops\n" |
7443 | "martian next-hop database\n") | |
acf71666 | 7444 | { |
0291c246 | 7445 | struct bgp *bgp = NULL; |
15c81ca4 DS |
7446 | int idx = 0; |
7447 | ||
7448 | if (argv_find(argv, argc, "view", &idx) | |
7449 | || argv_find(argv, argc, "vrf", &idx)) | |
7450 | bgp = bgp_lookup_by_name(argv[idx + 1]->arg); | |
7451 | else | |
7452 | bgp = bgp_get_default(); | |
acf71666 | 7453 | |
acf71666 MK |
7454 | if (!bgp) { |
7455 | vty_out(vty, "%% No BGP process is configured\n"); | |
7456 | return CMD_WARNING; | |
7457 | } | |
7458 | bgp_show_martian_nexthops(vty, bgp); | |
7459 | ||
7460 | return CMD_SUCCESS; | |
7461 | } | |
7462 | ||
f412b39a | 7463 | DEFUN (show_bgp_memory, |
4bf6a362 | 7464 | show_bgp_memory_cmd, |
7fa12b13 | 7465 | "show [ip] bgp memory", |
4bf6a362 | 7466 | SHOW_STR |
3a2d747c | 7467 | IP_STR |
4bf6a362 PJ |
7468 | BGP_STR |
7469 | "Global BGP memory statistics\n") | |
7470 | { | |
d62a17ae | 7471 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
7472 | unsigned long count; | |
7473 | ||
7474 | /* RIB related usage stats */ | |
7475 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
7476 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
7477 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7478 | count * sizeof(struct bgp_node))); | |
7479 | ||
7480 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
7481 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
7482 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7483 | count * sizeof(struct bgp_info))); | |
7484 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) | |
7485 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
7486 | count, | |
7487 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7488 | count * sizeof(struct bgp_info_extra))); | |
7489 | ||
7490 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
7491 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
7492 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7493 | count * sizeof(struct bgp_static))); | |
7494 | ||
7495 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
7496 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
7497 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7498 | count * sizeof(struct bpacket))); | |
7499 | ||
7500 | /* Adj-In/Out */ | |
7501 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
7502 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
7503 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7504 | count * sizeof(struct bgp_adj_in))); | |
7505 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
7506 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
7507 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7508 | count * sizeof(struct bgp_adj_out))); | |
7509 | ||
7510 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
7511 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
7512 | count, | |
7513 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7514 | count * sizeof(struct bgp_nexthop_cache))); | |
7515 | ||
7516 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
7517 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
7518 | count, | |
7519 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7520 | count * sizeof(struct bgp_damp_info))); | |
7521 | ||
7522 | /* Attributes */ | |
7523 | count = attr_count(); | |
7524 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
7525 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7526 | count * sizeof(struct attr))); | |
7527 | ||
7528 | if ((count = attr_unknown_count())) | |
7529 | vty_out(vty, "%ld unknown attributes\n", count); | |
7530 | ||
7531 | /* AS_PATH attributes */ | |
7532 | count = aspath_count(); | |
7533 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
7534 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7535 | count * sizeof(struct aspath))); | |
7536 | ||
7537 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
7538 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
7539 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7540 | count * sizeof(struct assegment))); | |
7541 | ||
7542 | /* Other attributes */ | |
7543 | if ((count = community_count())) | |
7544 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7545 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7546 | count * sizeof(struct community))); | |
d62a17ae | 7547 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
7548 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7549 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7550 | count * sizeof(struct ecommunity))); | |
d62a17ae | 7551 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
7552 | vty_out(vty, | |
7553 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
7554 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7555 | count * sizeof(struct lcommunity))); | |
d62a17ae | 7556 | |
7557 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
7558 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
7559 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7560 | count * sizeof(struct cluster_list))); | |
7561 | ||
7562 | /* Peer related usage */ | |
7563 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
7564 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
7565 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7566 | count * sizeof(struct peer))); | |
7567 | ||
7568 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
7569 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
7570 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7571 | count * sizeof(struct peer_group))); | |
7572 | ||
7573 | /* Other */ | |
7574 | if ((count = mtype_stats_alloc(MTYPE_HASH))) | |
7575 | vty_out(vty, "%ld hash tables, using %s of memory\n", count, | |
7576 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7577 | count * sizeof(struct hash))); | |
7578 | if ((count = mtype_stats_alloc(MTYPE_HASH_BACKET))) | |
7579 | vty_out(vty, "%ld hash buckets, using %s of memory\n", count, | |
7580 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7581 | count * sizeof(struct hash_backet))); | |
7582 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) | |
7583 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
7584 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7585 | count * sizeof(regex_t))); | |
d62a17ae | 7586 | return CMD_SUCCESS; |
4bf6a362 | 7587 | } |
fee0f4c6 | 7588 | |
57a9c8a8 DS |
7589 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
7590 | { | |
7591 | json_object *bestpath = json_object_new_object(); | |
7592 | ||
7593 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
7594 | json_object_string_add(bestpath, "asPath", "ignore"); | |
7595 | ||
7596 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
7597 | json_object_string_add(bestpath, "asPath", "confed"); | |
7598 | ||
7599 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
a4d82a8a PZ |
7600 | if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) |
7601 | json_object_string_add(bestpath, "multiPathRelax", | |
57a9c8a8 DS |
7602 | "as-set"); |
7603 | else | |
a4d82a8a | 7604 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
7605 | "true"); |
7606 | } else | |
a4d82a8a | 7607 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 DS |
7608 | |
7609 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
7610 | json_object_string_add(bestpath, "compareRouterId", "true"); | |
7611 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
7612 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
7613 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 7614 | json_object_string_add(bestpath, "med", "confed"); |
57a9c8a8 DS |
7615 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
7616 | json_object_string_add(bestpath, "med", | |
7617 | "missing-as-worst"); | |
7618 | else | |
7619 | json_object_string_add(bestpath, "med", "true"); | |
7620 | } | |
7621 | ||
7622 | json_object_object_add(json, "bestPath", bestpath); | |
7623 | } | |
7624 | ||
718e3744 | 7625 | /* Show BGP peer's summary information. */ |
d62a17ae | 7626 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
d7c0a89a | 7627 | uint8_t use_json, json_object *json) |
d62a17ae | 7628 | { |
7629 | struct peer *peer; | |
7630 | struct listnode *node, *nnode; | |
7631 | unsigned int count = 0, dn_count = 0; | |
7632 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
7633 | char neighbor_buf[VTY_BUFSIZ]; | |
7634 | int neighbor_col_default_width = 16; | |
7635 | int len; | |
7636 | int max_neighbor_width = 0; | |
7637 | int pfx_rcd_safi; | |
7638 | json_object *json_peer = NULL; | |
7639 | json_object *json_peers = NULL; | |
7640 | ||
7641 | /* labeled-unicast routes are installed in the unicast table so in order | |
7642 | * to | |
7643 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
7644 | */ | |
7645 | if (safi == SAFI_LABELED_UNICAST) | |
7646 | pfx_rcd_safi = SAFI_UNICAST; | |
7647 | else | |
7648 | pfx_rcd_safi = safi; | |
7649 | ||
7650 | if (use_json) { | |
7651 | if (json == NULL) | |
7652 | json = json_object_new_object(); | |
7653 | ||
7654 | json_peers = json_object_new_object(); | |
7655 | } else { | |
7656 | /* Loop over all neighbors that will be displayed to determine | |
7657 | * how many | |
7658 | * characters are needed for the Neighbor column | |
7659 | */ | |
7660 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
7661 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7662 | continue; | |
7663 | ||
7664 | if (peer->afc[afi][safi]) { | |
7665 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7666 | if (peer_dynamic_neighbor(peer)) | |
7667 | dn_flag[0] = '*'; | |
7668 | ||
7669 | if (peer->hostname | |
7670 | && bgp_flag_check(bgp, | |
7671 | BGP_FLAG_SHOW_HOSTNAME)) | |
7672 | sprintf(neighbor_buf, "%s%s(%s) ", | |
7673 | dn_flag, peer->hostname, | |
7674 | peer->host); | |
7675 | else | |
7676 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
7677 | peer->host); | |
7678 | ||
7679 | len = strlen(neighbor_buf); | |
7680 | ||
7681 | if (len > max_neighbor_width) | |
7682 | max_neighbor_width = len; | |
7683 | } | |
7684 | } | |
f933309e | 7685 | |
d62a17ae | 7686 | /* Originally we displayed the Neighbor column as 16 |
7687 | * characters wide so make that the default | |
7688 | */ | |
7689 | if (max_neighbor_width < neighbor_col_default_width) | |
7690 | max_neighbor_width = neighbor_col_default_width; | |
7691 | } | |
f933309e | 7692 | |
d62a17ae | 7693 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
7694 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7695 | continue; | |
7696 | ||
ea47320b DL |
7697 | if (!peer->afc[afi][safi]) |
7698 | continue; | |
d62a17ae | 7699 | |
ea47320b DL |
7700 | if (!count) { |
7701 | unsigned long ents; | |
7702 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 7703 | int64_t vrf_id_ui; |
d62a17ae | 7704 | |
a4d82a8a PZ |
7705 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7706 | ? -1 | |
7707 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
7708 | |
7709 | /* Usage summary and header */ | |
7710 | if (use_json) { | |
7711 | json_object_string_add( | |
7712 | json, "routerId", | |
7713 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
7714 | json_object_int_add(json, "as", bgp->as); |
7715 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
7716 | json_object_string_add( |
7717 | json, "vrfName", | |
7718 | (bgp->inst_type | |
7719 | == BGP_INSTANCE_TYPE_DEFAULT) | |
7720 | ? "Default" | |
7721 | : bgp->name); | |
7722 | } else { | |
7723 | vty_out(vty, | |
7724 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 7725 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
7726 | bgp->vrf_id == VRF_UNKNOWN |
7727 | ? -1 | |
7728 | : (int)bgp->vrf_id); | |
ea47320b DL |
7729 | vty_out(vty, "\n"); |
7730 | } | |
d62a17ae | 7731 | |
ea47320b | 7732 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 7733 | if (use_json) { |
ea47320b | 7734 | json_object_int_add( |
60466a63 | 7735 | json, "updateDelayLimit", |
ea47320b | 7736 | bgp->v_update_delay); |
d62a17ae | 7737 | |
ea47320b DL |
7738 | if (bgp->v_update_delay |
7739 | != bgp->v_establish_wait) | |
d62a17ae | 7740 | json_object_int_add( |
7741 | json, | |
ea47320b DL |
7742 | "updateDelayEstablishWait", |
7743 | bgp->v_establish_wait); | |
d62a17ae | 7744 | |
60466a63 | 7745 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
7746 | json_object_string_add( |
7747 | json, | |
7748 | "updateDelayFirstNeighbor", | |
7749 | bgp->update_delay_begin_time); | |
7750 | json_object_boolean_true_add( | |
7751 | json, | |
7752 | "updateDelayInProgress"); | |
7753 | } else { | |
7754 | if (bgp->update_delay_over) { | |
d62a17ae | 7755 | json_object_string_add( |
7756 | json, | |
7757 | "updateDelayFirstNeighbor", | |
7758 | bgp->update_delay_begin_time); | |
ea47320b | 7759 | json_object_string_add( |
d62a17ae | 7760 | json, |
ea47320b DL |
7761 | "updateDelayBestpathResumed", |
7762 | bgp->update_delay_end_time); | |
7763 | json_object_string_add( | |
d62a17ae | 7764 | json, |
ea47320b DL |
7765 | "updateDelayZebraUpdateResume", |
7766 | bgp->update_delay_zebra_resume_time); | |
7767 | json_object_string_add( | |
7768 | json, | |
7769 | "updateDelayPeerUpdateResume", | |
7770 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 7771 | } |
ea47320b DL |
7772 | } |
7773 | } else { | |
7774 | vty_out(vty, | |
7775 | "Read-only mode update-delay limit: %d seconds\n", | |
7776 | bgp->v_update_delay); | |
7777 | if (bgp->v_update_delay | |
7778 | != bgp->v_establish_wait) | |
d62a17ae | 7779 | vty_out(vty, |
ea47320b DL |
7780 | " Establish wait: %d seconds\n", |
7781 | bgp->v_establish_wait); | |
d62a17ae | 7782 | |
60466a63 | 7783 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
7784 | vty_out(vty, |
7785 | " First neighbor established: %s\n", | |
7786 | bgp->update_delay_begin_time); | |
7787 | vty_out(vty, | |
7788 | " Delay in progress\n"); | |
7789 | } else { | |
7790 | if (bgp->update_delay_over) { | |
d62a17ae | 7791 | vty_out(vty, |
7792 | " First neighbor established: %s\n", | |
7793 | bgp->update_delay_begin_time); | |
7794 | vty_out(vty, | |
ea47320b DL |
7795 | " Best-paths resumed: %s\n", |
7796 | bgp->update_delay_end_time); | |
7797 | vty_out(vty, | |
7798 | " zebra update resumed: %s\n", | |
7799 | bgp->update_delay_zebra_resume_time); | |
7800 | vty_out(vty, | |
7801 | " peers update resumed: %s\n", | |
7802 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 7803 | } |
7804 | } | |
7805 | } | |
ea47320b | 7806 | } |
d62a17ae | 7807 | |
ea47320b DL |
7808 | if (use_json) { |
7809 | if (bgp_maxmed_onstartup_configured(bgp) | |
7810 | && bgp->maxmed_active) | |
7811 | json_object_boolean_true_add( | |
60466a63 | 7812 | json, "maxMedOnStartup"); |
ea47320b DL |
7813 | if (bgp->v_maxmed_admin) |
7814 | json_object_boolean_true_add( | |
60466a63 | 7815 | json, "maxMedAdministrative"); |
d62a17ae | 7816 | |
ea47320b DL |
7817 | json_object_int_add( |
7818 | json, "tableVersion", | |
60466a63 | 7819 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 7820 | |
60466a63 QY |
7821 | ents = bgp_table_count(bgp->rib[afi][safi]); |
7822 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
7823 | json_object_int_add( |
7824 | json, "ribMemory", | |
7825 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 7826 | |
ea47320b | 7827 | ents = listcount(bgp->peer); |
60466a63 QY |
7828 | json_object_int_add(json, "peerCount", ents); |
7829 | json_object_int_add(json, "peerMemory", | |
7830 | ents * sizeof(struct peer)); | |
d62a17ae | 7831 | |
ea47320b DL |
7832 | if ((ents = listcount(bgp->group))) { |
7833 | json_object_int_add( | |
60466a63 | 7834 | json, "peerGroupCount", ents); |
ea47320b DL |
7835 | json_object_int_add( |
7836 | json, "peerGroupMemory", | |
996c9314 LB |
7837 | ents * sizeof(struct |
7838 | peer_group)); | |
ea47320b | 7839 | } |
d62a17ae | 7840 | |
ea47320b DL |
7841 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
7842 | BGP_CONFIG_DAMPENING)) | |
7843 | json_object_boolean_true_add( | |
60466a63 | 7844 | json, "dampeningEnabled"); |
ea47320b DL |
7845 | } else { |
7846 | if (bgp_maxmed_onstartup_configured(bgp) | |
7847 | && bgp->maxmed_active) | |
d62a17ae | 7848 | vty_out(vty, |
ea47320b DL |
7849 | "Max-med on-startup active\n"); |
7850 | if (bgp->v_maxmed_admin) | |
d62a17ae | 7851 | vty_out(vty, |
ea47320b | 7852 | "Max-med administrative active\n"); |
d62a17ae | 7853 | |
60466a63 QY |
7854 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
7855 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 7856 | |
60466a63 | 7857 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
7858 | vty_out(vty, |
7859 | "RIB entries %ld, using %s of memory\n", | |
7860 | ents, | |
996c9314 LB |
7861 | mtype_memstr(memstrbuf, |
7862 | sizeof(memstrbuf), | |
7863 | ents * sizeof(struct | |
7864 | bgp_node))); | |
ea47320b DL |
7865 | |
7866 | /* Peer related usage */ | |
7867 | ents = listcount(bgp->peer); | |
60466a63 | 7868 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
7869 | ents, |
7870 | mtype_memstr( | |
60466a63 QY |
7871 | memstrbuf, sizeof(memstrbuf), |
7872 | ents * sizeof(struct peer))); | |
ea47320b DL |
7873 | |
7874 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 7875 | vty_out(vty, |
ea47320b | 7876 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 7877 | ents, |
7878 | mtype_memstr( | |
7879 | memstrbuf, | |
7880 | sizeof(memstrbuf), | |
996c9314 LB |
7881 | ents * sizeof(struct |
7882 | peer_group))); | |
d62a17ae | 7883 | |
ea47320b DL |
7884 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
7885 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 7886 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 7887 | vty_out(vty, "\n"); |
d62a17ae | 7888 | |
ea47320b DL |
7889 | /* Subtract 8 here because 'Neighbor' is |
7890 | * 8 characters */ | |
7891 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
7892 | vty_out(vty, "%*s", max_neighbor_width - 8, |
7893 | " "); | |
ea47320b DL |
7894 | vty_out(vty, |
7895 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); | |
d62a17ae | 7896 | } |
ea47320b | 7897 | } |
d62a17ae | 7898 | |
ea47320b | 7899 | count++; |
d62a17ae | 7900 | |
ea47320b DL |
7901 | if (use_json) { |
7902 | json_peer = json_object_new_object(); | |
d62a17ae | 7903 | |
ea47320b | 7904 | if (peer_dynamic_neighbor(peer)) |
60466a63 QY |
7905 | json_object_boolean_true_add(json_peer, |
7906 | "dynamicPeer"); | |
d62a17ae | 7907 | |
ea47320b | 7908 | if (peer->hostname) |
60466a63 | 7909 | json_object_string_add(json_peer, "hostname", |
ea47320b | 7910 | peer->hostname); |
d62a17ae | 7911 | |
ea47320b | 7912 | if (peer->domainname) |
60466a63 QY |
7913 | json_object_string_add(json_peer, "domainname", |
7914 | peer->domainname); | |
d62a17ae | 7915 | |
60466a63 | 7916 | json_object_int_add(json_peer, "remoteAs", peer->as); |
ea47320b | 7917 | json_object_int_add(json_peer, "version", 4); |
60466a63 | 7918 | json_object_int_add(json_peer, "msgRcvd", |
0112e9e0 | 7919 | PEER_TOTAL_RX(peer)); |
60466a63 | 7920 | json_object_int_add(json_peer, "msgSent", |
0112e9e0 | 7921 | PEER_TOTAL_TX(peer)); |
ea47320b DL |
7922 | |
7923 | json_object_int_add(json_peer, "tableVersion", | |
7924 | peer->version[afi][safi]); | |
7925 | json_object_int_add(json_peer, "outq", | |
7926 | peer->obuf->count); | |
7927 | json_object_int_add(json_peer, "inq", 0); | |
60466a63 QY |
7928 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
7929 | use_json, json_peer); | |
7930 | json_object_int_add(json_peer, "prefixReceivedCount", | |
7931 | peer->pcount[afi][pfx_rcd_safi]); | |
d62a17ae | 7932 | |
ea47320b | 7933 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
60466a63 | 7934 | json_object_string_add(json_peer, "state", |
ea47320b | 7935 | "Idle (Admin)"); |
9199a725 TM |
7936 | else if (peer->afc_recv[afi][safi]) |
7937 | json_object_string_add( | |
7938 | json_peer, "state", | |
7939 | lookup_msg(bgp_status_msg, peer->status, | |
7940 | NULL)); | |
60466a63 QY |
7941 | else if (CHECK_FLAG(peer->sflags, |
7942 | PEER_STATUS_PREFIX_OVERFLOW)) | |
7943 | json_object_string_add(json_peer, "state", | |
ea47320b DL |
7944 | "Idle (PfxCt)"); |
7945 | else | |
7946 | json_object_string_add( | |
7947 | json_peer, "state", | |
60466a63 QY |
7948 | lookup_msg(bgp_status_msg, peer->status, |
7949 | NULL)); | |
ea47320b DL |
7950 | |
7951 | if (peer->conf_if) | |
60466a63 | 7952 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
7953 | "interface"); |
7954 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
7955 | json_object_string_add(json_peer, "idType", |
7956 | "ipv4"); | |
ea47320b | 7957 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
7958 | json_object_string_add(json_peer, "idType", |
7959 | "ipv6"); | |
d62a17ae | 7960 | |
ea47320b DL |
7961 | json_object_object_add(json_peers, peer->host, |
7962 | json_peer); | |
7963 | } else { | |
7964 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7965 | if (peer_dynamic_neighbor(peer)) { | |
7966 | dn_count++; | |
7967 | dn_flag[0] = '*'; | |
7968 | } | |
d62a17ae | 7969 | |
ea47320b | 7970 | if (peer->hostname |
60466a63 | 7971 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
ea47320b | 7972 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
60466a63 | 7973 | peer->hostname, peer->host); |
ea47320b | 7974 | else |
60466a63 | 7975 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
ea47320b DL |
7976 | |
7977 | /* pad the neighbor column with spaces */ | |
7978 | if (len < max_neighbor_width) | |
60466a63 QY |
7979 | vty_out(vty, "%*s", max_neighbor_width - len, |
7980 | " "); | |
ea47320b | 7981 | |
86a55b99 | 7982 | vty_out(vty, "4 %10u %7u %7u %8" PRIu64 " %4d %4zd %8s", |
0112e9e0 QY |
7983 | peer->as, PEER_TOTAL_RX(peer), |
7984 | PEER_TOTAL_TX(peer), peer->version[afi][safi], | |
7985 | 0, peer->obuf->count, | |
d62a17ae | 7986 | peer_uptime(peer->uptime, timebuf, |
ea47320b | 7987 | BGP_UPTIME_LEN, 0, NULL)); |
d62a17ae | 7988 | |
ea47320b | 7989 | if (peer->status == Established) |
2f8f4f10 | 7990 | if (peer->afc_recv[afi][safi]) |
95077abf | 7991 | vty_out(vty, " %12ld", |
a4d82a8a PZ |
7992 | peer->pcount[afi] |
7993 | [pfx_rcd_safi]); | |
95077abf DW |
7994 | else |
7995 | vty_out(vty, " NoNeg"); | |
ea47320b | 7996 | else { |
60466a63 | 7997 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
ea47320b | 7998 | vty_out(vty, " Idle (Admin)"); |
60466a63 QY |
7999 | else if (CHECK_FLAG( |
8000 | peer->sflags, | |
8001 | PEER_STATUS_PREFIX_OVERFLOW)) | |
ea47320b | 8002 | vty_out(vty, " Idle (PfxCt)"); |
d62a17ae | 8003 | else |
ea47320b | 8004 | vty_out(vty, " %12s", |
60466a63 QY |
8005 | lookup_msg(bgp_status_msg, |
8006 | peer->status, NULL)); | |
d62a17ae | 8007 | } |
ea47320b | 8008 | vty_out(vty, "\n"); |
d62a17ae | 8009 | } |
8010 | } | |
f933309e | 8011 | |
d62a17ae | 8012 | if (use_json) { |
8013 | json_object_object_add(json, "peers", json_peers); | |
8014 | ||
8015 | json_object_int_add(json, "totalPeers", count); | |
8016 | json_object_int_add(json, "dynamicPeers", dn_count); | |
8017 | ||
57a9c8a8 DS |
8018 | bgp_show_bestpath_json(bgp, json); |
8019 | ||
996c9314 LB |
8020 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8021 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8022 | json_object_free(json); |
8023 | } else { | |
8024 | if (count) | |
8025 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8026 | else { | |
d6ceaca3 | 8027 | vty_out(vty, "No %s neighbor is configured\n", |
8028 | afi_safi_print(afi, safi)); | |
d62a17ae | 8029 | } |
b05a1c8b | 8030 | |
d6ceaca3 | 8031 | if (dn_count) { |
d62a17ae | 8032 | vty_out(vty, "* - dynamic neighbor\n"); |
8033 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
8034 | dn_count, bgp->dynamic_neighbors_limit); | |
8035 | } | |
8036 | } | |
1ff9a340 | 8037 | |
d62a17ae | 8038 | return CMD_SUCCESS; |
718e3744 | 8039 | } |
8040 | ||
d62a17ae | 8041 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
d7c0a89a | 8042 | int safi, uint8_t use_json, |
d62a17ae | 8043 | json_object *json) |
8044 | { | |
8045 | int is_first = 1; | |
8046 | int afi_wildcard = (afi == AFI_MAX); | |
8047 | int safi_wildcard = (safi == SAFI_MAX); | |
8048 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
8049 | bool json_output = false; | |
8050 | ||
8051 | if (use_json && is_wildcard) | |
8052 | vty_out(vty, "{\n"); | |
8053 | if (afi_wildcard) | |
8054 | afi = 1; /* AFI_IP */ | |
8055 | while (afi < AFI_MAX) { | |
8056 | if (safi_wildcard) | |
8057 | safi = 1; /* SAFI_UNICAST */ | |
8058 | while (safi < SAFI_MAX) { | |
318cac96 | 8059 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
d62a17ae | 8060 | json_output = true; |
8061 | if (is_wildcard) { | |
8062 | /* | |
8063 | * So limit output to those afi/safi | |
8064 | * pairs that | |
8065 | * actualy have something interesting in | |
8066 | * them | |
8067 | */ | |
8068 | if (use_json) { | |
8069 | json = json_object_new_object(); | |
8070 | ||
8071 | if (!is_first) | |
8072 | vty_out(vty, ",\n"); | |
8073 | else | |
8074 | is_first = 0; | |
8075 | ||
8076 | vty_out(vty, "\"%s\":", | |
8077 | afi_safi_json(afi, | |
8078 | safi)); | |
8079 | } else { | |
8080 | vty_out(vty, "\n%s Summary:\n", | |
8081 | afi_safi_print(afi, | |
8082 | safi)); | |
8083 | } | |
8084 | } | |
8085 | bgp_show_summary(vty, bgp, afi, safi, use_json, | |
8086 | json); | |
8087 | } | |
8088 | safi++; | |
d62a17ae | 8089 | if (!safi_wildcard) |
8090 | safi = SAFI_MAX; | |
8091 | } | |
8092 | afi++; | |
ee851c8c | 8093 | if (!afi_wildcard) |
d62a17ae | 8094 | afi = AFI_MAX; |
8095 | } | |
8096 | ||
8097 | if (use_json && is_wildcard) | |
8098 | vty_out(vty, "}\n"); | |
8099 | else if (use_json && !json_output) | |
8100 | vty_out(vty, "{}\n"); | |
8101 | } | |
8102 | ||
8103 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
d7c0a89a | 8104 | safi_t safi, uint8_t use_json) |
d62a17ae | 8105 | { |
8106 | struct listnode *node, *nnode; | |
8107 | struct bgp *bgp; | |
8108 | json_object *json = NULL; | |
8109 | int is_first = 1; | |
8110 | ||
8111 | if (use_json) | |
8112 | vty_out(vty, "{\n"); | |
8113 | ||
8114 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
8115 | if (use_json) { | |
8116 | json = json_object_new_object(); | |
8117 | ||
8118 | if (!is_first) | |
8119 | vty_out(vty, ",\n"); | |
8120 | else | |
8121 | is_first = 0; | |
8122 | ||
8123 | vty_out(vty, "\"%s\":", | |
8124 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8125 | ? "Default" | |
8126 | : bgp->name); | |
8127 | } else { | |
8128 | vty_out(vty, "\nInstance %s:\n", | |
8129 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
8130 | ? "Default" | |
8131 | : bgp->name); | |
8132 | } | |
8133 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, json); | |
8134 | } | |
8135 | ||
8136 | if (use_json) | |
8137 | vty_out(vty, "}\n"); | |
8138 | } | |
8139 | ||
8140 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
d7c0a89a | 8141 | safi_t safi, uint8_t use_json) |
d62a17ae | 8142 | { |
8143 | struct bgp *bgp; | |
8144 | ||
8145 | if (name) { | |
8146 | if (strmatch(name, "all")) { | |
8147 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
8148 | use_json); | |
8149 | return CMD_SUCCESS; | |
8150 | } else { | |
8151 | bgp = bgp_lookup_by_name(name); | |
8152 | ||
8153 | if (!bgp) { | |
8154 | if (use_json) | |
8155 | vty_out(vty, "{}\n"); | |
8156 | else | |
8157 | vty_out(vty, | |
8158 | "%% No such BGP instance exist\n"); | |
8159 | return CMD_WARNING; | |
8160 | } | |
8161 | ||
8162 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, | |
8163 | NULL); | |
8164 | return CMD_SUCCESS; | |
8165 | } | |
8166 | } | |
8167 | ||
8168 | bgp = bgp_get_default(); | |
8169 | ||
8170 | if (bgp) | |
8171 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, NULL); | |
8172 | ||
8173 | return CMD_SUCCESS; | |
4fb25c53 DW |
8174 | } |
8175 | ||
716b2d8a | 8176 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 8177 | DEFUN (show_ip_bgp_summary, |
718e3744 | 8178 | show_ip_bgp_summary_cmd, |
dd6bd0f1 | 8179 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [json]", |
718e3744 | 8180 | SHOW_STR |
8181 | IP_STR | |
8182 | BGP_STR | |
8386ac43 | 8183 | BGP_INSTANCE_HELP_STR |
46f296b4 | 8184 | BGP_AFI_HELP_STR |
dd6bd0f1 | 8185 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 8186 | "Summary of BGP neighbor status\n" |
9973d184 | 8187 | JSON_STR) |
718e3744 | 8188 | { |
d62a17ae | 8189 | char *vrf = NULL; |
8190 | afi_t afi = AFI_MAX; | |
8191 | safi_t safi = SAFI_MAX; | |
8192 | ||
8193 | int idx = 0; | |
8194 | ||
8195 | /* show [ip] bgp */ | |
8196 | if (argv_find(argv, argc, "ip", &idx)) | |
8197 | afi = AFI_IP; | |
8198 | /* [<view|vrf> VIEWVRFNAME] */ | |
8199 | if (argv_find(argv, argc, "view", &idx) | |
8200 | || argv_find(argv, argc, "vrf", &idx)) | |
8201 | vrf = argv[++idx]->arg; | |
8202 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
8203 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
8204 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8205 | } | |
8206 | ||
8207 | int uj = use_json(argc, argv); | |
8208 | ||
8209 | return bgp_show_summary_vty(vty, vrf, afi, safi, uj); | |
8210 | } | |
8211 | ||
8212 | const char *afi_safi_print(afi_t afi, safi_t safi) | |
8213 | { | |
8214 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8215 | return "IPv4 Unicast"; | |
8216 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8217 | return "IPv4 Multicast"; | |
8218 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8219 | return "IPv4 Labeled Unicast"; | |
8220 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8221 | return "IPv4 VPN"; | |
8222 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8223 | return "IPv4 Encap"; | |
7c40bf39 | 8224 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8225 | return "IPv4 Flowspec"; | |
d62a17ae | 8226 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8227 | return "IPv6 Unicast"; | |
8228 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8229 | return "IPv6 Multicast"; | |
8230 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8231 | return "IPv6 Labeled Unicast"; | |
8232 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8233 | return "IPv6 VPN"; | |
8234 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8235 | return "IPv6 Encap"; | |
7c40bf39 | 8236 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8237 | return "IPv6 Flowspec"; | |
d62a17ae | 8238 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8239 | return "L2VPN EVPN"; | |
8240 | else | |
8241 | return "Unknown"; | |
538621f2 | 8242 | } |
8243 | ||
b9f77ec8 DS |
8244 | /* |
8245 | * Please note that we have intentionally camelCased | |
8246 | * the return strings here. So if you want | |
8247 | * to use this function, please ensure you | |
8248 | * are doing this within json output | |
8249 | */ | |
d62a17ae | 8250 | const char *afi_safi_json(afi_t afi, safi_t safi) |
8251 | { | |
8252 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8253 | return "ipv4Unicast"; | |
8254 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8255 | return "ipv4Multicast"; | |
8256 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8257 | return "ipv4LabeledUnicast"; | |
8258 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8259 | return "ipv4Vpn"; | |
8260 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8261 | return "ipv4Encap"; | |
7c40bf39 | 8262 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8263 | return "ipv4Flowspec"; | |
d62a17ae | 8264 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8265 | return "ipv6Unicast"; | |
8266 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8267 | return "ipv6Multicast"; | |
8268 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8269 | return "ipv6LabeledUnicast"; | |
8270 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8271 | return "ipv6Vpn"; | |
8272 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8273 | return "ipv6Encap"; | |
7c40bf39 | 8274 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8275 | return "ipv6Flowspec"; | |
d62a17ae | 8276 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8277 | return "l2VpnEvpn"; | |
8278 | else | |
8279 | return "Unknown"; | |
27162734 LB |
8280 | } |
8281 | ||
718e3744 | 8282 | /* Show BGP peer's information. */ |
d62a17ae | 8283 | enum show_type { show_all, show_peer }; |
8284 | ||
8285 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
8286 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
8287 | uint16_t adv_smcap, uint16_t adv_rmcap, |
8288 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
8289 | uint8_t use_json, json_object *json_pref) | |
d62a17ae | 8290 | { |
8291 | /* Send-Mode */ | |
8292 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8293 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
8294 | if (use_json) { | |
8295 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8296 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8297 | json_object_string_add(json_pref, "sendMode", | |
8298 | "advertisedAndReceived"); | |
8299 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8300 | json_object_string_add(json_pref, "sendMode", | |
8301 | "advertised"); | |
8302 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8303 | json_object_string_add(json_pref, "sendMode", | |
8304 | "received"); | |
8305 | } else { | |
8306 | vty_out(vty, " Send-mode: "); | |
8307 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8308 | vty_out(vty, "advertised"); | |
8309 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8310 | vty_out(vty, "%sreceived", | |
8311 | CHECK_FLAG(p->af_cap[afi][safi], | |
8312 | adv_smcap) | |
8313 | ? ", " | |
8314 | : ""); | |
8315 | vty_out(vty, "\n"); | |
8316 | } | |
8317 | } | |
8318 | ||
8319 | /* Receive-Mode */ | |
8320 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8321 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
8322 | if (use_json) { | |
8323 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8324 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8325 | json_object_string_add(json_pref, "recvMode", | |
8326 | "advertisedAndReceived"); | |
8327 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8328 | json_object_string_add(json_pref, "recvMode", | |
8329 | "advertised"); | |
8330 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8331 | json_object_string_add(json_pref, "recvMode", | |
8332 | "received"); | |
8333 | } else { | |
8334 | vty_out(vty, " Receive-mode: "); | |
8335 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8336 | vty_out(vty, "advertised"); | |
8337 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8338 | vty_out(vty, "%sreceived", | |
8339 | CHECK_FLAG(p->af_cap[afi][safi], | |
8340 | adv_rmcap) | |
8341 | ? ", " | |
8342 | : ""); | |
8343 | vty_out(vty, "\n"); | |
8344 | } | |
8345 | } | |
8346 | } | |
8347 | ||
8348 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, | |
d7c0a89a | 8349 | safi_t safi, uint8_t use_json, |
d62a17ae | 8350 | json_object *json_neigh) |
8351 | { | |
0291c246 MK |
8352 | struct bgp_filter *filter; |
8353 | struct peer_af *paf; | |
8354 | char orf_pfx_name[BUFSIZ]; | |
8355 | int orf_pfx_count; | |
8356 | json_object *json_af = NULL; | |
8357 | json_object *json_prefA = NULL; | |
8358 | json_object *json_prefB = NULL; | |
8359 | json_object *json_addr = NULL; | |
d62a17ae | 8360 | |
8361 | if (use_json) { | |
8362 | json_addr = json_object_new_object(); | |
8363 | json_af = json_object_new_object(); | |
8364 | filter = &p->filter[afi][safi]; | |
8365 | ||
8366 | if (peer_group_active(p)) | |
8367 | json_object_string_add(json_addr, "peerGroupMember", | |
8368 | p->group->name); | |
8369 | ||
8370 | paf = peer_af_find(p, afi, safi); | |
8371 | if (paf && PAF_SUBGRP(paf)) { | |
8372 | json_object_int_add(json_addr, "updateGroupId", | |
8373 | PAF_UPDGRP(paf)->id); | |
8374 | json_object_int_add(json_addr, "subGroupId", | |
8375 | PAF_SUBGRP(paf)->id); | |
8376 | json_object_int_add(json_addr, "packetQueueLength", | |
8377 | bpacket_queue_virtual_length(paf)); | |
8378 | } | |
8379 | ||
8380 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8381 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8382 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8383 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8384 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8385 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8386 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8387 | json_object_int_add(json_af, "orfType", | |
8388 | ORF_TYPE_PREFIX); | |
8389 | json_prefA = json_object_new_object(); | |
8390 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
8391 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
8392 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8393 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8394 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
8395 | use_json, json_prefA); | |
8396 | json_object_object_add(json_af, "orfPrefixList", | |
8397 | json_prefA); | |
8398 | } | |
8399 | ||
8400 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8401 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8402 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8403 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8404 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8405 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8406 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8407 | json_object_int_add(json_af, "orfOldType", | |
8408 | ORF_TYPE_PREFIX_OLD); | |
8409 | json_prefB = json_object_new_object(); | |
8410 | bgp_show_peer_afi_orf_cap( | |
8411 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8412 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8413 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8414 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
8415 | json_prefB); | |
8416 | json_object_object_add(json_af, "orfOldPrefixList", | |
8417 | json_prefB); | |
8418 | } | |
8419 | ||
8420 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8421 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8422 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8423 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8424 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8425 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8426 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8427 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8428 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8429 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8430 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8431 | json_object_object_add(json_addr, "afDependentCap", | |
8432 | json_af); | |
8433 | else | |
8434 | json_object_free(json_af); | |
8435 | ||
8436 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8437 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8438 | NULL, afi, orf_pfx_name, use_json); | |
8439 | ||
8440 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8441 | PEER_STATUS_ORF_PREFIX_SEND) | |
8442 | || orf_pfx_count) { | |
8443 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8444 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8445 | json_object_boolean_true_add(json_neigh, | |
8446 | "orfSent"); | |
8447 | if (orf_pfx_count) | |
8448 | json_object_int_add(json_addr, "orfRecvCounter", | |
8449 | orf_pfx_count); | |
8450 | } | |
8451 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8452 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8453 | json_object_string_add( | |
8454 | json_addr, "orfFirstUpdate", | |
8455 | "deferredUntilORFOrRouteRefreshRecvd"); | |
8456 | ||
8457 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8458 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8459 | json_object_boolean_true_add(json_addr, | |
8460 | "routeReflectorClient"); | |
8461 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8462 | PEER_FLAG_RSERVER_CLIENT)) | |
8463 | json_object_boolean_true_add(json_addr, | |
8464 | "routeServerClient"); | |
8465 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8466 | json_object_boolean_true_add(json_addr, | |
8467 | "inboundSoftConfigPermit"); | |
8468 | ||
8469 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8470 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8471 | json_object_boolean_true_add( | |
8472 | json_addr, | |
8473 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
8474 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8475 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8476 | json_object_boolean_true_add( | |
8477 | json_addr, | |
8478 | "privateAsNumsReplacedInUpdatesToNbr"); | |
8479 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8480 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8481 | json_object_boolean_true_add( | |
8482 | json_addr, | |
8483 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
8484 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8485 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8486 | json_object_boolean_true_add( | |
8487 | json_addr, | |
8488 | "privateAsNumsRemovedInUpdatesToNbr"); | |
8489 | ||
8490 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8491 | PEER_FLAG_ADDPATH_TX_ALL_PATHS)) | |
8492 | json_object_boolean_true_add(json_addr, | |
8493 | "addpathTxAllPaths"); | |
8494 | ||
8495 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8496 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
8497 | json_object_boolean_true_add(json_addr, | |
8498 | "addpathTxBestpathPerAS"); | |
8499 | ||
8500 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8501 | json_object_string_add(json_addr, | |
8502 | "overrideASNsInOutboundUpdates", | |
8503 | "ifAspathEqualRemoteAs"); | |
8504 | ||
8505 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8506 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8507 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8508 | json_object_boolean_true_add(json_addr, | |
8509 | "routerAlwaysNextHop"); | |
8510 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8511 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8512 | json_object_boolean_true_add( | |
8513 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
8514 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8515 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
8516 | json_object_boolean_true_add( | |
8517 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
8518 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
8519 | json_object_boolean_true_add( | |
8520 | json_addr, "unchangedMedPropogatedToNbr"); | |
8521 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
8522 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8523 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
8524 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8525 | PEER_FLAG_SEND_COMMUNITY) | |
8526 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8527 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8528 | json_object_string_add(json_addr, | |
8529 | "commAttriSentToNbr", | |
8530 | "extendedAndStandard"); | |
8531 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8532 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8533 | json_object_string_add(json_addr, | |
8534 | "commAttriSentToNbr", | |
8535 | "extended"); | |
8536 | else | |
8537 | json_object_string_add(json_addr, | |
8538 | "commAttriSentToNbr", | |
8539 | "standard"); | |
8540 | } | |
8541 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8542 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
8543 | if (p->default_rmap[afi][safi].name) | |
8544 | json_object_string_add( | |
8545 | json_addr, "defaultRouteMap", | |
8546 | p->default_rmap[afi][safi].name); | |
8547 | ||
8548 | if (paf && PAF_SUBGRP(paf) | |
8549 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
8550 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
8551 | json_object_boolean_true_add(json_addr, | |
8552 | "defaultSent"); | |
8553 | else | |
8554 | json_object_boolean_true_add(json_addr, | |
8555 | "defaultNotSent"); | |
8556 | } | |
8557 | ||
dff8f48d | 8558 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 8559 | if (is_evpn_enabled()) |
60466a63 QY |
8560 | json_object_boolean_true_add( |
8561 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
8562 | } |
8563 | ||
d62a17ae | 8564 | if (filter->plist[FILTER_IN].name |
8565 | || filter->dlist[FILTER_IN].name | |
8566 | || filter->aslist[FILTER_IN].name | |
8567 | || filter->map[RMAP_IN].name) | |
8568 | json_object_boolean_true_add(json_addr, | |
8569 | "inboundPathPolicyConfig"); | |
8570 | if (filter->plist[FILTER_OUT].name | |
8571 | || filter->dlist[FILTER_OUT].name | |
8572 | || filter->aslist[FILTER_OUT].name | |
8573 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
8574 | json_object_boolean_true_add( | |
8575 | json_addr, "outboundPathPolicyConfig"); | |
8576 | ||
8577 | /* prefix-list */ | |
8578 | if (filter->plist[FILTER_IN].name) | |
8579 | json_object_string_add(json_addr, | |
8580 | "incomingUpdatePrefixFilterList", | |
8581 | filter->plist[FILTER_IN].name); | |
8582 | if (filter->plist[FILTER_OUT].name) | |
8583 | json_object_string_add(json_addr, | |
8584 | "outgoingUpdatePrefixFilterList", | |
8585 | filter->plist[FILTER_OUT].name); | |
8586 | ||
8587 | /* distribute-list */ | |
8588 | if (filter->dlist[FILTER_IN].name) | |
8589 | json_object_string_add( | |
8590 | json_addr, "incomingUpdateNetworkFilterList", | |
8591 | filter->dlist[FILTER_IN].name); | |
8592 | if (filter->dlist[FILTER_OUT].name) | |
8593 | json_object_string_add( | |
8594 | json_addr, "outgoingUpdateNetworkFilterList", | |
8595 | filter->dlist[FILTER_OUT].name); | |
8596 | ||
8597 | /* filter-list. */ | |
8598 | if (filter->aslist[FILTER_IN].name) | |
8599 | json_object_string_add(json_addr, | |
8600 | "incomingUpdateAsPathFilterList", | |
8601 | filter->aslist[FILTER_IN].name); | |
8602 | if (filter->aslist[FILTER_OUT].name) | |
8603 | json_object_string_add(json_addr, | |
8604 | "outgoingUpdateAsPathFilterList", | |
8605 | filter->aslist[FILTER_OUT].name); | |
8606 | ||
8607 | /* route-map. */ | |
8608 | if (filter->map[RMAP_IN].name) | |
8609 | json_object_string_add( | |
8610 | json_addr, "routeMapForIncomingAdvertisements", | |
8611 | filter->map[RMAP_IN].name); | |
8612 | if (filter->map[RMAP_OUT].name) | |
8613 | json_object_string_add( | |
8614 | json_addr, "routeMapForOutgoingAdvertisements", | |
8615 | filter->map[RMAP_OUT].name); | |
8616 | ||
8617 | /* unsuppress-map */ | |
8618 | if (filter->usmap.name) | |
8619 | json_object_string_add(json_addr, | |
8620 | "selectiveUnsuppressRouteMap", | |
8621 | filter->usmap.name); | |
8622 | ||
8623 | /* Receive prefix count */ | |
8624 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
8625 | p->pcount[afi][safi]); | |
8626 | ||
8627 | /* Maximum prefix */ | |
8628 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
8629 | json_object_int_add(json_addr, "prefixAllowedMax", | |
8630 | p->pmax[afi][safi]); | |
8631 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8632 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
8633 | json_object_boolean_true_add( | |
8634 | json_addr, "prefixAllowedMaxWarning"); | |
8635 | json_object_int_add(json_addr, | |
8636 | "prefixAllowedWarningThresh", | |
8637 | p->pmax_threshold[afi][safi]); | |
8638 | if (p->pmax_restart[afi][safi]) | |
8639 | json_object_int_add( | |
8640 | json_addr, | |
8641 | "prefixAllowedRestartIntervalMsecs", | |
8642 | p->pmax_restart[afi][safi] * 60000); | |
8643 | } | |
8644 | json_object_object_add(json_neigh, afi_safi_print(afi, safi), | |
8645 | json_addr); | |
8646 | ||
8647 | } else { | |
8648 | filter = &p->filter[afi][safi]; | |
8649 | ||
8650 | vty_out(vty, " For address family: %s\n", | |
8651 | afi_safi_print(afi, safi)); | |
8652 | ||
8653 | if (peer_group_active(p)) | |
8654 | vty_out(vty, " %s peer-group member\n", | |
8655 | p->group->name); | |
8656 | ||
8657 | paf = peer_af_find(p, afi, safi); | |
8658 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
8659 | vty_out(vty, " Update group %" PRIu64 |
8660 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 8661 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
8662 | vty_out(vty, " Packet Queue length %d\n", | |
8663 | bpacket_queue_virtual_length(paf)); | |
8664 | } else { | |
8665 | vty_out(vty, " Not part of any update group\n"); | |
8666 | } | |
8667 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8668 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8669 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8670 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8671 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8672 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8673 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8674 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8675 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8676 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8677 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8678 | vty_out(vty, " AF-dependant capabilities:\n"); | |
8679 | ||
8680 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8681 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8682 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8683 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8684 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8685 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8686 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8687 | vty_out(vty, | |
8688 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8689 | ORF_TYPE_PREFIX); | |
8690 | bgp_show_peer_afi_orf_cap( | |
8691 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8692 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8693 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8694 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
8695 | } | |
8696 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8697 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8698 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8699 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8700 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8701 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8702 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8703 | vty_out(vty, | |
8704 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8705 | ORF_TYPE_PREFIX_OLD); | |
8706 | bgp_show_peer_afi_orf_cap( | |
8707 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8708 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8709 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8710 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
8711 | } | |
8712 | ||
8713 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8714 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8715 | NULL, afi, orf_pfx_name, use_json); | |
8716 | ||
8717 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8718 | PEER_STATUS_ORF_PREFIX_SEND) | |
8719 | || orf_pfx_count) { | |
8720 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
8721 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8722 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8723 | vty_out(vty, " sent;"); | |
8724 | if (orf_pfx_count) | |
8725 | vty_out(vty, " received (%d entries)", | |
8726 | orf_pfx_count); | |
8727 | vty_out(vty, "\n"); | |
8728 | } | |
8729 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8730 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8731 | vty_out(vty, | |
8732 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
8733 | ||
8734 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8735 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8736 | vty_out(vty, " Route-Reflector Client\n"); | |
8737 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8738 | PEER_FLAG_RSERVER_CLIENT)) | |
8739 | vty_out(vty, " Route-Server Client\n"); | |
8740 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8741 | vty_out(vty, | |
8742 | " Inbound soft reconfiguration allowed\n"); | |
8743 | ||
8744 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8745 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8746 | vty_out(vty, | |
8747 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
8748 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8749 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8750 | vty_out(vty, | |
8751 | " Private AS numbers replaced in updates to this neighbor\n"); | |
8752 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8753 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8754 | vty_out(vty, | |
8755 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
8756 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8757 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8758 | vty_out(vty, | |
8759 | " Private AS numbers removed in updates to this neighbor\n"); | |
8760 | ||
8761 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8762 | PEER_FLAG_ADDPATH_TX_ALL_PATHS)) | |
8763 | vty_out(vty, " Advertise all paths via addpath\n"); | |
8764 | ||
8765 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8766 | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) | |
8767 | vty_out(vty, | |
8768 | " Advertise bestpath per AS via addpath\n"); | |
8769 | ||
8770 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8771 | vty_out(vty, | |
8772 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
8773 | ||
8774 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8775 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8776 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8777 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
8778 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8779 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8780 | vty_out(vty, | |
8781 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
8782 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8783 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
8784 | vty_out(vty, | |
8785 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
8786 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
8787 | vty_out(vty, | |
8788 | " MED is propagated unchanged to this neighbor\n"); | |
8789 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
8790 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8791 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
8792 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8793 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
8794 | vty_out(vty, | |
8795 | " Community attribute sent to this neighbor"); | |
8796 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8797 | PEER_FLAG_SEND_COMMUNITY) | |
8798 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8799 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
8800 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8801 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
8802 | vty_out(vty, "(all)\n"); | |
8803 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8804 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
8805 | vty_out(vty, "(large)\n"); | |
8806 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8807 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8808 | vty_out(vty, "(extended)\n"); | |
8809 | else | |
8810 | vty_out(vty, "(standard)\n"); | |
8811 | } | |
8812 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8813 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
8814 | vty_out(vty, " Default information originate,"); | |
8815 | ||
8816 | if (p->default_rmap[afi][safi].name) | |
8817 | vty_out(vty, " default route-map %s%s,", | |
8818 | p->default_rmap[afi][safi].map ? "*" | |
8819 | : "", | |
8820 | p->default_rmap[afi][safi].name); | |
8821 | if (paf && PAF_SUBGRP(paf) | |
8822 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
8823 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
8824 | vty_out(vty, " default sent\n"); | |
8825 | else | |
8826 | vty_out(vty, " default not sent\n"); | |
8827 | } | |
8828 | ||
dff8f48d MK |
8829 | /* advertise-vni-all */ |
8830 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 8831 | if (is_evpn_enabled()) |
dff8f48d MK |
8832 | vty_out(vty, " advertise-all-vni\n"); |
8833 | } | |
8834 | ||
d62a17ae | 8835 | if (filter->plist[FILTER_IN].name |
8836 | || filter->dlist[FILTER_IN].name | |
8837 | || filter->aslist[FILTER_IN].name | |
8838 | || filter->map[RMAP_IN].name) | |
8839 | vty_out(vty, " Inbound path policy configured\n"); | |
8840 | if (filter->plist[FILTER_OUT].name | |
8841 | || filter->dlist[FILTER_OUT].name | |
8842 | || filter->aslist[FILTER_OUT].name | |
8843 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
8844 | vty_out(vty, " Outbound path policy configured\n"); | |
8845 | ||
8846 | /* prefix-list */ | |
8847 | if (filter->plist[FILTER_IN].name) | |
8848 | vty_out(vty, | |
8849 | " Incoming update prefix filter list is %s%s\n", | |
8850 | filter->plist[FILTER_IN].plist ? "*" : "", | |
8851 | filter->plist[FILTER_IN].name); | |
8852 | if (filter->plist[FILTER_OUT].name) | |
8853 | vty_out(vty, | |
8854 | " Outgoing update prefix filter list is %s%s\n", | |
8855 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
8856 | filter->plist[FILTER_OUT].name); | |
8857 | ||
8858 | /* distribute-list */ | |
8859 | if (filter->dlist[FILTER_IN].name) | |
8860 | vty_out(vty, | |
8861 | " Incoming update network filter list is %s%s\n", | |
8862 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
8863 | filter->dlist[FILTER_IN].name); | |
8864 | if (filter->dlist[FILTER_OUT].name) | |
8865 | vty_out(vty, | |
8866 | " Outgoing update network filter list is %s%s\n", | |
8867 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
8868 | filter->dlist[FILTER_OUT].name); | |
8869 | ||
8870 | /* filter-list. */ | |
8871 | if (filter->aslist[FILTER_IN].name) | |
8872 | vty_out(vty, | |
8873 | " Incoming update AS path filter list is %s%s\n", | |
8874 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
8875 | filter->aslist[FILTER_IN].name); | |
8876 | if (filter->aslist[FILTER_OUT].name) | |
8877 | vty_out(vty, | |
8878 | " Outgoing update AS path filter list is %s%s\n", | |
8879 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
8880 | filter->aslist[FILTER_OUT].name); | |
8881 | ||
8882 | /* route-map. */ | |
8883 | if (filter->map[RMAP_IN].name) | |
8884 | vty_out(vty, | |
8885 | " Route map for incoming advertisements is %s%s\n", | |
8886 | filter->map[RMAP_IN].map ? "*" : "", | |
8887 | filter->map[RMAP_IN].name); | |
8888 | if (filter->map[RMAP_OUT].name) | |
8889 | vty_out(vty, | |
8890 | " Route map for outgoing advertisements is %s%s\n", | |
8891 | filter->map[RMAP_OUT].map ? "*" : "", | |
8892 | filter->map[RMAP_OUT].name); | |
8893 | ||
8894 | /* unsuppress-map */ | |
8895 | if (filter->usmap.name) | |
8896 | vty_out(vty, | |
8897 | " Route map for selective unsuppress is %s%s\n", | |
8898 | filter->usmap.map ? "*" : "", | |
8899 | filter->usmap.name); | |
8900 | ||
8901 | /* Receive prefix count */ | |
8902 | vty_out(vty, " %ld accepted prefixes\n", p->pcount[afi][safi]); | |
8903 | ||
8904 | /* Maximum prefix */ | |
8905 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
8906 | vty_out(vty, " Maximum prefixes allowed %ld%s\n", | |
8907 | p->pmax[afi][safi], | |
8908 | CHECK_FLAG(p->af_flags[afi][safi], | |
8909 | PEER_FLAG_MAX_PREFIX_WARNING) | |
8910 | ? " (warning-only)" | |
8911 | : ""); | |
8912 | vty_out(vty, " Threshold for warning message %d%%", | |
8913 | p->pmax_threshold[afi][safi]); | |
8914 | if (p->pmax_restart[afi][safi]) | |
8915 | vty_out(vty, ", restart interval %d min", | |
8916 | p->pmax_restart[afi][safi]); | |
8917 | vty_out(vty, "\n"); | |
8918 | } | |
8919 | ||
8920 | vty_out(vty, "\n"); | |
8921 | } | |
8922 | } | |
8923 | ||
d7c0a89a | 8924 | static void bgp_show_peer(struct vty *vty, struct peer *p, uint8_t use_json, |
d62a17ae | 8925 | json_object *json) |
718e3744 | 8926 | { |
d62a17ae | 8927 | struct bgp *bgp; |
8928 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
8929 | char timebuf[BGP_UPTIME_LEN]; | |
8930 | char dn_flag[2]; | |
8931 | const char *subcode_str; | |
8932 | const char *code_str; | |
8933 | afi_t afi; | |
8934 | safi_t safi; | |
d7c0a89a QY |
8935 | uint16_t i; |
8936 | uint8_t *msg; | |
d62a17ae | 8937 | json_object *json_neigh = NULL; |
8938 | time_t epoch_tbuf; | |
718e3744 | 8939 | |
d62a17ae | 8940 | bgp = p->bgp; |
8941 | ||
8942 | if (use_json) | |
8943 | json_neigh = json_object_new_object(); | |
8944 | ||
8945 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8946 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
8947 | dn_flag[0] = '*'; | |
8948 | ||
8949 | if (!use_json) { | |
8950 | if (p->conf_if) /* Configured interface name. */ | |
8951 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
8952 | BGP_PEER_SU_UNSPEC(p) | |
8953 | ? "None" | |
8954 | : sockunion2str(&p->su, buf, | |
8955 | SU_ADDRSTRLEN)); | |
8956 | else /* Configured IP address. */ | |
8957 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
8958 | p->host); | |
8959 | } | |
8960 | ||
8961 | if (use_json) { | |
8962 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
8963 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
8964 | "none"); | |
8965 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
8966 | json_object_string_add( | |
8967 | json_neigh, "bgpNeighborAddr", | |
8968 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
8969 | ||
8970 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
8971 | ||
8972 | if (p->change_local_as) | |
8973 | json_object_int_add(json_neigh, "localAs", | |
8974 | p->change_local_as); | |
8975 | else | |
8976 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
8977 | ||
8978 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
8979 | json_object_boolean_true_add(json_neigh, | |
8980 | "localAsNoPrepend"); | |
8981 | ||
8982 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
8983 | json_object_boolean_true_add(json_neigh, | |
8984 | "localAsReplaceAs"); | |
8985 | } else { | |
8986 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
8987 | || (p->as_type == AS_INTERNAL)) | |
8988 | vty_out(vty, "remote AS %u, ", p->as); | |
8989 | else | |
8990 | vty_out(vty, "remote AS Unspecified, "); | |
8991 | vty_out(vty, "local AS %u%s%s, ", | |
8992 | p->change_local_as ? p->change_local_as : p->local_as, | |
8993 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
8994 | ? " no-prepend" | |
8995 | : "", | |
8996 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
8997 | ? " replace-as" | |
8998 | : ""); | |
8999 | } | |
9000 | /* peer type internal, external, confed-internal or confed-external */ | |
9001 | if (p->as == p->local_as) { | |
9002 | if (use_json) { | |
9003 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9004 | json_object_boolean_true_add( | |
9005 | json_neigh, "nbrConfedInternalLink"); | |
9006 | else | |
9007 | json_object_boolean_true_add(json_neigh, | |
9008 | "nbrInternalLink"); | |
9009 | } else { | |
9010 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9011 | vty_out(vty, "confed-internal link\n"); | |
9012 | else | |
9013 | vty_out(vty, "internal link\n"); | |
9014 | } | |
9015 | } else { | |
9016 | if (use_json) { | |
9017 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9018 | json_object_boolean_true_add( | |
9019 | json_neigh, "nbrConfedExternalLink"); | |
9020 | else | |
9021 | json_object_boolean_true_add(json_neigh, | |
9022 | "nbrExternalLink"); | |
9023 | } else { | |
9024 | if (bgp_confederation_peers_check(bgp, p->as)) | |
9025 | vty_out(vty, "confed-external link\n"); | |
9026 | else | |
9027 | vty_out(vty, "external link\n"); | |
9028 | } | |
9029 | } | |
9030 | ||
9031 | /* Description. */ | |
9032 | if (p->desc) { | |
9033 | if (use_json) | |
9034 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
9035 | else | |
9036 | vty_out(vty, " Description: %s\n", p->desc); | |
9037 | } | |
9038 | ||
9039 | if (p->hostname) { | |
9040 | if (use_json) { | |
9041 | if (p->hostname) | |
9042 | json_object_string_add(json_neigh, "hostname", | |
9043 | p->hostname); | |
9044 | ||
9045 | if (p->domainname) | |
9046 | json_object_string_add(json_neigh, "domainname", | |
9047 | p->domainname); | |
9048 | } else { | |
9049 | if (p->domainname && (p->domainname[0] != '\0')) | |
9050 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
9051 | p->domainname); | |
9052 | else | |
9053 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
9054 | } | |
9055 | } | |
9056 | ||
9057 | /* Peer-group */ | |
9058 | if (p->group) { | |
9059 | if (use_json) { | |
9060 | json_object_string_add(json_neigh, "peerGroup", | |
9061 | p->group->name); | |
9062 | ||
9063 | if (dn_flag[0]) { | |
9064 | struct prefix prefix, *range = NULL; | |
9065 | ||
9066 | sockunion2hostprefix(&(p->su), &prefix); | |
9067 | range = peer_group_lookup_dynamic_neighbor_range( | |
9068 | p->group, &prefix); | |
9069 | ||
9070 | if (range) { | |
9071 | prefix2str(range, buf1, sizeof(buf1)); | |
9072 | json_object_string_add( | |
9073 | json_neigh, | |
9074 | "peerSubnetRangeGroup", buf1); | |
9075 | } | |
9076 | } | |
9077 | } else { | |
9078 | vty_out(vty, | |
9079 | " Member of peer-group %s for session parameters\n", | |
9080 | p->group->name); | |
9081 | ||
9082 | if (dn_flag[0]) { | |
9083 | struct prefix prefix, *range = NULL; | |
9084 | ||
9085 | sockunion2hostprefix(&(p->su), &prefix); | |
9086 | range = peer_group_lookup_dynamic_neighbor_range( | |
9087 | p->group, &prefix); | |
9088 | ||
9089 | if (range) { | |
9090 | prefix2str(range, buf1, sizeof(buf1)); | |
9091 | vty_out(vty, | |
9092 | " Belongs to the subnet range group: %s\n", | |
9093 | buf1); | |
9094 | } | |
9095 | } | |
9096 | } | |
9097 | } | |
9098 | ||
9099 | if (use_json) { | |
9100 | /* Administrative shutdown. */ | |
9101 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9102 | json_object_boolean_true_add(json_neigh, | |
9103 | "adminShutDown"); | |
9104 | ||
9105 | /* BGP Version. */ | |
9106 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
9107 | json_object_string_add( | |
9108 | json_neigh, "remoteRouterId", | |
9109 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
9110 | ||
9111 | /* Confederation */ | |
9112 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9113 | && bgp_confederation_peers_check(bgp, p->as)) | |
9114 | json_object_boolean_true_add(json_neigh, | |
9115 | "nbrCommonAdmin"); | |
9116 | ||
9117 | /* Status. */ | |
9118 | json_object_string_add( | |
9119 | json_neigh, "bgpState", | |
9120 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9121 | ||
9122 | if (p->status == Established) { | |
9123 | time_t uptime; | |
d62a17ae | 9124 | |
9125 | uptime = bgp_clock(); | |
9126 | uptime -= p->uptime; | |
d62a17ae | 9127 | epoch_tbuf = time(NULL) - uptime; |
9128 | ||
e24be241 | 9129 | #if defined(VERSION_TYPE_DEV) && CONFDATE > 20200101 |
a4d82a8a PZ |
9130 | CPP_NOTICE( |
9131 | "bgpTimerUp should be deprecated and can be removed now"); | |
d3c7efed DS |
9132 | #endif |
9133 | /* | |
9134 | * bgpTimerUp was miliseconds that was accurate | |
9135 | * up to 1 day, then the value returned | |
9136 | * became garbage. So in order to provide | |
9137 | * some level of backwards compatability, | |
9138 | * we still provde the data, but now | |
9139 | * we are returning the correct value | |
9140 | * and also adding a new bgpTimerUpMsec | |
9141 | * which will allow us to deprecate | |
9142 | * this eventually | |
9143 | */ | |
d62a17ae | 9144 | json_object_int_add(json_neigh, "bgpTimerUp", |
e0330274 | 9145 | uptime * 1000); |
d3c7efed DS |
9146 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
9147 | uptime * 1000); | |
d62a17ae | 9148 | json_object_string_add(json_neigh, "bgpTimerUpString", |
9149 | peer_uptime(p->uptime, timebuf, | |
9150 | BGP_UPTIME_LEN, 0, | |
9151 | NULL)); | |
9152 | json_object_int_add(json_neigh, | |
9153 | "bgpTimerUpEstablishedEpoch", | |
9154 | epoch_tbuf); | |
9155 | } | |
9156 | ||
9157 | else if (p->status == Active) { | |
9158 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9159 | json_object_string_add(json_neigh, "bgpStateIs", | |
9160 | "passive"); | |
9161 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9162 | json_object_string_add(json_neigh, "bgpStateIs", | |
9163 | "passiveNSF"); | |
9164 | } | |
9165 | ||
9166 | /* read timer */ | |
9167 | time_t uptime; | |
9168 | struct tm *tm; | |
9169 | ||
9170 | uptime = bgp_clock(); | |
9171 | uptime -= p->readtime; | |
9172 | tm = gmtime(&uptime); | |
9173 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
9174 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9175 | + (tm->tm_hour * 3600000)); | |
9176 | ||
9177 | uptime = bgp_clock(); | |
9178 | uptime -= p->last_write; | |
9179 | tm = gmtime(&uptime); | |
9180 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
9181 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9182 | + (tm->tm_hour * 3600000)); | |
9183 | ||
9184 | uptime = bgp_clock(); | |
9185 | uptime -= p->update_time; | |
9186 | tm = gmtime(&uptime); | |
9187 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
9188 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9189 | + (tm->tm_hour * 3600000)); | |
9190 | ||
9191 | /* Configured timer values. */ | |
9192 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
9193 | p->v_holdtime * 1000); | |
9194 | json_object_int_add(json_neigh, | |
9195 | "bgpTimerKeepAliveIntervalMsecs", | |
9196 | p->v_keepalive * 1000); | |
b90a8e13 | 9197 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9198 | json_object_int_add(json_neigh, |
9199 | "bgpTimerConfiguredHoldTimeMsecs", | |
9200 | p->holdtime * 1000); | |
9201 | json_object_int_add( | |
9202 | json_neigh, | |
9203 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9204 | p->keepalive * 1000); | |
d25e4efc | 9205 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9206 | || (bgp->default_keepalive |
9207 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9208 | json_object_int_add(json_neigh, |
9209 | "bgpTimerConfiguredHoldTimeMsecs", | |
9210 | bgp->default_holdtime); | |
9211 | json_object_int_add( | |
9212 | json_neigh, | |
9213 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9214 | bgp->default_keepalive); | |
d62a17ae | 9215 | } |
9216 | } else { | |
9217 | /* Administrative shutdown. */ | |
9218 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9219 | vty_out(vty, " Administratively shut down\n"); | |
9220 | ||
9221 | /* BGP Version. */ | |
9222 | vty_out(vty, " BGP version 4"); | |
9223 | vty_out(vty, ", remote router ID %s\n", | |
9224 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
9225 | ||
9226 | /* Confederation */ | |
9227 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9228 | && bgp_confederation_peers_check(bgp, p->as)) | |
9229 | vty_out(vty, | |
9230 | " Neighbor under common administration\n"); | |
9231 | ||
9232 | /* Status. */ | |
9233 | vty_out(vty, " BGP state = %s", | |
9234 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9235 | ||
9236 | if (p->status == Established) | |
9237 | vty_out(vty, ", up for %8s", | |
9238 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
9239 | 0, NULL)); | |
9240 | ||
9241 | else if (p->status == Active) { | |
9242 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9243 | vty_out(vty, " (passive)"); | |
9244 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9245 | vty_out(vty, " (NSF passive)"); | |
9246 | } | |
9247 | vty_out(vty, "\n"); | |
9248 | ||
9249 | /* read timer */ | |
9250 | vty_out(vty, " Last read %s", | |
9251 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
9252 | NULL)); | |
9253 | vty_out(vty, ", Last write %s\n", | |
9254 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
9255 | NULL)); | |
9256 | ||
9257 | /* Configured timer values. */ | |
9258 | vty_out(vty, | |
9259 | " Hold time is %d, keepalive interval is %d seconds\n", | |
9260 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 9261 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9262 | vty_out(vty, " Configured hold time is %d", |
9263 | p->holdtime); | |
9264 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9265 | p->keepalive); | |
d25e4efc | 9266 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9267 | || (bgp->default_keepalive |
9268 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9269 | vty_out(vty, " Configured hold time is %d", |
9270 | bgp->default_holdtime); | |
9271 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9272 | bgp->default_keepalive); | |
d62a17ae | 9273 | } |
9274 | } | |
9275 | /* Capability. */ | |
9276 | if (p->status == Established) { | |
9277 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
9278 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
9279 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
9280 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
9281 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
9282 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
9283 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
9284 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
9285 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
9286 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
9287 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
9288 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 9289 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
9290 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 9291 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
9292 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 9293 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
9294 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 9295 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
9296 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
9297 | if (use_json) { | |
9298 | json_object *json_cap = NULL; | |
9299 | ||
9300 | json_cap = json_object_new_object(); | |
9301 | ||
9302 | /* AS4 */ | |
9303 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9304 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9305 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
9306 | && CHECK_FLAG(p->cap, | |
9307 | PEER_CAP_AS4_RCV)) | |
9308 | json_object_string_add( | |
9309 | json_cap, "4byteAs", | |
9310 | "advertisedAndReceived"); | |
9311 | else if (CHECK_FLAG(p->cap, | |
9312 | PEER_CAP_AS4_ADV)) | |
9313 | json_object_string_add( | |
9314 | json_cap, "4byteAs", | |
9315 | "advertised"); | |
9316 | else if (CHECK_FLAG(p->cap, | |
9317 | PEER_CAP_AS4_RCV)) | |
9318 | json_object_string_add( | |
9319 | json_cap, "4byteAs", | |
9320 | "received"); | |
9321 | } | |
9322 | ||
9323 | /* AddPath */ | |
9324 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9325 | || CHECK_FLAG(p->cap, | |
9326 | PEER_CAP_ADDPATH_ADV)) { | |
9327 | json_object *json_add = NULL; | |
9328 | const char *print_store; | |
9329 | ||
9330 | json_add = json_object_new_object(); | |
9331 | ||
05c7a1cc QY |
9332 | FOREACH_AFI_SAFI (afi, safi) { |
9333 | json_object *json_sub = NULL; | |
9334 | json_sub = | |
9335 | json_object_new_object(); | |
9336 | print_store = afi_safi_print( | |
9337 | afi, safi); | |
d62a17ae | 9338 | |
05c7a1cc QY |
9339 | if (CHECK_FLAG( |
9340 | p->af_cap[afi] | |
9341 | [safi], | |
9342 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9343 | || CHECK_FLAG( | |
9344 | p->af_cap[afi] | |
9345 | [safi], | |
9346 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 9347 | if (CHECK_FLAG( |
9348 | p->af_cap | |
9349 | [afi] | |
9350 | [safi], | |
9351 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 9352 | && CHECK_FLAG( |
d62a17ae | 9353 | p->af_cap |
9354 | [afi] | |
9355 | [safi], | |
05c7a1cc QY |
9356 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
9357 | json_object_boolean_true_add( | |
9358 | json_sub, | |
9359 | "txAdvertisedAndReceived"); | |
9360 | else if ( | |
9361 | CHECK_FLAG( | |
9362 | p->af_cap | |
9363 | [afi] | |
9364 | [safi], | |
9365 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
9366 | json_object_boolean_true_add( | |
9367 | json_sub, | |
9368 | "txAdvertised"); | |
9369 | else if ( | |
9370 | CHECK_FLAG( | |
9371 | p->af_cap | |
9372 | [afi] | |
9373 | [safi], | |
9374 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
9375 | json_object_boolean_true_add( | |
9376 | json_sub, | |
9377 | "txReceived"); | |
9378 | } | |
d62a17ae | 9379 | |
05c7a1cc QY |
9380 | if (CHECK_FLAG( |
9381 | p->af_cap[afi] | |
9382 | [safi], | |
9383 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9384 | || CHECK_FLAG( | |
9385 | p->af_cap[afi] | |
9386 | [safi], | |
9387 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 9388 | if (CHECK_FLAG( |
9389 | p->af_cap | |
9390 | [afi] | |
9391 | [safi], | |
9392 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 9393 | && CHECK_FLAG( |
d62a17ae | 9394 | p->af_cap |
9395 | [afi] | |
9396 | [safi], | |
9397 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
9398 | json_object_boolean_true_add( |
9399 | json_sub, | |
9400 | "rxAdvertisedAndReceived"); | |
9401 | else if ( | |
9402 | CHECK_FLAG( | |
9403 | p->af_cap | |
9404 | [afi] | |
9405 | [safi], | |
9406 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
9407 | json_object_boolean_true_add( | |
9408 | json_sub, | |
9409 | "rxAdvertised"); | |
9410 | else if ( | |
9411 | CHECK_FLAG( | |
9412 | p->af_cap | |
9413 | [afi] | |
9414 | [safi], | |
9415 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9416 | json_object_boolean_true_add( | |
9417 | json_sub, | |
9418 | "rxReceived"); | |
d62a17ae | 9419 | } |
9420 | ||
05c7a1cc QY |
9421 | if (CHECK_FLAG( |
9422 | p->af_cap[afi] | |
9423 | [safi], | |
9424 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9425 | || CHECK_FLAG( | |
9426 | p->af_cap[afi] | |
9427 | [safi], | |
9428 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
9429 | || CHECK_FLAG( | |
9430 | p->af_cap[afi] | |
9431 | [safi], | |
9432 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9433 | || CHECK_FLAG( | |
9434 | p->af_cap[afi] | |
9435 | [safi], | |
9436 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9437 | json_object_object_add( | |
9438 | json_add, | |
9439 | print_store, | |
9440 | json_sub); | |
9441 | else | |
9442 | json_object_free( | |
9443 | json_sub); | |
9444 | } | |
9445 | ||
d62a17ae | 9446 | json_object_object_add( |
9447 | json_cap, "addPath", json_add); | |
9448 | } | |
9449 | ||
9450 | /* Dynamic */ | |
9451 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
9452 | || CHECK_FLAG(p->cap, | |
9453 | PEER_CAP_DYNAMIC_ADV)) { | |
9454 | if (CHECK_FLAG(p->cap, | |
9455 | PEER_CAP_DYNAMIC_ADV) | |
9456 | && CHECK_FLAG(p->cap, | |
9457 | PEER_CAP_DYNAMIC_RCV)) | |
9458 | json_object_string_add( | |
9459 | json_cap, "dynamic", | |
9460 | "advertisedAndReceived"); | |
9461 | else if (CHECK_FLAG( | |
9462 | p->cap, | |
9463 | PEER_CAP_DYNAMIC_ADV)) | |
9464 | json_object_string_add( | |
9465 | json_cap, "dynamic", | |
9466 | "advertised"); | |
9467 | else if (CHECK_FLAG( | |
9468 | p->cap, | |
9469 | PEER_CAP_DYNAMIC_RCV)) | |
9470 | json_object_string_add( | |
9471 | json_cap, "dynamic", | |
9472 | "received"); | |
9473 | } | |
9474 | ||
9475 | /* Extended nexthop */ | |
9476 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
9477 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
9478 | json_object *json_nxt = NULL; | |
9479 | const char *print_store; | |
9480 | ||
9481 | ||
9482 | if (CHECK_FLAG(p->cap, | |
9483 | PEER_CAP_ENHE_ADV) | |
9484 | && CHECK_FLAG(p->cap, | |
9485 | PEER_CAP_ENHE_RCV)) | |
9486 | json_object_string_add( | |
9487 | json_cap, | |
9488 | "extendedNexthop", | |
9489 | "advertisedAndReceived"); | |
9490 | else if (CHECK_FLAG(p->cap, | |
9491 | PEER_CAP_ENHE_ADV)) | |
9492 | json_object_string_add( | |
9493 | json_cap, | |
9494 | "extendedNexthop", | |
9495 | "advertised"); | |
9496 | else if (CHECK_FLAG(p->cap, | |
9497 | PEER_CAP_ENHE_RCV)) | |
9498 | json_object_string_add( | |
9499 | json_cap, | |
9500 | "extendedNexthop", | |
9501 | "received"); | |
9502 | ||
9503 | if (CHECK_FLAG(p->cap, | |
9504 | PEER_CAP_ENHE_RCV)) { | |
9505 | json_nxt = | |
9506 | json_object_new_object(); | |
9507 | ||
9508 | for (safi = SAFI_UNICAST; | |
9509 | safi < SAFI_MAX; safi++) { | |
9510 | if (CHECK_FLAG( | |
9511 | p->af_cap | |
9512 | [AFI_IP] | |
9513 | [safi], | |
9514 | PEER_CAP_ENHE_AF_RCV)) { | |
9515 | print_store = afi_safi_print( | |
9516 | AFI_IP, | |
9517 | safi); | |
9518 | json_object_string_add( | |
9519 | json_nxt, | |
9520 | print_store, | |
9521 | "recieved"); | |
9522 | } | |
9523 | } | |
9524 | json_object_object_add( | |
9525 | json_cap, | |
9526 | "extendedNexthopFamililesByPeer", | |
9527 | json_nxt); | |
9528 | } | |
9529 | } | |
9530 | ||
9531 | /* Route Refresh */ | |
9532 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
9533 | || CHECK_FLAG(p->cap, | |
9534 | PEER_CAP_REFRESH_NEW_RCV) | |
9535 | || CHECK_FLAG(p->cap, | |
9536 | PEER_CAP_REFRESH_OLD_RCV)) { | |
9537 | if (CHECK_FLAG(p->cap, | |
9538 | PEER_CAP_REFRESH_ADV) | |
9539 | && (CHECK_FLAG( | |
9540 | p->cap, | |
9541 | PEER_CAP_REFRESH_NEW_RCV) | |
9542 | || CHECK_FLAG( | |
9543 | p->cap, | |
9544 | PEER_CAP_REFRESH_OLD_RCV))) { | |
9545 | if (CHECK_FLAG( | |
9546 | p->cap, | |
9547 | PEER_CAP_REFRESH_OLD_RCV) | |
9548 | && CHECK_FLAG( | |
9549 | p->cap, | |
9550 | PEER_CAP_REFRESH_NEW_RCV)) | |
9551 | json_object_string_add( | |
9552 | json_cap, | |
9553 | "routeRefresh", | |
9554 | "advertisedAndReceivedOldNew"); | |
9555 | else { | |
9556 | if (CHECK_FLAG( | |
9557 | p->cap, | |
9558 | PEER_CAP_REFRESH_OLD_RCV)) | |
9559 | json_object_string_add( | |
9560 | json_cap, | |
9561 | "routeRefresh", | |
9562 | "advertisedAndReceivedOld"); | |
9563 | else | |
9564 | json_object_string_add( | |
9565 | json_cap, | |
9566 | "routeRefresh", | |
9567 | "advertisedAndReceivedNew"); | |
9568 | } | |
9569 | } else if ( | |
9570 | CHECK_FLAG( | |
9571 | p->cap, | |
9572 | PEER_CAP_REFRESH_ADV)) | |
9573 | json_object_string_add( | |
9574 | json_cap, | |
9575 | "routeRefresh", | |
9576 | "advertised"); | |
9577 | else if ( | |
9578 | CHECK_FLAG( | |
9579 | p->cap, | |
9580 | PEER_CAP_REFRESH_NEW_RCV) | |
9581 | || CHECK_FLAG( | |
9582 | p->cap, | |
9583 | PEER_CAP_REFRESH_OLD_RCV)) | |
9584 | json_object_string_add( | |
9585 | json_cap, | |
9586 | "routeRefresh", | |
9587 | "received"); | |
9588 | } | |
9589 | ||
9590 | /* Multiprotocol Extensions */ | |
9591 | json_object *json_multi = NULL; | |
9592 | json_multi = json_object_new_object(); | |
9593 | ||
05c7a1cc QY |
9594 | FOREACH_AFI_SAFI (afi, safi) { |
9595 | if (p->afc_adv[afi][safi] | |
9596 | || p->afc_recv[afi][safi]) { | |
9597 | json_object *json_exten = NULL; | |
9598 | json_exten = | |
9599 | json_object_new_object(); | |
9600 | ||
d62a17ae | 9601 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
9602 | && p->afc_recv[afi][safi]) |
9603 | json_object_boolean_true_add( | |
9604 | json_exten, | |
9605 | "advertisedAndReceived"); | |
9606 | else if (p->afc_adv[afi][safi]) | |
9607 | json_object_boolean_true_add( | |
9608 | json_exten, | |
9609 | "advertised"); | |
9610 | else if (p->afc_recv[afi][safi]) | |
9611 | json_object_boolean_true_add( | |
9612 | json_exten, | |
9613 | "received"); | |
d62a17ae | 9614 | |
05c7a1cc QY |
9615 | json_object_object_add( |
9616 | json_multi, | |
9617 | afi_safi_print(afi, | |
9618 | safi), | |
9619 | json_exten); | |
d62a17ae | 9620 | } |
9621 | } | |
9622 | json_object_object_add( | |
9623 | json_cap, "multiprotocolExtensions", | |
9624 | json_multi); | |
9625 | ||
d77114b7 | 9626 | /* Hostname capabilities */ |
60466a63 | 9627 | json_object *json_hname = NULL; |
d77114b7 MK |
9628 | |
9629 | json_hname = json_object_new_object(); | |
9630 | ||
9631 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
9632 | json_object_string_add( | |
60466a63 QY |
9633 | json_hname, "advHostName", |
9634 | bgp->peer_self->hostname | |
9635 | ? bgp->peer_self | |
9636 | ->hostname | |
d77114b7 MK |
9637 | : "n/a"); |
9638 | json_object_string_add( | |
60466a63 QY |
9639 | json_hname, "advDomainName", |
9640 | bgp->peer_self->domainname | |
9641 | ? bgp->peer_self | |
9642 | ->domainname | |
d77114b7 MK |
9643 | : "n/a"); |
9644 | } | |
9645 | ||
9646 | ||
9647 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
9648 | json_object_string_add( | |
60466a63 QY |
9649 | json_hname, "rcvHostName", |
9650 | p->hostname ? p->hostname | |
9651 | : "n/a"); | |
d77114b7 | 9652 | json_object_string_add( |
60466a63 QY |
9653 | json_hname, "rcvDomainName", |
9654 | p->domainname ? p->domainname | |
9655 | : "n/a"); | |
d77114b7 MK |
9656 | } |
9657 | ||
60466a63 | 9658 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
9659 | json_hname); |
9660 | ||
d62a17ae | 9661 | /* Gracefull Restart */ |
9662 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
9663 | || CHECK_FLAG(p->cap, | |
9664 | PEER_CAP_RESTART_ADV)) { | |
9665 | if (CHECK_FLAG(p->cap, | |
9666 | PEER_CAP_RESTART_ADV) | |
9667 | && CHECK_FLAG(p->cap, | |
9668 | PEER_CAP_RESTART_RCV)) | |
9669 | json_object_string_add( | |
9670 | json_cap, | |
9671 | "gracefulRestart", | |
9672 | "advertisedAndReceived"); | |
9673 | else if (CHECK_FLAG( | |
9674 | p->cap, | |
9675 | PEER_CAP_RESTART_ADV)) | |
9676 | json_object_string_add( | |
9677 | json_cap, | |
9678 | "gracefulRestartCapability", | |
9679 | "advertised"); | |
9680 | else if (CHECK_FLAG( | |
9681 | p->cap, | |
9682 | PEER_CAP_RESTART_RCV)) | |
9683 | json_object_string_add( | |
9684 | json_cap, | |
9685 | "gracefulRestartCapability", | |
9686 | "received"); | |
9687 | ||
9688 | if (CHECK_FLAG(p->cap, | |
9689 | PEER_CAP_RESTART_RCV)) { | |
9690 | int restart_af_count = 0; | |
9691 | json_object *json_restart = | |
9692 | NULL; | |
9693 | json_restart = | |
9694 | json_object_new_object(); | |
9695 | ||
9696 | json_object_int_add( | |
9697 | json_cap, | |
9698 | "gracefulRestartRemoteTimerMsecs", | |
9699 | p->v_gr_restart * 1000); | |
9700 | ||
05c7a1cc QY |
9701 | FOREACH_AFI_SAFI (afi, safi) { |
9702 | if (CHECK_FLAG( | |
9703 | p->af_cap | |
9704 | [afi] | |
9705 | [safi], | |
9706 | PEER_CAP_RESTART_AF_RCV)) { | |
9707 | json_object * | |
9708 | json_sub = | |
9709 | NULL; | |
9710 | json_sub = | |
9711 | json_object_new_object(); | |
9712 | ||
d62a17ae | 9713 | if (CHECK_FLAG( |
9714 | p->af_cap | |
9715 | [afi] | |
9716 | [safi], | |
05c7a1cc QY |
9717 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
9718 | json_object_boolean_true_add( | |
9719 | json_sub, | |
9720 | "preserved"); | |
9721 | restart_af_count++; | |
9722 | json_object_object_add( | |
9723 | json_restart, | |
9724 | afi_safi_print( | |
9725 | afi, | |
9726 | safi), | |
9727 | json_sub); | |
d62a17ae | 9728 | } |
9729 | } | |
9730 | if (!restart_af_count) { | |
9731 | json_object_string_add( | |
9732 | json_cap, | |
9733 | "addressFamiliesByPeer", | |
9734 | "none"); | |
9735 | json_object_free( | |
9736 | json_restart); | |
9737 | } else | |
9738 | json_object_object_add( | |
9739 | json_cap, | |
9740 | "addressFamiliesByPeer", | |
9741 | json_restart); | |
9742 | } | |
9743 | } | |
9744 | json_object_object_add(json_neigh, | |
9745 | "neighborCapabilities", | |
9746 | json_cap); | |
9747 | } else { | |
9748 | vty_out(vty, " Neighbor capabilities:\n"); | |
9749 | ||
9750 | /* AS4 */ | |
9751 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9752 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9753 | vty_out(vty, " 4 Byte AS:"); | |
9754 | if (CHECK_FLAG(p->cap, | |
9755 | PEER_CAP_AS4_ADV)) | |
9756 | vty_out(vty, " advertised"); | |
9757 | if (CHECK_FLAG(p->cap, | |
9758 | PEER_CAP_AS4_RCV)) | |
9759 | vty_out(vty, " %sreceived", | |
9760 | CHECK_FLAG( | |
9761 | p->cap, | |
9762 | PEER_CAP_AS4_ADV) | |
9763 | ? "and " | |
9764 | : ""); | |
9765 | vty_out(vty, "\n"); | |
9766 | } | |
9767 | ||
9768 | /* AddPath */ | |
9769 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9770 | || CHECK_FLAG(p->cap, | |
9771 | PEER_CAP_ADDPATH_ADV)) { | |
9772 | vty_out(vty, " AddPath:\n"); | |
9773 | ||
05c7a1cc QY |
9774 | FOREACH_AFI_SAFI (afi, safi) { |
9775 | if (CHECK_FLAG( | |
9776 | p->af_cap[afi] | |
9777 | [safi], | |
9778 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9779 | || CHECK_FLAG( | |
9780 | p->af_cap[afi] | |
9781 | [safi], | |
9782 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
9783 | vty_out(vty, | |
9784 | " %s: TX ", | |
9785 | afi_safi_print( | |
9786 | afi, | |
9787 | safi)); | |
9788 | ||
d62a17ae | 9789 | if (CHECK_FLAG( |
9790 | p->af_cap | |
9791 | [afi] | |
9792 | [safi], | |
05c7a1cc | 9793 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 9794 | vty_out(vty, |
05c7a1cc | 9795 | "advertised %s", |
d62a17ae | 9796 | afi_safi_print( |
9797 | afi, | |
9798 | safi)); | |
9799 | ||
05c7a1cc QY |
9800 | if (CHECK_FLAG( |
9801 | p->af_cap | |
9802 | [afi] | |
9803 | [safi], | |
9804 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
9805 | vty_out(vty, | |
9806 | "%sreceived", | |
9807 | CHECK_FLAG( | |
9808 | p->af_cap | |
9809 | [afi] | |
9810 | [safi], | |
9811 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9812 | ? " and " | |
9813 | : ""); | |
d62a17ae | 9814 | |
05c7a1cc QY |
9815 | vty_out(vty, "\n"); |
9816 | } | |
d62a17ae | 9817 | |
05c7a1cc QY |
9818 | if (CHECK_FLAG( |
9819 | p->af_cap[afi] | |
9820 | [safi], | |
9821 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9822 | || CHECK_FLAG( | |
9823 | p->af_cap[afi] | |
9824 | [safi], | |
9825 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
9826 | vty_out(vty, | |
9827 | " %s: RX ", | |
9828 | afi_safi_print( | |
9829 | afi, | |
9830 | safi)); | |
d62a17ae | 9831 | |
9832 | if (CHECK_FLAG( | |
9833 | p->af_cap | |
9834 | [afi] | |
9835 | [safi], | |
05c7a1cc | 9836 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 9837 | vty_out(vty, |
05c7a1cc | 9838 | "advertised %s", |
d62a17ae | 9839 | afi_safi_print( |
9840 | afi, | |
9841 | safi)); | |
9842 | ||
05c7a1cc QY |
9843 | if (CHECK_FLAG( |
9844 | p->af_cap | |
9845 | [afi] | |
9846 | [safi], | |
9847 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 9848 | vty_out(vty, |
05c7a1cc QY |
9849 | "%sreceived", |
9850 | CHECK_FLAG( | |
9851 | p->af_cap | |
9852 | [afi] | |
9853 | [safi], | |
9854 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9855 | ? " and " | |
9856 | : ""); | |
9857 | ||
9858 | vty_out(vty, "\n"); | |
d62a17ae | 9859 | } |
05c7a1cc | 9860 | } |
d62a17ae | 9861 | } |
9862 | ||
9863 | /* Dynamic */ | |
9864 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
9865 | || CHECK_FLAG(p->cap, | |
9866 | PEER_CAP_DYNAMIC_ADV)) { | |
9867 | vty_out(vty, " Dynamic:"); | |
9868 | if (CHECK_FLAG(p->cap, | |
9869 | PEER_CAP_DYNAMIC_ADV)) | |
9870 | vty_out(vty, " advertised"); | |
9871 | if (CHECK_FLAG(p->cap, | |
9872 | PEER_CAP_DYNAMIC_RCV)) | |
9873 | vty_out(vty, " %sreceived", | |
9874 | CHECK_FLAG( | |
9875 | p->cap, | |
9876 | PEER_CAP_DYNAMIC_ADV) | |
9877 | ? "and " | |
9878 | : ""); | |
9879 | vty_out(vty, "\n"); | |
9880 | } | |
9881 | ||
9882 | /* Extended nexthop */ | |
9883 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
9884 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
9885 | vty_out(vty, " Extended nexthop:"); | |
9886 | if (CHECK_FLAG(p->cap, | |
9887 | PEER_CAP_ENHE_ADV)) | |
9888 | vty_out(vty, " advertised"); | |
9889 | if (CHECK_FLAG(p->cap, | |
9890 | PEER_CAP_ENHE_RCV)) | |
9891 | vty_out(vty, " %sreceived", | |
9892 | CHECK_FLAG( | |
9893 | p->cap, | |
9894 | PEER_CAP_ENHE_ADV) | |
9895 | ? "and " | |
9896 | : ""); | |
9897 | vty_out(vty, "\n"); | |
9898 | ||
9899 | if (CHECK_FLAG(p->cap, | |
9900 | PEER_CAP_ENHE_RCV)) { | |
9901 | vty_out(vty, | |
9902 | " Address families by peer:\n "); | |
9903 | for (safi = SAFI_UNICAST; | |
9904 | safi < SAFI_MAX; safi++) | |
9905 | if (CHECK_FLAG( | |
9906 | p->af_cap | |
9907 | [AFI_IP] | |
9908 | [safi], | |
9909 | PEER_CAP_ENHE_AF_RCV)) | |
9910 | vty_out(vty, | |
9911 | " %s\n", | |
9912 | afi_safi_print( | |
9913 | AFI_IP, | |
9914 | safi)); | |
9915 | } | |
9916 | } | |
9917 | ||
9918 | /* Route Refresh */ | |
9919 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
9920 | || CHECK_FLAG(p->cap, | |
9921 | PEER_CAP_REFRESH_NEW_RCV) | |
9922 | || CHECK_FLAG(p->cap, | |
9923 | PEER_CAP_REFRESH_OLD_RCV)) { | |
9924 | vty_out(vty, " Route refresh:"); | |
9925 | if (CHECK_FLAG(p->cap, | |
9926 | PEER_CAP_REFRESH_ADV)) | |
9927 | vty_out(vty, " advertised"); | |
9928 | if (CHECK_FLAG(p->cap, | |
9929 | PEER_CAP_REFRESH_NEW_RCV) | |
9930 | || CHECK_FLAG( | |
9931 | p->cap, | |
9932 | PEER_CAP_REFRESH_OLD_RCV)) | |
9933 | vty_out(vty, " %sreceived(%s)", | |
9934 | CHECK_FLAG( | |
9935 | p->cap, | |
9936 | PEER_CAP_REFRESH_ADV) | |
9937 | ? "and " | |
9938 | : "", | |
9939 | (CHECK_FLAG( | |
9940 | p->cap, | |
9941 | PEER_CAP_REFRESH_OLD_RCV) | |
9942 | && CHECK_FLAG( | |
9943 | p->cap, | |
9944 | PEER_CAP_REFRESH_NEW_RCV)) | |
9945 | ? "old & new" | |
9946 | : CHECK_FLAG( | |
9947 | p->cap, | |
9948 | PEER_CAP_REFRESH_OLD_RCV) | |
9949 | ? "old" | |
9950 | : "new"); | |
9951 | ||
9952 | vty_out(vty, "\n"); | |
9953 | } | |
9954 | ||
9955 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
9956 | FOREACH_AFI_SAFI (afi, safi) |
9957 | if (p->afc_adv[afi][safi] | |
9958 | || p->afc_recv[afi][safi]) { | |
9959 | vty_out(vty, | |
9960 | " Address Family %s:", | |
9961 | afi_safi_print(afi, | |
9962 | safi)); | |
9963 | if (p->afc_adv[afi][safi]) | |
d62a17ae | 9964 | vty_out(vty, |
05c7a1cc QY |
9965 | " advertised"); |
9966 | if (p->afc_recv[afi][safi]) | |
9967 | vty_out(vty, | |
9968 | " %sreceived", | |
9969 | p->afc_adv[afi] | |
9970 | [safi] | |
9971 | ? "and " | |
9972 | : ""); | |
9973 | vty_out(vty, "\n"); | |
9974 | } | |
d62a17ae | 9975 | |
9976 | /* Hostname capability */ | |
60466a63 | 9977 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
9978 | |
9979 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
9980 | vty_out(vty, |
9981 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
9982 | bgp->peer_self->hostname |
9983 | ? bgp->peer_self | |
9984 | ->hostname | |
d77114b7 | 9985 | : "n/a", |
60466a63 QY |
9986 | bgp->peer_self->domainname |
9987 | ? bgp->peer_self | |
9988 | ->domainname | |
d77114b7 MK |
9989 | : "n/a"); |
9990 | } else { | |
9991 | vty_out(vty, " not advertised"); | |
d62a17ae | 9992 | } |
9993 | ||
d77114b7 | 9994 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
9995 | vty_out(vty, |
9996 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
9997 | p->hostname ? p->hostname |
9998 | : "n/a", | |
9999 | p->domainname ? p->domainname | |
10000 | : "n/a"); | |
d77114b7 MK |
10001 | } else { |
10002 | vty_out(vty, " not received"); | |
10003 | } | |
10004 | ||
10005 | vty_out(vty, "\n"); | |
10006 | ||
d62a17ae | 10007 | /* Gracefull Restart */ |
10008 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
10009 | || CHECK_FLAG(p->cap, | |
10010 | PEER_CAP_RESTART_ADV)) { | |
10011 | vty_out(vty, | |
10012 | " Graceful Restart Capabilty:"); | |
10013 | if (CHECK_FLAG(p->cap, | |
10014 | PEER_CAP_RESTART_ADV)) | |
10015 | vty_out(vty, " advertised"); | |
10016 | if (CHECK_FLAG(p->cap, | |
10017 | PEER_CAP_RESTART_RCV)) | |
10018 | vty_out(vty, " %sreceived", | |
10019 | CHECK_FLAG( | |
10020 | p->cap, | |
10021 | PEER_CAP_RESTART_ADV) | |
10022 | ? "and " | |
10023 | : ""); | |
10024 | vty_out(vty, "\n"); | |
10025 | ||
10026 | if (CHECK_FLAG(p->cap, | |
10027 | PEER_CAP_RESTART_RCV)) { | |
10028 | int restart_af_count = 0; | |
10029 | ||
10030 | vty_out(vty, | |
10031 | " Remote Restart timer is %d seconds\n", | |
10032 | p->v_gr_restart); | |
10033 | vty_out(vty, | |
10034 | " Address families by peer:\n "); | |
10035 | ||
05c7a1cc QY |
10036 | FOREACH_AFI_SAFI (afi, safi) |
10037 | if (CHECK_FLAG( | |
10038 | p->af_cap | |
10039 | [afi] | |
10040 | [safi], | |
10041 | PEER_CAP_RESTART_AF_RCV)) { | |
10042 | vty_out(vty, | |
10043 | "%s%s(%s)", | |
10044 | restart_af_count | |
10045 | ? ", " | |
10046 | : "", | |
10047 | afi_safi_print( | |
10048 | afi, | |
10049 | safi), | |
10050 | CHECK_FLAG( | |
10051 | p->af_cap | |
10052 | [afi] | |
10053 | [safi], | |
10054 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
10055 | ? "preserved" | |
10056 | : "not preserved"); | |
10057 | restart_af_count++; | |
10058 | } | |
d62a17ae | 10059 | if (!restart_af_count) |
10060 | vty_out(vty, "none"); | |
10061 | vty_out(vty, "\n"); | |
10062 | } | |
10063 | } | |
10064 | } | |
10065 | } | |
10066 | } | |
10067 | ||
10068 | /* graceful restart information */ | |
10069 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || p->t_gr_restart | |
10070 | || p->t_gr_stale) { | |
10071 | json_object *json_grace = NULL; | |
10072 | json_object *json_grace_send = NULL; | |
10073 | json_object *json_grace_recv = NULL; | |
10074 | int eor_send_af_count = 0; | |
10075 | int eor_receive_af_count = 0; | |
10076 | ||
10077 | if (use_json) { | |
10078 | json_grace = json_object_new_object(); | |
10079 | json_grace_send = json_object_new_object(); | |
10080 | json_grace_recv = json_object_new_object(); | |
10081 | ||
10082 | if (p->status == Established) { | |
05c7a1cc QY |
10083 | FOREACH_AFI_SAFI (afi, safi) { |
10084 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10085 | PEER_STATUS_EOR_SEND)) { | |
10086 | json_object_boolean_true_add( | |
10087 | json_grace_send, | |
10088 | afi_safi_print(afi, | |
10089 | safi)); | |
10090 | eor_send_af_count++; | |
d62a17ae | 10091 | } |
10092 | } | |
05c7a1cc QY |
10093 | FOREACH_AFI_SAFI (afi, safi) { |
10094 | if (CHECK_FLAG( | |
10095 | p->af_sflags[afi][safi], | |
10096 | PEER_STATUS_EOR_RECEIVED)) { | |
10097 | json_object_boolean_true_add( | |
10098 | json_grace_recv, | |
10099 | afi_safi_print(afi, | |
10100 | safi)); | |
10101 | eor_receive_af_count++; | |
d62a17ae | 10102 | } |
10103 | } | |
10104 | } | |
10105 | ||
10106 | json_object_object_add(json_grace, "endOfRibSend", | |
10107 | json_grace_send); | |
10108 | json_object_object_add(json_grace, "endOfRibRecv", | |
10109 | json_grace_recv); | |
10110 | ||
10111 | if (p->t_gr_restart) | |
10112 | json_object_int_add(json_grace, | |
10113 | "gracefulRestartTimerMsecs", | |
10114 | thread_timer_remain_second( | |
10115 | p->t_gr_restart) | |
10116 | * 1000); | |
10117 | ||
10118 | if (p->t_gr_stale) | |
10119 | json_object_int_add( | |
10120 | json_grace, | |
10121 | "gracefulStalepathTimerMsecs", | |
10122 | thread_timer_remain_second( | |
10123 | p->t_gr_stale) | |
10124 | * 1000); | |
10125 | ||
10126 | json_object_object_add( | |
10127 | json_neigh, "gracefulRestartInfo", json_grace); | |
10128 | } else { | |
10129 | vty_out(vty, " Graceful restart informations:\n"); | |
10130 | if (p->status == Established) { | |
10131 | vty_out(vty, " End-of-RIB send: "); | |
05c7a1cc QY |
10132 | FOREACH_AFI_SAFI (afi, safi) { |
10133 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10134 | PEER_STATUS_EOR_SEND)) { | |
10135 | vty_out(vty, "%s%s", | |
10136 | eor_send_af_count ? ", " | |
10137 | : "", | |
10138 | afi_safi_print(afi, | |
10139 | safi)); | |
10140 | eor_send_af_count++; | |
d62a17ae | 10141 | } |
10142 | } | |
10143 | vty_out(vty, "\n"); | |
10144 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
10145 | FOREACH_AFI_SAFI (afi, safi) { |
10146 | if (CHECK_FLAG( | |
10147 | p->af_sflags[afi][safi], | |
10148 | PEER_STATUS_EOR_RECEIVED)) { | |
10149 | vty_out(vty, "%s%s", | |
10150 | eor_receive_af_count | |
10151 | ? ", " | |
10152 | : "", | |
10153 | afi_safi_print(afi, | |
10154 | safi)); | |
10155 | eor_receive_af_count++; | |
d62a17ae | 10156 | } |
10157 | } | |
10158 | vty_out(vty, "\n"); | |
10159 | } | |
10160 | ||
10161 | if (p->t_gr_restart) | |
10162 | vty_out(vty, | |
10163 | " The remaining time of restart timer is %ld\n", | |
10164 | thread_timer_remain_second( | |
10165 | p->t_gr_restart)); | |
10166 | ||
10167 | if (p->t_gr_stale) | |
10168 | vty_out(vty, | |
10169 | " The remaining time of stalepath timer is %ld\n", | |
10170 | thread_timer_remain_second( | |
10171 | p->t_gr_stale)); | |
10172 | } | |
10173 | } | |
10174 | if (use_json) { | |
10175 | json_object *json_stat = NULL; | |
10176 | json_stat = json_object_new_object(); | |
10177 | /* Packet counts. */ | |
10178 | json_object_int_add(json_stat, "depthInq", 0); | |
10179 | json_object_int_add(json_stat, "depthOutq", | |
10180 | (unsigned long)p->obuf->count); | |
0112e9e0 QY |
10181 | json_object_int_add(json_stat, "opensSent", |
10182 | atomic_load_explicit(&p->open_out, | |
10183 | memory_order_relaxed)); | |
10184 | json_object_int_add(json_stat, "opensRecv", | |
10185 | atomic_load_explicit(&p->open_in, | |
10186 | memory_order_relaxed)); | |
d62a17ae | 10187 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
10188 | atomic_load_explicit(&p->notify_out, |
10189 | memory_order_relaxed)); | |
d62a17ae | 10190 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
10191 | atomic_load_explicit(&p->notify_in, |
10192 | memory_order_relaxed)); | |
10193 | json_object_int_add(json_stat, "updatesSent", | |
10194 | atomic_load_explicit(&p->update_out, | |
10195 | memory_order_relaxed)); | |
10196 | json_object_int_add(json_stat, "updatesRecv", | |
10197 | atomic_load_explicit(&p->update_in, | |
10198 | memory_order_relaxed)); | |
d62a17ae | 10199 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
10200 | atomic_load_explicit(&p->keepalive_out, |
10201 | memory_order_relaxed)); | |
d62a17ae | 10202 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
10203 | atomic_load_explicit(&p->keepalive_in, |
10204 | memory_order_relaxed)); | |
d62a17ae | 10205 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
10206 | atomic_load_explicit(&p->refresh_out, |
10207 | memory_order_relaxed)); | |
d62a17ae | 10208 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
10209 | atomic_load_explicit(&p->refresh_in, |
10210 | memory_order_relaxed)); | |
d62a17ae | 10211 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
10212 | atomic_load_explicit(&p->dynamic_cap_out, |
10213 | memory_order_relaxed)); | |
d62a17ae | 10214 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
10215 | atomic_load_explicit(&p->dynamic_cap_in, |
10216 | memory_order_relaxed)); | |
10217 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
10218 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 10219 | json_object_object_add(json_neigh, "messageStats", json_stat); |
10220 | } else { | |
10221 | /* Packet counts. */ | |
10222 | vty_out(vty, " Message statistics:\n"); | |
10223 | vty_out(vty, " Inq depth is 0\n"); | |
10224 | vty_out(vty, " Outq depth is %lu\n", | |
10225 | (unsigned long)p->obuf->count); | |
10226 | vty_out(vty, " Sent Rcvd\n"); | |
0112e9e0 QY |
10227 | vty_out(vty, " Opens: %10d %10d\n", |
10228 | atomic_load_explicit(&p->open_out, | |
10229 | memory_order_relaxed), | |
10230 | atomic_load_explicit(&p->open_in, | |
10231 | memory_order_relaxed)); | |
10232 | vty_out(vty, " Notifications: %10d %10d\n", | |
10233 | atomic_load_explicit(&p->notify_out, | |
10234 | memory_order_relaxed), | |
10235 | atomic_load_explicit(&p->notify_in, | |
10236 | memory_order_relaxed)); | |
10237 | vty_out(vty, " Updates: %10d %10d\n", | |
10238 | atomic_load_explicit(&p->update_out, | |
10239 | memory_order_relaxed), | |
10240 | atomic_load_explicit(&p->update_in, | |
10241 | memory_order_relaxed)); | |
10242 | vty_out(vty, " Keepalives: %10d %10d\n", | |
10243 | atomic_load_explicit(&p->keepalive_out, | |
10244 | memory_order_relaxed), | |
10245 | atomic_load_explicit(&p->keepalive_in, | |
10246 | memory_order_relaxed)); | |
10247 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
10248 | atomic_load_explicit(&p->refresh_out, | |
10249 | memory_order_relaxed), | |
10250 | atomic_load_explicit(&p->refresh_in, | |
10251 | memory_order_relaxed)); | |
d62a17ae | 10252 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
10253 | atomic_load_explicit(&p->dynamic_cap_out, |
10254 | memory_order_relaxed), | |
10255 | atomic_load_explicit(&p->dynamic_cap_in, | |
10256 | memory_order_relaxed)); | |
10257 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
10258 | PEER_TOTAL_RX(p)); | |
d62a17ae | 10259 | } |
10260 | ||
10261 | if (use_json) { | |
10262 | /* advertisement-interval */ | |
10263 | json_object_int_add(json_neigh, | |
10264 | "minBtwnAdvertisementRunsTimerMsecs", | |
10265 | p->v_routeadv * 1000); | |
10266 | ||
10267 | /* Update-source. */ | |
10268 | if (p->update_if || p->update_source) { | |
10269 | if (p->update_if) | |
10270 | json_object_string_add(json_neigh, | |
10271 | "updateSource", | |
10272 | p->update_if); | |
10273 | else if (p->update_source) | |
10274 | json_object_string_add( | |
10275 | json_neigh, "updateSource", | |
10276 | sockunion2str(p->update_source, buf1, | |
10277 | SU_ADDRSTRLEN)); | |
10278 | } | |
10279 | } else { | |
10280 | /* advertisement-interval */ | |
10281 | vty_out(vty, | |
10282 | " Minimum time between advertisement runs is %d seconds\n", | |
10283 | p->v_routeadv); | |
10284 | ||
10285 | /* Update-source. */ | |
10286 | if (p->update_if || p->update_source) { | |
10287 | vty_out(vty, " Update source is "); | |
10288 | if (p->update_if) | |
10289 | vty_out(vty, "%s", p->update_if); | |
10290 | else if (p->update_source) | |
10291 | vty_out(vty, "%s", | |
10292 | sockunion2str(p->update_source, buf1, | |
10293 | SU_ADDRSTRLEN)); | |
10294 | vty_out(vty, "\n"); | |
10295 | } | |
10296 | ||
10297 | vty_out(vty, "\n"); | |
10298 | } | |
10299 | ||
10300 | /* Address Family Information */ | |
10301 | json_object *json_hold = NULL; | |
10302 | ||
10303 | if (use_json) | |
10304 | json_hold = json_object_new_object(); | |
10305 | ||
05c7a1cc QY |
10306 | FOREACH_AFI_SAFI (afi, safi) |
10307 | if (p->afc[afi][safi]) | |
10308 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
10309 | json_hold); | |
d62a17ae | 10310 | |
10311 | if (use_json) { | |
10312 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
10313 | json_hold); | |
10314 | json_object_int_add(json_neigh, "connectionsEstablished", | |
10315 | p->established); | |
10316 | json_object_int_add(json_neigh, "connectionsDropped", | |
10317 | p->dropped); | |
10318 | } else | |
10319 | vty_out(vty, " Connections established %d; dropped %d\n", | |
10320 | p->established, p->dropped); | |
10321 | ||
10322 | if (!p->last_reset) { | |
10323 | if (use_json) | |
10324 | json_object_string_add(json_neigh, "lastReset", | |
10325 | "never"); | |
10326 | else | |
10327 | vty_out(vty, " Last reset never\n"); | |
10328 | } else { | |
10329 | if (use_json) { | |
10330 | time_t uptime; | |
10331 | struct tm *tm; | |
10332 | ||
10333 | uptime = bgp_clock(); | |
10334 | uptime -= p->resettime; | |
10335 | tm = gmtime(&uptime); | |
10336 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
10337 | (tm->tm_sec * 1000) | |
10338 | + (tm->tm_min * 60000) | |
10339 | + (tm->tm_hour * 3600000)); | |
10340 | json_object_string_add( | |
10341 | json_neigh, "lastResetDueTo", | |
10342 | peer_down_str[(int)p->last_reset]); | |
10343 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10344 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10345 | char errorcodesubcode_hexstr[5]; | |
10346 | char errorcodesubcode_str[256]; | |
10347 | ||
10348 | code_str = bgp_notify_code_str(p->notify.code); | |
10349 | subcode_str = bgp_notify_subcode_str( | |
10350 | p->notify.code, p->notify.subcode); | |
10351 | ||
10352 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
10353 | p->notify.code, p->notify.subcode); | |
10354 | json_object_string_add(json_neigh, | |
10355 | "lastErrorCodeSubcode", | |
10356 | errorcodesubcode_hexstr); | |
10357 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10358 | code_str, subcode_str); | |
10359 | json_object_string_add(json_neigh, | |
10360 | "lastNotificationReason", | |
10361 | errorcodesubcode_str); | |
10362 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10363 | && p->notify.code == BGP_NOTIFY_CEASE | |
10364 | && (p->notify.subcode | |
10365 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10366 | || p->notify.subcode | |
10367 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10368 | && p->notify.length) { | |
10369 | char msgbuf[1024]; | |
10370 | const char *msg_str; | |
10371 | ||
10372 | msg_str = bgp_notify_admin_message( | |
10373 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10374 | (uint8_t *)p->notify.data, |
d62a17ae | 10375 | p->notify.length); |
10376 | if (msg_str) | |
10377 | json_object_string_add( | |
10378 | json_neigh, | |
10379 | "lastShutdownDescription", | |
10380 | msg_str); | |
10381 | } | |
10382 | } | |
10383 | } else { | |
10384 | vty_out(vty, " Last reset %s, ", | |
10385 | peer_uptime(p->resettime, timebuf, | |
10386 | BGP_UPTIME_LEN, 0, NULL)); | |
10387 | ||
10388 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10389 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10390 | code_str = bgp_notify_code_str(p->notify.code); | |
10391 | subcode_str = bgp_notify_subcode_str( | |
10392 | p->notify.code, p->notify.subcode); | |
10393 | vty_out(vty, "due to NOTIFICATION %s (%s%s)\n", | |
10394 | p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10395 | ? "sent" | |
10396 | : "received", | |
10397 | code_str, subcode_str); | |
10398 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10399 | && p->notify.code == BGP_NOTIFY_CEASE | |
10400 | && (p->notify.subcode | |
10401 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10402 | || p->notify.subcode | |
10403 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10404 | && p->notify.length) { | |
10405 | char msgbuf[1024]; | |
10406 | const char *msg_str; | |
10407 | ||
10408 | msg_str = bgp_notify_admin_message( | |
10409 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10410 | (uint8_t *)p->notify.data, |
d62a17ae | 10411 | p->notify.length); |
10412 | if (msg_str) | |
10413 | vty_out(vty, | |
10414 | " Message: \"%s\"\n", | |
10415 | msg_str); | |
10416 | } | |
10417 | } else { | |
10418 | vty_out(vty, "due to %s\n", | |
10419 | peer_down_str[(int)p->last_reset]); | |
10420 | } | |
10421 | ||
10422 | if (p->last_reset_cause_size) { | |
10423 | msg = p->last_reset_cause; | |
10424 | vty_out(vty, | |
10425 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
10426 | for (i = 1; i <= p->last_reset_cause_size; | |
10427 | i++) { | |
10428 | vty_out(vty, "%02X", *msg++); | |
10429 | ||
10430 | if (i != p->last_reset_cause_size) { | |
10431 | if (i % 16 == 0) { | |
10432 | vty_out(vty, "\n "); | |
10433 | } else if (i % 4 == 0) { | |
10434 | vty_out(vty, " "); | |
10435 | } | |
10436 | } | |
10437 | } | |
10438 | vty_out(vty, "\n"); | |
10439 | } | |
10440 | } | |
10441 | } | |
10442 | ||
10443 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
10444 | if (use_json) | |
10445 | json_object_boolean_true_add(json_neigh, | |
10446 | "prefixesConfigExceedMax"); | |
10447 | else | |
10448 | vty_out(vty, | |
10449 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
10450 | ||
10451 | if (p->t_pmax_restart) { | |
10452 | if (use_json) { | |
10453 | json_object_boolean_true_add( | |
10454 | json_neigh, "reducePrefixNumFrom"); | |
10455 | json_object_int_add(json_neigh, | |
10456 | "restartInTimerMsec", | |
10457 | thread_timer_remain_second( | |
10458 | p->t_pmax_restart) | |
10459 | * 1000); | |
10460 | } else | |
10461 | vty_out(vty, | |
10462 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
10463 | p->host, thread_timer_remain_second( |
10464 | p->t_pmax_restart)); | |
d62a17ae | 10465 | } else { |
10466 | if (use_json) | |
10467 | json_object_boolean_true_add( | |
10468 | json_neigh, | |
10469 | "reducePrefixNumAndClearIpBgp"); | |
10470 | else | |
10471 | vty_out(vty, | |
10472 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
10473 | p->host); | |
10474 | } | |
10475 | } | |
10476 | ||
10477 | /* EBGP Multihop and GTSM */ | |
10478 | if (p->sort != BGP_PEER_IBGP) { | |
10479 | if (use_json) { | |
10480 | if (p->gtsm_hops > 0) | |
10481 | json_object_int_add(json_neigh, | |
10482 | "externalBgpNbrMaxHopsAway", | |
10483 | p->gtsm_hops); | |
10484 | else if (p->ttl > 1) | |
10485 | json_object_int_add(json_neigh, | |
10486 | "externalBgpNbrMaxHopsAway", | |
10487 | p->ttl); | |
10488 | } else { | |
10489 | if (p->gtsm_hops > 0) | |
10490 | vty_out(vty, | |
10491 | " External BGP neighbor may be up to %d hops away.\n", | |
10492 | p->gtsm_hops); | |
10493 | else if (p->ttl > 1) | |
10494 | vty_out(vty, | |
10495 | " External BGP neighbor may be up to %d hops away.\n", | |
10496 | p->ttl); | |
10497 | } | |
10498 | } else { | |
10499 | if (p->gtsm_hops > 0) { | |
10500 | if (use_json) | |
10501 | json_object_int_add(json_neigh, | |
10502 | "internalBgpNbrMaxHopsAway", | |
10503 | p->gtsm_hops); | |
10504 | else | |
10505 | vty_out(vty, | |
10506 | " Internal BGP neighbor may be up to %d hops away.\n", | |
10507 | p->gtsm_hops); | |
10508 | } | |
10509 | } | |
10510 | ||
10511 | /* Local address. */ | |
10512 | if (p->su_local) { | |
10513 | if (use_json) { | |
10514 | json_object_string_add(json_neigh, "hostLocal", | |
10515 | sockunion2str(p->su_local, buf1, | |
10516 | SU_ADDRSTRLEN)); | |
10517 | json_object_int_add(json_neigh, "portLocal", | |
10518 | ntohs(p->su_local->sin.sin_port)); | |
10519 | } else | |
10520 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
10521 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
10522 | ntohs(p->su_local->sin.sin_port)); | |
10523 | } | |
10524 | ||
10525 | /* Remote address. */ | |
10526 | if (p->su_remote) { | |
10527 | if (use_json) { | |
10528 | json_object_string_add(json_neigh, "hostForeign", | |
10529 | sockunion2str(p->su_remote, buf1, | |
10530 | SU_ADDRSTRLEN)); | |
10531 | json_object_int_add(json_neigh, "portForeign", | |
10532 | ntohs(p->su_remote->sin.sin_port)); | |
10533 | } else | |
10534 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
10535 | sockunion2str(p->su_remote, buf1, | |
10536 | SU_ADDRSTRLEN), | |
10537 | ntohs(p->su_remote->sin.sin_port)); | |
10538 | } | |
10539 | ||
10540 | /* Nexthop display. */ | |
10541 | if (p->su_local) { | |
10542 | if (use_json) { | |
10543 | json_object_string_add(json_neigh, "nexthop", | |
10544 | inet_ntop(AF_INET, | |
10545 | &p->nexthop.v4, buf1, | |
10546 | sizeof(buf1))); | |
10547 | json_object_string_add(json_neigh, "nexthopGlobal", | |
10548 | inet_ntop(AF_INET6, | |
10549 | &p->nexthop.v6_global, | |
10550 | buf1, sizeof(buf1))); | |
10551 | json_object_string_add(json_neigh, "nexthopLocal", | |
10552 | inet_ntop(AF_INET6, | |
10553 | &p->nexthop.v6_local, | |
10554 | buf1, sizeof(buf1))); | |
10555 | if (p->shared_network) | |
10556 | json_object_string_add(json_neigh, | |
10557 | "bgpConnection", | |
10558 | "sharedNetwork"); | |
10559 | else | |
10560 | json_object_string_add(json_neigh, | |
10561 | "bgpConnection", | |
10562 | "nonSharedNetwork"); | |
10563 | } else { | |
10564 | vty_out(vty, "Nexthop: %s\n", | |
10565 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
10566 | sizeof(buf1))); | |
10567 | vty_out(vty, "Nexthop global: %s\n", | |
10568 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
10569 | sizeof(buf1))); | |
10570 | vty_out(vty, "Nexthop local: %s\n", | |
10571 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
10572 | sizeof(buf1))); | |
10573 | vty_out(vty, "BGP connection: %s\n", | |
10574 | p->shared_network ? "shared network" | |
10575 | : "non shared network"); | |
10576 | } | |
10577 | } | |
10578 | ||
10579 | /* Timer information. */ | |
10580 | if (use_json) { | |
10581 | json_object_int_add(json_neigh, "connectRetryTimer", | |
10582 | p->v_connect); | |
10583 | if (p->status == Established && p->rtt) | |
10584 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
10585 | p->rtt); | |
10586 | if (p->t_start) | |
10587 | json_object_int_add( | |
10588 | json_neigh, "nextStartTimerDueInMsecs", | |
10589 | thread_timer_remain_second(p->t_start) * 1000); | |
10590 | if (p->t_connect) | |
10591 | json_object_int_add( | |
10592 | json_neigh, "nextConnectTimerDueInMsecs", | |
10593 | thread_timer_remain_second(p->t_connect) | |
10594 | * 1000); | |
10595 | if (p->t_routeadv) { | |
10596 | json_object_int_add(json_neigh, "mraiInterval", | |
10597 | p->v_routeadv); | |
10598 | json_object_int_add( | |
10599 | json_neigh, "mraiTimerExpireInMsecs", | |
10600 | thread_timer_remain_second(p->t_routeadv) | |
10601 | * 1000); | |
10602 | } | |
10603 | if (p->password) | |
10604 | json_object_int_add(json_neigh, "authenticationEnabled", | |
10605 | 1); | |
10606 | ||
10607 | if (p->t_read) | |
10608 | json_object_string_add(json_neigh, "readThread", "on"); | |
10609 | else | |
10610 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
10611 | |
10612 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 10613 | json_object_string_add(json_neigh, "writeThread", "on"); |
10614 | else | |
10615 | json_object_string_add(json_neigh, "writeThread", | |
10616 | "off"); | |
10617 | } else { | |
10618 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
10619 | p->v_connect); | |
10620 | if (p->status == Established && p->rtt) | |
10621 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
10622 | p->rtt); | |
10623 | if (p->t_start) | |
10624 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
10625 | thread_timer_remain_second(p->t_start)); | |
10626 | if (p->t_connect) | |
10627 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
10628 | thread_timer_remain_second(p->t_connect)); | |
10629 | if (p->t_routeadv) | |
10630 | vty_out(vty, | |
10631 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
10632 | p->v_routeadv, | |
10633 | thread_timer_remain_second(p->t_routeadv)); | |
10634 | if (p->password) | |
10635 | vty_out(vty, "Peer Authentication Enabled\n"); | |
10636 | ||
10637 | vty_out(vty, "Read thread: %s Write thread: %s\n", | |
49507a6f QY |
10638 | p->t_read ? "on" : "off", |
10639 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
10640 | ? "on" | |
10641 | : "off"); | |
d62a17ae | 10642 | } |
10643 | ||
10644 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
10645 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
10646 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
10647 | ||
10648 | if (!use_json) | |
10649 | vty_out(vty, "\n"); | |
10650 | ||
10651 | /* BFD information. */ | |
10652 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
10653 | ||
10654 | if (use_json) { | |
10655 | if (p->conf_if) /* Configured interface name. */ | |
10656 | json_object_object_add(json, p->conf_if, json_neigh); | |
10657 | else /* Configured IP address. */ | |
10658 | json_object_object_add(json, p->host, json_neigh); | |
10659 | } | |
10660 | } | |
10661 | ||
10662 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, | |
10663 | enum show_type type, union sockunion *su, | |
d7c0a89a | 10664 | const char *conf_if, uint8_t use_json, |
d62a17ae | 10665 | json_object *json) |
10666 | { | |
10667 | struct listnode *node, *nnode; | |
10668 | struct peer *peer; | |
10669 | int find = 0; | |
10670 | ||
10671 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
10672 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10673 | continue; | |
10674 | ||
10675 | switch (type) { | |
10676 | case show_all: | |
10677 | bgp_show_peer(vty, peer, use_json, json); | |
10678 | break; | |
10679 | case show_peer: | |
10680 | if (conf_if) { | |
10681 | if ((peer->conf_if | |
10682 | && !strcmp(peer->conf_if, conf_if)) | |
10683 | || (peer->hostname | |
10684 | && !strcmp(peer->hostname, conf_if))) { | |
10685 | find = 1; | |
10686 | bgp_show_peer(vty, peer, use_json, | |
10687 | json); | |
10688 | } | |
10689 | } else { | |
10690 | if (sockunion_same(&peer->su, su)) { | |
10691 | find = 1; | |
10692 | bgp_show_peer(vty, peer, use_json, | |
10693 | json); | |
10694 | } | |
10695 | } | |
10696 | break; | |
10697 | } | |
10698 | } | |
10699 | ||
10700 | if (type == show_peer && !find) { | |
10701 | if (use_json) | |
10702 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
10703 | else | |
88b7d255 | 10704 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 10705 | } |
10706 | ||
10707 | if (use_json) { | |
996c9314 LB |
10708 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
10709 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 10710 | json_object_free(json); |
10711 | } else { | |
10712 | vty_out(vty, "\n"); | |
10713 | } | |
10714 | ||
10715 | return CMD_SUCCESS; | |
10716 | } | |
10717 | ||
10718 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, | |
71aedaa3 DS |
10719 | enum show_type type, |
10720 | const char *ip_str, | |
d7c0a89a | 10721 | uint8_t use_json) |
d62a17ae | 10722 | { |
0291c246 MK |
10723 | struct listnode *node, *nnode; |
10724 | struct bgp *bgp; | |
71aedaa3 | 10725 | union sockunion su; |
0291c246 | 10726 | json_object *json = NULL; |
71aedaa3 | 10727 | int ret, is_first = 1; |
d62a17ae | 10728 | |
10729 | if (use_json) | |
10730 | vty_out(vty, "{\n"); | |
10731 | ||
10732 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
10733 | if (use_json) { | |
10734 | if (!(json = json_object_new_object())) { | |
10735 | zlog_err( | |
10736 | "Unable to allocate memory for JSON object"); | |
10737 | vty_out(vty, | |
10738 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
10739 | return; | |
10740 | } | |
10741 | ||
10742 | json_object_int_add(json, "vrfId", | |
10743 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
10744 | ? -1 |
10745 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 10746 | json_object_string_add( |
10747 | json, "vrfName", | |
10748 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
10749 | ? "Default" | |
10750 | : bgp->name); | |
10751 | ||
10752 | if (!is_first) | |
10753 | vty_out(vty, ",\n"); | |
10754 | else | |
10755 | is_first = 0; | |
10756 | ||
10757 | vty_out(vty, "\"%s\":", | |
10758 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
10759 | ? "Default" | |
10760 | : bgp->name); | |
10761 | } else { | |
10762 | vty_out(vty, "\nInstance %s:\n", | |
10763 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
10764 | ? "Default" | |
10765 | : bgp->name); | |
10766 | } | |
71aedaa3 DS |
10767 | |
10768 | if (type == show_peer) { | |
10769 | ret = str2sockunion(ip_str, &su); | |
10770 | if (ret < 0) | |
10771 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
10772 | use_json, json); | |
10773 | else | |
10774 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
10775 | use_json, json); | |
10776 | } else { | |
10777 | bgp_show_neighbor(vty, bgp, show_all, NULL, NULL, | |
10778 | use_json, json); | |
10779 | } | |
d62a17ae | 10780 | } |
10781 | ||
10782 | if (use_json) | |
10783 | vty_out(vty, "}\n"); | |
10784 | } | |
10785 | ||
10786 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
10787 | enum show_type type, const char *ip_str, | |
d7c0a89a | 10788 | uint8_t use_json) |
d62a17ae | 10789 | { |
10790 | int ret; | |
10791 | struct bgp *bgp; | |
10792 | union sockunion su; | |
10793 | json_object *json = NULL; | |
10794 | ||
10795 | if (name) { | |
10796 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
10797 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
10798 | use_json); | |
d62a17ae | 10799 | return CMD_SUCCESS; |
10800 | } else { | |
10801 | bgp = bgp_lookup_by_name(name); | |
10802 | if (!bgp) { | |
10803 | if (use_json) { | |
10804 | json = json_object_new_object(); | |
10805 | json_object_boolean_true_add( | |
10806 | json, "bgpNoSuchInstance"); | |
10807 | vty_out(vty, "%s\n", | |
10808 | json_object_to_json_string_ext( | |
10809 | json, | |
10810 | JSON_C_TO_STRING_PRETTY)); | |
10811 | json_object_free(json); | |
10812 | } else | |
10813 | vty_out(vty, | |
10814 | "%% No such BGP instance exist\n"); | |
10815 | ||
10816 | return CMD_WARNING; | |
10817 | } | |
10818 | } | |
10819 | } else { | |
10820 | bgp = bgp_get_default(); | |
10821 | } | |
10822 | ||
10823 | if (bgp) { | |
10824 | json = json_object_new_object(); | |
10825 | if (ip_str) { | |
10826 | ret = str2sockunion(ip_str, &su); | |
10827 | if (ret < 0) | |
10828 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
10829 | use_json, json); | |
10830 | else | |
10831 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
10832 | use_json, json); | |
10833 | } else { | |
10834 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
10835 | json); | |
10836 | } | |
10837 | json_object_free(json); | |
10838 | } | |
10839 | ||
10840 | return CMD_SUCCESS; | |
4fb25c53 DW |
10841 | } |
10842 | ||
716b2d8a | 10843 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 10844 | DEFUN (show_ip_bgp_neighbors, |
10845 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 10846 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 10847 | SHOW_STR |
10848 | IP_STR | |
10849 | BGP_STR | |
f2a8972b | 10850 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
10851 | "Address Family\n" |
10852 | "Address Family\n" | |
718e3744 | 10853 | "Detailed information on TCP and BGP neighbor connections\n" |
10854 | "Neighbor to display information about\n" | |
a80beece | 10855 | "Neighbor to display information about\n" |
91d37724 | 10856 | "Neighbor on BGP configured interface\n" |
9973d184 | 10857 | JSON_STR) |
718e3744 | 10858 | { |
d62a17ae | 10859 | char *vrf = NULL; |
10860 | char *sh_arg = NULL; | |
10861 | enum show_type sh_type; | |
718e3744 | 10862 | |
d7c0a89a | 10863 | uint8_t uj = use_json(argc, argv); |
718e3744 | 10864 | |
d62a17ae | 10865 | int idx = 0; |
718e3744 | 10866 | |
d62a17ae | 10867 | if (argv_find(argv, argc, "view", &idx) |
10868 | || argv_find(argv, argc, "vrf", &idx)) | |
10869 | vrf = argv[idx + 1]->arg; | |
718e3744 | 10870 | |
d62a17ae | 10871 | idx++; |
10872 | if (argv_find(argv, argc, "A.B.C.D", &idx) | |
10873 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
10874 | || argv_find(argv, argc, "WORD", &idx)) { | |
10875 | sh_type = show_peer; | |
10876 | sh_arg = argv[idx]->arg; | |
10877 | } else | |
10878 | sh_type = show_all; | |
856ca177 | 10879 | |
d62a17ae | 10880 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 10881 | } |
10882 | ||
716b2d8a | 10883 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 10884 | paths' and `show ip mbgp paths'. Those functions results are the |
10885 | same.*/ | |
f412b39a | 10886 | DEFUN (show_ip_bgp_paths, |
718e3744 | 10887 | show_ip_bgp_paths_cmd, |
46f296b4 | 10888 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 10889 | SHOW_STR |
10890 | IP_STR | |
10891 | BGP_STR | |
46f296b4 | 10892 | BGP_SAFI_HELP_STR |
718e3744 | 10893 | "Path information\n") |
10894 | { | |
d62a17ae | 10895 | vty_out(vty, "Address Refcnt Path\n"); |
10896 | aspath_print_all_vty(vty); | |
10897 | return CMD_SUCCESS; | |
718e3744 | 10898 | } |
10899 | ||
718e3744 | 10900 | #include "hash.h" |
10901 | ||
d62a17ae | 10902 | static void community_show_all_iterator(struct hash_backet *backet, |
10903 | struct vty *vty) | |
718e3744 | 10904 | { |
d62a17ae | 10905 | struct community *com; |
718e3744 | 10906 | |
d62a17ae | 10907 | com = (struct community *)backet->data; |
3f65c5b1 | 10908 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 10909 | community_str(com, false)); |
718e3744 | 10910 | } |
10911 | ||
10912 | /* Show BGP's community internal data. */ | |
f412b39a | 10913 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 10914 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 10915 | "show [ip] bgp community-info", |
718e3744 | 10916 | SHOW_STR |
10917 | IP_STR | |
10918 | BGP_STR | |
10919 | "List all bgp community information\n") | |
10920 | { | |
d62a17ae | 10921 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 10922 | |
d62a17ae | 10923 | hash_iterate(community_hash(), |
10924 | (void (*)(struct hash_backet *, | |
10925 | void *))community_show_all_iterator, | |
10926 | vty); | |
718e3744 | 10927 | |
d62a17ae | 10928 | return CMD_SUCCESS; |
718e3744 | 10929 | } |
10930 | ||
d62a17ae | 10931 | static void lcommunity_show_all_iterator(struct hash_backet *backet, |
10932 | struct vty *vty) | |
57d187bc | 10933 | { |
d62a17ae | 10934 | struct lcommunity *lcom; |
57d187bc | 10935 | |
d62a17ae | 10936 | lcom = (struct lcommunity *)backet->data; |
3f65c5b1 | 10937 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 10938 | lcommunity_str(lcom, false)); |
57d187bc JS |
10939 | } |
10940 | ||
10941 | /* Show BGP's community internal data. */ | |
10942 | DEFUN (show_ip_bgp_lcommunity_info, | |
10943 | show_ip_bgp_lcommunity_info_cmd, | |
10944 | "show ip bgp large-community-info", | |
10945 | SHOW_STR | |
10946 | IP_STR | |
10947 | BGP_STR | |
10948 | "List all bgp large-community information\n") | |
10949 | { | |
d62a17ae | 10950 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 10951 | |
d62a17ae | 10952 | hash_iterate(lcommunity_hash(), |
10953 | (void (*)(struct hash_backet *, | |
10954 | void *))lcommunity_show_all_iterator, | |
10955 | vty); | |
57d187bc | 10956 | |
d62a17ae | 10957 | return CMD_SUCCESS; |
57d187bc JS |
10958 | } |
10959 | ||
10960 | ||
f412b39a | 10961 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 10962 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 10963 | "show [ip] bgp attribute-info", |
718e3744 | 10964 | SHOW_STR |
10965 | IP_STR | |
10966 | BGP_STR | |
10967 | "List all bgp attribute information\n") | |
10968 | { | |
d62a17ae | 10969 | attr_show_all(vty); |
10970 | return CMD_SUCCESS; | |
718e3744 | 10971 | } |
6b0655a2 | 10972 | |
53089bec | 10973 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
10974 | afi_t afi, safi_t safi) | |
10975 | { | |
10976 | struct bgp *bgp; | |
10977 | struct listnode *node; | |
10978 | char *vname; | |
10979 | char buf1[INET6_ADDRSTRLEN]; | |
10980 | char *ecom_str; | |
10981 | vpn_policy_direction_t dir; | |
10982 | ||
10983 | if (name) { | |
10984 | bgp = bgp_lookup_by_name(name); | |
10985 | if (!bgp) { | |
10986 | vty_out(vty, "%% No such BGP instance exist\n"); | |
10987 | return CMD_WARNING; | |
10988 | } | |
10989 | } else { | |
10990 | bgp = bgp_get_default(); | |
10991 | if (!bgp) { | |
020a3f60 DS |
10992 | vty_out(vty, |
10993 | "%% Default BGP instance does not exist\n"); | |
53089bec | 10994 | return CMD_WARNING; |
10995 | } | |
10996 | } | |
10997 | ||
10998 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
10999 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
020a3f60 DS |
11000 | vty_out(vty, |
11001 | "This VRF is not importing %s routes from any other VRF\n", | |
53089bec | 11002 | afi_safi_print(afi, safi)); |
11003 | } else { | |
020a3f60 DS |
11004 | vty_out(vty, |
11005 | "This VRF is importing %s routes from the following VRFs:\n", | |
53089bec | 11006 | afi_safi_print(afi, safi)); |
11007 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, | |
11008 | vname)) { | |
11009 | vty_out(vty, " %s\n", vname); | |
11010 | } | |
11011 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
11012 | ecom_str = ecommunity_ecom2str( | |
11013 | bgp->vpn_policy[afi].rtlist[dir], | |
11014 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11015 | vty_out(vty, "Import RT(s): %s\n", ecom_str); | |
11016 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11017 | } | |
11018 | ||
11019 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
11020 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
020a3f60 DS |
11021 | vty_out(vty, |
11022 | "This VRF is not exporting %s routes to any other VRF\n", | |
53089bec | 11023 | afi_safi_print(afi, safi)); |
11024 | } else { | |
020a3f60 DS |
11025 | vty_out(vty, |
11026 | "This VRF is exporting %s routes to the following VRFs:\n", | |
53089bec | 11027 | afi_safi_print(afi, safi)); |
11028 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].export_vrf, node, | |
11029 | vname)) { | |
11030 | vty_out(vty, " %s\n", vname); | |
11031 | } | |
11032 | vty_out(vty, "RD: %s\n", | |
11033 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11034 | buf1, RD_ADDRSTRLEN)); | |
11035 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
11036 | ecom_str = ecommunity_ecom2str( | |
11037 | bgp->vpn_policy[afi].rtlist[dir], | |
11038 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11039 | vty_out(vty, "Emport RT: %s\n", ecom_str); | |
11040 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11041 | } | |
11042 | ||
11043 | return CMD_SUCCESS; | |
11044 | } | |
11045 | ||
11046 | /* "show [ip] bgp route-leak" command. */ | |
11047 | DEFUN (show_ip_bgp_route_leak, | |
11048 | show_ip_bgp_route_leak_cmd, | |
11049 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak", | |
11050 | SHOW_STR | |
11051 | IP_STR | |
11052 | BGP_STR | |
11053 | BGP_INSTANCE_HELP_STR | |
11054 | BGP_AFI_HELP_STR | |
11055 | BGP_SAFI_HELP_STR | |
11056 | "Route leaking information\n") | |
11057 | { | |
11058 | char *vrf = NULL; | |
11059 | afi_t afi = AFI_MAX; | |
11060 | safi_t safi = SAFI_MAX; | |
11061 | ||
11062 | int idx = 0; | |
11063 | ||
11064 | /* show [ip] bgp */ | |
11065 | if (argv_find(argv, argc, "ip", &idx)) { | |
11066 | afi = AFI_IP; | |
11067 | safi = SAFI_UNICAST; | |
11068 | } | |
11069 | /* [vrf VIEWVRFNAME] */ | |
11070 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
11071 | vty_out(vty, |
11072 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 11073 | return CMD_WARNING; |
11074 | } | |
11075 | ||
11076 | if (argv_find(argv, argc, "vrf", &idx)) | |
11077 | vrf = argv[++idx]->arg; | |
11078 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
11079 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11080 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11081 | } | |
11082 | ||
11083 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
11084 | vty_out(vty, |
11085 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 11086 | return CMD_WARNING; |
11087 | } | |
11088 | ||
11089 | return bgp_show_route_leak_vty(vty, vrf, afi, safi); | |
11090 | } | |
11091 | ||
d62a17ae | 11092 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
11093 | safi_t safi) | |
f186de26 | 11094 | { |
d62a17ae | 11095 | struct listnode *node, *nnode; |
11096 | struct bgp *bgp; | |
f186de26 | 11097 | |
d62a17ae | 11098 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
11099 | vty_out(vty, "\nInstance %s:\n", | |
11100 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
11101 | ? "Default" | |
11102 | : bgp->name); | |
11103 | update_group_show(bgp, afi, safi, vty, 0); | |
11104 | } | |
f186de26 | 11105 | } |
11106 | ||
d62a17ae | 11107 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
11108 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 11109 | { |
d62a17ae | 11110 | struct bgp *bgp; |
4fb25c53 | 11111 | |
d62a17ae | 11112 | if (name) { |
11113 | if (strmatch(name, "all")) { | |
11114 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
11115 | return CMD_SUCCESS; | |
11116 | } else { | |
11117 | bgp = bgp_lookup_by_name(name); | |
11118 | } | |
11119 | } else { | |
11120 | bgp = bgp_get_default(); | |
11121 | } | |
4fb25c53 | 11122 | |
d62a17ae | 11123 | if (bgp) |
11124 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
11125 | return CMD_SUCCESS; | |
4fb25c53 DW |
11126 | } |
11127 | ||
8fe8a7f6 DS |
11128 | DEFUN (show_ip_bgp_updgrps, |
11129 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 11130 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 11131 | SHOW_STR |
11132 | IP_STR | |
11133 | BGP_STR | |
11134 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 11135 | BGP_AFI_HELP_STR |
9bedbb1e | 11136 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
11137 | "Detailed info about dynamic update groups\n" |
11138 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 11139 | { |
d62a17ae | 11140 | char *vrf = NULL; |
11141 | afi_t afi = AFI_IP6; | |
11142 | safi_t safi = SAFI_UNICAST; | |
11143 | uint64_t subgrp_id = 0; | |
11144 | ||
11145 | int idx = 0; | |
11146 | ||
11147 | /* show [ip] bgp */ | |
11148 | if (argv_find(argv, argc, "ip", &idx)) | |
11149 | afi = AFI_IP; | |
11150 | /* [<view|vrf> VIEWVRFNAME] */ | |
11151 | if (argv_find(argv, argc, "view", &idx) | |
11152 | || argv_find(argv, argc, "vrf", &idx)) | |
11153 | vrf = argv[++idx]->arg; | |
11154 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ | |
11155 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11156 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11157 | } | |
5bf15956 | 11158 | |
d62a17ae | 11159 | /* get subgroup id, if provided */ |
11160 | idx = argc - 1; | |
11161 | if (argv[idx]->type == VARIABLE_TKN) | |
11162 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 11163 | |
d62a17ae | 11164 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
11165 | } |
11166 | ||
f186de26 | 11167 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
11168 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 11169 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 11170 | SHOW_STR |
716b2d8a | 11171 | IP_STR |
f186de26 | 11172 | BGP_STR |
11173 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 11174 | "Detailed info about dynamic update groups\n") |
f186de26 | 11175 | { |
d62a17ae | 11176 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
11177 | return CMD_SUCCESS; | |
f186de26 | 11178 | } |
11179 | ||
5bf15956 DW |
11180 | DEFUN (show_bgp_updgrps_stats, |
11181 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 11182 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 11183 | SHOW_STR |
716b2d8a | 11184 | IP_STR |
3f9c7369 | 11185 | BGP_STR |
0c7b1b01 | 11186 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
11187 | "Statistics\n") |
11188 | { | |
d62a17ae | 11189 | struct bgp *bgp; |
3f9c7369 | 11190 | |
d62a17ae | 11191 | bgp = bgp_get_default(); |
11192 | if (bgp) | |
11193 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 11194 | |
d62a17ae | 11195 | return CMD_SUCCESS; |
3f9c7369 DS |
11196 | } |
11197 | ||
8386ac43 | 11198 | DEFUN (show_bgp_instance_updgrps_stats, |
11199 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 11200 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 11201 | SHOW_STR |
716b2d8a | 11202 | IP_STR |
8386ac43 | 11203 | BGP_STR |
11204 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 11205 | "Detailed info about dynamic update groups\n" |
8386ac43 | 11206 | "Statistics\n") |
11207 | { | |
d62a17ae | 11208 | int idx_word = 3; |
11209 | struct bgp *bgp; | |
8386ac43 | 11210 | |
d62a17ae | 11211 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
11212 | if (bgp) | |
11213 | update_group_show_stats(bgp, vty); | |
8386ac43 | 11214 | |
d62a17ae | 11215 | return CMD_SUCCESS; |
8386ac43 | 11216 | } |
11217 | ||
d62a17ae | 11218 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
11219 | afi_t afi, safi_t safi, | |
11220 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 11221 | { |
d62a17ae | 11222 | struct bgp *bgp; |
8386ac43 | 11223 | |
d62a17ae | 11224 | if (name) |
11225 | bgp = bgp_lookup_by_name(name); | |
11226 | else | |
11227 | bgp = bgp_get_default(); | |
8386ac43 | 11228 | |
d62a17ae | 11229 | if (bgp) { |
11230 | if (!strcmp(what, "advertise-queue")) | |
11231 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
11232 | subgrp_id); | |
11233 | else if (!strcmp(what, "advertised-routes")) | |
11234 | update_group_show_advertised(bgp, afi, safi, vty, | |
11235 | subgrp_id); | |
11236 | else if (!strcmp(what, "packet-queue")) | |
11237 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
11238 | subgrp_id); | |
11239 | } | |
3f9c7369 DS |
11240 | } |
11241 | ||
dc64bdec QY |
11242 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
11243 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
11244 | "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", | |
11245 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
11246 | BGP_SAFI_HELP_STR | |
11247 | "Detailed info about dynamic update groups\n" | |
11248 | "Specific subgroup to display info for\n" | |
11249 | "Advertisement queue\n" | |
11250 | "Announced routes\n" | |
11251 | "Packet queue\n") | |
3f9c7369 | 11252 | { |
dc64bdec QY |
11253 | uint64_t subgrp_id = 0; |
11254 | afi_t afiz; | |
11255 | safi_t safiz; | |
11256 | if (sgid) | |
11257 | subgrp_id = strtoull(sgid, NULL, 10); | |
11258 | ||
11259 | if (!ip && !afi) | |
11260 | afiz = AFI_IP6; | |
11261 | if (!ip && afi) | |
11262 | afiz = bgp_vty_afi_from_str(afi); | |
11263 | if (ip && !afi) | |
11264 | afiz = AFI_IP; | |
11265 | if (ip && afi) { | |
11266 | afiz = bgp_vty_afi_from_str(afi); | |
11267 | if (afiz != AFI_IP) | |
11268 | vty_out(vty, | |
11269 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
11270 | return CMD_WARNING; | |
11271 | } | |
d62a17ae | 11272 | |
dc64bdec | 11273 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 11274 | |
dc64bdec | 11275 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 11276 | return CMD_SUCCESS; |
11277 | } | |
11278 | ||
d62a17ae | 11279 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
11280 | { | |
11281 | struct listnode *node, *nnode; | |
11282 | struct prefix *range; | |
11283 | struct peer *conf; | |
11284 | struct peer *peer; | |
11285 | char buf[PREFIX2STR_BUFFER]; | |
11286 | afi_t afi; | |
11287 | safi_t safi; | |
11288 | const char *peer_status; | |
11289 | const char *af_str; | |
11290 | int lr_count; | |
11291 | int dynamic; | |
11292 | int af_cfgd; | |
11293 | ||
11294 | conf = group->conf; | |
11295 | ||
11296 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
11297 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
11298 | conf->as); | |
11299 | } else if (conf->as_type == AS_INTERNAL) { | |
11300 | vty_out(vty, "\nBGP peer-group %s, remote AS %d\n", group->name, | |
11301 | group->bgp->as); | |
11302 | } else { | |
11303 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
11304 | } | |
f14e6fdb | 11305 | |
d62a17ae | 11306 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
11307 | vty_out(vty, " Peer-group type is internal\n"); | |
11308 | else | |
11309 | vty_out(vty, " Peer-group type is external\n"); | |
11310 | ||
11311 | /* Display AFs configured. */ | |
11312 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
11313 | FOREACH_AFI_SAFI (afi, safi) { |
11314 | if (conf->afc[afi][safi]) { | |
11315 | af_cfgd = 1; | |
11316 | vty_out(vty, " %s;", afi_safi_print(afi, safi)); | |
d62a17ae | 11317 | } |
05c7a1cc | 11318 | } |
d62a17ae | 11319 | if (!af_cfgd) |
11320 | vty_out(vty, " none\n"); | |
11321 | else | |
11322 | vty_out(vty, "\n"); | |
11323 | ||
11324 | /* Display listen ranges (for dynamic neighbors), if any */ | |
11325 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
11326 | if (afi == AFI_IP) | |
11327 | af_str = "IPv4"; | |
11328 | else if (afi == AFI_IP6) | |
11329 | af_str = "IPv6"; | |
11330 | else | |
11331 | af_str = "???"; | |
11332 | lr_count = listcount(group->listen_range[afi]); | |
11333 | if (lr_count) { | |
11334 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
11335 | af_str); | |
11336 | ||
11337 | ||
11338 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
11339 | nnode, range)) { | |
11340 | prefix2str(range, buf, sizeof(buf)); | |
11341 | vty_out(vty, " %s\n", buf); | |
11342 | } | |
11343 | } | |
11344 | } | |
f14e6fdb | 11345 | |
d62a17ae | 11346 | /* Display group members and their status */ |
11347 | if (listcount(group->peer)) { | |
11348 | vty_out(vty, " Peer-group members:\n"); | |
11349 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
11350 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
11351 | peer_status = "Idle (Admin)"; | |
11352 | else if (CHECK_FLAG(peer->sflags, | |
11353 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11354 | peer_status = "Idle (PfxCt)"; | |
11355 | else | |
11356 | peer_status = lookup_msg(bgp_status_msg, | |
11357 | peer->status, NULL); | |
11358 | ||
11359 | dynamic = peer_dynamic_neighbor(peer); | |
11360 | vty_out(vty, " %s %s %s \n", peer->host, | |
11361 | dynamic ? "(dynamic)" : "", peer_status); | |
11362 | } | |
11363 | } | |
f14e6fdb | 11364 | |
d62a17ae | 11365 | return CMD_SUCCESS; |
11366 | } | |
11367 | ||
ff9959b0 QY |
11368 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
11369 | const char *group_name) | |
d62a17ae | 11370 | { |
ff9959b0 | 11371 | struct bgp *bgp; |
d62a17ae | 11372 | struct listnode *node, *nnode; |
11373 | struct peer_group *group; | |
ff9959b0 QY |
11374 | bool found = false; |
11375 | ||
11376 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
11377 | ||
11378 | if (!bgp) { | |
11379 | vty_out(vty, "%% No such BGP instance exists\n"); | |
11380 | return CMD_WARNING; | |
11381 | } | |
d62a17ae | 11382 | |
11383 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
11384 | if (group_name) { |
11385 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 11386 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
11387 | found = true; |
11388 | break; | |
d62a17ae | 11389 | } |
ff9959b0 QY |
11390 | } else { |
11391 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 11392 | } |
f14e6fdb | 11393 | } |
f14e6fdb | 11394 | |
ff9959b0 | 11395 | if (group_name && !found) |
d62a17ae | 11396 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 11397 | |
d62a17ae | 11398 | return CMD_SUCCESS; |
f14e6fdb DS |
11399 | } |
11400 | ||
f14e6fdb DS |
11401 | DEFUN (show_ip_bgp_peer_groups, |
11402 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 11403 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
11404 | SHOW_STR |
11405 | IP_STR | |
11406 | BGP_STR | |
8386ac43 | 11407 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
11408 | "Detailed information on BGP peer groups\n" |
11409 | "Peer group name\n") | |
f14e6fdb | 11410 | { |
d62a17ae | 11411 | char *vrf, *pg; |
d62a17ae | 11412 | int idx = 0; |
f14e6fdb | 11413 | |
a4d82a8a PZ |
11414 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
11415 | : NULL; | |
d62a17ae | 11416 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 11417 | |
ff9959b0 | 11418 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 11419 | } |
3f9c7369 | 11420 | |
d6e3c605 | 11421 | |
718e3744 | 11422 | /* Redistribute VTY commands. */ |
11423 | ||
718e3744 | 11424 | DEFUN (bgp_redistribute_ipv4, |
11425 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 11426 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 11427 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11428 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 11429 | { |
d62a17ae | 11430 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11431 | int idx_protocol = 1; | |
11432 | int type; | |
718e3744 | 11433 | |
d62a17ae | 11434 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
11435 | if (type < 0) { | |
11436 | vty_out(vty, "%% Invalid route type\n"); | |
11437 | return CMD_WARNING_CONFIG_FAILED; | |
11438 | } | |
7f323236 | 11439 | |
d62a17ae | 11440 | bgp_redist_add(bgp, AFI_IP, type, 0); |
11441 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
718e3744 | 11442 | } |
11443 | ||
d62a17ae | 11444 | ALIAS_HIDDEN( |
11445 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
11446 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
11447 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 11448 | |
718e3744 | 11449 | DEFUN (bgp_redistribute_ipv4_rmap, |
11450 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 11451 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 11452 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11453 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11454 | "Route map reference\n" |
11455 | "Pointer to route-map entries\n") | |
11456 | { | |
d62a17ae | 11457 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11458 | int idx_protocol = 1; | |
11459 | int idx_word = 3; | |
11460 | int type; | |
11461 | struct bgp_redist *red; | |
718e3744 | 11462 | |
d62a17ae | 11463 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
11464 | if (type < 0) { | |
11465 | vty_out(vty, "%% Invalid route type\n"); | |
11466 | return CMD_WARNING_CONFIG_FAILED; | |
11467 | } | |
718e3744 | 11468 | |
d62a17ae | 11469 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
11470 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11471 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
718e3744 | 11472 | } |
11473 | ||
d62a17ae | 11474 | ALIAS_HIDDEN( |
11475 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
11476 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
11477 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11478 | "Route map reference\n" | |
11479 | "Pointer to route-map entries\n") | |
596c17ba | 11480 | |
718e3744 | 11481 | DEFUN (bgp_redistribute_ipv4_metric, |
11482 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 11483 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 11484 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11485 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11486 | "Metric for redistributed routes\n" |
11487 | "Default metric\n") | |
11488 | { | |
d62a17ae | 11489 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11490 | int idx_protocol = 1; | |
11491 | int idx_number = 3; | |
11492 | int type; | |
d7c0a89a | 11493 | uint32_t metric; |
d62a17ae | 11494 | struct bgp_redist *red; |
11495 | ||
11496 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11497 | if (type < 0) { | |
11498 | vty_out(vty, "%% Invalid route type\n"); | |
11499 | return CMD_WARNING_CONFIG_FAILED; | |
11500 | } | |
11501 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11502 | ||
11503 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
11504 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
11505 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
11506 | } | |
11507 | ||
11508 | ALIAS_HIDDEN( | |
11509 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
11510 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
11511 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11512 | "Metric for redistributed routes\n" | |
11513 | "Default metric\n") | |
596c17ba | 11514 | |
718e3744 | 11515 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
11516 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 11517 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 11518 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11519 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11520 | "Route map reference\n" |
11521 | "Pointer to route-map entries\n" | |
11522 | "Metric for redistributed routes\n" | |
11523 | "Default metric\n") | |
11524 | { | |
d62a17ae | 11525 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11526 | int idx_protocol = 1; | |
11527 | int idx_word = 3; | |
11528 | int idx_number = 5; | |
11529 | int type; | |
d7c0a89a | 11530 | uint32_t metric; |
d62a17ae | 11531 | struct bgp_redist *red; |
11532 | ||
11533 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11534 | if (type < 0) { | |
11535 | vty_out(vty, "%% Invalid route type\n"); | |
11536 | return CMD_WARNING_CONFIG_FAILED; | |
11537 | } | |
11538 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11539 | ||
11540 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
11541 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11542 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
11543 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
11544 | } | |
11545 | ||
11546 | ALIAS_HIDDEN( | |
11547 | bgp_redistribute_ipv4_rmap_metric, | |
11548 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
11549 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
11550 | " route-map WORD metric (0-4294967295)", | |
11551 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11552 | "Route map reference\n" | |
11553 | "Pointer to route-map entries\n" | |
11554 | "Metric for redistributed routes\n" | |
11555 | "Default metric\n") | |
596c17ba | 11556 | |
718e3744 | 11557 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
11558 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 11559 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 11560 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11561 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11562 | "Metric for redistributed routes\n" |
11563 | "Default metric\n" | |
11564 | "Route map reference\n" | |
11565 | "Pointer to route-map entries\n") | |
11566 | { | |
d62a17ae | 11567 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11568 | int idx_protocol = 1; | |
11569 | int idx_number = 3; | |
11570 | int idx_word = 5; | |
11571 | int type; | |
d7c0a89a | 11572 | uint32_t metric; |
d62a17ae | 11573 | struct bgp_redist *red; |
11574 | ||
11575 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11576 | if (type < 0) { | |
11577 | vty_out(vty, "%% Invalid route type\n"); | |
11578 | return CMD_WARNING_CONFIG_FAILED; | |
11579 | } | |
11580 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11581 | ||
11582 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
11583 | bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); | |
11584 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11585 | return bgp_redistribute_set(bgp, AFI_IP, type, 0); | |
11586 | } | |
11587 | ||
11588 | ALIAS_HIDDEN( | |
11589 | bgp_redistribute_ipv4_metric_rmap, | |
11590 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
11591 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
11592 | " metric (0-4294967295) route-map WORD", | |
11593 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11594 | "Metric for redistributed routes\n" | |
11595 | "Default metric\n" | |
11596 | "Route map reference\n" | |
11597 | "Pointer to route-map entries\n") | |
596c17ba | 11598 | |
7c8ff89e DS |
11599 | DEFUN (bgp_redistribute_ipv4_ospf, |
11600 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 11601 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
11602 | "Redistribute information from another routing protocol\n" |
11603 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11604 | "Non-main Kernel Routing Table\n" |
11605 | "Instance ID/Table ID\n") | |
7c8ff89e | 11606 | { |
d62a17ae | 11607 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11608 | int idx_ospf_table = 1; | |
11609 | int idx_number = 2; | |
d7c0a89a QY |
11610 | unsigned short instance; |
11611 | unsigned short protocol; | |
7c8ff89e | 11612 | |
d62a17ae | 11613 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 11614 | |
d62a17ae | 11615 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
11616 | protocol = ZEBRA_ROUTE_OSPF; | |
11617 | else | |
11618 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 11619 | |
d62a17ae | 11620 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
11621 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
7c8ff89e DS |
11622 | } |
11623 | ||
d62a17ae | 11624 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
11625 | "redistribute <ospf|table> (1-65535)", | |
11626 | "Redistribute information from another routing protocol\n" | |
11627 | "Open Shortest Path First (OSPFv2)\n" | |
11628 | "Non-main Kernel Routing Table\n" | |
11629 | "Instance ID/Table ID\n") | |
596c17ba | 11630 | |
7c8ff89e DS |
11631 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
11632 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 11633 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
11634 | "Redistribute information from another routing protocol\n" |
11635 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11636 | "Non-main Kernel Routing Table\n" |
11637 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
11638 | "Route map reference\n" |
11639 | "Pointer to route-map entries\n") | |
11640 | { | |
d62a17ae | 11641 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11642 | int idx_ospf_table = 1; | |
11643 | int idx_number = 2; | |
11644 | int idx_word = 4; | |
11645 | struct bgp_redist *red; | |
d7c0a89a | 11646 | unsigned short instance; |
d62a17ae | 11647 | int protocol; |
11648 | ||
11649 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11650 | protocol = ZEBRA_ROUTE_OSPF; | |
11651 | else | |
11652 | protocol = ZEBRA_ROUTE_TABLE; | |
11653 | ||
11654 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11655 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
11656 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11657 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
11658 | } | |
11659 | ||
11660 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
11661 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
11662 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
11663 | "Redistribute information from another routing protocol\n" | |
11664 | "Open Shortest Path First (OSPFv2)\n" | |
11665 | "Non-main Kernel Routing Table\n" | |
11666 | "Instance ID/Table ID\n" | |
11667 | "Route map reference\n" | |
11668 | "Pointer to route-map entries\n") | |
596c17ba | 11669 | |
7c8ff89e DS |
11670 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
11671 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 11672 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
11673 | "Redistribute information from another routing protocol\n" |
11674 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11675 | "Non-main Kernel Routing Table\n" |
11676 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
11677 | "Metric for redistributed routes\n" |
11678 | "Default metric\n") | |
11679 | { | |
d62a17ae | 11680 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11681 | int idx_ospf_table = 1; | |
11682 | int idx_number = 2; | |
11683 | int idx_number_2 = 4; | |
d7c0a89a | 11684 | uint32_t metric; |
d62a17ae | 11685 | struct bgp_redist *red; |
d7c0a89a | 11686 | unsigned short instance; |
d62a17ae | 11687 | int protocol; |
11688 | ||
11689 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11690 | protocol = ZEBRA_ROUTE_OSPF; | |
11691 | else | |
11692 | protocol = ZEBRA_ROUTE_TABLE; | |
11693 | ||
11694 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11695 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
11696 | ||
11697 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
11698 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
11699 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
11700 | } | |
11701 | ||
11702 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
11703 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
11704 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
11705 | "Redistribute information from another routing protocol\n" | |
11706 | "Open Shortest Path First (OSPFv2)\n" | |
11707 | "Non-main Kernel Routing Table\n" | |
11708 | "Instance ID/Table ID\n" | |
11709 | "Metric for redistributed routes\n" | |
11710 | "Default metric\n") | |
596c17ba | 11711 | |
7c8ff89e DS |
11712 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
11713 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 11714 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
11715 | "Redistribute information from another routing protocol\n" |
11716 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11717 | "Non-main Kernel Routing Table\n" |
11718 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
11719 | "Route map reference\n" |
11720 | "Pointer to route-map entries\n" | |
11721 | "Metric for redistributed routes\n" | |
11722 | "Default metric\n") | |
11723 | { | |
d62a17ae | 11724 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11725 | int idx_ospf_table = 1; | |
11726 | int idx_number = 2; | |
11727 | int idx_word = 4; | |
11728 | int idx_number_2 = 6; | |
d7c0a89a | 11729 | uint32_t metric; |
d62a17ae | 11730 | struct bgp_redist *red; |
d7c0a89a | 11731 | unsigned short instance; |
d62a17ae | 11732 | int protocol; |
11733 | ||
11734 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11735 | protocol = ZEBRA_ROUTE_OSPF; | |
11736 | else | |
11737 | protocol = ZEBRA_ROUTE_TABLE; | |
11738 | ||
11739 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11740 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
11741 | ||
11742 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
11743 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11744 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
11745 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
11746 | } | |
11747 | ||
11748 | ALIAS_HIDDEN( | |
11749 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
11750 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
11751 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
11752 | "Redistribute information from another routing protocol\n" | |
11753 | "Open Shortest Path First (OSPFv2)\n" | |
11754 | "Non-main Kernel Routing Table\n" | |
11755 | "Instance ID/Table ID\n" | |
11756 | "Route map reference\n" | |
11757 | "Pointer to route-map entries\n" | |
11758 | "Metric for redistributed routes\n" | |
11759 | "Default metric\n") | |
596c17ba | 11760 | |
7c8ff89e DS |
11761 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
11762 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 11763 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
11764 | "Redistribute information from another routing protocol\n" |
11765 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
11766 | "Non-main Kernel Routing Table\n" |
11767 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
11768 | "Metric for redistributed routes\n" |
11769 | "Default metric\n" | |
11770 | "Route map reference\n" | |
11771 | "Pointer to route-map entries\n") | |
11772 | { | |
d62a17ae | 11773 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11774 | int idx_ospf_table = 1; | |
11775 | int idx_number = 2; | |
11776 | int idx_number_2 = 4; | |
11777 | int idx_word = 6; | |
d7c0a89a | 11778 | uint32_t metric; |
d62a17ae | 11779 | struct bgp_redist *red; |
d7c0a89a | 11780 | unsigned short instance; |
d62a17ae | 11781 | int protocol; |
11782 | ||
11783 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11784 | protocol = ZEBRA_ROUTE_OSPF; | |
11785 | else | |
11786 | protocol = ZEBRA_ROUTE_TABLE; | |
11787 | ||
11788 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11789 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
11790 | ||
11791 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
11792 | bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, metric); | |
11793 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11794 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance); | |
11795 | } | |
11796 | ||
11797 | ALIAS_HIDDEN( | |
11798 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
11799 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
11800 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
11801 | "Redistribute information from another routing protocol\n" | |
11802 | "Open Shortest Path First (OSPFv2)\n" | |
11803 | "Non-main Kernel Routing Table\n" | |
11804 | "Instance ID/Table ID\n" | |
11805 | "Metric for redistributed routes\n" | |
11806 | "Default metric\n" | |
11807 | "Route map reference\n" | |
11808 | "Pointer to route-map entries\n") | |
596c17ba | 11809 | |
7c8ff89e DS |
11810 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
11811 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 11812 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
11813 | NO_STR |
11814 | "Redistribute information from another routing protocol\n" | |
11815 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 11816 | "Non-main Kernel Routing Table\n" |
31500417 DW |
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") | |
7c8ff89e | 11822 | { |
d62a17ae | 11823 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11824 | int idx_ospf_table = 2; | |
11825 | int idx_number = 3; | |
d7c0a89a | 11826 | unsigned short instance; |
d62a17ae | 11827 | int protocol; |
11828 | ||
11829 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
11830 | protocol = ZEBRA_ROUTE_OSPF; | |
11831 | else | |
11832 | protocol = ZEBRA_ROUTE_TABLE; | |
11833 | ||
11834 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
11835 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
11836 | } | |
11837 | ||
11838 | ALIAS_HIDDEN( | |
11839 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
11840 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", | |
11841 | NO_STR | |
11842 | "Redistribute information from another routing protocol\n" | |
11843 | "Open Shortest Path First (OSPFv2)\n" | |
11844 | "Non-main Kernel Routing Table\n" | |
11845 | "Instance ID/Table ID\n" | |
11846 | "Metric for redistributed routes\n" | |
11847 | "Default metric\n" | |
11848 | "Route map reference\n" | |
11849 | "Pointer to route-map entries\n") | |
596c17ba | 11850 | |
718e3744 | 11851 | DEFUN (no_bgp_redistribute_ipv4, |
11852 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 11853 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 11854 | NO_STR |
11855 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 11856 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
11857 | "Metric for redistributed routes\n" |
11858 | "Default metric\n" | |
11859 | "Route map reference\n" | |
11860 | "Pointer to route-map entries\n") | |
718e3744 | 11861 | { |
d62a17ae | 11862 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11863 | int idx_protocol = 2; | |
11864 | int type; | |
11865 | ||
11866 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11867 | if (type < 0) { | |
11868 | vty_out(vty, "%% Invalid route type\n"); | |
11869 | return CMD_WARNING_CONFIG_FAILED; | |
11870 | } | |
11871 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
11872 | } | |
11873 | ||
11874 | ALIAS_HIDDEN( | |
11875 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
11876 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
11877 | " [metric (0-4294967295)] [route-map WORD]", | |
11878 | NO_STR | |
11879 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11880 | "Metric for redistributed routes\n" | |
11881 | "Default metric\n" | |
11882 | "Route map reference\n" | |
11883 | "Pointer to route-map entries\n") | |
596c17ba | 11884 | |
718e3744 | 11885 | DEFUN (bgp_redistribute_ipv6, |
11886 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 11887 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 11888 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11889 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 11890 | { |
d62a17ae | 11891 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11892 | int idx_protocol = 1; | |
11893 | int type; | |
718e3744 | 11894 | |
d62a17ae | 11895 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
11896 | if (type < 0) { | |
11897 | vty_out(vty, "%% Invalid route type\n"); | |
11898 | return CMD_WARNING_CONFIG_FAILED; | |
11899 | } | |
718e3744 | 11900 | |
d62a17ae | 11901 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
11902 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11903 | } |
11904 | ||
11905 | DEFUN (bgp_redistribute_ipv6_rmap, | |
11906 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 11907 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 11908 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11909 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11910 | "Route map reference\n" |
11911 | "Pointer to route-map entries\n") | |
11912 | { | |
d62a17ae | 11913 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11914 | int idx_protocol = 1; | |
11915 | int idx_word = 3; | |
11916 | int type; | |
11917 | struct bgp_redist *red; | |
718e3744 | 11918 | |
d62a17ae | 11919 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
11920 | if (type < 0) { | |
11921 | vty_out(vty, "%% Invalid route type\n"); | |
11922 | return CMD_WARNING_CONFIG_FAILED; | |
11923 | } | |
718e3744 | 11924 | |
d62a17ae | 11925 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11926 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11927 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11928 | } |
11929 | ||
11930 | DEFUN (bgp_redistribute_ipv6_metric, | |
11931 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 11932 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 11933 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11934 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11935 | "Metric for redistributed routes\n" |
11936 | "Default metric\n") | |
11937 | { | |
d62a17ae | 11938 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11939 | int idx_protocol = 1; | |
11940 | int idx_number = 3; | |
11941 | int type; | |
d7c0a89a | 11942 | uint32_t metric; |
d62a17ae | 11943 | struct bgp_redist *red; |
11944 | ||
11945 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
11946 | if (type < 0) { | |
11947 | vty_out(vty, "%% Invalid route type\n"); | |
11948 | return CMD_WARNING_CONFIG_FAILED; | |
11949 | } | |
11950 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 11951 | |
d62a17ae | 11952 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11953 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
11954 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11955 | } |
11956 | ||
11957 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
11958 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 11959 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 11960 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11961 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11962 | "Route map reference\n" |
11963 | "Pointer to route-map entries\n" | |
11964 | "Metric for redistributed routes\n" | |
11965 | "Default metric\n") | |
11966 | { | |
d62a17ae | 11967 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11968 | int idx_protocol = 1; | |
11969 | int idx_word = 3; | |
11970 | int idx_number = 5; | |
11971 | int type; | |
d7c0a89a | 11972 | uint32_t metric; |
d62a17ae | 11973 | struct bgp_redist *red; |
11974 | ||
11975 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
11976 | if (type < 0) { | |
11977 | vty_out(vty, "%% Invalid route type\n"); | |
11978 | return CMD_WARNING_CONFIG_FAILED; | |
11979 | } | |
11980 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 11981 | |
d62a17ae | 11982 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
11983 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
11984 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); | |
11985 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 11986 | } |
11987 | ||
11988 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
11989 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 11990 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 11991 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11992 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 11993 | "Metric for redistributed routes\n" |
11994 | "Default metric\n" | |
11995 | "Route map reference\n" | |
11996 | "Pointer to route-map entries\n") | |
11997 | { | |
d62a17ae | 11998 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11999 | int idx_protocol = 1; | |
12000 | int idx_number = 3; | |
12001 | int idx_word = 5; | |
12002 | int type; | |
d7c0a89a | 12003 | uint32_t metric; |
d62a17ae | 12004 | struct bgp_redist *red; |
12005 | ||
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 | } | |
12011 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12012 | |
d62a17ae | 12013 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
12014 | bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, metric); | |
12015 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg); | |
12016 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0); | |
718e3744 | 12017 | } |
12018 | ||
12019 | DEFUN (no_bgp_redistribute_ipv6, | |
12020 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 12021 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 12022 | NO_STR |
12023 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12024 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
12025 | "Metric for redistributed routes\n" |
12026 | "Default metric\n" | |
12027 | "Route map reference\n" | |
12028 | "Pointer to route-map entries\n") | |
718e3744 | 12029 | { |
d62a17ae | 12030 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12031 | int idx_protocol = 2; | |
12032 | int type; | |
718e3744 | 12033 | |
d62a17ae | 12034 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12035 | if (type < 0) { | |
12036 | vty_out(vty, "%% Invalid route type\n"); | |
12037 | return CMD_WARNING_CONFIG_FAILED; | |
12038 | } | |
718e3744 | 12039 | |
d62a17ae | 12040 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
12041 | } | |
12042 | ||
2b791107 | 12043 | void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 12044 | safi_t safi) |
d62a17ae | 12045 | { |
12046 | int i; | |
12047 | ||
12048 | /* Unicast redistribution only. */ | |
12049 | if (safi != SAFI_UNICAST) | |
2b791107 | 12050 | return; |
d62a17ae | 12051 | |
12052 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
12053 | /* Redistribute BGP does not make sense. */ | |
12054 | if (i != ZEBRA_ROUTE_BGP) { | |
12055 | struct list *red_list; | |
12056 | struct listnode *node; | |
12057 | struct bgp_redist *red; | |
12058 | ||
12059 | red_list = bgp->redist[afi][i]; | |
12060 | if (!red_list) | |
12061 | continue; | |
12062 | ||
12063 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 12064 | /* "redistribute" configuration. */ |
12065 | vty_out(vty, " redistribute %s", | |
12066 | zebra_route_string(i)); | |
12067 | if (red->instance) | |
12068 | vty_out(vty, " %d", red->instance); | |
12069 | if (red->redist_metric_flag) | |
12070 | vty_out(vty, " metric %u", | |
12071 | red->redist_metric); | |
12072 | if (red->rmap.name) | |
12073 | vty_out(vty, " route-map %s", | |
12074 | red->rmap.name); | |
12075 | vty_out(vty, "\n"); | |
12076 | } | |
12077 | } | |
12078 | } | |
718e3744 | 12079 | } |
6b0655a2 | 12080 | |
b9c7bc5a PZ |
12081 | /* This is part of the address-family block (unicast only) */ |
12082 | void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, | |
ddb5b488 PZ |
12083 | afi_t afi) |
12084 | { | |
b9c7bc5a | 12085 | int indent = 2; |
ddb5b488 | 12086 | |
bb4f6190 DS |
12087 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) |
12088 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", | |
12089 | bgp->vpn_policy[afi] | |
12090 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
12091 | ||
12a844a5 DS |
12092 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
12093 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
12094 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
12095 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
12096 | return; | |
12097 | ||
e70e9f8e PZ |
12098 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
12099 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
12100 | ||
12101 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
12102 | ||
12103 | } else { | |
12104 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
12105 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
12106 | bgp->vpn_policy[afi].tovpn_label); | |
12107 | } | |
ddb5b488 PZ |
12108 | } |
12109 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12110 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
12111 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 12112 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
12113 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
12114 | sizeof(buf))); | |
12115 | } | |
12116 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12117 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
12118 | ||
12119 | char buf[PREFIX_STRLEN]; | |
12120 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
12121 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
12122 | sizeof(buf))) { | |
12123 | ||
b9c7bc5a PZ |
12124 | vty_out(vty, "%*snexthop vpn export %s\n", |
12125 | indent, "", buf); | |
ddb5b488 PZ |
12126 | } |
12127 | } | |
12128 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
12129 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
12130 | && ecommunity_cmp( | |
12131 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12132 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
12133 | ||
12134 | char *b = ecommunity_ecom2str( | |
12135 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12136 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12137 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
12138 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12139 | } else { | |
12140 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
12141 | char *b = ecommunity_ecom2str( | |
12142 | bgp->vpn_policy[afi] | |
12143 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12144 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12145 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12146 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
12147 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12148 | } | |
12149 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
12150 | char *b = ecommunity_ecom2str( | |
12151 | bgp->vpn_policy[afi] | |
12152 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12153 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12154 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12155 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
12156 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12157 | } | |
12158 | } | |
bb4f6190 DS |
12159 | |
12160 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 12161 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
12162 | bgp->vpn_policy[afi] |
12163 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 12164 | |
301ad80a PG |
12165 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
12166 | char *b = ecommunity_ecom2str( | |
12167 | bgp->vpn_policy[afi] | |
12168 | .import_redirect_rtlist, | |
12169 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12170 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 12171 | |
301ad80a PG |
12172 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
12173 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
12174 | } | |
ddb5b488 PZ |
12175 | } |
12176 | ||
12177 | ||
718e3744 | 12178 | /* BGP node structure. */ |
d62a17ae | 12179 | static struct cmd_node bgp_node = { |
9d303b37 | 12180 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 12181 | }; |
12182 | ||
d62a17ae | 12183 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 12184 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12185 | }; |
12186 | ||
d62a17ae | 12187 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 12188 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12189 | }; |
12190 | ||
d62a17ae | 12191 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 12192 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12193 | }; |
12194 | ||
d62a17ae | 12195 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 12196 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12197 | }; |
12198 | ||
d62a17ae | 12199 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 12200 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 12201 | }; |
12202 | ||
d62a17ae | 12203 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 12204 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12205 | }; |
12206 | ||
d62a17ae | 12207 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
12208 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 12209 | |
d62a17ae | 12210 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
12211 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 12212 | |
d62a17ae | 12213 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
12214 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 12215 | |
d62a17ae | 12216 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
12217 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 12218 | |
7c40bf39 | 12219 | static struct cmd_node bgp_flowspecv4_node = {BGP_FLOWSPECV4_NODE, |
12220 | "%s(config-router-af)# ", 1}; | |
12221 | ||
12222 | static struct cmd_node bgp_flowspecv6_node = {BGP_FLOWSPECV6_NODE, | |
12223 | "%s(config-router-af-vpnv6)# ", 1}; | |
12224 | ||
d62a17ae | 12225 | static void community_list_vty(void); |
1f8ae70b | 12226 | |
d62a17ae | 12227 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 12228 | { |
d62a17ae | 12229 | struct bgp *bgp; |
12230 | struct peer *peer; | |
d62a17ae | 12231 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 12232 | |
d62a17ae | 12233 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
12234 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
12235 | /* only provide suggestions on the appropriate input | |
12236 | * token type, | |
12237 | * they'll otherwise show up multiple times */ | |
12238 | enum cmd_token_type match_type; | |
12239 | char *name = peer->host; | |
d48ed3e0 | 12240 | |
d62a17ae | 12241 | if (peer->conf_if) { |
12242 | match_type = VARIABLE_TKN; | |
12243 | name = peer->conf_if; | |
12244 | } else if (strchr(peer->host, ':')) | |
12245 | match_type = IPV6_TKN; | |
12246 | else | |
12247 | match_type = IPV4_TKN; | |
d48ed3e0 | 12248 | |
d62a17ae | 12249 | if (token->type != match_type) |
12250 | continue; | |
d48ed3e0 | 12251 | |
d62a17ae | 12252 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
12253 | } | |
d62a17ae | 12254 | } |
b8a815e5 DL |
12255 | } |
12256 | ||
12257 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 12258 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
12259 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 12260 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 12261 | {.completions = NULL}}; |
12262 | ||
47a306a0 DS |
12263 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
12264 | { | |
12265 | struct bgp *bgp; | |
12266 | struct peer_group *group; | |
12267 | struct listnode *lnbgp, *lnpeer; | |
12268 | ||
12269 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
12270 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
12271 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
12272 | group->name)); | |
12273 | } | |
12274 | } | |
12275 | ||
12276 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
12277 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
12278 | {.completions = NULL} }; | |
12279 | ||
d62a17ae | 12280 | void bgp_vty_init(void) |
12281 | { | |
12282 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 12283 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 12284 | |
12285 | /* Install bgp top node. */ | |
12286 | install_node(&bgp_node, bgp_config_write); | |
12287 | install_node(&bgp_ipv4_unicast_node, NULL); | |
12288 | install_node(&bgp_ipv4_multicast_node, NULL); | |
12289 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
12290 | install_node(&bgp_ipv6_unicast_node, NULL); | |
12291 | install_node(&bgp_ipv6_multicast_node, NULL); | |
12292 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
12293 | install_node(&bgp_vpnv4_node, NULL); | |
12294 | install_node(&bgp_vpnv6_node, NULL); | |
12295 | install_node(&bgp_evpn_node, NULL); | |
12296 | install_node(&bgp_evpn_vni_node, NULL); | |
7c40bf39 | 12297 | install_node(&bgp_flowspecv4_node, NULL); |
12298 | install_node(&bgp_flowspecv6_node, NULL); | |
d62a17ae | 12299 | |
12300 | /* Install default VTY commands to new nodes. */ | |
12301 | install_default(BGP_NODE); | |
12302 | install_default(BGP_IPV4_NODE); | |
12303 | install_default(BGP_IPV4M_NODE); | |
12304 | install_default(BGP_IPV4L_NODE); | |
12305 | install_default(BGP_IPV6_NODE); | |
12306 | install_default(BGP_IPV6M_NODE); | |
12307 | install_default(BGP_IPV6L_NODE); | |
12308 | install_default(BGP_VPNV4_NODE); | |
12309 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 12310 | install_default(BGP_FLOWSPECV4_NODE); |
12311 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 12312 | install_default(BGP_EVPN_NODE); |
12313 | install_default(BGP_EVPN_VNI_NODE); | |
12314 | ||
12315 | /* "bgp multiple-instance" commands. */ | |
12316 | install_element(CONFIG_NODE, &bgp_multiple_instance_cmd); | |
12317 | install_element(CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
12318 | ||
12319 | /* "bgp config-type" commands. */ | |
12320 | install_element(CONFIG_NODE, &bgp_config_type_cmd); | |
12321 | install_element(CONFIG_NODE, &no_bgp_config_type_cmd); | |
12322 | ||
12323 | /* bgp route-map delay-timer commands. */ | |
12324 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
12325 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
12326 | ||
12327 | /* Dummy commands (Currently not supported) */ | |
12328 | install_element(BGP_NODE, &no_synchronization_cmd); | |
12329 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
12330 | ||
12331 | /* "router bgp" commands. */ | |
12332 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
12333 | ||
12334 | /* "no router bgp" commands. */ | |
12335 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
12336 | ||
12337 | /* "bgp router-id" commands. */ | |
12338 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
12339 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
12340 | ||
12341 | /* "bgp cluster-id" commands. */ | |
12342 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
12343 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
12344 | ||
12345 | /* "bgp confederation" commands. */ | |
12346 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
12347 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
12348 | ||
12349 | /* "bgp confederation peers" commands. */ | |
12350 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
12351 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
12352 | ||
12353 | /* bgp max-med command */ | |
12354 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
12355 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
12356 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
12357 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
12358 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
12359 | ||
12360 | /* bgp disable-ebgp-connected-nh-check */ | |
12361 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
12362 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
12363 | ||
12364 | /* bgp update-delay command */ | |
12365 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
12366 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
12367 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
12368 | ||
12369 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
12370 | install_element(BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
555e09d4 QY |
12371 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
12372 | install_element(BGP_NODE, &no_bgp_rpkt_quanta_cmd); | |
d62a17ae | 12373 | |
12374 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
12375 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
12376 | ||
12377 | /* "maximum-paths" commands. */ | |
12378 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
12379 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
12380 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
12381 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
12382 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
12383 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
12384 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
12385 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
12386 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
12387 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
12388 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12389 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12390 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
12391 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12392 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12393 | ||
12394 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
12395 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
12396 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
12397 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12398 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12399 | ||
12400 | /* "timers bgp" commands. */ | |
12401 | install_element(BGP_NODE, &bgp_timers_cmd); | |
12402 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
12403 | ||
12404 | /* route-map delay-timer commands - per instance for backwards compat. | |
12405 | */ | |
12406 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
12407 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
12408 | ||
12409 | /* "bgp client-to-client reflection" commands */ | |
12410 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
12411 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
12412 | ||
12413 | /* "bgp always-compare-med" commands */ | |
12414 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
12415 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
12416 | ||
12417 | /* "bgp deterministic-med" commands */ | |
12418 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
12419 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
12420 | ||
12421 | /* "bgp graceful-restart" commands */ | |
12422 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); | |
12423 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
12424 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); | |
12425 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
12426 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
12427 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
12428 | ||
12429 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); | |
12430 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
12431 | ||
7f323236 DW |
12432 | /* "bgp graceful-shutdown" commands */ |
12433 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
12434 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
12435 | ||
d62a17ae | 12436 | /* "bgp fast-external-failover" commands */ |
12437 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
12438 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
12439 | ||
12440 | /* "bgp enforce-first-as" commands */ | |
12441 | install_element(BGP_NODE, &bgp_enforce_first_as_cmd); | |
d62a17ae | 12442 | |
12443 | /* "bgp bestpath compare-routerid" commands */ | |
12444 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
12445 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
12446 | ||
12447 | /* "bgp bestpath as-path ignore" commands */ | |
12448 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
12449 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
12450 | ||
12451 | /* "bgp bestpath as-path confed" commands */ | |
12452 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
12453 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
12454 | ||
12455 | /* "bgp bestpath as-path multipath-relax" commands */ | |
12456 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
12457 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
12458 | ||
12459 | /* "bgp log-neighbor-changes" commands */ | |
12460 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
12461 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
12462 | ||
12463 | /* "bgp bestpath med" commands */ | |
12464 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
12465 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
12466 | ||
12467 | /* "no bgp default ipv4-unicast" commands. */ | |
12468 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
12469 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
12470 | ||
12471 | /* "bgp network import-check" commands. */ | |
12472 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
12473 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
12474 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
12475 | ||
12476 | /* "bgp default local-preference" commands. */ | |
12477 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
12478 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
12479 | ||
12480 | /* bgp default show-hostname */ | |
12481 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
12482 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
12483 | ||
12484 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
12485 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
12486 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
12487 | ||
12488 | /* bgp ibgp-allow-policy-mods command */ | |
12489 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
12490 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
12491 | ||
12492 | /* "bgp listen limit" commands. */ | |
12493 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
12494 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
12495 | ||
12496 | /* "bgp listen range" commands. */ | |
12497 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
12498 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
12499 | ||
8175f54a | 12500 | /* "bgp default shutdown" command */ |
f26845f9 QY |
12501 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
12502 | ||
d62a17ae | 12503 | /* "neighbor remote-as" commands. */ |
12504 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
12505 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
12506 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
12507 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
12508 | install_element(BGP_NODE, | |
12509 | &neighbor_interface_v6only_config_remote_as_cmd); | |
12510 | install_element(BGP_NODE, &no_neighbor_cmd); | |
12511 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
12512 | ||
12513 | /* "neighbor peer-group" commands. */ | |
12514 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
12515 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
12516 | install_element(BGP_NODE, | |
12517 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
12518 | ||
12519 | /* "neighbor local-as" commands. */ | |
12520 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
12521 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
12522 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
12523 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
12524 | ||
12525 | /* "neighbor solo" commands. */ | |
12526 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
12527 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
12528 | ||
12529 | /* "neighbor password" commands. */ | |
12530 | install_element(BGP_NODE, &neighbor_password_cmd); | |
12531 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
12532 | ||
12533 | /* "neighbor activate" commands. */ | |
12534 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
12535 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
12536 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
12537 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
12538 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
12539 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
12540 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
12541 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
12542 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 12543 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
12544 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 12545 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
12546 | ||
12547 | /* "no neighbor activate" commands. */ | |
12548 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
12549 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
12550 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
12551 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
12552 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
12553 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
12554 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
12555 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
12556 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 12557 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
12558 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 12559 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
12560 | ||
12561 | /* "neighbor peer-group" set commands. */ | |
12562 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
12563 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12564 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12565 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12566 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12567 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12568 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
12569 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 12570 | install_element(BGP_FLOWSPECV4_NODE, |
12571 | &neighbor_set_peer_group_hidden_cmd); | |
12572 | install_element(BGP_FLOWSPECV6_NODE, | |
12573 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 12574 | |
12575 | /* "no neighbor peer-group unset" commands. */ | |
12576 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
12577 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12578 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12579 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12580 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12581 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12582 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
12583 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 12584 | install_element(BGP_FLOWSPECV4_NODE, |
12585 | &no_neighbor_set_peer_group_hidden_cmd); | |
12586 | install_element(BGP_FLOWSPECV6_NODE, | |
12587 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 12588 | |
12589 | /* "neighbor softreconfiguration inbound" commands.*/ | |
12590 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
12591 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
12592 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
12593 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12594 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
12595 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12596 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
12597 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12598 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
12599 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12600 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
12601 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12602 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
12603 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12604 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
12605 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
12606 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
12607 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 12608 | install_element(BGP_FLOWSPECV4_NODE, |
12609 | &neighbor_soft_reconfiguration_cmd); | |
12610 | install_element(BGP_FLOWSPECV4_NODE, | |
12611 | &no_neighbor_soft_reconfiguration_cmd); | |
12612 | install_element(BGP_FLOWSPECV6_NODE, | |
12613 | &neighbor_soft_reconfiguration_cmd); | |
12614 | install_element(BGP_FLOWSPECV6_NODE, | |
12615 | &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 12616 | |
12617 | /* "neighbor attribute-unchanged" commands. */ | |
12618 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
12619 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
12620 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
12621 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
12622 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
12623 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
12624 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
12625 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
12626 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
12627 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
12628 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
12629 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
12630 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
12631 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
12632 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
12633 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
12634 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
12635 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
12636 | ||
12637 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
12638 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
12639 | ||
12640 | /* "nexthop-local unchanged" commands */ | |
12641 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
12642 | install_element(BGP_IPV6_NODE, | |
12643 | &no_neighbor_nexthop_local_unchanged_cmd); | |
12644 | ||
12645 | /* "neighbor next-hop-self" commands. */ | |
12646 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
12647 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
12648 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
12649 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
12650 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
12651 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
12652 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
12653 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
12654 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
12655 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
12656 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
12657 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
12658 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
12659 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
12660 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
12661 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
12662 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
12663 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
12664 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
12665 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 12666 | |
12667 | /* "neighbor next-hop-self force" commands. */ | |
12668 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
12669 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
12670 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); | |
12671 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12672 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
12673 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12674 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); | |
12675 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12676 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
12677 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12678 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
12679 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12680 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); | |
12681 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12682 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
12683 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12684 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); | |
12685 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
12686 | ||
12687 | /* "neighbor as-override" commands. */ | |
12688 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
12689 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
12690 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
12691 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
12692 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
12693 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
12694 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
12695 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
12696 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
12697 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
12698 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
12699 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
12700 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
12701 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
12702 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
12703 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
12704 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
12705 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
12706 | ||
12707 | /* "neighbor remove-private-AS" commands. */ | |
12708 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
12709 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
12710 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
12711 | install_element(BGP_NODE, | |
12712 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
12713 | install_element(BGP_NODE, | |
12714 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
12715 | install_element(BGP_NODE, | |
12716 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
12717 | install_element(BGP_NODE, | |
12718 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
12719 | install_element( | |
12720 | BGP_NODE, | |
12721 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
12722 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
12723 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
12724 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
12725 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12726 | install_element(BGP_IPV4_NODE, | |
12727 | &neighbor_remove_private_as_replace_as_cmd); | |
12728 | install_element(BGP_IPV4_NODE, | |
12729 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12730 | install_element(BGP_IPV4_NODE, | |
12731 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12732 | install_element(BGP_IPV4_NODE, | |
12733 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12734 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
12735 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
12736 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
12737 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12738 | install_element(BGP_IPV4M_NODE, | |
12739 | &neighbor_remove_private_as_replace_as_cmd); | |
12740 | install_element(BGP_IPV4M_NODE, | |
12741 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12742 | install_element(BGP_IPV4M_NODE, | |
12743 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12744 | install_element(BGP_IPV4M_NODE, | |
12745 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12746 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
12747 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
12748 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
12749 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12750 | install_element(BGP_IPV4L_NODE, | |
12751 | &neighbor_remove_private_as_replace_as_cmd); | |
12752 | install_element(BGP_IPV4L_NODE, | |
12753 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12754 | install_element(BGP_IPV4L_NODE, | |
12755 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12756 | install_element(BGP_IPV4L_NODE, | |
12757 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12758 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
12759 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
12760 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
12761 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12762 | install_element(BGP_IPV6_NODE, | |
12763 | &neighbor_remove_private_as_replace_as_cmd); | |
12764 | install_element(BGP_IPV6_NODE, | |
12765 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12766 | install_element(BGP_IPV6_NODE, | |
12767 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12768 | install_element(BGP_IPV6_NODE, | |
12769 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12770 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
12771 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
12772 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
12773 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12774 | install_element(BGP_IPV6M_NODE, | |
12775 | &neighbor_remove_private_as_replace_as_cmd); | |
12776 | install_element(BGP_IPV6M_NODE, | |
12777 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12778 | install_element(BGP_IPV6M_NODE, | |
12779 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12780 | install_element(BGP_IPV6M_NODE, | |
12781 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12782 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
12783 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
12784 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
12785 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12786 | install_element(BGP_IPV6L_NODE, | |
12787 | &neighbor_remove_private_as_replace_as_cmd); | |
12788 | install_element(BGP_IPV6L_NODE, | |
12789 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12790 | install_element(BGP_IPV6L_NODE, | |
12791 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12792 | install_element(BGP_IPV6L_NODE, | |
12793 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12794 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
12795 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
12796 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
12797 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12798 | install_element(BGP_VPNV4_NODE, | |
12799 | &neighbor_remove_private_as_replace_as_cmd); | |
12800 | install_element(BGP_VPNV4_NODE, | |
12801 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12802 | install_element(BGP_VPNV4_NODE, | |
12803 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12804 | install_element(BGP_VPNV4_NODE, | |
12805 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12806 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
12807 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
12808 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
12809 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
12810 | install_element(BGP_VPNV6_NODE, | |
12811 | &neighbor_remove_private_as_replace_as_cmd); | |
12812 | install_element(BGP_VPNV6_NODE, | |
12813 | &no_neighbor_remove_private_as_replace_as_cmd); | |
12814 | install_element(BGP_VPNV6_NODE, | |
12815 | &neighbor_remove_private_as_all_replace_as_cmd); | |
12816 | install_element(BGP_VPNV6_NODE, | |
12817 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
12818 | ||
12819 | /* "neighbor send-community" commands.*/ | |
12820 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
12821 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
12822 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
12823 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
12824 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
12825 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
12826 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
12827 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
12828 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
12829 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
12830 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
12831 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
12832 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
12833 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
12834 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
12835 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
12836 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
12837 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
12838 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
12839 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
12840 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
12841 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
12842 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
12843 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
12844 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
12845 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
12846 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
12847 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
12848 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
12849 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
12850 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
12851 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
12852 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
12853 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
12854 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
12855 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
12856 | ||
12857 | /* "neighbor route-reflector" commands.*/ | |
12858 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
12859 | install_element(BGP_NODE, | |
12860 | &no_neighbor_route_reflector_client_hidden_cmd); | |
12861 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
12862 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
12863 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
12864 | install_element(BGP_IPV4M_NODE, | |
12865 | &no_neighbor_route_reflector_client_cmd); | |
12866 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
12867 | install_element(BGP_IPV4L_NODE, | |
12868 | &no_neighbor_route_reflector_client_cmd); | |
12869 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
12870 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
12871 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
12872 | install_element(BGP_IPV6M_NODE, | |
12873 | &no_neighbor_route_reflector_client_cmd); | |
12874 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
12875 | install_element(BGP_IPV6L_NODE, | |
12876 | &no_neighbor_route_reflector_client_cmd); | |
12877 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
12878 | install_element(BGP_VPNV4_NODE, | |
12879 | &no_neighbor_route_reflector_client_cmd); | |
12880 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
12881 | install_element(BGP_VPNV6_NODE, | |
12882 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 12883 | install_element(BGP_FLOWSPECV4_NODE, |
12884 | &neighbor_route_reflector_client_cmd); | |
12885 | install_element(BGP_FLOWSPECV4_NODE, | |
12886 | &no_neighbor_route_reflector_client_cmd); | |
12887 | install_element(BGP_FLOWSPECV6_NODE, | |
12888 | &neighbor_route_reflector_client_cmd); | |
12889 | install_element(BGP_FLOWSPECV6_NODE, | |
12890 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 12891 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
12892 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
12893 | ||
12894 | /* "neighbor route-server" commands.*/ | |
12895 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
12896 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
12897 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
12898 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
12899 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
12900 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
12901 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
12902 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
12903 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
12904 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
12905 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
12906 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
12907 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
12908 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
12909 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
12910 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
12911 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
12912 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 12913 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
12914 | install_element(BGP_FLOWSPECV4_NODE, | |
12915 | &no_neighbor_route_server_client_cmd); | |
12916 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
12917 | install_element(BGP_FLOWSPECV6_NODE, | |
12918 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 12919 | |
12920 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
12921 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
12922 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
12923 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12924 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12925 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12926 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12927 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12928 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12929 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12930 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12931 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12932 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12933 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12934 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12935 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12936 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12937 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
12938 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
12939 | ||
12940 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
12941 | install_element(BGP_NODE, | |
12942 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
12943 | install_element(BGP_NODE, | |
12944 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
12945 | install_element(BGP_IPV4_NODE, | |
12946 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12947 | install_element(BGP_IPV4_NODE, | |
12948 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12949 | install_element(BGP_IPV4M_NODE, | |
12950 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12951 | install_element(BGP_IPV4M_NODE, | |
12952 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12953 | install_element(BGP_IPV4L_NODE, | |
12954 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12955 | install_element(BGP_IPV4L_NODE, | |
12956 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12957 | install_element(BGP_IPV6_NODE, | |
12958 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12959 | install_element(BGP_IPV6_NODE, | |
12960 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12961 | install_element(BGP_IPV6M_NODE, | |
12962 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12963 | install_element(BGP_IPV6M_NODE, | |
12964 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12965 | install_element(BGP_IPV6L_NODE, | |
12966 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12967 | install_element(BGP_IPV6L_NODE, | |
12968 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12969 | install_element(BGP_VPNV4_NODE, | |
12970 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12971 | install_element(BGP_VPNV4_NODE, | |
12972 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12973 | install_element(BGP_VPNV6_NODE, | |
12974 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
12975 | install_element(BGP_VPNV6_NODE, | |
12976 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
12977 | ||
12978 | /* "neighbor passive" commands. */ | |
12979 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
12980 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
12981 | ||
12982 | ||
12983 | /* "neighbor shutdown" commands. */ | |
12984 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
12985 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
12986 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
12987 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
12988 | ||
12989 | /* "neighbor capability extended-nexthop" commands.*/ | |
12990 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
12991 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
12992 | ||
12993 | /* "neighbor capability orf prefix-list" commands.*/ | |
12994 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
12995 | install_element(BGP_NODE, | |
12996 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
12997 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
12998 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
12999 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13000 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13001 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13002 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13003 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
13004 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13005 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13006 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13007 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13008 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13009 | ||
13010 | /* "neighbor capability dynamic" commands.*/ | |
13011 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
13012 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
13013 | ||
13014 | /* "neighbor dont-capability-negotiate" commands. */ | |
13015 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
13016 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
13017 | ||
13018 | /* "neighbor ebgp-multihop" commands. */ | |
13019 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
13020 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
13021 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
13022 | ||
13023 | /* "neighbor disable-connected-check" commands. */ | |
13024 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
13025 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
13026 | ||
47cbc09b PM |
13027 | /* "neighbor enforce-first-as" commands. */ |
13028 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
13029 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
13030 | ||
d62a17ae | 13031 | /* "neighbor description" commands. */ |
13032 | install_element(BGP_NODE, &neighbor_description_cmd); | |
13033 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 13034 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 13035 | |
13036 | /* "neighbor update-source" commands. "*/ | |
13037 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
13038 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
13039 | ||
13040 | /* "neighbor default-originate" commands. */ | |
13041 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
13042 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
13043 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
13044 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
13045 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
13046 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
13047 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
13048 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
13049 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
13050 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
13051 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
13052 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
13053 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
13054 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
13055 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
13056 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
13057 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
13058 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
13059 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
13060 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
13061 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
13062 | ||
13063 | /* "neighbor port" commands. */ | |
13064 | install_element(BGP_NODE, &neighbor_port_cmd); | |
13065 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
13066 | ||
13067 | /* "neighbor weight" commands. */ | |
13068 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
13069 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
13070 | ||
13071 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
13072 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
13073 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
13074 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
13075 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
13076 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
13077 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
13078 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
13079 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
13080 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
13081 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
13082 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
13083 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
13084 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
13085 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
13086 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
13087 | ||
13088 | /* "neighbor override-capability" commands. */ | |
13089 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
13090 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
13091 | ||
13092 | /* "neighbor strict-capability-match" commands. */ | |
13093 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
13094 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
13095 | ||
13096 | /* "neighbor timers" commands. */ | |
13097 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
13098 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
13099 | ||
13100 | /* "neighbor timers connect" commands. */ | |
13101 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
13102 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
13103 | ||
13104 | /* "neighbor advertisement-interval" commands. */ | |
13105 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
13106 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
13107 | ||
13108 | /* "neighbor interface" commands. */ | |
13109 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
13110 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
13111 | ||
13112 | /* "neighbor distribute" commands. */ | |
13113 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
13114 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
13115 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
13116 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
13117 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
13118 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
13119 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
13120 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
13121 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
13122 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
13123 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
13124 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
13125 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
13126 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
13127 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
13128 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
13129 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
13130 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
13131 | ||
13132 | /* "neighbor prefix-list" commands. */ | |
13133 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
13134 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
13135 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
13136 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
13137 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
13138 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
13139 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
13140 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
13141 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
13142 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
13143 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
13144 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
13145 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
13146 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
13147 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
13148 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
13149 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
13150 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 13151 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
13152 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
13153 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
13154 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 13155 | |
13156 | /* "neighbor filter-list" commands. */ | |
13157 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
13158 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
13159 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
13160 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
13161 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
13162 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
13163 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
13164 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
13165 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
13166 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
13167 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
13168 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
13169 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
13170 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
13171 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
13172 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
13173 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
13174 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 13175 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
13176 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
13177 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
13178 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 13179 | |
13180 | /* "neighbor route-map" commands. */ | |
13181 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
13182 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
13183 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
13184 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
13185 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
13186 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
13187 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
13188 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
13189 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
13190 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
13191 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
13192 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
13193 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
13194 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
13195 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
13196 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
13197 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
13198 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 13199 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
13200 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
13201 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
13202 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
13203 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
13204 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 13205 | |
13206 | /* "neighbor unsuppress-map" commands. */ | |
13207 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
13208 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
13209 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
13210 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13211 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
13212 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13213 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
13214 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13215 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
13216 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13217 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
13218 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13219 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
13220 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13221 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
13222 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13223 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
13224 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13225 | ||
13226 | /* "neighbor maximum-prefix" commands. */ | |
13227 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
13228 | install_element(BGP_NODE, | |
13229 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
13230 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
13231 | install_element(BGP_NODE, | |
13232 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
13233 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
13234 | install_element(BGP_NODE, | |
13235 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
13236 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
13237 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
13238 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13239 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13240 | install_element(BGP_IPV4_NODE, | |
13241 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13242 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13243 | install_element(BGP_IPV4_NODE, | |
13244 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13245 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13246 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
13247 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13248 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13249 | install_element(BGP_IPV4M_NODE, | |
13250 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13251 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13252 | install_element(BGP_IPV4M_NODE, | |
13253 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13254 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13255 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
13256 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13257 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13258 | install_element(BGP_IPV4L_NODE, | |
13259 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13260 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13261 | install_element(BGP_IPV4L_NODE, | |
13262 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13263 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13264 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
13265 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13266 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13267 | install_element(BGP_IPV6_NODE, | |
13268 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13269 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13270 | install_element(BGP_IPV6_NODE, | |
13271 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13272 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13273 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
13274 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13275 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13276 | install_element(BGP_IPV6M_NODE, | |
13277 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13278 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13279 | install_element(BGP_IPV6M_NODE, | |
13280 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13281 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13282 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
13283 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13284 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13285 | install_element(BGP_IPV6L_NODE, | |
13286 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13287 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13288 | install_element(BGP_IPV6L_NODE, | |
13289 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13290 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13291 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
13292 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13293 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13294 | install_element(BGP_VPNV4_NODE, | |
13295 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13296 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13297 | install_element(BGP_VPNV4_NODE, | |
13298 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13299 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13300 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
13301 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13302 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13303 | install_element(BGP_VPNV6_NODE, | |
13304 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13305 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13306 | install_element(BGP_VPNV6_NODE, | |
13307 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13308 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13309 | ||
13310 | /* "neighbor allowas-in" */ | |
13311 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
13312 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
13313 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
13314 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
13315 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
13316 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
13317 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
13318 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
13319 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
13320 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
13321 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
13322 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
13323 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
13324 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
13325 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
13326 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
13327 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
13328 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
13329 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
13330 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
13331 | ||
13332 | /* address-family commands. */ | |
13333 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
13334 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 13335 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 13336 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
13337 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 13338 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 13339 | |
d62a17ae | 13340 | install_element(BGP_NODE, &address_family_evpn_cmd); |
13341 | ||
13342 | /* "exit-address-family" command. */ | |
13343 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
13344 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
13345 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
13346 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
13347 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
13348 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
13349 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
13350 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 13351 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
13352 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 13353 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
13354 | ||
13355 | /* "clear ip bgp commands" */ | |
13356 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
13357 | ||
13358 | /* clear ip bgp prefix */ | |
13359 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
13360 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
13361 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
13362 | ||
13363 | /* "show [ip] bgp summary" commands. */ | |
13364 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
d62a17ae | 13365 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 13366 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 13367 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
13368 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 13369 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
13370 | ||
13371 | /* "show [ip] bgp neighbors" commands. */ | |
13372 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
13373 | ||
13374 | /* "show [ip] bgp peer-group" commands. */ | |
13375 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
13376 | ||
13377 | /* "show [ip] bgp paths" commands. */ | |
13378 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
13379 | ||
13380 | /* "show [ip] bgp community" commands. */ | |
13381 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
13382 | ||
13383 | /* "show ip bgp large-community" commands. */ | |
13384 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
13385 | /* "show [ip] bgp attribute-info" commands. */ | |
13386 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 13387 | /* "show [ip] bgp route-leak" command */ |
13388 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 13389 | |
13390 | /* "redistribute" commands. */ | |
13391 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
13392 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
13393 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
13394 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
13395 | install_element(BGP_NODE, | |
13396 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
13397 | install_element(BGP_NODE, | |
13398 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
13399 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
13400 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
13401 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
13402 | install_element(BGP_NODE, | |
13403 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
13404 | install_element(BGP_NODE, | |
13405 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
13406 | install_element(BGP_NODE, | |
13407 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
13408 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
13409 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
13410 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
13411 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
13412 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
13413 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
13414 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
13415 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
13416 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
13417 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
13418 | install_element(BGP_IPV4_NODE, | |
13419 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
13420 | install_element(BGP_IPV4_NODE, | |
13421 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
13422 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
13423 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
13424 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
13425 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
13426 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
13427 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
13428 | ||
b9c7bc5a PZ |
13429 | /* import|export vpn [route-map WORD] */ |
13430 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
13431 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 13432 | |
12a844a5 DS |
13433 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
13434 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
13435 | ||
d62a17ae | 13436 | /* ttl_security commands */ |
13437 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
13438 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
13439 | ||
13440 | /* "show [ip] bgp memory" commands. */ | |
13441 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
13442 | ||
acf71666 MK |
13443 | /* "show bgp martian next-hop" */ |
13444 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
13445 | ||
d62a17ae | 13446 | /* "show [ip] bgp views" commands. */ |
13447 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
13448 | ||
13449 | /* "show [ip] bgp vrfs" commands. */ | |
13450 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
13451 | ||
13452 | /* Community-list. */ | |
13453 | community_list_vty(); | |
ddb5b488 PZ |
13454 | |
13455 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
13456 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
13457 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
13458 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
13459 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
13460 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
13461 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
13462 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
13463 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
13464 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
13465 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
13466 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
13467 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 13468 | |
301ad80a PG |
13469 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
13470 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
13471 | ||
b9c7bc5a PZ |
13472 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
13473 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
13474 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
13475 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
13476 | install_element(BGP_IPV4_NODE, &af_no_nexthop_vpn_export_cmd); | |
13477 | install_element(BGP_IPV6_NODE, &af_no_nexthop_vpn_export_cmd); | |
13478 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); | |
13479 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
13480 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
13481 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
13482 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
13483 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 13484 | } |
6b0655a2 | 13485 | |
718e3744 | 13486 | #include "memory.h" |
13487 | #include "bgp_regex.h" | |
13488 | #include "bgp_clist.h" | |
13489 | #include "bgp_ecommunity.h" | |
13490 | ||
13491 | /* VTY functions. */ | |
13492 | ||
13493 | /* Direction value to string conversion. */ | |
d62a17ae | 13494 | static const char *community_direct_str(int direct) |
13495 | { | |
13496 | switch (direct) { | |
13497 | case COMMUNITY_DENY: | |
13498 | return "deny"; | |
13499 | case COMMUNITY_PERMIT: | |
13500 | return "permit"; | |
13501 | default: | |
13502 | return "unknown"; | |
13503 | } | |
718e3744 | 13504 | } |
13505 | ||
13506 | /* Display error string. */ | |
d62a17ae | 13507 | static void community_list_perror(struct vty *vty, int ret) |
13508 | { | |
13509 | switch (ret) { | |
13510 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
13511 | vty_out(vty, "%% Can't find community-list\n"); | |
13512 | break; | |
13513 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
13514 | vty_out(vty, "%% Malformed community-list value\n"); | |
13515 | break; | |
13516 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
13517 | vty_out(vty, | |
13518 | "%% Community name conflict, previously defined as standard community\n"); | |
13519 | break; | |
13520 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
13521 | vty_out(vty, | |
13522 | "%% Community name conflict, previously defined as expanded community\n"); | |
13523 | break; | |
13524 | } | |
718e3744 | 13525 | } |
13526 | ||
5bf15956 DW |
13527 | /* "community-list" keyword help string. */ |
13528 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
13529 | ||
5bf15956 | 13530 | /* ip community-list standard */ |
718e3744 | 13531 | DEFUN (ip_community_list_standard, |
13532 | ip_community_list_standard_cmd, | |
e961923c | 13533 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 13534 | IP_STR |
13535 | COMMUNITY_LIST_STR | |
13536 | "Community list number (standard)\n" | |
5bf15956 | 13537 | "Add an standard community-list entry\n" |
718e3744 | 13538 | "Community list name\n" |
13539 | "Specify community to reject\n" | |
13540 | "Specify community to accept\n" | |
13541 | COMMUNITY_VAL_STR) | |
13542 | { | |
d62a17ae | 13543 | char *cl_name_or_number = NULL; |
13544 | int direct = 0; | |
13545 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 13546 | |
d62a17ae | 13547 | int idx = 0; |
13548 | argv_find(argv, argc, "(1-99)", &idx); | |
13549 | argv_find(argv, argc, "WORD", &idx); | |
13550 | cl_name_or_number = argv[idx]->arg; | |
13551 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13552 | : COMMUNITY_DENY; | |
13553 | argv_find(argv, argc, "AA:NN", &idx); | |
13554 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13555 | |
d62a17ae | 13556 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
13557 | style); | |
42f914d4 | 13558 | |
d62a17ae | 13559 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13560 | |
d62a17ae | 13561 | if (ret < 0) { |
13562 | /* Display error string. */ | |
13563 | community_list_perror(vty, ret); | |
13564 | return CMD_WARNING_CONFIG_FAILED; | |
13565 | } | |
42f914d4 | 13566 | |
d62a17ae | 13567 | return CMD_SUCCESS; |
718e3744 | 13568 | } |
13569 | ||
fee6e4e4 | 13570 | DEFUN (no_ip_community_list_standard_all, |
13571 | no_ip_community_list_standard_all_cmd, | |
e961923c | 13572 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 13573 | NO_STR |
13574 | IP_STR | |
13575 | COMMUNITY_LIST_STR | |
13576 | "Community list number (standard)\n" | |
5bf15956 DW |
13577 | "Add an standard community-list entry\n" |
13578 | "Community list name\n" | |
718e3744 | 13579 | "Specify community to reject\n" |
13580 | "Specify community to accept\n" | |
13581 | COMMUNITY_VAL_STR) | |
13582 | { | |
d62a17ae | 13583 | char *cl_name_or_number = NULL; |
13584 | int direct = 0; | |
13585 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 13586 | |
d62a17ae | 13587 | int idx = 0; |
13588 | argv_find(argv, argc, "(1-99)", &idx); | |
13589 | argv_find(argv, argc, "WORD", &idx); | |
13590 | cl_name_or_number = argv[idx]->arg; | |
13591 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13592 | : COMMUNITY_DENY; | |
13593 | argv_find(argv, argc, "AA:NN", &idx); | |
13594 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13595 | |
d62a17ae | 13596 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 13597 | direct, style); |
42f914d4 | 13598 | |
d62a17ae | 13599 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 13600 | |
d62a17ae | 13601 | if (ret < 0) { |
13602 | community_list_perror(vty, ret); | |
13603 | return CMD_WARNING_CONFIG_FAILED; | |
13604 | } | |
42f914d4 | 13605 | |
d62a17ae | 13606 | return CMD_SUCCESS; |
718e3744 | 13607 | } |
13608 | ||
5bf15956 DW |
13609 | /* ip community-list expanded */ |
13610 | DEFUN (ip_community_list_expanded_all, | |
13611 | ip_community_list_expanded_all_cmd, | |
42f914d4 | 13612 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 13613 | IP_STR |
13614 | COMMUNITY_LIST_STR | |
13615 | "Community list number (expanded)\n" | |
5bf15956 | 13616 | "Add an expanded community-list entry\n" |
718e3744 | 13617 | "Community list name\n" |
13618 | "Specify community to reject\n" | |
13619 | "Specify community to accept\n" | |
13620 | COMMUNITY_VAL_STR) | |
13621 | { | |
d62a17ae | 13622 | char *cl_name_or_number = NULL; |
13623 | int direct = 0; | |
13624 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 13625 | |
d62a17ae | 13626 | int idx = 0; |
13627 | argv_find(argv, argc, "(100-500)", &idx); | |
13628 | argv_find(argv, argc, "WORD", &idx); | |
13629 | cl_name_or_number = argv[idx]->arg; | |
13630 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13631 | : COMMUNITY_DENY; | |
13632 | argv_find(argv, argc, "AA:NN", &idx); | |
13633 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13634 | |
d62a17ae | 13635 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
13636 | style); | |
42f914d4 | 13637 | |
d62a17ae | 13638 | XFREE(MTYPE_TMP, str); |
42f914d4 | 13639 | |
d62a17ae | 13640 | if (ret < 0) { |
13641 | /* Display error string. */ | |
13642 | community_list_perror(vty, ret); | |
13643 | return CMD_WARNING_CONFIG_FAILED; | |
13644 | } | |
42f914d4 | 13645 | |
d62a17ae | 13646 | return CMD_SUCCESS; |
718e3744 | 13647 | } |
13648 | ||
5bf15956 DW |
13649 | DEFUN (no_ip_community_list_expanded_all, |
13650 | no_ip_community_list_expanded_all_cmd, | |
42f914d4 | 13651 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", |
718e3744 | 13652 | NO_STR |
13653 | IP_STR | |
13654 | COMMUNITY_LIST_STR | |
5bf15956 DW |
13655 | "Community list number (expanded)\n" |
13656 | "Add an expanded community-list entry\n" | |
718e3744 | 13657 | "Community list name\n" |
13658 | "Specify community to reject\n" | |
13659 | "Specify community to accept\n" | |
5bf15956 | 13660 | COMMUNITY_VAL_STR) |
718e3744 | 13661 | { |
d62a17ae | 13662 | char *cl_name_or_number = NULL; |
13663 | int direct = 0; | |
13664 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 13665 | |
d62a17ae | 13666 | int idx = 0; |
13667 | argv_find(argv, argc, "(100-500)", &idx); | |
13668 | argv_find(argv, argc, "WORD", &idx); | |
13669 | cl_name_or_number = argv[idx]->arg; | |
13670 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13671 | : COMMUNITY_DENY; | |
13672 | argv_find(argv, argc, "AA:NN", &idx); | |
13673 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 13674 | |
d62a17ae | 13675 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 13676 | direct, style); |
42f914d4 | 13677 | |
d62a17ae | 13678 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 13679 | |
d62a17ae | 13680 | if (ret < 0) { |
13681 | community_list_perror(vty, ret); | |
13682 | return CMD_WARNING_CONFIG_FAILED; | |
13683 | } | |
42f914d4 | 13684 | |
d62a17ae | 13685 | return CMD_SUCCESS; |
718e3744 | 13686 | } |
13687 | ||
8d9b8ed9 PM |
13688 | /* Return configuration string of community-list entry. */ |
13689 | static const char *community_list_config_str(struct community_entry *entry) | |
13690 | { | |
13691 | const char *str; | |
13692 | ||
13693 | if (entry->any) | |
13694 | str = ""; | |
13695 | else { | |
13696 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
13697 | str = community_str(entry->u.com, false); | |
13698 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
13699 | str = lcommunity_str(entry->u.lcom, false); | |
13700 | else | |
13701 | str = entry->config; | |
13702 | } | |
13703 | return str; | |
13704 | } | |
13705 | ||
d62a17ae | 13706 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 13707 | { |
d62a17ae | 13708 | struct community_entry *entry; |
718e3744 | 13709 | |
d62a17ae | 13710 | for (entry = list->head; entry; entry = entry->next) { |
13711 | if (entry == list->head) { | |
13712 | if (all_digit(list->name)) | |
13713 | vty_out(vty, "Community %s list %s\n", | |
13714 | entry->style == COMMUNITY_LIST_STANDARD | |
13715 | ? "standard" | |
13716 | : "(expanded) access", | |
13717 | list->name); | |
13718 | else | |
13719 | vty_out(vty, "Named Community %s list %s\n", | |
13720 | entry->style == COMMUNITY_LIST_STANDARD | |
13721 | ? "standard" | |
13722 | : "expanded", | |
13723 | list->name); | |
13724 | } | |
13725 | if (entry->any) | |
13726 | vty_out(vty, " %s\n", | |
13727 | community_direct_str(entry->direct)); | |
13728 | else | |
13729 | vty_out(vty, " %s %s\n", | |
13730 | community_direct_str(entry->direct), | |
8d9b8ed9 | 13731 | community_list_config_str(entry)); |
d62a17ae | 13732 | } |
718e3744 | 13733 | } |
13734 | ||
13735 | DEFUN (show_ip_community_list, | |
13736 | show_ip_community_list_cmd, | |
13737 | "show ip community-list", | |
13738 | SHOW_STR | |
13739 | IP_STR | |
13740 | "List community-list\n") | |
13741 | { | |
d62a17ae | 13742 | struct community_list *list; |
13743 | struct community_list_master *cm; | |
718e3744 | 13744 | |
d62a17ae | 13745 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
13746 | if (!cm) | |
13747 | return CMD_SUCCESS; | |
718e3744 | 13748 | |
d62a17ae | 13749 | for (list = cm->num.head; list; list = list->next) |
13750 | community_list_show(vty, list); | |
718e3744 | 13751 | |
d62a17ae | 13752 | for (list = cm->str.head; list; list = list->next) |
13753 | community_list_show(vty, list); | |
718e3744 | 13754 | |
d62a17ae | 13755 | return CMD_SUCCESS; |
718e3744 | 13756 | } |
13757 | ||
13758 | DEFUN (show_ip_community_list_arg, | |
13759 | show_ip_community_list_arg_cmd, | |
6147e2c6 | 13760 | "show ip community-list <(1-500)|WORD>", |
718e3744 | 13761 | SHOW_STR |
13762 | IP_STR | |
13763 | "List community-list\n" | |
13764 | "Community-list number\n" | |
13765 | "Community-list name\n") | |
13766 | { | |
d62a17ae | 13767 | int idx_comm_list = 3; |
13768 | struct community_list *list; | |
718e3744 | 13769 | |
d62a17ae | 13770 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
13771 | COMMUNITY_LIST_MASTER); | |
13772 | if (!list) { | |
13773 | vty_out(vty, "%% Can't find community-list\n"); | |
13774 | return CMD_WARNING; | |
13775 | } | |
718e3744 | 13776 | |
d62a17ae | 13777 | community_list_show(vty, list); |
718e3744 | 13778 | |
d62a17ae | 13779 | return CMD_SUCCESS; |
718e3744 | 13780 | } |
6b0655a2 | 13781 | |
57d187bc JS |
13782 | /* |
13783 | * Large Community code. | |
13784 | */ | |
d62a17ae | 13785 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
13786 | struct cmd_token **argv, int style, | |
13787 | int reject_all_digit_name) | |
13788 | { | |
13789 | int ret; | |
13790 | int direct; | |
13791 | char *str; | |
13792 | int idx = 0; | |
13793 | char *cl_name; | |
13794 | ||
13795 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
13796 | : COMMUNITY_DENY; | |
13797 | ||
13798 | /* All digit name check. */ | |
13799 | idx = 0; | |
13800 | argv_find(argv, argc, "WORD", &idx); | |
13801 | argv_find(argv, argc, "(1-99)", &idx); | |
13802 | argv_find(argv, argc, "(100-500)", &idx); | |
13803 | cl_name = argv[idx]->arg; | |
13804 | if (reject_all_digit_name && all_digit(cl_name)) { | |
13805 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
13806 | return CMD_WARNING_CONFIG_FAILED; | |
13807 | } | |
13808 | ||
13809 | idx = 0; | |
13810 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
13811 | argv_find(argv, argc, "LINE", &idx); | |
13812 | /* Concat community string argument. */ | |
13813 | if (idx) | |
13814 | str = argv_concat(argv, argc, idx); | |
13815 | else | |
13816 | str = NULL; | |
13817 | ||
13818 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
13819 | ||
13820 | /* Free temporary community list string allocated by | |
13821 | argv_concat(). */ | |
13822 | if (str) | |
13823 | XFREE(MTYPE_TMP, str); | |
13824 | ||
13825 | if (ret < 0) { | |
13826 | community_list_perror(vty, ret); | |
13827 | return CMD_WARNING_CONFIG_FAILED; | |
13828 | } | |
13829 | return CMD_SUCCESS; | |
13830 | } | |
13831 | ||
13832 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
13833 | struct cmd_token **argv, int style) | |
13834 | { | |
13835 | int ret; | |
13836 | int direct = 0; | |
13837 | char *str = NULL; | |
13838 | int idx = 0; | |
13839 | ||
13840 | argv_find(argv, argc, "permit", &idx); | |
13841 | argv_find(argv, argc, "deny", &idx); | |
13842 | ||
13843 | if (idx) { | |
13844 | /* Check the list direct. */ | |
13845 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
13846 | direct = COMMUNITY_PERMIT; | |
13847 | else | |
13848 | direct = COMMUNITY_DENY; | |
13849 | ||
13850 | idx = 0; | |
13851 | argv_find(argv, argc, "LINE", &idx); | |
13852 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
13853 | /* Concat community string argument. */ | |
13854 | str = argv_concat(argv, argc, idx); | |
13855 | } | |
13856 | ||
13857 | idx = 0; | |
13858 | argv_find(argv, argc, "(1-99)", &idx); | |
13859 | argv_find(argv, argc, "(100-500)", &idx); | |
13860 | argv_find(argv, argc, "WORD", &idx); | |
13861 | ||
13862 | /* Unset community list. */ | |
13863 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
13864 | style); | |
13865 | ||
13866 | /* Free temporary community list string allocated by | |
13867 | argv_concat(). */ | |
13868 | if (str) | |
13869 | XFREE(MTYPE_TMP, str); | |
13870 | ||
13871 | if (ret < 0) { | |
13872 | community_list_perror(vty, ret); | |
13873 | return CMD_WARNING_CONFIG_FAILED; | |
13874 | } | |
13875 | ||
13876 | return CMD_SUCCESS; | |
57d187bc JS |
13877 | } |
13878 | ||
13879 | /* "large-community-list" keyword help string. */ | |
13880 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
13881 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
13882 | ||
13883 | DEFUN (ip_lcommunity_list_standard, | |
13884 | ip_lcommunity_list_standard_cmd, | |
52951b63 DS |
13885 | "ip large-community-list (1-99) <deny|permit>", |
13886 | IP_STR | |
13887 | LCOMMUNITY_LIST_STR | |
13888 | "Large Community list number (standard)\n" | |
13889 | "Specify large community to reject\n" | |
7111c1a0 | 13890 | "Specify large community to accept\n") |
52951b63 | 13891 | { |
d62a17ae | 13892 | return lcommunity_list_set_vty(vty, argc, argv, |
13893 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
13894 | } |
13895 | ||
13896 | DEFUN (ip_lcommunity_list_standard1, | |
13897 | ip_lcommunity_list_standard1_cmd, | |
13898 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
13899 | IP_STR |
13900 | LCOMMUNITY_LIST_STR | |
13901 | "Large Community list number (standard)\n" | |
13902 | "Specify large community to reject\n" | |
13903 | "Specify large community to accept\n" | |
13904 | LCOMMUNITY_VAL_STR) | |
13905 | { | |
d62a17ae | 13906 | return lcommunity_list_set_vty(vty, argc, argv, |
13907 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
57d187bc JS |
13908 | } |
13909 | ||
13910 | DEFUN (ip_lcommunity_list_expanded, | |
13911 | ip_lcommunity_list_expanded_cmd, | |
13912 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
13913 | IP_STR | |
13914 | LCOMMUNITY_LIST_STR | |
13915 | "Large Community list number (expanded)\n" | |
13916 | "Specify large community to reject\n" | |
13917 | "Specify large community to accept\n" | |
13918 | "An ordered list as a regular-expression\n") | |
13919 | { | |
d62a17ae | 13920 | return lcommunity_list_set_vty(vty, argc, argv, |
13921 | LARGE_COMMUNITY_LIST_EXPANDED, 0); | |
57d187bc JS |
13922 | } |
13923 | ||
13924 | DEFUN (ip_lcommunity_list_name_standard, | |
13925 | ip_lcommunity_list_name_standard_cmd, | |
52951b63 DS |
13926 | "ip large-community-list standard WORD <deny|permit>", |
13927 | IP_STR | |
13928 | LCOMMUNITY_LIST_STR | |
13929 | "Specify standard large-community-list\n" | |
13930 | "Large Community list name\n" | |
13931 | "Specify large community to reject\n" | |
13932 | "Specify large community to accept\n") | |
13933 | { | |
d62a17ae | 13934 | return lcommunity_list_set_vty(vty, argc, argv, |
13935 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
13936 | } |
13937 | ||
13938 | DEFUN (ip_lcommunity_list_name_standard1, | |
13939 | ip_lcommunity_list_name_standard1_cmd, | |
13940 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
13941 | IP_STR |
13942 | LCOMMUNITY_LIST_STR | |
13943 | "Specify standard large-community-list\n" | |
13944 | "Large Community list name\n" | |
13945 | "Specify large community to reject\n" | |
13946 | "Specify large community to accept\n" | |
13947 | LCOMMUNITY_VAL_STR) | |
13948 | { | |
d62a17ae | 13949 | return lcommunity_list_set_vty(vty, argc, argv, |
13950 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
57d187bc JS |
13951 | } |
13952 | ||
13953 | DEFUN (ip_lcommunity_list_name_expanded, | |
13954 | ip_lcommunity_list_name_expanded_cmd, | |
13955 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
13956 | IP_STR | |
13957 | LCOMMUNITY_LIST_STR | |
13958 | "Specify expanded large-community-list\n" | |
13959 | "Large Community list name\n" | |
13960 | "Specify large community to reject\n" | |
13961 | "Specify large community to accept\n" | |
13962 | "An ordered list as a regular-expression\n") | |
13963 | { | |
d62a17ae | 13964 | return lcommunity_list_set_vty(vty, argc, argv, |
13965 | LARGE_COMMUNITY_LIST_EXPANDED, 1); | |
57d187bc JS |
13966 | } |
13967 | ||
13968 | DEFUN (no_ip_lcommunity_list_standard_all, | |
13969 | no_ip_lcommunity_list_standard_all_cmd, | |
13970 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
13971 | NO_STR | |
13972 | IP_STR | |
13973 | LCOMMUNITY_LIST_STR | |
13974 | "Large Community list number (standard)\n" | |
13975 | "Large Community list number (expanded)\n" | |
13976 | "Large Community list name\n") | |
13977 | { | |
d62a17ae | 13978 | return lcommunity_list_unset_vty(vty, argc, argv, |
13979 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
13980 | } |
13981 | ||
13982 | DEFUN (no_ip_lcommunity_list_name_expanded_all, | |
13983 | no_ip_lcommunity_list_name_expanded_all_cmd, | |
13984 | "no ip large-community-list expanded WORD", | |
13985 | NO_STR | |
13986 | IP_STR | |
13987 | LCOMMUNITY_LIST_STR | |
13988 | "Specify expanded large-community-list\n" | |
13989 | "Large Community list name\n") | |
13990 | { | |
d62a17ae | 13991 | return lcommunity_list_unset_vty(vty, argc, argv, |
13992 | LARGE_COMMUNITY_LIST_EXPANDED); | |
57d187bc JS |
13993 | } |
13994 | ||
13995 | DEFUN (no_ip_lcommunity_list_standard, | |
13996 | no_ip_lcommunity_list_standard_cmd, | |
13997 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
13998 | NO_STR | |
13999 | IP_STR | |
14000 | LCOMMUNITY_LIST_STR | |
14001 | "Large Community list number (standard)\n" | |
14002 | "Specify large community to reject\n" | |
14003 | "Specify large community to accept\n" | |
14004 | LCOMMUNITY_VAL_STR) | |
14005 | { | |
d62a17ae | 14006 | return lcommunity_list_unset_vty(vty, argc, argv, |
14007 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
14008 | } |
14009 | ||
14010 | DEFUN (no_ip_lcommunity_list_expanded, | |
14011 | no_ip_lcommunity_list_expanded_cmd, | |
14012 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
14013 | NO_STR | |
14014 | IP_STR | |
14015 | LCOMMUNITY_LIST_STR | |
14016 | "Large Community list number (expanded)\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); | |
57d187bc JS |
14023 | } |
14024 | ||
14025 | DEFUN (no_ip_lcommunity_list_name_standard, | |
14026 | no_ip_lcommunity_list_name_standard_cmd, | |
14027 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
14028 | NO_STR | |
14029 | IP_STR | |
14030 | LCOMMUNITY_LIST_STR | |
14031 | "Specify standard large-community-list\n" | |
14032 | "Large Community list name\n" | |
14033 | "Specify large community to reject\n" | |
14034 | "Specify large community to accept\n" | |
14035 | LCOMMUNITY_VAL_STR) | |
14036 | { | |
d62a17ae | 14037 | return lcommunity_list_unset_vty(vty, argc, argv, |
14038 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
14039 | } |
14040 | ||
14041 | DEFUN (no_ip_lcommunity_list_name_expanded, | |
14042 | no_ip_lcommunity_list_name_expanded_cmd, | |
14043 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
14044 | NO_STR | |
14045 | IP_STR | |
14046 | LCOMMUNITY_LIST_STR | |
14047 | "Specify expanded large-community-list\n" | |
14048 | "Large community list name\n" | |
14049 | "Specify large community to reject\n" | |
14050 | "Specify large community to accept\n" | |
14051 | "An ordered list as a regular-expression\n") | |
14052 | { | |
d62a17ae | 14053 | return lcommunity_list_unset_vty(vty, argc, argv, |
14054 | LARGE_COMMUNITY_LIST_EXPANDED); | |
14055 | } | |
14056 | ||
14057 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) | |
14058 | { | |
14059 | struct community_entry *entry; | |
14060 | ||
14061 | for (entry = list->head; entry; entry = entry->next) { | |
14062 | if (entry == list->head) { | |
14063 | if (all_digit(list->name)) | |
14064 | vty_out(vty, "Large community %s list %s\n", | |
14065 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14066 | ? "standard" | |
14067 | : "(expanded) access", | |
14068 | list->name); | |
14069 | else | |
14070 | vty_out(vty, | |
14071 | "Named large community %s list %s\n", | |
14072 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14073 | ? "standard" | |
14074 | : "expanded", | |
14075 | list->name); | |
14076 | } | |
14077 | if (entry->any) | |
14078 | vty_out(vty, " %s\n", | |
14079 | community_direct_str(entry->direct)); | |
14080 | else | |
14081 | vty_out(vty, " %s %s\n", | |
14082 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14083 | community_list_config_str(entry)); |
d62a17ae | 14084 | } |
57d187bc JS |
14085 | } |
14086 | ||
14087 | DEFUN (show_ip_lcommunity_list, | |
14088 | show_ip_lcommunity_list_cmd, | |
14089 | "show ip large-community-list", | |
14090 | SHOW_STR | |
14091 | IP_STR | |
14092 | "List large-community list\n") | |
14093 | { | |
d62a17ae | 14094 | struct community_list *list; |
14095 | struct community_list_master *cm; | |
57d187bc | 14096 | |
d62a17ae | 14097 | cm = community_list_master_lookup(bgp_clist, |
14098 | LARGE_COMMUNITY_LIST_MASTER); | |
14099 | if (!cm) | |
14100 | return CMD_SUCCESS; | |
57d187bc | 14101 | |
d62a17ae | 14102 | for (list = cm->num.head; list; list = list->next) |
14103 | lcommunity_list_show(vty, list); | |
57d187bc | 14104 | |
d62a17ae | 14105 | for (list = cm->str.head; list; list = list->next) |
14106 | lcommunity_list_show(vty, list); | |
57d187bc | 14107 | |
d62a17ae | 14108 | return CMD_SUCCESS; |
57d187bc JS |
14109 | } |
14110 | ||
14111 | DEFUN (show_ip_lcommunity_list_arg, | |
14112 | show_ip_lcommunity_list_arg_cmd, | |
14113 | "show ip large-community-list <(1-500)|WORD>", | |
14114 | SHOW_STR | |
14115 | IP_STR | |
14116 | "List large-community list\n" | |
14117 | "large-community-list number\n" | |
14118 | "large-community-list name\n") | |
14119 | { | |
d62a17ae | 14120 | struct community_list *list; |
57d187bc | 14121 | |
d62a17ae | 14122 | list = community_list_lookup(bgp_clist, argv[3]->arg, |
14123 | LARGE_COMMUNITY_LIST_MASTER); | |
14124 | if (!list) { | |
14125 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
14126 | return CMD_WARNING; | |
14127 | } | |
57d187bc | 14128 | |
d62a17ae | 14129 | lcommunity_list_show(vty, list); |
57d187bc | 14130 | |
d62a17ae | 14131 | return CMD_SUCCESS; |
57d187bc JS |
14132 | } |
14133 | ||
718e3744 | 14134 | /* "extcommunity-list" keyword help string. */ |
14135 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
14136 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
14137 | ||
14138 | DEFUN (ip_extcommunity_list_standard, | |
14139 | ip_extcommunity_list_standard_cmd, | |
e961923c | 14140 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
718e3744 | 14141 | IP_STR |
14142 | EXTCOMMUNITY_LIST_STR | |
14143 | "Extended Community list number (standard)\n" | |
718e3744 | 14144 | "Specify standard extcommunity-list\n" |
5bf15956 | 14145 | "Community list name\n" |
718e3744 | 14146 | "Specify community to reject\n" |
14147 | "Specify community to accept\n" | |
14148 | EXTCOMMUNITY_VAL_STR) | |
14149 | { | |
d62a17ae | 14150 | int style = EXTCOMMUNITY_LIST_STANDARD; |
14151 | int direct = 0; | |
14152 | char *cl_number_or_name = NULL; | |
42f914d4 | 14153 | |
d62a17ae | 14154 | int idx = 0; |
14155 | argv_find(argv, argc, "(1-99)", &idx); | |
14156 | argv_find(argv, argc, "WORD", &idx); | |
14157 | cl_number_or_name = argv[idx]->arg; | |
14158 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14159 | : COMMUNITY_DENY; | |
14160 | argv_find(argv, argc, "AA:NN", &idx); | |
14161 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14162 | |
d62a17ae | 14163 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
14164 | direct, style); | |
42f914d4 | 14165 | |
d62a17ae | 14166 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14167 | |
d62a17ae | 14168 | if (ret < 0) { |
14169 | community_list_perror(vty, ret); | |
14170 | return CMD_WARNING_CONFIG_FAILED; | |
14171 | } | |
42f914d4 | 14172 | |
d62a17ae | 14173 | return CMD_SUCCESS; |
718e3744 | 14174 | } |
14175 | ||
718e3744 | 14176 | DEFUN (ip_extcommunity_list_name_expanded, |
14177 | ip_extcommunity_list_name_expanded_cmd, | |
e961923c | 14178 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 14179 | IP_STR |
14180 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 14181 | "Extended Community list number (expanded)\n" |
718e3744 | 14182 | "Specify expanded extcommunity-list\n" |
14183 | "Extended Community list name\n" | |
14184 | "Specify community to reject\n" | |
14185 | "Specify community to accept\n" | |
14186 | "An ordered list as a regular-expression\n") | |
14187 | { | |
d62a17ae | 14188 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
14189 | int direct = 0; | |
14190 | char *cl_number_or_name = NULL; | |
42f914d4 | 14191 | |
d62a17ae | 14192 | int idx = 0; |
14193 | argv_find(argv, argc, "(100-500)", &idx); | |
14194 | argv_find(argv, argc, "WORD", &idx); | |
14195 | cl_number_or_name = argv[idx]->arg; | |
14196 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14197 | : COMMUNITY_DENY; | |
14198 | argv_find(argv, argc, "LINE", &idx); | |
14199 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14200 | |
d62a17ae | 14201 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
14202 | direct, style); | |
42f914d4 | 14203 | |
d62a17ae | 14204 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14205 | |
d62a17ae | 14206 | if (ret < 0) { |
14207 | community_list_perror(vty, ret); | |
14208 | return CMD_WARNING_CONFIG_FAILED; | |
14209 | } | |
42f914d4 | 14210 | |
d62a17ae | 14211 | return CMD_SUCCESS; |
718e3744 | 14212 | } |
14213 | ||
fee6e4e4 | 14214 | DEFUN (no_ip_extcommunity_list_standard_all, |
14215 | no_ip_extcommunity_list_standard_all_cmd, | |
e961923c | 14216 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", |
813d4307 DW |
14217 | NO_STR |
14218 | IP_STR | |
14219 | EXTCOMMUNITY_LIST_STR | |
14220 | "Extended Community list number (standard)\n" | |
718e3744 | 14221 | "Specify standard extcommunity-list\n" |
5bf15956 | 14222 | "Community list name\n" |
718e3744 | 14223 | "Specify community to reject\n" |
14224 | "Specify community to accept\n" | |
14225 | EXTCOMMUNITY_VAL_STR) | |
14226 | { | |
d62a17ae | 14227 | int style = EXTCOMMUNITY_LIST_STANDARD; |
14228 | int direct = 0; | |
14229 | char *cl_number_or_name = NULL; | |
42f914d4 | 14230 | |
d62a17ae | 14231 | int idx = 0; |
14232 | argv_find(argv, argc, "(1-99)", &idx); | |
14233 | argv_find(argv, argc, "WORD", &idx); | |
14234 | cl_number_or_name = argv[idx]->arg; | |
14235 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14236 | : COMMUNITY_DENY; | |
14237 | argv_find(argv, argc, "AA:NN", &idx); | |
14238 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14239 | |
d62a17ae | 14240 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 14241 | direct, style); |
42f914d4 | 14242 | |
d62a17ae | 14243 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14244 | |
d62a17ae | 14245 | if (ret < 0) { |
14246 | community_list_perror(vty, ret); | |
14247 | return CMD_WARNING_CONFIG_FAILED; | |
14248 | } | |
42f914d4 | 14249 | |
d62a17ae | 14250 | return CMD_SUCCESS; |
718e3744 | 14251 | } |
14252 | ||
5bf15956 DW |
14253 | DEFUN (no_ip_extcommunity_list_expanded_all, |
14254 | no_ip_extcommunity_list_expanded_all_cmd, | |
e961923c | 14255 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", |
718e3744 | 14256 | NO_STR |
14257 | IP_STR | |
14258 | EXTCOMMUNITY_LIST_STR | |
14259 | "Extended Community list number (expanded)\n" | |
718e3744 | 14260 | "Specify expanded extcommunity-list\n" |
5bf15956 | 14261 | "Extended Community list name\n" |
718e3744 | 14262 | "Specify community to reject\n" |
14263 | "Specify community to accept\n" | |
14264 | "An ordered list as a regular-expression\n") | |
14265 | { | |
d62a17ae | 14266 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
14267 | int direct = 0; | |
14268 | char *cl_number_or_name = NULL; | |
42f914d4 | 14269 | |
d62a17ae | 14270 | int idx = 0; |
14271 | argv_find(argv, argc, "(100-500)", &idx); | |
14272 | argv_find(argv, argc, "WORD", &idx); | |
14273 | cl_number_or_name = argv[idx]->arg; | |
14274 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14275 | : COMMUNITY_DENY; | |
14276 | argv_find(argv, argc, "LINE", &idx); | |
14277 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14278 | |
d62a17ae | 14279 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 14280 | direct, style); |
42f914d4 | 14281 | |
d62a17ae | 14282 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14283 | |
d62a17ae | 14284 | if (ret < 0) { |
14285 | community_list_perror(vty, ret); | |
14286 | return CMD_WARNING_CONFIG_FAILED; | |
14287 | } | |
42f914d4 | 14288 | |
d62a17ae | 14289 | return CMD_SUCCESS; |
718e3744 | 14290 | } |
14291 | ||
d62a17ae | 14292 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 14293 | { |
d62a17ae | 14294 | struct community_entry *entry; |
718e3744 | 14295 | |
d62a17ae | 14296 | for (entry = list->head; entry; entry = entry->next) { |
14297 | if (entry == list->head) { | |
14298 | if (all_digit(list->name)) | |
14299 | vty_out(vty, "Extended community %s list %s\n", | |
14300 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14301 | ? "standard" | |
14302 | : "(expanded) access", | |
14303 | list->name); | |
14304 | else | |
14305 | vty_out(vty, | |
14306 | "Named extended community %s list %s\n", | |
14307 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14308 | ? "standard" | |
14309 | : "expanded", | |
14310 | list->name); | |
14311 | } | |
14312 | if (entry->any) | |
14313 | vty_out(vty, " %s\n", | |
14314 | community_direct_str(entry->direct)); | |
14315 | else | |
14316 | vty_out(vty, " %s %s\n", | |
14317 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14318 | community_list_config_str(entry)); |
d62a17ae | 14319 | } |
718e3744 | 14320 | } |
14321 | ||
14322 | DEFUN (show_ip_extcommunity_list, | |
14323 | show_ip_extcommunity_list_cmd, | |
14324 | "show ip extcommunity-list", | |
14325 | SHOW_STR | |
14326 | IP_STR | |
14327 | "List extended-community list\n") | |
14328 | { | |
d62a17ae | 14329 | struct community_list *list; |
14330 | struct community_list_master *cm; | |
718e3744 | 14331 | |
d62a17ae | 14332 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
14333 | if (!cm) | |
14334 | return CMD_SUCCESS; | |
718e3744 | 14335 | |
d62a17ae | 14336 | for (list = cm->num.head; list; list = list->next) |
14337 | extcommunity_list_show(vty, list); | |
718e3744 | 14338 | |
d62a17ae | 14339 | for (list = cm->str.head; list; list = list->next) |
14340 | extcommunity_list_show(vty, list); | |
718e3744 | 14341 | |
d62a17ae | 14342 | return CMD_SUCCESS; |
718e3744 | 14343 | } |
14344 | ||
14345 | DEFUN (show_ip_extcommunity_list_arg, | |
14346 | show_ip_extcommunity_list_arg_cmd, | |
6147e2c6 | 14347 | "show ip extcommunity-list <(1-500)|WORD>", |
718e3744 | 14348 | SHOW_STR |
14349 | IP_STR | |
14350 | "List extended-community list\n" | |
14351 | "Extcommunity-list number\n" | |
14352 | "Extcommunity-list name\n") | |
14353 | { | |
d62a17ae | 14354 | int idx_comm_list = 3; |
14355 | struct community_list *list; | |
718e3744 | 14356 | |
d62a17ae | 14357 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, |
14358 | EXTCOMMUNITY_LIST_MASTER); | |
14359 | if (!list) { | |
14360 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
14361 | return CMD_WARNING; | |
14362 | } | |
718e3744 | 14363 | |
d62a17ae | 14364 | extcommunity_list_show(vty, list); |
718e3744 | 14365 | |
d62a17ae | 14366 | return CMD_SUCCESS; |
718e3744 | 14367 | } |
6b0655a2 | 14368 | |
718e3744 | 14369 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 14370 | static int community_list_config_write(struct vty *vty) |
14371 | { | |
14372 | struct community_list *list; | |
14373 | struct community_entry *entry; | |
14374 | struct community_list_master *cm; | |
14375 | int write = 0; | |
14376 | ||
14377 | /* Community-list. */ | |
14378 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
14379 | ||
14380 | for (list = cm->num.head; list; list = list->next) | |
14381 | for (entry = list->head; entry; entry = entry->next) { | |
14382 | vty_out(vty, "ip community-list %s %s %s\n", list->name, | |
14383 | community_direct_str(entry->direct), | |
14384 | community_list_config_str(entry)); | |
14385 | write++; | |
14386 | } | |
14387 | for (list = cm->str.head; list; list = list->next) | |
14388 | for (entry = list->head; entry; entry = entry->next) { | |
14389 | vty_out(vty, "ip community-list %s %s %s %s\n", | |
14390 | entry->style == COMMUNITY_LIST_STANDARD | |
14391 | ? "standard" | |
14392 | : "expanded", | |
14393 | list->name, community_direct_str(entry->direct), | |
14394 | community_list_config_str(entry)); | |
14395 | write++; | |
14396 | } | |
14397 | ||
14398 | /* Extcommunity-list. */ | |
14399 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
14400 | ||
14401 | for (list = cm->num.head; list; list = list->next) | |
14402 | for (entry = list->head; entry; entry = entry->next) { | |
14403 | vty_out(vty, "ip extcommunity-list %s %s %s\n", | |
14404 | list->name, community_direct_str(entry->direct), | |
14405 | community_list_config_str(entry)); | |
14406 | write++; | |
14407 | } | |
14408 | for (list = cm->str.head; list; list = list->next) | |
14409 | for (entry = list->head; entry; entry = entry->next) { | |
14410 | vty_out(vty, "ip extcommunity-list %s %s %s %s\n", | |
14411 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
14412 | ? "standard" | |
14413 | : "expanded", | |
14414 | list->name, community_direct_str(entry->direct), | |
14415 | community_list_config_str(entry)); | |
14416 | write++; | |
14417 | } | |
14418 | ||
14419 | ||
14420 | /* lcommunity-list. */ | |
14421 | cm = community_list_master_lookup(bgp_clist, | |
14422 | LARGE_COMMUNITY_LIST_MASTER); | |
14423 | ||
14424 | for (list = cm->num.head; list; list = list->next) | |
14425 | for (entry = list->head; entry; entry = entry->next) { | |
14426 | vty_out(vty, "ip large-community-list %s %s %s\n", | |
14427 | list->name, community_direct_str(entry->direct), | |
14428 | community_list_config_str(entry)); | |
14429 | write++; | |
14430 | } | |
14431 | for (list = cm->str.head; list; list = list->next) | |
14432 | for (entry = list->head; entry; entry = entry->next) { | |
14433 | vty_out(vty, "ip large-community-list %s %s %s %s\n", | |
14434 | entry->style == LARGE_COMMUNITY_LIST_STANDARD | |
14435 | ? "standard" | |
14436 | : "expanded", | |
14437 | list->name, community_direct_str(entry->direct), | |
14438 | community_list_config_str(entry)); | |
14439 | write++; | |
14440 | } | |
14441 | ||
14442 | return write; | |
14443 | } | |
14444 | ||
14445 | static struct cmd_node community_list_node = { | |
14446 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 14447 | }; |
14448 | ||
d62a17ae | 14449 | static void community_list_vty(void) |
14450 | { | |
14451 | install_node(&community_list_node, community_list_config_write); | |
14452 | ||
14453 | /* Community-list. */ | |
14454 | install_element(CONFIG_NODE, &ip_community_list_standard_cmd); | |
14455 | install_element(CONFIG_NODE, &ip_community_list_expanded_all_cmd); | |
14456 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_cmd); | |
14457 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); | |
14458 | install_element(VIEW_NODE, &show_ip_community_list_cmd); | |
14459 | install_element(VIEW_NODE, &show_ip_community_list_arg_cmd); | |
14460 | ||
14461 | /* Extcommunity-list. */ | |
14462 | install_element(CONFIG_NODE, &ip_extcommunity_list_standard_cmd); | |
14463 | install_element(CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); | |
14464 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); | |
14465 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); | |
14466 | install_element(VIEW_NODE, &show_ip_extcommunity_list_cmd); | |
14467 | install_element(VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
14468 | ||
14469 | /* Large Community List */ | |
14470 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard_cmd); | |
14471 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); | |
14472 | install_element(CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); | |
14473 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
14474 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); | |
14475 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); | |
14476 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
14477 | install_element(CONFIG_NODE, | |
14478 | &no_ip_lcommunity_list_name_expanded_all_cmd); | |
14479 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
14480 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
14481 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
14482 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
14483 | install_element(VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
14484 | install_element(VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 14485 | } |