]>
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" |
ec0ab544 | 25 | #include "lib/zclient.h" |
718e3744 | 26 | #include "prefix.h" |
27 | #include "plist.h" | |
28 | #include "buffer.h" | |
29 | #include "linklist.h" | |
30 | #include "stream.h" | |
31 | #include "thread.h" | |
32 | #include "log.h" | |
3b8b1855 | 33 | #include "memory.h" |
fc7948fa | 34 | #include "memory_vty.h" |
4bf6a362 | 35 | #include "hash.h" |
3f9c7369 | 36 | #include "queue.h" |
039f3a34 | 37 | #include "filter.h" |
5d5ba018 | 38 | #include "frrstr.h" |
718e3744 | 39 | |
40 | #include "bgpd/bgpd.h" | |
48ecf8f5 | 41 | #include "bgpd/bgp_attr_evpn.h" |
4bf6a362 | 42 | #include "bgpd/bgp_advertise.h" |
718e3744 | 43 | #include "bgpd/bgp_attr.h" |
44 | #include "bgpd/bgp_aspath.h" | |
45 | #include "bgpd/bgp_community.h" | |
4bf6a362 | 46 | #include "bgpd/bgp_ecommunity.h" |
57d187bc | 47 | #include "bgpd/bgp_lcommunity.h" |
4bf6a362 | 48 | #include "bgpd/bgp_damp.h" |
718e3744 | 49 | #include "bgpd/bgp_debug.h" |
14454c9f | 50 | #include "bgpd/bgp_errors.h" |
e0701b79 | 51 | #include "bgpd/bgp_fsm.h" |
4bf6a362 | 52 | #include "bgpd/bgp_nexthop.h" |
718e3744 | 53 | #include "bgpd/bgp_open.h" |
4bf6a362 | 54 | #include "bgpd/bgp_regex.h" |
718e3744 | 55 | #include "bgpd/bgp_route.h" |
c016b6c7 | 56 | #include "bgpd/bgp_mplsvpn.h" |
718e3744 | 57 | #include "bgpd/bgp_zebra.h" |
fee0f4c6 | 58 | #include "bgpd/bgp_table.h" |
94f2b392 | 59 | #include "bgpd/bgp_vty.h" |
165b5fff | 60 | #include "bgpd/bgp_mpath.h" |
cb1faec9 | 61 | #include "bgpd/bgp_packet.h" |
3f9c7369 | 62 | #include "bgpd/bgp_updgrp.h" |
c43ed2e4 | 63 | #include "bgpd/bgp_bfd.h" |
555e09d4 | 64 | #include "bgpd/bgp_io.h" |
94c2f693 | 65 | #include "bgpd/bgp_evpn.h" |
dcc68b5e | 66 | #include "bgpd/bgp_addpath.h" |
48ecf8f5 | 67 | #include "bgpd/bgp_mac.h" |
718e3744 | 68 | |
d62a17ae | 69 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
70 | struct prefix *range, int exact); | |
71 | ||
72 | static enum node_type bgp_node_type(afi_t afi, safi_t safi) | |
73 | { | |
74 | switch (afi) { | |
75 | case AFI_IP: | |
76 | switch (safi) { | |
77 | case SAFI_UNICAST: | |
78 | return BGP_IPV4_NODE; | |
79 | break; | |
80 | case SAFI_MULTICAST: | |
81 | return BGP_IPV4M_NODE; | |
82 | break; | |
83 | case SAFI_LABELED_UNICAST: | |
84 | return BGP_IPV4L_NODE; | |
85 | break; | |
86 | case SAFI_MPLS_VPN: | |
87 | return BGP_VPNV4_NODE; | |
88 | break; | |
7c40bf39 | 89 | case SAFI_FLOWSPEC: |
90 | return BGP_FLOWSPECV4_NODE; | |
5c525538 RW |
91 | default: |
92 | /* not expected */ | |
93 | return BGP_IPV4_NODE; | |
94 | break; | |
d62a17ae | 95 | } |
96 | break; | |
97 | case AFI_IP6: | |
98 | switch (safi) { | |
99 | case SAFI_UNICAST: | |
100 | return BGP_IPV6_NODE; | |
101 | break; | |
102 | case SAFI_MULTICAST: | |
103 | return BGP_IPV6M_NODE; | |
104 | break; | |
105 | case SAFI_LABELED_UNICAST: | |
106 | return BGP_IPV6L_NODE; | |
107 | break; | |
108 | case SAFI_MPLS_VPN: | |
109 | return BGP_VPNV6_NODE; | |
110 | break; | |
7c40bf39 | 111 | case SAFI_FLOWSPEC: |
112 | return BGP_FLOWSPECV6_NODE; | |
5c525538 RW |
113 | default: |
114 | /* not expected */ | |
115 | return BGP_IPV4_NODE; | |
116 | break; | |
d62a17ae | 117 | } |
118 | break; | |
119 | case AFI_L2VPN: | |
120 | return BGP_EVPN_NODE; | |
121 | break; | |
122 | case AFI_MAX: | |
123 | // We should never be here but to clarify the switch statement.. | |
124 | return BGP_IPV4_NODE; | |
125 | break; | |
126 | } | |
127 | ||
128 | // Impossible to happen | |
129 | return BGP_IPV4_NODE; | |
f51bae9c | 130 | } |
20eb8864 | 131 | |
718e3744 | 132 | /* Utility function to get address family from current node. */ |
d62a17ae | 133 | afi_t bgp_node_afi(struct vty *vty) |
134 | { | |
135 | afi_t afi; | |
136 | switch (vty->node) { | |
137 | case BGP_IPV6_NODE: | |
138 | case BGP_IPV6M_NODE: | |
139 | case BGP_IPV6L_NODE: | |
140 | case BGP_VPNV6_NODE: | |
7c40bf39 | 141 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 142 | afi = AFI_IP6; |
143 | break; | |
144 | case BGP_EVPN_NODE: | |
145 | afi = AFI_L2VPN; | |
146 | break; | |
147 | default: | |
148 | afi = AFI_IP; | |
149 | break; | |
150 | } | |
151 | return afi; | |
718e3744 | 152 | } |
153 | ||
154 | /* Utility function to get subsequent address family from current | |
155 | node. */ | |
d62a17ae | 156 | safi_t bgp_node_safi(struct vty *vty) |
157 | { | |
158 | safi_t safi; | |
159 | switch (vty->node) { | |
160 | case BGP_VPNV4_NODE: | |
161 | case BGP_VPNV6_NODE: | |
162 | safi = SAFI_MPLS_VPN; | |
163 | break; | |
164 | case BGP_IPV4M_NODE: | |
165 | case BGP_IPV6M_NODE: | |
166 | safi = SAFI_MULTICAST; | |
167 | break; | |
168 | case BGP_EVPN_NODE: | |
169 | safi = SAFI_EVPN; | |
170 | break; | |
171 | case BGP_IPV4L_NODE: | |
172 | case BGP_IPV6L_NODE: | |
173 | safi = SAFI_LABELED_UNICAST; | |
174 | break; | |
7c40bf39 | 175 | case BGP_FLOWSPECV4_NODE: |
176 | case BGP_FLOWSPECV6_NODE: | |
177 | safi = SAFI_FLOWSPEC; | |
178 | break; | |
d62a17ae | 179 | default: |
180 | safi = SAFI_UNICAST; | |
181 | break; | |
182 | } | |
183 | return safi; | |
718e3744 | 184 | } |
185 | ||
55f91488 QY |
186 | /** |
187 | * Converts an AFI in string form to afi_t | |
188 | * | |
189 | * @param afi string, one of | |
190 | * - "ipv4" | |
191 | * - "ipv6" | |
81cf0de5 | 192 | * - "l2vpn" |
55f91488 QY |
193 | * @return the corresponding afi_t |
194 | */ | |
d62a17ae | 195 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
196 | { | |
197 | afi_t afi = AFI_MAX; /* unknown */ | |
198 | if (strmatch(afi_str, "ipv4")) | |
199 | afi = AFI_IP; | |
200 | else if (strmatch(afi_str, "ipv6")) | |
201 | afi = AFI_IP6; | |
81cf0de5 CS |
202 | else if (strmatch(afi_str, "l2vpn")) |
203 | afi = AFI_L2VPN; | |
d62a17ae | 204 | return afi; |
205 | } | |
206 | ||
207 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
208 | afi_t *afi) | |
209 | { | |
210 | int ret = 0; | |
211 | if (argv_find(argv, argc, "ipv4", index)) { | |
212 | ret = 1; | |
213 | if (afi) | |
214 | *afi = AFI_IP; | |
215 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
216 | ret = 1; | |
217 | if (afi) | |
218 | *afi = AFI_IP6; | |
219 | } | |
220 | return ret; | |
46f296b4 LB |
221 | } |
222 | ||
375a2e67 | 223 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 224 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
225 | { | |
226 | safi_t safi = SAFI_MAX; /* unknown */ | |
227 | if (strmatch(safi_str, "multicast")) | |
228 | safi = SAFI_MULTICAST; | |
229 | else if (strmatch(safi_str, "unicast")) | |
230 | safi = SAFI_UNICAST; | |
231 | else if (strmatch(safi_str, "vpn")) | |
232 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
233 | else if (strmatch(safi_str, "evpn")) |
234 | safi = SAFI_EVPN; | |
d62a17ae | 235 | else if (strmatch(safi_str, "labeled-unicast")) |
236 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 237 | else if (strmatch(safi_str, "flowspec")) |
238 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 239 | return safi; |
240 | } | |
241 | ||
242 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
243 | safi_t *safi) | |
244 | { | |
245 | int ret = 0; | |
246 | if (argv_find(argv, argc, "unicast", index)) { | |
247 | ret = 1; | |
248 | if (safi) | |
249 | *safi = SAFI_UNICAST; | |
250 | } else if (argv_find(argv, argc, "multicast", index)) { | |
251 | ret = 1; | |
252 | if (safi) | |
253 | *safi = SAFI_MULTICAST; | |
254 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
255 | ret = 1; | |
256 | if (safi) | |
257 | *safi = SAFI_LABELED_UNICAST; | |
258 | } else if (argv_find(argv, argc, "vpn", index)) { | |
259 | ret = 1; | |
260 | if (safi) | |
261 | *safi = SAFI_MPLS_VPN; | |
7c40bf39 | 262 | } else if (argv_find(argv, argc, "flowspec", index)) { |
263 | ret = 1; | |
264 | if (safi) | |
265 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 266 | } |
267 | return ret; | |
46f296b4 LB |
268 | } |
269 | ||
7eeee51e | 270 | /* |
f212a857 | 271 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 272 | * |
f212a857 DS |
273 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
274 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
275 | * to appropriate values for the calling function. This is to allow the |
276 | * calling function to make decisions appropriate for the show command | |
277 | * that is being parsed. | |
278 | * | |
279 | * The show commands are generally of the form: | |
d62a17ae | 280 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
281 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
282 | * |
283 | * Since we use argv_find if the show command in particular doesn't have: | |
284 | * [ip] | |
18c57037 | 285 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 286 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
287 | * The command parsing should still be ok. |
288 | * | |
289 | * vty -> The vty for the command so we can output some useful data in | |
290 | * the event of a parse error in the vrf. | |
291 | * argv -> The command tokens | |
292 | * argc -> How many command tokens we have | |
d62a17ae | 293 | * idx -> The current place in the command, generally should be 0 for this |
294 | * function | |
7eeee51e DS |
295 | * afi -> The parsed afi if it was included in the show command, returned here |
296 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 297 | * bgp -> Pointer to the bgp data structure we need to fill in. |
87338296 | 298 | * use_json -> json is configured or not |
7eeee51e DS |
299 | * |
300 | * The function returns the correct location in the parse tree for the | |
301 | * last token found. | |
0e37c258 DS |
302 | * |
303 | * Returns 0 for failure to parse correctly, else the idx position of where | |
304 | * it found the last token. | |
7eeee51e | 305 | */ |
d62a17ae | 306 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
307 | struct cmd_token **argv, int argc, | |
308 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 309 | struct bgp **bgp, bool use_json) |
d62a17ae | 310 | { |
311 | char *vrf_name = NULL; | |
312 | ||
313 | assert(afi); | |
314 | assert(safi); | |
315 | assert(bgp); | |
316 | ||
317 | if (argv_find(argv, argc, "ip", idx)) | |
318 | *afi = AFI_IP; | |
319 | ||
9a8bdf1c | 320 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 321 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
322 | else if (argv_find(argv, argc, "vrf", idx)) { |
323 | vrf_name = argv[*idx + 1]->arg; | |
324 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
325 | vrf_name = NULL; | |
326 | } | |
327 | if (vrf_name) { | |
d62a17ae | 328 | if (strmatch(vrf_name, "all")) |
329 | *bgp = NULL; | |
330 | else { | |
331 | *bgp = bgp_lookup_by_name(vrf_name); | |
332 | if (!*bgp) { | |
87338296 SP |
333 | if (use_json) { |
334 | json_object *json = NULL; | |
335 | json = json_object_new_object(); | |
336 | json_object_string_add( | |
337 | json, "warning", | |
338 | "View/Vrf is unknown"); | |
339 | vty_out(vty, "%s\n", | |
340 | json_object_to_json_string_ext(json, | |
341 | JSON_C_TO_STRING_PRETTY)); | |
342 | json_object_free(json); | |
343 | } | |
ca61fd25 DS |
344 | else |
345 | vty_out(vty, "View/Vrf %s is unknown\n", | |
346 | vrf_name); | |
d62a17ae | 347 | *idx = 0; |
348 | return 0; | |
349 | } | |
350 | } | |
351 | } else { | |
352 | *bgp = bgp_get_default(); | |
353 | if (!*bgp) { | |
87338296 SP |
354 | if (use_json) { |
355 | json_object *json = NULL; | |
356 | json = json_object_new_object(); | |
357 | json_object_string_add( | |
358 | json, "warning", | |
359 | "Default BGP instance not found"); | |
360 | vty_out(vty, "%s\n", | |
361 | json_object_to_json_string_ext(json, | |
362 | JSON_C_TO_STRING_PRETTY)); | |
363 | json_object_free(json); | |
364 | } | |
ca61fd25 DS |
365 | else |
366 | vty_out(vty, | |
367 | "Default BGP instance not found\n"); | |
d62a17ae | 368 | *idx = 0; |
369 | return 0; | |
370 | } | |
371 | } | |
372 | ||
373 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
374 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
375 | ||
376 | *idx += 1; | |
377 | return *idx; | |
378 | } | |
379 | ||
380 | static int peer_address_self_check(struct bgp *bgp, union sockunion *su) | |
381 | { | |
382 | struct interface *ifp = NULL; | |
383 | ||
384 | if (su->sa.sa_family == AF_INET) | |
385 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
386 | else if (su->sa.sa_family == AF_INET6) | |
387 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
388 | su->sin6.sin6_scope_id, | |
389 | bgp->vrf_id); | |
390 | ||
391 | if (ifp) | |
392 | return 1; | |
393 | ||
394 | return 0; | |
718e3744 | 395 | } |
396 | ||
397 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
398 | /* This is used only for configuration, so disallow if attempted on |
399 | * a dynamic neighbor. | |
400 | */ | |
d62a17ae | 401 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
402 | { | |
403 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
404 | int ret; | |
405 | union sockunion su; | |
406 | struct peer *peer; | |
407 | ||
408 | if (!bgp) { | |
409 | return NULL; | |
410 | } | |
411 | ||
412 | ret = str2sockunion(ip_str, &su); | |
413 | if (ret < 0) { | |
414 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
415 | if (!peer) { | |
416 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
417 | == NULL) { | |
418 | vty_out(vty, | |
419 | "%% Malformed address or name: %s\n", | |
420 | ip_str); | |
421 | return NULL; | |
422 | } | |
423 | } | |
424 | } else { | |
425 | peer = peer_lookup(bgp, &su); | |
426 | if (!peer) { | |
427 | vty_out(vty, | |
428 | "%% Specify remote-as or peer-group commands first\n"); | |
429 | return NULL; | |
430 | } | |
431 | if (peer_dynamic_neighbor(peer)) { | |
432 | vty_out(vty, | |
433 | "%% Operation not allowed on a dynamic neighbor\n"); | |
434 | return NULL; | |
435 | } | |
436 | } | |
437 | return peer; | |
718e3744 | 438 | } |
439 | ||
440 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
441 | /* This is used only for configuration, so disallow if attempted on |
442 | * a dynamic neighbor. | |
443 | */ | |
d62a17ae | 444 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
445 | { | |
446 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
447 | int ret; | |
448 | union sockunion su; | |
449 | struct peer *peer = NULL; | |
450 | struct peer_group *group = NULL; | |
451 | ||
452 | if (!bgp) { | |
453 | return NULL; | |
454 | } | |
455 | ||
456 | ret = str2sockunion(peer_str, &su); | |
457 | if (ret == 0) { | |
458 | /* IP address, locate peer. */ | |
459 | peer = peer_lookup(bgp, &su); | |
460 | } else { | |
461 | /* Not IP, could match either peer configured on interface or a | |
462 | * group. */ | |
463 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
464 | if (!peer) | |
465 | group = peer_group_lookup(bgp, peer_str); | |
466 | } | |
467 | ||
468 | if (peer) { | |
469 | if (peer_dynamic_neighbor(peer)) { | |
470 | vty_out(vty, | |
471 | "%% Operation not allowed on a dynamic neighbor\n"); | |
472 | return NULL; | |
473 | } | |
474 | ||
475 | return peer; | |
476 | } | |
477 | ||
478 | if (group) | |
479 | return group->conf; | |
480 | ||
481 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
482 | ||
483 | return NULL; | |
484 | } | |
485 | ||
486 | int bgp_vty_return(struct vty *vty, int ret) | |
487 | { | |
488 | const char *str = NULL; | |
489 | ||
490 | switch (ret) { | |
491 | case BGP_ERR_INVALID_VALUE: | |
492 | str = "Invalid value"; | |
493 | break; | |
494 | case BGP_ERR_INVALID_FLAG: | |
495 | str = "Invalid flag"; | |
496 | break; | |
497 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
498 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
499 | break; | |
500 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
501 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
502 | break; | |
503 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
504 | str = "Specify remote-as or peer-group remote AS first"; | |
505 | break; | |
506 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
507 | str = "Cannot change the peer-group. Deconfigure first"; | |
508 | break; | |
509 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
510 | str = "Peer is not a member of this peer-group"; | |
511 | break; | |
512 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
513 | str = "Prefix/distribute list can not co-exist"; | |
514 | break; | |
515 | case BGP_ERR_NOT_INTERNAL_PEER: | |
516 | str = "Invalid command. Not an internal neighbor"; | |
517 | break; | |
518 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
519 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
520 | break; | |
521 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
522 | str = "Local-AS allowed only for EBGP peers"; | |
523 | break; | |
524 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
525 | str = "Cannot have local-as same as BGP AS number"; | |
526 | break; | |
527 | case BGP_ERR_TCPSIG_FAILED: | |
528 | str = "Error while applying TCP-Sig to session(s)"; | |
529 | break; | |
530 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
531 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
532 | break; | |
533 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
534 | str = "ttl-security only allowed for EBGP peers"; | |
535 | break; | |
536 | case BGP_ERR_AS_OVERRIDE: | |
537 | str = "as-override cannot be configured for IBGP peers"; | |
538 | break; | |
539 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
540 | str = "Invalid limit for number of dynamic neighbors"; | |
541 | break; | |
542 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
543 | str = "Dynamic neighbor listen range already exists"; | |
544 | break; | |
545 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
546 | str = "Operation not allowed on a dynamic neighbor"; | |
547 | break; | |
548 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
549 | str = "Operation not allowed on a directly connected neighbor"; | |
550 | break; | |
551 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
552 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; | |
553 | break; | |
554 | } | |
555 | if (str) { | |
556 | vty_out(vty, "%% %s\n", str); | |
557 | return CMD_WARNING_CONFIG_FAILED; | |
558 | } | |
559 | return CMD_SUCCESS; | |
718e3744 | 560 | } |
561 | ||
7aafcaca | 562 | /* BGP clear sort. */ |
d62a17ae | 563 | enum clear_sort { |
564 | clear_all, | |
565 | clear_peer, | |
566 | clear_group, | |
567 | clear_external, | |
568 | clear_as | |
7aafcaca DS |
569 | }; |
570 | ||
d62a17ae | 571 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
572 | safi_t safi, int error) | |
573 | { | |
574 | switch (error) { | |
575 | case BGP_ERR_AF_UNCONFIGURED: | |
576 | vty_out(vty, | |
577 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
578 | afi_safi_print(afi, safi), peer->host); | |
579 | break; | |
580 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
581 | vty_out(vty, | |
582 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
583 | peer->host); | |
584 | break; | |
585 | default: | |
586 | break; | |
587 | } | |
7aafcaca DS |
588 | } |
589 | ||
590 | /* `clear ip bgp' functions. */ | |
d62a17ae | 591 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
592 | enum clear_sort sort, enum bgp_clear_type stype, | |
593 | const char *arg) | |
594 | { | |
595 | int ret; | |
3ae8bfa5 | 596 | bool found = false; |
d62a17ae | 597 | struct peer *peer; |
598 | struct listnode *node, *nnode; | |
599 | ||
600 | /* Clear all neighbors. */ | |
601 | /* | |
602 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
603 | * nodes on the BGP instance as that may get freed if it is a |
604 | * doppelganger | |
d62a17ae | 605 | */ |
606 | if (sort == clear_all) { | |
607 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
3ae8bfa5 PM |
608 | if (!peer->afc[afi][safi]) |
609 | continue; | |
610 | ||
d62a17ae | 611 | if (stype == BGP_CLEAR_SOFT_NONE) |
612 | ret = peer_clear(peer, &nnode); | |
d62a17ae | 613 | else |
3ae8bfa5 | 614 | ret = peer_clear_soft(peer, afi, safi, stype); |
d62a17ae | 615 | |
616 | if (ret < 0) | |
617 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
618 | else |
619 | found = true; | |
04b6bdc0 | 620 | } |
d62a17ae | 621 | |
622 | /* This is to apply read-only mode on this clear. */ | |
623 | if (stype == BGP_CLEAR_SOFT_NONE) | |
624 | bgp->update_delay_over = 0; | |
625 | ||
3ae8bfa5 | 626 | if (!found) |
3702f84d | 627 | vty_out(vty, "%%BGP: No %s peer configured\n", |
3ae8bfa5 PM |
628 | afi_safi_print(afi, safi)); |
629 | ||
d62a17ae | 630 | return CMD_SUCCESS; |
7aafcaca DS |
631 | } |
632 | ||
3ae8bfa5 | 633 | /* Clear specified neighbor. */ |
d62a17ae | 634 | if (sort == clear_peer) { |
635 | union sockunion su; | |
d62a17ae | 636 | |
637 | /* Make sockunion for lookup. */ | |
638 | ret = str2sockunion(arg, &su); | |
639 | if (ret < 0) { | |
640 | peer = peer_lookup_by_conf_if(bgp, arg); | |
641 | if (!peer) { | |
642 | peer = peer_lookup_by_hostname(bgp, arg); | |
643 | if (!peer) { | |
644 | vty_out(vty, | |
645 | "Malformed address or name: %s\n", | |
646 | arg); | |
647 | return CMD_WARNING; | |
648 | } | |
649 | } | |
650 | } else { | |
651 | peer = peer_lookup(bgp, &su); | |
652 | if (!peer) { | |
653 | vty_out(vty, | |
654 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
655 | arg); | |
656 | return CMD_WARNING; | |
657 | } | |
658 | } | |
7aafcaca | 659 | |
3ae8bfa5 PM |
660 | if (!peer->afc[afi][safi]) |
661 | ret = BGP_ERR_AF_UNCONFIGURED; | |
662 | else if (stype == BGP_CLEAR_SOFT_NONE) | |
d62a17ae | 663 | ret = peer_clear(peer, NULL); |
664 | else | |
665 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 666 | |
d62a17ae | 667 | if (ret < 0) |
668 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 669 | |
d62a17ae | 670 | return CMD_SUCCESS; |
7aafcaca | 671 | } |
7aafcaca | 672 | |
3ae8bfa5 | 673 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 674 | if (sort == clear_group) { |
675 | struct peer_group *group; | |
7aafcaca | 676 | |
d62a17ae | 677 | group = peer_group_lookup(bgp, arg); |
678 | if (!group) { | |
679 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
680 | return CMD_WARNING; | |
681 | } | |
682 | ||
683 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
d62a17ae | 684 | if (!peer->afc[afi][safi]) |
685 | continue; | |
686 | ||
3ae8bfa5 PM |
687 | if (stype == BGP_CLEAR_SOFT_NONE) |
688 | ret = peer_clear(peer, NULL); | |
689 | else | |
690 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 691 | |
d62a17ae | 692 | if (ret < 0) |
693 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
694 | else |
695 | found = true; | |
d62a17ae | 696 | } |
3ae8bfa5 PM |
697 | |
698 | if (!found) | |
699 | vty_out(vty, | |
700 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
701 | afi_safi_print(afi, safi), arg); | |
702 | ||
d62a17ae | 703 | return CMD_SUCCESS; |
7aafcaca | 704 | } |
7aafcaca | 705 | |
3ae8bfa5 | 706 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 707 | if (sort == clear_external) { |
708 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
709 | if (peer->sort == BGP_PEER_IBGP) | |
710 | continue; | |
7aafcaca | 711 | |
3ae8bfa5 PM |
712 | if (!peer->afc[afi][safi]) |
713 | continue; | |
714 | ||
d62a17ae | 715 | if (stype == BGP_CLEAR_SOFT_NONE) |
716 | ret = peer_clear(peer, &nnode); | |
717 | else | |
718 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 719 | |
d62a17ae | 720 | if (ret < 0) |
721 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
722 | else |
723 | found = true; | |
d62a17ae | 724 | } |
3ae8bfa5 PM |
725 | |
726 | if (!found) | |
727 | vty_out(vty, | |
728 | "%%BGP: No external %s peer is configured\n", | |
729 | afi_safi_print(afi, safi)); | |
730 | ||
d62a17ae | 731 | return CMD_SUCCESS; |
732 | } | |
733 | ||
3ae8bfa5 | 734 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 735 | if (sort == clear_as) { |
3ae8bfa5 | 736 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 737 | |
738 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
739 | if (peer->as != as) | |
740 | continue; | |
741 | ||
3ae8bfa5 PM |
742 | if (!peer->afc[afi][safi]) |
743 | ret = BGP_ERR_AF_UNCONFIGURED; | |
744 | else if (stype == BGP_CLEAR_SOFT_NONE) | |
d62a17ae | 745 | ret = peer_clear(peer, &nnode); |
746 | else | |
747 | ret = peer_clear_soft(peer, afi, safi, stype); | |
748 | ||
749 | if (ret < 0) | |
750 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
751 | else |
752 | found = true; | |
d62a17ae | 753 | } |
3ae8bfa5 PM |
754 | |
755 | if (!found) | |
d62a17ae | 756 | vty_out(vty, |
3ae8bfa5 PM |
757 | "%%BGP: No %s peer is configured with AS %s\n", |
758 | afi_safi_print(afi, safi), arg); | |
759 | ||
d62a17ae | 760 | return CMD_SUCCESS; |
761 | } | |
762 | ||
763 | return CMD_SUCCESS; | |
764 | } | |
765 | ||
766 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
767 | safi_t safi, enum clear_sort sort, | |
768 | enum bgp_clear_type stype, const char *arg) | |
769 | { | |
770 | struct bgp *bgp; | |
771 | ||
772 | /* BGP structure lookup. */ | |
773 | if (name) { | |
774 | bgp = bgp_lookup_by_name(name); | |
775 | if (bgp == NULL) { | |
776 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
777 | return CMD_WARNING; | |
778 | } | |
779 | } else { | |
780 | bgp = bgp_get_default(); | |
781 | if (bgp == NULL) { | |
782 | vty_out(vty, "No BGP process is configured\n"); | |
783 | return CMD_WARNING; | |
784 | } | |
785 | } | |
786 | ||
787 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
788 | } |
789 | ||
790 | /* clear soft inbound */ | |
d62a17ae | 791 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 792 | { |
99b3ebd3 NS |
793 | afi_t afi; |
794 | safi_t safi; | |
795 | ||
796 | FOREACH_AFI_SAFI (afi, safi) | |
797 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
798 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
799 | } |
800 | ||
801 | /* clear soft outbound */ | |
d62a17ae | 802 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 803 | { |
99b3ebd3 NS |
804 | afi_t afi; |
805 | safi_t safi; | |
806 | ||
807 | FOREACH_AFI_SAFI (afi, safi) | |
808 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
809 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
810 | } |
811 | ||
812 | ||
f787d7a0 | 813 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 814 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
815 | #endif |
816 | ||
718e3744 | 817 | /* BGP global configuration. */ |
bee57a7a | 818 | #if (CONFDATE > 20190601) |
1cc40660 DS |
819 | CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance") |
820 | CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE") | |
821 | #endif | |
822 | DEFUN_HIDDEN (bgp_multiple_instance_func, | |
823 | bgp_multiple_instance_cmd, | |
824 | "bgp multiple-instance", | |
825 | BGP_STR | |
826 | "Enable bgp multiple instance\n") | |
718e3744 | 827 | { |
d62a17ae | 828 | bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE); |
829 | return CMD_SUCCESS; | |
718e3744 | 830 | } |
831 | ||
1cc40660 | 832 | DEFUN_HIDDEN (no_bgp_multiple_instance, |
718e3744 | 833 | no_bgp_multiple_instance_cmd, |
834 | "no bgp multiple-instance", | |
835 | NO_STR | |
836 | BGP_STR | |
837 | "BGP multiple instance\n") | |
838 | { | |
d62a17ae | 839 | int ret; |
718e3744 | 840 | |
1cc40660 DS |
841 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); |
842 | vty_out(vty, "if you are using this please let the developers know\n"); | |
b7cd3069 | 843 | zlog_info("Deprecated option: `bgp multiple-instance` being used"); |
d62a17ae | 844 | ret = bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE); |
845 | if (ret < 0) { | |
846 | vty_out(vty, "%% There are more than two BGP instances\n"); | |
847 | return CMD_WARNING_CONFIG_FAILED; | |
848 | } | |
849 | return CMD_SUCCESS; | |
718e3744 | 850 | } |
851 | ||
8029b216 AK |
852 | DEFUN_HIDDEN (bgp_local_mac, |
853 | bgp_local_mac_cmd, | |
093e3f23 | 854 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
855 | BGP_STR |
856 | "Local MAC config\n" | |
857 | "VxLAN Network Identifier\n" | |
858 | "VNI number\n" | |
859 | "local mac\n" | |
860 | "mac address\n" | |
861 | "mac-mobility sequence\n" | |
862 | "seq number\n") | |
863 | { | |
864 | int rv; | |
865 | vni_t vni; | |
866 | struct ethaddr mac; | |
867 | struct ipaddr ip; | |
868 | uint32_t seq; | |
869 | struct bgp *bgp; | |
870 | ||
871 | vni = strtoul(argv[3]->arg, NULL, 10); | |
872 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
873 | vty_out(vty, "%% Malformed MAC address\n"); | |
874 | return CMD_WARNING; | |
875 | } | |
876 | memset(&ip, 0, sizeof(ip)); | |
877 | seq = strtoul(argv[7]->arg, NULL, 10); | |
878 | ||
879 | bgp = bgp_get_default(); | |
880 | if (!bgp) { | |
881 | vty_out(vty, "Default BGP instance is not there\n"); | |
882 | return CMD_WARNING; | |
883 | } | |
884 | ||
885 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq); | |
886 | if (rv < 0) { | |
887 | vty_out(vty, "Internal error\n"); | |
888 | return CMD_WARNING; | |
889 | } | |
890 | ||
891 | return CMD_SUCCESS; | |
892 | } | |
893 | ||
894 | DEFUN_HIDDEN (no_bgp_local_mac, | |
895 | no_bgp_local_mac_cmd, | |
093e3f23 | 896 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
897 | NO_STR |
898 | BGP_STR | |
899 | "Local MAC config\n" | |
900 | "VxLAN Network Identifier\n" | |
901 | "VNI number\n" | |
902 | "local mac\n" | |
903 | "mac address\n") | |
904 | { | |
905 | int rv; | |
906 | vni_t vni; | |
907 | struct ethaddr mac; | |
908 | struct ipaddr ip; | |
909 | struct bgp *bgp; | |
910 | ||
911 | vni = strtoul(argv[4]->arg, NULL, 10); | |
912 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
913 | vty_out(vty, "%% Malformed MAC address\n"); | |
914 | return CMD_WARNING; | |
915 | } | |
916 | memset(&ip, 0, sizeof(ip)); | |
917 | ||
918 | bgp = bgp_get_default(); | |
919 | if (!bgp) { | |
920 | vty_out(vty, "Default BGP instance is not there\n"); | |
921 | return CMD_WARNING; | |
922 | } | |
923 | ||
ec0ab544 | 924 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
925 | if (rv < 0) { |
926 | vty_out(vty, "Internal error\n"); | |
927 | return CMD_WARNING; | |
928 | } | |
929 | ||
930 | return CMD_SUCCESS; | |
931 | } | |
932 | ||
bee57a7a | 933 | #if (CONFDATE > 20190601) |
798467a2 DS |
934 | CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco") |
935 | CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG") | |
936 | #endif | |
937 | DEFUN_HIDDEN (bgp_config_type, | |
938 | bgp_config_type_cmd, | |
939 | "bgp config-type <cisco|zebra>", | |
940 | BGP_STR | |
941 | "Configuration type\n" | |
942 | "cisco\n" | |
943 | "zebra\n") | |
718e3744 | 944 | { |
d62a17ae | 945 | int idx = 0; |
798467a2 DS |
946 | if (argv_find(argv, argc, "cisco", &idx)) { |
947 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
948 | vty_out(vty, "if you are using this please let the developers know!\n"); | |
b7cd3069 | 949 | zlog_info("Deprecated option: `bgp config-type cisco` being used"); |
d62a17ae | 950 | bgp_option_set(BGP_OPT_CONFIG_CISCO); |
798467a2 | 951 | } else |
d62a17ae | 952 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
718e3744 | 953 | |
d62a17ae | 954 | return CMD_SUCCESS; |
718e3744 | 955 | } |
956 | ||
798467a2 DS |
957 | DEFUN_HIDDEN (no_bgp_config_type, |
958 | no_bgp_config_type_cmd, | |
959 | "no bgp config-type [<cisco|zebra>]", | |
960 | NO_STR | |
961 | BGP_STR | |
962 | "Display configuration type\n" | |
963 | "cisco\n" | |
964 | "zebra\n") | |
718e3744 | 965 | { |
d62a17ae | 966 | bgp_option_unset(BGP_OPT_CONFIG_CISCO); |
967 | return CMD_SUCCESS; | |
718e3744 | 968 | } |
969 | ||
813d4307 | 970 | |
718e3744 | 971 | DEFUN (no_synchronization, |
972 | no_synchronization_cmd, | |
973 | "no synchronization", | |
974 | NO_STR | |
975 | "Perform IGP synchronization\n") | |
976 | { | |
d62a17ae | 977 | return CMD_SUCCESS; |
718e3744 | 978 | } |
979 | ||
980 | DEFUN (no_auto_summary, | |
981 | no_auto_summary_cmd, | |
982 | "no auto-summary", | |
983 | NO_STR | |
984 | "Enable automatic network number summarization\n") | |
985 | { | |
d62a17ae | 986 | return CMD_SUCCESS; |
718e3744 | 987 | } |
3d515fd9 | 988 | |
718e3744 | 989 | /* "router bgp" commands. */ |
505e5056 | 990 | DEFUN_NOSH (router_bgp, |
f412b39a | 991 | router_bgp_cmd, |
18c57037 | 992 | "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 993 | ROUTER_STR |
994 | BGP_STR | |
31500417 DW |
995 | AS_STR |
996 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 997 | { |
d62a17ae | 998 | int idx_asn = 2; |
999 | int idx_view_vrf = 3; | |
1000 | int idx_vrf = 4; | |
ecec9495 | 1001 | int is_new_bgp = 0; |
d62a17ae | 1002 | int ret; |
1003 | as_t as; | |
1004 | struct bgp *bgp; | |
1005 | const char *name = NULL; | |
1006 | enum bgp_instance_type inst_type; | |
1007 | ||
1008 | // "router bgp" without an ASN | |
1009 | if (argc == 2) { | |
1010 | // Pending: Make VRF option available for ASN less config | |
1011 | bgp = bgp_get_default(); | |
1012 | ||
1013 | if (bgp == NULL) { | |
1014 | vty_out(vty, "%% No BGP process is configured\n"); | |
1015 | return CMD_WARNING_CONFIG_FAILED; | |
1016 | } | |
1017 | ||
1018 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 1019 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1020 | return CMD_WARNING_CONFIG_FAILED; |
1021 | } | |
1022 | } | |
1023 | ||
1024 | // "router bgp X" | |
1025 | else { | |
1026 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
1027 | ||
1028 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
1029 | if (argc > 3) { | |
1030 | name = argv[idx_vrf]->arg; | |
1031 | ||
9a8bdf1c PG |
1032 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
1033 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
1034 | name = NULL; | |
1035 | else | |
1036 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
1037 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
d62a17ae | 1038 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
1039 | } | |
1040 | ||
ecec9495 AD |
1041 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
1042 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
1043 | ||
d62a17ae | 1044 | ret = bgp_get(&bgp, &as, name, inst_type); |
1045 | switch (ret) { | |
1046 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
1047 | vty_out(vty, | |
1048 | "Please specify 'bgp multiple-instance' first\n"); | |
1049 | return CMD_WARNING_CONFIG_FAILED; | |
1050 | case BGP_ERR_AS_MISMATCH: | |
1051 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
1052 | return CMD_WARNING_CONFIG_FAILED; | |
1053 | case BGP_ERR_INSTANCE_MISMATCH: | |
1054 | vty_out(vty, | |
1055 | "BGP instance name and AS number mismatch\n"); | |
1056 | vty_out(vty, | |
1057 | "BGP instance is already running; AS is %u\n", | |
1058 | as); | |
1059 | return CMD_WARNING_CONFIG_FAILED; | |
1060 | } | |
1061 | ||
3bd70bf8 PZ |
1062 | /* |
1063 | * If we just instantiated the default instance, complete | |
1064 | * any pending VRF-VPN leaking that was configured via | |
1065 | * earlier "router bgp X vrf FOO" blocks. | |
1066 | */ | |
ecec9495 | 1067 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
3bd70bf8 PZ |
1068 | vpn_leak_postchange_all(); |
1069 | ||
d62a17ae | 1070 | /* Pending: handle when user tries to change a view to vrf n vv. |
1071 | */ | |
1072 | } | |
1073 | ||
0b5131c9 MK |
1074 | /* unset the auto created flag as the user config is now present */ |
1075 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 1076 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
1077 | ||
1078 | return CMD_SUCCESS; | |
718e3744 | 1079 | } |
1080 | ||
718e3744 | 1081 | /* "no router bgp" commands. */ |
1082 | DEFUN (no_router_bgp, | |
1083 | no_router_bgp_cmd, | |
18c57037 | 1084 | "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1085 | NO_STR |
1086 | ROUTER_STR | |
1087 | BGP_STR | |
31500417 DW |
1088 | AS_STR |
1089 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1090 | { |
d62a17ae | 1091 | int idx_asn = 3; |
1092 | int idx_vrf = 5; | |
1093 | as_t as; | |
1094 | struct bgp *bgp; | |
1095 | const char *name = NULL; | |
718e3744 | 1096 | |
d62a17ae | 1097 | // "no router bgp" without an ASN |
1098 | if (argc == 3) { | |
1099 | // Pending: Make VRF option available for ASN less config | |
1100 | bgp = bgp_get_default(); | |
718e3744 | 1101 | |
d62a17ae | 1102 | if (bgp == NULL) { |
1103 | vty_out(vty, "%% No BGP process is configured\n"); | |
1104 | return CMD_WARNING_CONFIG_FAILED; | |
1105 | } | |
7fb21a9f | 1106 | |
d62a17ae | 1107 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1108 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1109 | return CMD_WARNING_CONFIG_FAILED; |
1110 | } | |
0b5131c9 MK |
1111 | |
1112 | if (bgp->l3vni) { | |
1113 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1114 | bgp->l3vni); | |
1115 | return CMD_WARNING_CONFIG_FAILED; | |
1116 | } | |
d62a17ae | 1117 | } else { |
1118 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1119 | |
d62a17ae | 1120 | if (argc > 4) |
1121 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1122 | |
d62a17ae | 1123 | /* Lookup bgp structure. */ |
1124 | bgp = bgp_lookup(as, name); | |
1125 | if (!bgp) { | |
1126 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1127 | return CMD_WARNING_CONFIG_FAILED; | |
1128 | } | |
0b5131c9 MK |
1129 | |
1130 | if (bgp->l3vni) { | |
1131 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1132 | bgp->l3vni); | |
1133 | return CMD_WARNING_CONFIG_FAILED; | |
1134 | } | |
d62a17ae | 1135 | } |
718e3744 | 1136 | |
d62a17ae | 1137 | bgp_delete(bgp); |
718e3744 | 1138 | |
d62a17ae | 1139 | return CMD_SUCCESS; |
718e3744 | 1140 | } |
1141 | ||
6b0655a2 | 1142 | |
718e3744 | 1143 | /* BGP router-id. */ |
1144 | ||
f787d7a0 | 1145 | DEFPY (bgp_router_id, |
718e3744 | 1146 | bgp_router_id_cmd, |
1147 | "bgp router-id A.B.C.D", | |
1148 | BGP_STR | |
1149 | "Override configured router identifier\n" | |
1150 | "Manually configured router identifier\n") | |
1151 | { | |
d62a17ae | 1152 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1153 | bgp_router_id_static_set(bgp, router_id); | |
1154 | return CMD_SUCCESS; | |
718e3744 | 1155 | } |
1156 | ||
f787d7a0 | 1157 | DEFPY (no_bgp_router_id, |
718e3744 | 1158 | no_bgp_router_id_cmd, |
31500417 | 1159 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1160 | NO_STR |
1161 | BGP_STR | |
31500417 DW |
1162 | "Override configured router identifier\n" |
1163 | "Manually configured router identifier\n") | |
718e3744 | 1164 | { |
d62a17ae | 1165 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1166 | |
d62a17ae | 1167 | if (router_id_str) { |
1168 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1169 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1170 | return CMD_WARNING_CONFIG_FAILED; | |
1171 | } | |
e018c7cc | 1172 | } |
718e3744 | 1173 | |
d62a17ae | 1174 | router_id.s_addr = 0; |
1175 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1176 | |
d62a17ae | 1177 | return CMD_SUCCESS; |
718e3744 | 1178 | } |
1179 | ||
6b0655a2 | 1180 | |
718e3744 | 1181 | /* BGP Cluster ID. */ |
718e3744 | 1182 | DEFUN (bgp_cluster_id, |
1183 | bgp_cluster_id_cmd, | |
838758ac | 1184 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1185 | BGP_STR |
1186 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1187 | "Route-Reflector Cluster-id in IP address format\n" |
1188 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1189 | { |
d62a17ae | 1190 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1191 | int idx_ipv4 = 2; | |
1192 | int ret; | |
1193 | struct in_addr cluster; | |
718e3744 | 1194 | |
d62a17ae | 1195 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1196 | if (!ret) { | |
1197 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1198 | return CMD_WARNING_CONFIG_FAILED; | |
1199 | } | |
718e3744 | 1200 | |
d62a17ae | 1201 | bgp_cluster_id_set(bgp, &cluster); |
1202 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1203 | |
d62a17ae | 1204 | return CMD_SUCCESS; |
718e3744 | 1205 | } |
1206 | ||
718e3744 | 1207 | DEFUN (no_bgp_cluster_id, |
1208 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1209 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1210 | NO_STR |
1211 | BGP_STR | |
838758ac DW |
1212 | "Configure Route-Reflector Cluster-id\n" |
1213 | "Route-Reflector Cluster-id in IP address format\n" | |
1214 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1215 | { |
d62a17ae | 1216 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1217 | bgp_cluster_id_unset(bgp); | |
1218 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1219 | |
d62a17ae | 1220 | return CMD_SUCCESS; |
718e3744 | 1221 | } |
1222 | ||
718e3744 | 1223 | DEFUN (bgp_confederation_identifier, |
1224 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1225 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1226 | "BGP specific commands\n" |
1227 | "AS confederation parameters\n" | |
1228 | "AS number\n" | |
1229 | "Set routing domain confederation AS\n") | |
1230 | { | |
d62a17ae | 1231 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1232 | int idx_number = 3; | |
1233 | as_t as; | |
718e3744 | 1234 | |
d62a17ae | 1235 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1236 | |
d62a17ae | 1237 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1238 | |
d62a17ae | 1239 | return CMD_SUCCESS; |
718e3744 | 1240 | } |
1241 | ||
1242 | DEFUN (no_bgp_confederation_identifier, | |
1243 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1244 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1245 | NO_STR |
1246 | "BGP specific commands\n" | |
1247 | "AS confederation parameters\n" | |
3a2d747c QY |
1248 | "AS number\n" |
1249 | "Set routing domain confederation AS\n") | |
718e3744 | 1250 | { |
d62a17ae | 1251 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1252 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1253 | |
d62a17ae | 1254 | return CMD_SUCCESS; |
718e3744 | 1255 | } |
1256 | ||
718e3744 | 1257 | DEFUN (bgp_confederation_peers, |
1258 | bgp_confederation_peers_cmd, | |
12dcf78e | 1259 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1260 | "BGP specific commands\n" |
1261 | "AS confederation parameters\n" | |
1262 | "Peer ASs in BGP confederation\n" | |
1263 | AS_STR) | |
1264 | { | |
d62a17ae | 1265 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1266 | int idx_asn = 3; | |
1267 | as_t as; | |
1268 | int i; | |
718e3744 | 1269 | |
d62a17ae | 1270 | for (i = idx_asn; i < argc; i++) { |
1271 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1272 | |
d62a17ae | 1273 | if (bgp->as == as) { |
1274 | vty_out(vty, | |
1275 | "%% Local member-AS not allowed in confed peer list\n"); | |
1276 | continue; | |
1277 | } | |
718e3744 | 1278 | |
d62a17ae | 1279 | bgp_confederation_peers_add(bgp, as); |
1280 | } | |
1281 | return CMD_SUCCESS; | |
718e3744 | 1282 | } |
1283 | ||
1284 | DEFUN (no_bgp_confederation_peers, | |
1285 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1286 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1287 | NO_STR |
1288 | "BGP specific commands\n" | |
1289 | "AS confederation parameters\n" | |
1290 | "Peer ASs in BGP confederation\n" | |
1291 | AS_STR) | |
1292 | { | |
d62a17ae | 1293 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1294 | int idx_asn = 4; | |
1295 | as_t as; | |
1296 | int i; | |
718e3744 | 1297 | |
d62a17ae | 1298 | for (i = idx_asn; i < argc; i++) { |
1299 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1300 | |
d62a17ae | 1301 | bgp_confederation_peers_remove(bgp, as); |
1302 | } | |
1303 | return CMD_SUCCESS; | |
718e3744 | 1304 | } |
6b0655a2 | 1305 | |
5e242b0d DS |
1306 | /** |
1307 | * Central routine for maximum-paths configuration. | |
1308 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1309 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1310 | */ | |
d62a17ae | 1311 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1312 | const char *mpaths, uint16_t options, |
d62a17ae | 1313 | int set) |
1314 | { | |
1315 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1316 | uint16_t maxpaths = 0; |
d62a17ae | 1317 | int ret; |
1318 | afi_t afi; | |
1319 | safi_t safi; | |
1320 | ||
1321 | afi = bgp_node_afi(vty); | |
1322 | safi = bgp_node_safi(vty); | |
1323 | ||
1324 | if (set) { | |
1325 | maxpaths = strtol(mpaths, NULL, 10); | |
1326 | if (maxpaths > multipath_num) { | |
1327 | vty_out(vty, | |
1328 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1329 | maxpaths, multipath_num); | |
1330 | return CMD_WARNING_CONFIG_FAILED; | |
1331 | } | |
1332 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1333 | options); | |
1334 | } else | |
1335 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1336 | ||
1337 | if (ret < 0) { | |
1338 | vty_out(vty, | |
1339 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1340 | (set == 1) ? "" : "un", | |
1341 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1342 | maxpaths, afi, safi); | |
1343 | return CMD_WARNING_CONFIG_FAILED; | |
1344 | } | |
1345 | ||
1346 | bgp_recalculate_all_bestpaths(bgp); | |
1347 | ||
1348 | return CMD_SUCCESS; | |
165b5fff JB |
1349 | } |
1350 | ||
abc920f8 DS |
1351 | DEFUN (bgp_maxmed_admin, |
1352 | bgp_maxmed_admin_cmd, | |
1353 | "bgp max-med administrative ", | |
1354 | BGP_STR | |
1355 | "Advertise routes with max-med\n" | |
1356 | "Administratively applied, for an indefinite period\n") | |
1357 | { | |
d62a17ae | 1358 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1359 | |
d62a17ae | 1360 | bgp->v_maxmed_admin = 1; |
1361 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1362 | |
d62a17ae | 1363 | bgp_maxmed_update(bgp); |
abc920f8 | 1364 | |
d62a17ae | 1365 | return CMD_SUCCESS; |
abc920f8 DS |
1366 | } |
1367 | ||
1368 | DEFUN (bgp_maxmed_admin_medv, | |
1369 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1370 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1371 | BGP_STR |
1372 | "Advertise routes with max-med\n" | |
1373 | "Administratively applied, for an indefinite period\n" | |
1374 | "Max MED value to be used\n") | |
1375 | { | |
d62a17ae | 1376 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1377 | int idx_number = 3; | |
abc920f8 | 1378 | |
d62a17ae | 1379 | bgp->v_maxmed_admin = 1; |
1380 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1381 | |
d62a17ae | 1382 | bgp_maxmed_update(bgp); |
abc920f8 | 1383 | |
d62a17ae | 1384 | return CMD_SUCCESS; |
abc920f8 DS |
1385 | } |
1386 | ||
1387 | DEFUN (no_bgp_maxmed_admin, | |
1388 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1389 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1390 | NO_STR |
1391 | BGP_STR | |
1392 | "Advertise routes with max-med\n" | |
838758ac DW |
1393 | "Administratively applied, for an indefinite period\n" |
1394 | "Max MED value to be used\n") | |
abc920f8 | 1395 | { |
d62a17ae | 1396 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1397 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1398 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1399 | bgp_maxmed_update(bgp); | |
abc920f8 | 1400 | |
d62a17ae | 1401 | return CMD_SUCCESS; |
abc920f8 DS |
1402 | } |
1403 | ||
abc920f8 DS |
1404 | DEFUN (bgp_maxmed_onstartup, |
1405 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1406 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1407 | BGP_STR |
1408 | "Advertise routes with max-med\n" | |
1409 | "Effective on a startup\n" | |
1410 | "Time (seconds) period for max-med\n" | |
1411 | "Max MED value to be used\n") | |
1412 | { | |
d62a17ae | 1413 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1414 | int idx = 0; | |
4668a151 | 1415 | |
d62a17ae | 1416 | argv_find(argv, argc, "(5-86400)", &idx); |
1417 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1418 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1419 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1420 | else | |
1421 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1422 | |
d62a17ae | 1423 | bgp_maxmed_update(bgp); |
abc920f8 | 1424 | |
d62a17ae | 1425 | return CMD_SUCCESS; |
abc920f8 DS |
1426 | } |
1427 | ||
1428 | DEFUN (no_bgp_maxmed_onstartup, | |
1429 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1430 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1431 | NO_STR |
1432 | BGP_STR | |
1433 | "Advertise routes with max-med\n" | |
838758ac DW |
1434 | "Effective on a startup\n" |
1435 | "Time (seconds) period for max-med\n" | |
1436 | "Max MED value to be used\n") | |
abc920f8 | 1437 | { |
d62a17ae | 1438 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1439 | |
d62a17ae | 1440 | /* Cancel max-med onstartup if its on */ |
1441 | if (bgp->t_maxmed_onstartup) { | |
1442 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1443 | bgp->maxmed_onstartup_over = 1; | |
1444 | } | |
abc920f8 | 1445 | |
d62a17ae | 1446 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1447 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1448 | |
d62a17ae | 1449 | bgp_maxmed_update(bgp); |
abc920f8 | 1450 | |
d62a17ae | 1451 | return CMD_SUCCESS; |
abc920f8 DS |
1452 | } |
1453 | ||
d62a17ae | 1454 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1455 | const char *wait) | |
f188f2c4 | 1456 | { |
d62a17ae | 1457 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1458 | uint16_t update_delay; |
1459 | uint16_t establish_wait; | |
f188f2c4 | 1460 | |
d62a17ae | 1461 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1462 | |
d62a17ae | 1463 | if (!wait) /* update-delay <delay> */ |
1464 | { | |
1465 | bgp->v_update_delay = update_delay; | |
1466 | bgp->v_establish_wait = bgp->v_update_delay; | |
1467 | return CMD_SUCCESS; | |
1468 | } | |
f188f2c4 | 1469 | |
d62a17ae | 1470 | /* update-delay <delay> <establish-wait> */ |
1471 | establish_wait = atoi(wait); | |
1472 | if (update_delay < establish_wait) { | |
1473 | vty_out(vty, | |
1474 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1475 | return CMD_WARNING_CONFIG_FAILED; | |
1476 | } | |
f188f2c4 | 1477 | |
d62a17ae | 1478 | bgp->v_update_delay = update_delay; |
1479 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1480 | |
d62a17ae | 1481 | return CMD_SUCCESS; |
f188f2c4 DS |
1482 | } |
1483 | ||
d62a17ae | 1484 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1485 | { |
d62a17ae | 1486 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1487 | |
d62a17ae | 1488 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1489 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1490 | |
d62a17ae | 1491 | return CMD_SUCCESS; |
f188f2c4 DS |
1492 | } |
1493 | ||
2b791107 | 1494 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1495 | { |
d62a17ae | 1496 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1497 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1498 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1499 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1500 | vty_out(vty, "\n"); | |
1501 | } | |
f188f2c4 DS |
1502 | } |
1503 | ||
1504 | ||
1505 | /* Update-delay configuration */ | |
1506 | DEFUN (bgp_update_delay, | |
1507 | bgp_update_delay_cmd, | |
6147e2c6 | 1508 | "update-delay (0-3600)", |
f188f2c4 DS |
1509 | "Force initial delay for best-path and updates\n" |
1510 | "Seconds\n") | |
1511 | { | |
d62a17ae | 1512 | int idx_number = 1; |
1513 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1514 | } |
1515 | ||
1516 | DEFUN (bgp_update_delay_establish_wait, | |
1517 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1518 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1519 | "Force initial delay for best-path and updates\n" |
1520 | "Seconds\n" | |
f188f2c4 DS |
1521 | "Seconds\n") |
1522 | { | |
d62a17ae | 1523 | int idx_number = 1; |
1524 | int idx_number_2 = 2; | |
1525 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1526 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1527 | } |
1528 | ||
1529 | /* Update-delay deconfiguration */ | |
1530 | DEFUN (no_bgp_update_delay, | |
1531 | no_bgp_update_delay_cmd, | |
838758ac DW |
1532 | "no update-delay [(0-3600) [(1-3600)]]", |
1533 | NO_STR | |
f188f2c4 | 1534 | "Force initial delay for best-path and updates\n" |
838758ac | 1535 | "Seconds\n" |
7111c1a0 | 1536 | "Seconds\n") |
f188f2c4 | 1537 | { |
d62a17ae | 1538 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1539 | } |
1540 | ||
5e242b0d | 1541 | |
d62a17ae | 1542 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, const char *num, |
1543 | char set) | |
cb1faec9 | 1544 | { |
d62a17ae | 1545 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1546 | |
555e09d4 QY |
1547 | if (set) { |
1548 | uint32_t quanta = strtoul(num, NULL, 10); | |
1549 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, | |
1550 | memory_order_relaxed); | |
1551 | } else { | |
1552 | atomic_store_explicit(&bgp->wpkt_quanta, BGP_WRITE_PACKET_MAX, | |
1553 | memory_order_relaxed); | |
1554 | } | |
1555 | ||
1556 | return CMD_SUCCESS; | |
1557 | } | |
1558 | ||
1559 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, const char *num, | |
1560 | char set) | |
1561 | { | |
1562 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1563 | ||
1564 | if (set) { | |
1565 | uint32_t quanta = strtoul(num, NULL, 10); | |
1566 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, | |
1567 | memory_order_relaxed); | |
1568 | } else { | |
1569 | atomic_store_explicit(&bgp->rpkt_quanta, BGP_READ_PACKET_MAX, | |
1570 | memory_order_relaxed); | |
1571 | } | |
cb1faec9 | 1572 | |
d62a17ae | 1573 | return CMD_SUCCESS; |
cb1faec9 DS |
1574 | } |
1575 | ||
2b791107 | 1576 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1577 | { |
555e09d4 QY |
1578 | uint32_t quanta = |
1579 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1580 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1581 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1582 | } |
1583 | ||
555e09d4 QY |
1584 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1585 | { | |
1586 | uint32_t quanta = | |
1587 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1588 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1589 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1590 | } |
cb1faec9 | 1591 | |
555e09d4 | 1592 | /* Packet quanta configuration */ |
cb1faec9 DS |
1593 | DEFUN (bgp_wpkt_quanta, |
1594 | bgp_wpkt_quanta_cmd, | |
555e09d4 | 1595 | "write-quanta (1-10)", |
cb1faec9 DS |
1596 | "How many packets to write to peer socket per run\n" |
1597 | "Number of packets\n") | |
1598 | { | |
d62a17ae | 1599 | int idx_number = 1; |
1600 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1601 | } |
1602 | ||
cb1faec9 DS |
1603 | DEFUN (no_bgp_wpkt_quanta, |
1604 | no_bgp_wpkt_quanta_cmd, | |
555e09d4 | 1605 | "no write-quanta (1-10)", |
d7fa34c1 | 1606 | NO_STR |
555e09d4 | 1607 | "How many packets to write to peer socket per I/O cycle\n" |
cb1faec9 DS |
1608 | "Number of packets\n") |
1609 | { | |
d62a17ae | 1610 | int idx_number = 2; |
1611 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1612 | } |
1613 | ||
555e09d4 QY |
1614 | DEFUN (bgp_rpkt_quanta, |
1615 | bgp_rpkt_quanta_cmd, | |
1616 | "read-quanta (1-10)", | |
1617 | "How many packets to read from peer socket per I/O cycle\n" | |
1618 | "Number of packets\n") | |
1619 | { | |
1620 | int idx_number = 1; | |
1621 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
1622 | } | |
1623 | ||
1624 | DEFUN (no_bgp_rpkt_quanta, | |
1625 | no_bgp_rpkt_quanta_cmd, | |
1626 | "no read-quanta (1-10)", | |
1627 | NO_STR | |
1628 | "How many packets to read from peer socket per I/O cycle\n" | |
1629 | "Number of packets\n") | |
1630 | { | |
1631 | int idx_number = 2; | |
1632 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
1633 | } | |
1634 | ||
2b791107 | 1635 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1636 | { |
37a333fe | 1637 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1638 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1639 | } |
1640 | ||
1641 | ||
1642 | DEFUN (bgp_coalesce_time, | |
1643 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1644 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1645 | "Subgroup coalesce timer\n" |
1646 | "Subgroup coalesce timer value (in ms)\n") | |
1647 | { | |
d62a17ae | 1648 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1649 | |
d62a17ae | 1650 | int idx = 0; |
1651 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1652 | bgp->heuristic_coalesce = false; |
d62a17ae | 1653 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1654 | return CMD_SUCCESS; | |
3f9c7369 DS |
1655 | } |
1656 | ||
1657 | DEFUN (no_bgp_coalesce_time, | |
1658 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1659 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1660 | NO_STR |
3f9c7369 DS |
1661 | "Subgroup coalesce timer\n" |
1662 | "Subgroup coalesce timer value (in ms)\n") | |
1663 | { | |
d62a17ae | 1664 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1665 | |
37a333fe | 1666 | bgp->heuristic_coalesce = true; |
d62a17ae | 1667 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1668 | return CMD_SUCCESS; | |
3f9c7369 DS |
1669 | } |
1670 | ||
5e242b0d DS |
1671 | /* Maximum-paths configuration */ |
1672 | DEFUN (bgp_maxpaths, | |
1673 | bgp_maxpaths_cmd, | |
6319fd63 | 1674 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1675 | "Forward packets over multiple paths\n" |
1676 | "Number of paths\n") | |
1677 | { | |
d62a17ae | 1678 | int idx_number = 1; |
1679 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1680 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1681 | } |
1682 | ||
d62a17ae | 1683 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1684 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1685 | "Forward packets over multiple paths\n" | |
1686 | "Number of paths\n") | |
596c17ba | 1687 | |
165b5fff JB |
1688 | DEFUN (bgp_maxpaths_ibgp, |
1689 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1690 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1691 | "Forward packets over multiple paths\n" |
1692 | "iBGP-multipath\n" | |
1693 | "Number of paths\n") | |
1694 | { | |
d62a17ae | 1695 | int idx_number = 2; |
1696 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1697 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1698 | } |
165b5fff | 1699 | |
d62a17ae | 1700 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1701 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1702 | "Forward packets over multiple paths\n" | |
1703 | "iBGP-multipath\n" | |
1704 | "Number of paths\n") | |
596c17ba | 1705 | |
5e242b0d DS |
1706 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1707 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1708 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1709 | "Forward packets over multiple paths\n" |
1710 | "iBGP-multipath\n" | |
1711 | "Number of paths\n" | |
1712 | "Match the cluster length\n") | |
1713 | { | |
d62a17ae | 1714 | int idx_number = 2; |
1715 | return bgp_maxpaths_config_vty( | |
1716 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1717 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1718 | } |
1719 | ||
d62a17ae | 1720 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1721 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1722 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1723 | "Forward packets over multiple paths\n" | |
1724 | "iBGP-multipath\n" | |
1725 | "Number of paths\n" | |
1726 | "Match the cluster length\n") | |
596c17ba | 1727 | |
165b5fff JB |
1728 | DEFUN (no_bgp_maxpaths, |
1729 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1730 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1731 | NO_STR |
1732 | "Forward packets over multiple paths\n" | |
1733 | "Number of paths\n") | |
1734 | { | |
d62a17ae | 1735 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1736 | } |
1737 | ||
d62a17ae | 1738 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1739 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1740 | "Forward packets over multiple paths\n" |
1741 | "Number of paths\n") | |
596c17ba | 1742 | |
165b5fff JB |
1743 | DEFUN (no_bgp_maxpaths_ibgp, |
1744 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1745 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1746 | NO_STR |
1747 | "Forward packets over multiple paths\n" | |
1748 | "iBGP-multipath\n" | |
838758ac DW |
1749 | "Number of paths\n" |
1750 | "Match the cluster length\n") | |
165b5fff | 1751 | { |
d62a17ae | 1752 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1753 | } |
1754 | ||
d62a17ae | 1755 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1756 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1757 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1758 | NO_STR | |
1759 | "Forward packets over multiple paths\n" | |
1760 | "iBGP-multipath\n" | |
1761 | "Number of paths\n" | |
1762 | "Match the cluster length\n") | |
596c17ba | 1763 | |
2b791107 | 1764 | void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 1765 | safi_t safi) |
165b5fff | 1766 | { |
d62a17ae | 1767 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1768 | vty_out(vty, " maximum-paths %d\n", |
1769 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1770 | } | |
165b5fff | 1771 | |
d62a17ae | 1772 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1773 | vty_out(vty, " maximum-paths ibgp %d", |
1774 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1775 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1776 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1777 | vty_out(vty, " equal-cluster-length"); | |
1778 | vty_out(vty, "\n"); | |
1779 | } | |
165b5fff | 1780 | } |
6b0655a2 | 1781 | |
718e3744 | 1782 | /* BGP timers. */ |
1783 | ||
1784 | DEFUN (bgp_timers, | |
1785 | bgp_timers_cmd, | |
6147e2c6 | 1786 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1787 | "Adjust routing timers\n" |
1788 | "BGP timers\n" | |
1789 | "Keepalive interval\n" | |
1790 | "Holdtime\n") | |
1791 | { | |
d62a17ae | 1792 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1793 | int idx_number = 2; | |
1794 | int idx_number_2 = 3; | |
1795 | unsigned long keepalive = 0; | |
1796 | unsigned long holdtime = 0; | |
718e3744 | 1797 | |
d62a17ae | 1798 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1799 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1800 | |
d62a17ae | 1801 | /* Holdtime value check. */ |
1802 | if (holdtime < 3 && holdtime != 0) { | |
1803 | vty_out(vty, | |
1804 | "%% hold time value must be either 0 or greater than 3\n"); | |
1805 | return CMD_WARNING_CONFIG_FAILED; | |
1806 | } | |
718e3744 | 1807 | |
d62a17ae | 1808 | bgp_timers_set(bgp, keepalive, holdtime); |
718e3744 | 1809 | |
d62a17ae | 1810 | return CMD_SUCCESS; |
718e3744 | 1811 | } |
1812 | ||
1813 | DEFUN (no_bgp_timers, | |
1814 | no_bgp_timers_cmd, | |
838758ac | 1815 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1816 | NO_STR |
1817 | "Adjust routing timers\n" | |
838758ac DW |
1818 | "BGP timers\n" |
1819 | "Keepalive interval\n" | |
1820 | "Holdtime\n") | |
718e3744 | 1821 | { |
d62a17ae | 1822 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1823 | bgp_timers_unset(bgp); | |
718e3744 | 1824 | |
d62a17ae | 1825 | return CMD_SUCCESS; |
718e3744 | 1826 | } |
1827 | ||
6b0655a2 | 1828 | |
718e3744 | 1829 | DEFUN (bgp_client_to_client_reflection, |
1830 | bgp_client_to_client_reflection_cmd, | |
1831 | "bgp client-to-client reflection", | |
1832 | "BGP specific commands\n" | |
1833 | "Configure client to client route reflection\n" | |
1834 | "reflection of routes allowed\n") | |
1835 | { | |
d62a17ae | 1836 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1837 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1838 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1839 | |
d62a17ae | 1840 | return CMD_SUCCESS; |
718e3744 | 1841 | } |
1842 | ||
1843 | DEFUN (no_bgp_client_to_client_reflection, | |
1844 | no_bgp_client_to_client_reflection_cmd, | |
1845 | "no bgp client-to-client reflection", | |
1846 | NO_STR | |
1847 | "BGP specific commands\n" | |
1848 | "Configure client to client route reflection\n" | |
1849 | "reflection of routes allowed\n") | |
1850 | { | |
d62a17ae | 1851 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1852 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1853 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1854 | |
d62a17ae | 1855 | return CMD_SUCCESS; |
718e3744 | 1856 | } |
1857 | ||
1858 | /* "bgp always-compare-med" configuration. */ | |
1859 | DEFUN (bgp_always_compare_med, | |
1860 | bgp_always_compare_med_cmd, | |
1861 | "bgp always-compare-med", | |
1862 | "BGP specific commands\n" | |
1863 | "Allow comparing MED from different neighbors\n") | |
1864 | { | |
d62a17ae | 1865 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1866 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1867 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1868 | |
d62a17ae | 1869 | return CMD_SUCCESS; |
718e3744 | 1870 | } |
1871 | ||
1872 | DEFUN (no_bgp_always_compare_med, | |
1873 | no_bgp_always_compare_med_cmd, | |
1874 | "no bgp always-compare-med", | |
1875 | NO_STR | |
1876 | "BGP specific commands\n" | |
1877 | "Allow comparing MED from different neighbors\n") | |
1878 | { | |
d62a17ae | 1879 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1880 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1881 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1882 | |
d62a17ae | 1883 | return CMD_SUCCESS; |
718e3744 | 1884 | } |
6b0655a2 | 1885 | |
9dac9fc8 DA |
1886 | |
1887 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, | |
1888 | "bgp ebgp-requires-policy", | |
1889 | "BGP specific commands\n" | |
1890 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
1891 | { | |
1892 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1893 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_ENABLED; | |
1894 | return CMD_SUCCESS; | |
1895 | } | |
1896 | ||
1897 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, | |
1898 | "no bgp ebgp-requires-policy", | |
1899 | NO_STR | |
1900 | "BGP specific commands\n" | |
1901 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
1902 | { | |
1903 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1904 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_DISABLED; | |
1905 | return CMD_SUCCESS; | |
1906 | } | |
1907 | ||
1908 | ||
718e3744 | 1909 | /* "bgp deterministic-med" configuration. */ |
1910 | DEFUN (bgp_deterministic_med, | |
1911 | bgp_deterministic_med_cmd, | |
1912 | "bgp deterministic-med", | |
1913 | "BGP specific commands\n" | |
1914 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1915 | { | |
d62a17ae | 1916 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 1917 | |
d62a17ae | 1918 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
1919 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1920 | bgp_recalculate_all_bestpaths(bgp); | |
1921 | } | |
7aafcaca | 1922 | |
d62a17ae | 1923 | return CMD_SUCCESS; |
718e3744 | 1924 | } |
1925 | ||
1926 | DEFUN (no_bgp_deterministic_med, | |
1927 | no_bgp_deterministic_med_cmd, | |
1928 | "no bgp deterministic-med", | |
1929 | NO_STR | |
1930 | "BGP specific commands\n" | |
1931 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1932 | { | |
d62a17ae | 1933 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1934 | int bestpath_per_as_used; | |
1935 | afi_t afi; | |
1936 | safi_t safi; | |
1937 | struct peer *peer; | |
1938 | struct listnode *node, *nnode; | |
1939 | ||
1940 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
1941 | bestpath_per_as_used = 0; | |
1942 | ||
1943 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc | 1944 | FOREACH_AFI_SAFI (afi, safi) |
dcc68b5e MS |
1945 | if (bgp_addpath_dmed_required( |
1946 | peer->addpath_type[afi][safi])) { | |
05c7a1cc QY |
1947 | bestpath_per_as_used = 1; |
1948 | break; | |
1949 | } | |
d62a17ae | 1950 | |
1951 | if (bestpath_per_as_used) | |
1952 | break; | |
1953 | } | |
1954 | ||
1955 | if (bestpath_per_as_used) { | |
1956 | vty_out(vty, | |
1957 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
1958 | return CMD_WARNING_CONFIG_FAILED; | |
1959 | } else { | |
1960 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1961 | bgp_recalculate_all_bestpaths(bgp); | |
1962 | } | |
1963 | } | |
1964 | ||
1965 | return CMD_SUCCESS; | |
718e3744 | 1966 | } |
538621f2 | 1967 | |
1968 | /* "bgp graceful-restart" configuration. */ | |
1969 | DEFUN (bgp_graceful_restart, | |
1970 | bgp_graceful_restart_cmd, | |
1971 | "bgp graceful-restart", | |
1972 | "BGP specific commands\n" | |
1973 | "Graceful restart capability parameters\n") | |
1974 | { | |
d62a17ae | 1975 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1976 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1977 | return CMD_SUCCESS; | |
538621f2 | 1978 | } |
1979 | ||
1980 | DEFUN (no_bgp_graceful_restart, | |
1981 | no_bgp_graceful_restart_cmd, | |
1982 | "no bgp graceful-restart", | |
1983 | NO_STR | |
1984 | "BGP specific commands\n" | |
1985 | "Graceful restart capability parameters\n") | |
1986 | { | |
d62a17ae | 1987 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1988 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1989 | return CMD_SUCCESS; | |
538621f2 | 1990 | } |
1991 | ||
93406d87 | 1992 | DEFUN (bgp_graceful_restart_stalepath_time, |
1993 | bgp_graceful_restart_stalepath_time_cmd, | |
c1779b7d | 1994 | "bgp graceful-restart stalepath-time (1-4095)", |
93406d87 | 1995 | "BGP specific commands\n" |
1996 | "Graceful restart capability parameters\n" | |
1997 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1998 | "Delay value (seconds)\n") | |
1999 | { | |
d62a17ae | 2000 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2001 | int idx_number = 3; | |
d7c0a89a | 2002 | uint32_t stalepath; |
93406d87 | 2003 | |
d62a17ae | 2004 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
2005 | bgp->stalepath_time = stalepath; | |
2006 | return CMD_SUCCESS; | |
93406d87 | 2007 | } |
2008 | ||
eb6f1b41 PG |
2009 | DEFUN (bgp_graceful_restart_restart_time, |
2010 | bgp_graceful_restart_restart_time_cmd, | |
c72d0314 | 2011 | "bgp graceful-restart restart-time (1-4095)", |
eb6f1b41 PG |
2012 | "BGP specific commands\n" |
2013 | "Graceful restart capability parameters\n" | |
2014 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
2015 | "Delay value (seconds)\n") | |
2016 | { | |
d62a17ae | 2017 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2018 | int idx_number = 3; | |
d7c0a89a | 2019 | uint32_t restart; |
eb6f1b41 | 2020 | |
d62a17ae | 2021 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
2022 | bgp->restart_time = restart; | |
2023 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2024 | } |
2025 | ||
93406d87 | 2026 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
2027 | no_bgp_graceful_restart_stalepath_time_cmd, | |
c1779b7d | 2028 | "no bgp graceful-restart stalepath-time [(1-4095)]", |
93406d87 | 2029 | NO_STR |
2030 | "BGP specific commands\n" | |
2031 | "Graceful restart capability parameters\n" | |
838758ac DW |
2032 | "Set the max time to hold onto restarting peer's stale paths\n" |
2033 | "Delay value (seconds)\n") | |
93406d87 | 2034 | { |
d62a17ae | 2035 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 2036 | |
d62a17ae | 2037 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
2038 | return CMD_SUCCESS; | |
93406d87 | 2039 | } |
2040 | ||
eb6f1b41 PG |
2041 | DEFUN (no_bgp_graceful_restart_restart_time, |
2042 | no_bgp_graceful_restart_restart_time_cmd, | |
c72d0314 | 2043 | "no bgp graceful-restart restart-time [(1-4095)]", |
eb6f1b41 PG |
2044 | NO_STR |
2045 | "BGP specific commands\n" | |
2046 | "Graceful restart capability parameters\n" | |
838758ac DW |
2047 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
2048 | "Delay value (seconds)\n") | |
eb6f1b41 | 2049 | { |
d62a17ae | 2050 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2051 | |
d62a17ae | 2052 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2053 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2054 | } |
2055 | ||
43fc21b3 JC |
2056 | DEFUN (bgp_graceful_restart_preserve_fw, |
2057 | bgp_graceful_restart_preserve_fw_cmd, | |
2058 | "bgp graceful-restart preserve-fw-state", | |
2059 | "BGP specific commands\n" | |
2060 | "Graceful restart capability parameters\n" | |
2061 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2062 | { | |
d62a17ae | 2063 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2064 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2065 | return CMD_SUCCESS; | |
43fc21b3 JC |
2066 | } |
2067 | ||
2068 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2069 | no_bgp_graceful_restart_preserve_fw_cmd, | |
2070 | "no bgp graceful-restart preserve-fw-state", | |
2071 | NO_STR | |
2072 | "BGP specific commands\n" | |
2073 | "Graceful restart capability parameters\n" | |
2074 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2075 | { | |
d62a17ae | 2076 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2077 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2078 | return CMD_SUCCESS; | |
43fc21b3 JC |
2079 | } |
2080 | ||
7f323236 DW |
2081 | /* "bgp graceful-shutdown" configuration */ |
2082 | DEFUN (bgp_graceful_shutdown, | |
2083 | bgp_graceful_shutdown_cmd, | |
2084 | "bgp graceful-shutdown", | |
2085 | BGP_STR | |
2086 | "Graceful shutdown parameters\n") | |
2087 | { | |
2088 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2089 | ||
2090 | if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2091 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2092 | bgp_static_redo_import_check(bgp); | |
2093 | bgp_redistribute_redo(bgp); | |
2094 | bgp_clear_star_soft_out(vty, bgp->name); | |
2095 | bgp_clear_star_soft_in(vty, bgp->name); | |
2096 | } | |
2097 | ||
2098 | return CMD_SUCCESS; | |
2099 | } | |
2100 | ||
2101 | DEFUN (no_bgp_graceful_shutdown, | |
2102 | no_bgp_graceful_shutdown_cmd, | |
2103 | "no bgp graceful-shutdown", | |
2104 | NO_STR | |
2105 | BGP_STR | |
2106 | "Graceful shutdown parameters\n") | |
2107 | { | |
2108 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2109 | ||
2110 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2111 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2112 | bgp_static_redo_import_check(bgp); | |
2113 | bgp_redistribute_redo(bgp); | |
2114 | bgp_clear_star_soft_out(vty, bgp->name); | |
2115 | bgp_clear_star_soft_in(vty, bgp->name); | |
2116 | } | |
2117 | ||
2118 | return CMD_SUCCESS; | |
2119 | } | |
2120 | ||
718e3744 | 2121 | /* "bgp fast-external-failover" configuration. */ |
2122 | DEFUN (bgp_fast_external_failover, | |
2123 | bgp_fast_external_failover_cmd, | |
2124 | "bgp fast-external-failover", | |
2125 | BGP_STR | |
2126 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2127 | { | |
d62a17ae | 2128 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2129 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2130 | return CMD_SUCCESS; | |
718e3744 | 2131 | } |
2132 | ||
2133 | DEFUN (no_bgp_fast_external_failover, | |
2134 | no_bgp_fast_external_failover_cmd, | |
2135 | "no bgp fast-external-failover", | |
2136 | NO_STR | |
2137 | BGP_STR | |
2138 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2139 | { | |
d62a17ae | 2140 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2141 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2142 | return CMD_SUCCESS; | |
718e3744 | 2143 | } |
6b0655a2 | 2144 | |
718e3744 | 2145 | /* "bgp enforce-first-as" configuration. */ |
ec4f0750 | 2146 | #if CONFDATE > 20190517 |
47cbc09b PM |
2147 | CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands") |
2148 | #endif | |
2149 | ||
f07e1c4f QY |
2150 | DEFUN_HIDDEN (bgp_enforce_first_as, |
2151 | bgp_enforce_first_as_cmd, | |
2152 | "[no] bgp enforce-first-as", | |
2153 | NO_STR | |
2154 | BGP_STR | |
2155 | "Enforce the first AS for EBGP routes\n") | |
718e3744 | 2156 | { |
d62a17ae | 2157 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 2158 | |
f07e1c4f QY |
2159 | if (strmatch(argv[0]->text, "no")) |
2160 | bgp_flag_unset(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
2161 | else | |
2162 | bgp_flag_set(bgp, BGP_FLAG_ENFORCE_FIRST_AS); | |
7aafcaca | 2163 | |
d62a17ae | 2164 | return CMD_SUCCESS; |
718e3744 | 2165 | } |
6b0655a2 | 2166 | |
718e3744 | 2167 | /* "bgp bestpath compare-routerid" configuration. */ |
2168 | DEFUN (bgp_bestpath_compare_router_id, | |
2169 | bgp_bestpath_compare_router_id_cmd, | |
2170 | "bgp bestpath compare-routerid", | |
2171 | "BGP specific commands\n" | |
2172 | "Change the default bestpath selection\n" | |
2173 | "Compare router-id for identical EBGP paths\n") | |
2174 | { | |
d62a17ae | 2175 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2176 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2177 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2178 | |
d62a17ae | 2179 | return CMD_SUCCESS; |
718e3744 | 2180 | } |
2181 | ||
2182 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2183 | no_bgp_bestpath_compare_router_id_cmd, | |
2184 | "no bgp bestpath compare-routerid", | |
2185 | NO_STR | |
2186 | "BGP specific commands\n" | |
2187 | "Change the default bestpath selection\n" | |
2188 | "Compare router-id for identical EBGP paths\n") | |
2189 | { | |
d62a17ae | 2190 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2191 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2192 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2193 | |
d62a17ae | 2194 | return CMD_SUCCESS; |
718e3744 | 2195 | } |
6b0655a2 | 2196 | |
718e3744 | 2197 | /* "bgp bestpath as-path ignore" configuration. */ |
2198 | DEFUN (bgp_bestpath_aspath_ignore, | |
2199 | bgp_bestpath_aspath_ignore_cmd, | |
2200 | "bgp bestpath as-path ignore", | |
2201 | "BGP specific commands\n" | |
2202 | "Change the default bestpath selection\n" | |
2203 | "AS-path attribute\n" | |
2204 | "Ignore as-path length in selecting a route\n") | |
2205 | { | |
d62a17ae | 2206 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2207 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2208 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2209 | |
d62a17ae | 2210 | return CMD_SUCCESS; |
718e3744 | 2211 | } |
2212 | ||
2213 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2214 | no_bgp_bestpath_aspath_ignore_cmd, | |
2215 | "no bgp bestpath as-path ignore", | |
2216 | NO_STR | |
2217 | "BGP specific commands\n" | |
2218 | "Change the default bestpath selection\n" | |
2219 | "AS-path attribute\n" | |
2220 | "Ignore as-path length in selecting a route\n") | |
2221 | { | |
d62a17ae | 2222 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2223 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2224 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2225 | |
d62a17ae | 2226 | return CMD_SUCCESS; |
718e3744 | 2227 | } |
6b0655a2 | 2228 | |
6811845b | 2229 | /* "bgp bestpath as-path confed" configuration. */ |
2230 | DEFUN (bgp_bestpath_aspath_confed, | |
2231 | bgp_bestpath_aspath_confed_cmd, | |
2232 | "bgp bestpath as-path confed", | |
2233 | "BGP specific commands\n" | |
2234 | "Change the default bestpath selection\n" | |
2235 | "AS-path attribute\n" | |
2236 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2237 | { | |
d62a17ae | 2238 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2239 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
2240 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2241 | |
d62a17ae | 2242 | return CMD_SUCCESS; |
6811845b | 2243 | } |
2244 | ||
2245 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2246 | no_bgp_bestpath_aspath_confed_cmd, | |
2247 | "no bgp bestpath as-path confed", | |
2248 | NO_STR | |
2249 | "BGP specific commands\n" | |
2250 | "Change the default bestpath selection\n" | |
2251 | "AS-path attribute\n" | |
2252 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2253 | { | |
d62a17ae | 2254 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2255 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
2256 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2257 | |
d62a17ae | 2258 | return CMD_SUCCESS; |
6811845b | 2259 | } |
6b0655a2 | 2260 | |
2fdd455c PM |
2261 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2262 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2263 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2264 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2265 | "BGP specific commands\n" |
2266 | "Change the default bestpath selection\n" | |
2267 | "AS-path attribute\n" | |
2268 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2269 | "Generate an AS_SET\n" |
16fc1eec DS |
2270 | "Do not generate an AS_SET\n") |
2271 | { | |
d62a17ae | 2272 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2273 | int idx = 0; | |
2274 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 2275 | |
d62a17ae | 2276 | /* no-as-set is now the default behavior so we can silently |
2277 | * ignore it */ | |
2278 | if (argv_find(argv, argc, "as-set", &idx)) | |
2279 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2280 | else | |
2281 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 2282 | |
d62a17ae | 2283 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2284 | |
d62a17ae | 2285 | return CMD_SUCCESS; |
16fc1eec DS |
2286 | } |
2287 | ||
219178b6 DW |
2288 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2289 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2290 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2291 | NO_STR |
2292 | "BGP specific commands\n" | |
2293 | "Change the default bestpath selection\n" | |
2294 | "AS-path attribute\n" | |
2295 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2296 | "Generate an AS_SET\n" |
16fc1eec DS |
2297 | "Do not generate an AS_SET\n") |
2298 | { | |
d62a17ae | 2299 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2300 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
2301 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2302 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2303 | |
d62a17ae | 2304 | return CMD_SUCCESS; |
2fdd455c | 2305 | } |
6b0655a2 | 2306 | |
848973c7 | 2307 | /* "bgp log-neighbor-changes" configuration. */ |
2308 | DEFUN (bgp_log_neighbor_changes, | |
2309 | bgp_log_neighbor_changes_cmd, | |
2310 | "bgp log-neighbor-changes", | |
2311 | "BGP specific commands\n" | |
2312 | "Log neighbor up/down and reset reason\n") | |
2313 | { | |
d62a17ae | 2314 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2315 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2316 | return CMD_SUCCESS; | |
848973c7 | 2317 | } |
2318 | ||
2319 | DEFUN (no_bgp_log_neighbor_changes, | |
2320 | no_bgp_log_neighbor_changes_cmd, | |
2321 | "no bgp log-neighbor-changes", | |
2322 | NO_STR | |
2323 | "BGP specific commands\n" | |
2324 | "Log neighbor up/down and reset reason\n") | |
2325 | { | |
d62a17ae | 2326 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2327 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2328 | return CMD_SUCCESS; | |
848973c7 | 2329 | } |
6b0655a2 | 2330 | |
718e3744 | 2331 | /* "bgp bestpath med" configuration. */ |
2332 | DEFUN (bgp_bestpath_med, | |
2333 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2334 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2335 | "BGP specific commands\n" |
2336 | "Change the default bestpath selection\n" | |
2337 | "MED attribute\n" | |
2338 | "Compare MED among confederation paths\n" | |
838758ac DW |
2339 | "Treat missing MED as the least preferred one\n" |
2340 | "Treat missing MED as the least preferred one\n" | |
2341 | "Compare MED among confederation paths\n") | |
718e3744 | 2342 | { |
d62a17ae | 2343 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2344 | |
d62a17ae | 2345 | int idx = 0; |
2346 | if (argv_find(argv, argc, "confed", &idx)) | |
2347 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2348 | idx = 0; | |
2349 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2350 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2351 | |
d62a17ae | 2352 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2353 | |
d62a17ae | 2354 | return CMD_SUCCESS; |
718e3744 | 2355 | } |
2356 | ||
718e3744 | 2357 | DEFUN (no_bgp_bestpath_med, |
2358 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2359 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2360 | NO_STR |
2361 | "BGP specific commands\n" | |
2362 | "Change the default bestpath selection\n" | |
2363 | "MED attribute\n" | |
2364 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2365 | "Treat missing MED as the least preferred one\n" |
2366 | "Treat missing MED as the least preferred one\n" | |
2367 | "Compare MED among confederation paths\n") | |
718e3744 | 2368 | { |
d62a17ae | 2369 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2370 | |
d62a17ae | 2371 | int idx = 0; |
2372 | if (argv_find(argv, argc, "confed", &idx)) | |
2373 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2374 | idx = 0; | |
2375 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2376 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2377 | |
d62a17ae | 2378 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2379 | |
d62a17ae | 2380 | return CMD_SUCCESS; |
718e3744 | 2381 | } |
2382 | ||
718e3744 | 2383 | /* "no bgp default ipv4-unicast". */ |
2384 | DEFUN (no_bgp_default_ipv4_unicast, | |
2385 | no_bgp_default_ipv4_unicast_cmd, | |
2386 | "no bgp default ipv4-unicast", | |
2387 | NO_STR | |
2388 | "BGP specific commands\n" | |
2389 | "Configure BGP defaults\n" | |
2390 | "Activate ipv4-unicast for a peer by default\n") | |
2391 | { | |
d62a17ae | 2392 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2393 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2394 | return CMD_SUCCESS; | |
718e3744 | 2395 | } |
2396 | ||
2397 | DEFUN (bgp_default_ipv4_unicast, | |
2398 | bgp_default_ipv4_unicast_cmd, | |
2399 | "bgp default ipv4-unicast", | |
2400 | "BGP specific commands\n" | |
2401 | "Configure BGP defaults\n" | |
2402 | "Activate ipv4-unicast for a peer by default\n") | |
2403 | { | |
d62a17ae | 2404 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2405 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2406 | return CMD_SUCCESS; | |
718e3744 | 2407 | } |
6b0655a2 | 2408 | |
04b6bdc0 DW |
2409 | /* Display hostname in certain command outputs */ |
2410 | DEFUN (bgp_default_show_hostname, | |
2411 | bgp_default_show_hostname_cmd, | |
2412 | "bgp default show-hostname", | |
2413 | "BGP specific commands\n" | |
2414 | "Configure BGP defaults\n" | |
0437e105 | 2415 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2416 | { |
d62a17ae | 2417 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2418 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2419 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2420 | } |
2421 | ||
2422 | DEFUN (no_bgp_default_show_hostname, | |
2423 | no_bgp_default_show_hostname_cmd, | |
2424 | "no bgp default show-hostname", | |
2425 | NO_STR | |
2426 | "BGP specific commands\n" | |
2427 | "Configure BGP defaults\n" | |
0437e105 | 2428 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2429 | { |
d62a17ae | 2430 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2431 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2432 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2433 | } |
2434 | ||
8233ef81 | 2435 | /* "bgp network import-check" configuration. */ |
718e3744 | 2436 | DEFUN (bgp_network_import_check, |
2437 | bgp_network_import_check_cmd, | |
5623e905 | 2438 | "bgp network import-check", |
718e3744 | 2439 | "BGP specific commands\n" |
2440 | "BGP network command\n" | |
5623e905 | 2441 | "Check BGP network route exists in IGP\n") |
718e3744 | 2442 | { |
d62a17ae | 2443 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2444 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2445 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
2446 | bgp_static_redo_import_check(bgp); | |
2447 | } | |
078430f6 | 2448 | |
d62a17ae | 2449 | return CMD_SUCCESS; |
718e3744 | 2450 | } |
2451 | ||
d62a17ae | 2452 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
2453 | "bgp network import-check exact", | |
2454 | "BGP specific commands\n" | |
2455 | "BGP network command\n" | |
2456 | "Check BGP network route exists in IGP\n" | |
2457 | "Match route precisely\n") | |
8233ef81 | 2458 | |
718e3744 | 2459 | DEFUN (no_bgp_network_import_check, |
2460 | no_bgp_network_import_check_cmd, | |
5623e905 | 2461 | "no bgp network import-check", |
718e3744 | 2462 | NO_STR |
2463 | "BGP specific commands\n" | |
2464 | "BGP network command\n" | |
2465 | "Check BGP network route exists in IGP\n") | |
2466 | { | |
d62a17ae | 2467 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2468 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2469 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
2470 | bgp_static_redo_import_check(bgp); | |
2471 | } | |
5623e905 | 2472 | |
d62a17ae | 2473 | return CMD_SUCCESS; |
718e3744 | 2474 | } |
6b0655a2 | 2475 | |
718e3744 | 2476 | DEFUN (bgp_default_local_preference, |
2477 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2478 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2479 | "BGP specific commands\n" |
2480 | "Configure BGP defaults\n" | |
2481 | "local preference (higher=more preferred)\n" | |
2482 | "Configure default local preference value\n") | |
2483 | { | |
d62a17ae | 2484 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2485 | int idx_number = 3; | |
d7c0a89a | 2486 | uint32_t local_pref; |
718e3744 | 2487 | |
d62a17ae | 2488 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2489 | |
d62a17ae | 2490 | bgp_default_local_preference_set(bgp, local_pref); |
2491 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 2492 | |
d62a17ae | 2493 | return CMD_SUCCESS; |
718e3744 | 2494 | } |
2495 | ||
2496 | DEFUN (no_bgp_default_local_preference, | |
2497 | no_bgp_default_local_preference_cmd, | |
838758ac | 2498 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2499 | NO_STR |
2500 | "BGP specific commands\n" | |
2501 | "Configure BGP defaults\n" | |
838758ac DW |
2502 | "local preference (higher=more preferred)\n" |
2503 | "Configure default local preference value\n") | |
718e3744 | 2504 | { |
d62a17ae | 2505 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2506 | bgp_default_local_preference_unset(bgp); | |
2507 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2508 | |
d62a17ae | 2509 | return CMD_SUCCESS; |
718e3744 | 2510 | } |
2511 | ||
6b0655a2 | 2512 | |
3f9c7369 DS |
2513 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2514 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2515 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2516 | "BGP specific commands\n" |
2517 | "Configure BGP defaults\n" | |
2518 | "subgroup-pkt-queue-max\n" | |
2519 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2520 | { |
d62a17ae | 2521 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2522 | int idx_number = 3; | |
d7c0a89a | 2523 | uint32_t max_size; |
8bd9d948 | 2524 | |
d62a17ae | 2525 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 2526 | |
d62a17ae | 2527 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 2528 | |
d62a17ae | 2529 | return CMD_SUCCESS; |
3f9c7369 DS |
2530 | } |
2531 | ||
2532 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2533 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2534 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2535 | NO_STR |
2536 | "BGP specific commands\n" | |
2537 | "Configure BGP defaults\n" | |
838758ac DW |
2538 | "subgroup-pkt-queue-max\n" |
2539 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2540 | { |
d62a17ae | 2541 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2542 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
2543 | return CMD_SUCCESS; | |
8bd9d948 DS |
2544 | } |
2545 | ||
813d4307 | 2546 | |
8bd9d948 DS |
2547 | DEFUN (bgp_rr_allow_outbound_policy, |
2548 | bgp_rr_allow_outbound_policy_cmd, | |
2549 | "bgp route-reflector allow-outbound-policy", | |
2550 | "BGP specific commands\n" | |
2551 | "Allow modifications made by out route-map\n" | |
2552 | "on ibgp neighbors\n") | |
2553 | { | |
d62a17ae | 2554 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2555 | |
d62a17ae | 2556 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2557 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2558 | update_group_announce_rrclients(bgp); | |
2559 | bgp_clear_star_soft_out(vty, bgp->name); | |
2560 | } | |
8bd9d948 | 2561 | |
d62a17ae | 2562 | return CMD_SUCCESS; |
8bd9d948 DS |
2563 | } |
2564 | ||
2565 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2566 | no_bgp_rr_allow_outbound_policy_cmd, | |
2567 | "no bgp route-reflector allow-outbound-policy", | |
2568 | NO_STR | |
2569 | "BGP specific commands\n" | |
2570 | "Allow modifications made by out route-map\n" | |
2571 | "on ibgp neighbors\n") | |
2572 | { | |
d62a17ae | 2573 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2574 | |
d62a17ae | 2575 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2576 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2577 | update_group_announce_rrclients(bgp); | |
2578 | bgp_clear_star_soft_out(vty, bgp->name); | |
2579 | } | |
8bd9d948 | 2580 | |
d62a17ae | 2581 | return CMD_SUCCESS; |
8bd9d948 DS |
2582 | } |
2583 | ||
f14e6fdb DS |
2584 | DEFUN (bgp_listen_limit, |
2585 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2586 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2587 | "BGP specific commands\n" |
2588 | "Configure BGP defaults\n" | |
2589 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2590 | "Configure Dynamic Neighbors listen limit value\n") | |
2591 | { | |
d62a17ae | 2592 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2593 | int idx_number = 3; | |
2594 | int listen_limit; | |
f14e6fdb | 2595 | |
d62a17ae | 2596 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 2597 | |
d62a17ae | 2598 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 2599 | |
d62a17ae | 2600 | return CMD_SUCCESS; |
f14e6fdb DS |
2601 | } |
2602 | ||
2603 | DEFUN (no_bgp_listen_limit, | |
2604 | no_bgp_listen_limit_cmd, | |
838758ac | 2605 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2606 | "BGP specific commands\n" |
2607 | "Configure BGP defaults\n" | |
2608 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2609 | "Configure Dynamic Neighbors listen limit value to default\n" |
2610 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2611 | { |
d62a17ae | 2612 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2613 | bgp_listen_limit_unset(bgp); | |
2614 | return CMD_SUCCESS; | |
f14e6fdb DS |
2615 | } |
2616 | ||
2617 | ||
20eb8864 | 2618 | /* |
2619 | * Check if this listen range is already configured. Check for exact | |
2620 | * match or overlap based on input. | |
2621 | */ | |
d62a17ae | 2622 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
2623 | struct prefix *range, int exact) | |
2624 | { | |
2625 | struct listnode *node, *nnode; | |
2626 | struct listnode *node1, *nnode1; | |
2627 | struct peer_group *group; | |
2628 | struct prefix *lr; | |
2629 | afi_t afi; | |
2630 | int match; | |
2631 | ||
2632 | afi = family2afi(range->family); | |
2633 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2634 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
2635 | lr)) { | |
2636 | if (exact) | |
2637 | match = prefix_same(range, lr); | |
2638 | else | |
2639 | match = (prefix_match(range, lr) | |
2640 | || prefix_match(lr, range)); | |
2641 | if (match) | |
2642 | return group; | |
2643 | } | |
2644 | } | |
2645 | ||
2646 | return NULL; | |
20eb8864 | 2647 | } |
2648 | ||
f14e6fdb DS |
2649 | DEFUN (bgp_listen_range, |
2650 | bgp_listen_range_cmd, | |
f3c3ee0d | 2651 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
f14e6fdb | 2652 | "BGP specific commands\n" |
d7fa34c1 QY |
2653 | "Configure BGP dynamic neighbors listen range\n" |
2654 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2655 | NEIGHBOR_ADDR_STR |
2656 | "Member of the peer-group\n" | |
2657 | "Peer-group name\n") | |
f14e6fdb | 2658 | { |
d62a17ae | 2659 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2660 | struct prefix range; | |
2661 | struct peer_group *group, *existing_group; | |
2662 | afi_t afi; | |
2663 | int ret; | |
2664 | int idx = 0; | |
2665 | ||
2666 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2667 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2668 | char *prefix = argv[idx]->arg; | |
f3c3ee0d | 2669 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 2670 | char *peergroup = argv[idx]->arg; |
2671 | ||
2672 | /* Convert IP prefix string to struct prefix. */ | |
2673 | ret = str2prefix(prefix, &range); | |
2674 | if (!ret) { | |
2675 | vty_out(vty, "%% Malformed listen range\n"); | |
2676 | return CMD_WARNING_CONFIG_FAILED; | |
2677 | } | |
2678 | ||
2679 | afi = family2afi(range.family); | |
2680 | ||
2681 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2682 | vty_out(vty, | |
2683 | "%% Malformed listen range (link-local address)\n"); | |
2684 | return CMD_WARNING_CONFIG_FAILED; | |
2685 | } | |
2686 | ||
2687 | apply_mask(&range); | |
2688 | ||
2689 | /* Check if same listen range is already configured. */ | |
2690 | existing_group = listen_range_exists(bgp, &range, 1); | |
2691 | if (existing_group) { | |
2692 | if (strcmp(existing_group->name, peergroup) == 0) | |
2693 | return CMD_SUCCESS; | |
2694 | else { | |
2695 | vty_out(vty, | |
2696 | "%% Same listen range is attached to peer-group %s\n", | |
2697 | existing_group->name); | |
2698 | return CMD_WARNING_CONFIG_FAILED; | |
2699 | } | |
2700 | } | |
2701 | ||
2702 | /* Check if an overlapping listen range exists. */ | |
2703 | if (listen_range_exists(bgp, &range, 0)) { | |
2704 | vty_out(vty, | |
2705 | "%% Listen range overlaps with existing listen range\n"); | |
2706 | return CMD_WARNING_CONFIG_FAILED; | |
2707 | } | |
2708 | ||
2709 | group = peer_group_lookup(bgp, peergroup); | |
2710 | if (!group) { | |
2711 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2712 | return CMD_WARNING_CONFIG_FAILED; | |
2713 | } | |
2714 | ||
2715 | ret = peer_group_listen_range_add(group, &range); | |
2716 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
2717 | } |
2718 | ||
2719 | DEFUN (no_bgp_listen_range, | |
2720 | no_bgp_listen_range_cmd, | |
f3c3ee0d | 2721 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 2722 | NO_STR |
f14e6fdb | 2723 | "BGP specific commands\n" |
d7fa34c1 QY |
2724 | "Unconfigure BGP dynamic neighbors listen range\n" |
2725 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2726 | NEIGHBOR_ADDR_STR | |
2727 | "Member of the peer-group\n" | |
2728 | "Peer-group name\n") | |
f14e6fdb | 2729 | { |
d62a17ae | 2730 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2731 | struct prefix range; | |
2732 | struct peer_group *group; | |
2733 | afi_t afi; | |
2734 | int ret; | |
2735 | int idx = 0; | |
2736 | ||
2737 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2738 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2739 | char *prefix = argv[idx]->arg; | |
2740 | argv_find(argv, argc, "WORD", &idx); | |
2741 | char *peergroup = argv[idx]->arg; | |
2742 | ||
2743 | /* Convert IP prefix string to struct prefix. */ | |
2744 | ret = str2prefix(prefix, &range); | |
2745 | if (!ret) { | |
2746 | vty_out(vty, "%% Malformed listen range\n"); | |
2747 | return CMD_WARNING_CONFIG_FAILED; | |
2748 | } | |
2749 | ||
2750 | afi = family2afi(range.family); | |
2751 | ||
2752 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2753 | vty_out(vty, | |
2754 | "%% Malformed listen range (link-local address)\n"); | |
2755 | return CMD_WARNING_CONFIG_FAILED; | |
2756 | } | |
2757 | ||
2758 | apply_mask(&range); | |
2759 | ||
2760 | group = peer_group_lookup(bgp, peergroup); | |
2761 | if (!group) { | |
2762 | vty_out(vty, "%% Peer-group does not exist\n"); | |
2763 | return CMD_WARNING_CONFIG_FAILED; | |
2764 | } | |
2765 | ||
2766 | ret = peer_group_listen_range_del(group, &range); | |
2767 | return bgp_vty_return(vty, ret); | |
2768 | } | |
2769 | ||
2b791107 | 2770 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 2771 | { |
2772 | struct peer_group *group; | |
2773 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2774 | struct prefix *range; | |
2775 | afi_t afi; | |
2776 | char buf[PREFIX2STR_BUFFER]; | |
2777 | ||
2778 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2779 | vty_out(vty, " bgp listen limit %d\n", | |
2780 | bgp->dynamic_neighbors_limit); | |
2781 | ||
2782 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2783 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
2784 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
2785 | nrnode, range)) { | |
2786 | prefix2str(range, buf, sizeof(buf)); | |
2787 | vty_out(vty, | |
2788 | " bgp listen range %s peer-group %s\n", | |
2789 | buf, group->name); | |
2790 | } | |
2791 | } | |
2792 | } | |
f14e6fdb DS |
2793 | } |
2794 | ||
2795 | ||
907f92c8 DS |
2796 | DEFUN (bgp_disable_connected_route_check, |
2797 | bgp_disable_connected_route_check_cmd, | |
2798 | "bgp disable-ebgp-connected-route-check", | |
2799 | "BGP specific commands\n" | |
2800 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2801 | { | |
d62a17ae | 2802 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2803 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2804 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2805 | |
d62a17ae | 2806 | return CMD_SUCCESS; |
907f92c8 DS |
2807 | } |
2808 | ||
2809 | DEFUN (no_bgp_disable_connected_route_check, | |
2810 | no_bgp_disable_connected_route_check_cmd, | |
2811 | "no bgp disable-ebgp-connected-route-check", | |
2812 | NO_STR | |
2813 | "BGP specific commands\n" | |
2814 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2815 | { | |
d62a17ae | 2816 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2817 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2818 | bgp_clear_star_soft_in(vty, bgp->name); | |
2819 | ||
2820 | return CMD_SUCCESS; | |
2821 | } | |
2822 | ||
2823 | ||
2824 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
2825 | const char *as_str, afi_t afi, safi_t safi) | |
2826 | { | |
2827 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2828 | int ret; | |
2829 | as_t as; | |
2830 | int as_type = AS_SPECIFIED; | |
2831 | union sockunion su; | |
2832 | ||
2833 | if (as_str[0] == 'i') { | |
2834 | as = 0; | |
2835 | as_type = AS_INTERNAL; | |
2836 | } else if (as_str[0] == 'e') { | |
2837 | as = 0; | |
2838 | as_type = AS_EXTERNAL; | |
2839 | } else { | |
2840 | /* Get AS number. */ | |
2841 | as = strtoul(as_str, NULL, 10); | |
2842 | } | |
2843 | ||
390485fd | 2844 | /* If peer is peer group or interface peer, call proper function. */ |
d62a17ae | 2845 | ret = str2sockunion(peer_str, &su); |
2846 | if (ret < 0) { | |
390485fd DS |
2847 | struct peer *peer; |
2848 | ||
2849 | /* Check if existing interface peer */ | |
2850 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
2851 | ||
d62a17ae | 2852 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, |
2853 | safi); | |
390485fd DS |
2854 | |
2855 | /* if not interface peer, check peer-group settings */ | |
2856 | if (ret < 0 && !peer) { | |
d62a17ae | 2857 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); |
2858 | if (ret < 0) { | |
2859 | vty_out(vty, | |
390485fd | 2860 | "%% Create the peer-group or interface first\n"); |
d62a17ae | 2861 | return CMD_WARNING_CONFIG_FAILED; |
2862 | } | |
2863 | return CMD_SUCCESS; | |
2864 | } | |
2865 | } else { | |
2866 | if (peer_address_self_check(bgp, &su)) { | |
2867 | vty_out(vty, | |
2868 | "%% Can not configure the local system as neighbor\n"); | |
2869 | return CMD_WARNING_CONFIG_FAILED; | |
2870 | } | |
2871 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
2872 | } | |
2873 | ||
2874 | /* This peer belongs to peer group. */ | |
2875 | switch (ret) { | |
2876 | case BGP_ERR_PEER_GROUP_MEMBER: | |
2877 | vty_out(vty, | |
faa16034 | 2878 | "%% Peer-group member cannot override remote-as of peer-group\n"); |
d62a17ae | 2879 | return CMD_WARNING_CONFIG_FAILED; |
2880 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
2881 | vty_out(vty, | |
faa16034 | 2882 | "%% Peer-group members must be all internal or all external\n"); |
d62a17ae | 2883 | return CMD_WARNING_CONFIG_FAILED; |
2884 | } | |
2885 | return bgp_vty_return(vty, ret); | |
718e3744 | 2886 | } |
2887 | ||
f26845f9 QY |
2888 | DEFUN (bgp_default_shutdown, |
2889 | bgp_default_shutdown_cmd, | |
2890 | "[no] bgp default shutdown", | |
2891 | NO_STR | |
2892 | BGP_STR | |
2893 | "Configure BGP defaults\n" | |
b012cbe2 | 2894 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
2895 | { |
2896 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2897 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
2898 | return CMD_SUCCESS; | |
2899 | } | |
2900 | ||
718e3744 | 2901 | DEFUN (neighbor_remote_as, |
2902 | neighbor_remote_as_cmd, | |
3a2d747c | 2903 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2904 | NEIGHBOR_STR |
2905 | NEIGHBOR_ADDR_STR2 | |
2906 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2907 | AS_STR |
3a2d747c QY |
2908 | "Internal BGP peer\n" |
2909 | "External BGP peer\n") | |
718e3744 | 2910 | { |
d62a17ae | 2911 | int idx_peer = 1; |
2912 | int idx_remote_as = 3; | |
2913 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
2914 | argv[idx_remote_as]->arg, AFI_IP, | |
2915 | SAFI_UNICAST); | |
2916 | } | |
2917 | ||
2918 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
2919 | afi_t afi, safi_t safi, int v6only, | |
2920 | const char *peer_group_name, | |
2921 | const char *as_str) | |
2922 | { | |
2923 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2924 | as_t as = 0; | |
2925 | int as_type = AS_UNSPECIFIED; | |
2926 | struct peer *peer; | |
2927 | struct peer_group *group; | |
2928 | int ret = 0; | |
2929 | union sockunion su; | |
2930 | ||
2931 | group = peer_group_lookup(bgp, conf_if); | |
2932 | ||
2933 | if (group) { | |
2934 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
2935 | return CMD_WARNING_CONFIG_FAILED; | |
2936 | } | |
2937 | ||
2938 | if (as_str) { | |
2939 | if (as_str[0] == 'i') { | |
2940 | as_type = AS_INTERNAL; | |
2941 | } else if (as_str[0] == 'e') { | |
2942 | as_type = AS_EXTERNAL; | |
2943 | } else { | |
2944 | /* Get AS number. */ | |
2945 | as = strtoul(as_str, NULL, 10); | |
2946 | as_type = AS_SPECIFIED; | |
2947 | } | |
2948 | } | |
2949 | ||
2950 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
2951 | if (peer) { | |
2952 | if (as_str) | |
cc4d4ce8 | 2953 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 2954 | afi, safi); |
2955 | } else { | |
2956 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2957 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
2958 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2959 | as_type, 0, 0, NULL); | |
2960 | else | |
2961 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2962 | as_type, afi, safi, NULL); | |
2963 | ||
2964 | if (!peer) { | |
2965 | vty_out(vty, "%% BGP failed to create peer\n"); | |
2966 | return CMD_WARNING_CONFIG_FAILED; | |
2967 | } | |
2968 | ||
2969 | if (v6only) | |
527de3dc | 2970 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2971 | |
2972 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
2973 | * this | |
2974 | * any unnumbered peer in order to not worry about run-time | |
2975 | * transitions | |
2976 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
2977 | * address | |
2978 | * gets deleted later etc.) | |
2979 | */ | |
2980 | if (peer->ifp) | |
2981 | bgp_zebra_initiate_radv(bgp, peer); | |
2982 | } | |
2983 | ||
2984 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
2985 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
2986 | if (v6only) | |
527de3dc | 2987 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2988 | else |
527de3dc | 2989 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2990 | |
2991 | /* v6only flag changed. Reset bgp seesion */ | |
2992 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2993 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2994 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2995 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2996 | } else | |
2997 | bgp_session_reset(peer); | |
2998 | } | |
2999 | ||
9fb964de PM |
3000 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
3001 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
3002 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 3003 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 3004 | } |
d62a17ae | 3005 | |
3006 | if (peer_group_name) { | |
3007 | group = peer_group_lookup(bgp, peer_group_name); | |
3008 | if (!group) { | |
3009 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3010 | return CMD_WARNING_CONFIG_FAILED; | |
3011 | } | |
3012 | ||
3013 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3014 | } | |
3015 | ||
3016 | return bgp_vty_return(vty, ret); | |
a80beece DS |
3017 | } |
3018 | ||
4c48cf63 DW |
3019 | DEFUN (neighbor_interface_config, |
3020 | neighbor_interface_config_cmd, | |
f3c3ee0d | 3021 | "neighbor WORD interface [peer-group PGNAME]", |
4c48cf63 DW |
3022 | NEIGHBOR_STR |
3023 | "Interface name or neighbor tag\n" | |
31500417 DW |
3024 | "Enable BGP on interface\n" |
3025 | "Member of the peer-group\n" | |
16cedbb0 | 3026 | "Peer-group name\n") |
4c48cf63 | 3027 | { |
d62a17ae | 3028 | int idx_word = 1; |
3029 | int idx_peer_group_word = 4; | |
31500417 | 3030 | |
d62a17ae | 3031 | if (argc > idx_peer_group_word) |
3032 | return peer_conf_interface_get( | |
3033 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
3034 | argv[idx_peer_group_word]->arg, NULL); | |
3035 | else | |
3036 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3037 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
3038 | } |
3039 | ||
4c48cf63 DW |
3040 | DEFUN (neighbor_interface_config_v6only, |
3041 | neighbor_interface_config_v6only_cmd, | |
f3c3ee0d | 3042 | "neighbor WORD interface v6only [peer-group PGNAME]", |
4c48cf63 DW |
3043 | NEIGHBOR_STR |
3044 | "Interface name or neighbor tag\n" | |
3045 | "Enable BGP on interface\n" | |
31500417 DW |
3046 | "Enable BGP with v6 link-local only\n" |
3047 | "Member of the peer-group\n" | |
16cedbb0 | 3048 | "Peer-group name\n") |
4c48cf63 | 3049 | { |
d62a17ae | 3050 | int idx_word = 1; |
3051 | int idx_peer_group_word = 5; | |
31500417 | 3052 | |
d62a17ae | 3053 | if (argc > idx_peer_group_word) |
3054 | return peer_conf_interface_get( | |
3055 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
3056 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 3057 | |
d62a17ae | 3058 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
3059 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
3060 | } |
3061 | ||
a80beece | 3062 | |
b3a39dc5 DD |
3063 | DEFUN (neighbor_interface_config_remote_as, |
3064 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 3065 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3066 | NEIGHBOR_STR |
3067 | "Interface name or neighbor tag\n" | |
3068 | "Enable BGP on interface\n" | |
3a2d747c | 3069 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3070 | AS_STR |
3a2d747c QY |
3071 | "Internal BGP peer\n" |
3072 | "External BGP peer\n") | |
b3a39dc5 | 3073 | { |
d62a17ae | 3074 | int idx_word = 1; |
3075 | int idx_remote_as = 4; | |
3076 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3077 | SAFI_UNICAST, 0, NULL, | |
3078 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3079 | } |
3080 | ||
3081 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
3082 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 3083 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3084 | NEIGHBOR_STR |
3085 | "Interface name or neighbor tag\n" | |
3a2d747c | 3086 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 3087 | "Enable BGP on interface\n" |
3a2d747c | 3088 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3089 | AS_STR |
3a2d747c QY |
3090 | "Internal BGP peer\n" |
3091 | "External BGP peer\n") | |
b3a39dc5 | 3092 | { |
d62a17ae | 3093 | int idx_word = 1; |
3094 | int idx_remote_as = 5; | |
3095 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3096 | SAFI_UNICAST, 1, NULL, | |
3097 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3098 | } |
3099 | ||
718e3744 | 3100 | DEFUN (neighbor_peer_group, |
3101 | neighbor_peer_group_cmd, | |
3102 | "neighbor WORD peer-group", | |
3103 | NEIGHBOR_STR | |
a80beece | 3104 | "Interface name or neighbor tag\n" |
718e3744 | 3105 | "Configure peer-group\n") |
3106 | { | |
d62a17ae | 3107 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3108 | int idx_word = 1; | |
3109 | struct peer *peer; | |
3110 | struct peer_group *group; | |
718e3744 | 3111 | |
d62a17ae | 3112 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
3113 | if (peer) { | |
3114 | vty_out(vty, "%% Name conflict with interface: \n"); | |
3115 | return CMD_WARNING_CONFIG_FAILED; | |
3116 | } | |
718e3744 | 3117 | |
d62a17ae | 3118 | group = peer_group_get(bgp, argv[idx_word]->arg); |
3119 | if (!group) { | |
3120 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
3121 | return CMD_WARNING_CONFIG_FAILED; | |
3122 | } | |
718e3744 | 3123 | |
d62a17ae | 3124 | return CMD_SUCCESS; |
718e3744 | 3125 | } |
3126 | ||
3127 | DEFUN (no_neighbor, | |
3128 | no_neighbor_cmd, | |
dab8cd00 | 3129 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 3130 | NO_STR |
3131 | NEIGHBOR_STR | |
3a2d747c QY |
3132 | NEIGHBOR_ADDR_STR2 |
3133 | "Specify a BGP neighbor\n" | |
3134 | AS_STR | |
3135 | "Internal BGP peer\n" | |
3136 | "External BGP peer\n") | |
718e3744 | 3137 | { |
d62a17ae | 3138 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3139 | int idx_peer = 2; | |
3140 | int ret; | |
3141 | union sockunion su; | |
3142 | struct peer_group *group; | |
3143 | struct peer *peer; | |
3144 | struct peer *other; | |
3145 | ||
3146 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3147 | if (ret < 0) { | |
3148 | /* look up for neighbor by interface name config. */ | |
3149 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3150 | if (peer) { | |
3151 | /* Request zebra to terminate IPv6 RAs on this | |
3152 | * interface. */ | |
3153 | if (peer->ifp) | |
3154 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3155 | peer_delete(peer); | |
3156 | return CMD_SUCCESS; | |
3157 | } | |
f14e6fdb | 3158 | |
d62a17ae | 3159 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
3160 | if (group) | |
3161 | peer_group_delete(group); | |
3162 | else { | |
3163 | vty_out(vty, "%% Create the peer-group first\n"); | |
3164 | return CMD_WARNING_CONFIG_FAILED; | |
3165 | } | |
3166 | } else { | |
3167 | peer = peer_lookup(bgp, &su); | |
3168 | if (peer) { | |
3169 | if (peer_dynamic_neighbor(peer)) { | |
3170 | vty_out(vty, | |
3171 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3172 | return CMD_WARNING_CONFIG_FAILED; | |
3173 | } | |
3174 | ||
3175 | other = peer->doppelganger; | |
3176 | peer_delete(peer); | |
3177 | if (other && other->status != Deleted) | |
3178 | peer_delete(other); | |
3179 | } | |
1ff9a340 | 3180 | } |
718e3744 | 3181 | |
d62a17ae | 3182 | return CMD_SUCCESS; |
718e3744 | 3183 | } |
3184 | ||
a80beece DS |
3185 | DEFUN (no_neighbor_interface_config, |
3186 | no_neighbor_interface_config_cmd, | |
f3c3ee0d | 3187 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3188 | NO_STR |
3189 | NEIGHBOR_STR | |
3190 | "Interface name\n" | |
31500417 DW |
3191 | "Configure BGP on interface\n" |
3192 | "Enable BGP with v6 link-local only\n" | |
3193 | "Member of the peer-group\n" | |
16cedbb0 | 3194 | "Peer-group name\n" |
3a2d747c QY |
3195 | "Specify a BGP neighbor\n" |
3196 | AS_STR | |
3197 | "Internal BGP peer\n" | |
3198 | "External BGP peer\n") | |
a80beece | 3199 | { |
d62a17ae | 3200 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3201 | int idx_word = 2; | |
3202 | struct peer *peer; | |
3203 | ||
3204 | /* look up for neighbor by interface name config. */ | |
3205 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3206 | if (peer) { | |
3207 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3208 | if (peer->ifp) | |
3209 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3210 | peer_delete(peer); | |
3211 | } else { | |
3212 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3213 | return CMD_WARNING_CONFIG_FAILED; | |
3214 | } | |
3215 | return CMD_SUCCESS; | |
a80beece DS |
3216 | } |
3217 | ||
718e3744 | 3218 | DEFUN (no_neighbor_peer_group, |
3219 | no_neighbor_peer_group_cmd, | |
3220 | "no neighbor WORD peer-group", | |
3221 | NO_STR | |
3222 | NEIGHBOR_STR | |
3223 | "Neighbor tag\n" | |
3224 | "Configure peer-group\n") | |
3225 | { | |
d62a17ae | 3226 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3227 | int idx_word = 2; | |
3228 | struct peer_group *group; | |
718e3744 | 3229 | |
d62a17ae | 3230 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
3231 | if (group) | |
3232 | peer_group_delete(group); | |
3233 | else { | |
3234 | vty_out(vty, "%% Create the peer-group first\n"); | |
3235 | return CMD_WARNING_CONFIG_FAILED; | |
3236 | } | |
3237 | return CMD_SUCCESS; | |
718e3744 | 3238 | } |
3239 | ||
a80beece DS |
3240 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3241 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3242 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3243 | NO_STR |
3244 | NEIGHBOR_STR | |
a80beece | 3245 | "Interface name or neighbor tag\n" |
718e3744 | 3246 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3247 | AS_STR |
3248 | "Internal BGP peer\n" | |
3249 | "External BGP peer\n") | |
718e3744 | 3250 | { |
d62a17ae | 3251 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3252 | int idx_word = 2; | |
3253 | struct peer_group *group; | |
3254 | struct peer *peer; | |
3255 | ||
3256 | /* look up for neighbor by interface name config. */ | |
3257 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3258 | if (peer) { | |
390485fd | 3259 | peer_as_change(peer, 0, AS_UNSPECIFIED); |
d62a17ae | 3260 | return CMD_SUCCESS; |
3261 | } | |
3262 | ||
3263 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3264 | if (group) | |
3265 | peer_group_remote_as_delete(group); | |
3266 | else { | |
3267 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3268 | return CMD_WARNING_CONFIG_FAILED; | |
3269 | } | |
3270 | return CMD_SUCCESS; | |
718e3744 | 3271 | } |
6b0655a2 | 3272 | |
718e3744 | 3273 | DEFUN (neighbor_local_as, |
3274 | neighbor_local_as_cmd, | |
9ccf14f7 | 3275 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3276 | NEIGHBOR_STR |
3277 | NEIGHBOR_ADDR_STR2 | |
3278 | "Specify a local-as number\n" | |
3279 | "AS number used as local AS\n") | |
3280 | { | |
d62a17ae | 3281 | int idx_peer = 1; |
3282 | int idx_number = 3; | |
3283 | struct peer *peer; | |
3284 | int ret; | |
3285 | as_t as; | |
718e3744 | 3286 | |
d62a17ae | 3287 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3288 | if (!peer) | |
3289 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3290 | |
d62a17ae | 3291 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3292 | ret = peer_local_as_set(peer, as, 0, 0); | |
3293 | return bgp_vty_return(vty, ret); | |
718e3744 | 3294 | } |
3295 | ||
3296 | DEFUN (neighbor_local_as_no_prepend, | |
3297 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3298 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3299 | NEIGHBOR_STR |
3300 | NEIGHBOR_ADDR_STR2 | |
3301 | "Specify a local-as number\n" | |
3302 | "AS number used as local AS\n" | |
3303 | "Do not prepend local-as to updates from ebgp peers\n") | |
3304 | { | |
d62a17ae | 3305 | int idx_peer = 1; |
3306 | int idx_number = 3; | |
3307 | struct peer *peer; | |
3308 | int ret; | |
3309 | as_t as; | |
718e3744 | 3310 | |
d62a17ae | 3311 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3312 | if (!peer) | |
3313 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3314 | |
d62a17ae | 3315 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3316 | ret = peer_local_as_set(peer, as, 1, 0); | |
3317 | return bgp_vty_return(vty, ret); | |
718e3744 | 3318 | } |
3319 | ||
9d3f9705 AC |
3320 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3321 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3322 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3323 | NEIGHBOR_STR |
3324 | NEIGHBOR_ADDR_STR2 | |
3325 | "Specify a local-as number\n" | |
3326 | "AS number used as local AS\n" | |
3327 | "Do not prepend local-as to updates from ebgp peers\n" | |
3328 | "Do not prepend local-as to updates from ibgp peers\n") | |
3329 | { | |
d62a17ae | 3330 | int idx_peer = 1; |
3331 | int idx_number = 3; | |
3332 | struct peer *peer; | |
3333 | int ret; | |
3334 | as_t as; | |
9d3f9705 | 3335 | |
d62a17ae | 3336 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3337 | if (!peer) | |
3338 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3339 | |
d62a17ae | 3340 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3341 | ret = peer_local_as_set(peer, as, 1, 1); | |
3342 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3343 | } |
3344 | ||
718e3744 | 3345 | DEFUN (no_neighbor_local_as, |
3346 | no_neighbor_local_as_cmd, | |
a636c635 | 3347 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3348 | NO_STR |
3349 | NEIGHBOR_STR | |
3350 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3351 | "Specify a local-as number\n" |
3352 | "AS number used as local AS\n" | |
3353 | "Do not prepend local-as to updates from ebgp peers\n" | |
3354 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3355 | { |
d62a17ae | 3356 | int idx_peer = 2; |
3357 | struct peer *peer; | |
3358 | int ret; | |
718e3744 | 3359 | |
d62a17ae | 3360 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3361 | if (!peer) | |
3362 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3363 | |
d62a17ae | 3364 | ret = peer_local_as_unset(peer); |
3365 | return bgp_vty_return(vty, ret); | |
718e3744 | 3366 | } |
3367 | ||
718e3744 | 3368 | |
3f9c7369 DS |
3369 | DEFUN (neighbor_solo, |
3370 | neighbor_solo_cmd, | |
9ccf14f7 | 3371 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3372 | NEIGHBOR_STR |
3373 | NEIGHBOR_ADDR_STR2 | |
3374 | "Solo peer - part of its own update group\n") | |
3375 | { | |
d62a17ae | 3376 | int idx_peer = 1; |
3377 | struct peer *peer; | |
3378 | int ret; | |
3f9c7369 | 3379 | |
d62a17ae | 3380 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3381 | if (!peer) | |
3382 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3383 | |
d62a17ae | 3384 | ret = update_group_adjust_soloness(peer, 1); |
3385 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3386 | } |
3387 | ||
3388 | DEFUN (no_neighbor_solo, | |
3389 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3390 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3391 | NO_STR |
3392 | NEIGHBOR_STR | |
3393 | NEIGHBOR_ADDR_STR2 | |
3394 | "Solo peer - part of its own update group\n") | |
3395 | { | |
d62a17ae | 3396 | int idx_peer = 2; |
3397 | struct peer *peer; | |
3398 | int ret; | |
3f9c7369 | 3399 | |
d62a17ae | 3400 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3401 | if (!peer) | |
3402 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3403 | |
d62a17ae | 3404 | ret = update_group_adjust_soloness(peer, 0); |
3405 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3406 | } |
3407 | ||
0df7c91f PJ |
3408 | DEFUN (neighbor_password, |
3409 | neighbor_password_cmd, | |
9ccf14f7 | 3410 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3411 | NEIGHBOR_STR |
3412 | NEIGHBOR_ADDR_STR2 | |
3413 | "Set a password\n" | |
3414 | "The password\n") | |
3415 | { | |
d62a17ae | 3416 | int idx_peer = 1; |
3417 | int idx_line = 3; | |
3418 | struct peer *peer; | |
3419 | int ret; | |
0df7c91f | 3420 | |
d62a17ae | 3421 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3422 | if (!peer) | |
3423 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3424 | |
d62a17ae | 3425 | ret = peer_password_set(peer, argv[idx_line]->arg); |
3426 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
3427 | } |
3428 | ||
3429 | DEFUN (no_neighbor_password, | |
3430 | no_neighbor_password_cmd, | |
a636c635 | 3431 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3432 | NO_STR |
3433 | NEIGHBOR_STR | |
3434 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3435 | "Set a password\n" |
3436 | "The password\n") | |
0df7c91f | 3437 | { |
d62a17ae | 3438 | int idx_peer = 2; |
3439 | struct peer *peer; | |
3440 | int ret; | |
0df7c91f | 3441 | |
d62a17ae | 3442 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3443 | if (!peer) | |
3444 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3445 | |
d62a17ae | 3446 | ret = peer_password_unset(peer); |
3447 | return bgp_vty_return(vty, ret); | |
0df7c91f | 3448 | } |
6b0655a2 | 3449 | |
718e3744 | 3450 | DEFUN (neighbor_activate, |
3451 | neighbor_activate_cmd, | |
9ccf14f7 | 3452 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3453 | NEIGHBOR_STR |
3454 | NEIGHBOR_ADDR_STR2 | |
3455 | "Enable the Address Family for this Neighbor\n") | |
3456 | { | |
d62a17ae | 3457 | int idx_peer = 1; |
3458 | int ret; | |
3459 | struct peer *peer; | |
718e3744 | 3460 | |
d62a17ae | 3461 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3462 | if (!peer) | |
3463 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3464 | |
d62a17ae | 3465 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3466 | return bgp_vty_return(vty, ret); | |
718e3744 | 3467 | } |
3468 | ||
d62a17ae | 3469 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
3470 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3471 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3472 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3473 | |
718e3744 | 3474 | DEFUN (no_neighbor_activate, |
3475 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3476 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3477 | NO_STR |
3478 | NEIGHBOR_STR | |
3479 | NEIGHBOR_ADDR_STR2 | |
3480 | "Enable the Address Family for this Neighbor\n") | |
3481 | { | |
d62a17ae | 3482 | int idx_peer = 2; |
3483 | int ret; | |
3484 | struct peer *peer; | |
718e3744 | 3485 | |
d62a17ae | 3486 | /* Lookup peer. */ |
3487 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3488 | if (!peer) | |
3489 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3490 | |
d62a17ae | 3491 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3492 | return bgp_vty_return(vty, ret); | |
718e3744 | 3493 | } |
6b0655a2 | 3494 | |
d62a17ae | 3495 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
3496 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3497 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3498 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3499 | |
718e3744 | 3500 | DEFUN (neighbor_set_peer_group, |
3501 | neighbor_set_peer_group_cmd, | |
f3c3ee0d | 3502 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 3503 | NEIGHBOR_STR |
a80beece | 3504 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3505 | "Member of the peer-group\n" |
16cedbb0 | 3506 | "Peer-group name\n") |
718e3744 | 3507 | { |
d62a17ae | 3508 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3509 | int idx_peer = 1; | |
3510 | int idx_word = 3; | |
3511 | int ret; | |
3512 | as_t as; | |
3513 | union sockunion su; | |
3514 | struct peer *peer; | |
3515 | struct peer_group *group; | |
3516 | ||
d62a17ae | 3517 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
3518 | if (ret < 0) { | |
3519 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3520 | if (!peer) { | |
3521 | vty_out(vty, "%% Malformed address or name: %s\n", | |
3522 | argv[idx_peer]->arg); | |
3523 | return CMD_WARNING_CONFIG_FAILED; | |
3524 | } | |
3525 | } else { | |
3526 | if (peer_address_self_check(bgp, &su)) { | |
3527 | vty_out(vty, | |
3528 | "%% Can not configure the local system as neighbor\n"); | |
3529 | return CMD_WARNING_CONFIG_FAILED; | |
3530 | } | |
3531 | ||
3532 | /* Disallow for dynamic neighbor. */ | |
3533 | peer = peer_lookup(bgp, &su); | |
3534 | if (peer && peer_dynamic_neighbor(peer)) { | |
3535 | vty_out(vty, | |
3536 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3537 | return CMD_WARNING_CONFIG_FAILED; | |
3538 | } | |
3539 | } | |
3540 | ||
3541 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3542 | if (!group) { | |
3543 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3544 | return CMD_WARNING_CONFIG_FAILED; | |
3545 | } | |
3546 | ||
3547 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3548 | ||
3549 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
3550 | vty_out(vty, | |
3551 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
3552 | as); | |
3553 | return CMD_WARNING_CONFIG_FAILED; | |
3554 | } | |
3555 | ||
3556 | return bgp_vty_return(vty, ret); | |
3557 | } | |
3558 | ||
3559 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
f3c3ee0d | 3560 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 3561 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
3562 | "Member of the peer-group\n" | |
3563 | "Peer-group name\n") | |
596c17ba | 3564 | |
718e3744 | 3565 | DEFUN (no_neighbor_set_peer_group, |
3566 | no_neighbor_set_peer_group_cmd, | |
f3c3ee0d | 3567 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 3568 | NO_STR |
3569 | NEIGHBOR_STR | |
a80beece | 3570 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3571 | "Member of the peer-group\n" |
16cedbb0 | 3572 | "Peer-group name\n") |
718e3744 | 3573 | { |
d62a17ae | 3574 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3575 | int idx_peer = 2; | |
3576 | int idx_word = 4; | |
3577 | int ret; | |
3578 | struct peer *peer; | |
3579 | struct peer_group *group; | |
3580 | ||
3581 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
3582 | if (!peer) | |
3583 | return CMD_WARNING_CONFIG_FAILED; | |
3584 | ||
3585 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3586 | if (!group) { | |
3587 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3588 | return CMD_WARNING_CONFIG_FAILED; | |
3589 | } | |
718e3744 | 3590 | |
827ed707 | 3591 | ret = peer_delete(peer); |
718e3744 | 3592 | |
d62a17ae | 3593 | return bgp_vty_return(vty, ret); |
718e3744 | 3594 | } |
6b0655a2 | 3595 | |
d62a17ae | 3596 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
f3c3ee0d | 3597 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 3598 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
3599 | "Member of the peer-group\n" | |
3600 | "Peer-group name\n") | |
596c17ba | 3601 | |
d62a17ae | 3602 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3603 | uint32_t flag, int set) |
718e3744 | 3604 | { |
d62a17ae | 3605 | int ret; |
3606 | struct peer *peer; | |
718e3744 | 3607 | |
d62a17ae | 3608 | peer = peer_and_group_lookup_vty(vty, ip_str); |
3609 | if (!peer) | |
3610 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3611 | |
7ebe625c QY |
3612 | /* |
3613 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3614 | * we should not accept disable-connected-check. | |
3615 | */ | |
3616 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3617 | vty_out(vty, | |
3618 | "%s is directly connected peer, cannot accept disable-" | |
3619 | "connected-check\n", | |
3620 | ip_str); | |
3621 | return CMD_WARNING_CONFIG_FAILED; | |
3622 | } | |
3623 | ||
d62a17ae | 3624 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3625 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 3626 | |
d62a17ae | 3627 | if (set) |
3628 | ret = peer_flag_set(peer, flag); | |
3629 | else | |
3630 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 3631 | |
d62a17ae | 3632 | return bgp_vty_return(vty, ret); |
718e3744 | 3633 | } |
3634 | ||
47cbc09b | 3635 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 3636 | { |
d62a17ae | 3637 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 3638 | } |
3639 | ||
d62a17ae | 3640 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3641 | uint32_t flag) |
718e3744 | 3642 | { |
d62a17ae | 3643 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 3644 | } |
3645 | ||
3646 | /* neighbor passive. */ | |
3647 | DEFUN (neighbor_passive, | |
3648 | neighbor_passive_cmd, | |
9ccf14f7 | 3649 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3650 | NEIGHBOR_STR |
3651 | NEIGHBOR_ADDR_STR2 | |
3652 | "Don't send open messages to this neighbor\n") | |
3653 | { | |
d62a17ae | 3654 | int idx_peer = 1; |
3655 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3656 | } |
3657 | ||
3658 | DEFUN (no_neighbor_passive, | |
3659 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3660 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3661 | NO_STR |
3662 | NEIGHBOR_STR | |
3663 | NEIGHBOR_ADDR_STR2 | |
3664 | "Don't send open messages to this neighbor\n") | |
3665 | { | |
d62a17ae | 3666 | int idx_peer = 2; |
3667 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3668 | } |
6b0655a2 | 3669 | |
718e3744 | 3670 | /* neighbor shutdown. */ |
73d70fa6 DL |
3671 | DEFUN (neighbor_shutdown_msg, |
3672 | neighbor_shutdown_msg_cmd, | |
3673 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3674 | NEIGHBOR_STR |
3675 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3676 | "Administratively shut down this neighbor\n" |
3677 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3678 | "Shutdown message\n") | |
718e3744 | 3679 | { |
d62a17ae | 3680 | int idx_peer = 1; |
73d70fa6 | 3681 | |
d62a17ae | 3682 | if (argc >= 5) { |
3683 | struct peer *peer = | |
3684 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3685 | char *message; | |
73d70fa6 | 3686 | |
d62a17ae | 3687 | if (!peer) |
3688 | return CMD_WARNING_CONFIG_FAILED; | |
3689 | message = argv_concat(argv, argc, 4); | |
3690 | peer_tx_shutdown_message_set(peer, message); | |
3691 | XFREE(MTYPE_TMP, message); | |
3692 | } | |
73d70fa6 | 3693 | |
d62a17ae | 3694 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3695 | } |
3696 | ||
d62a17ae | 3697 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
3698 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3699 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3700 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3701 | |
3702 | DEFUN (no_neighbor_shutdown_msg, | |
3703 | no_neighbor_shutdown_msg_cmd, | |
3704 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3705 | NO_STR | |
3706 | NEIGHBOR_STR | |
3707 | NEIGHBOR_ADDR_STR2 | |
3708 | "Administratively shut down this neighbor\n" | |
3709 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3710 | "Shutdown message\n") | |
718e3744 | 3711 | { |
d62a17ae | 3712 | int idx_peer = 2; |
73d70fa6 | 3713 | |
d62a17ae | 3714 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
3715 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 3716 | } |
6b0655a2 | 3717 | |
d62a17ae | 3718 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
3719 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3720 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3721 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 3722 | |
718e3744 | 3723 | /* neighbor capability dynamic. */ |
3724 | DEFUN (neighbor_capability_dynamic, | |
3725 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3726 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3727 | NEIGHBOR_STR |
3728 | NEIGHBOR_ADDR_STR2 | |
3729 | "Advertise capability to the peer\n" | |
3730 | "Advertise dynamic capability to this neighbor\n") | |
3731 | { | |
d62a17ae | 3732 | int idx_peer = 1; |
3733 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3734 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3735 | } |
3736 | ||
3737 | DEFUN (no_neighbor_capability_dynamic, | |
3738 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3739 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3740 | NO_STR |
3741 | NEIGHBOR_STR | |
3742 | NEIGHBOR_ADDR_STR2 | |
3743 | "Advertise capability to the peer\n" | |
3744 | "Advertise dynamic capability to this neighbor\n") | |
3745 | { | |
d62a17ae | 3746 | int idx_peer = 2; |
3747 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3748 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3749 | } |
6b0655a2 | 3750 | |
718e3744 | 3751 | /* neighbor dont-capability-negotiate */ |
3752 | DEFUN (neighbor_dont_capability_negotiate, | |
3753 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3754 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3755 | NEIGHBOR_STR |
3756 | NEIGHBOR_ADDR_STR2 | |
3757 | "Do not perform capability negotiation\n") | |
3758 | { | |
d62a17ae | 3759 | int idx_peer = 1; |
3760 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3761 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3762 | } |
3763 | ||
3764 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3765 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3766 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3767 | NO_STR |
3768 | NEIGHBOR_STR | |
3769 | NEIGHBOR_ADDR_STR2 | |
3770 | "Do not perform capability negotiation\n") | |
3771 | { | |
d62a17ae | 3772 | int idx_peer = 2; |
3773 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3774 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3775 | } |
6b0655a2 | 3776 | |
8a92a8a0 DS |
3777 | /* neighbor capability extended next hop encoding */ |
3778 | DEFUN (neighbor_capability_enhe, | |
3779 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3780 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3781 | NEIGHBOR_STR |
3782 | NEIGHBOR_ADDR_STR2 | |
3783 | "Advertise capability to the peer\n" | |
3784 | "Advertise extended next-hop capability to the peer\n") | |
3785 | { | |
d62a17ae | 3786 | int idx_peer = 1; |
3787 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3788 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3789 | } |
3790 | ||
3791 | DEFUN (no_neighbor_capability_enhe, | |
3792 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3793 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3794 | NO_STR |
3795 | NEIGHBOR_STR | |
3796 | NEIGHBOR_ADDR_STR2 | |
3797 | "Advertise capability to the peer\n" | |
3798 | "Advertise extended next-hop capability to the peer\n") | |
3799 | { | |
d62a17ae | 3800 | int idx_peer = 2; |
3801 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3802 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3803 | } |
3804 | ||
d62a17ae | 3805 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3806 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 3807 | int set) |
718e3744 | 3808 | { |
d62a17ae | 3809 | int ret; |
3810 | struct peer *peer; | |
718e3744 | 3811 | |
d62a17ae | 3812 | peer = peer_and_group_lookup_vty(vty, peer_str); |
3813 | if (!peer) | |
3814 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3815 | |
d62a17ae | 3816 | if (set) |
3817 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
3818 | else | |
3819 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 3820 | |
d62a17ae | 3821 | return bgp_vty_return(vty, ret); |
718e3744 | 3822 | } |
3823 | ||
d62a17ae | 3824 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3825 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3826 | { |
d62a17ae | 3827 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 3828 | } |
3829 | ||
d62a17ae | 3830 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3831 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3832 | { |
d62a17ae | 3833 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 3834 | } |
6b0655a2 | 3835 | |
718e3744 | 3836 | /* neighbor capability orf prefix-list. */ |
3837 | DEFUN (neighbor_capability_orf_prefix, | |
3838 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3839 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3840 | NEIGHBOR_STR |
3841 | NEIGHBOR_ADDR_STR2 | |
3842 | "Advertise capability to the peer\n" | |
3843 | "Advertise ORF capability to the peer\n" | |
3844 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3845 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3846 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3847 | "Capability to SEND the ORF to this neighbor\n") | |
3848 | { | |
d62a17ae | 3849 | int idx_peer = 1; |
3850 | int idx_send_recv = 5; | |
d7c0a89a | 3851 | uint16_t flag = 0; |
d62a17ae | 3852 | |
3853 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3854 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3855 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3856 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3857 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3858 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3859 | else { | |
3860 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3861 | return CMD_WARNING_CONFIG_FAILED; | |
3862 | } | |
3863 | ||
3864 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3865 | bgp_node_safi(vty), flag); | |
3866 | } | |
3867 | ||
3868 | ALIAS_HIDDEN( | |
3869 | neighbor_capability_orf_prefix, | |
3870 | neighbor_capability_orf_prefix_hidden_cmd, | |
3871 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3872 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3873 | "Advertise capability to the peer\n" | |
3874 | "Advertise ORF capability to the peer\n" | |
3875 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3876 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3877 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3878 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3879 | |
718e3744 | 3880 | DEFUN (no_neighbor_capability_orf_prefix, |
3881 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3882 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3883 | NO_STR |
3884 | NEIGHBOR_STR | |
3885 | NEIGHBOR_ADDR_STR2 | |
3886 | "Advertise capability to the peer\n" | |
3887 | "Advertise ORF capability to the peer\n" | |
3888 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3889 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3890 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3891 | "Capability to SEND the ORF to this neighbor\n") | |
3892 | { | |
d62a17ae | 3893 | int idx_peer = 2; |
3894 | int idx_send_recv = 6; | |
d7c0a89a | 3895 | uint16_t flag = 0; |
d62a17ae | 3896 | |
3897 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3898 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3899 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3900 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3901 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3902 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3903 | else { | |
3904 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3905 | return CMD_WARNING_CONFIG_FAILED; | |
3906 | } | |
3907 | ||
3908 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3909 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3910 | flag); | |
3911 | } | |
3912 | ||
3913 | ALIAS_HIDDEN( | |
3914 | no_neighbor_capability_orf_prefix, | |
3915 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
3916 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3917 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3918 | "Advertise capability to the peer\n" | |
3919 | "Advertise ORF capability to the peer\n" | |
3920 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3921 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3922 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3923 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3924 | |
718e3744 | 3925 | /* neighbor next-hop-self. */ |
3926 | DEFUN (neighbor_nexthop_self, | |
3927 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3928 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3929 | NEIGHBOR_STR |
3930 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3931 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3932 | { |
d62a17ae | 3933 | int idx_peer = 1; |
3934 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3935 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 3936 | } |
9e7a53c1 | 3937 | |
d62a17ae | 3938 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
3939 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3940 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3941 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3942 | |
a538debe DS |
3943 | /* neighbor next-hop-self. */ |
3944 | DEFUN (neighbor_nexthop_self_force, | |
3945 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3946 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3947 | NEIGHBOR_STR |
3948 | NEIGHBOR_ADDR_STR2 | |
3949 | "Disable the next hop calculation for this neighbor\n" | |
3950 | "Set the next hop to self for reflected routes\n") | |
3951 | { | |
d62a17ae | 3952 | int idx_peer = 1; |
3953 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3954 | bgp_node_safi(vty), | |
3955 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 3956 | } |
3957 | ||
d62a17ae | 3958 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3959 | neighbor_nexthop_self_force_hidden_cmd, | |
3960 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3961 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3962 | "Disable the next hop calculation for this neighbor\n" | |
3963 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3964 | |
1bc4e531 DA |
3965 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3966 | neighbor_nexthop_self_all_hidden_cmd, | |
3967 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
3968 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3969 | "Disable the next hop calculation for this neighbor\n" | |
3970 | "Set the next hop to self for reflected routes\n") | |
3971 | ||
718e3744 | 3972 | DEFUN (no_neighbor_nexthop_self, |
3973 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3974 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3975 | NO_STR |
3976 | NEIGHBOR_STR | |
3977 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3978 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3979 | { |
d62a17ae | 3980 | int idx_peer = 2; |
3981 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3982 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3983 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 3984 | } |
6b0655a2 | 3985 | |
d62a17ae | 3986 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
3987 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3988 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3989 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3990 | |
88b8ed8d | 3991 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3992 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3993 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3994 | NO_STR |
3995 | NEIGHBOR_STR | |
3996 | NEIGHBOR_ADDR_STR2 | |
3997 | "Disable the next hop calculation for this neighbor\n" | |
3998 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3999 | { |
d62a17ae | 4000 | int idx_peer = 2; |
4001 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4002 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4003 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 4004 | } |
a538debe | 4005 | |
d62a17ae | 4006 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4007 | no_neighbor_nexthop_self_force_hidden_cmd, | |
4008 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
4009 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4010 | "Disable the next hop calculation for this neighbor\n" | |
4011 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 4012 | |
1bc4e531 DA |
4013 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
4014 | no_neighbor_nexthop_self_all_hidden_cmd, | |
4015 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
4016 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4017 | "Disable the next hop calculation for this neighbor\n" | |
4018 | "Set the next hop to self for reflected routes\n") | |
4019 | ||
c7122e14 DS |
4020 | /* neighbor as-override */ |
4021 | DEFUN (neighbor_as_override, | |
4022 | neighbor_as_override_cmd, | |
9ccf14f7 | 4023 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4024 | NEIGHBOR_STR |
4025 | NEIGHBOR_ADDR_STR2 | |
4026 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4027 | { | |
d62a17ae | 4028 | int idx_peer = 1; |
4029 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4030 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4031 | } |
4032 | ||
d62a17ae | 4033 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
4034 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4035 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4036 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4037 | |
c7122e14 DS |
4038 | DEFUN (no_neighbor_as_override, |
4039 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 4040 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
4041 | NO_STR |
4042 | NEIGHBOR_STR | |
4043 | NEIGHBOR_ADDR_STR2 | |
4044 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
4045 | { | |
d62a17ae | 4046 | int idx_peer = 2; |
4047 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4048 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4049 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
4050 | } |
4051 | ||
d62a17ae | 4052 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
4053 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
4054 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4055 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 4056 | |
718e3744 | 4057 | /* neighbor remove-private-AS. */ |
4058 | DEFUN (neighbor_remove_private_as, | |
4059 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4060 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4061 | NEIGHBOR_STR |
4062 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4063 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4064 | { |
d62a17ae | 4065 | int idx_peer = 1; |
4066 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4067 | bgp_node_safi(vty), | |
4068 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4069 | } |
4070 | ||
d62a17ae | 4071 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
4072 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4073 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4074 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4075 | |
5000f21c DS |
4076 | DEFUN (neighbor_remove_private_as_all, |
4077 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 4078 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4079 | NEIGHBOR_STR |
4080 | NEIGHBOR_ADDR_STR2 | |
4081 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 4082 | "Apply to all AS numbers\n") |
5000f21c | 4083 | { |
d62a17ae | 4084 | int idx_peer = 1; |
4085 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4086 | bgp_node_safi(vty), | |
4087 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
4088 | } |
4089 | ||
d62a17ae | 4090 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
4091 | neighbor_remove_private_as_all_hidden_cmd, | |
4092 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4093 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4094 | "Remove private ASNs in outbound updates\n" | |
4095 | "Apply to all AS numbers") | |
596c17ba | 4096 | |
5000f21c DS |
4097 | DEFUN (neighbor_remove_private_as_replace_as, |
4098 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 4099 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4100 | NEIGHBOR_STR |
4101 | NEIGHBOR_ADDR_STR2 | |
4102 | "Remove private ASNs in outbound updates\n" | |
4103 | "Replace private ASNs with our ASN in outbound updates\n") | |
4104 | { | |
d62a17ae | 4105 | int idx_peer = 1; |
4106 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4107 | bgp_node_safi(vty), | |
4108 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
4109 | } |
4110 | ||
d62a17ae | 4111 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
4112 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
4113 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4114 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4115 | "Remove private ASNs in outbound updates\n" | |
4116 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4117 | |
5000f21c DS |
4118 | DEFUN (neighbor_remove_private_as_all_replace_as, |
4119 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 4120 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4121 | NEIGHBOR_STR |
4122 | NEIGHBOR_ADDR_STR2 | |
4123 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4124 | "Apply to all AS numbers\n" |
5000f21c DS |
4125 | "Replace private ASNs with our ASN in outbound updates\n") |
4126 | { | |
d62a17ae | 4127 | int idx_peer = 1; |
4128 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4129 | bgp_node_safi(vty), | |
4130 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
4131 | } |
4132 | ||
d62a17ae | 4133 | ALIAS_HIDDEN( |
4134 | neighbor_remove_private_as_all_replace_as, | |
4135 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4136 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4137 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4138 | "Remove private ASNs in outbound updates\n" | |
4139 | "Apply to all AS numbers\n" | |
4140 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4141 | |
718e3744 | 4142 | DEFUN (no_neighbor_remove_private_as, |
4143 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4144 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4145 | NO_STR |
4146 | NEIGHBOR_STR | |
4147 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4148 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4149 | { |
d62a17ae | 4150 | int idx_peer = 2; |
4151 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4152 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4153 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4154 | } |
6b0655a2 | 4155 | |
d62a17ae | 4156 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4157 | no_neighbor_remove_private_as_hidden_cmd, | |
4158 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4159 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4160 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4161 | |
88b8ed8d | 4162 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4163 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4164 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4165 | NO_STR |
4166 | NEIGHBOR_STR | |
4167 | NEIGHBOR_ADDR_STR2 | |
4168 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4169 | "Apply to all AS numbers\n") |
88b8ed8d | 4170 | { |
d62a17ae | 4171 | int idx_peer = 2; |
4172 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4173 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4174 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4175 | } |
5000f21c | 4176 | |
d62a17ae | 4177 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4178 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4179 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4180 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4181 | "Remove private ASNs in outbound updates\n" | |
4182 | "Apply to all AS numbers\n") | |
596c17ba | 4183 | |
88b8ed8d | 4184 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4185 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4186 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4187 | NO_STR |
4188 | NEIGHBOR_STR | |
4189 | NEIGHBOR_ADDR_STR2 | |
4190 | "Remove private ASNs in outbound updates\n" | |
4191 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4192 | { |
d62a17ae | 4193 | int idx_peer = 2; |
4194 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4195 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4196 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4197 | } |
5000f21c | 4198 | |
d62a17ae | 4199 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4200 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4201 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4202 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4203 | "Remove private ASNs in outbound updates\n" | |
4204 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4205 | |
88b8ed8d | 4206 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4207 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4208 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4209 | NO_STR |
4210 | NEIGHBOR_STR | |
4211 | NEIGHBOR_ADDR_STR2 | |
4212 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4213 | "Apply to all AS numbers\n" |
5000f21c | 4214 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4215 | { |
d62a17ae | 4216 | int idx_peer = 2; |
4217 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4218 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4219 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4220 | } |
5000f21c | 4221 | |
d62a17ae | 4222 | ALIAS_HIDDEN( |
4223 | no_neighbor_remove_private_as_all_replace_as, | |
4224 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4225 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4226 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4227 | "Remove private ASNs in outbound updates\n" | |
4228 | "Apply to all AS numbers\n" | |
4229 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4230 | |
5000f21c | 4231 | |
718e3744 | 4232 | /* neighbor send-community. */ |
4233 | DEFUN (neighbor_send_community, | |
4234 | neighbor_send_community_cmd, | |
9ccf14f7 | 4235 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4236 | NEIGHBOR_STR |
4237 | NEIGHBOR_ADDR_STR2 | |
4238 | "Send Community attribute to this neighbor\n") | |
4239 | { | |
d62a17ae | 4240 | int idx_peer = 1; |
27c05d4d | 4241 | |
d62a17ae | 4242 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4243 | bgp_node_safi(vty), | |
4244 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4245 | } |
4246 | ||
d62a17ae | 4247 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4248 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4249 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4250 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4251 | |
718e3744 | 4252 | DEFUN (no_neighbor_send_community, |
4253 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4254 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4255 | NO_STR |
4256 | NEIGHBOR_STR | |
4257 | NEIGHBOR_ADDR_STR2 | |
4258 | "Send Community attribute to this neighbor\n") | |
4259 | { | |
d62a17ae | 4260 | int idx_peer = 2; |
27c05d4d | 4261 | |
d62a17ae | 4262 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4263 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4264 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4265 | } |
6b0655a2 | 4266 | |
d62a17ae | 4267 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4268 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4269 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4270 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4271 | |
718e3744 | 4272 | /* neighbor send-community extended. */ |
4273 | DEFUN (neighbor_send_community_type, | |
4274 | neighbor_send_community_type_cmd, | |
57d187bc | 4275 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4276 | NEIGHBOR_STR |
4277 | NEIGHBOR_ADDR_STR2 | |
4278 | "Send Community attribute to this neighbor\n" | |
4279 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4280 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4281 | "Send Extended Community attributes\n" |
57d187bc JS |
4282 | "Send Standard Community attributes\n" |
4283 | "Send Large Community attributes\n") | |
718e3744 | 4284 | { |
27c05d4d | 4285 | int idx_peer = 1; |
d7c0a89a | 4286 | uint32_t flag = 0; |
27c05d4d | 4287 | const char *type = argv[argc - 1]->text; |
d62a17ae | 4288 | |
27c05d4d | 4289 | if (strmatch(type, "standard")) { |
d62a17ae | 4290 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
27c05d4d | 4291 | } else if (strmatch(type, "extended")) { |
d62a17ae | 4292 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); |
27c05d4d | 4293 | } else if (strmatch(type, "large")) { |
d62a17ae | 4294 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); |
27c05d4d | 4295 | } else if (strmatch(type, "both")) { |
d62a17ae | 4296 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4297 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d | 4298 | } else { /* if (strmatch(type, "all")) */ |
d62a17ae | 4299 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4300 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4301 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4302 | } | |
4303 | ||
27c05d4d | 4304 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
d62a17ae | 4305 | bgp_node_safi(vty), flag); |
4306 | } | |
4307 | ||
4308 | ALIAS_HIDDEN( | |
4309 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4310 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4311 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4312 | "Send Community attribute to this neighbor\n" | |
4313 | "Send Standard and Extended Community attributes\n" | |
4314 | "Send Standard, Large and Extended Community attributes\n" | |
4315 | "Send Extended Community attributes\n" | |
4316 | "Send Standard Community attributes\n" | |
4317 | "Send Large Community attributes\n") | |
596c17ba | 4318 | |
718e3744 | 4319 | DEFUN (no_neighbor_send_community_type, |
4320 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4321 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4322 | NO_STR |
4323 | NEIGHBOR_STR | |
4324 | NEIGHBOR_ADDR_STR2 | |
4325 | "Send Community attribute to this neighbor\n" | |
4326 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4327 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4328 | "Send Extended Community attributes\n" |
57d187bc JS |
4329 | "Send Standard Community attributes\n" |
4330 | "Send Large Community attributes\n") | |
718e3744 | 4331 | { |
d62a17ae | 4332 | int idx_peer = 2; |
27c05d4d | 4333 | uint32_t flag = 0; |
d62a17ae | 4334 | const char *type = argv[argc - 1]->text; |
4335 | ||
27c05d4d PM |
4336 | if (strmatch(type, "standard")) { |
4337 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4338 | } else if (strmatch(type, "extended")) { | |
4339 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4340 | } else if (strmatch(type, "large")) { | |
4341 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4342 | } else if (strmatch(type, "both")) { | |
4343 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4344 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4345 | } else { /* if (strmatch(type, "all")) */ | |
4346 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4347 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4348 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4349 | } | |
4350 | ||
4351 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4352 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4353 | flag); | |
d62a17ae | 4354 | } |
4355 | ||
4356 | ALIAS_HIDDEN( | |
4357 | no_neighbor_send_community_type, | |
4358 | no_neighbor_send_community_type_hidden_cmd, | |
4359 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4360 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4361 | "Send Community attribute to this neighbor\n" | |
4362 | "Send Standard and Extended Community attributes\n" | |
4363 | "Send Standard, Large and Extended Community attributes\n" | |
4364 | "Send Extended Community attributes\n" | |
4365 | "Send Standard Community attributes\n" | |
4366 | "Send Large Community attributes\n") | |
596c17ba | 4367 | |
718e3744 | 4368 | /* neighbor soft-reconfig. */ |
4369 | DEFUN (neighbor_soft_reconfiguration, | |
4370 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4371 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4372 | NEIGHBOR_STR |
4373 | NEIGHBOR_ADDR_STR2 | |
4374 | "Per neighbor soft reconfiguration\n" | |
4375 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4376 | { | |
d62a17ae | 4377 | int idx_peer = 1; |
4378 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4379 | bgp_node_safi(vty), | |
4380 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4381 | } |
4382 | ||
d62a17ae | 4383 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4384 | neighbor_soft_reconfiguration_hidden_cmd, | |
4385 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4386 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4387 | "Per neighbor soft reconfiguration\n" | |
4388 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4389 | |
718e3744 | 4390 | DEFUN (no_neighbor_soft_reconfiguration, |
4391 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4392 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4393 | NO_STR |
4394 | NEIGHBOR_STR | |
4395 | NEIGHBOR_ADDR_STR2 | |
4396 | "Per neighbor soft reconfiguration\n" | |
4397 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4398 | { | |
d62a17ae | 4399 | int idx_peer = 2; |
4400 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4401 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4402 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4403 | } |
6b0655a2 | 4404 | |
d62a17ae | 4405 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
4406 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4407 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4408 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4409 | "Per neighbor soft reconfiguration\n" | |
4410 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4411 | |
718e3744 | 4412 | DEFUN (neighbor_route_reflector_client, |
4413 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4414 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4415 | NEIGHBOR_STR |
4416 | NEIGHBOR_ADDR_STR2 | |
4417 | "Configure a neighbor as Route Reflector client\n") | |
4418 | { | |
d62a17ae | 4419 | int idx_peer = 1; |
4420 | struct peer *peer; | |
718e3744 | 4421 | |
4422 | ||
d62a17ae | 4423 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4424 | if (!peer) | |
4425 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4426 | |
d62a17ae | 4427 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4428 | bgp_node_safi(vty), | |
4429 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4430 | } |
4431 | ||
d62a17ae | 4432 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
4433 | neighbor_route_reflector_client_hidden_cmd, | |
4434 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4435 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4436 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4437 | |
718e3744 | 4438 | DEFUN (no_neighbor_route_reflector_client, |
4439 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4440 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4441 | NO_STR |
4442 | NEIGHBOR_STR | |
4443 | NEIGHBOR_ADDR_STR2 | |
4444 | "Configure a neighbor as Route Reflector client\n") | |
4445 | { | |
d62a17ae | 4446 | int idx_peer = 2; |
4447 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4448 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4449 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4450 | } |
6b0655a2 | 4451 | |
d62a17ae | 4452 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
4453 | no_neighbor_route_reflector_client_hidden_cmd, | |
4454 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4455 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4456 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4457 | |
718e3744 | 4458 | /* neighbor route-server-client. */ |
4459 | DEFUN (neighbor_route_server_client, | |
4460 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4461 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4462 | NEIGHBOR_STR |
4463 | NEIGHBOR_ADDR_STR2 | |
4464 | "Configure a neighbor as Route Server client\n") | |
4465 | { | |
d62a17ae | 4466 | int idx_peer = 1; |
4467 | struct peer *peer; | |
2a3d5731 | 4468 | |
d62a17ae | 4469 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4470 | if (!peer) | |
4471 | return CMD_WARNING_CONFIG_FAILED; | |
4472 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4473 | bgp_node_safi(vty), | |
4474 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4475 | } |
4476 | ||
d62a17ae | 4477 | ALIAS_HIDDEN(neighbor_route_server_client, |
4478 | neighbor_route_server_client_hidden_cmd, | |
4479 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4480 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4481 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4482 | |
718e3744 | 4483 | DEFUN (no_neighbor_route_server_client, |
4484 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4485 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4486 | NO_STR |
4487 | NEIGHBOR_STR | |
4488 | NEIGHBOR_ADDR_STR2 | |
4489 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4490 | { |
d62a17ae | 4491 | int idx_peer = 2; |
4492 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4493 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4494 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4495 | } |
6b0655a2 | 4496 | |
d62a17ae | 4497 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
4498 | no_neighbor_route_server_client_hidden_cmd, | |
4499 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4500 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4501 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4502 | |
fee0f4c6 | 4503 | DEFUN (neighbor_nexthop_local_unchanged, |
4504 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4505 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4506 | NEIGHBOR_STR |
4507 | NEIGHBOR_ADDR_STR2 | |
4508 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4509 | "Leave link-local nexthop unchanged for this peer\n") | |
4510 | { | |
d62a17ae | 4511 | int idx_peer = 1; |
4512 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4513 | bgp_node_safi(vty), | |
4514 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 4515 | } |
6b0655a2 | 4516 | |
fee0f4c6 | 4517 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4518 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4519 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4520 | NO_STR |
4521 | NEIGHBOR_STR | |
4522 | NEIGHBOR_ADDR_STR2 | |
4523 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4524 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4525 | { |
d62a17ae | 4526 | int idx_peer = 2; |
4527 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4528 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4529 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 4530 | } |
6b0655a2 | 4531 | |
718e3744 | 4532 | DEFUN (neighbor_attr_unchanged, |
4533 | neighbor_attr_unchanged_cmd, | |
a8206004 | 4534 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 4535 | NEIGHBOR_STR |
4536 | NEIGHBOR_ADDR_STR2 | |
4537 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4538 | "As-path attribute\n" | |
4539 | "Nexthop attribute\n" | |
a8206004 | 4540 | "Med attribute\n") |
718e3744 | 4541 | { |
d62a17ae | 4542 | int idx = 0; |
8eeb0335 DW |
4543 | char *peer_str = argv[1]->arg; |
4544 | struct peer *peer; | |
d7c0a89a | 4545 | uint16_t flags = 0; |
8eeb0335 DW |
4546 | afi_t afi = bgp_node_afi(vty); |
4547 | safi_t safi = bgp_node_safi(vty); | |
4548 | ||
4549 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4550 | if (!peer) | |
4551 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4552 | |
4553 | if (argv_find(argv, argc, "as-path", &idx)) | |
4554 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4555 | idx = 0; | |
4556 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4557 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4558 | idx = 0; | |
4559 | if (argv_find(argv, argc, "med", &idx)) | |
4560 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4561 | ||
8eeb0335 DW |
4562 | /* no flags means all of them! */ |
4563 | if (!flags) { | |
d62a17ae | 4564 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
4565 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4566 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 4567 | } else { |
a4d82a8a PZ |
4568 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
4569 | && peer_af_flag_check(peer, afi, safi, | |
4570 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
4571 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4572 | PEER_FLAG_AS_PATH_UNCHANGED); | |
4573 | } | |
4574 | ||
a4d82a8a PZ |
4575 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
4576 | && peer_af_flag_check(peer, afi, safi, | |
4577 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
4578 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4579 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
4580 | } | |
4581 | ||
a4d82a8a PZ |
4582 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
4583 | && peer_af_flag_check(peer, afi, safi, | |
4584 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
4585 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4586 | PEER_FLAG_MED_UNCHANGED); | |
4587 | } | |
d62a17ae | 4588 | } |
4589 | ||
8eeb0335 | 4590 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 4591 | } |
4592 | ||
4593 | ALIAS_HIDDEN( | |
4594 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
4595 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4596 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4597 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4598 | "As-path attribute\n" | |
4599 | "Nexthop attribute\n" | |
4600 | "Med attribute\n") | |
596c17ba | 4601 | |
718e3744 | 4602 | DEFUN (no_neighbor_attr_unchanged, |
4603 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 4604 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 4605 | NO_STR |
718e3744 | 4606 | NEIGHBOR_STR |
4607 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4608 | "BGP attribute is propagated unchanged to this neighbor\n" |
4609 | "As-path attribute\n" | |
40e718b5 | 4610 | "Nexthop attribute\n" |
a8206004 | 4611 | "Med attribute\n") |
718e3744 | 4612 | { |
d62a17ae | 4613 | int idx = 0; |
4614 | char *peer = argv[2]->arg; | |
d7c0a89a | 4615 | uint16_t flags = 0; |
d62a17ae | 4616 | |
4617 | if (argv_find(argv, argc, "as-path", &idx)) | |
4618 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4619 | idx = 0; | |
4620 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4621 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4622 | idx = 0; | |
4623 | if (argv_find(argv, argc, "med", &idx)) | |
4624 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4625 | ||
4626 | if (!flags) // no flags means all of them! | |
4627 | { | |
4628 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4629 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4630 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4631 | } | |
4632 | ||
4633 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
4634 | bgp_node_safi(vty), flags); | |
4635 | } | |
4636 | ||
4637 | ALIAS_HIDDEN( | |
4638 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
4639 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4640 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4641 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4642 | "As-path attribute\n" | |
4643 | "Nexthop attribute\n" | |
4644 | "Med attribute\n") | |
718e3744 | 4645 | |
718e3744 | 4646 | /* EBGP multihop configuration. */ |
d62a17ae | 4647 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
4648 | const char *ttl_str) | |
718e3744 | 4649 | { |
d62a17ae | 4650 | struct peer *peer; |
4651 | unsigned int ttl; | |
718e3744 | 4652 | |
d62a17ae | 4653 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4654 | if (!peer) | |
4655 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4656 | |
d62a17ae | 4657 | if (peer->conf_if) |
4658 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 4659 | |
d62a17ae | 4660 | if (!ttl_str) |
4661 | ttl = MAXTTL; | |
4662 | else | |
4663 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 4664 | |
d62a17ae | 4665 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 4666 | } |
4667 | ||
d62a17ae | 4668 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4669 | { |
d62a17ae | 4670 | struct peer *peer; |
718e3744 | 4671 | |
d62a17ae | 4672 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4673 | if (!peer) | |
4674 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4675 | |
d62a17ae | 4676 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 4677 | } |
4678 | ||
4679 | /* neighbor ebgp-multihop. */ | |
4680 | DEFUN (neighbor_ebgp_multihop, | |
4681 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4682 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4683 | NEIGHBOR_STR |
4684 | NEIGHBOR_ADDR_STR2 | |
4685 | "Allow EBGP neighbors not on directly connected networks\n") | |
4686 | { | |
d62a17ae | 4687 | int idx_peer = 1; |
4688 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4689 | } |
4690 | ||
4691 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4692 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4693 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4694 | NEIGHBOR_STR |
4695 | NEIGHBOR_ADDR_STR2 | |
4696 | "Allow EBGP neighbors not on directly connected networks\n" | |
4697 | "maximum hop count\n") | |
4698 | { | |
d62a17ae | 4699 | int idx_peer = 1; |
4700 | int idx_number = 3; | |
4701 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
4702 | argv[idx_number]->arg); | |
718e3744 | 4703 | } |
4704 | ||
4705 | DEFUN (no_neighbor_ebgp_multihop, | |
4706 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4707 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4708 | NO_STR |
4709 | NEIGHBOR_STR | |
4710 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4711 | "Allow EBGP neighbors not on directly connected networks\n" |
4712 | "maximum hop count\n") | |
718e3744 | 4713 | { |
d62a17ae | 4714 | int idx_peer = 2; |
4715 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4716 | } |
4717 | ||
6b0655a2 | 4718 | |
6ffd2079 | 4719 | /* disable-connected-check */ |
4720 | DEFUN (neighbor_disable_connected_check, | |
4721 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 4722 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4723 | NEIGHBOR_STR |
7ebe625c | 4724 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4725 | "one-hop away EBGP peer using loopback address\n" |
4726 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4727 | { |
d62a17ae | 4728 | int idx_peer = 1; |
4729 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4730 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4731 | } |
4732 | ||
4733 | DEFUN (no_neighbor_disable_connected_check, | |
4734 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 4735 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4736 | NO_STR |
4737 | NEIGHBOR_STR | |
7ebe625c | 4738 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4739 | "one-hop away EBGP peer using loopback address\n" |
4740 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4741 | { |
d62a17ae | 4742 | int idx_peer = 2; |
4743 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4744 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4745 | } |
4746 | ||
47cbc09b PM |
4747 | |
4748 | /* enforce-first-as */ | |
4749 | DEFUN (neighbor_enforce_first_as, | |
4750 | neighbor_enforce_first_as_cmd, | |
4751 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4752 | NEIGHBOR_STR | |
4753 | NEIGHBOR_ADDR_STR2 | |
4754 | "Enforce the first AS for EBGP routes\n") | |
4755 | { | |
4756 | int idx_peer = 1; | |
4757 | ||
4758 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4759 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4760 | } | |
4761 | ||
4762 | DEFUN (no_neighbor_enforce_first_as, | |
4763 | no_neighbor_enforce_first_as_cmd, | |
4764 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4765 | NO_STR | |
4766 | NEIGHBOR_STR | |
4767 | NEIGHBOR_ADDR_STR2 | |
4768 | "Enforce the first AS for EBGP routes\n") | |
4769 | { | |
4770 | int idx_peer = 2; | |
4771 | ||
4772 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4773 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4774 | } | |
4775 | ||
4776 | ||
718e3744 | 4777 | DEFUN (neighbor_description, |
4778 | neighbor_description_cmd, | |
e961923c | 4779 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4780 | NEIGHBOR_STR |
4781 | NEIGHBOR_ADDR_STR2 | |
4782 | "Neighbor specific description\n" | |
4783 | "Up to 80 characters describing this neighbor\n") | |
4784 | { | |
d62a17ae | 4785 | int idx_peer = 1; |
4786 | int idx_line = 3; | |
4787 | struct peer *peer; | |
4788 | char *str; | |
718e3744 | 4789 | |
d62a17ae | 4790 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4791 | if (!peer) | |
4792 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4793 | |
d62a17ae | 4794 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4795 | |
d62a17ae | 4796 | peer_description_set(peer, str); |
718e3744 | 4797 | |
d62a17ae | 4798 | XFREE(MTYPE_TMP, str); |
718e3744 | 4799 | |
d62a17ae | 4800 | return CMD_SUCCESS; |
718e3744 | 4801 | } |
4802 | ||
4803 | DEFUN (no_neighbor_description, | |
4804 | no_neighbor_description_cmd, | |
a14810f4 | 4805 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 4806 | NO_STR |
4807 | NEIGHBOR_STR | |
4808 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 4809 | "Neighbor specific description\n") |
718e3744 | 4810 | { |
d62a17ae | 4811 | int idx_peer = 2; |
4812 | struct peer *peer; | |
718e3744 | 4813 | |
d62a17ae | 4814 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4815 | if (!peer) | |
4816 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4817 | |
d62a17ae | 4818 | peer_description_unset(peer); |
718e3744 | 4819 | |
d62a17ae | 4820 | return CMD_SUCCESS; |
718e3744 | 4821 | } |
4822 | ||
a14810f4 PM |
4823 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
4824 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
4825 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4826 | "Neighbor specific description\n" | |
4827 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 4828 | |
718e3744 | 4829 | /* Neighbor update-source. */ |
d62a17ae | 4830 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
4831 | const char *source_str) | |
4832 | { | |
4833 | struct peer *peer; | |
4834 | struct prefix p; | |
a14810f4 | 4835 | union sockunion su; |
d62a17ae | 4836 | |
4837 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4838 | if (!peer) | |
4839 | return CMD_WARNING_CONFIG_FAILED; | |
4840 | ||
4841 | if (peer->conf_if) | |
4842 | return CMD_WARNING; | |
4843 | ||
4844 | if (source_str) { | |
a14810f4 | 4845 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 4846 | peer_update_source_addr_set(peer, &su); |
4847 | else { | |
4848 | if (str2prefix(source_str, &p)) { | |
4849 | vty_out(vty, | |
4850 | "%% Invalid update-source, remove prefix length \n"); | |
4851 | return CMD_WARNING_CONFIG_FAILED; | |
4852 | } else | |
4853 | peer_update_source_if_set(peer, source_str); | |
4854 | } | |
4855 | } else | |
4856 | peer_update_source_unset(peer); | |
4857 | ||
4858 | return CMD_SUCCESS; | |
4859 | } | |
4860 | ||
4861 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
4862 | "IPv4 address\n" \ | |
4863 | "IPv6 address\n" \ | |
4864 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4865 | |
718e3744 | 4866 | DEFUN (neighbor_update_source, |
4867 | neighbor_update_source_cmd, | |
9ccf14f7 | 4868 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4869 | NEIGHBOR_STR |
4870 | NEIGHBOR_ADDR_STR2 | |
4871 | "Source of routing updates\n" | |
369688c0 | 4872 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4873 | { |
d62a17ae | 4874 | int idx_peer = 1; |
4875 | int idx_peer_2 = 3; | |
4876 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
4877 | argv[idx_peer_2]->arg); | |
718e3744 | 4878 | } |
4879 | ||
4880 | DEFUN (no_neighbor_update_source, | |
4881 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4882 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4883 | NO_STR |
4884 | NEIGHBOR_STR | |
4885 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4886 | "Source of routing updates\n" |
4887 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4888 | { |
d62a17ae | 4889 | int idx_peer = 2; |
4890 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4891 | } |
6b0655a2 | 4892 | |
d62a17ae | 4893 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
4894 | afi_t afi, safi_t safi, | |
4895 | const char *rmap, int set) | |
718e3744 | 4896 | { |
d62a17ae | 4897 | int ret; |
4898 | struct peer *peer; | |
1de27621 | 4899 | struct route_map *route_map; |
718e3744 | 4900 | |
d62a17ae | 4901 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4902 | if (!peer) | |
4903 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4904 | |
1de27621 DA |
4905 | if (set) { |
4906 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
4907 | ret = peer_default_originate_set(peer, afi, safi, | |
4908 | rmap, route_map); | |
4909 | } else | |
d62a17ae | 4910 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 4911 | |
d62a17ae | 4912 | return bgp_vty_return(vty, ret); |
718e3744 | 4913 | } |
4914 | ||
4915 | /* neighbor default-originate. */ | |
4916 | DEFUN (neighbor_default_originate, | |
4917 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4918 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4919 | NEIGHBOR_STR |
4920 | NEIGHBOR_ADDR_STR2 | |
4921 | "Originate default route to this neighbor\n") | |
4922 | { | |
d62a17ae | 4923 | int idx_peer = 1; |
4924 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4925 | bgp_node_afi(vty), | |
4926 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 4927 | } |
4928 | ||
d62a17ae | 4929 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
4930 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
4931 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4932 | "Originate default route to this neighbor\n") | |
596c17ba | 4933 | |
718e3744 | 4934 | DEFUN (neighbor_default_originate_rmap, |
4935 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4936 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4937 | NEIGHBOR_STR |
4938 | NEIGHBOR_ADDR_STR2 | |
4939 | "Originate default route to this neighbor\n" | |
4940 | "Route-map to specify criteria to originate default\n" | |
4941 | "route-map name\n") | |
4942 | { | |
d62a17ae | 4943 | int idx_peer = 1; |
4944 | int idx_word = 4; | |
4945 | return peer_default_originate_set_vty( | |
4946 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4947 | argv[idx_word]->arg, 1); | |
718e3744 | 4948 | } |
4949 | ||
d62a17ae | 4950 | ALIAS_HIDDEN( |
4951 | neighbor_default_originate_rmap, | |
4952 | neighbor_default_originate_rmap_hidden_cmd, | |
4953 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
4954 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4955 | "Originate default route to this neighbor\n" | |
4956 | "Route-map to specify criteria to originate default\n" | |
4957 | "route-map name\n") | |
596c17ba | 4958 | |
718e3744 | 4959 | DEFUN (no_neighbor_default_originate, |
4960 | no_neighbor_default_originate_cmd, | |
a636c635 | 4961 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4962 | NO_STR |
4963 | NEIGHBOR_STR | |
4964 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4965 | "Originate default route to this neighbor\n" |
4966 | "Route-map to specify criteria to originate default\n" | |
4967 | "route-map name\n") | |
718e3744 | 4968 | { |
d62a17ae | 4969 | int idx_peer = 2; |
4970 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4971 | bgp_node_afi(vty), | |
4972 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 4973 | } |
4974 | ||
d62a17ae | 4975 | ALIAS_HIDDEN( |
4976 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
4977 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
4978 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4979 | "Originate default route to this neighbor\n" | |
4980 | "Route-map to specify criteria to originate default\n" | |
4981 | "route-map name\n") | |
596c17ba | 4982 | |
6b0655a2 | 4983 | |
718e3744 | 4984 | /* Set neighbor's BGP port. */ |
d62a17ae | 4985 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
4986 | const char *port_str) | |
4987 | { | |
4988 | struct peer *peer; | |
d7c0a89a | 4989 | uint16_t port; |
d62a17ae | 4990 | struct servent *sp; |
4991 | ||
4992 | peer = peer_lookup_vty(vty, ip_str); | |
4993 | if (!peer) | |
4994 | return CMD_WARNING_CONFIG_FAILED; | |
4995 | ||
4996 | if (!port_str) { | |
4997 | sp = getservbyname("bgp", "tcp"); | |
4998 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
4999 | } else { | |
5000 | port = strtoul(port_str, NULL, 10); | |
5001 | } | |
718e3744 | 5002 | |
d62a17ae | 5003 | peer_port_set(peer, port); |
718e3744 | 5004 | |
d62a17ae | 5005 | return CMD_SUCCESS; |
718e3744 | 5006 | } |
5007 | ||
f418446b | 5008 | /* Set specified peer's BGP port. */ |
718e3744 | 5009 | DEFUN (neighbor_port, |
5010 | neighbor_port_cmd, | |
9ccf14f7 | 5011 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 5012 | NEIGHBOR_STR |
5013 | NEIGHBOR_ADDR_STR | |
5014 | "Neighbor's BGP port\n" | |
5015 | "TCP port number\n") | |
5016 | { | |
d62a17ae | 5017 | int idx_ip = 1; |
5018 | int idx_number = 3; | |
5019 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
5020 | argv[idx_number]->arg); | |
718e3744 | 5021 | } |
5022 | ||
5023 | DEFUN (no_neighbor_port, | |
5024 | no_neighbor_port_cmd, | |
9ccf14f7 | 5025 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 5026 | NO_STR |
5027 | NEIGHBOR_STR | |
5028 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
5029 | "Neighbor's BGP port\n" |
5030 | "TCP port number\n") | |
718e3744 | 5031 | { |
d62a17ae | 5032 | int idx_ip = 2; |
5033 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 5034 | } |
5035 | ||
6b0655a2 | 5036 | |
718e3744 | 5037 | /* neighbor weight. */ |
d62a17ae | 5038 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5039 | safi_t safi, const char *weight_str) | |
718e3744 | 5040 | { |
d62a17ae | 5041 | int ret; |
5042 | struct peer *peer; | |
5043 | unsigned long weight; | |
718e3744 | 5044 | |
d62a17ae | 5045 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5046 | if (!peer) | |
5047 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5048 | |
d62a17ae | 5049 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 5050 | |
d62a17ae | 5051 | ret = peer_weight_set(peer, afi, safi, weight); |
5052 | return bgp_vty_return(vty, ret); | |
718e3744 | 5053 | } |
5054 | ||
d62a17ae | 5055 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5056 | safi_t safi) | |
718e3744 | 5057 | { |
d62a17ae | 5058 | int ret; |
5059 | struct peer *peer; | |
718e3744 | 5060 | |
d62a17ae | 5061 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5062 | if (!peer) | |
5063 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5064 | |
d62a17ae | 5065 | ret = peer_weight_unset(peer, afi, safi); |
5066 | return bgp_vty_return(vty, ret); | |
718e3744 | 5067 | } |
5068 | ||
5069 | DEFUN (neighbor_weight, | |
5070 | neighbor_weight_cmd, | |
9ccf14f7 | 5071 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 5072 | NEIGHBOR_STR |
5073 | NEIGHBOR_ADDR_STR2 | |
5074 | "Set default weight for routes from this neighbor\n" | |
5075 | "default weight\n") | |
5076 | { | |
d62a17ae | 5077 | int idx_peer = 1; |
5078 | int idx_number = 3; | |
5079 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5080 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 5081 | } |
5082 | ||
d62a17ae | 5083 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
5084 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
5085 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5086 | "Set default weight for routes from this neighbor\n" | |
5087 | "default weight\n") | |
596c17ba | 5088 | |
718e3744 | 5089 | DEFUN (no_neighbor_weight, |
5090 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5091 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5092 | NO_STR |
5093 | NEIGHBOR_STR | |
5094 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5095 | "Set default weight for routes from this neighbor\n" |
5096 | "default weight\n") | |
718e3744 | 5097 | { |
d62a17ae | 5098 | int idx_peer = 2; |
5099 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
5100 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 5101 | } |
5102 | ||
d62a17ae | 5103 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
5104 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5105 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5106 | "Set default weight for routes from this neighbor\n" | |
5107 | "default weight\n") | |
596c17ba | 5108 | |
6b0655a2 | 5109 | |
718e3744 | 5110 | /* Override capability negotiation. */ |
5111 | DEFUN (neighbor_override_capability, | |
5112 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5113 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5114 | NEIGHBOR_STR |
5115 | NEIGHBOR_ADDR_STR2 | |
5116 | "Override capability negotiation result\n") | |
5117 | { | |
d62a17ae | 5118 | int idx_peer = 1; |
5119 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5120 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5121 | } |
5122 | ||
5123 | DEFUN (no_neighbor_override_capability, | |
5124 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5125 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5126 | NO_STR |
5127 | NEIGHBOR_STR | |
5128 | NEIGHBOR_ADDR_STR2 | |
5129 | "Override capability negotiation result\n") | |
5130 | { | |
d62a17ae | 5131 | int idx_peer = 2; |
5132 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5133 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5134 | } |
6b0655a2 | 5135 | |
718e3744 | 5136 | DEFUN (neighbor_strict_capability, |
5137 | neighbor_strict_capability_cmd, | |
9fb964de | 5138 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5139 | NEIGHBOR_STR |
9fb964de | 5140 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5141 | "Strict capability negotiation match\n") |
5142 | { | |
9fb964de PM |
5143 | int idx_peer = 1; |
5144 | ||
5145 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5146 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5147 | } |
5148 | ||
5149 | DEFUN (no_neighbor_strict_capability, | |
5150 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5151 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5152 | NO_STR |
5153 | NEIGHBOR_STR | |
9fb964de | 5154 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5155 | "Strict capability negotiation match\n") |
5156 | { | |
9fb964de PM |
5157 | int idx_peer = 2; |
5158 | ||
5159 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5160 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5161 | } |
6b0655a2 | 5162 | |
d62a17ae | 5163 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5164 | const char *keep_str, const char *hold_str) | |
718e3744 | 5165 | { |
d62a17ae | 5166 | int ret; |
5167 | struct peer *peer; | |
d7c0a89a QY |
5168 | uint32_t keepalive; |
5169 | uint32_t holdtime; | |
718e3744 | 5170 | |
d62a17ae | 5171 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5172 | if (!peer) | |
5173 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5174 | |
d62a17ae | 5175 | keepalive = strtoul(keep_str, NULL, 10); |
5176 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5177 | |
d62a17ae | 5178 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5179 | |
d62a17ae | 5180 | return bgp_vty_return(vty, ret); |
718e3744 | 5181 | } |
6b0655a2 | 5182 | |
d62a17ae | 5183 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5184 | { |
d62a17ae | 5185 | int ret; |
5186 | struct peer *peer; | |
718e3744 | 5187 | |
d62a17ae | 5188 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5189 | if (!peer) | |
5190 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5191 | |
d62a17ae | 5192 | ret = peer_timers_unset(peer); |
718e3744 | 5193 | |
d62a17ae | 5194 | return bgp_vty_return(vty, ret); |
718e3744 | 5195 | } |
5196 | ||
5197 | DEFUN (neighbor_timers, | |
5198 | neighbor_timers_cmd, | |
9ccf14f7 | 5199 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5200 | NEIGHBOR_STR |
5201 | NEIGHBOR_ADDR_STR2 | |
5202 | "BGP per neighbor timers\n" | |
5203 | "Keepalive interval\n" | |
5204 | "Holdtime\n") | |
5205 | { | |
d62a17ae | 5206 | int idx_peer = 1; |
5207 | int idx_number = 3; | |
5208 | int idx_number_2 = 4; | |
5209 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5210 | argv[idx_number]->arg, | |
5211 | argv[idx_number_2]->arg); | |
718e3744 | 5212 | } |
5213 | ||
5214 | DEFUN (no_neighbor_timers, | |
5215 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5216 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5217 | NO_STR |
5218 | NEIGHBOR_STR | |
5219 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5220 | "BGP per neighbor timers\n" |
5221 | "Keepalive interval\n" | |
5222 | "Holdtime\n") | |
718e3744 | 5223 | { |
d62a17ae | 5224 | int idx_peer = 2; |
5225 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5226 | } |
6b0655a2 | 5227 | |
813d4307 | 5228 | |
d62a17ae | 5229 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
5230 | const char *time_str) | |
718e3744 | 5231 | { |
d62a17ae | 5232 | int ret; |
5233 | struct peer *peer; | |
d7c0a89a | 5234 | uint32_t connect; |
718e3744 | 5235 | |
d62a17ae | 5236 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5237 | if (!peer) | |
5238 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5239 | |
d62a17ae | 5240 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5241 | |
d62a17ae | 5242 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5243 | |
d62a17ae | 5244 | return bgp_vty_return(vty, ret); |
718e3744 | 5245 | } |
5246 | ||
d62a17ae | 5247 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5248 | { |
d62a17ae | 5249 | int ret; |
5250 | struct peer *peer; | |
718e3744 | 5251 | |
d62a17ae | 5252 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5253 | if (!peer) | |
5254 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5255 | |
d62a17ae | 5256 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5257 | |
d62a17ae | 5258 | return bgp_vty_return(vty, ret); |
718e3744 | 5259 | } |
5260 | ||
5261 | DEFUN (neighbor_timers_connect, | |
5262 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5263 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5264 | NEIGHBOR_STR |
966f821c | 5265 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5266 | "BGP per neighbor timers\n" |
5267 | "BGP connect timer\n" | |
5268 | "Connect timer\n") | |
5269 | { | |
d62a17ae | 5270 | int idx_peer = 1; |
5271 | int idx_number = 4; | |
5272 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5273 | argv[idx_number]->arg); | |
718e3744 | 5274 | } |
5275 | ||
5276 | DEFUN (no_neighbor_timers_connect, | |
5277 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5278 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5279 | NO_STR |
5280 | NEIGHBOR_STR | |
966f821c | 5281 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5282 | "BGP per neighbor timers\n" |
8334fd5a DW |
5283 | "BGP connect timer\n" |
5284 | "Connect timer\n") | |
718e3744 | 5285 | { |
d62a17ae | 5286 | int idx_peer = 2; |
5287 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5288 | } |
5289 | ||
6b0655a2 | 5290 | |
d62a17ae | 5291 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5292 | const char *time_str, int set) | |
718e3744 | 5293 | { |
d62a17ae | 5294 | int ret; |
5295 | struct peer *peer; | |
d7c0a89a | 5296 | uint32_t routeadv = 0; |
718e3744 | 5297 | |
d62a17ae | 5298 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5299 | if (!peer) | |
5300 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5301 | |
d62a17ae | 5302 | if (time_str) |
5303 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5304 | |
d62a17ae | 5305 | if (set) |
5306 | ret = peer_advertise_interval_set(peer, routeadv); | |
5307 | else | |
5308 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5309 | |
d62a17ae | 5310 | return bgp_vty_return(vty, ret); |
718e3744 | 5311 | } |
5312 | ||
5313 | DEFUN (neighbor_advertise_interval, | |
5314 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5315 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5316 | NEIGHBOR_STR |
966f821c | 5317 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5318 | "Minimum interval between sending BGP routing updates\n" |
5319 | "time in seconds\n") | |
5320 | { | |
d62a17ae | 5321 | int idx_peer = 1; |
5322 | int idx_number = 3; | |
5323 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5324 | argv[idx_number]->arg, 1); | |
718e3744 | 5325 | } |
5326 | ||
5327 | DEFUN (no_neighbor_advertise_interval, | |
5328 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5329 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5330 | NO_STR |
5331 | NEIGHBOR_STR | |
966f821c | 5332 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5333 | "Minimum interval between sending BGP routing updates\n" |
5334 | "time in seconds\n") | |
718e3744 | 5335 | { |
d62a17ae | 5336 | int idx_peer = 2; |
5337 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5338 | } |
5339 | ||
6b0655a2 | 5340 | |
518f0eb1 DS |
5341 | /* Time to wait before processing route-map updates */ |
5342 | DEFUN (bgp_set_route_map_delay_timer, | |
5343 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5344 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5345 | SET_STR |
5346 | "BGP route-map delay timer\n" | |
5347 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5348 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5349 | { |
d62a17ae | 5350 | int idx_number = 3; |
d7c0a89a | 5351 | uint32_t rmap_delay_timer; |
d62a17ae | 5352 | |
5353 | if (argv[idx_number]->arg) { | |
5354 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
5355 | bm->rmap_update_timer = rmap_delay_timer; | |
5356 | ||
5357 | /* if the dynamic update handling is being disabled, and a timer | |
5358 | * is | |
5359 | * running, stop the timer and act as if the timer has already | |
5360 | * fired. | |
5361 | */ | |
5362 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
5363 | BGP_TIMER_OFF(bm->t_rmap_update); | |
5364 | thread_execute(bm->master, bgp_route_map_update_timer, | |
5365 | NULL, 0); | |
5366 | } | |
5367 | return CMD_SUCCESS; | |
5368 | } else { | |
5369 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5370 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5371 | } |
518f0eb1 DS |
5372 | } |
5373 | ||
5374 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5375 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5376 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5377 | NO_STR |
3a2d747c | 5378 | BGP_STR |
518f0eb1 | 5379 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5380 | "Reset to default time to wait for processing route-map changes\n" |
5381 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5382 | { |
518f0eb1 | 5383 | |
d62a17ae | 5384 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 5385 | |
d62a17ae | 5386 | return CMD_SUCCESS; |
518f0eb1 DS |
5387 | } |
5388 | ||
f414725f | 5389 | |
718e3744 | 5390 | /* neighbor interface */ |
d62a17ae | 5391 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
5392 | const char *str) | |
718e3744 | 5393 | { |
d62a17ae | 5394 | struct peer *peer; |
718e3744 | 5395 | |
d62a17ae | 5396 | peer = peer_lookup_vty(vty, ip_str); |
5397 | if (!peer || peer->conf_if) { | |
5398 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
5399 | return CMD_WARNING_CONFIG_FAILED; | |
5400 | } | |
718e3744 | 5401 | |
d62a17ae | 5402 | if (str) |
5403 | peer_interface_set(peer, str); | |
5404 | else | |
5405 | peer_interface_unset(peer); | |
718e3744 | 5406 | |
d62a17ae | 5407 | return CMD_SUCCESS; |
718e3744 | 5408 | } |
5409 | ||
5410 | DEFUN (neighbor_interface, | |
5411 | neighbor_interface_cmd, | |
9ccf14f7 | 5412 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5413 | NEIGHBOR_STR |
5414 | NEIGHBOR_ADDR_STR | |
5415 | "Interface\n" | |
5416 | "Interface name\n") | |
5417 | { | |
d62a17ae | 5418 | int idx_ip = 1; |
5419 | int idx_word = 3; | |
5420 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 5421 | } |
5422 | ||
5423 | DEFUN (no_neighbor_interface, | |
5424 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5425 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5426 | NO_STR |
5427 | NEIGHBOR_STR | |
16cedbb0 | 5428 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5429 | "Interface\n" |
5430 | "Interface name\n") | |
5431 | { | |
d62a17ae | 5432 | int idx_peer = 2; |
5433 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5434 | } |
6b0655a2 | 5435 | |
718e3744 | 5436 | DEFUN (neighbor_distribute_list, |
5437 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5438 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5439 | NEIGHBOR_STR |
5440 | NEIGHBOR_ADDR_STR2 | |
5441 | "Filter updates to/from this neighbor\n" | |
5442 | "IP access-list number\n" | |
5443 | "IP access-list number (expanded range)\n" | |
5444 | "IP Access-list name\n" | |
5445 | "Filter incoming updates\n" | |
5446 | "Filter outgoing updates\n") | |
5447 | { | |
d62a17ae | 5448 | int idx_peer = 1; |
5449 | int idx_acl = 3; | |
5450 | int direct, ret; | |
5451 | struct peer *peer; | |
a8206004 | 5452 | |
d62a17ae | 5453 | const char *pstr = argv[idx_peer]->arg; |
5454 | const char *acl = argv[idx_acl]->arg; | |
5455 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5456 | |
d62a17ae | 5457 | peer = peer_and_group_lookup_vty(vty, pstr); |
5458 | if (!peer) | |
5459 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5460 | |
d62a17ae | 5461 | /* Check filter direction. */ |
5462 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5463 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5464 | direct, acl); | |
a8206004 | 5465 | |
d62a17ae | 5466 | return bgp_vty_return(vty, ret); |
718e3744 | 5467 | } |
5468 | ||
d62a17ae | 5469 | ALIAS_HIDDEN( |
5470 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
5471 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5472 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5473 | "Filter updates to/from this neighbor\n" | |
5474 | "IP access-list number\n" | |
5475 | "IP access-list number (expanded range)\n" | |
5476 | "IP Access-list name\n" | |
5477 | "Filter incoming updates\n" | |
5478 | "Filter outgoing updates\n") | |
596c17ba | 5479 | |
718e3744 | 5480 | DEFUN (no_neighbor_distribute_list, |
5481 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5482 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5483 | NO_STR |
5484 | NEIGHBOR_STR | |
5485 | NEIGHBOR_ADDR_STR2 | |
5486 | "Filter updates to/from this neighbor\n" | |
5487 | "IP access-list number\n" | |
5488 | "IP access-list number (expanded range)\n" | |
5489 | "IP Access-list name\n" | |
5490 | "Filter incoming updates\n" | |
5491 | "Filter outgoing updates\n") | |
5492 | { | |
d62a17ae | 5493 | int idx_peer = 2; |
5494 | int direct, ret; | |
5495 | struct peer *peer; | |
a8206004 | 5496 | |
d62a17ae | 5497 | const char *pstr = argv[idx_peer]->arg; |
5498 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5499 | |
d62a17ae | 5500 | peer = peer_and_group_lookup_vty(vty, pstr); |
5501 | if (!peer) | |
5502 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5503 | |
d62a17ae | 5504 | /* Check filter direction. */ |
5505 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5506 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5507 | direct); | |
a8206004 | 5508 | |
d62a17ae | 5509 | return bgp_vty_return(vty, ret); |
718e3744 | 5510 | } |
6b0655a2 | 5511 | |
d62a17ae | 5512 | ALIAS_HIDDEN( |
5513 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
5514 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5515 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5516 | "Filter updates to/from this neighbor\n" | |
5517 | "IP access-list number\n" | |
5518 | "IP access-list number (expanded range)\n" | |
5519 | "IP Access-list name\n" | |
5520 | "Filter incoming updates\n" | |
5521 | "Filter outgoing updates\n") | |
596c17ba | 5522 | |
718e3744 | 5523 | /* Set prefix list to the peer. */ |
d62a17ae | 5524 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
5525 | afi_t afi, safi_t safi, | |
5526 | const char *name_str, | |
5527 | const char *direct_str) | |
718e3744 | 5528 | { |
d62a17ae | 5529 | int ret; |
d62a17ae | 5530 | int direct = FILTER_IN; |
cf9ac8bf | 5531 | struct peer *peer; |
718e3744 | 5532 | |
d62a17ae | 5533 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5534 | if (!peer) | |
5535 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5536 | |
d62a17ae | 5537 | /* Check filter direction. */ |
5538 | if (strncmp(direct_str, "i", 1) == 0) | |
5539 | direct = FILTER_IN; | |
5540 | else if (strncmp(direct_str, "o", 1) == 0) | |
5541 | direct = FILTER_OUT; | |
718e3744 | 5542 | |
d62a17ae | 5543 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 5544 | |
d62a17ae | 5545 | return bgp_vty_return(vty, ret); |
718e3744 | 5546 | } |
5547 | ||
d62a17ae | 5548 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
5549 | afi_t afi, safi_t safi, | |
5550 | const char *direct_str) | |
718e3744 | 5551 | { |
d62a17ae | 5552 | int ret; |
5553 | struct peer *peer; | |
5554 | int direct = FILTER_IN; | |
718e3744 | 5555 | |
d62a17ae | 5556 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5557 | if (!peer) | |
5558 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 5559 | |
d62a17ae | 5560 | /* Check filter direction. */ |
5561 | if (strncmp(direct_str, "i", 1) == 0) | |
5562 | direct = FILTER_IN; | |
5563 | else if (strncmp(direct_str, "o", 1) == 0) | |
5564 | direct = FILTER_OUT; | |
718e3744 | 5565 | |
d62a17ae | 5566 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 5567 | |
d62a17ae | 5568 | return bgp_vty_return(vty, ret); |
718e3744 | 5569 | } |
5570 | ||
5571 | DEFUN (neighbor_prefix_list, | |
5572 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5573 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5574 | NEIGHBOR_STR |
5575 | NEIGHBOR_ADDR_STR2 | |
5576 | "Filter updates to/from this neighbor\n" | |
5577 | "Name of a prefix list\n" | |
5578 | "Filter incoming updates\n" | |
5579 | "Filter outgoing updates\n") | |
5580 | { | |
d62a17ae | 5581 | int idx_peer = 1; |
5582 | int idx_word = 3; | |
5583 | int idx_in_out = 4; | |
5584 | return peer_prefix_list_set_vty( | |
5585 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5586 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5587 | } |
5588 | ||
d62a17ae | 5589 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
5590 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5591 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5592 | "Filter updates to/from this neighbor\n" | |
5593 | "Name of a prefix list\n" | |
5594 | "Filter incoming updates\n" | |
5595 | "Filter outgoing updates\n") | |
596c17ba | 5596 | |
718e3744 | 5597 | DEFUN (no_neighbor_prefix_list, |
5598 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5599 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5600 | NO_STR |
5601 | NEIGHBOR_STR | |
5602 | NEIGHBOR_ADDR_STR2 | |
5603 | "Filter updates to/from this neighbor\n" | |
5604 | "Name of a prefix list\n" | |
5605 | "Filter incoming updates\n" | |
5606 | "Filter outgoing updates\n") | |
5607 | { | |
d62a17ae | 5608 | int idx_peer = 2; |
5609 | int idx_in_out = 5; | |
5610 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
5611 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5612 | argv[idx_in_out]->arg); | |
718e3744 | 5613 | } |
6b0655a2 | 5614 | |
d62a17ae | 5615 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
5616 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5617 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5618 | "Filter updates to/from this neighbor\n" | |
5619 | "Name of a prefix list\n" | |
5620 | "Filter incoming updates\n" | |
5621 | "Filter outgoing updates\n") | |
596c17ba | 5622 | |
d62a17ae | 5623 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5624 | safi_t safi, const char *name_str, | |
5625 | const char *direct_str) | |
718e3744 | 5626 | { |
d62a17ae | 5627 | int ret; |
5628 | struct peer *peer; | |
5629 | int direct = FILTER_IN; | |
718e3744 | 5630 | |
d62a17ae | 5631 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5632 | if (!peer) | |
5633 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5634 | |
d62a17ae | 5635 | /* Check filter direction. */ |
5636 | if (strncmp(direct_str, "i", 1) == 0) | |
5637 | direct = FILTER_IN; | |
5638 | else if (strncmp(direct_str, "o", 1) == 0) | |
5639 | direct = FILTER_OUT; | |
718e3744 | 5640 | |
d62a17ae | 5641 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 5642 | |
d62a17ae | 5643 | return bgp_vty_return(vty, ret); |
718e3744 | 5644 | } |
5645 | ||
d62a17ae | 5646 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5647 | safi_t safi, const char *direct_str) | |
718e3744 | 5648 | { |
d62a17ae | 5649 | int ret; |
5650 | struct peer *peer; | |
5651 | int direct = FILTER_IN; | |
718e3744 | 5652 | |
d62a17ae | 5653 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5654 | if (!peer) | |
5655 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5656 | |
d62a17ae | 5657 | /* Check filter direction. */ |
5658 | if (strncmp(direct_str, "i", 1) == 0) | |
5659 | direct = FILTER_IN; | |
5660 | else if (strncmp(direct_str, "o", 1) == 0) | |
5661 | direct = FILTER_OUT; | |
718e3744 | 5662 | |
d62a17ae | 5663 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 5664 | |
d62a17ae | 5665 | return bgp_vty_return(vty, ret); |
718e3744 | 5666 | } |
5667 | ||
5668 | DEFUN (neighbor_filter_list, | |
5669 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5670 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5671 | NEIGHBOR_STR |
5672 | NEIGHBOR_ADDR_STR2 | |
5673 | "Establish BGP filters\n" | |
5674 | "AS path access-list name\n" | |
5675 | "Filter incoming routes\n" | |
5676 | "Filter outgoing routes\n") | |
5677 | { | |
d62a17ae | 5678 | int idx_peer = 1; |
5679 | int idx_word = 3; | |
5680 | int idx_in_out = 4; | |
5681 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5682 | bgp_node_safi(vty), argv[idx_word]->arg, | |
5683 | argv[idx_in_out]->arg); | |
718e3744 | 5684 | } |
5685 | ||
d62a17ae | 5686 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
5687 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5688 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5689 | "Establish BGP filters\n" | |
5690 | "AS path access-list name\n" | |
5691 | "Filter incoming routes\n" | |
5692 | "Filter outgoing routes\n") | |
596c17ba | 5693 | |
718e3744 | 5694 | DEFUN (no_neighbor_filter_list, |
5695 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5696 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5697 | NO_STR |
5698 | NEIGHBOR_STR | |
5699 | NEIGHBOR_ADDR_STR2 | |
5700 | "Establish BGP filters\n" | |
5701 | "AS path access-list name\n" | |
5702 | "Filter incoming routes\n" | |
5703 | "Filter outgoing routes\n") | |
5704 | { | |
d62a17ae | 5705 | int idx_peer = 2; |
5706 | int idx_in_out = 5; | |
5707 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
5708 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5709 | argv[idx_in_out]->arg); | |
718e3744 | 5710 | } |
6b0655a2 | 5711 | |
d62a17ae | 5712 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
5713 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5714 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5715 | "Establish BGP filters\n" | |
5716 | "AS path access-list name\n" | |
5717 | "Filter incoming routes\n" | |
5718 | "Filter outgoing routes\n") | |
596c17ba | 5719 | |
718e3744 | 5720 | /* Set route-map to the peer. */ |
d62a17ae | 5721 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
5722 | afi_t afi, safi_t safi, const char *name_str, | |
5723 | const char *direct_str) | |
718e3744 | 5724 | { |
d62a17ae | 5725 | int ret; |
5726 | struct peer *peer; | |
5727 | int direct = RMAP_IN; | |
1de27621 | 5728 | struct route_map *route_map; |
718e3744 | 5729 | |
d62a17ae | 5730 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5731 | if (!peer) | |
5732 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5733 | |
d62a17ae | 5734 | /* Check filter direction. */ |
5735 | if (strncmp(direct_str, "in", 2) == 0) | |
5736 | direct = RMAP_IN; | |
5737 | else if (strncmp(direct_str, "o", 1) == 0) | |
5738 | direct = RMAP_OUT; | |
718e3744 | 5739 | |
1de27621 DA |
5740 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
5741 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 5742 | |
d62a17ae | 5743 | return bgp_vty_return(vty, ret); |
718e3744 | 5744 | } |
5745 | ||
d62a17ae | 5746 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
5747 | afi_t afi, safi_t safi, | |
5748 | const char *direct_str) | |
718e3744 | 5749 | { |
d62a17ae | 5750 | int ret; |
5751 | struct peer *peer; | |
5752 | int direct = RMAP_IN; | |
718e3744 | 5753 | |
d62a17ae | 5754 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5755 | if (!peer) | |
5756 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5757 | |
d62a17ae | 5758 | /* Check filter direction. */ |
5759 | if (strncmp(direct_str, "in", 2) == 0) | |
5760 | direct = RMAP_IN; | |
5761 | else if (strncmp(direct_str, "o", 1) == 0) | |
5762 | direct = RMAP_OUT; | |
718e3744 | 5763 | |
d62a17ae | 5764 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 5765 | |
d62a17ae | 5766 | return bgp_vty_return(vty, ret); |
718e3744 | 5767 | } |
5768 | ||
5769 | DEFUN (neighbor_route_map, | |
5770 | neighbor_route_map_cmd, | |
9ccf14f7 | 5771 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5772 | NEIGHBOR_STR |
5773 | NEIGHBOR_ADDR_STR2 | |
5774 | "Apply route map to neighbor\n" | |
5775 | "Name of route map\n" | |
5776 | "Apply map to incoming routes\n" | |
2a3d5731 | 5777 | "Apply map to outbound routes\n") |
718e3744 | 5778 | { |
d62a17ae | 5779 | int idx_peer = 1; |
5780 | int idx_word = 3; | |
5781 | int idx_in_out = 4; | |
5782 | return peer_route_map_set_vty( | |
5783 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5784 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5785 | } |
5786 | ||
d62a17ae | 5787 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
5788 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5789 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5790 | "Apply route map to neighbor\n" | |
5791 | "Name of route map\n" | |
5792 | "Apply map to incoming routes\n" | |
5793 | "Apply map to outbound routes\n") | |
596c17ba | 5794 | |
718e3744 | 5795 | DEFUN (no_neighbor_route_map, |
5796 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5797 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5798 | NO_STR |
5799 | NEIGHBOR_STR | |
5800 | NEIGHBOR_ADDR_STR2 | |
5801 | "Apply route map to neighbor\n" | |
5802 | "Name of route map\n" | |
5803 | "Apply map to incoming routes\n" | |
2a3d5731 | 5804 | "Apply map to outbound routes\n") |
718e3744 | 5805 | { |
d62a17ae | 5806 | int idx_peer = 2; |
5807 | int idx_in_out = 5; | |
5808 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
5809 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5810 | argv[idx_in_out]->arg); | |
718e3744 | 5811 | } |
6b0655a2 | 5812 | |
d62a17ae | 5813 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
5814 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5815 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5816 | "Apply route map to neighbor\n" | |
5817 | "Name of route map\n" | |
5818 | "Apply map to incoming routes\n" | |
5819 | "Apply map to outbound routes\n") | |
596c17ba | 5820 | |
718e3744 | 5821 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 5822 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
5823 | afi_t afi, safi_t safi, | |
5824 | const char *name_str) | |
718e3744 | 5825 | { |
d62a17ae | 5826 | int ret; |
5827 | struct peer *peer; | |
1de27621 | 5828 | struct route_map *route_map; |
718e3744 | 5829 | |
d62a17ae | 5830 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5831 | if (!peer) | |
5832 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5833 | |
1de27621 DA |
5834 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
5835 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 5836 | |
d62a17ae | 5837 | return bgp_vty_return(vty, ret); |
718e3744 | 5838 | } |
5839 | ||
5840 | /* Unset route-map from the peer. */ | |
d62a17ae | 5841 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
5842 | afi_t afi, safi_t safi) | |
718e3744 | 5843 | { |
d62a17ae | 5844 | int ret; |
5845 | struct peer *peer; | |
718e3744 | 5846 | |
d62a17ae | 5847 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5848 | if (!peer) | |
5849 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5850 | |
d62a17ae | 5851 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 5852 | |
d62a17ae | 5853 | return bgp_vty_return(vty, ret); |
718e3744 | 5854 | } |
5855 | ||
5856 | DEFUN (neighbor_unsuppress_map, | |
5857 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5858 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5859 | NEIGHBOR_STR |
5860 | NEIGHBOR_ADDR_STR2 | |
5861 | "Route-map to selectively unsuppress suppressed routes\n" | |
5862 | "Name of route map\n") | |
5863 | { | |
d62a17ae | 5864 | int idx_peer = 1; |
5865 | int idx_word = 3; | |
5866 | return peer_unsuppress_map_set_vty( | |
5867 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5868 | argv[idx_word]->arg); | |
718e3744 | 5869 | } |
5870 | ||
d62a17ae | 5871 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
5872 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5873 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5874 | "Route-map to selectively unsuppress suppressed routes\n" | |
5875 | "Name of route map\n") | |
596c17ba | 5876 | |
718e3744 | 5877 | DEFUN (no_neighbor_unsuppress_map, |
5878 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5879 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5880 | NO_STR |
5881 | NEIGHBOR_STR | |
5882 | NEIGHBOR_ADDR_STR2 | |
5883 | "Route-map to selectively unsuppress suppressed routes\n" | |
5884 | "Name of route map\n") | |
5885 | { | |
d62a17ae | 5886 | int idx_peer = 2; |
5887 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
5888 | bgp_node_afi(vty), | |
5889 | bgp_node_safi(vty)); | |
718e3744 | 5890 | } |
6b0655a2 | 5891 | |
d62a17ae | 5892 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
5893 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5894 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5895 | "Route-map to selectively unsuppress suppressed routes\n" | |
5896 | "Name of route map\n") | |
596c17ba | 5897 | |
d62a17ae | 5898 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
5899 | afi_t afi, safi_t safi, | |
5900 | const char *num_str, | |
5901 | const char *threshold_str, int warning, | |
5902 | const char *restart_str) | |
718e3744 | 5903 | { |
d62a17ae | 5904 | int ret; |
5905 | struct peer *peer; | |
d7c0a89a QY |
5906 | uint32_t max; |
5907 | uint8_t threshold; | |
5908 | uint16_t restart; | |
718e3744 | 5909 | |
d62a17ae | 5910 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5911 | if (!peer) | |
5912 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5913 | |
d62a17ae | 5914 | max = strtoul(num_str, NULL, 10); |
5915 | if (threshold_str) | |
5916 | threshold = atoi(threshold_str); | |
5917 | else | |
5918 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5919 | |
d62a17ae | 5920 | if (restart_str) |
5921 | restart = atoi(restart_str); | |
5922 | else | |
5923 | restart = 0; | |
0a486e5f | 5924 | |
d62a17ae | 5925 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
5926 | restart); | |
718e3744 | 5927 | |
d62a17ae | 5928 | return bgp_vty_return(vty, ret); |
718e3744 | 5929 | } |
5930 | ||
d62a17ae | 5931 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
5932 | afi_t afi, safi_t safi) | |
718e3744 | 5933 | { |
d62a17ae | 5934 | int ret; |
5935 | struct peer *peer; | |
718e3744 | 5936 | |
d62a17ae | 5937 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5938 | if (!peer) | |
5939 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5940 | |
d62a17ae | 5941 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 5942 | |
d62a17ae | 5943 | return bgp_vty_return(vty, ret); |
718e3744 | 5944 | } |
5945 | ||
5946 | /* Maximum number of prefix configuration. prefix count is different | |
5947 | for each peer configuration. So this configuration can be set for | |
5948 | each peer configuration. */ | |
5949 | DEFUN (neighbor_maximum_prefix, | |
5950 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5951 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5952 | NEIGHBOR_STR |
5953 | NEIGHBOR_ADDR_STR2 | |
5954 | "Maximum number of prefix accept from this peer\n" | |
5955 | "maximum no. of prefix limit\n") | |
5956 | { | |
d62a17ae | 5957 | int idx_peer = 1; |
5958 | int idx_number = 3; | |
5959 | return peer_maximum_prefix_set_vty( | |
5960 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5961 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 5962 | } |
5963 | ||
d62a17ae | 5964 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
5965 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
5966 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5967 | "Maximum number of prefix accept from this peer\n" | |
5968 | "maximum no. of prefix limit\n") | |
596c17ba | 5969 | |
e0701b79 | 5970 | DEFUN (neighbor_maximum_prefix_threshold, |
5971 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5972 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5973 | NEIGHBOR_STR |
5974 | NEIGHBOR_ADDR_STR2 | |
5975 | "Maximum number of prefix accept from this peer\n" | |
5976 | "maximum no. of prefix limit\n" | |
5977 | "Threshold value (%) at which to generate a warning msg\n") | |
5978 | { | |
d62a17ae | 5979 | int idx_peer = 1; |
5980 | int idx_number = 3; | |
5981 | int idx_number_2 = 4; | |
5982 | return peer_maximum_prefix_set_vty( | |
5983 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5984 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 5985 | } |
e0701b79 | 5986 | |
d62a17ae | 5987 | ALIAS_HIDDEN( |
5988 | neighbor_maximum_prefix_threshold, | |
5989 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
5990 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
5991 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5992 | "Maximum number of prefix accept from this peer\n" | |
5993 | "maximum no. of prefix limit\n" | |
5994 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 5995 | |
718e3744 | 5996 | DEFUN (neighbor_maximum_prefix_warning, |
5997 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5998 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5999 | NEIGHBOR_STR |
6000 | NEIGHBOR_ADDR_STR2 | |
6001 | "Maximum number of prefix accept from this peer\n" | |
6002 | "maximum no. of prefix limit\n" | |
6003 | "Only give warning message when limit is exceeded\n") | |
6004 | { | |
d62a17ae | 6005 | int idx_peer = 1; |
6006 | int idx_number = 3; | |
6007 | return peer_maximum_prefix_set_vty( | |
6008 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6009 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 6010 | } |
6011 | ||
d62a17ae | 6012 | ALIAS_HIDDEN( |
6013 | neighbor_maximum_prefix_warning, | |
6014 | neighbor_maximum_prefix_warning_hidden_cmd, | |
6015 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
6016 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6017 | "Maximum number of prefix accept from this peer\n" | |
6018 | "maximum no. of prefix limit\n" | |
6019 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6020 | |
e0701b79 | 6021 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
6022 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 6023 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 6024 | NEIGHBOR_STR |
6025 | NEIGHBOR_ADDR_STR2 | |
6026 | "Maximum number of prefix accept from this peer\n" | |
6027 | "maximum no. of prefix limit\n" | |
6028 | "Threshold value (%) at which to generate a warning msg\n" | |
6029 | "Only give warning message when limit is exceeded\n") | |
6030 | { | |
d62a17ae | 6031 | int idx_peer = 1; |
6032 | int idx_number = 3; | |
6033 | int idx_number_2 = 4; | |
6034 | return peer_maximum_prefix_set_vty( | |
6035 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6036 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 6037 | } |
6038 | ||
d62a17ae | 6039 | ALIAS_HIDDEN( |
6040 | neighbor_maximum_prefix_threshold_warning, | |
6041 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
6042 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
6043 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6044 | "Maximum number of prefix accept from this peer\n" | |
6045 | "maximum no. of prefix limit\n" | |
6046 | "Threshold value (%) at which to generate a warning msg\n" | |
6047 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6048 | |
0a486e5f | 6049 | DEFUN (neighbor_maximum_prefix_restart, |
6050 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 6051 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 6052 | NEIGHBOR_STR |
6053 | NEIGHBOR_ADDR_STR2 | |
6054 | "Maximum number of prefix accept from this peer\n" | |
6055 | "maximum no. of prefix limit\n" | |
6056 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6057 | "Restart interval in minutes\n") |
0a486e5f | 6058 | { |
d62a17ae | 6059 | int idx_peer = 1; |
6060 | int idx_number = 3; | |
6061 | int idx_number_2 = 5; | |
6062 | return peer_maximum_prefix_set_vty( | |
6063 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6064 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 6065 | } |
6066 | ||
d62a17ae | 6067 | ALIAS_HIDDEN( |
6068 | neighbor_maximum_prefix_restart, | |
6069 | neighbor_maximum_prefix_restart_hidden_cmd, | |
6070 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
6071 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6072 | "Maximum number of prefix accept from this peer\n" | |
6073 | "maximum no. of prefix limit\n" | |
6074 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6075 | "Restart interval in minutes\n") |
596c17ba | 6076 | |
0a486e5f | 6077 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6078 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 6079 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 6080 | NEIGHBOR_STR |
6081 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6082 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 6083 | "maximum no. of prefix limit\n" |
6084 | "Threshold value (%) at which to generate a warning msg\n" | |
6085 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6086 | "Restart interval in minutes\n") |
0a486e5f | 6087 | { |
d62a17ae | 6088 | int idx_peer = 1; |
6089 | int idx_number = 3; | |
6090 | int idx_number_2 = 4; | |
6091 | int idx_number_3 = 6; | |
6092 | return peer_maximum_prefix_set_vty( | |
6093 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6094 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
6095 | argv[idx_number_3]->arg); | |
6096 | } | |
6097 | ||
6098 | ALIAS_HIDDEN( | |
6099 | neighbor_maximum_prefix_threshold_restart, | |
6100 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
6101 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
6102 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6103 | "Maximum number of prefixes to accept from this peer\n" | |
6104 | "maximum no. of prefix limit\n" | |
6105 | "Threshold value (%) at which to generate a warning msg\n" | |
6106 | "Restart bgp connection after limit is exceeded\n" | |
6107 | "Restart interval in minutes\n") | |
596c17ba | 6108 | |
718e3744 | 6109 | DEFUN (no_neighbor_maximum_prefix, |
6110 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 6111 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 6112 | NO_STR |
6113 | NEIGHBOR_STR | |
6114 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6115 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
6116 | "maximum no. of prefix limit\n" |
6117 | "Threshold value (%) at which to generate a warning msg\n" | |
6118 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6119 | "Restart interval in minutes\n" |
31500417 | 6120 | "Only give warning message when limit is exceeded\n") |
718e3744 | 6121 | { |
d62a17ae | 6122 | int idx_peer = 2; |
6123 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
6124 | bgp_node_afi(vty), | |
6125 | bgp_node_safi(vty)); | |
718e3744 | 6126 | } |
e52702f2 | 6127 | |
d62a17ae | 6128 | ALIAS_HIDDEN( |
6129 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
6130 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
6131 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6132 | "Maximum number of prefixes to accept from this peer\n" | |
6133 | "maximum no. of prefix limit\n" | |
6134 | "Threshold value (%) at which to generate a warning msg\n" | |
6135 | "Restart bgp connection after limit is exceeded\n" | |
6136 | "Restart interval in minutes\n" | |
6137 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6138 | |
718e3744 | 6139 | |
718e3744 | 6140 | /* "neighbor allowas-in" */ |
6141 | DEFUN (neighbor_allowas_in, | |
6142 | neighbor_allowas_in_cmd, | |
fd8503f5 | 6143 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6144 | NEIGHBOR_STR |
6145 | NEIGHBOR_ADDR_STR2 | |
31500417 | 6146 | "Accept as-path with my AS present in it\n" |
0437e105 | 6147 | "Number of occurences of AS number\n" |
fd8503f5 | 6148 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6149 | { |
d62a17ae | 6150 | int idx_peer = 1; |
6151 | int idx_number_origin = 3; | |
6152 | int ret; | |
6153 | int origin = 0; | |
6154 | struct peer *peer; | |
6155 | int allow_num = 0; | |
6156 | ||
6157 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6158 | if (!peer) | |
6159 | return CMD_WARNING_CONFIG_FAILED; | |
6160 | ||
6161 | if (argc <= idx_number_origin) | |
6162 | allow_num = 3; | |
6163 | else { | |
6164 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6165 | origin = 1; | |
6166 | else | |
6167 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6168 | } | |
6169 | ||
6170 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6171 | allow_num, origin); | |
6172 | ||
6173 | return bgp_vty_return(vty, ret); | |
6174 | } | |
6175 | ||
6176 | ALIAS_HIDDEN( | |
6177 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
6178 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6179 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6180 | "Accept as-path with my AS present in it\n" | |
0437e105 | 6181 | "Number of occurences of AS number\n" |
d62a17ae | 6182 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6183 | |
718e3744 | 6184 | DEFUN (no_neighbor_allowas_in, |
6185 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6186 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6187 | NO_STR |
6188 | NEIGHBOR_STR | |
6189 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6190 | "allow local ASN appears in aspath attribute\n" |
0437e105 | 6191 | "Number of occurences of AS number\n" |
fd8503f5 | 6192 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6193 | { |
d62a17ae | 6194 | int idx_peer = 2; |
6195 | int ret; | |
6196 | struct peer *peer; | |
718e3744 | 6197 | |
d62a17ae | 6198 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6199 | if (!peer) | |
6200 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6201 | |
d62a17ae | 6202 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6203 | bgp_node_safi(vty)); | |
718e3744 | 6204 | |
d62a17ae | 6205 | return bgp_vty_return(vty, ret); |
718e3744 | 6206 | } |
6b0655a2 | 6207 | |
d62a17ae | 6208 | ALIAS_HIDDEN( |
6209 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6210 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6211 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6212 | "allow local ASN appears in aspath attribute\n" | |
0437e105 | 6213 | "Number of occurences of AS number\n" |
d62a17ae | 6214 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6215 | |
fa411a21 NH |
6216 | DEFUN (neighbor_ttl_security, |
6217 | neighbor_ttl_security_cmd, | |
7ebe625c | 6218 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6219 | NEIGHBOR_STR |
7ebe625c | 6220 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6221 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6222 | "Specify the maximum number of hops to the BGP peer\n" |
6223 | "Number of hops to BGP peer\n") | |
fa411a21 | 6224 | { |
d62a17ae | 6225 | int idx_peer = 1; |
6226 | int idx_number = 4; | |
6227 | struct peer *peer; | |
6228 | int gtsm_hops; | |
6229 | ||
6230 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6231 | if (!peer) | |
6232 | return CMD_WARNING_CONFIG_FAILED; | |
6233 | ||
6234 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6235 | ||
7ebe625c QY |
6236 | /* |
6237 | * If 'neighbor swpX', then this is for directly connected peers, | |
6238 | * we should not accept a ttl-security hops value greater than 1. | |
6239 | */ | |
6240 | if (peer->conf_if && (gtsm_hops > 1)) { | |
6241 | vty_out(vty, | |
6242 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6243 | argv[idx_peer]->arg); | |
6244 | return CMD_WARNING_CONFIG_FAILED; | |
6245 | } | |
6246 | ||
d62a17ae | 6247 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6248 | } |
6249 | ||
6250 | DEFUN (no_neighbor_ttl_security, | |
6251 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6252 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6253 | NO_STR |
6254 | NEIGHBOR_STR | |
7ebe625c | 6255 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6256 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6257 | "Specify the maximum number of hops to the BGP peer\n" |
6258 | "Number of hops to BGP peer\n") | |
fa411a21 | 6259 | { |
d62a17ae | 6260 | int idx_peer = 2; |
6261 | struct peer *peer; | |
fa411a21 | 6262 | |
d62a17ae | 6263 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6264 | if (!peer) | |
6265 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6266 | |
d62a17ae | 6267 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6268 | } |
6b0655a2 | 6269 | |
adbac85e DW |
6270 | DEFUN (neighbor_addpath_tx_all_paths, |
6271 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6272 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6273 | NEIGHBOR_STR |
6274 | NEIGHBOR_ADDR_STR2 | |
6275 | "Use addpath to advertise all paths to a neighbor\n") | |
6276 | { | |
d62a17ae | 6277 | int idx_peer = 1; |
6278 | struct peer *peer; | |
adbac85e | 6279 | |
d62a17ae | 6280 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6281 | if (!peer) | |
6282 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6283 | |
dcc68b5e MS |
6284 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6285 | BGP_ADDPATH_ALL); | |
6286 | return CMD_SUCCESS; | |
adbac85e DW |
6287 | } |
6288 | ||
d62a17ae | 6289 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6290 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6291 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6292 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6293 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6294 | |
adbac85e DW |
6295 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6296 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6297 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6298 | NO_STR |
6299 | NEIGHBOR_STR | |
6300 | NEIGHBOR_ADDR_STR2 | |
6301 | "Use addpath to advertise all paths to a neighbor\n") | |
6302 | { | |
d62a17ae | 6303 | int idx_peer = 2; |
dcc68b5e MS |
6304 | struct peer *peer; |
6305 | ||
6306 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6307 | if (!peer) | |
6308 | return CMD_WARNING_CONFIG_FAILED; | |
6309 | ||
6310 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6311 | != BGP_ADDPATH_ALL) { | |
6312 | vty_out(vty, | |
6313 | "%% Peer not currently configured to transmit all paths."); | |
6314 | return CMD_WARNING_CONFIG_FAILED; | |
6315 | } | |
6316 | ||
6317 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6318 | BGP_ADDPATH_NONE); | |
6319 | ||
6320 | return CMD_SUCCESS; | |
adbac85e DW |
6321 | } |
6322 | ||
d62a17ae | 6323 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6324 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6325 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6326 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6327 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6328 | |
06370dac DW |
6329 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6330 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6331 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6332 | NEIGHBOR_STR |
6333 | NEIGHBOR_ADDR_STR2 | |
6334 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6335 | { | |
d62a17ae | 6336 | int idx_peer = 1; |
6337 | struct peer *peer; | |
06370dac | 6338 | |
d62a17ae | 6339 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6340 | if (!peer) | |
6341 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 6342 | |
dcc68b5e MS |
6343 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6344 | BGP_ADDPATH_BEST_PER_AS); | |
6345 | ||
6346 | return CMD_SUCCESS; | |
06370dac DW |
6347 | } |
6348 | ||
d62a17ae | 6349 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
6350 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6351 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6352 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6353 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6354 | |
06370dac DW |
6355 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
6356 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6357 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6358 | NO_STR |
6359 | NEIGHBOR_STR | |
6360 | NEIGHBOR_ADDR_STR2 | |
6361 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6362 | { | |
d62a17ae | 6363 | int idx_peer = 2; |
dcc68b5e MS |
6364 | struct peer *peer; |
6365 | ||
6366 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6367 | if (!peer) | |
6368 | return CMD_WARNING_CONFIG_FAILED; | |
6369 | ||
6370 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6371 | != BGP_ADDPATH_BEST_PER_AS) { | |
6372 | vty_out(vty, | |
6373 | "%% Peer not currently configured to transmit all best path per as."); | |
6374 | return CMD_WARNING_CONFIG_FAILED; | |
6375 | } | |
6376 | ||
6377 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6378 | BGP_ADDPATH_NONE); | |
6379 | ||
6380 | return CMD_SUCCESS; | |
06370dac DW |
6381 | } |
6382 | ||
d62a17ae | 6383 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
6384 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6385 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6386 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6387 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6388 | |
b9c7bc5a PZ |
6389 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
6390 | struct ecommunity **list) | |
ddb5b488 | 6391 | { |
b9c7bc5a PZ |
6392 | struct ecommunity *ecom = NULL; |
6393 | struct ecommunity *ecomadd; | |
ddb5b488 | 6394 | |
b9c7bc5a | 6395 | for (; argc; --argc, ++argv) { |
ddb5b488 | 6396 | |
b9c7bc5a PZ |
6397 | ecomadd = ecommunity_str2com(argv[0]->arg, |
6398 | ECOMMUNITY_ROUTE_TARGET, 0); | |
6399 | if (!ecomadd) { | |
6400 | vty_out(vty, "Malformed community-list value\n"); | |
6401 | if (ecom) | |
6402 | ecommunity_free(&ecom); | |
6403 | return CMD_WARNING_CONFIG_FAILED; | |
6404 | } | |
ddb5b488 | 6405 | |
b9c7bc5a PZ |
6406 | if (ecom) { |
6407 | ecommunity_merge(ecom, ecomadd); | |
6408 | ecommunity_free(&ecomadd); | |
6409 | } else { | |
6410 | ecom = ecomadd; | |
6411 | } | |
6412 | } | |
6413 | ||
6414 | if (*list) { | |
6415 | ecommunity_free(&*list); | |
ddb5b488 | 6416 | } |
b9c7bc5a PZ |
6417 | *list = ecom; |
6418 | ||
6419 | return CMD_SUCCESS; | |
ddb5b488 PZ |
6420 | } |
6421 | ||
0ca70ba5 DS |
6422 | /* |
6423 | * v2vimport is true if we are handling a `import vrf ...` command | |
6424 | */ | |
6425 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 6426 | { |
0ca70ba5 DS |
6427 | afi_t afi; |
6428 | ||
ddb5b488 | 6429 | switch (vty->node) { |
b9c7bc5a | 6430 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
6431 | afi = AFI_IP; |
6432 | break; | |
b9c7bc5a | 6433 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
6434 | afi = AFI_IP6; |
6435 | break; | |
ddb5b488 PZ |
6436 | default: |
6437 | vty_out(vty, | |
b9c7bc5a | 6438 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 6439 | return AFI_MAX; |
ddb5b488 | 6440 | } |
69b07479 | 6441 | |
0ca70ba5 DS |
6442 | if (!v2vimport) { |
6443 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6444 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
6445 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6446 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
6447 | vty_out(vty, | |
6448 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
6449 | return AFI_MAX; | |
6450 | } | |
6451 | } else { | |
6452 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6453 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
6454 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6455 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
6456 | vty_out(vty, | |
6457 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
6458 | return AFI_MAX; | |
6459 | } | |
6460 | } | |
6461 | return afi; | |
ddb5b488 PZ |
6462 | } |
6463 | ||
b9c7bc5a PZ |
6464 | DEFPY (af_rd_vpn_export, |
6465 | af_rd_vpn_export_cmd, | |
6466 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
6467 | NO_STR | |
ddb5b488 | 6468 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
6469 | "Between current address-family and vpn\n" |
6470 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6471 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
6472 | { | |
6473 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6474 | struct prefix_rd prd; | |
6475 | int ret; | |
ddb5b488 | 6476 | afi_t afi; |
b9c7bc5a PZ |
6477 | int idx = 0; |
6478 | int yes = 1; | |
ddb5b488 | 6479 | |
b9c7bc5a | 6480 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6481 | yes = 0; |
b9c7bc5a PZ |
6482 | |
6483 | if (yes) { | |
6484 | ret = str2prefix_rd(rd_str, &prd); | |
6485 | if (!ret) { | |
6486 | vty_out(vty, "%% Malformed rd\n"); | |
6487 | return CMD_WARNING_CONFIG_FAILED; | |
6488 | } | |
ddb5b488 PZ |
6489 | } |
6490 | ||
0ca70ba5 | 6491 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6492 | if (afi == AFI_MAX) |
6493 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6494 | |
69b07479 DS |
6495 | /* |
6496 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6497 | */ | |
6498 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6499 | bgp_get_default(), bgp); | |
ddb5b488 | 6500 | |
69b07479 DS |
6501 | if (yes) { |
6502 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
6503 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6504 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
6505 | } else { | |
6506 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6507 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
6508 | } |
6509 | ||
69b07479 DS |
6510 | /* post-change: re-export vpn routes */ |
6511 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6512 | bgp_get_default(), bgp); | |
6513 | ||
ddb5b488 PZ |
6514 | return CMD_SUCCESS; |
6515 | } | |
6516 | ||
b9c7bc5a PZ |
6517 | ALIAS (af_rd_vpn_export, |
6518 | af_no_rd_vpn_export_cmd, | |
6519 | "no rd vpn export", | |
ddb5b488 | 6520 | NO_STR |
b9c7bc5a PZ |
6521 | "Specify route distinguisher\n" |
6522 | "Between current address-family and vpn\n" | |
6523 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6524 | |
b9c7bc5a PZ |
6525 | DEFPY (af_label_vpn_export, |
6526 | af_label_vpn_export_cmd, | |
e70e9f8e | 6527 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 6528 | NO_STR |
ddb5b488 | 6529 | "label value for VRF\n" |
b9c7bc5a PZ |
6530 | "Between current address-family and vpn\n" |
6531 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
6532 | "Label Value <0-1048575>\n" |
6533 | "Automatically assign a label\n") | |
ddb5b488 PZ |
6534 | { |
6535 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6536 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 6537 | afi_t afi; |
b9c7bc5a PZ |
6538 | int idx = 0; |
6539 | int yes = 1; | |
6540 | ||
6541 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 6542 | yes = 0; |
ddb5b488 | 6543 | |
21a16cc2 PZ |
6544 | /* If "no ...", squash trailing parameter */ |
6545 | if (!yes) | |
6546 | label_auto = NULL; | |
6547 | ||
e70e9f8e PZ |
6548 | if (yes) { |
6549 | if (!label_auto) | |
6550 | label = label_val; /* parser should force unsigned */ | |
6551 | } | |
ddb5b488 | 6552 | |
0ca70ba5 | 6553 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6554 | if (afi == AFI_MAX) |
6555 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 6556 | |
e70e9f8e | 6557 | |
69b07479 DS |
6558 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
6559 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
6560 | /* no change */ | |
6561 | return CMD_SUCCESS; | |
e70e9f8e | 6562 | |
69b07479 DS |
6563 | /* |
6564 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6565 | */ | |
6566 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6567 | bgp_get_default(), bgp); | |
6568 | ||
6569 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
6570 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
6571 | ||
6572 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
6573 | ||
6574 | /* | |
6575 | * label has previously been automatically | |
6576 | * assigned by labelpool: release it | |
6577 | * | |
6578 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
6579 | * means the automatic assignment is in flight | |
6580 | * and therefore the labelpool callback must | |
6581 | * detect that the auto label is not needed. | |
6582 | */ | |
6583 | ||
6584 | bgp_lp_release(LP_TYPE_VRF, | |
6585 | &bgp->vpn_policy[afi], | |
6586 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 6587 | } |
69b07479 DS |
6588 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
6589 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6590 | } | |
ddb5b488 | 6591 | |
69b07479 DS |
6592 | bgp->vpn_policy[afi].tovpn_label = label; |
6593 | if (label_auto) { | |
6594 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6595 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6596 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
6597 | vpn_leak_label_callback); | |
ddb5b488 PZ |
6598 | } |
6599 | ||
69b07479 DS |
6600 | /* post-change: re-export vpn routes */ |
6601 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6602 | bgp_get_default(), bgp); | |
6603 | ||
ddb5b488 PZ |
6604 | return CMD_SUCCESS; |
6605 | } | |
6606 | ||
b9c7bc5a PZ |
6607 | ALIAS (af_label_vpn_export, |
6608 | af_no_label_vpn_export_cmd, | |
6609 | "no label vpn export", | |
6610 | NO_STR | |
6611 | "label value for VRF\n" | |
6612 | "Between current address-family and vpn\n" | |
6613 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6614 | |
b9c7bc5a PZ |
6615 | DEFPY (af_nexthop_vpn_export, |
6616 | af_nexthop_vpn_export_cmd, | |
6617 | "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str", | |
6618 | NO_STR | |
ddb5b488 | 6619 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
6620 | "Between current address-family and vpn\n" |
6621 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6622 | "IPv4 prefix\n" |
6623 | "IPv6 prefix\n") | |
6624 | { | |
6625 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 6626 | afi_t afi; |
ddb5b488 | 6627 | struct prefix p; |
b9c7bc5a PZ |
6628 | int idx = 0; |
6629 | int yes = 1; | |
ddb5b488 | 6630 | |
b9c7bc5a | 6631 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6632 | yes = 0; |
b9c7bc5a PZ |
6633 | |
6634 | if (yes) { | |
6635 | if (!sockunion2hostprefix(nexthop_str, &p)) | |
6636 | return CMD_WARNING_CONFIG_FAILED; | |
6637 | } | |
ddb5b488 | 6638 | |
0ca70ba5 | 6639 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6640 | if (afi == AFI_MAX) |
6641 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6642 | |
69b07479 DS |
6643 | /* |
6644 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6645 | */ | |
6646 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6647 | bgp_get_default(), bgp); | |
ddb5b488 | 6648 | |
69b07479 DS |
6649 | if (yes) { |
6650 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
6651 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6652 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
6653 | } else { | |
6654 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6655 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
6656 | } |
6657 | ||
69b07479 DS |
6658 | /* post-change: re-export vpn routes */ |
6659 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6660 | bgp_get_default(), bgp); | |
6661 | ||
ddb5b488 PZ |
6662 | return CMD_SUCCESS; |
6663 | } | |
6664 | ||
b9c7bc5a PZ |
6665 | ALIAS (af_nexthop_vpn_export, |
6666 | af_no_nexthop_vpn_export_cmd, | |
6667 | "no nexthop vpn export", | |
ddb5b488 | 6668 | NO_STR |
b9c7bc5a PZ |
6669 | "Specify next hop to use for VRF advertised prefixes\n" |
6670 | "Between current address-family and vpn\n" | |
6671 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6672 | |
b9c7bc5a | 6673 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 6674 | { |
b9c7bc5a PZ |
6675 | if (!strcmp(dstr, "import")) { |
6676 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6677 | } else if (!strcmp(dstr, "export")) { | |
6678 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6679 | } else if (!strcmp(dstr, "both")) { | |
6680 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6681 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6682 | } else { | |
6683 | vty_out(vty, "%% direction parse error\n"); | |
6684 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6685 | } |
ddb5b488 PZ |
6686 | return CMD_SUCCESS; |
6687 | } | |
6688 | ||
b9c7bc5a PZ |
6689 | DEFPY (af_rt_vpn_imexport, |
6690 | af_rt_vpn_imexport_cmd, | |
6691 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
6692 | NO_STR | |
6693 | "Specify route target list\n" | |
ddb5b488 | 6694 | "Specify route target list\n" |
b9c7bc5a PZ |
6695 | "Between current address-family and vpn\n" |
6696 | "For routes leaked from vpn to current address-family: match any\n" | |
6697 | "For routes leaked from current address-family to vpn: set\n" | |
6698 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
6699 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
6700 | { | |
6701 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6702 | int ret; | |
6703 | struct ecommunity *ecom = NULL; | |
6704 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6705 | vpn_policy_direction_t dir; |
6706 | afi_t afi; | |
6707 | int idx = 0; | |
b9c7bc5a | 6708 | int yes = 1; |
ddb5b488 | 6709 | |
b9c7bc5a | 6710 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6711 | yes = 0; |
b9c7bc5a | 6712 | |
0ca70ba5 | 6713 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6714 | if (afi == AFI_MAX) |
6715 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6716 | |
b9c7bc5a | 6717 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6718 | if (ret != CMD_SUCCESS) |
6719 | return ret; | |
6720 | ||
b9c7bc5a PZ |
6721 | if (yes) { |
6722 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
6723 | vty_out(vty, "%% Missing RTLIST\n"); | |
6724 | return CMD_WARNING_CONFIG_FAILED; | |
6725 | } | |
6726 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
6727 | if (ret != CMD_SUCCESS) { | |
6728 | return ret; | |
6729 | } | |
ddb5b488 PZ |
6730 | } |
6731 | ||
69b07479 DS |
6732 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6733 | if (!dodir[dir]) | |
ddb5b488 | 6734 | continue; |
ddb5b488 | 6735 | |
69b07479 | 6736 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6737 | |
69b07479 DS |
6738 | if (yes) { |
6739 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6740 | ecommunity_free( | |
6741 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6742 | bgp->vpn_policy[afi].rtlist[dir] = | |
6743 | ecommunity_dup(ecom); | |
6744 | } else { | |
6745 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6746 | ecommunity_free( | |
6747 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6748 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 6749 | } |
69b07479 DS |
6750 | |
6751 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 6752 | } |
69b07479 | 6753 | |
d555f3e9 PZ |
6754 | if (ecom) |
6755 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
6756 | |
6757 | return CMD_SUCCESS; | |
6758 | } | |
6759 | ||
b9c7bc5a PZ |
6760 | ALIAS (af_rt_vpn_imexport, |
6761 | af_no_rt_vpn_imexport_cmd, | |
6762 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
6763 | NO_STR |
6764 | "Specify route target list\n" | |
b9c7bc5a PZ |
6765 | "Specify route target list\n" |
6766 | "Between current address-family and vpn\n" | |
6767 | "For routes leaked from vpn to current address-family\n" | |
6768 | "For routes leaked from current address-family to vpn\n" | |
6769 | "both import and export\n") | |
6770 | ||
6771 | DEFPY (af_route_map_vpn_imexport, | |
6772 | af_route_map_vpn_imexport_cmd, | |
6773 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
6774 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
6775 | NO_STR | |
ddb5b488 | 6776 | "Specify route map\n" |
b9c7bc5a PZ |
6777 | "Between current address-family and vpn\n" |
6778 | "For routes leaked from vpn to current address-family\n" | |
6779 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6780 | "name of route-map\n") |
6781 | { | |
6782 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6783 | int ret; | |
6784 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6785 | vpn_policy_direction_t dir; |
6786 | afi_t afi; | |
ddb5b488 | 6787 | int idx = 0; |
b9c7bc5a | 6788 | int yes = 1; |
ddb5b488 | 6789 | |
b9c7bc5a | 6790 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6791 | yes = 0; |
b9c7bc5a | 6792 | |
0ca70ba5 | 6793 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6794 | if (afi == AFI_MAX) |
6795 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6796 | |
b9c7bc5a | 6797 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6798 | if (ret != CMD_SUCCESS) |
6799 | return ret; | |
6800 | ||
69b07479 DS |
6801 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6802 | if (!dodir[dir]) | |
ddb5b488 | 6803 | continue; |
ddb5b488 | 6804 | |
69b07479 | 6805 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6806 | |
69b07479 DS |
6807 | if (yes) { |
6808 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6809 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6810 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6811 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
6812 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6813 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 6814 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
6815 | if (!bgp->vpn_policy[afi].rmap[dir]) |
6816 | return CMD_SUCCESS; | |
6817 | } else { | |
6818 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6819 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6820 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6821 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6822 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 6823 | } |
69b07479 DS |
6824 | |
6825 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
6826 | } |
6827 | ||
6828 | return CMD_SUCCESS; | |
6829 | } | |
6830 | ||
b9c7bc5a PZ |
6831 | ALIAS (af_route_map_vpn_imexport, |
6832 | af_no_route_map_vpn_imexport_cmd, | |
6833 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
6834 | NO_STR |
6835 | "Specify route map\n" | |
b9c7bc5a PZ |
6836 | "Between current address-family and vpn\n" |
6837 | "For routes leaked from vpn to current address-family\n" | |
6838 | "For routes leaked from current address-family to vpn\n") | |
6839 | ||
bb4f6190 DS |
6840 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
6841 | "[no] import vrf route-map RMAP$rmap_str", | |
6842 | NO_STR | |
6843 | "Import routes from another VRF\n" | |
6844 | "Vrf routes being filtered\n" | |
6845 | "Specify route map\n" | |
6846 | "name of route-map\n") | |
6847 | { | |
6848 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
6849 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
6850 | afi_t afi; | |
6851 | int idx = 0; | |
6852 | int yes = 1; | |
6853 | struct bgp *bgp_default; | |
6854 | ||
6855 | if (argv_find(argv, argc, "no", &idx)) | |
6856 | yes = 0; | |
6857 | ||
0ca70ba5 | 6858 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
6859 | if (afi == AFI_MAX) |
6860 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
6861 | |
6862 | bgp_default = bgp_get_default(); | |
6863 | if (!bgp_default) { | |
6864 | int32_t ret; | |
6865 | as_t as = bgp->as; | |
6866 | ||
6867 | /* Auto-create assuming the same AS */ | |
6868 | ret = bgp_get(&bgp_default, &as, NULL, | |
6869 | BGP_INSTANCE_TYPE_DEFAULT); | |
6870 | ||
6871 | if (ret) { | |
6872 | vty_out(vty, | |
6873 | "VRF default is not configured as a bgp instance\n"); | |
6874 | return CMD_WARNING; | |
6875 | } | |
6876 | } | |
6877 | ||
69b07479 | 6878 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 6879 | |
69b07479 DS |
6880 | if (yes) { |
6881 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6882 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6883 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6884 | bgp->vpn_policy[afi].rmap_name[dir] = | |
6885 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6886 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 6887 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
6888 | if (!bgp->vpn_policy[afi].rmap[dir]) |
6889 | return CMD_SUCCESS; | |
6890 | } else { | |
6891 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6892 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6893 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6894 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6895 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
bb4f6190 DS |
6896 | } |
6897 | ||
69b07479 DS |
6898 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
6899 | ||
bb4f6190 DS |
6900 | return CMD_SUCCESS; |
6901 | } | |
6902 | ||
6903 | ALIAS(af_import_vrf_route_map, af_no_import_vrf_route_map_cmd, | |
6904 | "no import vrf route-map", | |
6905 | NO_STR | |
6906 | "Import routes from another VRF\n" | |
6907 | "Vrf routes being filtered\n" | |
6908 | "Specify route map\n") | |
6909 | ||
4d1b335c DA |
6910 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
6911 | "[no] import vrf VIEWVRFNAME$import_name", | |
6912 | NO_STR | |
6913 | "Import routes from another VRF\n" | |
6914 | "VRF to import from\n" | |
6915 | "The name of the VRF\n") | |
12a844a5 DS |
6916 | { |
6917 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6918 | struct listnode *node; | |
79ef8664 DS |
6919 | struct bgp *vrf_bgp, *bgp_default; |
6920 | int32_t ret = 0; | |
6921 | as_t as = bgp->as; | |
12a844a5 DS |
6922 | bool remove = false; |
6923 | int32_t idx = 0; | |
6924 | char *vname; | |
a8dadcf6 | 6925 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
6926 | safi_t safi; |
6927 | afi_t afi; | |
6928 | ||
867f0cca | 6929 | if (import_name == NULL) { |
6930 | vty_out(vty, "%% Missing import name\n"); | |
6931 | return CMD_WARNING; | |
6932 | } | |
6933 | ||
12a844a5 DS |
6934 | if (argv_find(argv, argc, "no", &idx)) |
6935 | remove = true; | |
6936 | ||
0ca70ba5 DS |
6937 | afi = vpn_policy_getafi(vty, bgp, true); |
6938 | if (afi == AFI_MAX) | |
6939 | return CMD_WARNING_CONFIG_FAILED; | |
6940 | ||
12a844a5 DS |
6941 | safi = bgp_node_safi(vty); |
6942 | ||
25679caa | 6943 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 6944 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
6945 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
6946 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
6947 | remove ? "unimport" : "import", import_name); | |
6948 | return CMD_WARNING; | |
6949 | } | |
6950 | ||
79ef8664 DS |
6951 | bgp_default = bgp_get_default(); |
6952 | if (!bgp_default) { | |
6953 | /* Auto-create assuming the same AS */ | |
6954 | ret = bgp_get(&bgp_default, &as, NULL, | |
6955 | BGP_INSTANCE_TYPE_DEFAULT); | |
6956 | ||
6957 | if (ret) { | |
6958 | vty_out(vty, | |
6959 | "VRF default is not configured as a bgp instance\n"); | |
6960 | return CMD_WARNING; | |
6961 | } | |
6962 | } | |
6963 | ||
12a844a5 DS |
6964 | vrf_bgp = bgp_lookup_by_name(import_name); |
6965 | if (!vrf_bgp) { | |
5742e42b | 6966 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
6967 | vrf_bgp = bgp_default; |
6968 | else | |
0fb8d6e6 DS |
6969 | /* Auto-create assuming the same AS */ |
6970 | ret = bgp_get(&vrf_bgp, &as, import_name, bgp_type); | |
a8dadcf6 | 6971 | |
6e2c7fe6 | 6972 | if (ret) { |
020a3f60 DS |
6973 | vty_out(vty, |
6974 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
6975 | import_name); |
6976 | return CMD_WARNING; | |
6977 | } | |
12a844a5 DS |
6978 | } |
6979 | ||
12a844a5 | 6980 | if (remove) { |
44338987 | 6981 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 6982 | } else { |
44338987 | 6983 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
6984 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
6985 | vname)) { | |
6986 | if (strcmp(vname, import_name) == 0) | |
6987 | return CMD_WARNING; | |
6988 | } | |
6989 | ||
44338987 | 6990 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
6991 | } |
6992 | ||
6993 | return CMD_SUCCESS; | |
6994 | } | |
6995 | ||
b9c7bc5a PZ |
6996 | /* This command is valid only in a bgp vrf instance or the default instance */ |
6997 | DEFPY (bgp_imexport_vpn, | |
6998 | bgp_imexport_vpn_cmd, | |
6999 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
7000 | NO_STR |
7001 | "Import routes to this address-family\n" | |
7002 | "Export routes from this address-family\n" | |
7003 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
7004 | { |
7005 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 7006 | int previous_state; |
ddb5b488 | 7007 | afi_t afi; |
b9c7bc5a | 7008 | safi_t safi; |
ddb5b488 | 7009 | int idx = 0; |
b9c7bc5a PZ |
7010 | int yes = 1; |
7011 | int flag; | |
7012 | vpn_policy_direction_t dir; | |
ddb5b488 | 7013 | |
b9c7bc5a | 7014 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 7015 | yes = 0; |
ddb5b488 | 7016 | |
b9c7bc5a PZ |
7017 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
7018 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 7019 | |
b9c7bc5a PZ |
7020 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
7021 | return CMD_WARNING_CONFIG_FAILED; | |
7022 | } | |
ddb5b488 | 7023 | |
b9c7bc5a PZ |
7024 | afi = bgp_node_afi(vty); |
7025 | safi = bgp_node_safi(vty); | |
7026 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
7027 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
7028 | return CMD_WARNING_CONFIG_FAILED; | |
7029 | } | |
ddb5b488 | 7030 | |
b9c7bc5a PZ |
7031 | if (!strcmp(direction_str, "import")) { |
7032 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
7033 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
7034 | } else if (!strcmp(direction_str, "export")) { | |
7035 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
7036 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
7037 | } else { | |
7038 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
7039 | return CMD_WARNING_CONFIG_FAILED; | |
7040 | } | |
7041 | ||
7042 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 7043 | |
b9c7bc5a PZ |
7044 | if (yes) { |
7045 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
7046 | if (!previous_state) { | |
7047 | /* trigger export current vrf */ | |
ddb5b488 PZ |
7048 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
7049 | } | |
b9c7bc5a PZ |
7050 | } else { |
7051 | if (previous_state) { | |
7052 | /* trigger un-export current vrf */ | |
7053 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
7054 | } | |
7055 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
7056 | } |
7057 | ||
7058 | return CMD_SUCCESS; | |
7059 | } | |
7060 | ||
301ad80a PG |
7061 | DEFPY (af_routetarget_import, |
7062 | af_routetarget_import_cmd, | |
7063 | "[no] <rt|route-target> redirect import RTLIST...", | |
7064 | NO_STR | |
7065 | "Specify route target list\n" | |
7066 | "Specify route target list\n" | |
7067 | "Flow-spec redirect type route target\n" | |
7068 | "Import routes to this address-family\n" | |
7069 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
7070 | { | |
7071 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7072 | int ret; | |
7073 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
7074 | afi_t afi; |
7075 | int idx = 0; | |
7076 | int yes = 1; | |
7077 | ||
7078 | if (argv_find(argv, argc, "no", &idx)) | |
7079 | yes = 0; | |
7080 | ||
0ca70ba5 | 7081 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7082 | if (afi == AFI_MAX) |
7083 | return CMD_WARNING_CONFIG_FAILED; | |
7084 | ||
301ad80a PG |
7085 | if (yes) { |
7086 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7087 | vty_out(vty, "%% Missing RTLIST\n"); | |
7088 | return CMD_WARNING_CONFIG_FAILED; | |
7089 | } | |
7090 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7091 | if (ret != CMD_SUCCESS) | |
7092 | return ret; | |
7093 | } | |
69b07479 DS |
7094 | |
7095 | if (yes) { | |
7096 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7097 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7098 | .import_redirect_rtlist); |
69b07479 DS |
7099 | bgp->vpn_policy[afi].import_redirect_rtlist = |
7100 | ecommunity_dup(ecom); | |
7101 | } else { | |
7102 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7103 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7104 | .import_redirect_rtlist); |
69b07479 | 7105 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 7106 | } |
69b07479 | 7107 | |
301ad80a PG |
7108 | if (ecom) |
7109 | ecommunity_free(&ecom); | |
7110 | ||
7111 | return CMD_SUCCESS; | |
7112 | } | |
7113 | ||
505e5056 | 7114 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 7115 | address_family_ipv4_safi_cmd, |
7116 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7117 | "Enter Address Family command mode\n" | |
7118 | "Address Family\n" | |
7119 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 7120 | { |
f51bae9c | 7121 | |
d62a17ae | 7122 | if (argc == 3) { |
2131d5cf | 7123 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7124 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7125 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7126 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7127 | && safi != SAFI_EVPN) { |
31947174 MK |
7128 | vty_out(vty, |
7129 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7130 | return CMD_WARNING_CONFIG_FAILED; |
7131 | } | |
d62a17ae | 7132 | vty->node = bgp_node_type(AFI_IP, safi); |
7133 | } else | |
7134 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 7135 | |
d62a17ae | 7136 | return CMD_SUCCESS; |
718e3744 | 7137 | } |
7138 | ||
505e5056 | 7139 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 7140 | address_family_ipv6_safi_cmd, |
7141 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7142 | "Enter Address Family command mode\n" | |
7143 | "Address Family\n" | |
7144 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 7145 | { |
d62a17ae | 7146 | if (argc == 3) { |
2131d5cf | 7147 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7148 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7149 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7150 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7151 | && safi != SAFI_EVPN) { |
31947174 MK |
7152 | vty_out(vty, |
7153 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7154 | return CMD_WARNING_CONFIG_FAILED; |
7155 | } | |
d62a17ae | 7156 | vty->node = bgp_node_type(AFI_IP6, safi); |
7157 | } else | |
7158 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 7159 | |
d62a17ae | 7160 | return CMD_SUCCESS; |
25ffbdc1 | 7161 | } |
718e3744 | 7162 | |
d6902373 | 7163 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 7164 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 7165 | address_family_vpnv4_cmd, |
8334fd5a | 7166 | "address-family vpnv4 [unicast]", |
718e3744 | 7167 | "Enter Address Family command mode\n" |
8c3deaae | 7168 | "Address Family\n" |
3a2d747c | 7169 | "Address Family modifier\n") |
718e3744 | 7170 | { |
d62a17ae | 7171 | vty->node = BGP_VPNV4_NODE; |
7172 | return CMD_SUCCESS; | |
718e3744 | 7173 | } |
7174 | ||
505e5056 | 7175 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 7176 | address_family_vpnv6_cmd, |
8334fd5a | 7177 | "address-family vpnv6 [unicast]", |
8ecd3266 | 7178 | "Enter Address Family command mode\n" |
8c3deaae | 7179 | "Address Family\n" |
3a2d747c | 7180 | "Address Family modifier\n") |
8ecd3266 | 7181 | { |
d62a17ae | 7182 | vty->node = BGP_VPNV6_NODE; |
7183 | return CMD_SUCCESS; | |
8ecd3266 | 7184 | } |
64e4a6c5 | 7185 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 7186 | |
505e5056 | 7187 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 7188 | address_family_evpn_cmd, |
7111c1a0 | 7189 | "address-family l2vpn evpn", |
4e0b7b6d | 7190 | "Enter Address Family command mode\n" |
7111c1a0 QY |
7191 | "Address Family\n" |
7192 | "Address Family modifier\n") | |
4e0b7b6d | 7193 | { |
2131d5cf | 7194 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7195 | vty->node = BGP_EVPN_NODE; |
7196 | return CMD_SUCCESS; | |
4e0b7b6d PG |
7197 | } |
7198 | ||
505e5056 | 7199 | DEFUN_NOSH (exit_address_family, |
718e3744 | 7200 | exit_address_family_cmd, |
7201 | "exit-address-family", | |
7202 | "Exit from Address Family configuration mode\n") | |
7203 | { | |
d62a17ae | 7204 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
7205 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
7206 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
7207 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
7208 | || vty->node == BGP_EVPN_NODE |
7209 | || vty->node == BGP_FLOWSPECV4_NODE | |
7210 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 7211 | vty->node = BGP_NODE; |
7212 | return CMD_SUCCESS; | |
718e3744 | 7213 | } |
6b0655a2 | 7214 | |
8ad7271d | 7215 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 7216 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
7217 | const char *ip_str, afi_t afi, safi_t safi, | |
7218 | struct prefix_rd *prd) | |
7219 | { | |
7220 | int ret; | |
7221 | struct prefix match; | |
7222 | struct bgp_node *rn; | |
7223 | struct bgp_node *rm; | |
7224 | struct bgp *bgp; | |
7225 | struct bgp_table *table; | |
7226 | struct bgp_table *rib; | |
7227 | ||
7228 | /* BGP structure lookup. */ | |
7229 | if (view_name) { | |
7230 | bgp = bgp_lookup_by_name(view_name); | |
7231 | if (bgp == NULL) { | |
7232 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
7233 | view_name); | |
7234 | return CMD_WARNING; | |
7235 | } | |
7236 | } else { | |
7237 | bgp = bgp_get_default(); | |
7238 | if (bgp == NULL) { | |
7239 | vty_out(vty, "%% No BGP process is configured\n"); | |
7240 | return CMD_WARNING; | |
7241 | } | |
7242 | } | |
7243 | ||
7244 | /* Check IP address argument. */ | |
7245 | ret = str2prefix(ip_str, &match); | |
7246 | if (!ret) { | |
7247 | vty_out(vty, "%% address is malformed\n"); | |
7248 | return CMD_WARNING; | |
7249 | } | |
7250 | ||
7251 | match.family = afi2family(afi); | |
7252 | rib = bgp->rib[afi][safi]; | |
7253 | ||
7254 | if (safi == SAFI_MPLS_VPN) { | |
7255 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
7256 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
7257 | continue; | |
7258 | ||
67009e22 DS |
7259 | table = bgp_node_get_bgp_table_info(rn); |
7260 | if (table != NULL) { | |
7261 | ||
d62a17ae | 7262 | if ((rm = bgp_node_match(table, &match)) |
7263 | != NULL) { | |
7264 | if (rm->p.prefixlen | |
7265 | == match.prefixlen) { | |
343cdb61 | 7266 | SET_FLAG(rm->flags, |
d62a17ae | 7267 | BGP_NODE_USER_CLEAR); |
7268 | bgp_process(bgp, rm, afi, safi); | |
7269 | } | |
7270 | bgp_unlock_node(rm); | |
7271 | } | |
7272 | } | |
7273 | } | |
7274 | } else { | |
7275 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
7276 | if (rn->p.prefixlen == match.prefixlen) { | |
7277 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
7278 | bgp_process(bgp, rn, afi, safi); | |
7279 | } | |
7280 | bgp_unlock_node(rn); | |
7281 | } | |
7282 | } | |
7283 | ||
7284 | return CMD_SUCCESS; | |
8ad7271d DS |
7285 | } |
7286 | ||
b09b5ae0 | 7287 | /* one clear bgp command to rule them all */ |
718e3744 | 7288 | DEFUN (clear_ip_bgp_all, |
7289 | clear_ip_bgp_all_cmd, | |
f3c3ee0d | 7290 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out>]", |
718e3744 | 7291 | CLEAR_STR |
7292 | IP_STR | |
7293 | BGP_STR | |
838758ac | 7294 | BGP_INSTANCE_HELP_STR |
510afcd6 | 7295 | BGP_AFI_HELP_STR |
fd5e7b70 | 7296 | "Address Family\n" |
510afcd6 | 7297 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 7298 | "Address Family modifier\n" |
b09b5ae0 DW |
7299 | "Clear all peers\n" |
7300 | "BGP neighbor address to clear\n" | |
a80beece | 7301 | "BGP IPv6 neighbor to clear\n" |
838758ac | 7302 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
7303 | "Clear peers with the AS number\n" |
7304 | "Clear all external peers\n" | |
718e3744 | 7305 | "Clear all members of peer-group\n" |
b09b5ae0 | 7306 | "BGP peer-group name\n" |
b09b5ae0 DW |
7307 | BGP_SOFT_STR |
7308 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
7309 | BGP_SOFT_OUT_STR |
7310 | BGP_SOFT_IN_STR | |
7311 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 7312 | BGP_SOFT_OUT_STR) |
718e3744 | 7313 | { |
d62a17ae | 7314 | char *vrf = NULL; |
7315 | ||
7316 | afi_t afi = AFI_IP6; | |
7317 | safi_t safi = SAFI_UNICAST; | |
7318 | enum clear_sort clr_sort = clear_peer; | |
7319 | enum bgp_clear_type clr_type; | |
7320 | char *clr_arg = NULL; | |
7321 | ||
7322 | int idx = 0; | |
7323 | ||
7324 | /* clear [ip] bgp */ | |
7325 | if (argv_find(argv, argc, "ip", &idx)) | |
7326 | afi = AFI_IP; | |
7327 | ||
9a8bdf1c PG |
7328 | /* [<vrf> VIEWVRFNAME] */ |
7329 | if (argv_find(argv, argc, "vrf", &idx)) { | |
7330 | vrf = argv[idx + 1]->arg; | |
7331 | idx += 2; | |
7332 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7333 | vrf = NULL; | |
7334 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7335 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 7336 | vrf = argv[idx + 1]->arg; |
7337 | idx += 2; | |
7338 | } | |
d62a17ae | 7339 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
7340 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
7341 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
7342 | ||
f3c3ee0d | 7343 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 7344 | if (argv_find(argv, argc, "*", &idx)) { |
7345 | clr_sort = clear_all; | |
7346 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
7347 | clr_sort = clear_peer; | |
7348 | clr_arg = argv[idx]->arg; | |
7349 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
7350 | clr_sort = clear_peer; | |
7351 | clr_arg = argv[idx]->arg; | |
7352 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
7353 | clr_sort = clear_group; | |
7354 | idx++; | |
7355 | clr_arg = argv[idx]->arg; | |
f3c3ee0d | 7356 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 7357 | clr_sort = clear_peer; |
7358 | clr_arg = argv[idx]->arg; | |
7359 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { | |
7360 | clr_sort = clear_as; | |
7361 | clr_arg = argv[idx]->arg; | |
7362 | } else if (argv_find(argv, argc, "external", &idx)) { | |
7363 | clr_sort = clear_external; | |
7364 | } | |
7365 | ||
7366 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
7367 | if (argv_find(argv, argc, "soft", &idx)) { | |
7368 | if (argv_find(argv, argc, "in", &idx) | |
7369 | || argv_find(argv, argc, "out", &idx)) | |
7370 | clr_type = strmatch(argv[idx]->text, "in") | |
7371 | ? BGP_CLEAR_SOFT_IN | |
7372 | : BGP_CLEAR_SOFT_OUT; | |
7373 | else | |
7374 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
7375 | } else if (argv_find(argv, argc, "in", &idx)) { | |
7376 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
7377 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
7378 | : BGP_CLEAR_SOFT_IN; | |
7379 | } else if (argv_find(argv, argc, "out", &idx)) { | |
7380 | clr_type = BGP_CLEAR_SOFT_OUT; | |
7381 | } else | |
7382 | clr_type = BGP_CLEAR_SOFT_NONE; | |
7383 | ||
7384 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 7385 | } |
01080f7c | 7386 | |
8ad7271d DS |
7387 | DEFUN (clear_ip_bgp_prefix, |
7388 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 7389 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
7390 | CLEAR_STR |
7391 | IP_STR | |
7392 | BGP_STR | |
838758ac | 7393 | BGP_INSTANCE_HELP_STR |
8ad7271d | 7394 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7395 | "IPv4 prefix\n") |
8ad7271d | 7396 | { |
d62a17ae | 7397 | char *vrf = NULL; |
7398 | char *prefix = NULL; | |
8ad7271d | 7399 | |
d62a17ae | 7400 | int idx = 0; |
01080f7c | 7401 | |
d62a17ae | 7402 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
7403 | if (argv_find(argv, argc, "vrf", &idx)) { |
7404 | vrf = argv[idx + 1]->arg; | |
7405 | idx += 2; | |
7406 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7407 | vrf = NULL; | |
7408 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7409 | /* [<view> VIEWVRFNAME] */ | |
7410 | vrf = argv[idx + 1]->arg; | |
7411 | idx += 2; | |
7412 | } | |
0c7b1b01 | 7413 | |
d62a17ae | 7414 | prefix = argv[argc - 1]->arg; |
8ad7271d | 7415 | |
d62a17ae | 7416 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 7417 | } |
8ad7271d | 7418 | |
b09b5ae0 DW |
7419 | DEFUN (clear_bgp_ipv6_safi_prefix, |
7420 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 7421 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7422 | CLEAR_STR |
3a2d747c | 7423 | IP_STR |
718e3744 | 7424 | BGP_STR |
8c3deaae | 7425 | "Address Family\n" |
46f296b4 | 7426 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7427 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7428 | "IPv6 prefix\n") |
718e3744 | 7429 | { |
9b475e76 PG |
7430 | int idx_safi = 0; |
7431 | int idx_ipv6_prefix = 0; | |
7432 | safi_t safi = SAFI_UNICAST; | |
7433 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7434 | argv[idx_ipv6_prefix]->arg : NULL; | |
7435 | ||
7436 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 7437 | return bgp_clear_prefix( |
9b475e76 PG |
7438 | vty, NULL, prefix, AFI_IP6, |
7439 | safi, NULL); | |
838758ac | 7440 | } |
01080f7c | 7441 | |
b09b5ae0 DW |
7442 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
7443 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 7444 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7445 | CLEAR_STR |
3a2d747c | 7446 | IP_STR |
718e3744 | 7447 | BGP_STR |
838758ac | 7448 | BGP_INSTANCE_HELP_STR |
8c3deaae | 7449 | "Address Family\n" |
46f296b4 | 7450 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7451 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7452 | "IPv6 prefix\n") |
718e3744 | 7453 | { |
9b475e76 | 7454 | int idx_safi = 0; |
9a8bdf1c | 7455 | int idx_vrfview = 0; |
9b475e76 PG |
7456 | int idx_ipv6_prefix = 0; |
7457 | safi_t safi = SAFI_UNICAST; | |
7458 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7459 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 7460 | char *vrfview = NULL; |
9b475e76 | 7461 | |
9a8bdf1c PG |
7462 | /* [<view|vrf> VIEWVRFNAME] */ |
7463 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
7464 | vrfview = argv[idx_vrfview + 1]->arg; | |
7465 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
7466 | vrfview = NULL; | |
7467 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
7468 | /* [<view> VIEWVRFNAME] */ | |
7469 | vrfview = argv[idx_vrfview + 1]->arg; | |
7470 | } | |
9b475e76 PG |
7471 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
7472 | ||
d62a17ae | 7473 | return bgp_clear_prefix( |
9b475e76 PG |
7474 | vty, vrfview, prefix, |
7475 | AFI_IP6, safi, NULL); | |
718e3744 | 7476 | } |
7477 | ||
b09b5ae0 DW |
7478 | DEFUN (show_bgp_views, |
7479 | show_bgp_views_cmd, | |
d6e3c605 | 7480 | "show [ip] bgp views", |
b09b5ae0 | 7481 | SHOW_STR |
d6e3c605 | 7482 | IP_STR |
01080f7c | 7483 | BGP_STR |
b09b5ae0 | 7484 | "Show the defined BGP views\n") |
01080f7c | 7485 | { |
d62a17ae | 7486 | struct list *inst = bm->bgp; |
7487 | struct listnode *node; | |
7488 | struct bgp *bgp; | |
01080f7c | 7489 | |
d62a17ae | 7490 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { |
7491 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
7492 | return CMD_WARNING; | |
7493 | } | |
e52702f2 | 7494 | |
d62a17ae | 7495 | vty_out(vty, "Defined BGP views:\n"); |
7496 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7497 | /* Skip VRFs. */ | |
7498 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
7499 | continue; | |
7500 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
7501 | bgp->as); | |
7502 | } | |
e52702f2 | 7503 | |
d62a17ae | 7504 | return CMD_SUCCESS; |
e0081f70 ML |
7505 | } |
7506 | ||
8386ac43 | 7507 | DEFUN (show_bgp_vrfs, |
7508 | show_bgp_vrfs_cmd, | |
d6e3c605 | 7509 | "show [ip] bgp vrfs [json]", |
8386ac43 | 7510 | SHOW_STR |
d6e3c605 | 7511 | IP_STR |
8386ac43 | 7512 | BGP_STR |
7513 | "Show BGP VRFs\n" | |
9973d184 | 7514 | JSON_STR) |
8386ac43 | 7515 | { |
fe1dc5a3 | 7516 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 7517 | struct list *inst = bm->bgp; |
7518 | struct listnode *node; | |
7519 | struct bgp *bgp; | |
9f049418 | 7520 | bool uj = use_json(argc, argv); |
d62a17ae | 7521 | json_object *json = NULL; |
7522 | json_object *json_vrfs = NULL; | |
7523 | int count = 0; | |
d62a17ae | 7524 | |
7525 | if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE)) { | |
7526 | vty_out(vty, "BGP Multiple Instance is not enabled\n"); | |
7527 | return CMD_WARNING; | |
7528 | } | |
7529 | ||
7530 | if (uj) { | |
7531 | json = json_object_new_object(); | |
7532 | json_vrfs = json_object_new_object(); | |
7533 | } | |
7534 | ||
7535 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7536 | const char *name, *type; | |
7537 | struct peer *peer; | |
7fe96307 | 7538 | struct listnode *node2, *nnode2; |
d62a17ae | 7539 | int peers_cfg, peers_estb; |
7540 | json_object *json_vrf = NULL; | |
d62a17ae | 7541 | |
7542 | /* Skip Views. */ | |
7543 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
7544 | continue; | |
7545 | ||
7546 | count++; | |
7547 | if (!uj && count == 1) | |
fe1dc5a3 MK |
7548 | vty_out(vty, |
7549 | "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n", | |
a4d82a8a PZ |
7550 | "Type", "Id", "routerId", "#PeersVfg", |
7551 | "#PeersEstb", "Name", "L3-VNI", "Rmac"); | |
d62a17ae | 7552 | |
7553 | peers_cfg = peers_estb = 0; | |
7554 | if (uj) | |
7555 | json_vrf = json_object_new_object(); | |
7556 | ||
7557 | ||
7fe96307 | 7558 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 7559 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
7560 | continue; | |
7561 | peers_cfg++; | |
7562 | if (peer->status == Established) | |
7563 | peers_estb++; | |
7564 | } | |
7565 | ||
7566 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 7567 | name = VRF_DEFAULT_NAME; |
d62a17ae | 7568 | type = "DFLT"; |
7569 | } else { | |
7570 | name = bgp->name; | |
7571 | type = "VRF"; | |
7572 | } | |
7573 | ||
a8bf7d9c | 7574 | |
d62a17ae | 7575 | if (uj) { |
a4d82a8a PZ |
7576 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7577 | ? -1 | |
7578 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 7579 | json_object_string_add(json_vrf, "type", type); |
7580 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
7581 | json_object_string_add(json_vrf, "routerId", | |
7582 | inet_ntoa(bgp->router_id)); | |
7583 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
7584 | peers_cfg); | |
7585 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
7586 | peers_estb); | |
7587 | ||
fe1dc5a3 | 7588 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
7589 | json_object_string_add( |
7590 | json_vrf, "rmac", | |
7591 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
d62a17ae | 7592 | json_object_object_add(json_vrfs, name, json_vrf); |
7593 | } else | |
fe1dc5a3 MK |
7594 | vty_out(vty, |
7595 | "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n", | |
a4d82a8a PZ |
7596 | type, |
7597 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
7598 | : (int)bgp->vrf_id, | |
7599 | inet_ntoa(bgp->router_id), peers_cfg, | |
7600 | peers_estb, name, bgp->l3vni, | |
fe1dc5a3 | 7601 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); |
d62a17ae | 7602 | } |
7603 | ||
7604 | if (uj) { | |
7605 | json_object_object_add(json, "vrfs", json_vrfs); | |
7606 | ||
7607 | json_object_int_add(json, "totalVrfs", count); | |
7608 | ||
996c9314 LB |
7609 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
7610 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 7611 | json_object_free(json); |
7612 | } else { | |
7613 | if (count) | |
7614 | vty_out(vty, | |
7615 | "\nTotal number of VRFs (including default): %d\n", | |
7616 | count); | |
7617 | } | |
7618 | ||
7619 | return CMD_SUCCESS; | |
8386ac43 | 7620 | } |
7621 | ||
48ecf8f5 DS |
7622 | DEFUN (show_bgp_mac_hash, |
7623 | show_bgp_mac_hash_cmd, | |
7624 | "show bgp mac hash", | |
7625 | SHOW_STR | |
7626 | BGP_STR | |
7627 | "Mac Address\n" | |
7628 | "Mac Address database\n") | |
7629 | { | |
7630 | bgp_mac_dump_table(vty); | |
7631 | ||
7632 | return CMD_SUCCESS; | |
7633 | } | |
acf71666 | 7634 | |
e3b78da8 | 7635 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 7636 | { |
0291c246 | 7637 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 7638 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 7639 | |
60466a63 | 7640 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
7641 | tip->refcnt); |
7642 | } | |
7643 | ||
7644 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
7645 | { | |
7646 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 7647 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
7648 | |
7649 | vty_out(vty, "Tunnel-ip database:\n"); | |
7650 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 7651 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
7652 | vty); |
7653 | } | |
7654 | ||
15c81ca4 DS |
7655 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
7656 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
7657 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
7658 | "martian next-hops\n" |
7659 | "martian next-hop database\n") | |
acf71666 | 7660 | { |
0291c246 | 7661 | struct bgp *bgp = NULL; |
15c81ca4 | 7662 | int idx = 0; |
9a8bdf1c PG |
7663 | char *name = NULL; |
7664 | ||
7665 | /* [<vrf> VIEWVRFNAME] */ | |
7666 | if (argv_find(argv, argc, "vrf", &idx)) { | |
7667 | name = argv[idx + 1]->arg; | |
7668 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
7669 | name = NULL; | |
7670 | } else if (argv_find(argv, argc, "view", &idx)) | |
7671 | /* [<view> VIEWVRFNAME] */ | |
7672 | name = argv[idx + 1]->arg; | |
7673 | if (name) | |
7674 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
7675 | else |
7676 | bgp = bgp_get_default(); | |
acf71666 | 7677 | |
acf71666 MK |
7678 | if (!bgp) { |
7679 | vty_out(vty, "%% No BGP process is configured\n"); | |
7680 | return CMD_WARNING; | |
7681 | } | |
7682 | bgp_show_martian_nexthops(vty, bgp); | |
7683 | ||
7684 | return CMD_SUCCESS; | |
7685 | } | |
7686 | ||
f412b39a | 7687 | DEFUN (show_bgp_memory, |
4bf6a362 | 7688 | show_bgp_memory_cmd, |
7fa12b13 | 7689 | "show [ip] bgp memory", |
4bf6a362 | 7690 | SHOW_STR |
3a2d747c | 7691 | IP_STR |
4bf6a362 PJ |
7692 | BGP_STR |
7693 | "Global BGP memory statistics\n") | |
7694 | { | |
d62a17ae | 7695 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
7696 | unsigned long count; | |
7697 | ||
7698 | /* RIB related usage stats */ | |
7699 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
7700 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
7701 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7702 | count * sizeof(struct bgp_node))); | |
7703 | ||
7704 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
7705 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
7706 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 7707 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 7708 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
7709 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
7710 | count, | |
4b7e6066 DS |
7711 | mtype_memstr( |
7712 | memstrbuf, sizeof(memstrbuf), | |
7713 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 7714 | |
7715 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
7716 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
7717 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7718 | count * sizeof(struct bgp_static))); | |
7719 | ||
7720 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
7721 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
7722 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7723 | count * sizeof(struct bpacket))); | |
7724 | ||
7725 | /* Adj-In/Out */ | |
7726 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
7727 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
7728 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7729 | count * sizeof(struct bgp_adj_in))); | |
7730 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
7731 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
7732 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7733 | count * sizeof(struct bgp_adj_out))); | |
7734 | ||
7735 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
7736 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
7737 | count, | |
7738 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7739 | count * sizeof(struct bgp_nexthop_cache))); | |
7740 | ||
7741 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
7742 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
7743 | count, | |
7744 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7745 | count * sizeof(struct bgp_damp_info))); | |
7746 | ||
7747 | /* Attributes */ | |
7748 | count = attr_count(); | |
7749 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
7750 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7751 | count * sizeof(struct attr))); | |
7752 | ||
7753 | if ((count = attr_unknown_count())) | |
7754 | vty_out(vty, "%ld unknown attributes\n", count); | |
7755 | ||
7756 | /* AS_PATH attributes */ | |
7757 | count = aspath_count(); | |
7758 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
7759 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7760 | count * sizeof(struct aspath))); | |
7761 | ||
7762 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
7763 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
7764 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7765 | count * sizeof(struct assegment))); | |
7766 | ||
7767 | /* Other attributes */ | |
7768 | if ((count = community_count())) | |
7769 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7770 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7771 | count * sizeof(struct community))); | |
d62a17ae | 7772 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
7773 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7774 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7775 | count * sizeof(struct ecommunity))); | |
d62a17ae | 7776 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
7777 | vty_out(vty, | |
7778 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
7779 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7780 | count * sizeof(struct lcommunity))); | |
d62a17ae | 7781 | |
7782 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
7783 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
7784 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7785 | count * sizeof(struct cluster_list))); | |
7786 | ||
7787 | /* Peer related usage */ | |
7788 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
7789 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
7790 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7791 | count * sizeof(struct peer))); | |
7792 | ||
7793 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
7794 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
7795 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7796 | count * sizeof(struct peer_group))); | |
7797 | ||
7798 | /* Other */ | |
7799 | if ((count = mtype_stats_alloc(MTYPE_HASH))) | |
7800 | vty_out(vty, "%ld hash tables, using %s of memory\n", count, | |
7801 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7802 | count * sizeof(struct hash))); | |
7803 | if ((count = mtype_stats_alloc(MTYPE_HASH_BACKET))) | |
7804 | vty_out(vty, "%ld hash buckets, using %s of memory\n", count, | |
7805 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
e3b78da8 | 7806 | count * sizeof(struct hash_bucket))); |
d62a17ae | 7807 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
7808 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
7809 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7810 | count * sizeof(regex_t))); | |
d62a17ae | 7811 | return CMD_SUCCESS; |
4bf6a362 | 7812 | } |
fee0f4c6 | 7813 | |
57a9c8a8 DS |
7814 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
7815 | { | |
7816 | json_object *bestpath = json_object_new_object(); | |
7817 | ||
7818 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
7819 | json_object_string_add(bestpath, "asPath", "ignore"); | |
7820 | ||
7821 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
7822 | json_object_string_add(bestpath, "asPath", "confed"); | |
7823 | ||
7824 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
a4d82a8a PZ |
7825 | if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) |
7826 | json_object_string_add(bestpath, "multiPathRelax", | |
57a9c8a8 DS |
7827 | "as-set"); |
7828 | else | |
a4d82a8a | 7829 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
7830 | "true"); |
7831 | } else | |
a4d82a8a | 7832 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 DS |
7833 | |
7834 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
7835 | json_object_string_add(bestpath, "compareRouterId", "true"); | |
7836 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
7837 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
7838 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 7839 | json_object_string_add(bestpath, "med", "confed"); |
57a9c8a8 DS |
7840 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
7841 | json_object_string_add(bestpath, "med", | |
7842 | "missing-as-worst"); | |
7843 | else | |
7844 | json_object_string_add(bestpath, "med", "true"); | |
7845 | } | |
7846 | ||
7847 | json_object_object_add(json, "bestPath", bestpath); | |
7848 | } | |
7849 | ||
718e3744 | 7850 | /* Show BGP peer's summary information. */ |
d62a17ae | 7851 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
9f049418 | 7852 | bool use_json, json_object *json) |
d62a17ae | 7853 | { |
7854 | struct peer *peer; | |
7855 | struct listnode *node, *nnode; | |
7856 | unsigned int count = 0, dn_count = 0; | |
7857 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
7858 | char neighbor_buf[VTY_BUFSIZ]; | |
7859 | int neighbor_col_default_width = 16; | |
7860 | int len; | |
7861 | int max_neighbor_width = 0; | |
7862 | int pfx_rcd_safi; | |
7863 | json_object *json_peer = NULL; | |
7864 | json_object *json_peers = NULL; | |
50e05855 | 7865 | struct peer_af *paf; |
d62a17ae | 7866 | |
7867 | /* labeled-unicast routes are installed in the unicast table so in order | |
7868 | * to | |
7869 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
7870 | */ | |
7871 | if (safi == SAFI_LABELED_UNICAST) | |
7872 | pfx_rcd_safi = SAFI_UNICAST; | |
7873 | else | |
7874 | pfx_rcd_safi = safi; | |
7875 | ||
7876 | if (use_json) { | |
7877 | if (json == NULL) | |
7878 | json = json_object_new_object(); | |
7879 | ||
7880 | json_peers = json_object_new_object(); | |
7881 | } else { | |
7882 | /* Loop over all neighbors that will be displayed to determine | |
7883 | * how many | |
7884 | * characters are needed for the Neighbor column | |
7885 | */ | |
7886 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
7887 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7888 | continue; | |
7889 | ||
7890 | if (peer->afc[afi][safi]) { | |
7891 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7892 | if (peer_dynamic_neighbor(peer)) | |
7893 | dn_flag[0] = '*'; | |
7894 | ||
7895 | if (peer->hostname | |
7896 | && bgp_flag_check(bgp, | |
7897 | BGP_FLAG_SHOW_HOSTNAME)) | |
7898 | sprintf(neighbor_buf, "%s%s(%s) ", | |
7899 | dn_flag, peer->hostname, | |
7900 | peer->host); | |
7901 | else | |
7902 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
7903 | peer->host); | |
7904 | ||
7905 | len = strlen(neighbor_buf); | |
7906 | ||
7907 | if (len > max_neighbor_width) | |
7908 | max_neighbor_width = len; | |
7909 | } | |
7910 | } | |
f933309e | 7911 | |
d62a17ae | 7912 | /* Originally we displayed the Neighbor column as 16 |
7913 | * characters wide so make that the default | |
7914 | */ | |
7915 | if (max_neighbor_width < neighbor_col_default_width) | |
7916 | max_neighbor_width = neighbor_col_default_width; | |
7917 | } | |
f933309e | 7918 | |
d62a17ae | 7919 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
7920 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7921 | continue; | |
7922 | ||
ea47320b DL |
7923 | if (!peer->afc[afi][safi]) |
7924 | continue; | |
d62a17ae | 7925 | |
ea47320b DL |
7926 | if (!count) { |
7927 | unsigned long ents; | |
7928 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 7929 | int64_t vrf_id_ui; |
d62a17ae | 7930 | |
a4d82a8a PZ |
7931 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7932 | ? -1 | |
7933 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
7934 | |
7935 | /* Usage summary and header */ | |
7936 | if (use_json) { | |
7937 | json_object_string_add( | |
7938 | json, "routerId", | |
7939 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
7940 | json_object_int_add(json, "as", bgp->as); |
7941 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
7942 | json_object_string_add( |
7943 | json, "vrfName", | |
7944 | (bgp->inst_type | |
7945 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 7946 | ? VRF_DEFAULT_NAME |
ea47320b DL |
7947 | : bgp->name); |
7948 | } else { | |
7949 | vty_out(vty, | |
7950 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 7951 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
7952 | bgp->vrf_id == VRF_UNKNOWN |
7953 | ? -1 | |
7954 | : (int)bgp->vrf_id); | |
ea47320b DL |
7955 | vty_out(vty, "\n"); |
7956 | } | |
d62a17ae | 7957 | |
ea47320b | 7958 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 7959 | if (use_json) { |
ea47320b | 7960 | json_object_int_add( |
60466a63 | 7961 | json, "updateDelayLimit", |
ea47320b | 7962 | bgp->v_update_delay); |
d62a17ae | 7963 | |
ea47320b DL |
7964 | if (bgp->v_update_delay |
7965 | != bgp->v_establish_wait) | |
d62a17ae | 7966 | json_object_int_add( |
7967 | json, | |
ea47320b DL |
7968 | "updateDelayEstablishWait", |
7969 | bgp->v_establish_wait); | |
d62a17ae | 7970 | |
60466a63 | 7971 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
7972 | json_object_string_add( |
7973 | json, | |
7974 | "updateDelayFirstNeighbor", | |
7975 | bgp->update_delay_begin_time); | |
7976 | json_object_boolean_true_add( | |
7977 | json, | |
7978 | "updateDelayInProgress"); | |
7979 | } else { | |
7980 | if (bgp->update_delay_over) { | |
d62a17ae | 7981 | json_object_string_add( |
7982 | json, | |
7983 | "updateDelayFirstNeighbor", | |
7984 | bgp->update_delay_begin_time); | |
ea47320b | 7985 | json_object_string_add( |
d62a17ae | 7986 | json, |
ea47320b DL |
7987 | "updateDelayBestpathResumed", |
7988 | bgp->update_delay_end_time); | |
7989 | json_object_string_add( | |
d62a17ae | 7990 | json, |
ea47320b DL |
7991 | "updateDelayZebraUpdateResume", |
7992 | bgp->update_delay_zebra_resume_time); | |
7993 | json_object_string_add( | |
7994 | json, | |
7995 | "updateDelayPeerUpdateResume", | |
7996 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 7997 | } |
ea47320b DL |
7998 | } |
7999 | } else { | |
8000 | vty_out(vty, | |
8001 | "Read-only mode update-delay limit: %d seconds\n", | |
8002 | bgp->v_update_delay); | |
8003 | if (bgp->v_update_delay | |
8004 | != bgp->v_establish_wait) | |
d62a17ae | 8005 | vty_out(vty, |
ea47320b DL |
8006 | " Establish wait: %d seconds\n", |
8007 | bgp->v_establish_wait); | |
d62a17ae | 8008 | |
60466a63 | 8009 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
8010 | vty_out(vty, |
8011 | " First neighbor established: %s\n", | |
8012 | bgp->update_delay_begin_time); | |
8013 | vty_out(vty, | |
8014 | " Delay in progress\n"); | |
8015 | } else { | |
8016 | if (bgp->update_delay_over) { | |
d62a17ae | 8017 | vty_out(vty, |
8018 | " First neighbor established: %s\n", | |
8019 | bgp->update_delay_begin_time); | |
8020 | vty_out(vty, | |
ea47320b DL |
8021 | " Best-paths resumed: %s\n", |
8022 | bgp->update_delay_end_time); | |
8023 | vty_out(vty, | |
8024 | " zebra update resumed: %s\n", | |
8025 | bgp->update_delay_zebra_resume_time); | |
8026 | vty_out(vty, | |
8027 | " peers update resumed: %s\n", | |
8028 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 8029 | } |
8030 | } | |
8031 | } | |
ea47320b | 8032 | } |
d62a17ae | 8033 | |
ea47320b DL |
8034 | if (use_json) { |
8035 | if (bgp_maxmed_onstartup_configured(bgp) | |
8036 | && bgp->maxmed_active) | |
8037 | json_object_boolean_true_add( | |
60466a63 | 8038 | json, "maxMedOnStartup"); |
ea47320b DL |
8039 | if (bgp->v_maxmed_admin) |
8040 | json_object_boolean_true_add( | |
60466a63 | 8041 | json, "maxMedAdministrative"); |
d62a17ae | 8042 | |
ea47320b DL |
8043 | json_object_int_add( |
8044 | json, "tableVersion", | |
60466a63 | 8045 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 8046 | |
60466a63 QY |
8047 | ents = bgp_table_count(bgp->rib[afi][safi]); |
8048 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
8049 | json_object_int_add( |
8050 | json, "ribMemory", | |
8051 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 8052 | |
210ec2a0 | 8053 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
8054 | json_object_int_add(json, "peerCount", ents); |
8055 | json_object_int_add(json, "peerMemory", | |
8056 | ents * sizeof(struct peer)); | |
d62a17ae | 8057 | |
ea47320b DL |
8058 | if ((ents = listcount(bgp->group))) { |
8059 | json_object_int_add( | |
60466a63 | 8060 | json, "peerGroupCount", ents); |
ea47320b DL |
8061 | json_object_int_add( |
8062 | json, "peerGroupMemory", | |
996c9314 LB |
8063 | ents * sizeof(struct |
8064 | peer_group)); | |
ea47320b | 8065 | } |
d62a17ae | 8066 | |
ea47320b DL |
8067 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8068 | BGP_CONFIG_DAMPENING)) | |
8069 | json_object_boolean_true_add( | |
60466a63 | 8070 | json, "dampeningEnabled"); |
ea47320b DL |
8071 | } else { |
8072 | if (bgp_maxmed_onstartup_configured(bgp) | |
8073 | && bgp->maxmed_active) | |
d62a17ae | 8074 | vty_out(vty, |
ea47320b DL |
8075 | "Max-med on-startup active\n"); |
8076 | if (bgp->v_maxmed_admin) | |
d62a17ae | 8077 | vty_out(vty, |
ea47320b | 8078 | "Max-med administrative active\n"); |
d62a17ae | 8079 | |
60466a63 QY |
8080 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
8081 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 8082 | |
60466a63 | 8083 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
8084 | vty_out(vty, |
8085 | "RIB entries %ld, using %s of memory\n", | |
8086 | ents, | |
996c9314 LB |
8087 | mtype_memstr(memstrbuf, |
8088 | sizeof(memstrbuf), | |
8089 | ents * sizeof(struct | |
8090 | bgp_node))); | |
ea47320b DL |
8091 | |
8092 | /* Peer related usage */ | |
210ec2a0 | 8093 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 8094 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
8095 | ents, |
8096 | mtype_memstr( | |
60466a63 QY |
8097 | memstrbuf, sizeof(memstrbuf), |
8098 | ents * sizeof(struct peer))); | |
ea47320b DL |
8099 | |
8100 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 8101 | vty_out(vty, |
ea47320b | 8102 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 8103 | ents, |
8104 | mtype_memstr( | |
8105 | memstrbuf, | |
8106 | sizeof(memstrbuf), | |
996c9314 LB |
8107 | ents * sizeof(struct |
8108 | peer_group))); | |
d62a17ae | 8109 | |
ea47320b DL |
8110 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8111 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 8112 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 8113 | vty_out(vty, "\n"); |
d62a17ae | 8114 | |
ea47320b DL |
8115 | /* Subtract 8 here because 'Neighbor' is |
8116 | * 8 characters */ | |
8117 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
8118 | vty_out(vty, "%*s", max_neighbor_width - 8, |
8119 | " "); | |
ea47320b DL |
8120 | vty_out(vty, |
8121 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); | |
d62a17ae | 8122 | } |
ea47320b | 8123 | } |
d62a17ae | 8124 | |
ea47320b | 8125 | count++; |
d62a17ae | 8126 | |
ea47320b DL |
8127 | if (use_json) { |
8128 | json_peer = json_object_new_object(); | |
d62a17ae | 8129 | |
b4e9dcba DD |
8130 | if (peer_dynamic_neighbor(peer)) { |
8131 | dn_count++; | |
60466a63 QY |
8132 | json_object_boolean_true_add(json_peer, |
8133 | "dynamicPeer"); | |
b4e9dcba | 8134 | } |
d62a17ae | 8135 | |
ea47320b | 8136 | if (peer->hostname) |
60466a63 | 8137 | json_object_string_add(json_peer, "hostname", |
ea47320b | 8138 | peer->hostname); |
d62a17ae | 8139 | |
ea47320b | 8140 | if (peer->domainname) |
60466a63 QY |
8141 | json_object_string_add(json_peer, "domainname", |
8142 | peer->domainname); | |
d62a17ae | 8143 | |
60466a63 | 8144 | json_object_int_add(json_peer, "remoteAs", peer->as); |
ea47320b | 8145 | json_object_int_add(json_peer, "version", 4); |
60466a63 | 8146 | json_object_int_add(json_peer, "msgRcvd", |
0112e9e0 | 8147 | PEER_TOTAL_RX(peer)); |
60466a63 | 8148 | json_object_int_add(json_peer, "msgSent", |
0112e9e0 | 8149 | PEER_TOTAL_TX(peer)); |
ea47320b DL |
8150 | |
8151 | json_object_int_add(json_peer, "tableVersion", | |
8152 | peer->version[afi][safi]); | |
8153 | json_object_int_add(json_peer, "outq", | |
8154 | peer->obuf->count); | |
8155 | json_object_int_add(json_peer, "inq", 0); | |
60466a63 QY |
8156 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
8157 | use_json, json_peer); | |
50e05855 AD |
8158 | |
8159 | /* | |
8160 | * Adding "pfxRcd" field to match with the corresponding | |
8161 | * CLI. "prefixReceivedCount" will be deprecated in | |
8162 | * future. | |
8163 | */ | |
60466a63 QY |
8164 | json_object_int_add(json_peer, "prefixReceivedCount", |
8165 | peer->pcount[afi][pfx_rcd_safi]); | |
50e05855 AD |
8166 | json_object_int_add(json_peer, "pfxRcd", |
8167 | peer->pcount[afi][pfx_rcd_safi]); | |
8168 | ||
8169 | paf = peer_af_find(peer, afi, pfx_rcd_safi); | |
8170 | if (paf && PAF_SUBGRP(paf)) | |
8171 | json_object_int_add(json_peer, | |
8172 | "pfxSnt", | |
8173 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 8174 | |
ea47320b | 8175 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
60466a63 | 8176 | json_object_string_add(json_peer, "state", |
ea47320b | 8177 | "Idle (Admin)"); |
9199a725 TM |
8178 | else if (peer->afc_recv[afi][safi]) |
8179 | json_object_string_add( | |
8180 | json_peer, "state", | |
8181 | lookup_msg(bgp_status_msg, peer->status, | |
8182 | NULL)); | |
60466a63 QY |
8183 | else if (CHECK_FLAG(peer->sflags, |
8184 | PEER_STATUS_PREFIX_OVERFLOW)) | |
8185 | json_object_string_add(json_peer, "state", | |
ea47320b DL |
8186 | "Idle (PfxCt)"); |
8187 | else | |
8188 | json_object_string_add( | |
8189 | json_peer, "state", | |
60466a63 QY |
8190 | lookup_msg(bgp_status_msg, peer->status, |
8191 | NULL)); | |
ea47320b DL |
8192 | |
8193 | if (peer->conf_if) | |
60466a63 | 8194 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
8195 | "interface"); |
8196 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
8197 | json_object_string_add(json_peer, "idType", |
8198 | "ipv4"); | |
ea47320b | 8199 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
8200 | json_object_string_add(json_peer, "idType", |
8201 | "ipv6"); | |
d62a17ae | 8202 | |
ea47320b DL |
8203 | json_object_object_add(json_peers, peer->host, |
8204 | json_peer); | |
8205 | } else { | |
8206 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8207 | if (peer_dynamic_neighbor(peer)) { | |
8208 | dn_count++; | |
8209 | dn_flag[0] = '*'; | |
8210 | } | |
d62a17ae | 8211 | |
ea47320b | 8212 | if (peer->hostname |
60466a63 | 8213 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
ea47320b | 8214 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
60466a63 | 8215 | peer->hostname, peer->host); |
ea47320b | 8216 | else |
60466a63 | 8217 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
ea47320b DL |
8218 | |
8219 | /* pad the neighbor column with spaces */ | |
8220 | if (len < max_neighbor_width) | |
60466a63 QY |
8221 | vty_out(vty, "%*s", max_neighbor_width - len, |
8222 | " "); | |
ea47320b | 8223 | |
86a55b99 | 8224 | vty_out(vty, "4 %10u %7u %7u %8" PRIu64 " %4d %4zd %8s", |
0112e9e0 QY |
8225 | peer->as, PEER_TOTAL_RX(peer), |
8226 | PEER_TOTAL_TX(peer), peer->version[afi][safi], | |
8227 | 0, peer->obuf->count, | |
d62a17ae | 8228 | peer_uptime(peer->uptime, timebuf, |
ea47320b | 8229 | BGP_UPTIME_LEN, 0, NULL)); |
d62a17ae | 8230 | |
ea47320b | 8231 | if (peer->status == Established) |
2f8f4f10 | 8232 | if (peer->afc_recv[afi][safi]) |
95077abf | 8233 | vty_out(vty, " %12ld", |
a4d82a8a PZ |
8234 | peer->pcount[afi] |
8235 | [pfx_rcd_safi]); | |
95077abf DW |
8236 | else |
8237 | vty_out(vty, " NoNeg"); | |
ea47320b | 8238 | else { |
60466a63 | 8239 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
ea47320b | 8240 | vty_out(vty, " Idle (Admin)"); |
60466a63 QY |
8241 | else if (CHECK_FLAG( |
8242 | peer->sflags, | |
8243 | PEER_STATUS_PREFIX_OVERFLOW)) | |
ea47320b | 8244 | vty_out(vty, " Idle (PfxCt)"); |
d62a17ae | 8245 | else |
ea47320b | 8246 | vty_out(vty, " %12s", |
60466a63 QY |
8247 | lookup_msg(bgp_status_msg, |
8248 | peer->status, NULL)); | |
d62a17ae | 8249 | } |
ea47320b | 8250 | vty_out(vty, "\n"); |
d62a17ae | 8251 | } |
8252 | } | |
f933309e | 8253 | |
d62a17ae | 8254 | if (use_json) { |
8255 | json_object_object_add(json, "peers", json_peers); | |
8256 | ||
8257 | json_object_int_add(json, "totalPeers", count); | |
8258 | json_object_int_add(json, "dynamicPeers", dn_count); | |
8259 | ||
57a9c8a8 DS |
8260 | bgp_show_bestpath_json(bgp, json); |
8261 | ||
996c9314 LB |
8262 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8263 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8264 | json_object_free(json); |
8265 | } else { | |
8266 | if (count) | |
8267 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8268 | else { | |
d6ceaca3 | 8269 | vty_out(vty, "No %s neighbor is configured\n", |
8270 | afi_safi_print(afi, safi)); | |
d62a17ae | 8271 | } |
b05a1c8b | 8272 | |
d6ceaca3 | 8273 | if (dn_count) { |
d62a17ae | 8274 | vty_out(vty, "* - dynamic neighbor\n"); |
8275 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
8276 | dn_count, bgp->dynamic_neighbors_limit); | |
8277 | } | |
8278 | } | |
1ff9a340 | 8279 | |
d62a17ae | 8280 | return CMD_SUCCESS; |
718e3744 | 8281 | } |
8282 | ||
d62a17ae | 8283 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
9f049418 | 8284 | int safi, bool use_json, |
d62a17ae | 8285 | json_object *json) |
8286 | { | |
8287 | int is_first = 1; | |
8288 | int afi_wildcard = (afi == AFI_MAX); | |
8289 | int safi_wildcard = (safi == SAFI_MAX); | |
8290 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 8291 | bool nbr_output = false; |
d62a17ae | 8292 | |
8293 | if (use_json && is_wildcard) | |
8294 | vty_out(vty, "{\n"); | |
8295 | if (afi_wildcard) | |
8296 | afi = 1; /* AFI_IP */ | |
8297 | while (afi < AFI_MAX) { | |
8298 | if (safi_wildcard) | |
8299 | safi = 1; /* SAFI_UNICAST */ | |
8300 | while (safi < SAFI_MAX) { | |
318cac96 | 8301 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 8302 | nbr_output = true; |
d62a17ae | 8303 | if (is_wildcard) { |
8304 | /* | |
8305 | * So limit output to those afi/safi | |
8306 | * pairs that | |
8307 | * actualy have something interesting in | |
8308 | * them | |
8309 | */ | |
8310 | if (use_json) { | |
8311 | json = json_object_new_object(); | |
8312 | ||
8313 | if (!is_first) | |
8314 | vty_out(vty, ",\n"); | |
8315 | else | |
8316 | is_first = 0; | |
8317 | ||
8318 | vty_out(vty, "\"%s\":", | |
8319 | afi_safi_json(afi, | |
8320 | safi)); | |
8321 | } else { | |
8322 | vty_out(vty, "\n%s Summary:\n", | |
8323 | afi_safi_print(afi, | |
8324 | safi)); | |
8325 | } | |
8326 | } | |
8327 | bgp_show_summary(vty, bgp, afi, safi, use_json, | |
8328 | json); | |
8329 | } | |
8330 | safi++; | |
d62a17ae | 8331 | if (!safi_wildcard) |
8332 | safi = SAFI_MAX; | |
8333 | } | |
8334 | afi++; | |
ee851c8c | 8335 | if (!afi_wildcard) |
d62a17ae | 8336 | afi = AFI_MAX; |
8337 | } | |
8338 | ||
8339 | if (use_json && is_wildcard) | |
8340 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
8341 | else if (!nbr_output) { |
8342 | if (use_json) | |
8343 | vty_out(vty, "{}\n"); | |
8344 | else | |
8345 | vty_out(vty, "%% No BGP neighbors found\n"); | |
8346 | } | |
d62a17ae | 8347 | } |
8348 | ||
8349 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
9f049418 | 8350 | safi_t safi, bool use_json) |
d62a17ae | 8351 | { |
8352 | struct listnode *node, *nnode; | |
8353 | struct bgp *bgp; | |
8354 | json_object *json = NULL; | |
8355 | int is_first = 1; | |
9f049418 | 8356 | bool nbr_output = false; |
d62a17ae | 8357 | |
8358 | if (use_json) | |
8359 | vty_out(vty, "{\n"); | |
8360 | ||
8361 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 8362 | nbr_output = true; |
d62a17ae | 8363 | if (use_json) { |
8364 | json = json_object_new_object(); | |
8365 | ||
8366 | if (!is_first) | |
8367 | vty_out(vty, ",\n"); | |
8368 | else | |
8369 | is_first = 0; | |
8370 | ||
8371 | vty_out(vty, "\"%s\":", | |
8372 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8373 | ? VRF_DEFAULT_NAME |
d62a17ae | 8374 | : bgp->name); |
8375 | } else { | |
8376 | vty_out(vty, "\nInstance %s:\n", | |
8377 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8378 | ? VRF_DEFAULT_NAME |
d62a17ae | 8379 | : bgp->name); |
8380 | } | |
8381 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, json); | |
8382 | } | |
8383 | ||
8384 | if (use_json) | |
8385 | vty_out(vty, "}\n"); | |
9f049418 DS |
8386 | else if (!nbr_output) |
8387 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 8388 | } |
8389 | ||
8390 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
9f049418 | 8391 | safi_t safi, bool use_json) |
d62a17ae | 8392 | { |
8393 | struct bgp *bgp; | |
8394 | ||
8395 | if (name) { | |
8396 | if (strmatch(name, "all")) { | |
8397 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
8398 | use_json); | |
8399 | return CMD_SUCCESS; | |
8400 | } else { | |
8401 | bgp = bgp_lookup_by_name(name); | |
8402 | ||
8403 | if (!bgp) { | |
8404 | if (use_json) | |
8405 | vty_out(vty, "{}\n"); | |
8406 | else | |
8407 | vty_out(vty, | |
ca61fd25 | 8408 | "%% BGP instance not found\n"); |
d62a17ae | 8409 | return CMD_WARNING; |
8410 | } | |
8411 | ||
8412 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, | |
8413 | NULL); | |
8414 | return CMD_SUCCESS; | |
8415 | } | |
8416 | } | |
8417 | ||
8418 | bgp = bgp_get_default(); | |
8419 | ||
8420 | if (bgp) | |
8421 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, NULL); | |
9f049418 | 8422 | else { |
ca61fd25 DS |
8423 | if (use_json) |
8424 | vty_out(vty, "{}\n"); | |
8425 | else | |
8426 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
8427 | return CMD_WARNING; |
8428 | } | |
d62a17ae | 8429 | |
8430 | return CMD_SUCCESS; | |
4fb25c53 DW |
8431 | } |
8432 | ||
716b2d8a | 8433 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 8434 | DEFUN (show_ip_bgp_summary, |
718e3744 | 8435 | show_ip_bgp_summary_cmd, |
dd6bd0f1 | 8436 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [json]", |
718e3744 | 8437 | SHOW_STR |
8438 | IP_STR | |
8439 | BGP_STR | |
8386ac43 | 8440 | BGP_INSTANCE_HELP_STR |
46f296b4 | 8441 | BGP_AFI_HELP_STR |
dd6bd0f1 | 8442 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 8443 | "Summary of BGP neighbor status\n" |
9973d184 | 8444 | JSON_STR) |
718e3744 | 8445 | { |
d62a17ae | 8446 | char *vrf = NULL; |
8447 | afi_t afi = AFI_MAX; | |
8448 | safi_t safi = SAFI_MAX; | |
8449 | ||
8450 | int idx = 0; | |
8451 | ||
8452 | /* show [ip] bgp */ | |
8453 | if (argv_find(argv, argc, "ip", &idx)) | |
8454 | afi = AFI_IP; | |
9a8bdf1c PG |
8455 | /* [<vrf> VIEWVRFNAME] */ |
8456 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8457 | vrf = argv[idx + 1]->arg; | |
8458 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8459 | vrf = NULL; | |
8460 | } else if (argv_find(argv, argc, "view", &idx)) | |
8461 | /* [<view> VIEWVRFNAME] */ | |
8462 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 8463 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8464 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
8465 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8466 | } | |
8467 | ||
9f049418 | 8468 | bool uj = use_json(argc, argv); |
d62a17ae | 8469 | |
8470 | return bgp_show_summary_vty(vty, vrf, afi, safi, uj); | |
8471 | } | |
8472 | ||
8473 | const char *afi_safi_print(afi_t afi, safi_t safi) | |
8474 | { | |
8475 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8476 | return "IPv4 Unicast"; | |
8477 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8478 | return "IPv4 Multicast"; | |
8479 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8480 | return "IPv4 Labeled Unicast"; | |
8481 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8482 | return "IPv4 VPN"; | |
8483 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8484 | return "IPv4 Encap"; | |
7c40bf39 | 8485 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8486 | return "IPv4 Flowspec"; | |
d62a17ae | 8487 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8488 | return "IPv6 Unicast"; | |
8489 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8490 | return "IPv6 Multicast"; | |
8491 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8492 | return "IPv6 Labeled Unicast"; | |
8493 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8494 | return "IPv6 VPN"; | |
8495 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8496 | return "IPv6 Encap"; | |
7c40bf39 | 8497 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8498 | return "IPv6 Flowspec"; | |
d62a17ae | 8499 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8500 | return "L2VPN EVPN"; | |
8501 | else | |
8502 | return "Unknown"; | |
538621f2 | 8503 | } |
8504 | ||
b9f77ec8 DS |
8505 | /* |
8506 | * Please note that we have intentionally camelCased | |
8507 | * the return strings here. So if you want | |
8508 | * to use this function, please ensure you | |
8509 | * are doing this within json output | |
8510 | */ | |
d62a17ae | 8511 | const char *afi_safi_json(afi_t afi, safi_t safi) |
8512 | { | |
8513 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8514 | return "ipv4Unicast"; | |
8515 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8516 | return "ipv4Multicast"; | |
8517 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8518 | return "ipv4LabeledUnicast"; | |
8519 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8520 | return "ipv4Vpn"; | |
8521 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8522 | return "ipv4Encap"; | |
7c40bf39 | 8523 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8524 | return "ipv4Flowspec"; | |
d62a17ae | 8525 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8526 | return "ipv6Unicast"; | |
8527 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8528 | return "ipv6Multicast"; | |
8529 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8530 | return "ipv6LabeledUnicast"; | |
8531 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8532 | return "ipv6Vpn"; | |
8533 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8534 | return "ipv6Encap"; | |
7c40bf39 | 8535 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8536 | return "ipv6Flowspec"; | |
d62a17ae | 8537 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8538 | return "l2VpnEvpn"; | |
8539 | else | |
8540 | return "Unknown"; | |
27162734 LB |
8541 | } |
8542 | ||
718e3744 | 8543 | /* Show BGP peer's information. */ |
d1927ebe | 8544 | enum show_type { show_all, show_peer, show_ipv4_all, show_ipv6_all, show_ipv4_peer, show_ipv6_peer }; |
d62a17ae | 8545 | |
8546 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
8547 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
8548 | uint16_t adv_smcap, uint16_t adv_rmcap, |
8549 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 8550 | bool use_json, json_object *json_pref) |
d62a17ae | 8551 | { |
8552 | /* Send-Mode */ | |
8553 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8554 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
8555 | if (use_json) { | |
8556 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8557 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8558 | json_object_string_add(json_pref, "sendMode", | |
8559 | "advertisedAndReceived"); | |
8560 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8561 | json_object_string_add(json_pref, "sendMode", | |
8562 | "advertised"); | |
8563 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8564 | json_object_string_add(json_pref, "sendMode", | |
8565 | "received"); | |
8566 | } else { | |
8567 | vty_out(vty, " Send-mode: "); | |
8568 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8569 | vty_out(vty, "advertised"); | |
8570 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8571 | vty_out(vty, "%sreceived", | |
8572 | CHECK_FLAG(p->af_cap[afi][safi], | |
8573 | adv_smcap) | |
8574 | ? ", " | |
8575 | : ""); | |
8576 | vty_out(vty, "\n"); | |
8577 | } | |
8578 | } | |
8579 | ||
8580 | /* Receive-Mode */ | |
8581 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8582 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
8583 | if (use_json) { | |
8584 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8585 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8586 | json_object_string_add(json_pref, "recvMode", | |
8587 | "advertisedAndReceived"); | |
8588 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8589 | json_object_string_add(json_pref, "recvMode", | |
8590 | "advertised"); | |
8591 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8592 | json_object_string_add(json_pref, "recvMode", | |
8593 | "received"); | |
8594 | } else { | |
8595 | vty_out(vty, " Receive-mode: "); | |
8596 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8597 | vty_out(vty, "advertised"); | |
8598 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8599 | vty_out(vty, "%sreceived", | |
8600 | CHECK_FLAG(p->af_cap[afi][safi], | |
8601 | adv_rmcap) | |
8602 | ? ", " | |
8603 | : ""); | |
8604 | vty_out(vty, "\n"); | |
8605 | } | |
8606 | } | |
8607 | } | |
8608 | ||
8609 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, | |
9f049418 | 8610 | safi_t safi, bool use_json, |
d62a17ae | 8611 | json_object *json_neigh) |
8612 | { | |
0291c246 MK |
8613 | struct bgp_filter *filter; |
8614 | struct peer_af *paf; | |
8615 | char orf_pfx_name[BUFSIZ]; | |
8616 | int orf_pfx_count; | |
8617 | json_object *json_af = NULL; | |
8618 | json_object *json_prefA = NULL; | |
8619 | json_object *json_prefB = NULL; | |
8620 | json_object *json_addr = NULL; | |
d62a17ae | 8621 | |
8622 | if (use_json) { | |
8623 | json_addr = json_object_new_object(); | |
8624 | json_af = json_object_new_object(); | |
8625 | filter = &p->filter[afi][safi]; | |
8626 | ||
8627 | if (peer_group_active(p)) | |
8628 | json_object_string_add(json_addr, "peerGroupMember", | |
8629 | p->group->name); | |
8630 | ||
8631 | paf = peer_af_find(p, afi, safi); | |
8632 | if (paf && PAF_SUBGRP(paf)) { | |
8633 | json_object_int_add(json_addr, "updateGroupId", | |
8634 | PAF_UPDGRP(paf)->id); | |
8635 | json_object_int_add(json_addr, "subGroupId", | |
8636 | PAF_SUBGRP(paf)->id); | |
8637 | json_object_int_add(json_addr, "packetQueueLength", | |
8638 | bpacket_queue_virtual_length(paf)); | |
8639 | } | |
8640 | ||
8641 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8642 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8643 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8644 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8645 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8646 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8647 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8648 | json_object_int_add(json_af, "orfType", | |
8649 | ORF_TYPE_PREFIX); | |
8650 | json_prefA = json_object_new_object(); | |
8651 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
8652 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
8653 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8654 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8655 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
8656 | use_json, json_prefA); | |
8657 | json_object_object_add(json_af, "orfPrefixList", | |
8658 | json_prefA); | |
8659 | } | |
8660 | ||
8661 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8662 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8663 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8664 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8665 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8666 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8667 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8668 | json_object_int_add(json_af, "orfOldType", | |
8669 | ORF_TYPE_PREFIX_OLD); | |
8670 | json_prefB = json_object_new_object(); | |
8671 | bgp_show_peer_afi_orf_cap( | |
8672 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8673 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8674 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8675 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
8676 | json_prefB); | |
8677 | json_object_object_add(json_af, "orfOldPrefixList", | |
8678 | json_prefB); | |
8679 | } | |
8680 | ||
8681 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8682 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8683 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8684 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8685 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8686 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8687 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8688 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8689 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8690 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8691 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8692 | json_object_object_add(json_addr, "afDependentCap", | |
8693 | json_af); | |
8694 | else | |
8695 | json_object_free(json_af); | |
8696 | ||
8697 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8698 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8699 | NULL, afi, orf_pfx_name, use_json); | |
8700 | ||
8701 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8702 | PEER_STATUS_ORF_PREFIX_SEND) | |
8703 | || orf_pfx_count) { | |
8704 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8705 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8706 | json_object_boolean_true_add(json_neigh, | |
8707 | "orfSent"); | |
8708 | if (orf_pfx_count) | |
8709 | json_object_int_add(json_addr, "orfRecvCounter", | |
8710 | orf_pfx_count); | |
8711 | } | |
8712 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8713 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8714 | json_object_string_add( | |
8715 | json_addr, "orfFirstUpdate", | |
8716 | "deferredUntilORFOrRouteRefreshRecvd"); | |
8717 | ||
8718 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8719 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8720 | json_object_boolean_true_add(json_addr, | |
8721 | "routeReflectorClient"); | |
8722 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8723 | PEER_FLAG_RSERVER_CLIENT)) | |
8724 | json_object_boolean_true_add(json_addr, | |
8725 | "routeServerClient"); | |
8726 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8727 | json_object_boolean_true_add(json_addr, | |
8728 | "inboundSoftConfigPermit"); | |
8729 | ||
8730 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8731 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8732 | json_object_boolean_true_add( | |
8733 | json_addr, | |
8734 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
8735 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8736 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8737 | json_object_boolean_true_add( | |
8738 | json_addr, | |
8739 | "privateAsNumsReplacedInUpdatesToNbr"); | |
8740 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8741 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8742 | json_object_boolean_true_add( | |
8743 | json_addr, | |
8744 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
8745 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8746 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8747 | json_object_boolean_true_add( | |
8748 | json_addr, | |
8749 | "privateAsNumsRemovedInUpdatesToNbr"); | |
8750 | ||
dcc68b5e MS |
8751 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
8752 | json_object_boolean_true_add( | |
8753 | json_addr, | |
8754 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
8755 | ->type_json_name); | |
d62a17ae | 8756 | |
8757 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8758 | json_object_string_add(json_addr, | |
8759 | "overrideASNsInOutboundUpdates", | |
8760 | "ifAspathEqualRemoteAs"); | |
8761 | ||
8762 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8763 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8764 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8765 | json_object_boolean_true_add(json_addr, | |
8766 | "routerAlwaysNextHop"); | |
8767 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8768 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8769 | json_object_boolean_true_add( | |
8770 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
8771 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8772 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
8773 | json_object_boolean_true_add( | |
8774 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
8775 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
8776 | json_object_boolean_true_add( | |
8777 | json_addr, "unchangedMedPropogatedToNbr"); | |
8778 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
8779 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8780 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
8781 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8782 | PEER_FLAG_SEND_COMMUNITY) | |
8783 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8784 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8785 | json_object_string_add(json_addr, | |
8786 | "commAttriSentToNbr", | |
8787 | "extendedAndStandard"); | |
8788 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8789 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8790 | json_object_string_add(json_addr, | |
8791 | "commAttriSentToNbr", | |
8792 | "extended"); | |
8793 | else | |
8794 | json_object_string_add(json_addr, | |
8795 | "commAttriSentToNbr", | |
8796 | "standard"); | |
8797 | } | |
8798 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8799 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
8800 | if (p->default_rmap[afi][safi].name) | |
8801 | json_object_string_add( | |
8802 | json_addr, "defaultRouteMap", | |
8803 | p->default_rmap[afi][safi].name); | |
8804 | ||
8805 | if (paf && PAF_SUBGRP(paf) | |
8806 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
8807 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
8808 | json_object_boolean_true_add(json_addr, | |
8809 | "defaultSent"); | |
8810 | else | |
8811 | json_object_boolean_true_add(json_addr, | |
8812 | "defaultNotSent"); | |
8813 | } | |
8814 | ||
dff8f48d | 8815 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 8816 | if (is_evpn_enabled()) |
60466a63 QY |
8817 | json_object_boolean_true_add( |
8818 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
8819 | } |
8820 | ||
d62a17ae | 8821 | if (filter->plist[FILTER_IN].name |
8822 | || filter->dlist[FILTER_IN].name | |
8823 | || filter->aslist[FILTER_IN].name | |
8824 | || filter->map[RMAP_IN].name) | |
8825 | json_object_boolean_true_add(json_addr, | |
8826 | "inboundPathPolicyConfig"); | |
8827 | if (filter->plist[FILTER_OUT].name | |
8828 | || filter->dlist[FILTER_OUT].name | |
8829 | || filter->aslist[FILTER_OUT].name | |
8830 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
8831 | json_object_boolean_true_add( | |
8832 | json_addr, "outboundPathPolicyConfig"); | |
8833 | ||
8834 | /* prefix-list */ | |
8835 | if (filter->plist[FILTER_IN].name) | |
8836 | json_object_string_add(json_addr, | |
8837 | "incomingUpdatePrefixFilterList", | |
8838 | filter->plist[FILTER_IN].name); | |
8839 | if (filter->plist[FILTER_OUT].name) | |
8840 | json_object_string_add(json_addr, | |
8841 | "outgoingUpdatePrefixFilterList", | |
8842 | filter->plist[FILTER_OUT].name); | |
8843 | ||
8844 | /* distribute-list */ | |
8845 | if (filter->dlist[FILTER_IN].name) | |
8846 | json_object_string_add( | |
8847 | json_addr, "incomingUpdateNetworkFilterList", | |
8848 | filter->dlist[FILTER_IN].name); | |
8849 | if (filter->dlist[FILTER_OUT].name) | |
8850 | json_object_string_add( | |
8851 | json_addr, "outgoingUpdateNetworkFilterList", | |
8852 | filter->dlist[FILTER_OUT].name); | |
8853 | ||
8854 | /* filter-list. */ | |
8855 | if (filter->aslist[FILTER_IN].name) | |
8856 | json_object_string_add(json_addr, | |
8857 | "incomingUpdateAsPathFilterList", | |
8858 | filter->aslist[FILTER_IN].name); | |
8859 | if (filter->aslist[FILTER_OUT].name) | |
8860 | json_object_string_add(json_addr, | |
8861 | "outgoingUpdateAsPathFilterList", | |
8862 | filter->aslist[FILTER_OUT].name); | |
8863 | ||
8864 | /* route-map. */ | |
8865 | if (filter->map[RMAP_IN].name) | |
8866 | json_object_string_add( | |
8867 | json_addr, "routeMapForIncomingAdvertisements", | |
8868 | filter->map[RMAP_IN].name); | |
8869 | if (filter->map[RMAP_OUT].name) | |
8870 | json_object_string_add( | |
8871 | json_addr, "routeMapForOutgoingAdvertisements", | |
8872 | filter->map[RMAP_OUT].name); | |
8873 | ||
9dac9fc8 DA |
8874 | /* ebgp-requires-policy (inbound) */ |
8875 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
8876 | && !bgp_inbound_policy_exists(p, filter)) | |
8877 | json_object_string_add( | |
8878 | json_addr, "inboundEbgpRequiresPolicy", | |
8879 | "Inbound updates discarded due to missing policy"); | |
8880 | ||
8881 | /* ebgp-requires-policy (outbound) */ | |
8882 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
8883 | && (!bgp_outbound_policy_exists(p, filter))) | |
8884 | json_object_string_add( | |
8885 | json_addr, "outboundEbgpRequiresPolicy", | |
8886 | "Outbound updates discarded due to missing policy"); | |
8887 | ||
d62a17ae | 8888 | /* unsuppress-map */ |
8889 | if (filter->usmap.name) | |
8890 | json_object_string_add(json_addr, | |
8891 | "selectiveUnsuppressRouteMap", | |
8892 | filter->usmap.name); | |
8893 | ||
8894 | /* Receive prefix count */ | |
8895 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
8896 | p->pcount[afi][safi]); | |
50e05855 AD |
8897 | if (paf && PAF_SUBGRP(paf)) |
8898 | json_object_int_add(json_addr, "sentPrefixCounter", | |
8899 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 8900 | |
8901 | /* Maximum prefix */ | |
8902 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
8903 | json_object_int_add(json_addr, "prefixAllowedMax", | |
8904 | p->pmax[afi][safi]); | |
8905 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8906 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
8907 | json_object_boolean_true_add( | |
8908 | json_addr, "prefixAllowedMaxWarning"); | |
8909 | json_object_int_add(json_addr, | |
8910 | "prefixAllowedWarningThresh", | |
8911 | p->pmax_threshold[afi][safi]); | |
8912 | if (p->pmax_restart[afi][safi]) | |
8913 | json_object_int_add( | |
8914 | json_addr, | |
8915 | "prefixAllowedRestartIntervalMsecs", | |
8916 | p->pmax_restart[afi][safi] * 60000); | |
8917 | } | |
8918 | json_object_object_add(json_neigh, afi_safi_print(afi, safi), | |
8919 | json_addr); | |
8920 | ||
8921 | } else { | |
8922 | filter = &p->filter[afi][safi]; | |
8923 | ||
8924 | vty_out(vty, " For address family: %s\n", | |
8925 | afi_safi_print(afi, safi)); | |
8926 | ||
8927 | if (peer_group_active(p)) | |
8928 | vty_out(vty, " %s peer-group member\n", | |
8929 | p->group->name); | |
8930 | ||
8931 | paf = peer_af_find(p, afi, safi); | |
8932 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
8933 | vty_out(vty, " Update group %" PRIu64 |
8934 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 8935 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
8936 | vty_out(vty, " Packet Queue length %d\n", | |
8937 | bpacket_queue_virtual_length(paf)); | |
8938 | } else { | |
8939 | vty_out(vty, " Not part of any update group\n"); | |
8940 | } | |
8941 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8942 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8943 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8944 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8945 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8946 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8947 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8948 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8949 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8950 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8951 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8952 | vty_out(vty, " AF-dependant capabilities:\n"); | |
8953 | ||
8954 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8955 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8956 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8957 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8958 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8959 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8960 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8961 | vty_out(vty, | |
8962 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8963 | ORF_TYPE_PREFIX); | |
8964 | bgp_show_peer_afi_orf_cap( | |
8965 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8966 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8967 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8968 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
8969 | } | |
8970 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8971 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8972 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8973 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8974 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8975 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8976 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8977 | vty_out(vty, | |
8978 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8979 | ORF_TYPE_PREFIX_OLD); | |
8980 | bgp_show_peer_afi_orf_cap( | |
8981 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8982 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8983 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8984 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
8985 | } | |
8986 | ||
8987 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8988 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8989 | NULL, afi, orf_pfx_name, use_json); | |
8990 | ||
8991 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8992 | PEER_STATUS_ORF_PREFIX_SEND) | |
8993 | || orf_pfx_count) { | |
8994 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
8995 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8996 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8997 | vty_out(vty, " sent;"); | |
8998 | if (orf_pfx_count) | |
8999 | vty_out(vty, " received (%d entries)", | |
9000 | orf_pfx_count); | |
9001 | vty_out(vty, "\n"); | |
9002 | } | |
9003 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
9004 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
9005 | vty_out(vty, | |
9006 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
9007 | ||
9008 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9009 | PEER_FLAG_REFLECTOR_CLIENT)) | |
9010 | vty_out(vty, " Route-Reflector Client\n"); | |
9011 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9012 | PEER_FLAG_RSERVER_CLIENT)) | |
9013 | vty_out(vty, " Route-Server Client\n"); | |
9014 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
9015 | vty_out(vty, | |
9016 | " Inbound soft reconfiguration allowed\n"); | |
9017 | ||
9018 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9019 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
9020 | vty_out(vty, | |
9021 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
9022 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9023 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
9024 | vty_out(vty, | |
9025 | " Private AS numbers replaced in updates to this neighbor\n"); | |
9026 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9027 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
9028 | vty_out(vty, | |
9029 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
9030 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9031 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
9032 | vty_out(vty, | |
9033 | " Private AS numbers removed in updates to this neighbor\n"); | |
9034 | ||
dcc68b5e MS |
9035 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
9036 | vty_out(vty, " %s\n", | |
9037 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
9038 | ->human_description); | |
d62a17ae | 9039 | |
9040 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
9041 | vty_out(vty, | |
9042 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
9043 | ||
9044 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
9045 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9046 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
9047 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
9048 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9049 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
9050 | vty_out(vty, | |
9051 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
9052 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9053 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
9054 | vty_out(vty, | |
9055 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
9056 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
9057 | vty_out(vty, | |
9058 | " MED is propagated unchanged to this neighbor\n"); | |
9059 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
9060 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9061 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
9062 | || CHECK_FLAG(p->af_flags[afi][safi], | |
9063 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
9064 | vty_out(vty, | |
9065 | " Community attribute sent to this neighbor"); | |
9066 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9067 | PEER_FLAG_SEND_COMMUNITY) | |
9068 | && CHECK_FLAG(p->af_flags[afi][safi], | |
9069 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
9070 | && CHECK_FLAG(p->af_flags[afi][safi], | |
9071 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
9072 | vty_out(vty, "(all)\n"); | |
9073 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9074 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
9075 | vty_out(vty, "(large)\n"); | |
9076 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9077 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
9078 | vty_out(vty, "(extended)\n"); | |
9079 | else | |
9080 | vty_out(vty, "(standard)\n"); | |
9081 | } | |
9082 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9083 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
9084 | vty_out(vty, " Default information originate,"); | |
9085 | ||
9086 | if (p->default_rmap[afi][safi].name) | |
9087 | vty_out(vty, " default route-map %s%s,", | |
9088 | p->default_rmap[afi][safi].map ? "*" | |
9089 | : "", | |
9090 | p->default_rmap[afi][safi].name); | |
9091 | if (paf && PAF_SUBGRP(paf) | |
9092 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
9093 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
9094 | vty_out(vty, " default sent\n"); | |
9095 | else | |
9096 | vty_out(vty, " default not sent\n"); | |
9097 | } | |
9098 | ||
dff8f48d MK |
9099 | /* advertise-vni-all */ |
9100 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 9101 | if (is_evpn_enabled()) |
dff8f48d MK |
9102 | vty_out(vty, " advertise-all-vni\n"); |
9103 | } | |
9104 | ||
d62a17ae | 9105 | if (filter->plist[FILTER_IN].name |
9106 | || filter->dlist[FILTER_IN].name | |
9107 | || filter->aslist[FILTER_IN].name | |
9108 | || filter->map[RMAP_IN].name) | |
9109 | vty_out(vty, " Inbound path policy configured\n"); | |
9110 | if (filter->plist[FILTER_OUT].name | |
9111 | || filter->dlist[FILTER_OUT].name | |
9112 | || filter->aslist[FILTER_OUT].name | |
9113 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
9114 | vty_out(vty, " Outbound path policy configured\n"); | |
9115 | ||
9116 | /* prefix-list */ | |
9117 | if (filter->plist[FILTER_IN].name) | |
9118 | vty_out(vty, | |
9119 | " Incoming update prefix filter list is %s%s\n", | |
9120 | filter->plist[FILTER_IN].plist ? "*" : "", | |
9121 | filter->plist[FILTER_IN].name); | |
9122 | if (filter->plist[FILTER_OUT].name) | |
9123 | vty_out(vty, | |
9124 | " Outgoing update prefix filter list is %s%s\n", | |
9125 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
9126 | filter->plist[FILTER_OUT].name); | |
9127 | ||
9128 | /* distribute-list */ | |
9129 | if (filter->dlist[FILTER_IN].name) | |
9130 | vty_out(vty, | |
9131 | " Incoming update network filter list is %s%s\n", | |
9132 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
9133 | filter->dlist[FILTER_IN].name); | |
9134 | if (filter->dlist[FILTER_OUT].name) | |
9135 | vty_out(vty, | |
9136 | " Outgoing update network filter list is %s%s\n", | |
9137 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
9138 | filter->dlist[FILTER_OUT].name); | |
9139 | ||
9140 | /* filter-list. */ | |
9141 | if (filter->aslist[FILTER_IN].name) | |
9142 | vty_out(vty, | |
9143 | " Incoming update AS path filter list is %s%s\n", | |
9144 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
9145 | filter->aslist[FILTER_IN].name); | |
9146 | if (filter->aslist[FILTER_OUT].name) | |
9147 | vty_out(vty, | |
9148 | " Outgoing update AS path filter list is %s%s\n", | |
9149 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
9150 | filter->aslist[FILTER_OUT].name); | |
9151 | ||
9152 | /* route-map. */ | |
9153 | if (filter->map[RMAP_IN].name) | |
9154 | vty_out(vty, | |
9155 | " Route map for incoming advertisements is %s%s\n", | |
9156 | filter->map[RMAP_IN].map ? "*" : "", | |
9157 | filter->map[RMAP_IN].name); | |
9158 | if (filter->map[RMAP_OUT].name) | |
9159 | vty_out(vty, | |
9160 | " Route map for outgoing advertisements is %s%s\n", | |
9161 | filter->map[RMAP_OUT].map ? "*" : "", | |
9162 | filter->map[RMAP_OUT].name); | |
9163 | ||
9dac9fc8 DA |
9164 | /* ebgp-requires-policy (inbound) */ |
9165 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9166 | && !bgp_inbound_policy_exists(p, filter)) | |
9167 | vty_out(vty, | |
9168 | " Inbound updates discarded due to missing policy\n"); | |
9169 | ||
9170 | /* ebgp-requires-policy (outbound) */ | |
9171 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9172 | && !bgp_outbound_policy_exists(p, filter)) | |
9173 | vty_out(vty, | |
9174 | " Outbound updates discarded due to missing policy\n"); | |
9175 | ||
d62a17ae | 9176 | /* unsuppress-map */ |
9177 | if (filter->usmap.name) | |
9178 | vty_out(vty, | |
9179 | " Route map for selective unsuppress is %s%s\n", | |
9180 | filter->usmap.map ? "*" : "", | |
9181 | filter->usmap.name); | |
9182 | ||
9183 | /* Receive prefix count */ | |
9184 | vty_out(vty, " %ld accepted prefixes\n", p->pcount[afi][safi]); | |
9185 | ||
9186 | /* Maximum prefix */ | |
9187 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
9188 | vty_out(vty, " Maximum prefixes allowed %ld%s\n", | |
9189 | p->pmax[afi][safi], | |
9190 | CHECK_FLAG(p->af_flags[afi][safi], | |
9191 | PEER_FLAG_MAX_PREFIX_WARNING) | |
9192 | ? " (warning-only)" | |
9193 | : ""); | |
9194 | vty_out(vty, " Threshold for warning message %d%%", | |
9195 | p->pmax_threshold[afi][safi]); | |
9196 | if (p->pmax_restart[afi][safi]) | |
9197 | vty_out(vty, ", restart interval %d min", | |
9198 | p->pmax_restart[afi][safi]); | |
9199 | vty_out(vty, "\n"); | |
9200 | } | |
9201 | ||
9202 | vty_out(vty, "\n"); | |
9203 | } | |
9204 | } | |
9205 | ||
9f049418 | 9206 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 9207 | json_object *json) |
718e3744 | 9208 | { |
d62a17ae | 9209 | struct bgp *bgp; |
9210 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
9211 | char timebuf[BGP_UPTIME_LEN]; | |
9212 | char dn_flag[2]; | |
9213 | const char *subcode_str; | |
9214 | const char *code_str; | |
9215 | afi_t afi; | |
9216 | safi_t safi; | |
d7c0a89a QY |
9217 | uint16_t i; |
9218 | uint8_t *msg; | |
d62a17ae | 9219 | json_object *json_neigh = NULL; |
9220 | time_t epoch_tbuf; | |
718e3744 | 9221 | |
d62a17ae | 9222 | bgp = p->bgp; |
9223 | ||
9224 | if (use_json) | |
9225 | json_neigh = json_object_new_object(); | |
9226 | ||
9227 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9228 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
9229 | dn_flag[0] = '*'; | |
9230 | ||
9231 | if (!use_json) { | |
9232 | if (p->conf_if) /* Configured interface name. */ | |
9233 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
9234 | BGP_PEER_SU_UNSPEC(p) | |
9235 | ? "None" | |
9236 | : sockunion2str(&p->su, buf, | |
9237 | SU_ADDRSTRLEN)); | |
9238 | else /* Configured IP address. */ | |
9239 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
9240 | p->host); | |
9241 | } | |
9242 | ||
9243 | if (use_json) { | |
9244 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
9245 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
9246 | "none"); | |
9247 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
9248 | json_object_string_add( | |
9249 | json_neigh, "bgpNeighborAddr", | |
9250 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
9251 | ||
9252 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
9253 | ||
9254 | if (p->change_local_as) | |
9255 | json_object_int_add(json_neigh, "localAs", | |
9256 | p->change_local_as); | |
9257 | else | |
9258 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
9259 | ||
9260 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
9261 | json_object_boolean_true_add(json_neigh, | |
9262 | "localAsNoPrepend"); | |
9263 | ||
9264 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
9265 | json_object_boolean_true_add(json_neigh, | |
9266 | "localAsReplaceAs"); | |
9267 | } else { | |
9268 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
9269 | || (p->as_type == AS_INTERNAL)) | |
9270 | vty_out(vty, "remote AS %u, ", p->as); | |
9271 | else | |
9272 | vty_out(vty, "remote AS Unspecified, "); | |
9273 | vty_out(vty, "local AS %u%s%s, ", | |
9274 | p->change_local_as ? p->change_local_as : p->local_as, | |
9275 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
9276 | ? " no-prepend" | |
9277 | : "", | |
9278 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
9279 | ? " replace-as" | |
9280 | : ""); | |
9281 | } | |
faa16034 DS |
9282 | /* peer type internal or confed-internal */ |
9283 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 9284 | if (use_json) { |
9285 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9286 | json_object_boolean_true_add( | |
9287 | json_neigh, "nbrConfedInternalLink"); | |
9288 | else | |
9289 | json_object_boolean_true_add(json_neigh, | |
9290 | "nbrInternalLink"); | |
9291 | } else { | |
9292 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9293 | vty_out(vty, "confed-internal link\n"); | |
9294 | else | |
9295 | vty_out(vty, "internal link\n"); | |
9296 | } | |
faa16034 DS |
9297 | /* peer type external or confed-external */ |
9298 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 9299 | if (use_json) { |
9300 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9301 | json_object_boolean_true_add( | |
9302 | json_neigh, "nbrConfedExternalLink"); | |
9303 | else | |
9304 | json_object_boolean_true_add(json_neigh, | |
9305 | "nbrExternalLink"); | |
9306 | } else { | |
9307 | if (bgp_confederation_peers_check(bgp, p->as)) | |
9308 | vty_out(vty, "confed-external link\n"); | |
9309 | else | |
9310 | vty_out(vty, "external link\n"); | |
9311 | } | |
faa16034 DS |
9312 | } else { |
9313 | if (use_json) | |
9314 | json_object_boolean_true_add(json_neigh, | |
9315 | "nbrUnspecifiedLink"); | |
9316 | else | |
9317 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 9318 | } |
9319 | ||
9320 | /* Description. */ | |
9321 | if (p->desc) { | |
9322 | if (use_json) | |
9323 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
9324 | else | |
9325 | vty_out(vty, " Description: %s\n", p->desc); | |
9326 | } | |
9327 | ||
9328 | if (p->hostname) { | |
9329 | if (use_json) { | |
9330 | if (p->hostname) | |
9331 | json_object_string_add(json_neigh, "hostname", | |
9332 | p->hostname); | |
9333 | ||
9334 | if (p->domainname) | |
9335 | json_object_string_add(json_neigh, "domainname", | |
9336 | p->domainname); | |
9337 | } else { | |
9338 | if (p->domainname && (p->domainname[0] != '\0')) | |
9339 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
9340 | p->domainname); | |
9341 | else | |
9342 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
9343 | } | |
9344 | } | |
9345 | ||
9346 | /* Peer-group */ | |
9347 | if (p->group) { | |
9348 | if (use_json) { | |
9349 | json_object_string_add(json_neigh, "peerGroup", | |
9350 | p->group->name); | |
9351 | ||
9352 | if (dn_flag[0]) { | |
9353 | struct prefix prefix, *range = NULL; | |
9354 | ||
9355 | sockunion2hostprefix(&(p->su), &prefix); | |
9356 | range = peer_group_lookup_dynamic_neighbor_range( | |
9357 | p->group, &prefix); | |
9358 | ||
9359 | if (range) { | |
9360 | prefix2str(range, buf1, sizeof(buf1)); | |
9361 | json_object_string_add( | |
9362 | json_neigh, | |
9363 | "peerSubnetRangeGroup", buf1); | |
9364 | } | |
9365 | } | |
9366 | } else { | |
9367 | vty_out(vty, | |
9368 | " Member of peer-group %s for session parameters\n", | |
9369 | p->group->name); | |
9370 | ||
9371 | if (dn_flag[0]) { | |
9372 | struct prefix prefix, *range = NULL; | |
9373 | ||
9374 | sockunion2hostprefix(&(p->su), &prefix); | |
9375 | range = peer_group_lookup_dynamic_neighbor_range( | |
9376 | p->group, &prefix); | |
9377 | ||
9378 | if (range) { | |
9379 | prefix2str(range, buf1, sizeof(buf1)); | |
9380 | vty_out(vty, | |
9381 | " Belongs to the subnet range group: %s\n", | |
9382 | buf1); | |
9383 | } | |
9384 | } | |
9385 | } | |
9386 | } | |
9387 | ||
9388 | if (use_json) { | |
9389 | /* Administrative shutdown. */ | |
9390 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9391 | json_object_boolean_true_add(json_neigh, | |
9392 | "adminShutDown"); | |
9393 | ||
9394 | /* BGP Version. */ | |
9395 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
9396 | json_object_string_add( | |
9397 | json_neigh, "remoteRouterId", | |
9398 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
9399 | json_object_string_add( |
9400 | json_neigh, "localRouterId", | |
9401 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9402 | sizeof(buf1))); | |
d62a17ae | 9403 | |
9404 | /* Confederation */ | |
9405 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9406 | && bgp_confederation_peers_check(bgp, p->as)) | |
9407 | json_object_boolean_true_add(json_neigh, | |
9408 | "nbrCommonAdmin"); | |
9409 | ||
9410 | /* Status. */ | |
9411 | json_object_string_add( | |
9412 | json_neigh, "bgpState", | |
9413 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9414 | ||
9415 | if (p->status == Established) { | |
9416 | time_t uptime; | |
d62a17ae | 9417 | |
9418 | uptime = bgp_clock(); | |
9419 | uptime -= p->uptime; | |
d62a17ae | 9420 | epoch_tbuf = time(NULL) - uptime; |
9421 | ||
bee57a7a | 9422 | #if CONFDATE > 20200101 |
a4d82a8a PZ |
9423 | CPP_NOTICE( |
9424 | "bgpTimerUp should be deprecated and can be removed now"); | |
d3c7efed DS |
9425 | #endif |
9426 | /* | |
9427 | * bgpTimerUp was miliseconds that was accurate | |
9428 | * up to 1 day, then the value returned | |
9429 | * became garbage. So in order to provide | |
9430 | * some level of backwards compatability, | |
9431 | * we still provde the data, but now | |
9432 | * we are returning the correct value | |
9433 | * and also adding a new bgpTimerUpMsec | |
9434 | * which will allow us to deprecate | |
9435 | * this eventually | |
9436 | */ | |
d62a17ae | 9437 | json_object_int_add(json_neigh, "bgpTimerUp", |
e0330274 | 9438 | uptime * 1000); |
d3c7efed DS |
9439 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
9440 | uptime * 1000); | |
d62a17ae | 9441 | json_object_string_add(json_neigh, "bgpTimerUpString", |
9442 | peer_uptime(p->uptime, timebuf, | |
9443 | BGP_UPTIME_LEN, 0, | |
9444 | NULL)); | |
9445 | json_object_int_add(json_neigh, | |
9446 | "bgpTimerUpEstablishedEpoch", | |
9447 | epoch_tbuf); | |
9448 | } | |
9449 | ||
9450 | else if (p->status == Active) { | |
9451 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9452 | json_object_string_add(json_neigh, "bgpStateIs", | |
9453 | "passive"); | |
9454 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9455 | json_object_string_add(json_neigh, "bgpStateIs", | |
9456 | "passiveNSF"); | |
9457 | } | |
9458 | ||
9459 | /* read timer */ | |
9460 | time_t uptime; | |
9461 | struct tm *tm; | |
9462 | ||
9463 | uptime = bgp_clock(); | |
9464 | uptime -= p->readtime; | |
9465 | tm = gmtime(&uptime); | |
9466 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
9467 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9468 | + (tm->tm_hour * 3600000)); | |
9469 | ||
9470 | uptime = bgp_clock(); | |
9471 | uptime -= p->last_write; | |
9472 | tm = gmtime(&uptime); | |
9473 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
9474 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9475 | + (tm->tm_hour * 3600000)); | |
9476 | ||
9477 | uptime = bgp_clock(); | |
9478 | uptime -= p->update_time; | |
9479 | tm = gmtime(&uptime); | |
9480 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
9481 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9482 | + (tm->tm_hour * 3600000)); | |
9483 | ||
9484 | /* Configured timer values. */ | |
9485 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
9486 | p->v_holdtime * 1000); | |
9487 | json_object_int_add(json_neigh, | |
9488 | "bgpTimerKeepAliveIntervalMsecs", | |
9489 | p->v_keepalive * 1000); | |
b90a8e13 | 9490 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9491 | json_object_int_add(json_neigh, |
9492 | "bgpTimerConfiguredHoldTimeMsecs", | |
9493 | p->holdtime * 1000); | |
9494 | json_object_int_add( | |
9495 | json_neigh, | |
9496 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9497 | p->keepalive * 1000); | |
d25e4efc | 9498 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9499 | || (bgp->default_keepalive |
9500 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9501 | json_object_int_add(json_neigh, |
9502 | "bgpTimerConfiguredHoldTimeMsecs", | |
9503 | bgp->default_holdtime); | |
9504 | json_object_int_add( | |
9505 | json_neigh, | |
9506 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9507 | bgp->default_keepalive); | |
d62a17ae | 9508 | } |
9509 | } else { | |
9510 | /* Administrative shutdown. */ | |
9511 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9512 | vty_out(vty, " Administratively shut down\n"); | |
9513 | ||
9514 | /* BGP Version. */ | |
9515 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 9516 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 9517 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
9518 | vty_out(vty, ", local router ID %s\n", |
9519 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9520 | sizeof(buf1))); | |
d62a17ae | 9521 | |
9522 | /* Confederation */ | |
9523 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9524 | && bgp_confederation_peers_check(bgp, p->as)) | |
9525 | vty_out(vty, | |
9526 | " Neighbor under common administration\n"); | |
9527 | ||
9528 | /* Status. */ | |
9529 | vty_out(vty, " BGP state = %s", | |
9530 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9531 | ||
9532 | if (p->status == Established) | |
9533 | vty_out(vty, ", up for %8s", | |
9534 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
9535 | 0, NULL)); | |
9536 | ||
9537 | else if (p->status == Active) { | |
9538 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9539 | vty_out(vty, " (passive)"); | |
9540 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9541 | vty_out(vty, " (NSF passive)"); | |
9542 | } | |
9543 | vty_out(vty, "\n"); | |
9544 | ||
9545 | /* read timer */ | |
9546 | vty_out(vty, " Last read %s", | |
9547 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
9548 | NULL)); | |
9549 | vty_out(vty, ", Last write %s\n", | |
9550 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
9551 | NULL)); | |
9552 | ||
9553 | /* Configured timer values. */ | |
9554 | vty_out(vty, | |
9555 | " Hold time is %d, keepalive interval is %d seconds\n", | |
9556 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 9557 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9558 | vty_out(vty, " Configured hold time is %d", |
9559 | p->holdtime); | |
9560 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9561 | p->keepalive); | |
d25e4efc | 9562 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9563 | || (bgp->default_keepalive |
9564 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9565 | vty_out(vty, " Configured hold time is %d", |
9566 | bgp->default_holdtime); | |
9567 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9568 | bgp->default_keepalive); | |
d62a17ae | 9569 | } |
9570 | } | |
9571 | /* Capability. */ | |
9572 | if (p->status == Established) { | |
9573 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
9574 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
9575 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
9576 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
9577 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
9578 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
9579 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
9580 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
9581 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
9582 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
9583 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
9584 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 9585 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
9586 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 9587 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
9588 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 9589 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
9590 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 9591 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
9592 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
9593 | if (use_json) { | |
9594 | json_object *json_cap = NULL; | |
9595 | ||
9596 | json_cap = json_object_new_object(); | |
9597 | ||
9598 | /* AS4 */ | |
9599 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9600 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9601 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
9602 | && CHECK_FLAG(p->cap, | |
9603 | PEER_CAP_AS4_RCV)) | |
9604 | json_object_string_add( | |
9605 | json_cap, "4byteAs", | |
9606 | "advertisedAndReceived"); | |
9607 | else if (CHECK_FLAG(p->cap, | |
9608 | PEER_CAP_AS4_ADV)) | |
9609 | json_object_string_add( | |
9610 | json_cap, "4byteAs", | |
9611 | "advertised"); | |
9612 | else if (CHECK_FLAG(p->cap, | |
9613 | PEER_CAP_AS4_RCV)) | |
9614 | json_object_string_add( | |
9615 | json_cap, "4byteAs", | |
9616 | "received"); | |
9617 | } | |
9618 | ||
9619 | /* AddPath */ | |
9620 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9621 | || CHECK_FLAG(p->cap, | |
9622 | PEER_CAP_ADDPATH_ADV)) { | |
9623 | json_object *json_add = NULL; | |
9624 | const char *print_store; | |
9625 | ||
9626 | json_add = json_object_new_object(); | |
9627 | ||
05c7a1cc QY |
9628 | FOREACH_AFI_SAFI (afi, safi) { |
9629 | json_object *json_sub = NULL; | |
9630 | json_sub = | |
9631 | json_object_new_object(); | |
9632 | print_store = afi_safi_print( | |
9633 | afi, safi); | |
d62a17ae | 9634 | |
05c7a1cc QY |
9635 | if (CHECK_FLAG( |
9636 | p->af_cap[afi] | |
9637 | [safi], | |
9638 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9639 | || CHECK_FLAG( | |
9640 | p->af_cap[afi] | |
9641 | [safi], | |
9642 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 9643 | if (CHECK_FLAG( |
9644 | p->af_cap | |
9645 | [afi] | |
9646 | [safi], | |
9647 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 9648 | && CHECK_FLAG( |
d62a17ae | 9649 | p->af_cap |
9650 | [afi] | |
9651 | [safi], | |
05c7a1cc QY |
9652 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
9653 | json_object_boolean_true_add( | |
9654 | json_sub, | |
9655 | "txAdvertisedAndReceived"); | |
9656 | else if ( | |
9657 | CHECK_FLAG( | |
9658 | p->af_cap | |
9659 | [afi] | |
9660 | [safi], | |
9661 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
9662 | json_object_boolean_true_add( | |
9663 | json_sub, | |
9664 | "txAdvertised"); | |
9665 | else if ( | |
9666 | CHECK_FLAG( | |
9667 | p->af_cap | |
9668 | [afi] | |
9669 | [safi], | |
9670 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
9671 | json_object_boolean_true_add( | |
9672 | json_sub, | |
9673 | "txReceived"); | |
9674 | } | |
d62a17ae | 9675 | |
05c7a1cc QY |
9676 | if (CHECK_FLAG( |
9677 | p->af_cap[afi] | |
9678 | [safi], | |
9679 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9680 | || CHECK_FLAG( | |
9681 | p->af_cap[afi] | |
9682 | [safi], | |
9683 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 9684 | if (CHECK_FLAG( |
9685 | p->af_cap | |
9686 | [afi] | |
9687 | [safi], | |
9688 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 9689 | && CHECK_FLAG( |
d62a17ae | 9690 | p->af_cap |
9691 | [afi] | |
9692 | [safi], | |
9693 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
9694 | json_object_boolean_true_add( |
9695 | json_sub, | |
9696 | "rxAdvertisedAndReceived"); | |
9697 | else if ( | |
9698 | CHECK_FLAG( | |
9699 | p->af_cap | |
9700 | [afi] | |
9701 | [safi], | |
9702 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
9703 | json_object_boolean_true_add( | |
9704 | json_sub, | |
9705 | "rxAdvertised"); | |
9706 | else if ( | |
9707 | CHECK_FLAG( | |
9708 | p->af_cap | |
9709 | [afi] | |
9710 | [safi], | |
9711 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9712 | json_object_boolean_true_add( | |
9713 | json_sub, | |
9714 | "rxReceived"); | |
d62a17ae | 9715 | } |
9716 | ||
05c7a1cc QY |
9717 | if (CHECK_FLAG( |
9718 | p->af_cap[afi] | |
9719 | [safi], | |
9720 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9721 | || CHECK_FLAG( | |
9722 | p->af_cap[afi] | |
9723 | [safi], | |
9724 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
9725 | || CHECK_FLAG( | |
9726 | p->af_cap[afi] | |
9727 | [safi], | |
9728 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9729 | || CHECK_FLAG( | |
9730 | p->af_cap[afi] | |
9731 | [safi], | |
9732 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9733 | json_object_object_add( | |
9734 | json_add, | |
9735 | print_store, | |
9736 | json_sub); | |
9737 | else | |
9738 | json_object_free( | |
9739 | json_sub); | |
9740 | } | |
9741 | ||
d62a17ae | 9742 | json_object_object_add( |
9743 | json_cap, "addPath", json_add); | |
9744 | } | |
9745 | ||
9746 | /* Dynamic */ | |
9747 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
9748 | || CHECK_FLAG(p->cap, | |
9749 | PEER_CAP_DYNAMIC_ADV)) { | |
9750 | if (CHECK_FLAG(p->cap, | |
9751 | PEER_CAP_DYNAMIC_ADV) | |
9752 | && CHECK_FLAG(p->cap, | |
9753 | PEER_CAP_DYNAMIC_RCV)) | |
9754 | json_object_string_add( | |
9755 | json_cap, "dynamic", | |
9756 | "advertisedAndReceived"); | |
9757 | else if (CHECK_FLAG( | |
9758 | p->cap, | |
9759 | PEER_CAP_DYNAMIC_ADV)) | |
9760 | json_object_string_add( | |
9761 | json_cap, "dynamic", | |
9762 | "advertised"); | |
9763 | else if (CHECK_FLAG( | |
9764 | p->cap, | |
9765 | PEER_CAP_DYNAMIC_RCV)) | |
9766 | json_object_string_add( | |
9767 | json_cap, "dynamic", | |
9768 | "received"); | |
9769 | } | |
9770 | ||
9771 | /* Extended nexthop */ | |
9772 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
9773 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
9774 | json_object *json_nxt = NULL; | |
9775 | const char *print_store; | |
9776 | ||
9777 | ||
9778 | if (CHECK_FLAG(p->cap, | |
9779 | PEER_CAP_ENHE_ADV) | |
9780 | && CHECK_FLAG(p->cap, | |
9781 | PEER_CAP_ENHE_RCV)) | |
9782 | json_object_string_add( | |
9783 | json_cap, | |
9784 | "extendedNexthop", | |
9785 | "advertisedAndReceived"); | |
9786 | else if (CHECK_FLAG(p->cap, | |
9787 | PEER_CAP_ENHE_ADV)) | |
9788 | json_object_string_add( | |
9789 | json_cap, | |
9790 | "extendedNexthop", | |
9791 | "advertised"); | |
9792 | else if (CHECK_FLAG(p->cap, | |
9793 | PEER_CAP_ENHE_RCV)) | |
9794 | json_object_string_add( | |
9795 | json_cap, | |
9796 | "extendedNexthop", | |
9797 | "received"); | |
9798 | ||
9799 | if (CHECK_FLAG(p->cap, | |
9800 | PEER_CAP_ENHE_RCV)) { | |
9801 | json_nxt = | |
9802 | json_object_new_object(); | |
9803 | ||
9804 | for (safi = SAFI_UNICAST; | |
9805 | safi < SAFI_MAX; safi++) { | |
9806 | if (CHECK_FLAG( | |
9807 | p->af_cap | |
9808 | [AFI_IP] | |
9809 | [safi], | |
9810 | PEER_CAP_ENHE_AF_RCV)) { | |
9811 | print_store = afi_safi_print( | |
9812 | AFI_IP, | |
9813 | safi); | |
9814 | json_object_string_add( | |
9815 | json_nxt, | |
9816 | print_store, | |
54f29523 | 9817 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 9818 | } |
9819 | } | |
9820 | json_object_object_add( | |
9821 | json_cap, | |
9822 | "extendedNexthopFamililesByPeer", | |
9823 | json_nxt); | |
9824 | } | |
9825 | } | |
9826 | ||
9827 | /* Route Refresh */ | |
9828 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
9829 | || CHECK_FLAG(p->cap, | |
9830 | PEER_CAP_REFRESH_NEW_RCV) | |
9831 | || CHECK_FLAG(p->cap, | |
9832 | PEER_CAP_REFRESH_OLD_RCV)) { | |
9833 | if (CHECK_FLAG(p->cap, | |
9834 | PEER_CAP_REFRESH_ADV) | |
9835 | && (CHECK_FLAG( | |
9836 | p->cap, | |
9837 | PEER_CAP_REFRESH_NEW_RCV) | |
9838 | || CHECK_FLAG( | |
9839 | p->cap, | |
9840 | PEER_CAP_REFRESH_OLD_RCV))) { | |
9841 | if (CHECK_FLAG( | |
9842 | p->cap, | |
9843 | PEER_CAP_REFRESH_OLD_RCV) | |
9844 | && CHECK_FLAG( | |
9845 | p->cap, | |
9846 | PEER_CAP_REFRESH_NEW_RCV)) | |
9847 | json_object_string_add( | |
9848 | json_cap, | |
9849 | "routeRefresh", | |
9850 | "advertisedAndReceivedOldNew"); | |
9851 | else { | |
9852 | if (CHECK_FLAG( | |
9853 | p->cap, | |
9854 | PEER_CAP_REFRESH_OLD_RCV)) | |
9855 | json_object_string_add( | |
9856 | json_cap, | |
9857 | "routeRefresh", | |
9858 | "advertisedAndReceivedOld"); | |
9859 | else | |
9860 | json_object_string_add( | |
9861 | json_cap, | |
9862 | "routeRefresh", | |
9863 | "advertisedAndReceivedNew"); | |
9864 | } | |
9865 | } else if ( | |
9866 | CHECK_FLAG( | |
9867 | p->cap, | |
9868 | PEER_CAP_REFRESH_ADV)) | |
9869 | json_object_string_add( | |
9870 | json_cap, | |
9871 | "routeRefresh", | |
9872 | "advertised"); | |
9873 | else if ( | |
9874 | CHECK_FLAG( | |
9875 | p->cap, | |
9876 | PEER_CAP_REFRESH_NEW_RCV) | |
9877 | || CHECK_FLAG( | |
9878 | p->cap, | |
9879 | PEER_CAP_REFRESH_OLD_RCV)) | |
9880 | json_object_string_add( | |
9881 | json_cap, | |
9882 | "routeRefresh", | |
9883 | "received"); | |
9884 | } | |
9885 | ||
9886 | /* Multiprotocol Extensions */ | |
9887 | json_object *json_multi = NULL; | |
9888 | json_multi = json_object_new_object(); | |
9889 | ||
05c7a1cc QY |
9890 | FOREACH_AFI_SAFI (afi, safi) { |
9891 | if (p->afc_adv[afi][safi] | |
9892 | || p->afc_recv[afi][safi]) { | |
9893 | json_object *json_exten = NULL; | |
9894 | json_exten = | |
9895 | json_object_new_object(); | |
9896 | ||
d62a17ae | 9897 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
9898 | && p->afc_recv[afi][safi]) |
9899 | json_object_boolean_true_add( | |
9900 | json_exten, | |
9901 | "advertisedAndReceived"); | |
9902 | else if (p->afc_adv[afi][safi]) | |
9903 | json_object_boolean_true_add( | |
9904 | json_exten, | |
9905 | "advertised"); | |
9906 | else if (p->afc_recv[afi][safi]) | |
9907 | json_object_boolean_true_add( | |
9908 | json_exten, | |
9909 | "received"); | |
d62a17ae | 9910 | |
05c7a1cc QY |
9911 | json_object_object_add( |
9912 | json_multi, | |
9913 | afi_safi_print(afi, | |
9914 | safi), | |
9915 | json_exten); | |
d62a17ae | 9916 | } |
9917 | } | |
9918 | json_object_object_add( | |
9919 | json_cap, "multiprotocolExtensions", | |
9920 | json_multi); | |
9921 | ||
d77114b7 | 9922 | /* Hostname capabilities */ |
60466a63 | 9923 | json_object *json_hname = NULL; |
d77114b7 MK |
9924 | |
9925 | json_hname = json_object_new_object(); | |
9926 | ||
9927 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
9928 | json_object_string_add( | |
60466a63 QY |
9929 | json_hname, "advHostName", |
9930 | bgp->peer_self->hostname | |
9931 | ? bgp->peer_self | |
9932 | ->hostname | |
d77114b7 MK |
9933 | : "n/a"); |
9934 | json_object_string_add( | |
60466a63 QY |
9935 | json_hname, "advDomainName", |
9936 | bgp->peer_self->domainname | |
9937 | ? bgp->peer_self | |
9938 | ->domainname | |
d77114b7 MK |
9939 | : "n/a"); |
9940 | } | |
9941 | ||
9942 | ||
9943 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
9944 | json_object_string_add( | |
60466a63 QY |
9945 | json_hname, "rcvHostName", |
9946 | p->hostname ? p->hostname | |
9947 | : "n/a"); | |
d77114b7 | 9948 | json_object_string_add( |
60466a63 QY |
9949 | json_hname, "rcvDomainName", |
9950 | p->domainname ? p->domainname | |
9951 | : "n/a"); | |
d77114b7 MK |
9952 | } |
9953 | ||
60466a63 | 9954 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
9955 | json_hname); |
9956 | ||
d62a17ae | 9957 | /* Gracefull Restart */ |
9958 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
9959 | || CHECK_FLAG(p->cap, | |
9960 | PEER_CAP_RESTART_ADV)) { | |
9961 | if (CHECK_FLAG(p->cap, | |
9962 | PEER_CAP_RESTART_ADV) | |
9963 | && CHECK_FLAG(p->cap, | |
9964 | PEER_CAP_RESTART_RCV)) | |
9965 | json_object_string_add( | |
9966 | json_cap, | |
9967 | "gracefulRestart", | |
9968 | "advertisedAndReceived"); | |
9969 | else if (CHECK_FLAG( | |
9970 | p->cap, | |
9971 | PEER_CAP_RESTART_ADV)) | |
9972 | json_object_string_add( | |
9973 | json_cap, | |
9974 | "gracefulRestartCapability", | |
9975 | "advertised"); | |
9976 | else if (CHECK_FLAG( | |
9977 | p->cap, | |
9978 | PEER_CAP_RESTART_RCV)) | |
9979 | json_object_string_add( | |
9980 | json_cap, | |
9981 | "gracefulRestartCapability", | |
9982 | "received"); | |
9983 | ||
9984 | if (CHECK_FLAG(p->cap, | |
9985 | PEER_CAP_RESTART_RCV)) { | |
9986 | int restart_af_count = 0; | |
9987 | json_object *json_restart = | |
9988 | NULL; | |
9989 | json_restart = | |
9990 | json_object_new_object(); | |
9991 | ||
9992 | json_object_int_add( | |
9993 | json_cap, | |
9994 | "gracefulRestartRemoteTimerMsecs", | |
9995 | p->v_gr_restart * 1000); | |
9996 | ||
05c7a1cc QY |
9997 | FOREACH_AFI_SAFI (afi, safi) { |
9998 | if (CHECK_FLAG( | |
9999 | p->af_cap | |
10000 | [afi] | |
10001 | [safi], | |
10002 | PEER_CAP_RESTART_AF_RCV)) { | |
10003 | json_object * | |
10004 | json_sub = | |
10005 | NULL; | |
10006 | json_sub = | |
10007 | json_object_new_object(); | |
10008 | ||
d62a17ae | 10009 | if (CHECK_FLAG( |
10010 | p->af_cap | |
10011 | [afi] | |
10012 | [safi], | |
05c7a1cc QY |
10013 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
10014 | json_object_boolean_true_add( | |
10015 | json_sub, | |
10016 | "preserved"); | |
10017 | restart_af_count++; | |
10018 | json_object_object_add( | |
10019 | json_restart, | |
10020 | afi_safi_print( | |
10021 | afi, | |
10022 | safi), | |
10023 | json_sub); | |
d62a17ae | 10024 | } |
10025 | } | |
10026 | if (!restart_af_count) { | |
10027 | json_object_string_add( | |
10028 | json_cap, | |
10029 | "addressFamiliesByPeer", | |
10030 | "none"); | |
10031 | json_object_free( | |
10032 | json_restart); | |
10033 | } else | |
10034 | json_object_object_add( | |
10035 | json_cap, | |
10036 | "addressFamiliesByPeer", | |
10037 | json_restart); | |
10038 | } | |
10039 | } | |
10040 | json_object_object_add(json_neigh, | |
10041 | "neighborCapabilities", | |
10042 | json_cap); | |
10043 | } else { | |
10044 | vty_out(vty, " Neighbor capabilities:\n"); | |
10045 | ||
10046 | /* AS4 */ | |
10047 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
10048 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
10049 | vty_out(vty, " 4 Byte AS:"); | |
10050 | if (CHECK_FLAG(p->cap, | |
10051 | PEER_CAP_AS4_ADV)) | |
10052 | vty_out(vty, " advertised"); | |
10053 | if (CHECK_FLAG(p->cap, | |
10054 | PEER_CAP_AS4_RCV)) | |
10055 | vty_out(vty, " %sreceived", | |
10056 | CHECK_FLAG( | |
10057 | p->cap, | |
10058 | PEER_CAP_AS4_ADV) | |
10059 | ? "and " | |
10060 | : ""); | |
10061 | vty_out(vty, "\n"); | |
10062 | } | |
10063 | ||
10064 | /* AddPath */ | |
10065 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
10066 | || CHECK_FLAG(p->cap, | |
10067 | PEER_CAP_ADDPATH_ADV)) { | |
10068 | vty_out(vty, " AddPath:\n"); | |
10069 | ||
05c7a1cc QY |
10070 | FOREACH_AFI_SAFI (afi, safi) { |
10071 | if (CHECK_FLAG( | |
10072 | p->af_cap[afi] | |
10073 | [safi], | |
10074 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10075 | || CHECK_FLAG( | |
10076 | p->af_cap[afi] | |
10077 | [safi], | |
10078 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
10079 | vty_out(vty, | |
10080 | " %s: TX ", | |
10081 | afi_safi_print( | |
10082 | afi, | |
10083 | safi)); | |
10084 | ||
d62a17ae | 10085 | if (CHECK_FLAG( |
10086 | p->af_cap | |
10087 | [afi] | |
10088 | [safi], | |
05c7a1cc | 10089 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 10090 | vty_out(vty, |
05c7a1cc | 10091 | "advertised %s", |
d62a17ae | 10092 | afi_safi_print( |
10093 | afi, | |
10094 | safi)); | |
10095 | ||
05c7a1cc QY |
10096 | if (CHECK_FLAG( |
10097 | p->af_cap | |
10098 | [afi] | |
10099 | [safi], | |
10100 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
10101 | vty_out(vty, | |
10102 | "%sreceived", | |
10103 | CHECK_FLAG( | |
10104 | p->af_cap | |
10105 | [afi] | |
10106 | [safi], | |
10107 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10108 | ? " and " | |
10109 | : ""); | |
d62a17ae | 10110 | |
05c7a1cc QY |
10111 | vty_out(vty, "\n"); |
10112 | } | |
d62a17ae | 10113 | |
05c7a1cc QY |
10114 | if (CHECK_FLAG( |
10115 | p->af_cap[afi] | |
10116 | [safi], | |
10117 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10118 | || CHECK_FLAG( | |
10119 | p->af_cap[afi] | |
10120 | [safi], | |
10121 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
10122 | vty_out(vty, | |
10123 | " %s: RX ", | |
10124 | afi_safi_print( | |
10125 | afi, | |
10126 | safi)); | |
d62a17ae | 10127 | |
10128 | if (CHECK_FLAG( | |
10129 | p->af_cap | |
10130 | [afi] | |
10131 | [safi], | |
05c7a1cc | 10132 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 10133 | vty_out(vty, |
05c7a1cc | 10134 | "advertised %s", |
d62a17ae | 10135 | afi_safi_print( |
10136 | afi, | |
10137 | safi)); | |
10138 | ||
05c7a1cc QY |
10139 | if (CHECK_FLAG( |
10140 | p->af_cap | |
10141 | [afi] | |
10142 | [safi], | |
10143 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 10144 | vty_out(vty, |
05c7a1cc QY |
10145 | "%sreceived", |
10146 | CHECK_FLAG( | |
10147 | p->af_cap | |
10148 | [afi] | |
10149 | [safi], | |
10150 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10151 | ? " and " | |
10152 | : ""); | |
10153 | ||
10154 | vty_out(vty, "\n"); | |
d62a17ae | 10155 | } |
05c7a1cc | 10156 | } |
d62a17ae | 10157 | } |
10158 | ||
10159 | /* Dynamic */ | |
10160 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
10161 | || CHECK_FLAG(p->cap, | |
10162 | PEER_CAP_DYNAMIC_ADV)) { | |
10163 | vty_out(vty, " Dynamic:"); | |
10164 | if (CHECK_FLAG(p->cap, | |
10165 | PEER_CAP_DYNAMIC_ADV)) | |
10166 | vty_out(vty, " advertised"); | |
10167 | if (CHECK_FLAG(p->cap, | |
10168 | PEER_CAP_DYNAMIC_RCV)) | |
10169 | vty_out(vty, " %sreceived", | |
10170 | CHECK_FLAG( | |
10171 | p->cap, | |
10172 | PEER_CAP_DYNAMIC_ADV) | |
10173 | ? "and " | |
10174 | : ""); | |
10175 | vty_out(vty, "\n"); | |
10176 | } | |
10177 | ||
10178 | /* Extended nexthop */ | |
10179 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
10180 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
10181 | vty_out(vty, " Extended nexthop:"); | |
10182 | if (CHECK_FLAG(p->cap, | |
10183 | PEER_CAP_ENHE_ADV)) | |
10184 | vty_out(vty, " advertised"); | |
10185 | if (CHECK_FLAG(p->cap, | |
10186 | PEER_CAP_ENHE_RCV)) | |
10187 | vty_out(vty, " %sreceived", | |
10188 | CHECK_FLAG( | |
10189 | p->cap, | |
10190 | PEER_CAP_ENHE_ADV) | |
10191 | ? "and " | |
10192 | : ""); | |
10193 | vty_out(vty, "\n"); | |
10194 | ||
10195 | if (CHECK_FLAG(p->cap, | |
10196 | PEER_CAP_ENHE_RCV)) { | |
10197 | vty_out(vty, | |
10198 | " Address families by peer:\n "); | |
10199 | for (safi = SAFI_UNICAST; | |
10200 | safi < SAFI_MAX; safi++) | |
10201 | if (CHECK_FLAG( | |
10202 | p->af_cap | |
10203 | [AFI_IP] | |
10204 | [safi], | |
10205 | PEER_CAP_ENHE_AF_RCV)) | |
10206 | vty_out(vty, | |
10207 | " %s\n", | |
10208 | afi_safi_print( | |
10209 | AFI_IP, | |
10210 | safi)); | |
10211 | } | |
10212 | } | |
10213 | ||
10214 | /* Route Refresh */ | |
10215 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
10216 | || CHECK_FLAG(p->cap, | |
10217 | PEER_CAP_REFRESH_NEW_RCV) | |
10218 | || CHECK_FLAG(p->cap, | |
10219 | PEER_CAP_REFRESH_OLD_RCV)) { | |
10220 | vty_out(vty, " Route refresh:"); | |
10221 | if (CHECK_FLAG(p->cap, | |
10222 | PEER_CAP_REFRESH_ADV)) | |
10223 | vty_out(vty, " advertised"); | |
10224 | if (CHECK_FLAG(p->cap, | |
10225 | PEER_CAP_REFRESH_NEW_RCV) | |
10226 | || CHECK_FLAG( | |
10227 | p->cap, | |
10228 | PEER_CAP_REFRESH_OLD_RCV)) | |
10229 | vty_out(vty, " %sreceived(%s)", | |
10230 | CHECK_FLAG( | |
10231 | p->cap, | |
10232 | PEER_CAP_REFRESH_ADV) | |
10233 | ? "and " | |
10234 | : "", | |
10235 | (CHECK_FLAG( | |
10236 | p->cap, | |
10237 | PEER_CAP_REFRESH_OLD_RCV) | |
10238 | && CHECK_FLAG( | |
10239 | p->cap, | |
10240 | PEER_CAP_REFRESH_NEW_RCV)) | |
10241 | ? "old & new" | |
10242 | : CHECK_FLAG( | |
10243 | p->cap, | |
10244 | PEER_CAP_REFRESH_OLD_RCV) | |
10245 | ? "old" | |
10246 | : "new"); | |
10247 | ||
10248 | vty_out(vty, "\n"); | |
10249 | } | |
10250 | ||
10251 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
10252 | FOREACH_AFI_SAFI (afi, safi) |
10253 | if (p->afc_adv[afi][safi] | |
10254 | || p->afc_recv[afi][safi]) { | |
10255 | vty_out(vty, | |
10256 | " Address Family %s:", | |
10257 | afi_safi_print(afi, | |
10258 | safi)); | |
10259 | if (p->afc_adv[afi][safi]) | |
d62a17ae | 10260 | vty_out(vty, |
05c7a1cc QY |
10261 | " advertised"); |
10262 | if (p->afc_recv[afi][safi]) | |
10263 | vty_out(vty, | |
10264 | " %sreceived", | |
10265 | p->afc_adv[afi] | |
10266 | [safi] | |
10267 | ? "and " | |
10268 | : ""); | |
10269 | vty_out(vty, "\n"); | |
10270 | } | |
d62a17ae | 10271 | |
10272 | /* Hostname capability */ | |
60466a63 | 10273 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
10274 | |
10275 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
10276 | vty_out(vty, |
10277 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
10278 | bgp->peer_self->hostname |
10279 | ? bgp->peer_self | |
10280 | ->hostname | |
d77114b7 | 10281 | : "n/a", |
60466a63 QY |
10282 | bgp->peer_self->domainname |
10283 | ? bgp->peer_self | |
10284 | ->domainname | |
d77114b7 MK |
10285 | : "n/a"); |
10286 | } else { | |
10287 | vty_out(vty, " not advertised"); | |
d62a17ae | 10288 | } |
10289 | ||
d77114b7 | 10290 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
10291 | vty_out(vty, |
10292 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
10293 | p->hostname ? p->hostname |
10294 | : "n/a", | |
10295 | p->domainname ? p->domainname | |
10296 | : "n/a"); | |
d77114b7 MK |
10297 | } else { |
10298 | vty_out(vty, " not received"); | |
10299 | } | |
10300 | ||
10301 | vty_out(vty, "\n"); | |
10302 | ||
d62a17ae | 10303 | /* Gracefull Restart */ |
10304 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
10305 | || CHECK_FLAG(p->cap, | |
10306 | PEER_CAP_RESTART_ADV)) { | |
10307 | vty_out(vty, | |
10308 | " Graceful Restart Capabilty:"); | |
10309 | if (CHECK_FLAG(p->cap, | |
10310 | PEER_CAP_RESTART_ADV)) | |
10311 | vty_out(vty, " advertised"); | |
10312 | if (CHECK_FLAG(p->cap, | |
10313 | PEER_CAP_RESTART_RCV)) | |
10314 | vty_out(vty, " %sreceived", | |
10315 | CHECK_FLAG( | |
10316 | p->cap, | |
10317 | PEER_CAP_RESTART_ADV) | |
10318 | ? "and " | |
10319 | : ""); | |
10320 | vty_out(vty, "\n"); | |
10321 | ||
10322 | if (CHECK_FLAG(p->cap, | |
10323 | PEER_CAP_RESTART_RCV)) { | |
10324 | int restart_af_count = 0; | |
10325 | ||
10326 | vty_out(vty, | |
10327 | " Remote Restart timer is %d seconds\n", | |
10328 | p->v_gr_restart); | |
10329 | vty_out(vty, | |
10330 | " Address families by peer:\n "); | |
10331 | ||
05c7a1cc QY |
10332 | FOREACH_AFI_SAFI (afi, safi) |
10333 | if (CHECK_FLAG( | |
10334 | p->af_cap | |
10335 | [afi] | |
10336 | [safi], | |
10337 | PEER_CAP_RESTART_AF_RCV)) { | |
10338 | vty_out(vty, | |
10339 | "%s%s(%s)", | |
10340 | restart_af_count | |
10341 | ? ", " | |
10342 | : "", | |
10343 | afi_safi_print( | |
10344 | afi, | |
10345 | safi), | |
10346 | CHECK_FLAG( | |
10347 | p->af_cap | |
10348 | [afi] | |
10349 | [safi], | |
10350 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
10351 | ? "preserved" | |
10352 | : "not preserved"); | |
10353 | restart_af_count++; | |
10354 | } | |
d62a17ae | 10355 | if (!restart_af_count) |
10356 | vty_out(vty, "none"); | |
10357 | vty_out(vty, "\n"); | |
10358 | } | |
10359 | } | |
10360 | } | |
10361 | } | |
10362 | } | |
10363 | ||
10364 | /* graceful restart information */ | |
10365 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || p->t_gr_restart | |
10366 | || p->t_gr_stale) { | |
10367 | json_object *json_grace = NULL; | |
10368 | json_object *json_grace_send = NULL; | |
10369 | json_object *json_grace_recv = NULL; | |
10370 | int eor_send_af_count = 0; | |
10371 | int eor_receive_af_count = 0; | |
10372 | ||
10373 | if (use_json) { | |
10374 | json_grace = json_object_new_object(); | |
10375 | json_grace_send = json_object_new_object(); | |
10376 | json_grace_recv = json_object_new_object(); | |
10377 | ||
10378 | if (p->status == Established) { | |
05c7a1cc QY |
10379 | FOREACH_AFI_SAFI (afi, safi) { |
10380 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10381 | PEER_STATUS_EOR_SEND)) { | |
10382 | json_object_boolean_true_add( | |
10383 | json_grace_send, | |
10384 | afi_safi_print(afi, | |
10385 | safi)); | |
10386 | eor_send_af_count++; | |
d62a17ae | 10387 | } |
10388 | } | |
05c7a1cc QY |
10389 | FOREACH_AFI_SAFI (afi, safi) { |
10390 | if (CHECK_FLAG( | |
10391 | p->af_sflags[afi][safi], | |
10392 | PEER_STATUS_EOR_RECEIVED)) { | |
10393 | json_object_boolean_true_add( | |
10394 | json_grace_recv, | |
10395 | afi_safi_print(afi, | |
10396 | safi)); | |
10397 | eor_receive_af_count++; | |
d62a17ae | 10398 | } |
10399 | } | |
10400 | } | |
10401 | ||
10402 | json_object_object_add(json_grace, "endOfRibSend", | |
10403 | json_grace_send); | |
10404 | json_object_object_add(json_grace, "endOfRibRecv", | |
10405 | json_grace_recv); | |
10406 | ||
10407 | if (p->t_gr_restart) | |
10408 | json_object_int_add(json_grace, | |
10409 | "gracefulRestartTimerMsecs", | |
10410 | thread_timer_remain_second( | |
10411 | p->t_gr_restart) | |
10412 | * 1000); | |
10413 | ||
10414 | if (p->t_gr_stale) | |
10415 | json_object_int_add( | |
10416 | json_grace, | |
10417 | "gracefulStalepathTimerMsecs", | |
10418 | thread_timer_remain_second( | |
10419 | p->t_gr_stale) | |
10420 | * 1000); | |
10421 | ||
10422 | json_object_object_add( | |
10423 | json_neigh, "gracefulRestartInfo", json_grace); | |
10424 | } else { | |
0437e105 | 10425 | vty_out(vty, " Graceful restart information:\n"); |
d62a17ae | 10426 | if (p->status == Established) { |
10427 | vty_out(vty, " End-of-RIB send: "); | |
05c7a1cc QY |
10428 | FOREACH_AFI_SAFI (afi, safi) { |
10429 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10430 | PEER_STATUS_EOR_SEND)) { | |
10431 | vty_out(vty, "%s%s", | |
10432 | eor_send_af_count ? ", " | |
10433 | : "", | |
10434 | afi_safi_print(afi, | |
10435 | safi)); | |
10436 | eor_send_af_count++; | |
d62a17ae | 10437 | } |
10438 | } | |
10439 | vty_out(vty, "\n"); | |
10440 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
10441 | FOREACH_AFI_SAFI (afi, safi) { |
10442 | if (CHECK_FLAG( | |
10443 | p->af_sflags[afi][safi], | |
10444 | PEER_STATUS_EOR_RECEIVED)) { | |
10445 | vty_out(vty, "%s%s", | |
10446 | eor_receive_af_count | |
10447 | ? ", " | |
10448 | : "", | |
10449 | afi_safi_print(afi, | |
10450 | safi)); | |
10451 | eor_receive_af_count++; | |
d62a17ae | 10452 | } |
10453 | } | |
10454 | vty_out(vty, "\n"); | |
10455 | } | |
10456 | ||
10457 | if (p->t_gr_restart) | |
10458 | vty_out(vty, | |
10459 | " The remaining time of restart timer is %ld\n", | |
10460 | thread_timer_remain_second( | |
10461 | p->t_gr_restart)); | |
10462 | ||
10463 | if (p->t_gr_stale) | |
10464 | vty_out(vty, | |
10465 | " The remaining time of stalepath timer is %ld\n", | |
10466 | thread_timer_remain_second( | |
10467 | p->t_gr_stale)); | |
10468 | } | |
10469 | } | |
10470 | if (use_json) { | |
10471 | json_object *json_stat = NULL; | |
10472 | json_stat = json_object_new_object(); | |
10473 | /* Packet counts. */ | |
10474 | json_object_int_add(json_stat, "depthInq", 0); | |
10475 | json_object_int_add(json_stat, "depthOutq", | |
10476 | (unsigned long)p->obuf->count); | |
0112e9e0 QY |
10477 | json_object_int_add(json_stat, "opensSent", |
10478 | atomic_load_explicit(&p->open_out, | |
10479 | memory_order_relaxed)); | |
10480 | json_object_int_add(json_stat, "opensRecv", | |
10481 | atomic_load_explicit(&p->open_in, | |
10482 | memory_order_relaxed)); | |
d62a17ae | 10483 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
10484 | atomic_load_explicit(&p->notify_out, |
10485 | memory_order_relaxed)); | |
d62a17ae | 10486 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
10487 | atomic_load_explicit(&p->notify_in, |
10488 | memory_order_relaxed)); | |
10489 | json_object_int_add(json_stat, "updatesSent", | |
10490 | atomic_load_explicit(&p->update_out, | |
10491 | memory_order_relaxed)); | |
10492 | json_object_int_add(json_stat, "updatesRecv", | |
10493 | atomic_load_explicit(&p->update_in, | |
10494 | memory_order_relaxed)); | |
d62a17ae | 10495 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
10496 | atomic_load_explicit(&p->keepalive_out, |
10497 | memory_order_relaxed)); | |
d62a17ae | 10498 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
10499 | atomic_load_explicit(&p->keepalive_in, |
10500 | memory_order_relaxed)); | |
d62a17ae | 10501 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
10502 | atomic_load_explicit(&p->refresh_out, |
10503 | memory_order_relaxed)); | |
d62a17ae | 10504 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
10505 | atomic_load_explicit(&p->refresh_in, |
10506 | memory_order_relaxed)); | |
d62a17ae | 10507 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
10508 | atomic_load_explicit(&p->dynamic_cap_out, |
10509 | memory_order_relaxed)); | |
d62a17ae | 10510 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
10511 | atomic_load_explicit(&p->dynamic_cap_in, |
10512 | memory_order_relaxed)); | |
10513 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
10514 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 10515 | json_object_object_add(json_neigh, "messageStats", json_stat); |
10516 | } else { | |
10517 | /* Packet counts. */ | |
10518 | vty_out(vty, " Message statistics:\n"); | |
10519 | vty_out(vty, " Inq depth is 0\n"); | |
10520 | vty_out(vty, " Outq depth is %lu\n", | |
10521 | (unsigned long)p->obuf->count); | |
10522 | vty_out(vty, " Sent Rcvd\n"); | |
0112e9e0 QY |
10523 | vty_out(vty, " Opens: %10d %10d\n", |
10524 | atomic_load_explicit(&p->open_out, | |
10525 | memory_order_relaxed), | |
10526 | atomic_load_explicit(&p->open_in, | |
10527 | memory_order_relaxed)); | |
10528 | vty_out(vty, " Notifications: %10d %10d\n", | |
10529 | atomic_load_explicit(&p->notify_out, | |
10530 | memory_order_relaxed), | |
10531 | atomic_load_explicit(&p->notify_in, | |
10532 | memory_order_relaxed)); | |
10533 | vty_out(vty, " Updates: %10d %10d\n", | |
10534 | atomic_load_explicit(&p->update_out, | |
10535 | memory_order_relaxed), | |
10536 | atomic_load_explicit(&p->update_in, | |
10537 | memory_order_relaxed)); | |
10538 | vty_out(vty, " Keepalives: %10d %10d\n", | |
10539 | atomic_load_explicit(&p->keepalive_out, | |
10540 | memory_order_relaxed), | |
10541 | atomic_load_explicit(&p->keepalive_in, | |
10542 | memory_order_relaxed)); | |
10543 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
10544 | atomic_load_explicit(&p->refresh_out, | |
10545 | memory_order_relaxed), | |
10546 | atomic_load_explicit(&p->refresh_in, | |
10547 | memory_order_relaxed)); | |
d62a17ae | 10548 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
10549 | atomic_load_explicit(&p->dynamic_cap_out, |
10550 | memory_order_relaxed), | |
10551 | atomic_load_explicit(&p->dynamic_cap_in, | |
10552 | memory_order_relaxed)); | |
10553 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
10554 | PEER_TOTAL_RX(p)); | |
d62a17ae | 10555 | } |
10556 | ||
10557 | if (use_json) { | |
10558 | /* advertisement-interval */ | |
10559 | json_object_int_add(json_neigh, | |
10560 | "minBtwnAdvertisementRunsTimerMsecs", | |
10561 | p->v_routeadv * 1000); | |
10562 | ||
10563 | /* Update-source. */ | |
10564 | if (p->update_if || p->update_source) { | |
10565 | if (p->update_if) | |
10566 | json_object_string_add(json_neigh, | |
10567 | "updateSource", | |
10568 | p->update_if); | |
10569 | else if (p->update_source) | |
10570 | json_object_string_add( | |
10571 | json_neigh, "updateSource", | |
10572 | sockunion2str(p->update_source, buf1, | |
10573 | SU_ADDRSTRLEN)); | |
10574 | } | |
10575 | } else { | |
10576 | /* advertisement-interval */ | |
10577 | vty_out(vty, | |
10578 | " Minimum time between advertisement runs is %d seconds\n", | |
10579 | p->v_routeadv); | |
10580 | ||
10581 | /* Update-source. */ | |
10582 | if (p->update_if || p->update_source) { | |
10583 | vty_out(vty, " Update source is "); | |
10584 | if (p->update_if) | |
10585 | vty_out(vty, "%s", p->update_if); | |
10586 | else if (p->update_source) | |
10587 | vty_out(vty, "%s", | |
10588 | sockunion2str(p->update_source, buf1, | |
10589 | SU_ADDRSTRLEN)); | |
10590 | vty_out(vty, "\n"); | |
10591 | } | |
10592 | ||
10593 | vty_out(vty, "\n"); | |
10594 | } | |
10595 | ||
10596 | /* Address Family Information */ | |
10597 | json_object *json_hold = NULL; | |
10598 | ||
10599 | if (use_json) | |
10600 | json_hold = json_object_new_object(); | |
10601 | ||
05c7a1cc QY |
10602 | FOREACH_AFI_SAFI (afi, safi) |
10603 | if (p->afc[afi][safi]) | |
10604 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
10605 | json_hold); | |
d62a17ae | 10606 | |
10607 | if (use_json) { | |
10608 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
10609 | json_hold); | |
10610 | json_object_int_add(json_neigh, "connectionsEstablished", | |
10611 | p->established); | |
10612 | json_object_int_add(json_neigh, "connectionsDropped", | |
10613 | p->dropped); | |
10614 | } else | |
10615 | vty_out(vty, " Connections established %d; dropped %d\n", | |
10616 | p->established, p->dropped); | |
10617 | ||
10618 | if (!p->last_reset) { | |
10619 | if (use_json) | |
10620 | json_object_string_add(json_neigh, "lastReset", | |
10621 | "never"); | |
10622 | else | |
10623 | vty_out(vty, " Last reset never\n"); | |
10624 | } else { | |
10625 | if (use_json) { | |
10626 | time_t uptime; | |
10627 | struct tm *tm; | |
10628 | ||
10629 | uptime = bgp_clock(); | |
10630 | uptime -= p->resettime; | |
10631 | tm = gmtime(&uptime); | |
10632 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
10633 | (tm->tm_sec * 1000) | |
10634 | + (tm->tm_min * 60000) | |
10635 | + (tm->tm_hour * 3600000)); | |
10636 | json_object_string_add( | |
10637 | json_neigh, "lastResetDueTo", | |
10638 | peer_down_str[(int)p->last_reset]); | |
10639 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10640 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10641 | char errorcodesubcode_hexstr[5]; | |
10642 | char errorcodesubcode_str[256]; | |
10643 | ||
10644 | code_str = bgp_notify_code_str(p->notify.code); | |
10645 | subcode_str = bgp_notify_subcode_str( | |
10646 | p->notify.code, p->notify.subcode); | |
10647 | ||
10648 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
10649 | p->notify.code, p->notify.subcode); | |
10650 | json_object_string_add(json_neigh, | |
10651 | "lastErrorCodeSubcode", | |
10652 | errorcodesubcode_hexstr); | |
10653 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10654 | code_str, subcode_str); | |
10655 | json_object_string_add(json_neigh, | |
10656 | "lastNotificationReason", | |
10657 | errorcodesubcode_str); | |
10658 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10659 | && p->notify.code == BGP_NOTIFY_CEASE | |
10660 | && (p->notify.subcode | |
10661 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10662 | || p->notify.subcode | |
10663 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10664 | && p->notify.length) { | |
10665 | char msgbuf[1024]; | |
10666 | const char *msg_str; | |
10667 | ||
10668 | msg_str = bgp_notify_admin_message( | |
10669 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10670 | (uint8_t *)p->notify.data, |
d62a17ae | 10671 | p->notify.length); |
10672 | if (msg_str) | |
10673 | json_object_string_add( | |
10674 | json_neigh, | |
10675 | "lastShutdownDescription", | |
10676 | msg_str); | |
10677 | } | |
10678 | } | |
10679 | } else { | |
10680 | vty_out(vty, " Last reset %s, ", | |
10681 | peer_uptime(p->resettime, timebuf, | |
10682 | BGP_UPTIME_LEN, 0, NULL)); | |
10683 | ||
10684 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10685 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10686 | code_str = bgp_notify_code_str(p->notify.code); | |
10687 | subcode_str = bgp_notify_subcode_str( | |
10688 | p->notify.code, p->notify.subcode); | |
10689 | vty_out(vty, "due to NOTIFICATION %s (%s%s)\n", | |
10690 | p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10691 | ? "sent" | |
10692 | : "received", | |
10693 | code_str, subcode_str); | |
10694 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10695 | && p->notify.code == BGP_NOTIFY_CEASE | |
10696 | && (p->notify.subcode | |
10697 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10698 | || p->notify.subcode | |
10699 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10700 | && p->notify.length) { | |
10701 | char msgbuf[1024]; | |
10702 | const char *msg_str; | |
10703 | ||
10704 | msg_str = bgp_notify_admin_message( | |
10705 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10706 | (uint8_t *)p->notify.data, |
d62a17ae | 10707 | p->notify.length); |
10708 | if (msg_str) | |
10709 | vty_out(vty, | |
10710 | " Message: \"%s\"\n", | |
10711 | msg_str); | |
10712 | } | |
10713 | } else { | |
10714 | vty_out(vty, "due to %s\n", | |
10715 | peer_down_str[(int)p->last_reset]); | |
10716 | } | |
10717 | ||
10718 | if (p->last_reset_cause_size) { | |
10719 | msg = p->last_reset_cause; | |
10720 | vty_out(vty, | |
10721 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
10722 | for (i = 1; i <= p->last_reset_cause_size; | |
10723 | i++) { | |
10724 | vty_out(vty, "%02X", *msg++); | |
10725 | ||
10726 | if (i != p->last_reset_cause_size) { | |
10727 | if (i % 16 == 0) { | |
10728 | vty_out(vty, "\n "); | |
10729 | } else if (i % 4 == 0) { | |
10730 | vty_out(vty, " "); | |
10731 | } | |
10732 | } | |
10733 | } | |
10734 | vty_out(vty, "\n"); | |
10735 | } | |
10736 | } | |
10737 | } | |
10738 | ||
10739 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
10740 | if (use_json) | |
10741 | json_object_boolean_true_add(json_neigh, | |
10742 | "prefixesConfigExceedMax"); | |
10743 | else | |
10744 | vty_out(vty, | |
10745 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
10746 | ||
10747 | if (p->t_pmax_restart) { | |
10748 | if (use_json) { | |
10749 | json_object_boolean_true_add( | |
10750 | json_neigh, "reducePrefixNumFrom"); | |
10751 | json_object_int_add(json_neigh, | |
10752 | "restartInTimerMsec", | |
10753 | thread_timer_remain_second( | |
10754 | p->t_pmax_restart) | |
10755 | * 1000); | |
10756 | } else | |
10757 | vty_out(vty, | |
10758 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
10759 | p->host, thread_timer_remain_second( |
10760 | p->t_pmax_restart)); | |
d62a17ae | 10761 | } else { |
10762 | if (use_json) | |
10763 | json_object_boolean_true_add( | |
10764 | json_neigh, | |
10765 | "reducePrefixNumAndClearIpBgp"); | |
10766 | else | |
10767 | vty_out(vty, | |
10768 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
10769 | p->host); | |
10770 | } | |
10771 | } | |
10772 | ||
10773 | /* EBGP Multihop and GTSM */ | |
10774 | if (p->sort != BGP_PEER_IBGP) { | |
10775 | if (use_json) { | |
10776 | if (p->gtsm_hops > 0) | |
10777 | json_object_int_add(json_neigh, | |
10778 | "externalBgpNbrMaxHopsAway", | |
10779 | p->gtsm_hops); | |
10780 | else if (p->ttl > 1) | |
10781 | json_object_int_add(json_neigh, | |
10782 | "externalBgpNbrMaxHopsAway", | |
10783 | p->ttl); | |
10784 | } else { | |
10785 | if (p->gtsm_hops > 0) | |
10786 | vty_out(vty, | |
10787 | " External BGP neighbor may be up to %d hops away.\n", | |
10788 | p->gtsm_hops); | |
10789 | else if (p->ttl > 1) | |
10790 | vty_out(vty, | |
10791 | " External BGP neighbor may be up to %d hops away.\n", | |
10792 | p->ttl); | |
10793 | } | |
10794 | } else { | |
10795 | if (p->gtsm_hops > 0) { | |
10796 | if (use_json) | |
10797 | json_object_int_add(json_neigh, | |
10798 | "internalBgpNbrMaxHopsAway", | |
10799 | p->gtsm_hops); | |
10800 | else | |
10801 | vty_out(vty, | |
10802 | " Internal BGP neighbor may be up to %d hops away.\n", | |
10803 | p->gtsm_hops); | |
10804 | } | |
10805 | } | |
10806 | ||
10807 | /* Local address. */ | |
10808 | if (p->su_local) { | |
10809 | if (use_json) { | |
10810 | json_object_string_add(json_neigh, "hostLocal", | |
10811 | sockunion2str(p->su_local, buf1, | |
10812 | SU_ADDRSTRLEN)); | |
10813 | json_object_int_add(json_neigh, "portLocal", | |
10814 | ntohs(p->su_local->sin.sin_port)); | |
10815 | } else | |
10816 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
10817 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
10818 | ntohs(p->su_local->sin.sin_port)); | |
10819 | } | |
10820 | ||
10821 | /* Remote address. */ | |
10822 | if (p->su_remote) { | |
10823 | if (use_json) { | |
10824 | json_object_string_add(json_neigh, "hostForeign", | |
10825 | sockunion2str(p->su_remote, buf1, | |
10826 | SU_ADDRSTRLEN)); | |
10827 | json_object_int_add(json_neigh, "portForeign", | |
10828 | ntohs(p->su_remote->sin.sin_port)); | |
10829 | } else | |
10830 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
10831 | sockunion2str(p->su_remote, buf1, | |
10832 | SU_ADDRSTRLEN), | |
10833 | ntohs(p->su_remote->sin.sin_port)); | |
10834 | } | |
10835 | ||
10836 | /* Nexthop display. */ | |
10837 | if (p->su_local) { | |
10838 | if (use_json) { | |
10839 | json_object_string_add(json_neigh, "nexthop", | |
10840 | inet_ntop(AF_INET, | |
10841 | &p->nexthop.v4, buf1, | |
10842 | sizeof(buf1))); | |
10843 | json_object_string_add(json_neigh, "nexthopGlobal", | |
10844 | inet_ntop(AF_INET6, | |
10845 | &p->nexthop.v6_global, | |
10846 | buf1, sizeof(buf1))); | |
10847 | json_object_string_add(json_neigh, "nexthopLocal", | |
10848 | inet_ntop(AF_INET6, | |
10849 | &p->nexthop.v6_local, | |
10850 | buf1, sizeof(buf1))); | |
10851 | if (p->shared_network) | |
10852 | json_object_string_add(json_neigh, | |
10853 | "bgpConnection", | |
10854 | "sharedNetwork"); | |
10855 | else | |
10856 | json_object_string_add(json_neigh, | |
10857 | "bgpConnection", | |
10858 | "nonSharedNetwork"); | |
10859 | } else { | |
10860 | vty_out(vty, "Nexthop: %s\n", | |
10861 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
10862 | sizeof(buf1))); | |
10863 | vty_out(vty, "Nexthop global: %s\n", | |
10864 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
10865 | sizeof(buf1))); | |
10866 | vty_out(vty, "Nexthop local: %s\n", | |
10867 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
10868 | sizeof(buf1))); | |
10869 | vty_out(vty, "BGP connection: %s\n", | |
10870 | p->shared_network ? "shared network" | |
10871 | : "non shared network"); | |
10872 | } | |
10873 | } | |
10874 | ||
10875 | /* Timer information. */ | |
10876 | if (use_json) { | |
10877 | json_object_int_add(json_neigh, "connectRetryTimer", | |
10878 | p->v_connect); | |
10879 | if (p->status == Established && p->rtt) | |
10880 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
10881 | p->rtt); | |
10882 | if (p->t_start) | |
10883 | json_object_int_add( | |
10884 | json_neigh, "nextStartTimerDueInMsecs", | |
10885 | thread_timer_remain_second(p->t_start) * 1000); | |
10886 | if (p->t_connect) | |
10887 | json_object_int_add( | |
10888 | json_neigh, "nextConnectTimerDueInMsecs", | |
10889 | thread_timer_remain_second(p->t_connect) | |
10890 | * 1000); | |
10891 | if (p->t_routeadv) { | |
10892 | json_object_int_add(json_neigh, "mraiInterval", | |
10893 | p->v_routeadv); | |
10894 | json_object_int_add( | |
10895 | json_neigh, "mraiTimerExpireInMsecs", | |
10896 | thread_timer_remain_second(p->t_routeadv) | |
10897 | * 1000); | |
10898 | } | |
10899 | if (p->password) | |
10900 | json_object_int_add(json_neigh, "authenticationEnabled", | |
10901 | 1); | |
10902 | ||
10903 | if (p->t_read) | |
10904 | json_object_string_add(json_neigh, "readThread", "on"); | |
10905 | else | |
10906 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
10907 | |
10908 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 10909 | json_object_string_add(json_neigh, "writeThread", "on"); |
10910 | else | |
10911 | json_object_string_add(json_neigh, "writeThread", | |
10912 | "off"); | |
10913 | } else { | |
10914 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
10915 | p->v_connect); | |
10916 | if (p->status == Established && p->rtt) | |
10917 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
10918 | p->rtt); | |
10919 | if (p->t_start) | |
10920 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
10921 | thread_timer_remain_second(p->t_start)); | |
10922 | if (p->t_connect) | |
10923 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
10924 | thread_timer_remain_second(p->t_connect)); | |
10925 | if (p->t_routeadv) | |
10926 | vty_out(vty, | |
10927 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
10928 | p->v_routeadv, | |
10929 | thread_timer_remain_second(p->t_routeadv)); | |
10930 | if (p->password) | |
10931 | vty_out(vty, "Peer Authentication Enabled\n"); | |
10932 | ||
10933 | vty_out(vty, "Read thread: %s Write thread: %s\n", | |
49507a6f QY |
10934 | p->t_read ? "on" : "off", |
10935 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
10936 | ? "on" | |
10937 | : "off"); | |
d62a17ae | 10938 | } |
10939 | ||
10940 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
10941 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
10942 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
10943 | ||
10944 | if (!use_json) | |
10945 | vty_out(vty, "\n"); | |
10946 | ||
10947 | /* BFD information. */ | |
10948 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
10949 | ||
10950 | if (use_json) { | |
10951 | if (p->conf_if) /* Configured interface name. */ | |
10952 | json_object_object_add(json, p->conf_if, json_neigh); | |
10953 | else /* Configured IP address. */ | |
10954 | json_object_object_add(json, p->host, json_neigh); | |
10955 | } | |
10956 | } | |
10957 | ||
10958 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, | |
10959 | enum show_type type, union sockunion *su, | |
9f049418 | 10960 | const char *conf_if, bool use_json, |
d62a17ae | 10961 | json_object *json) |
10962 | { | |
10963 | struct listnode *node, *nnode; | |
10964 | struct peer *peer; | |
10965 | int find = 0; | |
9f049418 | 10966 | bool nbr_output = false; |
d1927ebe AS |
10967 | afi_t afi = AFI_MAX; |
10968 | safi_t safi = SAFI_MAX; | |
10969 | ||
10970 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
10971 | afi = AFI_IP; | |
10972 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
10973 | afi = AFI_IP6; | |
10974 | } | |
d62a17ae | 10975 | |
10976 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
10977 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10978 | continue; | |
10979 | ||
10980 | switch (type) { | |
10981 | case show_all: | |
10982 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 10983 | nbr_output = true; |
d62a17ae | 10984 | break; |
10985 | case show_peer: | |
10986 | if (conf_if) { | |
10987 | if ((peer->conf_if | |
10988 | && !strcmp(peer->conf_if, conf_if)) | |
10989 | || (peer->hostname | |
10990 | && !strcmp(peer->hostname, conf_if))) { | |
10991 | find = 1; | |
10992 | bgp_show_peer(vty, peer, use_json, | |
10993 | json); | |
10994 | } | |
10995 | } else { | |
10996 | if (sockunion_same(&peer->su, su)) { | |
10997 | find = 1; | |
10998 | bgp_show_peer(vty, peer, use_json, | |
10999 | json); | |
11000 | } | |
11001 | } | |
11002 | break; | |
d1927ebe AS |
11003 | case show_ipv4_peer: |
11004 | case show_ipv6_peer: | |
11005 | FOREACH_SAFI (safi) { | |
11006 | if (peer->afc[afi][safi]) { | |
11007 | if (conf_if) { | |
11008 | if ((peer->conf_if | |
11009 | && !strcmp(peer->conf_if, conf_if)) | |
11010 | || (peer->hostname | |
11011 | && !strcmp(peer->hostname, conf_if))) { | |
11012 | find = 1; | |
11013 | bgp_show_peer(vty, peer, use_json, | |
11014 | json); | |
11015 | break; | |
11016 | } | |
11017 | } else { | |
11018 | if (sockunion_same(&peer->su, su)) { | |
11019 | find = 1; | |
11020 | bgp_show_peer(vty, peer, use_json, | |
11021 | json); | |
11022 | break; | |
11023 | } | |
11024 | } | |
11025 | } | |
11026 | } | |
11027 | break; | |
11028 | case show_ipv4_all: | |
11029 | case show_ipv6_all: | |
11030 | FOREACH_SAFI (safi) { | |
11031 | if (peer->afc[afi][safi]) { | |
11032 | bgp_show_peer(vty, peer, use_json, json); | |
11033 | nbr_output = true; | |
11034 | break; | |
11035 | } | |
11036 | } | |
11037 | break; | |
d62a17ae | 11038 | } |
11039 | } | |
11040 | ||
d1927ebe AS |
11041 | if ((type == show_peer || type == show_ipv4_peer || |
11042 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 11043 | if (use_json) |
11044 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
11045 | else | |
88b7d255 | 11046 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 11047 | } |
11048 | ||
d1927ebe AS |
11049 | if (type != show_peer && type != show_ipv4_peer && |
11050 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 11051 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 11052 | |
d62a17ae | 11053 | if (use_json) { |
996c9314 LB |
11054 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
11055 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 11056 | } else { |
11057 | vty_out(vty, "\n"); | |
11058 | } | |
11059 | ||
11060 | return CMD_SUCCESS; | |
11061 | } | |
11062 | ||
11063 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, | |
71aedaa3 DS |
11064 | enum show_type type, |
11065 | const char *ip_str, | |
9f049418 | 11066 | bool use_json) |
d62a17ae | 11067 | { |
0291c246 MK |
11068 | struct listnode *node, *nnode; |
11069 | struct bgp *bgp; | |
71aedaa3 | 11070 | union sockunion su; |
0291c246 | 11071 | json_object *json = NULL; |
71aedaa3 | 11072 | int ret, is_first = 1; |
9f049418 | 11073 | bool nbr_output = false; |
d62a17ae | 11074 | |
11075 | if (use_json) | |
11076 | vty_out(vty, "{\n"); | |
11077 | ||
11078 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 11079 | nbr_output = true; |
d62a17ae | 11080 | if (use_json) { |
11081 | if (!(json = json_object_new_object())) { | |
af4c2728 | 11082 | flog_err( |
e50f7cfd | 11083 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 11084 | "Unable to allocate memory for JSON object"); |
11085 | vty_out(vty, | |
11086 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
11087 | return; | |
11088 | } | |
11089 | ||
11090 | json_object_int_add(json, "vrfId", | |
11091 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
11092 | ? -1 |
11093 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 11094 | json_object_string_add( |
11095 | json, "vrfName", | |
11096 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11097 | ? VRF_DEFAULT_NAME |
d62a17ae | 11098 | : bgp->name); |
11099 | ||
11100 | if (!is_first) | |
11101 | vty_out(vty, ",\n"); | |
11102 | else | |
11103 | is_first = 0; | |
11104 | ||
11105 | vty_out(vty, "\"%s\":", | |
11106 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11107 | ? VRF_DEFAULT_NAME |
d62a17ae | 11108 | : bgp->name); |
11109 | } else { | |
11110 | vty_out(vty, "\nInstance %s:\n", | |
11111 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11112 | ? VRF_DEFAULT_NAME |
d62a17ae | 11113 | : bgp->name); |
11114 | } | |
71aedaa3 | 11115 | |
d1927ebe AS |
11116 | if (type == show_peer || type == show_ipv4_peer || |
11117 | type == show_ipv6_peer) { | |
71aedaa3 DS |
11118 | ret = str2sockunion(ip_str, &su); |
11119 | if (ret < 0) | |
11120 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
11121 | use_json, json); | |
11122 | else | |
11123 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
11124 | use_json, json); | |
11125 | } else { | |
d1927ebe | 11126 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
11127 | use_json, json); |
11128 | } | |
b77004d6 | 11129 | json_object_free(json); |
d62a17ae | 11130 | } |
11131 | ||
01cbfd04 | 11132 | if (use_json) { |
d62a17ae | 11133 | vty_out(vty, "}\n"); |
01cbfd04 QY |
11134 | json_object_free(json); |
11135 | } | |
9f049418 DS |
11136 | else if (!nbr_output) |
11137 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11138 | } |
11139 | ||
11140 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
11141 | enum show_type type, const char *ip_str, | |
9f049418 | 11142 | bool use_json) |
d62a17ae | 11143 | { |
11144 | int ret; | |
11145 | struct bgp *bgp; | |
11146 | union sockunion su; | |
11147 | json_object *json = NULL; | |
11148 | ||
11149 | if (name) { | |
11150 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
11151 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
11152 | use_json); | |
d62a17ae | 11153 | return CMD_SUCCESS; |
11154 | } else { | |
11155 | bgp = bgp_lookup_by_name(name); | |
11156 | if (!bgp) { | |
11157 | if (use_json) { | |
11158 | json = json_object_new_object(); | |
d62a17ae | 11159 | vty_out(vty, "%s\n", |
11160 | json_object_to_json_string_ext( | |
11161 | json, | |
11162 | JSON_C_TO_STRING_PRETTY)); | |
11163 | json_object_free(json); | |
11164 | } else | |
11165 | vty_out(vty, | |
9f049418 | 11166 | "%% BGP instance not found\n"); |
d62a17ae | 11167 | |
11168 | return CMD_WARNING; | |
11169 | } | |
11170 | } | |
11171 | } else { | |
11172 | bgp = bgp_get_default(); | |
11173 | } | |
11174 | ||
11175 | if (bgp) { | |
11176 | json = json_object_new_object(); | |
11177 | if (ip_str) { | |
11178 | ret = str2sockunion(ip_str, &su); | |
11179 | if (ret < 0) | |
11180 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
11181 | use_json, json); | |
11182 | else | |
11183 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
11184 | use_json, json); | |
11185 | } else { | |
11186 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
11187 | json); | |
11188 | } | |
11189 | json_object_free(json); | |
ca61fd25 DS |
11190 | } else { |
11191 | if (use_json) | |
11192 | vty_out(vty, "{}\n"); | |
11193 | else | |
11194 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11195 | } |
11196 | ||
11197 | return CMD_SUCCESS; | |
4fb25c53 DW |
11198 | } |
11199 | ||
716b2d8a | 11200 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 11201 | DEFUN (show_ip_bgp_neighbors, |
11202 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 11203 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 11204 | SHOW_STR |
11205 | IP_STR | |
11206 | BGP_STR | |
f2a8972b | 11207 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
11208 | "Address Family\n" |
11209 | "Address Family\n" | |
718e3744 | 11210 | "Detailed information on TCP and BGP neighbor connections\n" |
11211 | "Neighbor to display information about\n" | |
a80beece | 11212 | "Neighbor to display information about\n" |
91d37724 | 11213 | "Neighbor on BGP configured interface\n" |
9973d184 | 11214 | JSON_STR) |
718e3744 | 11215 | { |
d62a17ae | 11216 | char *vrf = NULL; |
11217 | char *sh_arg = NULL; | |
11218 | enum show_type sh_type; | |
d1927ebe | 11219 | afi_t afi = AFI_MAX; |
718e3744 | 11220 | |
9f049418 | 11221 | bool uj = use_json(argc, argv); |
718e3744 | 11222 | |
d62a17ae | 11223 | int idx = 0; |
718e3744 | 11224 | |
9a8bdf1c PG |
11225 | /* [<vrf> VIEWVRFNAME] */ |
11226 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11227 | vrf = argv[idx + 1]->arg; | |
11228 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11229 | vrf = NULL; | |
11230 | } else if (argv_find(argv, argc, "view", &idx)) | |
11231 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 11232 | vrf = argv[idx + 1]->arg; |
718e3744 | 11233 | |
d62a17ae | 11234 | idx++; |
d1927ebe AS |
11235 | |
11236 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
11237 | sh_type = show_ipv4_all; | |
11238 | afi = AFI_IP; | |
11239 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
11240 | sh_type = show_ipv6_all; | |
11241 | afi = AFI_IP6; | |
11242 | } else { | |
11243 | sh_type = show_all; | |
11244 | } | |
11245 | ||
d62a17ae | 11246 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
11247 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
11248 | || argv_find(argv, argc, "WORD", &idx)) { | |
11249 | sh_type = show_peer; | |
11250 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
11251 | } |
11252 | ||
11253 | if (sh_type == show_peer && afi == AFI_IP) { | |
11254 | sh_type = show_ipv4_peer; | |
11255 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
11256 | sh_type = show_ipv6_peer; | |
11257 | } | |
856ca177 | 11258 | |
d62a17ae | 11259 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 11260 | } |
11261 | ||
716b2d8a | 11262 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 11263 | paths' and `show ip mbgp paths'. Those functions results are the |
11264 | same.*/ | |
f412b39a | 11265 | DEFUN (show_ip_bgp_paths, |
718e3744 | 11266 | show_ip_bgp_paths_cmd, |
46f296b4 | 11267 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 11268 | SHOW_STR |
11269 | IP_STR | |
11270 | BGP_STR | |
46f296b4 | 11271 | BGP_SAFI_HELP_STR |
718e3744 | 11272 | "Path information\n") |
11273 | { | |
d62a17ae | 11274 | vty_out(vty, "Address Refcnt Path\n"); |
11275 | aspath_print_all_vty(vty); | |
11276 | return CMD_SUCCESS; | |
718e3744 | 11277 | } |
11278 | ||
718e3744 | 11279 | #include "hash.h" |
11280 | ||
e3b78da8 | 11281 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 11282 | struct vty *vty) |
718e3744 | 11283 | { |
d62a17ae | 11284 | struct community *com; |
718e3744 | 11285 | |
e3b78da8 | 11286 | com = (struct community *)bucket->data; |
3f65c5b1 | 11287 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 11288 | community_str(com, false)); |
718e3744 | 11289 | } |
11290 | ||
11291 | /* Show BGP's community internal data. */ | |
f412b39a | 11292 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 11293 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 11294 | "show [ip] bgp community-info", |
718e3744 | 11295 | SHOW_STR |
11296 | IP_STR | |
11297 | BGP_STR | |
11298 | "List all bgp community information\n") | |
11299 | { | |
d62a17ae | 11300 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 11301 | |
d62a17ae | 11302 | hash_iterate(community_hash(), |
e3b78da8 | 11303 | (void (*)(struct hash_bucket *, |
d62a17ae | 11304 | void *))community_show_all_iterator, |
11305 | vty); | |
718e3744 | 11306 | |
d62a17ae | 11307 | return CMD_SUCCESS; |
718e3744 | 11308 | } |
11309 | ||
e3b78da8 | 11310 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 11311 | struct vty *vty) |
57d187bc | 11312 | { |
d62a17ae | 11313 | struct lcommunity *lcom; |
57d187bc | 11314 | |
e3b78da8 | 11315 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 11316 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 11317 | lcommunity_str(lcom, false)); |
57d187bc JS |
11318 | } |
11319 | ||
11320 | /* Show BGP's community internal data. */ | |
11321 | DEFUN (show_ip_bgp_lcommunity_info, | |
11322 | show_ip_bgp_lcommunity_info_cmd, | |
11323 | "show ip bgp large-community-info", | |
11324 | SHOW_STR | |
11325 | IP_STR | |
11326 | BGP_STR | |
11327 | "List all bgp large-community information\n") | |
11328 | { | |
d62a17ae | 11329 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 11330 | |
d62a17ae | 11331 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 11332 | (void (*)(struct hash_bucket *, |
d62a17ae | 11333 | void *))lcommunity_show_all_iterator, |
11334 | vty); | |
57d187bc | 11335 | |
d62a17ae | 11336 | return CMD_SUCCESS; |
57d187bc JS |
11337 | } |
11338 | ||
11339 | ||
f412b39a | 11340 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 11341 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 11342 | "show [ip] bgp attribute-info", |
718e3744 | 11343 | SHOW_STR |
11344 | IP_STR | |
11345 | BGP_STR | |
11346 | "List all bgp attribute information\n") | |
11347 | { | |
d62a17ae | 11348 | attr_show_all(vty); |
11349 | return CMD_SUCCESS; | |
718e3744 | 11350 | } |
6b0655a2 | 11351 | |
03915806 CS |
11352 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
11353 | afi_t afi, safi_t safi, | |
11354 | bool use_json, json_object *json) | |
53089bec | 11355 | { |
11356 | struct bgp *bgp; | |
11357 | struct listnode *node; | |
11358 | char *vname; | |
11359 | char buf1[INET6_ADDRSTRLEN]; | |
11360 | char *ecom_str; | |
11361 | vpn_policy_direction_t dir; | |
11362 | ||
03915806 | 11363 | if (json) { |
b46dfd20 DS |
11364 | json_object *json_import_vrfs = NULL; |
11365 | json_object *json_export_vrfs = NULL; | |
11366 | ||
b46dfd20 DS |
11367 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
11368 | ||
53089bec | 11369 | if (!bgp) { |
b46dfd20 DS |
11370 | vty_out(vty, "%s\n", |
11371 | json_object_to_json_string_ext( | |
11372 | json, | |
11373 | JSON_C_TO_STRING_PRETTY)); | |
11374 | json_object_free(json); | |
11375 | ||
53089bec | 11376 | return CMD_WARNING; |
11377 | } | |
b46dfd20 | 11378 | |
94d4c685 DS |
11379 | /* Provide context for the block */ |
11380 | json_object_string_add(json, "vrf", name ? name : "default"); | |
11381 | json_object_string_add(json, "afiSafi", | |
11382 | afi_safi_print(afi, safi)); | |
11383 | ||
b46dfd20 DS |
11384 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11385 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
11386 | json_object_string_add(json, "importFromVrfs", "none"); | |
11387 | json_object_string_add(json, "importRts", "none"); | |
11388 | } else { | |
6ce24e52 DS |
11389 | json_import_vrfs = json_object_new_array(); |
11390 | ||
b46dfd20 DS |
11391 | for (ALL_LIST_ELEMENTS_RO( |
11392 | bgp->vpn_policy[afi].import_vrf, | |
11393 | node, vname)) | |
11394 | json_object_array_add(json_import_vrfs, | |
11395 | json_object_new_string(vname)); | |
11396 | ||
11397 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
11398 | ecom_str = ecommunity_ecom2str( | |
11399 | bgp->vpn_policy[afi].rtlist[dir], | |
11400 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11401 | json_object_object_add(json, "importFromVrfs", | |
11402 | json_import_vrfs); | |
11403 | json_object_string_add(json, "importRts", ecom_str); | |
11404 | ||
11405 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11406 | } | |
11407 | ||
11408 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
11409 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
11410 | json_object_string_add(json, "exportToVrfs", "none"); | |
11411 | json_object_string_add(json, "routeDistinguisher", | |
11412 | "none"); | |
11413 | json_object_string_add(json, "exportRts", "none"); | |
11414 | } else { | |
6ce24e52 DS |
11415 | json_export_vrfs = json_object_new_array(); |
11416 | ||
b46dfd20 DS |
11417 | for (ALL_LIST_ELEMENTS_RO( |
11418 | bgp->vpn_policy[afi].export_vrf, | |
11419 | node, vname)) | |
11420 | json_object_array_add(json_export_vrfs, | |
11421 | json_object_new_string(vname)); | |
11422 | json_object_object_add(json, "exportToVrfs", | |
11423 | json_export_vrfs); | |
11424 | json_object_string_add(json, "routeDistinguisher", | |
11425 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11426 | buf1, RD_ADDRSTRLEN)); | |
11427 | ||
11428 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
11429 | ecom_str = ecommunity_ecom2str( | |
11430 | bgp->vpn_policy[afi].rtlist[dir], | |
11431 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11432 | json_object_string_add(json, "exportRts", ecom_str); | |
11433 | ||
11434 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11435 | } | |
11436 | ||
03915806 CS |
11437 | if (use_json) { |
11438 | vty_out(vty, "%s\n", | |
11439 | json_object_to_json_string_ext(json, | |
b46dfd20 | 11440 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
11441 | json_object_free(json); |
11442 | } | |
53089bec | 11443 | } else { |
b46dfd20 DS |
11444 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
11445 | ||
53089bec | 11446 | if (!bgp) { |
b46dfd20 | 11447 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 11448 | return CMD_WARNING; |
11449 | } | |
53089bec | 11450 | |
b46dfd20 DS |
11451 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11452 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
11453 | vty_out(vty, | |
11454 | "This VRF is not importing %s routes from any other VRF\n", | |
11455 | afi_safi_print(afi, safi)); | |
11456 | else { | |
11457 | vty_out(vty, | |
11458 | "This VRF is importing %s routes from the following VRFs:\n", | |
11459 | afi_safi_print(afi, safi)); | |
11460 | ||
11461 | for (ALL_LIST_ELEMENTS_RO( | |
11462 | bgp->vpn_policy[afi].import_vrf, | |
11463 | node, vname)) | |
11464 | vty_out(vty, " %s\n", vname); | |
11465 | ||
11466 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
11467 | ecom_str = ecommunity_ecom2str( | |
11468 | bgp->vpn_policy[afi].rtlist[dir], | |
11469 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11470 | vty_out(vty, "Import RT(s): %s\n", ecom_str); | |
11471 | ||
11472 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
53089bec | 11473 | } |
53089bec | 11474 | |
b46dfd20 DS |
11475 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11476 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
11477 | vty_out(vty, | |
11478 | "This VRF is not exporting %s routes to any other VRF\n", | |
53089bec | 11479 | afi_safi_print(afi, safi)); |
b46dfd20 DS |
11480 | else { |
11481 | vty_out(vty, | |
04c9077f | 11482 | "This VRF is exporting %s routes to the following VRFs:\n", |
53089bec | 11483 | afi_safi_print(afi, safi)); |
b46dfd20 DS |
11484 | |
11485 | for (ALL_LIST_ELEMENTS_RO( | |
11486 | bgp->vpn_policy[afi].export_vrf, | |
11487 | node, vname)) | |
11488 | vty_out(vty, " %s\n", vname); | |
11489 | ||
11490 | vty_out(vty, "RD: %s\n", | |
11491 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11492 | buf1, RD_ADDRSTRLEN)); | |
11493 | ||
11494 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
11495 | ecom_str = ecommunity_ecom2str( | |
11496 | bgp->vpn_policy[afi].rtlist[dir], | |
11497 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11498 | vty_out(vty, "Export RT: %s\n", ecom_str); | |
04c9077f | 11499 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
53089bec | 11500 | } |
53089bec | 11501 | } |
11502 | ||
11503 | return CMD_SUCCESS; | |
11504 | } | |
11505 | ||
03915806 CS |
11506 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
11507 | safi_t safi, bool use_json) | |
11508 | { | |
11509 | struct listnode *node, *nnode; | |
11510 | struct bgp *bgp; | |
11511 | char *vrf_name = NULL; | |
11512 | json_object *json = NULL; | |
11513 | json_object *json_vrf = NULL; | |
11514 | json_object *json_vrfs = NULL; | |
11515 | ||
11516 | if (use_json) { | |
11517 | json = json_object_new_object(); | |
11518 | json_vrfs = json_object_new_object(); | |
11519 | } | |
11520 | ||
11521 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
11522 | ||
11523 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
11524 | vrf_name = bgp->name; | |
11525 | ||
11526 | if (use_json) { | |
11527 | json_vrf = json_object_new_object(); | |
11528 | } else { | |
11529 | vty_out(vty, "\nInstance %s:\n", | |
11530 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
11531 | ? VRF_DEFAULT_NAME : bgp->name); | |
11532 | } | |
11533 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
11534 | if (use_json) { | |
11535 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
11536 | json_object_object_add(json_vrfs, | |
11537 | VRF_DEFAULT_NAME, json_vrf); | |
11538 | else | |
11539 | json_object_object_add(json_vrfs, vrf_name, | |
11540 | json_vrf); | |
11541 | } | |
11542 | } | |
11543 | ||
11544 | if (use_json) { | |
11545 | json_object_object_add(json, "vrfs", json_vrfs); | |
11546 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
11547 | JSON_C_TO_STRING_PRETTY)); | |
11548 | json_object_free(json); | |
11549 | } | |
11550 | ||
11551 | return CMD_SUCCESS; | |
11552 | } | |
11553 | ||
53089bec | 11554 | /* "show [ip] bgp route-leak" command. */ |
11555 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
11556 | show_ip_bgp_route_leak_cmd, |
11557 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
11558 | SHOW_STR |
11559 | IP_STR | |
11560 | BGP_STR | |
11561 | BGP_INSTANCE_HELP_STR | |
11562 | BGP_AFI_HELP_STR | |
11563 | BGP_SAFI_HELP_STR | |
11564 | "Route leaking information\n" | |
11565 | JSON_STR) | |
53089bec | 11566 | { |
11567 | char *vrf = NULL; | |
11568 | afi_t afi = AFI_MAX; | |
11569 | safi_t safi = SAFI_MAX; | |
11570 | ||
9f049418 | 11571 | bool uj = use_json(argc, argv); |
53089bec | 11572 | int idx = 0; |
03915806 | 11573 | json_object *json = NULL; |
53089bec | 11574 | |
11575 | /* show [ip] bgp */ | |
11576 | if (argv_find(argv, argc, "ip", &idx)) { | |
11577 | afi = AFI_IP; | |
11578 | safi = SAFI_UNICAST; | |
11579 | } | |
11580 | /* [vrf VIEWVRFNAME] */ | |
11581 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
11582 | vty_out(vty, |
11583 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 11584 | return CMD_WARNING; |
11585 | } | |
11586 | ||
9a8bdf1c PG |
11587 | if (argv_find(argv, argc, "vrf", &idx)) { |
11588 | vrf = argv[idx + 1]->arg; | |
11589 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11590 | vrf = NULL; | |
11591 | } | |
53089bec | 11592 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11593 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11594 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11595 | } | |
11596 | ||
11597 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
11598 | vty_out(vty, |
11599 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 11600 | return CMD_WARNING; |
11601 | } | |
11602 | ||
03915806 CS |
11603 | if (vrf && strmatch(vrf, "all")) |
11604 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
11605 | ||
11606 | if (uj) | |
11607 | json = json_object_new_object(); | |
11608 | ||
11609 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 11610 | } |
11611 | ||
d62a17ae | 11612 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
11613 | safi_t safi) | |
f186de26 | 11614 | { |
d62a17ae | 11615 | struct listnode *node, *nnode; |
11616 | struct bgp *bgp; | |
f186de26 | 11617 | |
d62a17ae | 11618 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
11619 | vty_out(vty, "\nInstance %s:\n", | |
11620 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11621 | ? VRF_DEFAULT_NAME |
d62a17ae | 11622 | : bgp->name); |
11623 | update_group_show(bgp, afi, safi, vty, 0); | |
11624 | } | |
f186de26 | 11625 | } |
11626 | ||
d62a17ae | 11627 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
11628 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 11629 | { |
d62a17ae | 11630 | struct bgp *bgp; |
4fb25c53 | 11631 | |
d62a17ae | 11632 | if (name) { |
11633 | if (strmatch(name, "all")) { | |
11634 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
11635 | return CMD_SUCCESS; | |
11636 | } else { | |
11637 | bgp = bgp_lookup_by_name(name); | |
11638 | } | |
11639 | } else { | |
11640 | bgp = bgp_get_default(); | |
11641 | } | |
4fb25c53 | 11642 | |
d62a17ae | 11643 | if (bgp) |
11644 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
11645 | return CMD_SUCCESS; | |
4fb25c53 DW |
11646 | } |
11647 | ||
8fe8a7f6 DS |
11648 | DEFUN (show_ip_bgp_updgrps, |
11649 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 11650 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 11651 | SHOW_STR |
11652 | IP_STR | |
11653 | BGP_STR | |
11654 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 11655 | BGP_AFI_HELP_STR |
9bedbb1e | 11656 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
11657 | "Detailed info about dynamic update groups\n" |
11658 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 11659 | { |
d62a17ae | 11660 | char *vrf = NULL; |
11661 | afi_t afi = AFI_IP6; | |
11662 | safi_t safi = SAFI_UNICAST; | |
11663 | uint64_t subgrp_id = 0; | |
11664 | ||
11665 | int idx = 0; | |
11666 | ||
11667 | /* show [ip] bgp */ | |
11668 | if (argv_find(argv, argc, "ip", &idx)) | |
11669 | afi = AFI_IP; | |
9a8bdf1c PG |
11670 | /* [<vrf> VIEWVRFNAME] */ |
11671 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11672 | vrf = argv[idx + 1]->arg; | |
11673 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11674 | vrf = NULL; | |
11675 | } else if (argv_find(argv, argc, "view", &idx)) | |
11676 | /* [<view> VIEWVRFNAME] */ | |
11677 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11678 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11679 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11680 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11681 | } | |
5bf15956 | 11682 | |
d62a17ae | 11683 | /* get subgroup id, if provided */ |
11684 | idx = argc - 1; | |
11685 | if (argv[idx]->type == VARIABLE_TKN) | |
11686 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 11687 | |
d62a17ae | 11688 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
11689 | } |
11690 | ||
f186de26 | 11691 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
11692 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 11693 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 11694 | SHOW_STR |
716b2d8a | 11695 | IP_STR |
f186de26 | 11696 | BGP_STR |
11697 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 11698 | "Detailed info about dynamic update groups\n") |
f186de26 | 11699 | { |
d62a17ae | 11700 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
11701 | return CMD_SUCCESS; | |
f186de26 | 11702 | } |
11703 | ||
43d3f4fc DS |
11704 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
11705 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
11706 | "show [ip] bgp l2vpn evpn update-groups", | |
11707 | SHOW_STR | |
11708 | IP_STR | |
11709 | BGP_STR | |
11710 | "l2vpn address family\n" | |
11711 | "evpn sub-address family\n" | |
11712 | "Detailed info about dynamic update groups\n") | |
11713 | { | |
11714 | char *vrf = NULL; | |
11715 | uint64_t subgrp_id = 0; | |
11716 | ||
11717 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
11718 | return CMD_SUCCESS; | |
11719 | } | |
11720 | ||
5bf15956 DW |
11721 | DEFUN (show_bgp_updgrps_stats, |
11722 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 11723 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 11724 | SHOW_STR |
716b2d8a | 11725 | IP_STR |
3f9c7369 | 11726 | BGP_STR |
0c7b1b01 | 11727 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
11728 | "Statistics\n") |
11729 | { | |
d62a17ae | 11730 | struct bgp *bgp; |
3f9c7369 | 11731 | |
d62a17ae | 11732 | bgp = bgp_get_default(); |
11733 | if (bgp) | |
11734 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 11735 | |
d62a17ae | 11736 | return CMD_SUCCESS; |
3f9c7369 DS |
11737 | } |
11738 | ||
8386ac43 | 11739 | DEFUN (show_bgp_instance_updgrps_stats, |
11740 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 11741 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 11742 | SHOW_STR |
716b2d8a | 11743 | IP_STR |
8386ac43 | 11744 | BGP_STR |
11745 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 11746 | "Detailed info about dynamic update groups\n" |
8386ac43 | 11747 | "Statistics\n") |
11748 | { | |
d62a17ae | 11749 | int idx_word = 3; |
11750 | struct bgp *bgp; | |
8386ac43 | 11751 | |
d62a17ae | 11752 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
11753 | if (bgp) | |
11754 | update_group_show_stats(bgp, vty); | |
8386ac43 | 11755 | |
d62a17ae | 11756 | return CMD_SUCCESS; |
8386ac43 | 11757 | } |
11758 | ||
d62a17ae | 11759 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
11760 | afi_t afi, safi_t safi, | |
11761 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 11762 | { |
d62a17ae | 11763 | struct bgp *bgp; |
8386ac43 | 11764 | |
d62a17ae | 11765 | if (name) |
11766 | bgp = bgp_lookup_by_name(name); | |
11767 | else | |
11768 | bgp = bgp_get_default(); | |
8386ac43 | 11769 | |
d62a17ae | 11770 | if (bgp) { |
11771 | if (!strcmp(what, "advertise-queue")) | |
11772 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
11773 | subgrp_id); | |
11774 | else if (!strcmp(what, "advertised-routes")) | |
11775 | update_group_show_advertised(bgp, afi, safi, vty, | |
11776 | subgrp_id); | |
11777 | else if (!strcmp(what, "packet-queue")) | |
11778 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
11779 | subgrp_id); | |
11780 | } | |
3f9c7369 DS |
11781 | } |
11782 | ||
dc64bdec QY |
11783 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
11784 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
11785 | "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", | |
11786 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
11787 | BGP_SAFI_HELP_STR | |
11788 | "Detailed info about dynamic update groups\n" | |
11789 | "Specific subgroup to display info for\n" | |
11790 | "Advertisement queue\n" | |
11791 | "Announced routes\n" | |
11792 | "Packet queue\n") | |
3f9c7369 | 11793 | { |
dc64bdec QY |
11794 | uint64_t subgrp_id = 0; |
11795 | afi_t afiz; | |
11796 | safi_t safiz; | |
11797 | if (sgid) | |
11798 | subgrp_id = strtoull(sgid, NULL, 10); | |
11799 | ||
11800 | if (!ip && !afi) | |
11801 | afiz = AFI_IP6; | |
11802 | if (!ip && afi) | |
11803 | afiz = bgp_vty_afi_from_str(afi); | |
11804 | if (ip && !afi) | |
11805 | afiz = AFI_IP; | |
11806 | if (ip && afi) { | |
11807 | afiz = bgp_vty_afi_from_str(afi); | |
11808 | if (afiz != AFI_IP) | |
11809 | vty_out(vty, | |
11810 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
11811 | return CMD_WARNING; | |
11812 | } | |
d62a17ae | 11813 | |
dc64bdec | 11814 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 11815 | |
dc64bdec | 11816 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 11817 | return CMD_SUCCESS; |
11818 | } | |
11819 | ||
d62a17ae | 11820 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
11821 | { | |
11822 | struct listnode *node, *nnode; | |
11823 | struct prefix *range; | |
11824 | struct peer *conf; | |
11825 | struct peer *peer; | |
11826 | char buf[PREFIX2STR_BUFFER]; | |
11827 | afi_t afi; | |
11828 | safi_t safi; | |
11829 | const char *peer_status; | |
11830 | const char *af_str; | |
11831 | int lr_count; | |
11832 | int dynamic; | |
11833 | int af_cfgd; | |
11834 | ||
11835 | conf = group->conf; | |
11836 | ||
11837 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
3b61f610 QY |
11838 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
11839 | group->name, conf->as); | |
d62a17ae | 11840 | } else if (conf->as_type == AS_INTERNAL) { |
3b61f610 QY |
11841 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
11842 | group->name, group->bgp->as); | |
d62a17ae | 11843 | } else { |
11844 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
11845 | } | |
f14e6fdb | 11846 | |
d62a17ae | 11847 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
11848 | vty_out(vty, " Peer-group type is internal\n"); | |
11849 | else | |
11850 | vty_out(vty, " Peer-group type is external\n"); | |
11851 | ||
11852 | /* Display AFs configured. */ | |
11853 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
11854 | FOREACH_AFI_SAFI (afi, safi) { |
11855 | if (conf->afc[afi][safi]) { | |
11856 | af_cfgd = 1; | |
11857 | vty_out(vty, " %s;", afi_safi_print(afi, safi)); | |
d62a17ae | 11858 | } |
05c7a1cc | 11859 | } |
d62a17ae | 11860 | if (!af_cfgd) |
11861 | vty_out(vty, " none\n"); | |
11862 | else | |
11863 | vty_out(vty, "\n"); | |
11864 | ||
11865 | /* Display listen ranges (for dynamic neighbors), if any */ | |
11866 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
11867 | if (afi == AFI_IP) | |
11868 | af_str = "IPv4"; | |
11869 | else if (afi == AFI_IP6) | |
11870 | af_str = "IPv6"; | |
11871 | else | |
11872 | af_str = "???"; | |
11873 | lr_count = listcount(group->listen_range[afi]); | |
11874 | if (lr_count) { | |
11875 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
11876 | af_str); | |
11877 | ||
11878 | ||
11879 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
11880 | nnode, range)) { | |
11881 | prefix2str(range, buf, sizeof(buf)); | |
11882 | vty_out(vty, " %s\n", buf); | |
11883 | } | |
11884 | } | |
11885 | } | |
f14e6fdb | 11886 | |
d62a17ae | 11887 | /* Display group members and their status */ |
11888 | if (listcount(group->peer)) { | |
11889 | vty_out(vty, " Peer-group members:\n"); | |
11890 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
11891 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
11892 | peer_status = "Idle (Admin)"; | |
11893 | else if (CHECK_FLAG(peer->sflags, | |
11894 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11895 | peer_status = "Idle (PfxCt)"; | |
11896 | else | |
11897 | peer_status = lookup_msg(bgp_status_msg, | |
11898 | peer->status, NULL); | |
11899 | ||
11900 | dynamic = peer_dynamic_neighbor(peer); | |
11901 | vty_out(vty, " %s %s %s \n", peer->host, | |
11902 | dynamic ? "(dynamic)" : "", peer_status); | |
11903 | } | |
11904 | } | |
f14e6fdb | 11905 | |
d62a17ae | 11906 | return CMD_SUCCESS; |
11907 | } | |
11908 | ||
ff9959b0 QY |
11909 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
11910 | const char *group_name) | |
d62a17ae | 11911 | { |
ff9959b0 | 11912 | struct bgp *bgp; |
d62a17ae | 11913 | struct listnode *node, *nnode; |
11914 | struct peer_group *group; | |
ff9959b0 QY |
11915 | bool found = false; |
11916 | ||
11917 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
11918 | ||
11919 | if (!bgp) { | |
9f049418 | 11920 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
11921 | return CMD_WARNING; |
11922 | } | |
d62a17ae | 11923 | |
11924 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
11925 | if (group_name) { |
11926 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 11927 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
11928 | found = true; |
11929 | break; | |
d62a17ae | 11930 | } |
ff9959b0 QY |
11931 | } else { |
11932 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 11933 | } |
f14e6fdb | 11934 | } |
f14e6fdb | 11935 | |
ff9959b0 | 11936 | if (group_name && !found) |
d62a17ae | 11937 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 11938 | |
d62a17ae | 11939 | return CMD_SUCCESS; |
f14e6fdb DS |
11940 | } |
11941 | ||
f14e6fdb DS |
11942 | DEFUN (show_ip_bgp_peer_groups, |
11943 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 11944 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
11945 | SHOW_STR |
11946 | IP_STR | |
11947 | BGP_STR | |
8386ac43 | 11948 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
11949 | "Detailed information on BGP peer groups\n" |
11950 | "Peer group name\n") | |
f14e6fdb | 11951 | { |
d62a17ae | 11952 | char *vrf, *pg; |
d62a17ae | 11953 | int idx = 0; |
f14e6fdb | 11954 | |
a4d82a8a PZ |
11955 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
11956 | : NULL; | |
d62a17ae | 11957 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 11958 | |
ff9959b0 | 11959 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 11960 | } |
3f9c7369 | 11961 | |
d6e3c605 | 11962 | |
718e3744 | 11963 | /* Redistribute VTY commands. */ |
11964 | ||
718e3744 | 11965 | DEFUN (bgp_redistribute_ipv4, |
11966 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 11967 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 11968 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11969 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 11970 | { |
d62a17ae | 11971 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11972 | int idx_protocol = 1; | |
11973 | int type; | |
718e3744 | 11974 | |
d62a17ae | 11975 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
11976 | if (type < 0) { | |
11977 | vty_out(vty, "%% Invalid route type\n"); | |
11978 | return CMD_WARNING_CONFIG_FAILED; | |
11979 | } | |
7f323236 | 11980 | |
d62a17ae | 11981 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 11982 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 11983 | } |
11984 | ||
d62a17ae | 11985 | ALIAS_HIDDEN( |
11986 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
11987 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
11988 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 11989 | |
718e3744 | 11990 | DEFUN (bgp_redistribute_ipv4_rmap, |
11991 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 11992 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 11993 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11994 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 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_word = 3; | |
12001 | int type; | |
12002 | struct bgp_redist *red; | |
e923dd62 | 12003 | bool changed; |
1de27621 DA |
12004 | struct route_map *route_map = route_map_lookup_warn_noexist( |
12005 | vty, argv[idx_word]->arg); | |
718e3744 | 12006 | |
d62a17ae | 12007 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
12008 | if (type < 0) { | |
12009 | vty_out(vty, "%% Invalid route type\n"); | |
12010 | return CMD_WARNING_CONFIG_FAILED; | |
12011 | } | |
718e3744 | 12012 | |
d62a17ae | 12013 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
12014 | changed = |
12015 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12016 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 12017 | } |
12018 | ||
d62a17ae | 12019 | ALIAS_HIDDEN( |
12020 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
12021 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
12022 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12023 | "Route map reference\n" | |
12024 | "Pointer to route-map entries\n") | |
596c17ba | 12025 | |
718e3744 | 12026 | DEFUN (bgp_redistribute_ipv4_metric, |
12027 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 12028 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 12029 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12030 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12031 | "Metric for redistributed routes\n" |
12032 | "Default metric\n") | |
12033 | { | |
d62a17ae | 12034 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12035 | int idx_protocol = 1; | |
12036 | int idx_number = 3; | |
12037 | int type; | |
d7c0a89a | 12038 | uint32_t metric; |
d62a17ae | 12039 | struct bgp_redist *red; |
e923dd62 | 12040 | bool changed; |
d62a17ae | 12041 | |
12042 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12043 | if (type < 0) { | |
12044 | vty_out(vty, "%% Invalid route type\n"); | |
12045 | return CMD_WARNING_CONFIG_FAILED; | |
12046 | } | |
12047 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
12048 | ||
12049 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 12050 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
12051 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 12052 | } |
12053 | ||
12054 | ALIAS_HIDDEN( | |
12055 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
12056 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
12057 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12058 | "Metric for redistributed routes\n" | |
12059 | "Default metric\n") | |
596c17ba | 12060 | |
718e3744 | 12061 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
12062 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 12063 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 12064 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12065 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12066 | "Route map reference\n" |
12067 | "Pointer to route-map entries\n" | |
12068 | "Metric for redistributed routes\n" | |
12069 | "Default metric\n") | |
12070 | { | |
d62a17ae | 12071 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12072 | int idx_protocol = 1; | |
12073 | int idx_word = 3; | |
12074 | int idx_number = 5; | |
12075 | int type; | |
d7c0a89a | 12076 | uint32_t metric; |
d62a17ae | 12077 | struct bgp_redist *red; |
e923dd62 | 12078 | bool changed; |
1de27621 DA |
12079 | struct route_map *route_map = |
12080 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12081 | |
12082 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12083 | if (type < 0) { | |
12084 | vty_out(vty, "%% Invalid route type\n"); | |
12085 | return CMD_WARNING_CONFIG_FAILED; | |
12086 | } | |
12087 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
12088 | ||
12089 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
12090 | changed = |
12091 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12092 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
12093 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 12094 | } |
12095 | ||
12096 | ALIAS_HIDDEN( | |
12097 | bgp_redistribute_ipv4_rmap_metric, | |
12098 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
12099 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
12100 | " route-map WORD metric (0-4294967295)", | |
12101 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12102 | "Route map reference\n" | |
12103 | "Pointer to route-map entries\n" | |
12104 | "Metric for redistributed routes\n" | |
12105 | "Default metric\n") | |
596c17ba | 12106 | |
718e3744 | 12107 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
12108 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 12109 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 12110 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12111 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12112 | "Metric for redistributed routes\n" |
12113 | "Default metric\n" | |
12114 | "Route map reference\n" | |
12115 | "Pointer to route-map entries\n") | |
12116 | { | |
d62a17ae | 12117 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12118 | int idx_protocol = 1; | |
12119 | int idx_number = 3; | |
12120 | int idx_word = 5; | |
12121 | int type; | |
d7c0a89a | 12122 | uint32_t metric; |
d62a17ae | 12123 | struct bgp_redist *red; |
e923dd62 | 12124 | bool changed; |
1de27621 DA |
12125 | struct route_map *route_map = |
12126 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12127 | |
12128 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12129 | if (type < 0) { | |
12130 | vty_out(vty, "%% Invalid route type\n"); | |
12131 | return CMD_WARNING_CONFIG_FAILED; | |
12132 | } | |
12133 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
12134 | ||
12135 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 12136 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
12137 | changed |= |
12138 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12139 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 12140 | } |
12141 | ||
12142 | ALIAS_HIDDEN( | |
12143 | bgp_redistribute_ipv4_metric_rmap, | |
12144 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
12145 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
12146 | " metric (0-4294967295) route-map WORD", | |
12147 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12148 | "Metric for redistributed routes\n" | |
12149 | "Default metric\n" | |
12150 | "Route map reference\n" | |
12151 | "Pointer to route-map entries\n") | |
596c17ba | 12152 | |
7c8ff89e DS |
12153 | DEFUN (bgp_redistribute_ipv4_ospf, |
12154 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 12155 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
12156 | "Redistribute information from another routing protocol\n" |
12157 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12158 | "Non-main Kernel Routing Table\n" |
12159 | "Instance ID/Table ID\n") | |
7c8ff89e | 12160 | { |
d62a17ae | 12161 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12162 | int idx_ospf_table = 1; | |
12163 | int idx_number = 2; | |
d7c0a89a QY |
12164 | unsigned short instance; |
12165 | unsigned short protocol; | |
7c8ff89e | 12166 | |
d62a17ae | 12167 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 12168 | |
d62a17ae | 12169 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
12170 | protocol = ZEBRA_ROUTE_OSPF; | |
12171 | else | |
12172 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 12173 | |
d62a17ae | 12174 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 12175 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
12176 | } |
12177 | ||
d62a17ae | 12178 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
12179 | "redistribute <ospf|table> (1-65535)", | |
12180 | "Redistribute information from another routing protocol\n" | |
12181 | "Open Shortest Path First (OSPFv2)\n" | |
12182 | "Non-main Kernel Routing Table\n" | |
12183 | "Instance ID/Table ID\n") | |
596c17ba | 12184 | |
7c8ff89e DS |
12185 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
12186 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 12187 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
12188 | "Redistribute information from another routing protocol\n" |
12189 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12190 | "Non-main Kernel Routing Table\n" |
12191 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12192 | "Route map reference\n" |
12193 | "Pointer to route-map entries\n") | |
12194 | { | |
d62a17ae | 12195 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12196 | int idx_ospf_table = 1; | |
12197 | int idx_number = 2; | |
12198 | int idx_word = 4; | |
12199 | struct bgp_redist *red; | |
d7c0a89a | 12200 | unsigned short instance; |
d62a17ae | 12201 | int protocol; |
e923dd62 | 12202 | bool changed; |
1de27621 DA |
12203 | struct route_map *route_map = |
12204 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12205 | |
12206 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12207 | protocol = ZEBRA_ROUTE_OSPF; | |
12208 | else | |
12209 | protocol = ZEBRA_ROUTE_TABLE; | |
12210 | ||
12211 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12212 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
12213 | changed = |
12214 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12215 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 12216 | } |
12217 | ||
12218 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
12219 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
12220 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
12221 | "Redistribute information from another routing protocol\n" | |
12222 | "Open Shortest Path First (OSPFv2)\n" | |
12223 | "Non-main Kernel Routing Table\n" | |
12224 | "Instance ID/Table ID\n" | |
12225 | "Route map reference\n" | |
12226 | "Pointer to route-map entries\n") | |
596c17ba | 12227 | |
7c8ff89e DS |
12228 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
12229 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 12230 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
12231 | "Redistribute information from another routing protocol\n" |
12232 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12233 | "Non-main Kernel Routing Table\n" |
12234 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12235 | "Metric for redistributed routes\n" |
12236 | "Default metric\n") | |
12237 | { | |
d62a17ae | 12238 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12239 | int idx_ospf_table = 1; | |
12240 | int idx_number = 2; | |
12241 | int idx_number_2 = 4; | |
d7c0a89a | 12242 | uint32_t metric; |
d62a17ae | 12243 | struct bgp_redist *red; |
d7c0a89a | 12244 | unsigned short instance; |
d62a17ae | 12245 | int protocol; |
e923dd62 | 12246 | bool changed; |
d62a17ae | 12247 | |
12248 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12249 | protocol = ZEBRA_ROUTE_OSPF; | |
12250 | else | |
12251 | protocol = ZEBRA_ROUTE_TABLE; | |
12252 | ||
12253 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12254 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12255 | ||
12256 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 12257 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12258 | metric); | |
12259 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 12260 | } |
12261 | ||
12262 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
12263 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
12264 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
12265 | "Redistribute information from another routing protocol\n" | |
12266 | "Open Shortest Path First (OSPFv2)\n" | |
12267 | "Non-main Kernel Routing Table\n" | |
12268 | "Instance ID/Table ID\n" | |
12269 | "Metric for redistributed routes\n" | |
12270 | "Default metric\n") | |
596c17ba | 12271 | |
7c8ff89e DS |
12272 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
12273 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 12274 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
12275 | "Redistribute information from another routing protocol\n" |
12276 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12277 | "Non-main Kernel Routing Table\n" |
12278 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12279 | "Route map reference\n" |
12280 | "Pointer to route-map entries\n" | |
12281 | "Metric for redistributed routes\n" | |
12282 | "Default metric\n") | |
12283 | { | |
d62a17ae | 12284 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12285 | int idx_ospf_table = 1; | |
12286 | int idx_number = 2; | |
12287 | int idx_word = 4; | |
12288 | int idx_number_2 = 6; | |
d7c0a89a | 12289 | uint32_t metric; |
d62a17ae | 12290 | struct bgp_redist *red; |
d7c0a89a | 12291 | unsigned short instance; |
d62a17ae | 12292 | int protocol; |
e923dd62 | 12293 | bool changed; |
1de27621 DA |
12294 | struct route_map *route_map = |
12295 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12296 | |
12297 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12298 | protocol = ZEBRA_ROUTE_OSPF; | |
12299 | else | |
12300 | protocol = ZEBRA_ROUTE_TABLE; | |
12301 | ||
12302 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12303 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12304 | ||
12305 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
12306 | changed = |
12307 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12308 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12309 | metric); | |
12310 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 12311 | } |
12312 | ||
12313 | ALIAS_HIDDEN( | |
12314 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
12315 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
12316 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
12317 | "Redistribute information from another routing protocol\n" | |
12318 | "Open Shortest Path First (OSPFv2)\n" | |
12319 | "Non-main Kernel Routing Table\n" | |
12320 | "Instance ID/Table ID\n" | |
12321 | "Route map reference\n" | |
12322 | "Pointer to route-map entries\n" | |
12323 | "Metric for redistributed routes\n" | |
12324 | "Default metric\n") | |
596c17ba | 12325 | |
7c8ff89e DS |
12326 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
12327 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 12328 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
12329 | "Redistribute information from another routing protocol\n" |
12330 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12331 | "Non-main Kernel Routing Table\n" |
12332 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12333 | "Metric for redistributed routes\n" |
12334 | "Default metric\n" | |
12335 | "Route map reference\n" | |
12336 | "Pointer to route-map entries\n") | |
12337 | { | |
d62a17ae | 12338 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12339 | int idx_ospf_table = 1; | |
12340 | int idx_number = 2; | |
12341 | int idx_number_2 = 4; | |
12342 | int idx_word = 6; | |
d7c0a89a | 12343 | uint32_t metric; |
d62a17ae | 12344 | struct bgp_redist *red; |
d7c0a89a | 12345 | unsigned short instance; |
d62a17ae | 12346 | int protocol; |
e923dd62 | 12347 | bool changed; |
1de27621 DA |
12348 | struct route_map *route_map = |
12349 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12350 | |
12351 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12352 | protocol = ZEBRA_ROUTE_OSPF; | |
12353 | else | |
12354 | protocol = ZEBRA_ROUTE_TABLE; | |
12355 | ||
12356 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12357 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12358 | ||
12359 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 12360 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12361 | metric); | |
1de27621 DA |
12362 | changed |= |
12363 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12364 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 12365 | } |
12366 | ||
12367 | ALIAS_HIDDEN( | |
12368 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
12369 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
12370 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
12371 | "Redistribute information from another routing protocol\n" | |
12372 | "Open Shortest Path First (OSPFv2)\n" | |
12373 | "Non-main Kernel Routing Table\n" | |
12374 | "Instance ID/Table ID\n" | |
12375 | "Metric for redistributed routes\n" | |
12376 | "Default metric\n" | |
12377 | "Route map reference\n" | |
12378 | "Pointer to route-map entries\n") | |
596c17ba | 12379 | |
7c8ff89e DS |
12380 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
12381 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 12382 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
12383 | NO_STR |
12384 | "Redistribute information from another routing protocol\n" | |
12385 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 12386 | "Non-main Kernel Routing Table\n" |
31500417 DW |
12387 | "Instance ID/Table ID\n" |
12388 | "Metric for redistributed routes\n" | |
12389 | "Default metric\n" | |
12390 | "Route map reference\n" | |
12391 | "Pointer to route-map entries\n") | |
7c8ff89e | 12392 | { |
d62a17ae | 12393 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12394 | int idx_ospf_table = 2; | |
12395 | int idx_number = 3; | |
d7c0a89a | 12396 | unsigned short instance; |
d62a17ae | 12397 | int protocol; |
12398 | ||
12399 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12400 | protocol = ZEBRA_ROUTE_OSPF; | |
12401 | else | |
12402 | protocol = ZEBRA_ROUTE_TABLE; | |
12403 | ||
12404 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12405 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
12406 | } | |
12407 | ||
12408 | ALIAS_HIDDEN( | |
12409 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
12410 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", | |
12411 | NO_STR | |
12412 | "Redistribute information from another routing protocol\n" | |
12413 | "Open Shortest Path First (OSPFv2)\n" | |
12414 | "Non-main Kernel Routing Table\n" | |
12415 | "Instance ID/Table ID\n" | |
12416 | "Metric for redistributed routes\n" | |
12417 | "Default metric\n" | |
12418 | "Route map reference\n" | |
12419 | "Pointer to route-map entries\n") | |
596c17ba | 12420 | |
718e3744 | 12421 | DEFUN (no_bgp_redistribute_ipv4, |
12422 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 12423 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 12424 | NO_STR |
12425 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12426 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
12427 | "Metric for redistributed routes\n" |
12428 | "Default metric\n" | |
12429 | "Route map reference\n" | |
12430 | "Pointer to route-map entries\n") | |
718e3744 | 12431 | { |
d62a17ae | 12432 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12433 | int idx_protocol = 2; | |
12434 | int type; | |
12435 | ||
12436 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12437 | if (type < 0) { | |
12438 | vty_out(vty, "%% Invalid route type\n"); | |
12439 | return CMD_WARNING_CONFIG_FAILED; | |
12440 | } | |
12441 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
12442 | } | |
12443 | ||
12444 | ALIAS_HIDDEN( | |
12445 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
12446 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
12447 | " [metric (0-4294967295)] [route-map WORD]", | |
12448 | NO_STR | |
12449 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12450 | "Metric for redistributed routes\n" | |
12451 | "Default metric\n" | |
12452 | "Route map reference\n" | |
12453 | "Pointer to route-map entries\n") | |
596c17ba | 12454 | |
718e3744 | 12455 | DEFUN (bgp_redistribute_ipv6, |
12456 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 12457 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 12458 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12459 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 12460 | { |
d62a17ae | 12461 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12462 | int idx_protocol = 1; | |
12463 | int type; | |
718e3744 | 12464 | |
d62a17ae | 12465 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12466 | if (type < 0) { | |
12467 | vty_out(vty, "%% Invalid route type\n"); | |
12468 | return CMD_WARNING_CONFIG_FAILED; | |
12469 | } | |
718e3744 | 12470 | |
d62a17ae | 12471 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12472 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 12473 | } |
12474 | ||
12475 | DEFUN (bgp_redistribute_ipv6_rmap, | |
12476 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 12477 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 12478 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12479 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12480 | "Route map reference\n" |
12481 | "Pointer to route-map entries\n") | |
12482 | { | |
d62a17ae | 12483 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12484 | int idx_protocol = 1; | |
12485 | int idx_word = 3; | |
12486 | int type; | |
12487 | struct bgp_redist *red; | |
e923dd62 | 12488 | bool changed; |
1de27621 DA |
12489 | struct route_map *route_map = |
12490 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 12491 | |
d62a17ae | 12492 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12493 | if (type < 0) { | |
12494 | vty_out(vty, "%% Invalid route type\n"); | |
12495 | return CMD_WARNING_CONFIG_FAILED; | |
12496 | } | |
718e3744 | 12497 | |
d62a17ae | 12498 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
12499 | changed = |
12500 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12501 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 12502 | } |
12503 | ||
12504 | DEFUN (bgp_redistribute_ipv6_metric, | |
12505 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 12506 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 12507 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12508 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12509 | "Metric for redistributed routes\n" |
12510 | "Default metric\n") | |
12511 | { | |
d62a17ae | 12512 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12513 | int idx_protocol = 1; | |
12514 | int idx_number = 3; | |
12515 | int type; | |
d7c0a89a | 12516 | uint32_t metric; |
d62a17ae | 12517 | struct bgp_redist *red; |
e923dd62 | 12518 | bool changed; |
d62a17ae | 12519 | |
12520 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12521 | if (type < 0) { | |
12522 | vty_out(vty, "%% Invalid route type\n"); | |
12523 | return CMD_WARNING_CONFIG_FAILED; | |
12524 | } | |
12525 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12526 | |
d62a17ae | 12527 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12528 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
12529 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12530 | } |
12531 | ||
12532 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
12533 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 12534 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 12535 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12536 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12537 | "Route map reference\n" |
12538 | "Pointer to route-map entries\n" | |
12539 | "Metric for redistributed routes\n" | |
12540 | "Default metric\n") | |
12541 | { | |
d62a17ae | 12542 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12543 | int idx_protocol = 1; | |
12544 | int idx_word = 3; | |
12545 | int idx_number = 5; | |
12546 | int type; | |
d7c0a89a | 12547 | uint32_t metric; |
d62a17ae | 12548 | struct bgp_redist *red; |
e923dd62 | 12549 | bool changed; |
1de27621 DA |
12550 | struct route_map *route_map = |
12551 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12552 | |
12553 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12554 | if (type < 0) { | |
12555 | vty_out(vty, "%% Invalid route type\n"); | |
12556 | return CMD_WARNING_CONFIG_FAILED; | |
12557 | } | |
12558 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12559 | |
d62a17ae | 12560 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
12561 | changed = |
12562 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12563 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
12564 | metric); | |
12565 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12566 | } |
12567 | ||
12568 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
12569 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 12570 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 12571 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12572 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12573 | "Metric for redistributed routes\n" |
12574 | "Default metric\n" | |
12575 | "Route map reference\n" | |
12576 | "Pointer to route-map entries\n") | |
12577 | { | |
d62a17ae | 12578 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12579 | int idx_protocol = 1; | |
12580 | int idx_number = 3; | |
12581 | int idx_word = 5; | |
12582 | int type; | |
d7c0a89a | 12583 | uint32_t metric; |
d62a17ae | 12584 | struct bgp_redist *red; |
e923dd62 | 12585 | bool changed; |
1de27621 DA |
12586 | struct route_map *route_map = |
12587 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12588 | |
12589 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12590 | if (type < 0) { | |
12591 | vty_out(vty, "%% Invalid route type\n"); | |
12592 | return CMD_WARNING_CONFIG_FAILED; | |
12593 | } | |
12594 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12595 | |
d62a17ae | 12596 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12597 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
12598 | metric); | |
1de27621 DA |
12599 | changed |= |
12600 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12601 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 12602 | } |
12603 | ||
12604 | DEFUN (no_bgp_redistribute_ipv6, | |
12605 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 12606 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 12607 | NO_STR |
12608 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12609 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
12610 | "Metric for redistributed routes\n" |
12611 | "Default metric\n" | |
12612 | "Route map reference\n" | |
12613 | "Pointer to route-map entries\n") | |
718e3744 | 12614 | { |
d62a17ae | 12615 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12616 | int idx_protocol = 2; | |
12617 | int type; | |
718e3744 | 12618 | |
d62a17ae | 12619 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12620 | if (type < 0) { | |
12621 | vty_out(vty, "%% Invalid route type\n"); | |
12622 | return CMD_WARNING_CONFIG_FAILED; | |
12623 | } | |
718e3744 | 12624 | |
d62a17ae | 12625 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
12626 | } | |
12627 | ||
2b791107 | 12628 | void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 12629 | safi_t safi) |
d62a17ae | 12630 | { |
12631 | int i; | |
12632 | ||
12633 | /* Unicast redistribution only. */ | |
12634 | if (safi != SAFI_UNICAST) | |
2b791107 | 12635 | return; |
d62a17ae | 12636 | |
12637 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
12638 | /* Redistribute BGP does not make sense. */ | |
12639 | if (i != ZEBRA_ROUTE_BGP) { | |
12640 | struct list *red_list; | |
12641 | struct listnode *node; | |
12642 | struct bgp_redist *red; | |
12643 | ||
12644 | red_list = bgp->redist[afi][i]; | |
12645 | if (!red_list) | |
12646 | continue; | |
12647 | ||
12648 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 12649 | /* "redistribute" configuration. */ |
12650 | vty_out(vty, " redistribute %s", | |
12651 | zebra_route_string(i)); | |
12652 | if (red->instance) | |
12653 | vty_out(vty, " %d", red->instance); | |
12654 | if (red->redist_metric_flag) | |
12655 | vty_out(vty, " metric %u", | |
12656 | red->redist_metric); | |
12657 | if (red->rmap.name) | |
12658 | vty_out(vty, " route-map %s", | |
12659 | red->rmap.name); | |
12660 | vty_out(vty, "\n"); | |
12661 | } | |
12662 | } | |
12663 | } | |
718e3744 | 12664 | } |
6b0655a2 | 12665 | |
b9c7bc5a PZ |
12666 | /* This is part of the address-family block (unicast only) */ |
12667 | void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, | |
ddb5b488 PZ |
12668 | afi_t afi) |
12669 | { | |
b9c7bc5a | 12670 | int indent = 2; |
ddb5b488 | 12671 | |
8a066a70 PG |
12672 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
12673 | if (listcount(bgp->vpn_policy[afi].import_vrf)) | |
12674 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", | |
12675 | bgp->vpn_policy[afi] | |
bb4f6190 | 12676 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
12677 | else |
12678 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
12679 | bgp->vpn_policy[afi] | |
12680 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
12681 | } | |
12a844a5 DS |
12682 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
12683 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
12684 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
12685 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
12686 | return; | |
12687 | ||
e70e9f8e PZ |
12688 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
12689 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
12690 | ||
12691 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
12692 | ||
12693 | } else { | |
12694 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
12695 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
12696 | bgp->vpn_policy[afi].tovpn_label); | |
12697 | } | |
ddb5b488 PZ |
12698 | } |
12699 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12700 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
12701 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 12702 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
12703 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
12704 | sizeof(buf))); | |
12705 | } | |
12706 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12707 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
12708 | ||
12709 | char buf[PREFIX_STRLEN]; | |
12710 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
12711 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
12712 | sizeof(buf))) { | |
12713 | ||
b9c7bc5a PZ |
12714 | vty_out(vty, "%*snexthop vpn export %s\n", |
12715 | indent, "", buf); | |
ddb5b488 PZ |
12716 | } |
12717 | } | |
12718 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
12719 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
12720 | && ecommunity_cmp( | |
12721 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12722 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
12723 | ||
12724 | char *b = ecommunity_ecom2str( | |
12725 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12726 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12727 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
12728 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12729 | } else { | |
12730 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
12731 | char *b = ecommunity_ecom2str( | |
12732 | bgp->vpn_policy[afi] | |
12733 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12734 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12735 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12736 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
12737 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12738 | } | |
12739 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
12740 | char *b = ecommunity_ecom2str( | |
12741 | bgp->vpn_policy[afi] | |
12742 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12743 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12744 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12745 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
12746 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12747 | } | |
12748 | } | |
bb4f6190 DS |
12749 | |
12750 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 12751 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
12752 | bgp->vpn_policy[afi] |
12753 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 12754 | |
301ad80a PG |
12755 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
12756 | char *b = ecommunity_ecom2str( | |
12757 | bgp->vpn_policy[afi] | |
12758 | .import_redirect_rtlist, | |
12759 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12760 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 12761 | |
301ad80a PG |
12762 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
12763 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
12764 | } | |
ddb5b488 PZ |
12765 | } |
12766 | ||
12767 | ||
718e3744 | 12768 | /* BGP node structure. */ |
d62a17ae | 12769 | static struct cmd_node bgp_node = { |
9d303b37 | 12770 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 12771 | }; |
12772 | ||
d62a17ae | 12773 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 12774 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12775 | }; |
12776 | ||
d62a17ae | 12777 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 12778 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12779 | }; |
12780 | ||
d62a17ae | 12781 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 12782 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12783 | }; |
12784 | ||
d62a17ae | 12785 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 12786 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12787 | }; |
12788 | ||
d62a17ae | 12789 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 12790 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 12791 | }; |
12792 | ||
d62a17ae | 12793 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 12794 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12795 | }; |
12796 | ||
d62a17ae | 12797 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
12798 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 12799 | |
d62a17ae | 12800 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
12801 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 12802 | |
d62a17ae | 12803 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
12804 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 12805 | |
d62a17ae | 12806 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
12807 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 12808 | |
7c40bf39 | 12809 | static struct cmd_node bgp_flowspecv4_node = {BGP_FLOWSPECV4_NODE, |
12810 | "%s(config-router-af)# ", 1}; | |
12811 | ||
12812 | static struct cmd_node bgp_flowspecv6_node = {BGP_FLOWSPECV6_NODE, | |
12813 | "%s(config-router-af-vpnv6)# ", 1}; | |
12814 | ||
d62a17ae | 12815 | static void community_list_vty(void); |
1f8ae70b | 12816 | |
d62a17ae | 12817 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 12818 | { |
d62a17ae | 12819 | struct bgp *bgp; |
12820 | struct peer *peer; | |
d62a17ae | 12821 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 12822 | |
d62a17ae | 12823 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
12824 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
12825 | /* only provide suggestions on the appropriate input | |
12826 | * token type, | |
12827 | * they'll otherwise show up multiple times */ | |
12828 | enum cmd_token_type match_type; | |
12829 | char *name = peer->host; | |
d48ed3e0 | 12830 | |
d62a17ae | 12831 | if (peer->conf_if) { |
12832 | match_type = VARIABLE_TKN; | |
12833 | name = peer->conf_if; | |
12834 | } else if (strchr(peer->host, ':')) | |
12835 | match_type = IPV6_TKN; | |
12836 | else | |
12837 | match_type = IPV4_TKN; | |
d48ed3e0 | 12838 | |
d62a17ae | 12839 | if (token->type != match_type) |
12840 | continue; | |
d48ed3e0 | 12841 | |
d62a17ae | 12842 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
12843 | } | |
d62a17ae | 12844 | } |
b8a815e5 DL |
12845 | } |
12846 | ||
12847 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 12848 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
12849 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 12850 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 12851 | {.completions = NULL}}; |
12852 | ||
47a306a0 DS |
12853 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
12854 | { | |
12855 | struct bgp *bgp; | |
12856 | struct peer_group *group; | |
12857 | struct listnode *lnbgp, *lnpeer; | |
12858 | ||
12859 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
12860 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
12861 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
12862 | group->name)); | |
12863 | } | |
12864 | } | |
12865 | ||
12866 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
12867 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
12868 | {.completions = NULL} }; | |
12869 | ||
d62a17ae | 12870 | void bgp_vty_init(void) |
12871 | { | |
12872 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 12873 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 12874 | |
12875 | /* Install bgp top node. */ | |
12876 | install_node(&bgp_node, bgp_config_write); | |
12877 | install_node(&bgp_ipv4_unicast_node, NULL); | |
12878 | install_node(&bgp_ipv4_multicast_node, NULL); | |
12879 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
12880 | install_node(&bgp_ipv6_unicast_node, NULL); | |
12881 | install_node(&bgp_ipv6_multicast_node, NULL); | |
12882 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
12883 | install_node(&bgp_vpnv4_node, NULL); | |
12884 | install_node(&bgp_vpnv6_node, NULL); | |
12885 | install_node(&bgp_evpn_node, NULL); | |
12886 | install_node(&bgp_evpn_vni_node, NULL); | |
7c40bf39 | 12887 | install_node(&bgp_flowspecv4_node, NULL); |
12888 | install_node(&bgp_flowspecv6_node, NULL); | |
d62a17ae | 12889 | |
12890 | /* Install default VTY commands to new nodes. */ | |
12891 | install_default(BGP_NODE); | |
12892 | install_default(BGP_IPV4_NODE); | |
12893 | install_default(BGP_IPV4M_NODE); | |
12894 | install_default(BGP_IPV4L_NODE); | |
12895 | install_default(BGP_IPV6_NODE); | |
12896 | install_default(BGP_IPV6M_NODE); | |
12897 | install_default(BGP_IPV6L_NODE); | |
12898 | install_default(BGP_VPNV4_NODE); | |
12899 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 12900 | install_default(BGP_FLOWSPECV4_NODE); |
12901 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 12902 | install_default(BGP_EVPN_NODE); |
12903 | install_default(BGP_EVPN_VNI_NODE); | |
12904 | ||
12905 | /* "bgp multiple-instance" commands. */ | |
12906 | install_element(CONFIG_NODE, &bgp_multiple_instance_cmd); | |
12907 | install_element(CONFIG_NODE, &no_bgp_multiple_instance_cmd); | |
12908 | ||
12909 | /* "bgp config-type" commands. */ | |
12910 | install_element(CONFIG_NODE, &bgp_config_type_cmd); | |
12911 | install_element(CONFIG_NODE, &no_bgp_config_type_cmd); | |
12912 | ||
8029b216 AK |
12913 | /* "bgp local-mac" hidden commands. */ |
12914 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
12915 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
12916 | ||
d62a17ae | 12917 | /* bgp route-map delay-timer commands. */ |
12918 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
12919 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
12920 | ||
12921 | /* Dummy commands (Currently not supported) */ | |
12922 | install_element(BGP_NODE, &no_synchronization_cmd); | |
12923 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
12924 | ||
12925 | /* "router bgp" commands. */ | |
12926 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
12927 | ||
12928 | /* "no router bgp" commands. */ | |
12929 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
12930 | ||
12931 | /* "bgp router-id" commands. */ | |
12932 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
12933 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
12934 | ||
12935 | /* "bgp cluster-id" commands. */ | |
12936 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
12937 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
12938 | ||
12939 | /* "bgp confederation" commands. */ | |
12940 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
12941 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
12942 | ||
12943 | /* "bgp confederation peers" commands. */ | |
12944 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
12945 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
12946 | ||
12947 | /* bgp max-med command */ | |
12948 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
12949 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
12950 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
12951 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
12952 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
12953 | ||
12954 | /* bgp disable-ebgp-connected-nh-check */ | |
12955 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
12956 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
12957 | ||
12958 | /* bgp update-delay command */ | |
12959 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
12960 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
12961 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
12962 | ||
12963 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
12964 | install_element(BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
555e09d4 QY |
12965 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
12966 | install_element(BGP_NODE, &no_bgp_rpkt_quanta_cmd); | |
d62a17ae | 12967 | |
12968 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
12969 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
12970 | ||
12971 | /* "maximum-paths" commands. */ | |
12972 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
12973 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
12974 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
12975 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
12976 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
12977 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
12978 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
12979 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
12980 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
12981 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
12982 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12983 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12984 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
12985 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12986 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12987 | ||
12988 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
12989 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
12990 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
12991 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12992 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12993 | ||
12994 | /* "timers bgp" commands. */ | |
12995 | install_element(BGP_NODE, &bgp_timers_cmd); | |
12996 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
12997 | ||
12998 | /* route-map delay-timer commands - per instance for backwards compat. | |
12999 | */ | |
13000 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
13001 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
13002 | ||
13003 | /* "bgp client-to-client reflection" commands */ | |
13004 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
13005 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
13006 | ||
13007 | /* "bgp always-compare-med" commands */ | |
13008 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
13009 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
13010 | ||
9dac9fc8 DA |
13011 | /* bgp ebgp-requires-policy */ |
13012 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
13013 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
13014 | ||
d62a17ae | 13015 | /* "bgp deterministic-med" commands */ |
13016 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
13017 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
13018 | ||
13019 | /* "bgp graceful-restart" commands */ | |
13020 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); | |
13021 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
13022 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); | |
13023 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
13024 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
13025 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
13026 | ||
13027 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); | |
13028 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
13029 | ||
7f323236 DW |
13030 | /* "bgp graceful-shutdown" commands */ |
13031 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
13032 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
13033 | ||
d62a17ae | 13034 | /* "bgp fast-external-failover" commands */ |
13035 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
13036 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
13037 | ||
13038 | /* "bgp enforce-first-as" commands */ | |
13039 | install_element(BGP_NODE, &bgp_enforce_first_as_cmd); | |
d62a17ae | 13040 | |
13041 | /* "bgp bestpath compare-routerid" commands */ | |
13042 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
13043 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
13044 | ||
13045 | /* "bgp bestpath as-path ignore" commands */ | |
13046 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
13047 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
13048 | ||
13049 | /* "bgp bestpath as-path confed" commands */ | |
13050 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
13051 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
13052 | ||
13053 | /* "bgp bestpath as-path multipath-relax" commands */ | |
13054 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
13055 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
13056 | ||
13057 | /* "bgp log-neighbor-changes" commands */ | |
13058 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
13059 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
13060 | ||
13061 | /* "bgp bestpath med" commands */ | |
13062 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
13063 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
13064 | ||
13065 | /* "no bgp default ipv4-unicast" commands. */ | |
13066 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
13067 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
13068 | ||
13069 | /* "bgp network import-check" commands. */ | |
13070 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
13071 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
13072 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
13073 | ||
13074 | /* "bgp default local-preference" commands. */ | |
13075 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
13076 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
13077 | ||
13078 | /* bgp default show-hostname */ | |
13079 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
13080 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
13081 | ||
13082 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
13083 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
13084 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
13085 | ||
13086 | /* bgp ibgp-allow-policy-mods command */ | |
13087 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
13088 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
13089 | ||
13090 | /* "bgp listen limit" commands. */ | |
13091 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
13092 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
13093 | ||
13094 | /* "bgp listen range" commands. */ | |
13095 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
13096 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
13097 | ||
8175f54a | 13098 | /* "bgp default shutdown" command */ |
f26845f9 QY |
13099 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
13100 | ||
d62a17ae | 13101 | /* "neighbor remote-as" commands. */ |
13102 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
13103 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
13104 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
13105 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
13106 | install_element(BGP_NODE, | |
13107 | &neighbor_interface_v6only_config_remote_as_cmd); | |
13108 | install_element(BGP_NODE, &no_neighbor_cmd); | |
13109 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
13110 | ||
13111 | /* "neighbor peer-group" commands. */ | |
13112 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
13113 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
13114 | install_element(BGP_NODE, | |
13115 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
13116 | ||
13117 | /* "neighbor local-as" commands. */ | |
13118 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
13119 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
13120 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
13121 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
13122 | ||
13123 | /* "neighbor solo" commands. */ | |
13124 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
13125 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
13126 | ||
13127 | /* "neighbor password" commands. */ | |
13128 | install_element(BGP_NODE, &neighbor_password_cmd); | |
13129 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
13130 | ||
13131 | /* "neighbor activate" commands. */ | |
13132 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
13133 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
13134 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
13135 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
13136 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
13137 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
13138 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
13139 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
13140 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 13141 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
13142 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 13143 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
13144 | ||
13145 | /* "no neighbor activate" commands. */ | |
13146 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
13147 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
13148 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
13149 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
13150 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
13151 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
13152 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
13153 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
13154 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 13155 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
13156 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 13157 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
13158 | ||
13159 | /* "neighbor peer-group" set commands. */ | |
13160 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
13161 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13162 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13163 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13164 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13165 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13166 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13167 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 13168 | install_element(BGP_FLOWSPECV4_NODE, |
13169 | &neighbor_set_peer_group_hidden_cmd); | |
13170 | install_element(BGP_FLOWSPECV6_NODE, | |
13171 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 13172 | |
13173 | /* "no neighbor peer-group unset" commands. */ | |
13174 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
13175 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13176 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13177 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13178 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13179 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13180 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13181 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 13182 | install_element(BGP_FLOWSPECV4_NODE, |
13183 | &no_neighbor_set_peer_group_hidden_cmd); | |
13184 | install_element(BGP_FLOWSPECV6_NODE, | |
13185 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 13186 | |
13187 | /* "neighbor softreconfiguration inbound" commands.*/ | |
13188 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
13189 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
13190 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
13191 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13192 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
13193 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13194 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
13195 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13196 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
13197 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13198 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
13199 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13200 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
13201 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13202 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
13203 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13204 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
13205 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 13206 | install_element(BGP_FLOWSPECV4_NODE, |
13207 | &neighbor_soft_reconfiguration_cmd); | |
13208 | install_element(BGP_FLOWSPECV4_NODE, | |
13209 | &no_neighbor_soft_reconfiguration_cmd); | |
13210 | install_element(BGP_FLOWSPECV6_NODE, | |
13211 | &neighbor_soft_reconfiguration_cmd); | |
13212 | install_element(BGP_FLOWSPECV6_NODE, | |
13213 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
13214 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
13215 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 13216 | |
13217 | /* "neighbor attribute-unchanged" commands. */ | |
13218 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
13219 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
13220 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
13221 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
13222 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
13223 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
13224 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
13225 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
13226 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
13227 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
13228 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
13229 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
13230 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
13231 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
13232 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
13233 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
13234 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
13235 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
13236 | ||
13237 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
13238 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
13239 | ||
13240 | /* "nexthop-local unchanged" commands */ | |
13241 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
13242 | install_element(BGP_IPV6_NODE, | |
13243 | &no_neighbor_nexthop_local_unchanged_cmd); | |
13244 | ||
13245 | /* "neighbor next-hop-self" commands. */ | |
13246 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
13247 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
13248 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
13249 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
13250 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
13251 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
13252 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
13253 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
13254 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
13255 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
13256 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
13257 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
13258 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
13259 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
13260 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
13261 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
13262 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
13263 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
13264 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
13265 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 13266 | |
13267 | /* "neighbor next-hop-self force" commands. */ | |
13268 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
13269 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
13270 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13271 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13272 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
13273 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13274 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
13275 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13276 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); | |
13277 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13278 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
13279 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13280 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
13281 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13282 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); | |
13283 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13284 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
13285 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13286 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); | |
13287 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13288 | ||
13289 | /* "neighbor as-override" commands. */ | |
13290 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
13291 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
13292 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
13293 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
13294 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
13295 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
13296 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
13297 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
13298 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
13299 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
13300 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
13301 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
13302 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
13303 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
13304 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
13305 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
13306 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
13307 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
13308 | ||
13309 | /* "neighbor remove-private-AS" commands. */ | |
13310 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
13311 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
13312 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
13313 | install_element(BGP_NODE, | |
13314 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
13315 | install_element(BGP_NODE, | |
13316 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
13317 | install_element(BGP_NODE, | |
13318 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
13319 | install_element(BGP_NODE, | |
13320 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
13321 | install_element( | |
13322 | BGP_NODE, | |
13323 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
13324 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
13325 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
13326 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
13327 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13328 | install_element(BGP_IPV4_NODE, | |
13329 | &neighbor_remove_private_as_replace_as_cmd); | |
13330 | install_element(BGP_IPV4_NODE, | |
13331 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13332 | install_element(BGP_IPV4_NODE, | |
13333 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13334 | install_element(BGP_IPV4_NODE, | |
13335 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13336 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
13337 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
13338 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
13339 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13340 | install_element(BGP_IPV4M_NODE, | |
13341 | &neighbor_remove_private_as_replace_as_cmd); | |
13342 | install_element(BGP_IPV4M_NODE, | |
13343 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13344 | install_element(BGP_IPV4M_NODE, | |
13345 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13346 | install_element(BGP_IPV4M_NODE, | |
13347 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13348 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
13349 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
13350 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
13351 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13352 | install_element(BGP_IPV4L_NODE, | |
13353 | &neighbor_remove_private_as_replace_as_cmd); | |
13354 | install_element(BGP_IPV4L_NODE, | |
13355 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13356 | install_element(BGP_IPV4L_NODE, | |
13357 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13358 | install_element(BGP_IPV4L_NODE, | |
13359 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13360 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
13361 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
13362 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
13363 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13364 | install_element(BGP_IPV6_NODE, | |
13365 | &neighbor_remove_private_as_replace_as_cmd); | |
13366 | install_element(BGP_IPV6_NODE, | |
13367 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13368 | install_element(BGP_IPV6_NODE, | |
13369 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13370 | install_element(BGP_IPV6_NODE, | |
13371 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13372 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
13373 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
13374 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
13375 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13376 | install_element(BGP_IPV6M_NODE, | |
13377 | &neighbor_remove_private_as_replace_as_cmd); | |
13378 | install_element(BGP_IPV6M_NODE, | |
13379 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13380 | install_element(BGP_IPV6M_NODE, | |
13381 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13382 | install_element(BGP_IPV6M_NODE, | |
13383 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13384 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
13385 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
13386 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
13387 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13388 | install_element(BGP_IPV6L_NODE, | |
13389 | &neighbor_remove_private_as_replace_as_cmd); | |
13390 | install_element(BGP_IPV6L_NODE, | |
13391 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13392 | install_element(BGP_IPV6L_NODE, | |
13393 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13394 | install_element(BGP_IPV6L_NODE, | |
13395 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13396 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
13397 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
13398 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
13399 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13400 | install_element(BGP_VPNV4_NODE, | |
13401 | &neighbor_remove_private_as_replace_as_cmd); | |
13402 | install_element(BGP_VPNV4_NODE, | |
13403 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13404 | install_element(BGP_VPNV4_NODE, | |
13405 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13406 | install_element(BGP_VPNV4_NODE, | |
13407 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13408 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
13409 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
13410 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
13411 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13412 | install_element(BGP_VPNV6_NODE, | |
13413 | &neighbor_remove_private_as_replace_as_cmd); | |
13414 | install_element(BGP_VPNV6_NODE, | |
13415 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13416 | install_element(BGP_VPNV6_NODE, | |
13417 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13418 | install_element(BGP_VPNV6_NODE, | |
13419 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13420 | ||
13421 | /* "neighbor send-community" commands.*/ | |
13422 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
13423 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
13424 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
13425 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
13426 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
13427 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
13428 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
13429 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
13430 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
13431 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
13432 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
13433 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
13434 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
13435 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
13436 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
13437 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
13438 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
13439 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
13440 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
13441 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
13442 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
13443 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
13444 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
13445 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
13446 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
13447 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
13448 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
13449 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
13450 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
13451 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
13452 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
13453 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
13454 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
13455 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
13456 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
13457 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
13458 | ||
13459 | /* "neighbor route-reflector" commands.*/ | |
13460 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
13461 | install_element(BGP_NODE, | |
13462 | &no_neighbor_route_reflector_client_hidden_cmd); | |
13463 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
13464 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
13465 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
13466 | install_element(BGP_IPV4M_NODE, | |
13467 | &no_neighbor_route_reflector_client_cmd); | |
13468 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
13469 | install_element(BGP_IPV4L_NODE, | |
13470 | &no_neighbor_route_reflector_client_cmd); | |
13471 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
13472 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
13473 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
13474 | install_element(BGP_IPV6M_NODE, | |
13475 | &no_neighbor_route_reflector_client_cmd); | |
13476 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
13477 | install_element(BGP_IPV6L_NODE, | |
13478 | &no_neighbor_route_reflector_client_cmd); | |
13479 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
13480 | install_element(BGP_VPNV4_NODE, | |
13481 | &no_neighbor_route_reflector_client_cmd); | |
13482 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
13483 | install_element(BGP_VPNV6_NODE, | |
13484 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 13485 | install_element(BGP_FLOWSPECV4_NODE, |
13486 | &neighbor_route_reflector_client_cmd); | |
13487 | install_element(BGP_FLOWSPECV4_NODE, | |
13488 | &no_neighbor_route_reflector_client_cmd); | |
13489 | install_element(BGP_FLOWSPECV6_NODE, | |
13490 | &neighbor_route_reflector_client_cmd); | |
13491 | install_element(BGP_FLOWSPECV6_NODE, | |
13492 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 13493 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
13494 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
13495 | ||
13496 | /* "neighbor route-server" commands.*/ | |
13497 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
13498 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
13499 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
13500 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
13501 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
13502 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
13503 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
13504 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
13505 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
13506 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
13507 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
13508 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
13509 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
13510 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
13511 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
13512 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
13513 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
13514 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
13515 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
13516 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 13517 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
13518 | install_element(BGP_FLOWSPECV4_NODE, | |
13519 | &no_neighbor_route_server_client_cmd); | |
13520 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
13521 | install_element(BGP_FLOWSPECV6_NODE, | |
13522 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 13523 | |
13524 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
13525 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
13526 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
13527 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13528 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13529 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13530 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13531 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13532 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13533 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13534 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13535 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13536 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13537 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13538 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13539 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13540 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13541 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13542 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13543 | ||
13544 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
13545 | install_element(BGP_NODE, | |
13546 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
13547 | install_element(BGP_NODE, | |
13548 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
13549 | install_element(BGP_IPV4_NODE, | |
13550 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13551 | install_element(BGP_IPV4_NODE, | |
13552 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13553 | install_element(BGP_IPV4M_NODE, | |
13554 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13555 | install_element(BGP_IPV4M_NODE, | |
13556 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13557 | install_element(BGP_IPV4L_NODE, | |
13558 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13559 | install_element(BGP_IPV4L_NODE, | |
13560 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13561 | install_element(BGP_IPV6_NODE, | |
13562 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13563 | install_element(BGP_IPV6_NODE, | |
13564 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13565 | install_element(BGP_IPV6M_NODE, | |
13566 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13567 | install_element(BGP_IPV6M_NODE, | |
13568 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13569 | install_element(BGP_IPV6L_NODE, | |
13570 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13571 | install_element(BGP_IPV6L_NODE, | |
13572 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13573 | install_element(BGP_VPNV4_NODE, | |
13574 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13575 | install_element(BGP_VPNV4_NODE, | |
13576 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13577 | install_element(BGP_VPNV6_NODE, | |
13578 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13579 | install_element(BGP_VPNV6_NODE, | |
13580 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13581 | ||
13582 | /* "neighbor passive" commands. */ | |
13583 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
13584 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
13585 | ||
13586 | ||
13587 | /* "neighbor shutdown" commands. */ | |
13588 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
13589 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
13590 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
13591 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
13592 | ||
13593 | /* "neighbor capability extended-nexthop" commands.*/ | |
13594 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
13595 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
13596 | ||
13597 | /* "neighbor capability orf prefix-list" commands.*/ | |
13598 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
13599 | install_element(BGP_NODE, | |
13600 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
13601 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
13602 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13603 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13604 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13605 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13606 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13607 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
13608 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13609 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13610 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13611 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13612 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13613 | ||
13614 | /* "neighbor capability dynamic" commands.*/ | |
13615 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
13616 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
13617 | ||
13618 | /* "neighbor dont-capability-negotiate" commands. */ | |
13619 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
13620 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
13621 | ||
13622 | /* "neighbor ebgp-multihop" commands. */ | |
13623 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
13624 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
13625 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
13626 | ||
13627 | /* "neighbor disable-connected-check" commands. */ | |
13628 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
13629 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
13630 | ||
47cbc09b PM |
13631 | /* "neighbor enforce-first-as" commands. */ |
13632 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
13633 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
13634 | ||
d62a17ae | 13635 | /* "neighbor description" commands. */ |
13636 | install_element(BGP_NODE, &neighbor_description_cmd); | |
13637 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 13638 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 13639 | |
13640 | /* "neighbor update-source" commands. "*/ | |
13641 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
13642 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
13643 | ||
13644 | /* "neighbor default-originate" commands. */ | |
13645 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
13646 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
13647 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
13648 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
13649 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
13650 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
13651 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
13652 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
13653 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
13654 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
13655 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
13656 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
13657 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
13658 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
13659 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
13660 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
13661 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
13662 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
13663 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
13664 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
13665 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
13666 | ||
13667 | /* "neighbor port" commands. */ | |
13668 | install_element(BGP_NODE, &neighbor_port_cmd); | |
13669 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
13670 | ||
13671 | /* "neighbor weight" commands. */ | |
13672 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
13673 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
13674 | ||
13675 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
13676 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
13677 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
13678 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
13679 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
13680 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
13681 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
13682 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
13683 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
13684 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
13685 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
13686 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
13687 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
13688 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
13689 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
13690 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
13691 | ||
13692 | /* "neighbor override-capability" commands. */ | |
13693 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
13694 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
13695 | ||
13696 | /* "neighbor strict-capability-match" commands. */ | |
13697 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
13698 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
13699 | ||
13700 | /* "neighbor timers" commands. */ | |
13701 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
13702 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
13703 | ||
13704 | /* "neighbor timers connect" commands. */ | |
13705 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
13706 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
13707 | ||
13708 | /* "neighbor advertisement-interval" commands. */ | |
13709 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
13710 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
13711 | ||
13712 | /* "neighbor interface" commands. */ | |
13713 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
13714 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
13715 | ||
13716 | /* "neighbor distribute" commands. */ | |
13717 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
13718 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
13719 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
13720 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
13721 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
13722 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
13723 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
13724 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
13725 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
13726 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
13727 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
13728 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
13729 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
13730 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
13731 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
13732 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
13733 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
13734 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
13735 | ||
13736 | /* "neighbor prefix-list" commands. */ | |
13737 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
13738 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
13739 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
13740 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
13741 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
13742 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
13743 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
13744 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
13745 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
13746 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
13747 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
13748 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
13749 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
13750 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
13751 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
13752 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
13753 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
13754 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 13755 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
13756 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
13757 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
13758 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 13759 | |
13760 | /* "neighbor filter-list" commands. */ | |
13761 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
13762 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
13763 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
13764 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
13765 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
13766 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
13767 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
13768 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
13769 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
13770 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
13771 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
13772 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
13773 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
13774 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
13775 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
13776 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
13777 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
13778 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 13779 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
13780 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
13781 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
13782 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 13783 | |
13784 | /* "neighbor route-map" commands. */ | |
13785 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
13786 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
13787 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
13788 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
13789 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
13790 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
13791 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
13792 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
13793 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
13794 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
13795 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
13796 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
13797 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
13798 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
13799 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
13800 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
13801 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
13802 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 13803 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
13804 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
13805 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
13806 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
13807 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
13808 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 13809 | |
13810 | /* "neighbor unsuppress-map" commands. */ | |
13811 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
13812 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
13813 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
13814 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13815 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
13816 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13817 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
13818 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13819 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
13820 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13821 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
13822 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13823 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
13824 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13825 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
13826 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13827 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
13828 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13829 | ||
13830 | /* "neighbor maximum-prefix" commands. */ | |
13831 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
13832 | install_element(BGP_NODE, | |
13833 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
13834 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
13835 | install_element(BGP_NODE, | |
13836 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
13837 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
13838 | install_element(BGP_NODE, | |
13839 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
13840 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
13841 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
13842 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13843 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13844 | install_element(BGP_IPV4_NODE, | |
13845 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13846 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13847 | install_element(BGP_IPV4_NODE, | |
13848 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13849 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13850 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
13851 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13852 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13853 | install_element(BGP_IPV4M_NODE, | |
13854 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13855 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13856 | install_element(BGP_IPV4M_NODE, | |
13857 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13858 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13859 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
13860 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13861 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13862 | install_element(BGP_IPV4L_NODE, | |
13863 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13864 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13865 | install_element(BGP_IPV4L_NODE, | |
13866 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13867 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13868 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
13869 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13870 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13871 | install_element(BGP_IPV6_NODE, | |
13872 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13873 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13874 | install_element(BGP_IPV6_NODE, | |
13875 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13876 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13877 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
13878 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13879 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13880 | install_element(BGP_IPV6M_NODE, | |
13881 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13882 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13883 | install_element(BGP_IPV6M_NODE, | |
13884 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13885 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13886 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
13887 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13888 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13889 | install_element(BGP_IPV6L_NODE, | |
13890 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13891 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13892 | install_element(BGP_IPV6L_NODE, | |
13893 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13894 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13895 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
13896 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13897 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13898 | install_element(BGP_VPNV4_NODE, | |
13899 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13900 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13901 | install_element(BGP_VPNV4_NODE, | |
13902 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13903 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13904 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
13905 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13906 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13907 | install_element(BGP_VPNV6_NODE, | |
13908 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13909 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13910 | install_element(BGP_VPNV6_NODE, | |
13911 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13912 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13913 | ||
13914 | /* "neighbor allowas-in" */ | |
13915 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
13916 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
13917 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
13918 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
13919 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
13920 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
13921 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
13922 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
13923 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
13924 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
13925 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
13926 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
13927 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
13928 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
13929 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
13930 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
13931 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
13932 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
13933 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
13934 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
13935 | ||
13936 | /* address-family commands. */ | |
13937 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
13938 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 13939 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 13940 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
13941 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 13942 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 13943 | |
d62a17ae | 13944 | install_element(BGP_NODE, &address_family_evpn_cmd); |
13945 | ||
13946 | /* "exit-address-family" command. */ | |
13947 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
13948 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
13949 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
13950 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
13951 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
13952 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
13953 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
13954 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 13955 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
13956 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 13957 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
13958 | ||
13959 | /* "clear ip bgp commands" */ | |
13960 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
13961 | ||
13962 | /* clear ip bgp prefix */ | |
13963 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
13964 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
13965 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
13966 | ||
13967 | /* "show [ip] bgp summary" commands. */ | |
13968 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 13969 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 13970 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 13971 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 13972 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
13973 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 13974 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
13975 | ||
13976 | /* "show [ip] bgp neighbors" commands. */ | |
13977 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
13978 | ||
13979 | /* "show [ip] bgp peer-group" commands. */ | |
13980 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
13981 | ||
13982 | /* "show [ip] bgp paths" commands. */ | |
13983 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
13984 | ||
13985 | /* "show [ip] bgp community" commands. */ | |
13986 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
13987 | ||
13988 | /* "show ip bgp large-community" commands. */ | |
13989 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
13990 | /* "show [ip] bgp attribute-info" commands. */ | |
13991 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 13992 | /* "show [ip] bgp route-leak" command */ |
13993 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 13994 | |
13995 | /* "redistribute" commands. */ | |
13996 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
13997 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
13998 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
13999 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
14000 | install_element(BGP_NODE, | |
14001 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
14002 | install_element(BGP_NODE, | |
14003 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
14004 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
14005 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
14006 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
14007 | install_element(BGP_NODE, | |
14008 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
14009 | install_element(BGP_NODE, | |
14010 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
14011 | install_element(BGP_NODE, | |
14012 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
14013 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
14014 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
14015 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
14016 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
14017 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
14018 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
14019 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
14020 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
14021 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
14022 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
14023 | install_element(BGP_IPV4_NODE, | |
14024 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
14025 | install_element(BGP_IPV4_NODE, | |
14026 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
14027 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
14028 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
14029 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
14030 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
14031 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
14032 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
14033 | ||
b9c7bc5a PZ |
14034 | /* import|export vpn [route-map WORD] */ |
14035 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
14036 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 14037 | |
12a844a5 DS |
14038 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
14039 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
14040 | ||
d62a17ae | 14041 | /* ttl_security commands */ |
14042 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
14043 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
14044 | ||
14045 | /* "show [ip] bgp memory" commands. */ | |
14046 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
14047 | ||
acf71666 MK |
14048 | /* "show bgp martian next-hop" */ |
14049 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
14050 | ||
48ecf8f5 DS |
14051 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
14052 | ||
d62a17ae | 14053 | /* "show [ip] bgp views" commands. */ |
14054 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
14055 | ||
14056 | /* "show [ip] bgp vrfs" commands. */ | |
14057 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
14058 | ||
14059 | /* Community-list. */ | |
14060 | community_list_vty(); | |
ddb5b488 PZ |
14061 | |
14062 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
14063 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
14064 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
14065 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
14066 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
14067 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
14068 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
14069 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
14070 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
14071 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
14072 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
14073 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
14074 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 14075 | |
301ad80a PG |
14076 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
14077 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
14078 | ||
b9c7bc5a PZ |
14079 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
14080 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
14081 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
14082 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
14083 | install_element(BGP_IPV4_NODE, &af_no_nexthop_vpn_export_cmd); | |
14084 | install_element(BGP_IPV6_NODE, &af_no_nexthop_vpn_export_cmd); | |
14085 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); | |
14086 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
14087 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
14088 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
14089 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
14090 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 14091 | } |
6b0655a2 | 14092 | |
718e3744 | 14093 | #include "memory.h" |
14094 | #include "bgp_regex.h" | |
14095 | #include "bgp_clist.h" | |
14096 | #include "bgp_ecommunity.h" | |
14097 | ||
14098 | /* VTY functions. */ | |
14099 | ||
14100 | /* Direction value to string conversion. */ | |
d62a17ae | 14101 | static const char *community_direct_str(int direct) |
14102 | { | |
14103 | switch (direct) { | |
14104 | case COMMUNITY_DENY: | |
14105 | return "deny"; | |
14106 | case COMMUNITY_PERMIT: | |
14107 | return "permit"; | |
14108 | default: | |
14109 | return "unknown"; | |
14110 | } | |
718e3744 | 14111 | } |
14112 | ||
14113 | /* Display error string. */ | |
d62a17ae | 14114 | static void community_list_perror(struct vty *vty, int ret) |
14115 | { | |
14116 | switch (ret) { | |
14117 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
14118 | vty_out(vty, "%% Can't find community-list\n"); | |
14119 | break; | |
14120 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
14121 | vty_out(vty, "%% Malformed community-list value\n"); | |
14122 | break; | |
14123 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
14124 | vty_out(vty, | |
14125 | "%% Community name conflict, previously defined as standard community\n"); | |
14126 | break; | |
14127 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
14128 | vty_out(vty, | |
14129 | "%% Community name conflict, previously defined as expanded community\n"); | |
14130 | break; | |
14131 | } | |
718e3744 | 14132 | } |
14133 | ||
5bf15956 DW |
14134 | /* "community-list" keyword help string. */ |
14135 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
14136 | ||
7336e101 SP |
14137 | /*community-list standard */ |
14138 | DEFUN (community_list_standard, | |
14139 | bgp_community_list_standard_cmd, | |
14140 | "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14141 | BGP_STR | |
718e3744 | 14142 | COMMUNITY_LIST_STR |
14143 | "Community list number (standard)\n" | |
5bf15956 | 14144 | "Add an standard community-list entry\n" |
718e3744 | 14145 | "Community list name\n" |
14146 | "Specify community to reject\n" | |
14147 | "Specify community to accept\n" | |
14148 | COMMUNITY_VAL_STR) | |
14149 | { | |
d62a17ae | 14150 | char *cl_name_or_number = NULL; |
14151 | int direct = 0; | |
14152 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 14153 | |
d62a17ae | 14154 | int idx = 0; |
7336e101 SP |
14155 | |
14156 | if (argv_find(argv, argc, "ip", &idx)) { | |
14157 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14158 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14159 | vty_out(vty, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
14160 | zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
14161 | } | |
14162 | ||
d62a17ae | 14163 | argv_find(argv, argc, "(1-99)", &idx); |
14164 | argv_find(argv, argc, "WORD", &idx); | |
14165 | cl_name_or_number = argv[idx]->arg; | |
14166 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14167 | : COMMUNITY_DENY; | |
14168 | argv_find(argv, argc, "AA:NN", &idx); | |
14169 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14170 | |
d62a17ae | 14171 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
14172 | style); | |
42f914d4 | 14173 | |
d62a17ae | 14174 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14175 | |
d62a17ae | 14176 | if (ret < 0) { |
14177 | /* Display error string. */ | |
14178 | community_list_perror(vty, ret); | |
14179 | return CMD_WARNING_CONFIG_FAILED; | |
14180 | } | |
42f914d4 | 14181 | |
d62a17ae | 14182 | return CMD_SUCCESS; |
718e3744 | 14183 | } |
14184 | ||
7336e101 SP |
14185 | #if CONFDATE > 20191005 |
14186 | CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command") | |
14187 | #endif | |
14188 | ALIAS (community_list_standard, | |
14189 | ip_community_list_standard_cmd, | |
14190 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 14191 | IP_STR |
14192 | COMMUNITY_LIST_STR | |
14193 | "Community list number (standard)\n" | |
5bf15956 DW |
14194 | "Add an standard community-list entry\n" |
14195 | "Community list name\n" | |
718e3744 | 14196 | "Specify community to reject\n" |
14197 | "Specify community to accept\n" | |
14198 | COMMUNITY_VAL_STR) | |
7336e101 SP |
14199 | |
14200 | DEFUN (no_community_list_standard_all, | |
14201 | no_bgp_community_list_standard_all_cmd, | |
14202 | "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14203 | NO_STR | |
14204 | BGP_STR | |
14205 | COMMUNITY_LIST_STR | |
14206 | "Community list number (standard)\n" | |
14207 | "Add an standard community-list entry\n" | |
14208 | "Community list name\n" | |
14209 | "Specify community to reject\n" | |
14210 | "Specify community to accept\n" | |
14211 | COMMUNITY_VAL_STR) | |
718e3744 | 14212 | { |
d62a17ae | 14213 | char *cl_name_or_number = NULL; |
174b5cb9 | 14214 | char *str = NULL; |
d62a17ae | 14215 | int direct = 0; |
14216 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 14217 | |
d62a17ae | 14218 | int idx = 0; |
7336e101 SP |
14219 | |
14220 | if (argv_find(argv, argc, "ip", &idx)) { | |
14221 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
14222 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14223 | vty_out(vty, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
14224 | zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used"); | |
14225 | } | |
14226 | ||
174b5cb9 DA |
14227 | argv_find(argv, argc, "permit", &idx); |
14228 | argv_find(argv, argc, "deny", &idx); | |
14229 | ||
14230 | if (idx) { | |
14231 | direct = argv_find(argv, argc, "permit", &idx) | |
14232 | ? COMMUNITY_PERMIT | |
14233 | : COMMUNITY_DENY; | |
14234 | ||
14235 | idx = 0; | |
14236 | argv_find(argv, argc, "AA:NN", &idx); | |
14237 | str = argv_concat(argv, argc, idx); | |
14238 | } | |
14239 | ||
14240 | idx = 0; | |
d62a17ae | 14241 | argv_find(argv, argc, "(1-99)", &idx); |
14242 | argv_find(argv, argc, "WORD", &idx); | |
14243 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 14244 | |
d62a17ae | 14245 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 14246 | direct, style); |
42f914d4 | 14247 | |
d62a17ae | 14248 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 14249 | |
d62a17ae | 14250 | if (ret < 0) { |
14251 | community_list_perror(vty, ret); | |
14252 | return CMD_WARNING_CONFIG_FAILED; | |
14253 | } | |
42f914d4 | 14254 | |
d62a17ae | 14255 | return CMD_SUCCESS; |
718e3744 | 14256 | } |
7336e101 SP |
14257 | ALIAS (no_community_list_standard_all, |
14258 | no_ip_community_list_standard_all_cmd, | |
14259 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14260 | NO_STR | |
718e3744 | 14261 | IP_STR |
14262 | COMMUNITY_LIST_STR | |
7336e101 SP |
14263 | "Community list number (standard)\n" |
14264 | "Add an standard community-list entry\n" | |
14265 | "Community list name\n" | |
14266 | "Specify community to reject\n" | |
14267 | "Specify community to accept\n" | |
14268 | COMMUNITY_VAL_STR) | |
14269 | ||
174b5cb9 DA |
14270 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
14271 | "no bgp community-list <(1-99)|standard WORD>", | |
14272 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
14273 | "Community list number (standard)\n" | |
14274 | "Add an standard community-list entry\n" | |
14275 | "Community list name\n") | |
14276 | ||
14277 | ALIAS(no_community_list_standard_all, no_ip_community_list_standard_all_list_cmd, | |
14278 | "no ip community-list <(1-99)|standard WORD>", | |
14279 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
14280 | "Community list number (standard)\n" | |
14281 | "Add an standard community-list entry\n" | |
14282 | "Community list name\n") | |
14283 | ||
7336e101 SP |
14284 | /*community-list expanded */ |
14285 | DEFUN (community_list_expanded_all, | |
14286 | bgp_community_list_expanded_all_cmd, | |
14287 | "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14288 | BGP_STR | |
14289 | COMMUNITY_LIST_STR | |
718e3744 | 14290 | "Community list number (expanded)\n" |
5bf15956 | 14291 | "Add an expanded community-list entry\n" |
718e3744 | 14292 | "Community list name\n" |
14293 | "Specify community to reject\n" | |
14294 | "Specify community to accept\n" | |
14295 | COMMUNITY_VAL_STR) | |
14296 | { | |
d62a17ae | 14297 | char *cl_name_or_number = NULL; |
14298 | int direct = 0; | |
14299 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 14300 | |
d62a17ae | 14301 | int idx = 0; |
7336e101 SP |
14302 | if (argv_find(argv, argc, "ip", &idx)) { |
14303 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14304 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14305 | vty_out(vty, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
14306 | zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
14307 | } | |
d62a17ae | 14308 | argv_find(argv, argc, "(100-500)", &idx); |
14309 | argv_find(argv, argc, "WORD", &idx); | |
14310 | cl_name_or_number = argv[idx]->arg; | |
14311 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14312 | : COMMUNITY_DENY; | |
14313 | argv_find(argv, argc, "AA:NN", &idx); | |
14314 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14315 | |
d62a17ae | 14316 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
14317 | style); | |
42f914d4 | 14318 | |
d62a17ae | 14319 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14320 | |
d62a17ae | 14321 | if (ret < 0) { |
14322 | /* Display error string. */ | |
14323 | community_list_perror(vty, ret); | |
14324 | return CMD_WARNING_CONFIG_FAILED; | |
14325 | } | |
42f914d4 | 14326 | |
d62a17ae | 14327 | return CMD_SUCCESS; |
718e3744 | 14328 | } |
14329 | ||
7336e101 SP |
14330 | ALIAS (community_list_expanded_all, |
14331 | ip_community_list_expanded_all_cmd, | |
14332 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
718e3744 | 14333 | IP_STR |
14334 | COMMUNITY_LIST_STR | |
5bf15956 DW |
14335 | "Community list number (expanded)\n" |
14336 | "Add an expanded community-list entry\n" | |
718e3744 | 14337 | "Community list name\n" |
14338 | "Specify community to reject\n" | |
14339 | "Specify community to accept\n" | |
5bf15956 | 14340 | COMMUNITY_VAL_STR) |
7336e101 SP |
14341 | |
14342 | DEFUN (no_community_list_expanded_all, | |
14343 | no_bgp_community_list_expanded_all_cmd, | |
14344 | "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14345 | NO_STR | |
14346 | BGP_STR | |
14347 | COMMUNITY_LIST_STR | |
14348 | "Community list number (expanded)\n" | |
14349 | "Add an expanded community-list entry\n" | |
14350 | "Community list name\n" | |
14351 | "Specify community to reject\n" | |
14352 | "Specify community to accept\n" | |
14353 | COMMUNITY_VAL_STR) | |
718e3744 | 14354 | { |
d62a17ae | 14355 | char *cl_name_or_number = NULL; |
174b5cb9 | 14356 | char *str = NULL; |
d62a17ae | 14357 | int direct = 0; |
14358 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 14359 | |
d62a17ae | 14360 | int idx = 0; |
7336e101 SP |
14361 | if (argv_find(argv, argc, "ip", &idx)) { |
14362 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14363 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
174b5cb9 DA |
14364 | vty_out(vty, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); |
14365 | zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
14366 | } | |
14367 | ||
3c4b8fe2 | 14368 | idx = 0; |
174b5cb9 DA |
14369 | argv_find(argv, argc, "permit", &idx); |
14370 | argv_find(argv, argc, "deny", &idx); | |
14371 | ||
14372 | if (idx) { | |
14373 | direct = argv_find(argv, argc, "permit", &idx) | |
14374 | ? COMMUNITY_PERMIT | |
14375 | : COMMUNITY_DENY; | |
14376 | ||
14377 | idx = 0; | |
14378 | argv_find(argv, argc, "AA:NN", &idx); | |
14379 | str = argv_concat(argv, argc, idx); | |
7336e101 | 14380 | } |
174b5cb9 DA |
14381 | |
14382 | idx = 0; | |
d62a17ae | 14383 | argv_find(argv, argc, "(100-500)", &idx); |
14384 | argv_find(argv, argc, "WORD", &idx); | |
14385 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 14386 | |
d62a17ae | 14387 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 14388 | direct, style); |
42f914d4 | 14389 | |
d62a17ae | 14390 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 14391 | |
d62a17ae | 14392 | if (ret < 0) { |
14393 | community_list_perror(vty, ret); | |
14394 | return CMD_WARNING_CONFIG_FAILED; | |
14395 | } | |
42f914d4 | 14396 | |
d62a17ae | 14397 | return CMD_SUCCESS; |
718e3744 | 14398 | } |
14399 | ||
7336e101 SP |
14400 | ALIAS (no_community_list_expanded_all, |
14401 | no_ip_community_list_expanded_all_cmd, | |
14402 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14403 | NO_STR | |
14404 | IP_STR | |
14405 | COMMUNITY_LIST_STR | |
14406 | "Community list number (expanded)\n" | |
14407 | "Add an expanded community-list entry\n" | |
14408 | "Community list name\n" | |
14409 | "Specify community to reject\n" | |
14410 | "Specify community to accept\n" | |
14411 | COMMUNITY_VAL_STR) | |
14412 | ||
174b5cb9 DA |
14413 | ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd, |
14414 | "no bgp community-list <(100-500)|expanded WORD>", | |
14415 | NO_STR IP_STR COMMUNITY_LIST_STR | |
14416 | "Community list number (expanded)\n" | |
14417 | "Add an expanded community-list entry\n" | |
14418 | "Community list name\n") | |
14419 | ||
14420 | ALIAS(no_community_list_expanded_all, no_ip_community_list_expanded_all_list_cmd, | |
14421 | "no ip community-list <(100-500)|expanded WORD>", | |
14422 | NO_STR IP_STR COMMUNITY_LIST_STR | |
14423 | "Community list number (expanded)\n" | |
14424 | "Add an expanded community-list entry\n" | |
14425 | "Community list name\n") | |
14426 | ||
8d9b8ed9 PM |
14427 | /* Return configuration string of community-list entry. */ |
14428 | static const char *community_list_config_str(struct community_entry *entry) | |
14429 | { | |
14430 | const char *str; | |
14431 | ||
14432 | if (entry->any) | |
14433 | str = ""; | |
14434 | else { | |
14435 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
14436 | str = community_str(entry->u.com, false); | |
14437 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
14438 | str = lcommunity_str(entry->u.lcom, false); | |
14439 | else | |
14440 | str = entry->config; | |
14441 | } | |
14442 | return str; | |
14443 | } | |
14444 | ||
d62a17ae | 14445 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 14446 | { |
d62a17ae | 14447 | struct community_entry *entry; |
718e3744 | 14448 | |
d62a17ae | 14449 | for (entry = list->head; entry; entry = entry->next) { |
14450 | if (entry == list->head) { | |
14451 | if (all_digit(list->name)) | |
14452 | vty_out(vty, "Community %s list %s\n", | |
14453 | entry->style == COMMUNITY_LIST_STANDARD | |
14454 | ? "standard" | |
14455 | : "(expanded) access", | |
14456 | list->name); | |
14457 | else | |
14458 | vty_out(vty, "Named Community %s list %s\n", | |
14459 | entry->style == COMMUNITY_LIST_STANDARD | |
14460 | ? "standard" | |
14461 | : "expanded", | |
14462 | list->name); | |
14463 | } | |
14464 | if (entry->any) | |
14465 | vty_out(vty, " %s\n", | |
14466 | community_direct_str(entry->direct)); | |
14467 | else | |
14468 | vty_out(vty, " %s %s\n", | |
14469 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14470 | community_list_config_str(entry)); |
d62a17ae | 14471 | } |
718e3744 | 14472 | } |
14473 | ||
7336e101 SP |
14474 | DEFUN (show_community_list, |
14475 | show_bgp_community_list_cmd, | |
14476 | "show bgp community-list", | |
718e3744 | 14477 | SHOW_STR |
7336e101 | 14478 | BGP_STR |
718e3744 | 14479 | "List community-list\n") |
14480 | { | |
d62a17ae | 14481 | struct community_list *list; |
14482 | struct community_list_master *cm; | |
718e3744 | 14483 | |
7336e101 SP |
14484 | int idx = 0; |
14485 | if (argv_find(argv, argc, "ip", &idx)) { | |
14486 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14487 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14488 | vty_out(vty, "'show bgp community-list <(1-500)|WORD>'\n"); | |
14489 | zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used"); | |
14490 | } | |
d62a17ae | 14491 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
14492 | if (!cm) | |
14493 | return CMD_SUCCESS; | |
718e3744 | 14494 | |
d62a17ae | 14495 | for (list = cm->num.head; list; list = list->next) |
14496 | community_list_show(vty, list); | |
718e3744 | 14497 | |
d62a17ae | 14498 | for (list = cm->str.head; list; list = list->next) |
14499 | community_list_show(vty, list); | |
718e3744 | 14500 | |
d62a17ae | 14501 | return CMD_SUCCESS; |
718e3744 | 14502 | } |
14503 | ||
7336e101 SP |
14504 | ALIAS (show_community_list, |
14505 | show_ip_community_list_cmd, | |
14506 | "show ip community-list", | |
718e3744 | 14507 | SHOW_STR |
14508 | IP_STR | |
7336e101 SP |
14509 | "List community-list\n") |
14510 | ||
14511 | DEFUN (show_community_list_arg, | |
14512 | show_bgp_community_list_arg_cmd, | |
14513 | "show bgp community-list <(1-500)|WORD>", | |
14514 | SHOW_STR | |
14515 | BGP_STR | |
718e3744 | 14516 | "List community-list\n" |
14517 | "Community-list number\n" | |
14518 | "Community-list name\n") | |
14519 | { | |
d62a17ae | 14520 | int idx_comm_list = 3; |
14521 | struct community_list *list; | |
718e3744 | 14522 | |
7336e101 SP |
14523 | int idx = 0; |
14524 | if (argv_find(argv, argc, "ip", &idx)) { | |
14525 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14526 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14527 | vty_out(vty, "'show bgp community-list <(1-500)|WORD>'\n"); | |
14528 | zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used"); | |
14529 | } | |
e237b0d2 | 14530 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 14531 | COMMUNITY_LIST_MASTER); |
14532 | if (!list) { | |
14533 | vty_out(vty, "%% Can't find community-list\n"); | |
14534 | return CMD_WARNING; | |
14535 | } | |
718e3744 | 14536 | |
d62a17ae | 14537 | community_list_show(vty, list); |
718e3744 | 14538 | |
d62a17ae | 14539 | return CMD_SUCCESS; |
718e3744 | 14540 | } |
6b0655a2 | 14541 | |
7336e101 SP |
14542 | ALIAS (show_community_list_arg, |
14543 | show_ip_community_list_arg_cmd, | |
14544 | "show ip community-list <(1-500)|WORD>", | |
14545 | SHOW_STR | |
14546 | IP_STR | |
14547 | "List community-list\n" | |
14548 | "Community-list number\n" | |
14549 | "Community-list name\n") | |
14550 | ||
57d187bc JS |
14551 | /* |
14552 | * Large Community code. | |
14553 | */ | |
d62a17ae | 14554 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
14555 | struct cmd_token **argv, int style, | |
14556 | int reject_all_digit_name) | |
14557 | { | |
14558 | int ret; | |
14559 | int direct; | |
14560 | char *str; | |
14561 | int idx = 0; | |
14562 | char *cl_name; | |
14563 | ||
7336e101 SP |
14564 | if (argv_find(argv, argc, "ip", &idx)) { |
14565 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14566 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14567 | vty_out(vty, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n"); | |
14568 | zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used"); | |
14569 | } | |
d62a17ae | 14570 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
14571 | : COMMUNITY_DENY; | |
14572 | ||
14573 | /* All digit name check. */ | |
14574 | idx = 0; | |
14575 | argv_find(argv, argc, "WORD", &idx); | |
14576 | argv_find(argv, argc, "(1-99)", &idx); | |
14577 | argv_find(argv, argc, "(100-500)", &idx); | |
14578 | cl_name = argv[idx]->arg; | |
14579 | if (reject_all_digit_name && all_digit(cl_name)) { | |
14580 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
14581 | return CMD_WARNING_CONFIG_FAILED; | |
14582 | } | |
14583 | ||
14584 | idx = 0; | |
14585 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
14586 | argv_find(argv, argc, "LINE", &idx); | |
14587 | /* Concat community string argument. */ | |
14588 | if (idx) | |
14589 | str = argv_concat(argv, argc, idx); | |
14590 | else | |
14591 | str = NULL; | |
14592 | ||
14593 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
14594 | ||
14595 | /* Free temporary community list string allocated by | |
14596 | argv_concat(). */ | |
0a22ddfb | 14597 | XFREE(MTYPE_TMP, str); |
d62a17ae | 14598 | |
14599 | if (ret < 0) { | |
14600 | community_list_perror(vty, ret); | |
14601 | return CMD_WARNING_CONFIG_FAILED; | |
14602 | } | |
14603 | return CMD_SUCCESS; | |
14604 | } | |
14605 | ||
14606 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
14607 | struct cmd_token **argv, int style) | |
14608 | { | |
14609 | int ret; | |
14610 | int direct = 0; | |
14611 | char *str = NULL; | |
14612 | int idx = 0; | |
14613 | ||
7336e101 SP |
14614 | if (argv_find(argv, argc, "ip", &idx)) { |
14615 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14616 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14617 | vty_out(vty, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n"); | |
14618 | zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used"); | |
14619 | } | |
d62a17ae | 14620 | argv_find(argv, argc, "permit", &idx); |
14621 | argv_find(argv, argc, "deny", &idx); | |
14622 | ||
14623 | if (idx) { | |
14624 | /* Check the list direct. */ | |
14625 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
14626 | direct = COMMUNITY_PERMIT; | |
14627 | else | |
14628 | direct = COMMUNITY_DENY; | |
14629 | ||
14630 | idx = 0; | |
14631 | argv_find(argv, argc, "LINE", &idx); | |
14632 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
14633 | /* Concat community string argument. */ | |
14634 | str = argv_concat(argv, argc, idx); | |
14635 | } | |
14636 | ||
14637 | idx = 0; | |
14638 | argv_find(argv, argc, "(1-99)", &idx); | |
14639 | argv_find(argv, argc, "(100-500)", &idx); | |
14640 | argv_find(argv, argc, "WORD", &idx); | |
14641 | ||
14642 | /* Unset community list. */ | |
14643 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
14644 | style); | |
14645 | ||
14646 | /* Free temporary community list string allocated by | |
14647 | argv_concat(). */ | |
0a22ddfb | 14648 | XFREE(MTYPE_TMP, str); |
d62a17ae | 14649 | |
14650 | if (ret < 0) { | |
14651 | community_list_perror(vty, ret); | |
14652 | return CMD_WARNING_CONFIG_FAILED; | |
14653 | } | |
14654 | ||
14655 | return CMD_SUCCESS; | |
57d187bc JS |
14656 | } |
14657 | ||
14658 | /* "large-community-list" keyword help string. */ | |
14659 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
14660 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
14661 | ||
7336e101 SP |
14662 | #if CONFDATE > 20191005 |
14663 | CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command") | |
14664 | #endif | |
14665 | DEFUN (lcommunity_list_standard, | |
14666 | bgp_lcommunity_list_standard_cmd, | |
14667 | "bgp large-community-list (1-99) <deny|permit>", | |
14668 | BGP_STR | |
14669 | LCOMMUNITY_LIST_STR | |
14670 | "Large Community list number (standard)\n" | |
14671 | "Specify large community to reject\n" | |
14672 | "Specify large community to accept\n") | |
14673 | { | |
14674 | return lcommunity_list_set_vty(vty, argc, argv, | |
14675 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
14676 | } | |
14677 | ||
14678 | ALIAS (lcommunity_list_standard, | |
57d187bc | 14679 | ip_lcommunity_list_standard_cmd, |
52951b63 DS |
14680 | "ip large-community-list (1-99) <deny|permit>", |
14681 | IP_STR | |
14682 | LCOMMUNITY_LIST_STR | |
14683 | "Large Community list number (standard)\n" | |
14684 | "Specify large community to reject\n" | |
7111c1a0 | 14685 | "Specify large community to accept\n") |
7336e101 SP |
14686 | |
14687 | DEFUN (lcommunity_list_standard1, | |
14688 | bgp_lcommunity_list_standard1_cmd, | |
14689 | "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
14690 | BGP_STR | |
14691 | LCOMMUNITY_LIST_STR | |
14692 | "Large Community list number (standard)\n" | |
14693 | "Specify large community to reject\n" | |
14694 | "Specify large community to accept\n" | |
14695 | LCOMMUNITY_VAL_STR) | |
52951b63 | 14696 | { |
d62a17ae | 14697 | return lcommunity_list_set_vty(vty, argc, argv, |
14698 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
14699 | } |
14700 | ||
7336e101 | 14701 | ALIAS (lcommunity_list_standard1, |
52951b63 DS |
14702 | ip_lcommunity_list_standard1_cmd, |
14703 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
14704 | IP_STR |
14705 | LCOMMUNITY_LIST_STR | |
14706 | "Large Community list number (standard)\n" | |
14707 | "Specify large community to reject\n" | |
14708 | "Specify large community to accept\n" | |
14709 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14710 | |
14711 | DEFUN (lcommunity_list_expanded, | |
14712 | bgp_lcommunity_list_expanded_cmd, | |
14713 | "bgp large-community-list (100-500) <deny|permit> LINE...", | |
14714 | BGP_STR | |
14715 | LCOMMUNITY_LIST_STR | |
14716 | "Large Community list number (expanded)\n" | |
14717 | "Specify large community to reject\n" | |
14718 | "Specify large community to accept\n" | |
14719 | "An ordered list as a regular-expression\n") | |
57d187bc | 14720 | { |
d62a17ae | 14721 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14722 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
14723 | } |
14724 | ||
7336e101 | 14725 | ALIAS (lcommunity_list_expanded, |
57d187bc JS |
14726 | ip_lcommunity_list_expanded_cmd, |
14727 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
14728 | IP_STR | |
14729 | LCOMMUNITY_LIST_STR | |
14730 | "Large Community list number (expanded)\n" | |
14731 | "Specify large community to reject\n" | |
14732 | "Specify large community to accept\n" | |
14733 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14734 | |
14735 | DEFUN (lcommunity_list_name_standard, | |
14736 | bgp_lcommunity_list_name_standard_cmd, | |
14737 | "bgp large-community-list standard WORD <deny|permit>", | |
14738 | BGP_STR | |
14739 | LCOMMUNITY_LIST_STR | |
14740 | "Specify standard large-community-list\n" | |
14741 | "Large Community list name\n" | |
14742 | "Specify large community to reject\n" | |
14743 | "Specify large community to accept\n") | |
57d187bc | 14744 | { |
d62a17ae | 14745 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14746 | LARGE_COMMUNITY_LIST_STANDARD, 1); |
57d187bc JS |
14747 | } |
14748 | ||
7336e101 | 14749 | ALIAS (lcommunity_list_name_standard, |
57d187bc | 14750 | ip_lcommunity_list_name_standard_cmd, |
52951b63 DS |
14751 | "ip large-community-list standard WORD <deny|permit>", |
14752 | IP_STR | |
14753 | LCOMMUNITY_LIST_STR | |
14754 | "Specify standard large-community-list\n" | |
14755 | "Large Community list name\n" | |
14756 | "Specify large community to reject\n" | |
14757 | "Specify large community to accept\n") | |
7336e101 SP |
14758 | |
14759 | DEFUN (lcommunity_list_name_standard1, | |
14760 | bgp_lcommunity_list_name_standard1_cmd, | |
14761 | "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
14762 | BGP_STR | |
14763 | LCOMMUNITY_LIST_STR | |
14764 | "Specify standard large-community-list\n" | |
14765 | "Large Community list name\n" | |
14766 | "Specify large community to reject\n" | |
14767 | "Specify large community to accept\n" | |
14768 | LCOMMUNITY_VAL_STR) | |
52951b63 | 14769 | { |
d62a17ae | 14770 | return lcommunity_list_set_vty(vty, argc, argv, |
14771 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
14772 | } |
14773 | ||
7336e101 | 14774 | ALIAS (lcommunity_list_name_standard1, |
52951b63 DS |
14775 | ip_lcommunity_list_name_standard1_cmd, |
14776 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
14777 | IP_STR |
14778 | LCOMMUNITY_LIST_STR | |
14779 | "Specify standard large-community-list\n" | |
14780 | "Large Community list name\n" | |
14781 | "Specify large community to reject\n" | |
14782 | "Specify large community to accept\n" | |
14783 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14784 | |
14785 | DEFUN (lcommunity_list_name_expanded, | |
14786 | bgp_lcommunity_list_name_expanded_cmd, | |
14787 | "bgp large-community-list expanded WORD <deny|permit> LINE...", | |
14788 | BGP_STR | |
14789 | LCOMMUNITY_LIST_STR | |
14790 | "Specify expanded large-community-list\n" | |
14791 | "Large Community list name\n" | |
14792 | "Specify large community to reject\n" | |
14793 | "Specify large community to accept\n" | |
14794 | "An ordered list as a regular-expression\n") | |
57d187bc | 14795 | { |
d62a17ae | 14796 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14797 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
14798 | } |
14799 | ||
7336e101 | 14800 | ALIAS (lcommunity_list_name_expanded, |
57d187bc JS |
14801 | ip_lcommunity_list_name_expanded_cmd, |
14802 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
14803 | IP_STR | |
14804 | LCOMMUNITY_LIST_STR | |
14805 | "Specify expanded large-community-list\n" | |
14806 | "Large Community list name\n" | |
14807 | "Specify large community to reject\n" | |
14808 | "Specify large community to accept\n" | |
14809 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14810 | |
14811 | DEFUN (no_lcommunity_list_standard_all, | |
14812 | no_bgp_lcommunity_list_standard_all_cmd, | |
14813 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", | |
14814 | NO_STR | |
14815 | BGP_STR | |
14816 | LCOMMUNITY_LIST_STR | |
14817 | "Large Community list number (standard)\n" | |
14818 | "Large Community list number (expanded)\n" | |
14819 | "Large Community list name\n") | |
57d187bc | 14820 | { |
7336e101 SP |
14821 | return lcommunity_list_unset_vty(vty, argc, argv, |
14822 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
14823 | } |
14824 | ||
7336e101 | 14825 | ALIAS (no_lcommunity_list_standard_all, |
57d187bc JS |
14826 | no_ip_lcommunity_list_standard_all_cmd, |
14827 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
14828 | NO_STR | |
14829 | IP_STR | |
14830 | LCOMMUNITY_LIST_STR | |
14831 | "Large Community list number (standard)\n" | |
14832 | "Large Community list number (expanded)\n" | |
14833 | "Large Community list name\n") | |
7336e101 SP |
14834 | |
14835 | DEFUN (no_lcommunity_list_name_expanded_all, | |
14836 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
14837 | "no bgp large-community-list expanded WORD", | |
14838 | NO_STR | |
14839 | BGP_STR | |
14840 | LCOMMUNITY_LIST_STR | |
14841 | "Specify expanded large-community-list\n" | |
14842 | "Large Community list name\n") | |
57d187bc | 14843 | { |
d62a17ae | 14844 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14845 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14846 | } |
14847 | ||
7336e101 | 14848 | ALIAS (no_lcommunity_list_name_expanded_all, |
57d187bc JS |
14849 | no_ip_lcommunity_list_name_expanded_all_cmd, |
14850 | "no ip large-community-list expanded WORD", | |
14851 | NO_STR | |
14852 | IP_STR | |
14853 | LCOMMUNITY_LIST_STR | |
14854 | "Specify expanded large-community-list\n" | |
14855 | "Large Community list name\n") | |
7336e101 SP |
14856 | |
14857 | DEFUN (no_lcommunity_list_standard, | |
14858 | no_bgp_lcommunity_list_standard_cmd, | |
14859 | "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
14860 | NO_STR | |
14861 | BGP_STR | |
14862 | LCOMMUNITY_LIST_STR | |
14863 | "Large Community list number (standard)\n" | |
14864 | "Specify large community to reject\n" | |
14865 | "Specify large community to accept\n" | |
14866 | LCOMMUNITY_VAL_STR) | |
57d187bc | 14867 | { |
d62a17ae | 14868 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14869 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
14870 | } |
14871 | ||
7336e101 | 14872 | ALIAS (no_lcommunity_list_standard, |
57d187bc JS |
14873 | no_ip_lcommunity_list_standard_cmd, |
14874 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
14875 | NO_STR | |
14876 | IP_STR | |
14877 | LCOMMUNITY_LIST_STR | |
14878 | "Large Community list number (standard)\n" | |
14879 | "Specify large community to reject\n" | |
14880 | "Specify large community to accept\n" | |
14881 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14882 | |
14883 | DEFUN (no_lcommunity_list_expanded, | |
14884 | no_bgp_lcommunity_list_expanded_cmd, | |
14885 | "no bgp large-community-list (100-500) <deny|permit> LINE...", | |
14886 | NO_STR | |
14887 | BGP_STR | |
14888 | LCOMMUNITY_LIST_STR | |
14889 | "Large Community list number (expanded)\n" | |
14890 | "Specify large community to reject\n" | |
14891 | "Specify large community to accept\n" | |
14892 | "An ordered list as a regular-expression\n") | |
57d187bc | 14893 | { |
d62a17ae | 14894 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14895 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14896 | } |
14897 | ||
7336e101 | 14898 | ALIAS (no_lcommunity_list_expanded, |
57d187bc JS |
14899 | no_ip_lcommunity_list_expanded_cmd, |
14900 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
14901 | NO_STR | |
14902 | IP_STR | |
14903 | LCOMMUNITY_LIST_STR | |
14904 | "Large Community list number (expanded)\n" | |
14905 | "Specify large community to reject\n" | |
14906 | "Specify large community to accept\n" | |
14907 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14908 | |
14909 | DEFUN (no_lcommunity_list_name_standard, | |
14910 | no_bgp_lcommunity_list_name_standard_cmd, | |
14911 | "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
14912 | NO_STR | |
14913 | BGP_STR | |
14914 | LCOMMUNITY_LIST_STR | |
14915 | "Specify standard large-community-list\n" | |
14916 | "Large Community list name\n" | |
14917 | "Specify large community to reject\n" | |
14918 | "Specify large community to accept\n" | |
14919 | LCOMMUNITY_VAL_STR) | |
57d187bc | 14920 | { |
d62a17ae | 14921 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14922 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
14923 | } |
14924 | ||
7336e101 | 14925 | ALIAS (no_lcommunity_list_name_standard, |
57d187bc JS |
14926 | no_ip_lcommunity_list_name_standard_cmd, |
14927 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
14928 | NO_STR | |
14929 | IP_STR | |
14930 | LCOMMUNITY_LIST_STR | |
14931 | "Specify standard large-community-list\n" | |
14932 | "Large Community list name\n" | |
14933 | "Specify large community to reject\n" | |
14934 | "Specify large community to accept\n" | |
14935 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14936 | |
14937 | DEFUN (no_lcommunity_list_name_expanded, | |
14938 | no_bgp_lcommunity_list_name_expanded_cmd, | |
14939 | "no bgp large-community-list expanded WORD <deny|permit> LINE...", | |
14940 | NO_STR | |
14941 | BGP_STR | |
14942 | LCOMMUNITY_LIST_STR | |
14943 | "Specify expanded large-community-list\n" | |
14944 | "Large community list name\n" | |
14945 | "Specify large community to reject\n" | |
14946 | "Specify large community to accept\n" | |
14947 | "An ordered list as a regular-expression\n") | |
57d187bc | 14948 | { |
d62a17ae | 14949 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14950 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14951 | } |
14952 | ||
7336e101 | 14953 | ALIAS (no_lcommunity_list_name_expanded, |
57d187bc JS |
14954 | no_ip_lcommunity_list_name_expanded_cmd, |
14955 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
14956 | NO_STR | |
14957 | IP_STR | |
14958 | LCOMMUNITY_LIST_STR | |
14959 | "Specify expanded large-community-list\n" | |
14960 | "Large community list name\n" | |
14961 | "Specify large community to reject\n" | |
14962 | "Specify large community to accept\n" | |
14963 | "An ordered list as a regular-expression\n") | |
d62a17ae | 14964 | |
14965 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) | |
14966 | { | |
14967 | struct community_entry *entry; | |
14968 | ||
14969 | for (entry = list->head; entry; entry = entry->next) { | |
14970 | if (entry == list->head) { | |
14971 | if (all_digit(list->name)) | |
14972 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 14973 | entry->style == |
14974 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 14975 | ? "standard" |
14976 | : "(expanded) access", | |
14977 | list->name); | |
14978 | else | |
14979 | vty_out(vty, | |
14980 | "Named large community %s list %s\n", | |
169b72c8 | 14981 | entry->style == |
14982 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 14983 | ? "standard" |
14984 | : "expanded", | |
14985 | list->name); | |
14986 | } | |
14987 | if (entry->any) | |
14988 | vty_out(vty, " %s\n", | |
14989 | community_direct_str(entry->direct)); | |
14990 | else | |
14991 | vty_out(vty, " %s %s\n", | |
14992 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14993 | community_list_config_str(entry)); |
d62a17ae | 14994 | } |
57d187bc JS |
14995 | } |
14996 | ||
7336e101 SP |
14997 | DEFUN (show_lcommunity_list, |
14998 | show_bgp_lcommunity_list_cmd, | |
14999 | "show bgp large-community-list", | |
57d187bc | 15000 | SHOW_STR |
7336e101 | 15001 | BGP_STR |
57d187bc JS |
15002 | "List large-community list\n") |
15003 | { | |
d62a17ae | 15004 | struct community_list *list; |
15005 | struct community_list_master *cm; | |
7336e101 SP |
15006 | int idx = 0; |
15007 | ||
15008 | if (argv_find(argv, argc, "ip", &idx)) { | |
15009 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15010 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15011 | vty_out(vty, "'show bgp large-community-list <(1-500)|WORD>'\n"); | |
15012 | zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used"); | |
15013 | } | |
57d187bc | 15014 | |
d62a17ae | 15015 | cm = community_list_master_lookup(bgp_clist, |
15016 | LARGE_COMMUNITY_LIST_MASTER); | |
15017 | if (!cm) | |
15018 | return CMD_SUCCESS; | |
57d187bc | 15019 | |
d62a17ae | 15020 | for (list = cm->num.head; list; list = list->next) |
15021 | lcommunity_list_show(vty, list); | |
57d187bc | 15022 | |
d62a17ae | 15023 | for (list = cm->str.head; list; list = list->next) |
15024 | lcommunity_list_show(vty, list); | |
57d187bc | 15025 | |
d62a17ae | 15026 | return CMD_SUCCESS; |
57d187bc JS |
15027 | } |
15028 | ||
7336e101 SP |
15029 | ALIAS (show_lcommunity_list, |
15030 | show_ip_lcommunity_list_cmd, | |
15031 | "show ip large-community-list", | |
57d187bc JS |
15032 | SHOW_STR |
15033 | IP_STR | |
7336e101 SP |
15034 | "List large-community list\n") |
15035 | ||
15036 | DEFUN (show_lcommunity_list_arg, | |
15037 | show_bgp_lcommunity_list_arg_cmd, | |
15038 | "show bgp large-community-list <(1-500)|WORD>", | |
15039 | SHOW_STR | |
15040 | BGP_STR | |
57d187bc JS |
15041 | "List large-community list\n" |
15042 | "large-community-list number\n" | |
15043 | "large-community-list name\n") | |
15044 | { | |
d62a17ae | 15045 | struct community_list *list; |
7336e101 SP |
15046 | int idx = 0; |
15047 | ||
15048 | if (argv_find(argv, argc, "ip", &idx)) { | |
15049 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15050 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15051 | vty_out(vty, "'show bgp large-community-list <(1-500)|WORD>'\n"); | |
15052 | zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used"); | |
15053 | } | |
57d187bc | 15054 | |
e237b0d2 | 15055 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 15056 | LARGE_COMMUNITY_LIST_MASTER); |
15057 | if (!list) { | |
15058 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
15059 | return CMD_WARNING; | |
15060 | } | |
57d187bc | 15061 | |
d62a17ae | 15062 | lcommunity_list_show(vty, list); |
57d187bc | 15063 | |
d62a17ae | 15064 | return CMD_SUCCESS; |
57d187bc JS |
15065 | } |
15066 | ||
7336e101 SP |
15067 | ALIAS (show_lcommunity_list_arg, |
15068 | show_ip_lcommunity_list_arg_cmd, | |
15069 | "show ip large-community-list <(1-500)|WORD>", | |
15070 | SHOW_STR | |
15071 | IP_STR | |
15072 | "List large-community list\n" | |
15073 | "large-community-list number\n" | |
15074 | "large-community-list name\n") | |
15075 | ||
718e3744 | 15076 | /* "extcommunity-list" keyword help string. */ |
15077 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
15078 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
15079 | ||
7336e101 SP |
15080 | DEFUN (extcommunity_list_standard, |
15081 | bgp_extcommunity_list_standard_cmd, | |
15082 | "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
15083 | BGP_STR | |
718e3744 | 15084 | EXTCOMMUNITY_LIST_STR |
15085 | "Extended Community list number (standard)\n" | |
718e3744 | 15086 | "Specify standard extcommunity-list\n" |
5bf15956 | 15087 | "Community list name\n" |
718e3744 | 15088 | "Specify community to reject\n" |
15089 | "Specify community to accept\n" | |
15090 | EXTCOMMUNITY_VAL_STR) | |
15091 | { | |
d62a17ae | 15092 | int style = EXTCOMMUNITY_LIST_STANDARD; |
15093 | int direct = 0; | |
15094 | char *cl_number_or_name = NULL; | |
42f914d4 | 15095 | |
d62a17ae | 15096 | int idx = 0; |
7336e101 SP |
15097 | if (argv_find(argv, argc, "ip", &idx)) { |
15098 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15099 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15100 | vty_out(vty, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15101 | zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15102 | } | |
d62a17ae | 15103 | argv_find(argv, argc, "(1-99)", &idx); |
15104 | argv_find(argv, argc, "WORD", &idx); | |
15105 | cl_number_or_name = argv[idx]->arg; | |
15106 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
15107 | : COMMUNITY_DENY; | |
15108 | argv_find(argv, argc, "AA:NN", &idx); | |
15109 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 15110 | |
d62a17ae | 15111 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
15112 | direct, style); | |
42f914d4 | 15113 | |
d62a17ae | 15114 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15115 | |
d62a17ae | 15116 | if (ret < 0) { |
15117 | community_list_perror(vty, ret); | |
15118 | return CMD_WARNING_CONFIG_FAILED; | |
15119 | } | |
42f914d4 | 15120 | |
d62a17ae | 15121 | return CMD_SUCCESS; |
718e3744 | 15122 | } |
15123 | ||
7336e101 SP |
15124 | #if CONFDATE > 20191005 |
15125 | CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command") | |
15126 | #endif | |
15127 | ALIAS (extcommunity_list_standard, | |
15128 | ip_extcommunity_list_standard_cmd, | |
15129 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 15130 | IP_STR |
15131 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
15132 | "Extended Community list number (standard)\n" |
15133 | "Specify standard extcommunity-list\n" | |
15134 | "Community list name\n" | |
15135 | "Specify community to reject\n" | |
15136 | "Specify community to accept\n" | |
15137 | EXTCOMMUNITY_VAL_STR) | |
15138 | ||
15139 | DEFUN (extcommunity_list_name_expanded, | |
15140 | bgp_extcommunity_list_name_expanded_cmd, | |
15141 | "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15142 | BGP_STR | |
15143 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 15144 | "Extended Community list number (expanded)\n" |
718e3744 | 15145 | "Specify expanded extcommunity-list\n" |
15146 | "Extended Community list name\n" | |
15147 | "Specify community to reject\n" | |
15148 | "Specify community to accept\n" | |
15149 | "An ordered list as a regular-expression\n") | |
15150 | { | |
d62a17ae | 15151 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
15152 | int direct = 0; | |
15153 | char *cl_number_or_name = NULL; | |
42f914d4 | 15154 | |
d62a17ae | 15155 | int idx = 0; |
7336e101 SP |
15156 | if (argv_find(argv, argc, "ip", &idx)) { |
15157 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15158 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15159 | vty_out(vty, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15160 | zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15161 | } | |
15162 | ||
d62a17ae | 15163 | argv_find(argv, argc, "(100-500)", &idx); |
15164 | argv_find(argv, argc, "WORD", &idx); | |
15165 | cl_number_or_name = argv[idx]->arg; | |
15166 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
15167 | : COMMUNITY_DENY; | |
15168 | argv_find(argv, argc, "LINE", &idx); | |
15169 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 15170 | |
d62a17ae | 15171 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
15172 | direct, style); | |
42f914d4 | 15173 | |
d62a17ae | 15174 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15175 | |
d62a17ae | 15176 | if (ret < 0) { |
15177 | community_list_perror(vty, ret); | |
15178 | return CMD_WARNING_CONFIG_FAILED; | |
15179 | } | |
42f914d4 | 15180 | |
d62a17ae | 15181 | return CMD_SUCCESS; |
718e3744 | 15182 | } |
15183 | ||
7336e101 SP |
15184 | ALIAS (extcommunity_list_name_expanded, |
15185 | ip_extcommunity_list_name_expanded_cmd, | |
15186 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
813d4307 DW |
15187 | IP_STR |
15188 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
15189 | "Extended Community list number (expanded)\n" |
15190 | "Specify expanded extcommunity-list\n" | |
15191 | "Extended Community list name\n" | |
15192 | "Specify community to reject\n" | |
15193 | "Specify community to accept\n" | |
15194 | "An ordered list as a regular-expression\n") | |
15195 | ||
15196 | DEFUN (no_extcommunity_list_standard_all, | |
15197 | no_bgp_extcommunity_list_standard_all_cmd, | |
15198 | "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
15199 | NO_STR | |
15200 | BGP_STR | |
15201 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 15202 | "Extended Community list number (standard)\n" |
718e3744 | 15203 | "Specify standard extcommunity-list\n" |
5bf15956 | 15204 | "Community list name\n" |
718e3744 | 15205 | "Specify community to reject\n" |
15206 | "Specify community to accept\n" | |
15207 | EXTCOMMUNITY_VAL_STR) | |
15208 | { | |
d62a17ae | 15209 | int style = EXTCOMMUNITY_LIST_STANDARD; |
15210 | int direct = 0; | |
15211 | char *cl_number_or_name = NULL; | |
d4455c89 | 15212 | char *str = NULL; |
42f914d4 | 15213 | |
d62a17ae | 15214 | int idx = 0; |
7336e101 SP |
15215 | if (argv_find(argv, argc, "ip", &idx)) { |
15216 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
15217 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15218 | vty_out(vty, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15219 | zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15220 | } | |
d4455c89 DA |
15221 | |
15222 | idx = 0; | |
15223 | argv_find(argv, argc, "permit", &idx); | |
15224 | argv_find(argv, argc, "deny", &idx); | |
15225 | ||
15226 | if (idx) { | |
15227 | direct = argv_find(argv, argc, "permit", &idx) | |
15228 | ? COMMUNITY_PERMIT | |
15229 | : COMMUNITY_DENY; | |
15230 | ||
15231 | idx = 0; | |
15232 | argv_find(argv, argc, "AA:NN", &idx); | |
15233 | str = argv_concat(argv, argc, idx); | |
15234 | } | |
15235 | ||
15236 | idx = 0; | |
d62a17ae | 15237 | argv_find(argv, argc, "(1-99)", &idx); |
15238 | argv_find(argv, argc, "WORD", &idx); | |
15239 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 15240 | |
d62a17ae | 15241 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 15242 | direct, style); |
42f914d4 | 15243 | |
d62a17ae | 15244 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15245 | |
d62a17ae | 15246 | if (ret < 0) { |
15247 | community_list_perror(vty, ret); | |
15248 | return CMD_WARNING_CONFIG_FAILED; | |
15249 | } | |
42f914d4 | 15250 | |
d62a17ae | 15251 | return CMD_SUCCESS; |
718e3744 | 15252 | } |
15253 | ||
7336e101 SP |
15254 | ALIAS (no_extcommunity_list_standard_all, |
15255 | no_ip_extcommunity_list_standard_all_cmd, | |
15256 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 15257 | NO_STR |
15258 | IP_STR | |
15259 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
15260 | "Extended Community list number (standard)\n" |
15261 | "Specify standard extcommunity-list\n" | |
15262 | "Community list name\n" | |
15263 | "Specify community to reject\n" | |
15264 | "Specify community to accept\n" | |
15265 | EXTCOMMUNITY_VAL_STR) | |
15266 | ||
d4455c89 DA |
15267 | ALIAS(no_extcommunity_list_standard_all, |
15268 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
15269 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
15270 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15271 | "Extended Community list number (standard)\n" | |
15272 | "Specify standard extcommunity-list\n" | |
15273 | "Community list name\n") | |
15274 | ||
15275 | ALIAS(no_extcommunity_list_standard_all, | |
15276 | no_ip_extcommunity_list_standard_all_list_cmd, | |
15277 | "no ip extcommunity-list <(1-99)|standard WORD>", | |
15278 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15279 | "Extended Community list number (standard)\n" | |
15280 | "Specify standard extcommunity-list\n" | |
15281 | "Community list name\n") | |
15282 | ||
7336e101 SP |
15283 | DEFUN (no_extcommunity_list_expanded_all, |
15284 | no_bgp_extcommunity_list_expanded_all_cmd, | |
15285 | "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15286 | NO_STR | |
15287 | BGP_STR | |
15288 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 15289 | "Extended Community list number (expanded)\n" |
718e3744 | 15290 | "Specify expanded extcommunity-list\n" |
5bf15956 | 15291 | "Extended Community list name\n" |
718e3744 | 15292 | "Specify community to reject\n" |
15293 | "Specify community to accept\n" | |
15294 | "An ordered list as a regular-expression\n") | |
15295 | { | |
d62a17ae | 15296 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
15297 | int direct = 0; | |
15298 | char *cl_number_or_name = NULL; | |
d4455c89 | 15299 | char *str = NULL; |
42f914d4 | 15300 | |
d62a17ae | 15301 | int idx = 0; |
7336e101 SP |
15302 | if (argv_find(argv, argc, "ip", &idx)) { |
15303 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15304 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15305 | vty_out(vty, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15306 | zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15307 | } | |
d4455c89 DA |
15308 | |
15309 | idx = 0; | |
15310 | argv_find(argv, argc, "permit", &idx); | |
15311 | argv_find(argv, argc, "deny", &idx); | |
15312 | ||
15313 | if (idx) { | |
15314 | direct = argv_find(argv, argc, "permit", &idx) | |
15315 | ? COMMUNITY_PERMIT | |
15316 | : COMMUNITY_DENY; | |
15317 | ||
15318 | idx = 0; | |
15319 | argv_find(argv, argc, "LINE", &idx); | |
15320 | str = argv_concat(argv, argc, idx); | |
15321 | } | |
15322 | ||
15323 | idx = 0; | |
d62a17ae | 15324 | argv_find(argv, argc, "(100-500)", &idx); |
15325 | argv_find(argv, argc, "WORD", &idx); | |
15326 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 15327 | |
d62a17ae | 15328 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 15329 | direct, style); |
42f914d4 | 15330 | |
d62a17ae | 15331 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15332 | |
d62a17ae | 15333 | if (ret < 0) { |
15334 | community_list_perror(vty, ret); | |
15335 | return CMD_WARNING_CONFIG_FAILED; | |
15336 | } | |
42f914d4 | 15337 | |
d62a17ae | 15338 | return CMD_SUCCESS; |
718e3744 | 15339 | } |
15340 | ||
7336e101 SP |
15341 | ALIAS (no_extcommunity_list_expanded_all, |
15342 | no_ip_extcommunity_list_expanded_all_cmd, | |
15343 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15344 | NO_STR | |
15345 | IP_STR | |
15346 | EXTCOMMUNITY_LIST_STR | |
15347 | "Extended Community list number (expanded)\n" | |
15348 | "Specify expanded extcommunity-list\n" | |
15349 | "Extended Community list name\n" | |
15350 | "Specify community to reject\n" | |
15351 | "Specify community to accept\n" | |
15352 | "An ordered list as a regular-expression\n") | |
15353 | ||
d4455c89 DA |
15354 | ALIAS(no_extcommunity_list_expanded_all, |
15355 | no_ip_extcommunity_list_expanded_all_list_cmd, | |
15356 | "no ip extcommunity-list <(100-500)|expanded WORD>", | |
15357 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15358 | "Extended Community list number (expanded)\n" | |
15359 | "Specify expanded extcommunity-list\n" | |
15360 | "Extended Community list name\n") | |
15361 | ||
15362 | ALIAS(no_extcommunity_list_expanded_all, | |
15363 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
15364 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
15365 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15366 | "Extended Community list number (expanded)\n" | |
15367 | "Specify expanded extcommunity-list\n" | |
15368 | "Extended Community list name\n") | |
15369 | ||
d62a17ae | 15370 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 15371 | { |
d62a17ae | 15372 | struct community_entry *entry; |
718e3744 | 15373 | |
d62a17ae | 15374 | for (entry = list->head; entry; entry = entry->next) { |
15375 | if (entry == list->head) { | |
15376 | if (all_digit(list->name)) | |
15377 | vty_out(vty, "Extended community %s list %s\n", | |
15378 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
15379 | ? "standard" | |
15380 | : "(expanded) access", | |
15381 | list->name); | |
15382 | else | |
15383 | vty_out(vty, | |
15384 | "Named extended community %s list %s\n", | |
15385 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
15386 | ? "standard" | |
15387 | : "expanded", | |
15388 | list->name); | |
15389 | } | |
15390 | if (entry->any) | |
15391 | vty_out(vty, " %s\n", | |
15392 | community_direct_str(entry->direct)); | |
15393 | else | |
15394 | vty_out(vty, " %s %s\n", | |
15395 | community_direct_str(entry->direct), | |
8d9b8ed9 | 15396 | community_list_config_str(entry)); |
d62a17ae | 15397 | } |
718e3744 | 15398 | } |
15399 | ||
7336e101 SP |
15400 | DEFUN (show_extcommunity_list, |
15401 | show_bgp_extcommunity_list_cmd, | |
15402 | "show bgp extcommunity-list", | |
718e3744 | 15403 | SHOW_STR |
7336e101 | 15404 | BGP_STR |
718e3744 | 15405 | "List extended-community list\n") |
15406 | { | |
d62a17ae | 15407 | struct community_list *list; |
15408 | struct community_list_master *cm; | |
7336e101 | 15409 | int idx = 0; |
718e3744 | 15410 | |
7336e101 SP |
15411 | if (argv_find(argv, argc, "ip", &idx)) { |
15412 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
15413 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15414 | vty_out(vty, "'show bgp extcommunity-list <(1-500)|WORD>'\n"); | |
15415 | zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used"); | |
15416 | } | |
d62a17ae | 15417 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
15418 | if (!cm) | |
15419 | return CMD_SUCCESS; | |
718e3744 | 15420 | |
d62a17ae | 15421 | for (list = cm->num.head; list; list = list->next) |
15422 | extcommunity_list_show(vty, list); | |
718e3744 | 15423 | |
d62a17ae | 15424 | for (list = cm->str.head; list; list = list->next) |
15425 | extcommunity_list_show(vty, list); | |
718e3744 | 15426 | |
d62a17ae | 15427 | return CMD_SUCCESS; |
718e3744 | 15428 | } |
15429 | ||
7336e101 SP |
15430 | ALIAS (show_extcommunity_list, |
15431 | show_ip_extcommunity_list_cmd, | |
15432 | "show ip extcommunity-list", | |
718e3744 | 15433 | SHOW_STR |
15434 | IP_STR | |
7336e101 SP |
15435 | "List extended-community list\n") |
15436 | ||
15437 | DEFUN (show_extcommunity_list_arg, | |
15438 | show_bgp_extcommunity_list_arg_cmd, | |
15439 | "show bgp extcommunity-list <(1-500)|WORD>", | |
15440 | SHOW_STR | |
15441 | BGP_STR | |
718e3744 | 15442 | "List extended-community list\n" |
15443 | "Extcommunity-list number\n" | |
15444 | "Extcommunity-list name\n") | |
15445 | { | |
d62a17ae | 15446 | int idx_comm_list = 3; |
15447 | struct community_list *list; | |
7336e101 | 15448 | int idx = 0; |
718e3744 | 15449 | |
7336e101 SP |
15450 | if (argv_find(argv, argc, "ip", &idx)) { |
15451 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15452 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15453 | vty_out(vty, "'show bgp extcommunity-list <(1-500)|WORD>'\n"); | |
15454 | zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used"); | |
15455 | } | |
e237b0d2 | 15456 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 15457 | EXTCOMMUNITY_LIST_MASTER); |
15458 | if (!list) { | |
15459 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
15460 | return CMD_WARNING; | |
15461 | } | |
718e3744 | 15462 | |
d62a17ae | 15463 | extcommunity_list_show(vty, list); |
718e3744 | 15464 | |
d62a17ae | 15465 | return CMD_SUCCESS; |
718e3744 | 15466 | } |
6b0655a2 | 15467 | |
7336e101 SP |
15468 | ALIAS (show_extcommunity_list_arg, |
15469 | show_ip_extcommunity_list_arg_cmd, | |
15470 | "show ip extcommunity-list <(1-500)|WORD>", | |
15471 | SHOW_STR | |
15472 | IP_STR | |
15473 | "List extended-community list\n" | |
15474 | "Extcommunity-list number\n" | |
15475 | "Extcommunity-list name\n") | |
15476 | ||
718e3744 | 15477 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 15478 | static int community_list_config_write(struct vty *vty) |
15479 | { | |
15480 | struct community_list *list; | |
15481 | struct community_entry *entry; | |
15482 | struct community_list_master *cm; | |
15483 | int write = 0; | |
15484 | ||
15485 | /* Community-list. */ | |
15486 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
15487 | ||
15488 | for (list = cm->num.head; list; list = list->next) | |
15489 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15490 | vty_out(vty, "bgp community-list %s %s %s\n", list->name, |
d62a17ae | 15491 | community_direct_str(entry->direct), |
15492 | community_list_config_str(entry)); | |
15493 | write++; | |
15494 | } | |
15495 | for (list = cm->str.head; list; list = list->next) | |
15496 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15497 | vty_out(vty, "bgp community-list %s %s %s %s\n", |
d62a17ae | 15498 | entry->style == COMMUNITY_LIST_STANDARD |
15499 | ? "standard" | |
15500 | : "expanded", | |
15501 | list->name, community_direct_str(entry->direct), | |
15502 | community_list_config_str(entry)); | |
15503 | write++; | |
15504 | } | |
15505 | ||
15506 | /* Extcommunity-list. */ | |
15507 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
15508 | ||
15509 | for (list = cm->num.head; list; list = list->next) | |
15510 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15511 | vty_out(vty, "bgp extcommunity-list %s %s %s\n", |
d62a17ae | 15512 | list->name, community_direct_str(entry->direct), |
15513 | community_list_config_str(entry)); | |
15514 | write++; | |
15515 | } | |
15516 | for (list = cm->str.head; list; list = list->next) | |
15517 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15518 | vty_out(vty, "bgp extcommunity-list %s %s %s %s\n", |
d62a17ae | 15519 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
15520 | ? "standard" | |
15521 | : "expanded", | |
15522 | list->name, community_direct_str(entry->direct), | |
15523 | community_list_config_str(entry)); | |
15524 | write++; | |
15525 | } | |
15526 | ||
15527 | ||
15528 | /* lcommunity-list. */ | |
15529 | cm = community_list_master_lookup(bgp_clist, | |
15530 | LARGE_COMMUNITY_LIST_MASTER); | |
15531 | ||
15532 | for (list = cm->num.head; list; list = list->next) | |
15533 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15534 | vty_out(vty, "bgp large-community-list %s %s %s\n", |
d62a17ae | 15535 | list->name, community_direct_str(entry->direct), |
15536 | community_list_config_str(entry)); | |
15537 | write++; | |
15538 | } | |
15539 | for (list = cm->str.head; list; list = list->next) | |
15540 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15541 | vty_out(vty, "bgp large-community-list %s %s %s %s\n", |
d62a17ae | 15542 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
15543 | ? "standard" | |
15544 | : "expanded", | |
15545 | list->name, community_direct_str(entry->direct), | |
15546 | community_list_config_str(entry)); | |
15547 | write++; | |
15548 | } | |
15549 | ||
15550 | return write; | |
15551 | } | |
15552 | ||
15553 | static struct cmd_node community_list_node = { | |
15554 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 15555 | }; |
15556 | ||
d62a17ae | 15557 | static void community_list_vty(void) |
15558 | { | |
15559 | install_node(&community_list_node, community_list_config_write); | |
15560 | ||
15561 | /* Community-list. */ | |
7336e101 SP |
15562 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
15563 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
15564 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 15565 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 15566 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 15567 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
15568 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
15569 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 15570 | install_element(CONFIG_NODE, &ip_community_list_standard_cmd); |
15571 | install_element(CONFIG_NODE, &ip_community_list_expanded_all_cmd); | |
15572 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_cmd); | |
174b5cb9 | 15573 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_list_cmd); |
d62a17ae | 15574 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); |
174b5cb9 | 15575 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_list_cmd); |
d62a17ae | 15576 | install_element(VIEW_NODE, &show_ip_community_list_cmd); |
15577 | install_element(VIEW_NODE, &show_ip_community_list_arg_cmd); | |
15578 | ||
15579 | /* Extcommunity-list. */ | |
7336e101 SP |
15580 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
15581 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
15582 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
15583 | install_element(CONFIG_NODE, |
15584 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 15585 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
15586 | install_element(CONFIG_NODE, |
15587 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
15588 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
15589 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 15590 | install_element(CONFIG_NODE, &ip_extcommunity_list_standard_cmd); |
15591 | install_element(CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); | |
15592 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); | |
d4455c89 | 15593 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_list_cmd); |
d62a17ae | 15594 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); |
d4455c89 | 15595 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_list_cmd); |
d62a17ae | 15596 | install_element(VIEW_NODE, &show_ip_extcommunity_list_cmd); |
15597 | install_element(VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
15598 | ||
15599 | /* Large Community List */ | |
7336e101 SP |
15600 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
15601 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard1_cmd); | |
15602 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); | |
15603 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
15604 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard1_cmd); | |
15605 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); | |
15606 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_all_cmd); | |
15607 | install_element(CONFIG_NODE, | |
15608 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
15609 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
15610 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
15611 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
15612 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
15613 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
15614 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
d62a17ae | 15615 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard_cmd); |
15616 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); | |
15617 | install_element(CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); | |
15618 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
15619 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); | |
15620 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); | |
15621 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
15622 | install_element(CONFIG_NODE, | |
15623 | &no_ip_lcommunity_list_name_expanded_all_cmd); | |
15624 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
15625 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
15626 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
15627 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
15628 | install_element(VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
15629 | install_element(VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 15630 | } |