]>
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; | |
b26f891d | 122 | case AFI_UNSPEC: |
d62a17ae | 123 | case AFI_MAX: |
124 | // We should never be here but to clarify the switch statement.. | |
125 | return BGP_IPV4_NODE; | |
126 | break; | |
127 | } | |
128 | ||
129 | // Impossible to happen | |
130 | return BGP_IPV4_NODE; | |
f51bae9c | 131 | } |
20eb8864 | 132 | |
718e3744 | 133 | /* Utility function to get address family from current node. */ |
d62a17ae | 134 | afi_t bgp_node_afi(struct vty *vty) |
135 | { | |
136 | afi_t afi; | |
137 | switch (vty->node) { | |
138 | case BGP_IPV6_NODE: | |
139 | case BGP_IPV6M_NODE: | |
140 | case BGP_IPV6L_NODE: | |
141 | case BGP_VPNV6_NODE: | |
7c40bf39 | 142 | case BGP_FLOWSPECV6_NODE: |
d62a17ae | 143 | afi = AFI_IP6; |
144 | break; | |
145 | case BGP_EVPN_NODE: | |
146 | afi = AFI_L2VPN; | |
147 | break; | |
148 | default: | |
149 | afi = AFI_IP; | |
150 | break; | |
151 | } | |
152 | return afi; | |
718e3744 | 153 | } |
154 | ||
155 | /* Utility function to get subsequent address family from current | |
156 | node. */ | |
d62a17ae | 157 | safi_t bgp_node_safi(struct vty *vty) |
158 | { | |
159 | safi_t safi; | |
160 | switch (vty->node) { | |
161 | case BGP_VPNV4_NODE: | |
162 | case BGP_VPNV6_NODE: | |
163 | safi = SAFI_MPLS_VPN; | |
164 | break; | |
165 | case BGP_IPV4M_NODE: | |
166 | case BGP_IPV6M_NODE: | |
167 | safi = SAFI_MULTICAST; | |
168 | break; | |
169 | case BGP_EVPN_NODE: | |
170 | safi = SAFI_EVPN; | |
171 | break; | |
172 | case BGP_IPV4L_NODE: | |
173 | case BGP_IPV6L_NODE: | |
174 | safi = SAFI_LABELED_UNICAST; | |
175 | break; | |
7c40bf39 | 176 | case BGP_FLOWSPECV4_NODE: |
177 | case BGP_FLOWSPECV6_NODE: | |
178 | safi = SAFI_FLOWSPEC; | |
179 | break; | |
d62a17ae | 180 | default: |
181 | safi = SAFI_UNICAST; | |
182 | break; | |
183 | } | |
184 | return safi; | |
718e3744 | 185 | } |
186 | ||
55f91488 QY |
187 | /** |
188 | * Converts an AFI in string form to afi_t | |
189 | * | |
190 | * @param afi string, one of | |
191 | * - "ipv4" | |
192 | * - "ipv6" | |
81cf0de5 | 193 | * - "l2vpn" |
55f91488 QY |
194 | * @return the corresponding afi_t |
195 | */ | |
d62a17ae | 196 | afi_t bgp_vty_afi_from_str(const char *afi_str) |
197 | { | |
198 | afi_t afi = AFI_MAX; /* unknown */ | |
199 | if (strmatch(afi_str, "ipv4")) | |
200 | afi = AFI_IP; | |
201 | else if (strmatch(afi_str, "ipv6")) | |
202 | afi = AFI_IP6; | |
81cf0de5 CS |
203 | else if (strmatch(afi_str, "l2vpn")) |
204 | afi = AFI_L2VPN; | |
d62a17ae | 205 | return afi; |
206 | } | |
207 | ||
208 | int argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, | |
209 | afi_t *afi) | |
210 | { | |
211 | int ret = 0; | |
212 | if (argv_find(argv, argc, "ipv4", index)) { | |
213 | ret = 1; | |
214 | if (afi) | |
215 | *afi = AFI_IP; | |
216 | } else if (argv_find(argv, argc, "ipv6", index)) { | |
217 | ret = 1; | |
218 | if (afi) | |
219 | *afi = AFI_IP6; | |
8688b3e7 DS |
220 | } else if (argv_find(argv, argc, "l2vpn", index)) { |
221 | ret = 1; | |
222 | if (afi) | |
223 | *afi = AFI_L2VPN; | |
d62a17ae | 224 | } |
225 | return ret; | |
46f296b4 LB |
226 | } |
227 | ||
375a2e67 | 228 | /* supports <unicast|multicast|vpn|labeled-unicast> */ |
d62a17ae | 229 | safi_t bgp_vty_safi_from_str(const char *safi_str) |
230 | { | |
231 | safi_t safi = SAFI_MAX; /* unknown */ | |
232 | if (strmatch(safi_str, "multicast")) | |
233 | safi = SAFI_MULTICAST; | |
234 | else if (strmatch(safi_str, "unicast")) | |
235 | safi = SAFI_UNICAST; | |
236 | else if (strmatch(safi_str, "vpn")) | |
237 | safi = SAFI_MPLS_VPN; | |
81cf0de5 CS |
238 | else if (strmatch(safi_str, "evpn")) |
239 | safi = SAFI_EVPN; | |
d62a17ae | 240 | else if (strmatch(safi_str, "labeled-unicast")) |
241 | safi = SAFI_LABELED_UNICAST; | |
7c40bf39 | 242 | else if (strmatch(safi_str, "flowspec")) |
243 | safi = SAFI_FLOWSPEC; | |
d62a17ae | 244 | return safi; |
245 | } | |
246 | ||
247 | int argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, | |
248 | safi_t *safi) | |
249 | { | |
250 | int ret = 0; | |
251 | if (argv_find(argv, argc, "unicast", index)) { | |
252 | ret = 1; | |
253 | if (safi) | |
254 | *safi = SAFI_UNICAST; | |
255 | } else if (argv_find(argv, argc, "multicast", index)) { | |
256 | ret = 1; | |
257 | if (safi) | |
258 | *safi = SAFI_MULTICAST; | |
259 | } else if (argv_find(argv, argc, "labeled-unicast", index)) { | |
260 | ret = 1; | |
261 | if (safi) | |
262 | *safi = SAFI_LABELED_UNICAST; | |
263 | } else if (argv_find(argv, argc, "vpn", index)) { | |
264 | ret = 1; | |
265 | if (safi) | |
266 | *safi = SAFI_MPLS_VPN; | |
8688b3e7 DS |
267 | } else if (argv_find(argv, argc, "evpn", index)) { |
268 | ret = 1; | |
269 | if (safi) | |
270 | *safi = SAFI_EVPN; | |
7c40bf39 | 271 | } else if (argv_find(argv, argc, "flowspec", index)) { |
272 | ret = 1; | |
273 | if (safi) | |
274 | *safi = SAFI_FLOWSPEC; | |
d62a17ae | 275 | } |
276 | return ret; | |
46f296b4 LB |
277 | } |
278 | ||
7eeee51e | 279 | /* |
f212a857 | 280 | * bgp_vty_find_and_parse_afi_safi_bgp |
7eeee51e | 281 | * |
f212a857 DS |
282 | * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it |
283 | * This function *assumes* that the calling function pre-sets the afi/safi/bgp | |
7eeee51e DS |
284 | * to appropriate values for the calling function. This is to allow the |
285 | * calling function to make decisions appropriate for the show command | |
286 | * that is being parsed. | |
287 | * | |
288 | * The show commands are generally of the form: | |
d62a17ae | 289 | * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6> |
290 | * [<unicast|multicast|vpn|labeled-unicast>]] ..." | |
7eeee51e DS |
291 | * |
292 | * Since we use argv_find if the show command in particular doesn't have: | |
293 | * [ip] | |
18c57037 | 294 | * [<view|vrf> VIEWVRFNAME] |
375a2e67 | 295 | * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] |
7eeee51e DS |
296 | * The command parsing should still be ok. |
297 | * | |
298 | * vty -> The vty for the command so we can output some useful data in | |
299 | * the event of a parse error in the vrf. | |
300 | * argv -> The command tokens | |
301 | * argc -> How many command tokens we have | |
d62a17ae | 302 | * idx -> The current place in the command, generally should be 0 for this |
303 | * function | |
7eeee51e DS |
304 | * afi -> The parsed afi if it was included in the show command, returned here |
305 | * safi -> The parsed safi if it was included in the show command, returned here | |
f212a857 | 306 | * bgp -> Pointer to the bgp data structure we need to fill in. |
52e5b8c4 | 307 | * use_json -> json is configured or not |
7eeee51e DS |
308 | * |
309 | * The function returns the correct location in the parse tree for the | |
310 | * last token found. | |
0e37c258 DS |
311 | * |
312 | * Returns 0 for failure to parse correctly, else the idx position of where | |
313 | * it found the last token. | |
7eeee51e | 314 | */ |
d62a17ae | 315 | int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty, |
316 | struct cmd_token **argv, int argc, | |
317 | int *idx, afi_t *afi, safi_t *safi, | |
9f049418 | 318 | struct bgp **bgp, bool use_json) |
d62a17ae | 319 | { |
320 | char *vrf_name = NULL; | |
321 | ||
322 | assert(afi); | |
323 | assert(safi); | |
324 | assert(bgp); | |
325 | ||
326 | if (argv_find(argv, argc, "ip", idx)) | |
327 | *afi = AFI_IP; | |
328 | ||
9a8bdf1c | 329 | if (argv_find(argv, argc, "view", idx)) |
d62a17ae | 330 | vrf_name = argv[*idx + 1]->arg; |
9a8bdf1c PG |
331 | else if (argv_find(argv, argc, "vrf", idx)) { |
332 | vrf_name = argv[*idx + 1]->arg; | |
333 | if (strmatch(vrf_name, VRF_DEFAULT_NAME)) | |
334 | vrf_name = NULL; | |
335 | } | |
336 | if (vrf_name) { | |
d62a17ae | 337 | if (strmatch(vrf_name, "all")) |
338 | *bgp = NULL; | |
339 | else { | |
340 | *bgp = bgp_lookup_by_name(vrf_name); | |
341 | if (!*bgp) { | |
52e5b8c4 SP |
342 | if (use_json) { |
343 | json_object *json = NULL; | |
344 | json = json_object_new_object(); | |
345 | json_object_string_add( | |
346 | json, "warning", | |
347 | "View/Vrf is unknown"); | |
348 | vty_out(vty, "%s\n", | |
349 | json_object_to_json_string_ext(json, | |
350 | JSON_C_TO_STRING_PRETTY)); | |
351 | json_object_free(json); | |
352 | } | |
ca61fd25 DS |
353 | else |
354 | vty_out(vty, "View/Vrf %s is unknown\n", | |
355 | vrf_name); | |
d62a17ae | 356 | *idx = 0; |
357 | return 0; | |
358 | } | |
359 | } | |
360 | } else { | |
361 | *bgp = bgp_get_default(); | |
362 | if (!*bgp) { | |
52e5b8c4 SP |
363 | if (use_json) { |
364 | json_object *json = NULL; | |
365 | json = json_object_new_object(); | |
366 | json_object_string_add( | |
367 | json, "warning", | |
368 | "Default BGP instance not found"); | |
369 | vty_out(vty, "%s\n", | |
370 | json_object_to_json_string_ext(json, | |
371 | JSON_C_TO_STRING_PRETTY)); | |
372 | json_object_free(json); | |
373 | } | |
ca61fd25 DS |
374 | else |
375 | vty_out(vty, | |
376 | "Default BGP instance not found\n"); | |
d62a17ae | 377 | *idx = 0; |
378 | return 0; | |
379 | } | |
380 | } | |
381 | ||
382 | if (argv_find_and_parse_afi(argv, argc, idx, afi)) | |
383 | argv_find_and_parse_safi(argv, argc, idx, safi); | |
384 | ||
385 | *idx += 1; | |
386 | return *idx; | |
387 | } | |
388 | ||
389 | static int peer_address_self_check(struct bgp *bgp, union sockunion *su) | |
390 | { | |
391 | struct interface *ifp = NULL; | |
392 | ||
393 | if (su->sa.sa_family == AF_INET) | |
394 | ifp = if_lookup_by_ipv4_exact(&su->sin.sin_addr, bgp->vrf_id); | |
395 | else if (su->sa.sa_family == AF_INET6) | |
396 | ifp = if_lookup_by_ipv6_exact(&su->sin6.sin6_addr, | |
397 | su->sin6.sin6_scope_id, | |
398 | bgp->vrf_id); | |
399 | ||
400 | if (ifp) | |
401 | return 1; | |
402 | ||
403 | return 0; | |
718e3744 | 404 | } |
405 | ||
406 | /* Utility function for looking up peer from VTY. */ | |
f14e6fdb DS |
407 | /* This is used only for configuration, so disallow if attempted on |
408 | * a dynamic neighbor. | |
409 | */ | |
d62a17ae | 410 | static struct peer *peer_lookup_vty(struct vty *vty, const char *ip_str) |
411 | { | |
412 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
413 | int ret; | |
414 | union sockunion su; | |
415 | struct peer *peer; | |
416 | ||
417 | if (!bgp) { | |
418 | return NULL; | |
419 | } | |
420 | ||
421 | ret = str2sockunion(ip_str, &su); | |
422 | if (ret < 0) { | |
423 | peer = peer_lookup_by_conf_if(bgp, ip_str); | |
424 | if (!peer) { | |
425 | if ((peer = peer_lookup_by_hostname(bgp, ip_str)) | |
426 | == NULL) { | |
427 | vty_out(vty, | |
428 | "%% Malformed address or name: %s\n", | |
429 | ip_str); | |
430 | return NULL; | |
431 | } | |
432 | } | |
433 | } else { | |
434 | peer = peer_lookup(bgp, &su); | |
435 | if (!peer) { | |
436 | vty_out(vty, | |
437 | "%% Specify remote-as or peer-group commands first\n"); | |
438 | return NULL; | |
439 | } | |
440 | if (peer_dynamic_neighbor(peer)) { | |
441 | vty_out(vty, | |
442 | "%% Operation not allowed on a dynamic neighbor\n"); | |
443 | return NULL; | |
444 | } | |
445 | } | |
446 | return peer; | |
718e3744 | 447 | } |
448 | ||
449 | /* Utility function for looking up peer or peer group. */ | |
f14e6fdb DS |
450 | /* This is used only for configuration, so disallow if attempted on |
451 | * a dynamic neighbor. | |
452 | */ | |
d62a17ae | 453 | struct peer *peer_and_group_lookup_vty(struct vty *vty, const char *peer_str) |
454 | { | |
455 | struct bgp *bgp = VTY_GET_CONTEXT(bgp); | |
456 | int ret; | |
457 | union sockunion su; | |
458 | struct peer *peer = NULL; | |
459 | struct peer_group *group = NULL; | |
460 | ||
461 | if (!bgp) { | |
462 | return NULL; | |
463 | } | |
464 | ||
465 | ret = str2sockunion(peer_str, &su); | |
466 | if (ret == 0) { | |
467 | /* IP address, locate peer. */ | |
468 | peer = peer_lookup(bgp, &su); | |
469 | } else { | |
470 | /* Not IP, could match either peer configured on interface or a | |
471 | * group. */ | |
472 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
473 | if (!peer) | |
474 | group = peer_group_lookup(bgp, peer_str); | |
475 | } | |
476 | ||
477 | if (peer) { | |
478 | if (peer_dynamic_neighbor(peer)) { | |
479 | vty_out(vty, | |
480 | "%% Operation not allowed on a dynamic neighbor\n"); | |
481 | return NULL; | |
482 | } | |
483 | ||
484 | return peer; | |
485 | } | |
486 | ||
487 | if (group) | |
488 | return group->conf; | |
489 | ||
490 | vty_out(vty, "%% Specify remote-as or peer-group commands first\n"); | |
491 | ||
492 | return NULL; | |
493 | } | |
494 | ||
495 | int bgp_vty_return(struct vty *vty, int ret) | |
496 | { | |
497 | const char *str = NULL; | |
498 | ||
499 | switch (ret) { | |
500 | case BGP_ERR_INVALID_VALUE: | |
501 | str = "Invalid value"; | |
502 | break; | |
503 | case BGP_ERR_INVALID_FLAG: | |
504 | str = "Invalid flag"; | |
505 | break; | |
506 | case BGP_ERR_PEER_GROUP_SHUTDOWN: | |
507 | str = "Peer-group has been shutdown. Activate the peer-group first"; | |
508 | break; | |
509 | case BGP_ERR_PEER_FLAG_CONFLICT: | |
510 | str = "Can't set override-capability and strict-capability-match at the same time"; | |
511 | break; | |
512 | case BGP_ERR_PEER_GROUP_NO_REMOTE_AS: | |
513 | str = "Specify remote-as or peer-group remote AS first"; | |
514 | break; | |
515 | case BGP_ERR_PEER_GROUP_CANT_CHANGE: | |
516 | str = "Cannot change the peer-group. Deconfigure first"; | |
517 | break; | |
518 | case BGP_ERR_PEER_GROUP_MISMATCH: | |
519 | str = "Peer is not a member of this peer-group"; | |
520 | break; | |
521 | case BGP_ERR_PEER_FILTER_CONFLICT: | |
522 | str = "Prefix/distribute list can not co-exist"; | |
523 | break; | |
524 | case BGP_ERR_NOT_INTERNAL_PEER: | |
525 | str = "Invalid command. Not an internal neighbor"; | |
526 | break; | |
527 | case BGP_ERR_REMOVE_PRIVATE_AS: | |
528 | str = "remove-private-AS cannot be configured for IBGP peers"; | |
529 | break; | |
530 | case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP: | |
531 | str = "Local-AS allowed only for EBGP peers"; | |
532 | break; | |
533 | case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS: | |
534 | str = "Cannot have local-as same as BGP AS number"; | |
535 | break; | |
536 | case BGP_ERR_TCPSIG_FAILED: | |
537 | str = "Error while applying TCP-Sig to session(s)"; | |
538 | break; | |
539 | case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK: | |
540 | str = "ebgp-multihop and ttl-security cannot be configured together"; | |
541 | break; | |
542 | case BGP_ERR_NO_IBGP_WITH_TTLHACK: | |
543 | str = "ttl-security only allowed for EBGP peers"; | |
544 | break; | |
545 | case BGP_ERR_AS_OVERRIDE: | |
546 | str = "as-override cannot be configured for IBGP peers"; | |
547 | break; | |
548 | case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT: | |
549 | str = "Invalid limit for number of dynamic neighbors"; | |
550 | break; | |
551 | case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS: | |
552 | str = "Dynamic neighbor listen range already exists"; | |
553 | break; | |
554 | case BGP_ERR_INVALID_FOR_DYNAMIC_PEER: | |
555 | str = "Operation not allowed on a dynamic neighbor"; | |
556 | break; | |
557 | case BGP_ERR_INVALID_FOR_DIRECT_PEER: | |
558 | str = "Operation not allowed on a directly connected neighbor"; | |
559 | break; | |
560 | case BGP_ERR_PEER_SAFI_CONFLICT: | |
561 | str = "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'"; | |
562 | break; | |
563 | } | |
564 | if (str) { | |
565 | vty_out(vty, "%% %s\n", str); | |
566 | return CMD_WARNING_CONFIG_FAILED; | |
567 | } | |
568 | return CMD_SUCCESS; | |
718e3744 | 569 | } |
570 | ||
7aafcaca | 571 | /* BGP clear sort. */ |
d62a17ae | 572 | enum clear_sort { |
573 | clear_all, | |
574 | clear_peer, | |
575 | clear_group, | |
576 | clear_external, | |
577 | clear_as | |
7aafcaca DS |
578 | }; |
579 | ||
d62a17ae | 580 | static void bgp_clear_vty_error(struct vty *vty, struct peer *peer, afi_t afi, |
581 | safi_t safi, int error) | |
582 | { | |
583 | switch (error) { | |
584 | case BGP_ERR_AF_UNCONFIGURED: | |
585 | vty_out(vty, | |
586 | "%%BGP: Enable %s address family for the neighbor %s\n", | |
587 | afi_safi_print(afi, safi), peer->host); | |
588 | break; | |
589 | case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: | |
590 | vty_out(vty, | |
591 | "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n", | |
592 | peer->host); | |
593 | break; | |
594 | default: | |
595 | break; | |
596 | } | |
7aafcaca DS |
597 | } |
598 | ||
599 | /* `clear ip bgp' functions. */ | |
d62a17ae | 600 | static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, |
601 | enum clear_sort sort, enum bgp_clear_type stype, | |
602 | const char *arg) | |
603 | { | |
604 | int ret; | |
3ae8bfa5 | 605 | bool found = false; |
d62a17ae | 606 | struct peer *peer; |
607 | struct listnode *node, *nnode; | |
608 | ||
609 | /* Clear all neighbors. */ | |
610 | /* | |
611 | * Pass along pointer to next node to peer_clear() when walking all | |
3ae8bfa5 PM |
612 | * nodes on the BGP instance as that may get freed if it is a |
613 | * doppelganger | |
d62a17ae | 614 | */ |
615 | if (sort == clear_all) { | |
616 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
3ae8bfa5 PM |
617 | if (!peer->afc[afi][safi]) |
618 | continue; | |
619 | ||
d62a17ae | 620 | if (stype == BGP_CLEAR_SOFT_NONE) |
621 | ret = peer_clear(peer, &nnode); | |
d62a17ae | 622 | else |
3ae8bfa5 | 623 | ret = peer_clear_soft(peer, afi, safi, stype); |
d62a17ae | 624 | |
625 | if (ret < 0) | |
626 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
627 | else |
628 | found = true; | |
04b6bdc0 | 629 | } |
d62a17ae | 630 | |
631 | /* This is to apply read-only mode on this clear. */ | |
632 | if (stype == BGP_CLEAR_SOFT_NONE) | |
633 | bgp->update_delay_over = 0; | |
634 | ||
3ae8bfa5 | 635 | if (!found) |
3702f84d | 636 | vty_out(vty, "%%BGP: No %s peer configured\n", |
3ae8bfa5 PM |
637 | afi_safi_print(afi, safi)); |
638 | ||
d62a17ae | 639 | return CMD_SUCCESS; |
7aafcaca DS |
640 | } |
641 | ||
3ae8bfa5 | 642 | /* Clear specified neighbor. */ |
d62a17ae | 643 | if (sort == clear_peer) { |
644 | union sockunion su; | |
d62a17ae | 645 | |
646 | /* Make sockunion for lookup. */ | |
647 | ret = str2sockunion(arg, &su); | |
648 | if (ret < 0) { | |
649 | peer = peer_lookup_by_conf_if(bgp, arg); | |
650 | if (!peer) { | |
651 | peer = peer_lookup_by_hostname(bgp, arg); | |
652 | if (!peer) { | |
653 | vty_out(vty, | |
654 | "Malformed address or name: %s\n", | |
655 | arg); | |
656 | return CMD_WARNING; | |
657 | } | |
658 | } | |
659 | } else { | |
660 | peer = peer_lookup(bgp, &su); | |
661 | if (!peer) { | |
662 | vty_out(vty, | |
663 | "%%BGP: Unknown neighbor - \"%s\"\n", | |
664 | arg); | |
665 | return CMD_WARNING; | |
666 | } | |
667 | } | |
7aafcaca | 668 | |
3ae8bfa5 PM |
669 | if (!peer->afc[afi][safi]) |
670 | ret = BGP_ERR_AF_UNCONFIGURED; | |
671 | else if (stype == BGP_CLEAR_SOFT_NONE) | |
d62a17ae | 672 | ret = peer_clear(peer, NULL); |
673 | else | |
674 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 675 | |
d62a17ae | 676 | if (ret < 0) |
677 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
7aafcaca | 678 | |
d62a17ae | 679 | return CMD_SUCCESS; |
7aafcaca | 680 | } |
7aafcaca | 681 | |
3ae8bfa5 | 682 | /* Clear all neighbors belonging to a specific peer-group. */ |
d62a17ae | 683 | if (sort == clear_group) { |
684 | struct peer_group *group; | |
7aafcaca | 685 | |
d62a17ae | 686 | group = peer_group_lookup(bgp, arg); |
687 | if (!group) { | |
688 | vty_out(vty, "%%BGP: No such peer-group %s\n", arg); | |
689 | return CMD_WARNING; | |
690 | } | |
691 | ||
692 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
d62a17ae | 693 | if (!peer->afc[afi][safi]) |
694 | continue; | |
695 | ||
3ae8bfa5 PM |
696 | if (stype == BGP_CLEAR_SOFT_NONE) |
697 | ret = peer_clear(peer, NULL); | |
698 | else | |
699 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 700 | |
d62a17ae | 701 | if (ret < 0) |
702 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
703 | else |
704 | found = true; | |
d62a17ae | 705 | } |
3ae8bfa5 PM |
706 | |
707 | if (!found) | |
708 | vty_out(vty, | |
709 | "%%BGP: No %s peer belonging to peer-group %s is configured\n", | |
710 | afi_safi_print(afi, safi), arg); | |
711 | ||
d62a17ae | 712 | return CMD_SUCCESS; |
7aafcaca | 713 | } |
7aafcaca | 714 | |
3ae8bfa5 | 715 | /* Clear all external (eBGP) neighbors. */ |
d62a17ae | 716 | if (sort == clear_external) { |
717 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
718 | if (peer->sort == BGP_PEER_IBGP) | |
719 | continue; | |
7aafcaca | 720 | |
3ae8bfa5 PM |
721 | if (!peer->afc[afi][safi]) |
722 | continue; | |
723 | ||
d62a17ae | 724 | if (stype == BGP_CLEAR_SOFT_NONE) |
725 | ret = peer_clear(peer, &nnode); | |
726 | else | |
727 | ret = peer_clear_soft(peer, afi, safi, stype); | |
7aafcaca | 728 | |
d62a17ae | 729 | if (ret < 0) |
730 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
731 | else |
732 | found = true; | |
d62a17ae | 733 | } |
3ae8bfa5 PM |
734 | |
735 | if (!found) | |
736 | vty_out(vty, | |
737 | "%%BGP: No external %s peer is configured\n", | |
738 | afi_safi_print(afi, safi)); | |
739 | ||
d62a17ae | 740 | return CMD_SUCCESS; |
741 | } | |
742 | ||
3ae8bfa5 | 743 | /* Clear all neighbors belonging to a specific AS. */ |
d62a17ae | 744 | if (sort == clear_as) { |
3ae8bfa5 | 745 | as_t as = strtoul(arg, NULL, 10); |
d62a17ae | 746 | |
747 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
748 | if (peer->as != as) | |
749 | continue; | |
750 | ||
3ae8bfa5 PM |
751 | if (!peer->afc[afi][safi]) |
752 | ret = BGP_ERR_AF_UNCONFIGURED; | |
753 | else if (stype == BGP_CLEAR_SOFT_NONE) | |
d62a17ae | 754 | ret = peer_clear(peer, &nnode); |
755 | else | |
756 | ret = peer_clear_soft(peer, afi, safi, stype); | |
757 | ||
758 | if (ret < 0) | |
759 | bgp_clear_vty_error(vty, peer, afi, safi, ret); | |
3ae8bfa5 PM |
760 | else |
761 | found = true; | |
d62a17ae | 762 | } |
3ae8bfa5 PM |
763 | |
764 | if (!found) | |
d62a17ae | 765 | vty_out(vty, |
3ae8bfa5 PM |
766 | "%%BGP: No %s peer is configured with AS %s\n", |
767 | afi_safi_print(afi, safi), arg); | |
768 | ||
d62a17ae | 769 | return CMD_SUCCESS; |
770 | } | |
771 | ||
772 | return CMD_SUCCESS; | |
773 | } | |
774 | ||
775 | static int bgp_clear_vty(struct vty *vty, const char *name, afi_t afi, | |
776 | safi_t safi, enum clear_sort sort, | |
777 | enum bgp_clear_type stype, const char *arg) | |
778 | { | |
779 | struct bgp *bgp; | |
780 | ||
781 | /* BGP structure lookup. */ | |
782 | if (name) { | |
783 | bgp = bgp_lookup_by_name(name); | |
784 | if (bgp == NULL) { | |
785 | vty_out(vty, "Can't find BGP instance %s\n", name); | |
786 | return CMD_WARNING; | |
787 | } | |
788 | } else { | |
789 | bgp = bgp_get_default(); | |
790 | if (bgp == NULL) { | |
791 | vty_out(vty, "No BGP process is configured\n"); | |
792 | return CMD_WARNING; | |
793 | } | |
794 | } | |
795 | ||
796 | return bgp_clear(vty, bgp, afi, safi, sort, stype, arg); | |
7aafcaca DS |
797 | } |
798 | ||
799 | /* clear soft inbound */ | |
d62a17ae | 800 | static void bgp_clear_star_soft_in(struct vty *vty, const char *name) |
7aafcaca | 801 | { |
99b3ebd3 NS |
802 | afi_t afi; |
803 | safi_t safi; | |
804 | ||
805 | FOREACH_AFI_SAFI (afi, safi) | |
806 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
807 | BGP_CLEAR_SOFT_IN, NULL); | |
7aafcaca DS |
808 | } |
809 | ||
810 | /* clear soft outbound */ | |
d62a17ae | 811 | static void bgp_clear_star_soft_out(struct vty *vty, const char *name) |
7aafcaca | 812 | { |
99b3ebd3 NS |
813 | afi_t afi; |
814 | safi_t safi; | |
815 | ||
816 | FOREACH_AFI_SAFI (afi, safi) | |
817 | bgp_clear_vty(vty, name, afi, safi, clear_all, | |
818 | BGP_CLEAR_SOFT_OUT, NULL); | |
7aafcaca DS |
819 | } |
820 | ||
821 | ||
f787d7a0 | 822 | #ifndef VTYSH_EXTRACT_PL |
2e4c2296 | 823 | #include "bgpd/bgp_vty_clippy.c" |
f787d7a0 DL |
824 | #endif |
825 | ||
8029b216 AK |
826 | DEFUN_HIDDEN (bgp_local_mac, |
827 | bgp_local_mac_cmd, | |
093e3f23 | 828 | "bgp local-mac vni " CMD_VNI_RANGE " mac WORD seq (0-4294967295)", |
8029b216 AK |
829 | BGP_STR |
830 | "Local MAC config\n" | |
831 | "VxLAN Network Identifier\n" | |
832 | "VNI number\n" | |
833 | "local mac\n" | |
834 | "mac address\n" | |
835 | "mac-mobility sequence\n" | |
836 | "seq number\n") | |
837 | { | |
838 | int rv; | |
839 | vni_t vni; | |
840 | struct ethaddr mac; | |
841 | struct ipaddr ip; | |
842 | uint32_t seq; | |
843 | struct bgp *bgp; | |
844 | ||
845 | vni = strtoul(argv[3]->arg, NULL, 10); | |
846 | if (!prefix_str2mac(argv[5]->arg, &mac)) { | |
847 | vty_out(vty, "%% Malformed MAC address\n"); | |
848 | return CMD_WARNING; | |
849 | } | |
850 | memset(&ip, 0, sizeof(ip)); | |
851 | seq = strtoul(argv[7]->arg, NULL, 10); | |
852 | ||
853 | bgp = bgp_get_default(); | |
854 | if (!bgp) { | |
855 | vty_out(vty, "Default BGP instance is not there\n"); | |
856 | return CMD_WARNING; | |
857 | } | |
858 | ||
859 | rv = bgp_evpn_local_macip_add(bgp, vni, &mac, &ip, 0 /* flags */, seq); | |
860 | if (rv < 0) { | |
861 | vty_out(vty, "Internal error\n"); | |
862 | return CMD_WARNING; | |
863 | } | |
864 | ||
865 | return CMD_SUCCESS; | |
866 | } | |
867 | ||
868 | DEFUN_HIDDEN (no_bgp_local_mac, | |
869 | no_bgp_local_mac_cmd, | |
093e3f23 | 870 | "no bgp local-mac vni " CMD_VNI_RANGE " mac WORD", |
8029b216 AK |
871 | NO_STR |
872 | BGP_STR | |
873 | "Local MAC config\n" | |
874 | "VxLAN Network Identifier\n" | |
875 | "VNI number\n" | |
876 | "local mac\n" | |
877 | "mac address\n") | |
878 | { | |
879 | int rv; | |
880 | vni_t vni; | |
881 | struct ethaddr mac; | |
882 | struct ipaddr ip; | |
883 | struct bgp *bgp; | |
884 | ||
885 | vni = strtoul(argv[4]->arg, NULL, 10); | |
886 | if (!prefix_str2mac(argv[6]->arg, &mac)) { | |
887 | vty_out(vty, "%% Malformed MAC address\n"); | |
888 | return CMD_WARNING; | |
889 | } | |
890 | memset(&ip, 0, sizeof(ip)); | |
891 | ||
892 | bgp = bgp_get_default(); | |
893 | if (!bgp) { | |
894 | vty_out(vty, "Default BGP instance is not there\n"); | |
895 | return CMD_WARNING; | |
896 | } | |
897 | ||
ec0ab544 | 898 | rv = bgp_evpn_local_macip_del(bgp, vni, &mac, &ip, ZEBRA_NEIGH_ACTIVE); |
8029b216 AK |
899 | if (rv < 0) { |
900 | vty_out(vty, "Internal error\n"); | |
901 | return CMD_WARNING; | |
902 | } | |
903 | ||
904 | return CMD_SUCCESS; | |
905 | } | |
906 | ||
718e3744 | 907 | DEFUN (no_synchronization, |
908 | no_synchronization_cmd, | |
909 | "no synchronization", | |
910 | NO_STR | |
911 | "Perform IGP synchronization\n") | |
912 | { | |
d62a17ae | 913 | return CMD_SUCCESS; |
718e3744 | 914 | } |
915 | ||
916 | DEFUN (no_auto_summary, | |
917 | no_auto_summary_cmd, | |
918 | "no auto-summary", | |
919 | NO_STR | |
920 | "Enable automatic network number summarization\n") | |
921 | { | |
d62a17ae | 922 | return CMD_SUCCESS; |
718e3744 | 923 | } |
3d515fd9 | 924 | |
718e3744 | 925 | /* "router bgp" commands. */ |
505e5056 | 926 | DEFUN_NOSH (router_bgp, |
f412b39a | 927 | router_bgp_cmd, |
18c57037 | 928 | "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 929 | ROUTER_STR |
930 | BGP_STR | |
31500417 DW |
931 | AS_STR |
932 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 933 | { |
d62a17ae | 934 | int idx_asn = 2; |
935 | int idx_view_vrf = 3; | |
936 | int idx_vrf = 4; | |
ecec9495 | 937 | int is_new_bgp = 0; |
d62a17ae | 938 | int ret; |
939 | as_t as; | |
940 | struct bgp *bgp; | |
941 | const char *name = NULL; | |
942 | enum bgp_instance_type inst_type; | |
943 | ||
944 | // "router bgp" without an ASN | |
945 | if (argc == 2) { | |
946 | // Pending: Make VRF option available for ASN less config | |
947 | bgp = bgp_get_default(); | |
948 | ||
949 | if (bgp == NULL) { | |
950 | vty_out(vty, "%% No BGP process is configured\n"); | |
951 | return CMD_WARNING_CONFIG_FAILED; | |
952 | } | |
953 | ||
954 | if (listcount(bm->bgp) > 1) { | |
996c9314 | 955 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 956 | return CMD_WARNING_CONFIG_FAILED; |
957 | } | |
958 | } | |
959 | ||
960 | // "router bgp X" | |
961 | else { | |
962 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
963 | ||
964 | inst_type = BGP_INSTANCE_TYPE_DEFAULT; | |
965 | if (argc > 3) { | |
966 | name = argv[idx_vrf]->arg; | |
967 | ||
9a8bdf1c PG |
968 | if (!strcmp(argv[idx_view_vrf]->text, "vrf")) { |
969 | if (strmatch(name, VRF_DEFAULT_NAME)) | |
970 | name = NULL; | |
971 | else | |
972 | inst_type = BGP_INSTANCE_TYPE_VRF; | |
973 | } else if (!strcmp(argv[idx_view_vrf]->text, "view")) | |
d62a17ae | 974 | inst_type = BGP_INSTANCE_TYPE_VIEW; |
975 | } | |
976 | ||
ecec9495 AD |
977 | if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
978 | is_new_bgp = (bgp_lookup(as, name) == NULL); | |
979 | ||
d62a17ae | 980 | ret = bgp_get(&bgp, &as, name, inst_type); |
981 | switch (ret) { | |
d62a17ae | 982 | case BGP_ERR_AS_MISMATCH: |
983 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
984 | return CMD_WARNING_CONFIG_FAILED; | |
985 | case BGP_ERR_INSTANCE_MISMATCH: | |
986 | vty_out(vty, | |
987 | "BGP instance name and AS number mismatch\n"); | |
988 | vty_out(vty, | |
989 | "BGP instance is already running; AS is %u\n", | |
990 | as); | |
991 | return CMD_WARNING_CONFIG_FAILED; | |
992 | } | |
993 | ||
3bd70bf8 PZ |
994 | /* |
995 | * If we just instantiated the default instance, complete | |
996 | * any pending VRF-VPN leaking that was configured via | |
997 | * earlier "router bgp X vrf FOO" blocks. | |
998 | */ | |
ecec9495 | 999 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
3bd70bf8 PZ |
1000 | vpn_leak_postchange_all(); |
1001 | ||
48381346 CS |
1002 | if (inst_type == BGP_INSTANCE_TYPE_VRF) |
1003 | bgp_vpn_leak_export(bgp); | |
d62a17ae | 1004 | /* Pending: handle when user tries to change a view to vrf n vv. |
1005 | */ | |
1006 | } | |
1007 | ||
0b5131c9 MK |
1008 | /* unset the auto created flag as the user config is now present */ |
1009 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 1010 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
1011 | ||
1012 | return CMD_SUCCESS; | |
718e3744 | 1013 | } |
1014 | ||
718e3744 | 1015 | /* "no router bgp" commands. */ |
1016 | DEFUN (no_router_bgp, | |
1017 | no_router_bgp_cmd, | |
18c57037 | 1018 | "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1019 | NO_STR |
1020 | ROUTER_STR | |
1021 | BGP_STR | |
31500417 DW |
1022 | AS_STR |
1023 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1024 | { |
d62a17ae | 1025 | int idx_asn = 3; |
1026 | int idx_vrf = 5; | |
1027 | as_t as; | |
1028 | struct bgp *bgp; | |
1029 | const char *name = NULL; | |
718e3744 | 1030 | |
d62a17ae | 1031 | // "no router bgp" without an ASN |
1032 | if (argc == 3) { | |
1033 | // Pending: Make VRF option available for ASN less config | |
1034 | bgp = bgp_get_default(); | |
718e3744 | 1035 | |
d62a17ae | 1036 | if (bgp == NULL) { |
1037 | vty_out(vty, "%% No BGP process is configured\n"); | |
1038 | return CMD_WARNING_CONFIG_FAILED; | |
1039 | } | |
7fb21a9f | 1040 | |
d62a17ae | 1041 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1042 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1043 | return CMD_WARNING_CONFIG_FAILED; |
1044 | } | |
0b5131c9 MK |
1045 | |
1046 | if (bgp->l3vni) { | |
1047 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1048 | bgp->l3vni); | |
1049 | return CMD_WARNING_CONFIG_FAILED; | |
1050 | } | |
d62a17ae | 1051 | } else { |
1052 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1053 | |
d62a17ae | 1054 | if (argc > 4) |
1055 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1056 | |
d62a17ae | 1057 | /* Lookup bgp structure. */ |
1058 | bgp = bgp_lookup(as, name); | |
1059 | if (!bgp) { | |
1060 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1061 | return CMD_WARNING_CONFIG_FAILED; | |
1062 | } | |
0b5131c9 MK |
1063 | |
1064 | if (bgp->l3vni) { | |
dd5868c2 | 1065 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
0b5131c9 MK |
1066 | bgp->l3vni); |
1067 | return CMD_WARNING_CONFIG_FAILED; | |
1068 | } | |
dd5868c2 DS |
1069 | |
1070 | /* Cannot delete default instance if vrf instances exist */ | |
1071 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1072 | struct listnode *node; | |
1073 | struct bgp *tmp_bgp; | |
1074 | ||
1075 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1076 | if (tmp_bgp->inst_type | |
1077 | == BGP_INSTANCE_TYPE_VRF) { | |
1078 | vty_out(vty, | |
1079 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1080 | return CMD_WARNING_CONFIG_FAILED; | |
1081 | } | |
1082 | } | |
1083 | } | |
d62a17ae | 1084 | } |
718e3744 | 1085 | |
9ecf931b CS |
1086 | if (bgp_vpn_leak_unimport(bgp, vty)) |
1087 | return CMD_WARNING_CONFIG_FAILED; | |
1088 | ||
d62a17ae | 1089 | bgp_delete(bgp); |
718e3744 | 1090 | |
d62a17ae | 1091 | return CMD_SUCCESS; |
718e3744 | 1092 | } |
1093 | ||
6b0655a2 | 1094 | |
718e3744 | 1095 | /* BGP router-id. */ |
1096 | ||
f787d7a0 | 1097 | DEFPY (bgp_router_id, |
718e3744 | 1098 | bgp_router_id_cmd, |
1099 | "bgp router-id A.B.C.D", | |
1100 | BGP_STR | |
1101 | "Override configured router identifier\n" | |
1102 | "Manually configured router identifier\n") | |
1103 | { | |
d62a17ae | 1104 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1105 | bgp_router_id_static_set(bgp, router_id); | |
1106 | return CMD_SUCCESS; | |
718e3744 | 1107 | } |
1108 | ||
f787d7a0 | 1109 | DEFPY (no_bgp_router_id, |
718e3744 | 1110 | no_bgp_router_id_cmd, |
31500417 | 1111 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1112 | NO_STR |
1113 | BGP_STR | |
31500417 DW |
1114 | "Override configured router identifier\n" |
1115 | "Manually configured router identifier\n") | |
718e3744 | 1116 | { |
d62a17ae | 1117 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1118 | |
d62a17ae | 1119 | if (router_id_str) { |
1120 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1121 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1122 | return CMD_WARNING_CONFIG_FAILED; | |
1123 | } | |
e018c7cc | 1124 | } |
718e3744 | 1125 | |
d62a17ae | 1126 | router_id.s_addr = 0; |
1127 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1128 | |
d62a17ae | 1129 | return CMD_SUCCESS; |
718e3744 | 1130 | } |
1131 | ||
6b0655a2 | 1132 | |
718e3744 | 1133 | /* BGP Cluster ID. */ |
718e3744 | 1134 | DEFUN (bgp_cluster_id, |
1135 | bgp_cluster_id_cmd, | |
838758ac | 1136 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1137 | BGP_STR |
1138 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1139 | "Route-Reflector Cluster-id in IP address format\n" |
1140 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1141 | { |
d62a17ae | 1142 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1143 | int idx_ipv4 = 2; | |
1144 | int ret; | |
1145 | struct in_addr cluster; | |
718e3744 | 1146 | |
d62a17ae | 1147 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1148 | if (!ret) { | |
1149 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1150 | return CMD_WARNING_CONFIG_FAILED; | |
1151 | } | |
718e3744 | 1152 | |
d62a17ae | 1153 | bgp_cluster_id_set(bgp, &cluster); |
1154 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1155 | |
d62a17ae | 1156 | return CMD_SUCCESS; |
718e3744 | 1157 | } |
1158 | ||
718e3744 | 1159 | DEFUN (no_bgp_cluster_id, |
1160 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1161 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1162 | NO_STR |
1163 | BGP_STR | |
838758ac DW |
1164 | "Configure Route-Reflector Cluster-id\n" |
1165 | "Route-Reflector Cluster-id in IP address format\n" | |
1166 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1167 | { |
d62a17ae | 1168 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1169 | bgp_cluster_id_unset(bgp); | |
1170 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1171 | |
d62a17ae | 1172 | return CMD_SUCCESS; |
718e3744 | 1173 | } |
1174 | ||
718e3744 | 1175 | DEFUN (bgp_confederation_identifier, |
1176 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1177 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1178 | "BGP specific commands\n" |
1179 | "AS confederation parameters\n" | |
1180 | "AS number\n" | |
1181 | "Set routing domain confederation AS\n") | |
1182 | { | |
d62a17ae | 1183 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1184 | int idx_number = 3; | |
1185 | as_t as; | |
718e3744 | 1186 | |
d62a17ae | 1187 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1188 | |
d62a17ae | 1189 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1190 | |
d62a17ae | 1191 | return CMD_SUCCESS; |
718e3744 | 1192 | } |
1193 | ||
1194 | DEFUN (no_bgp_confederation_identifier, | |
1195 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1196 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1197 | NO_STR |
1198 | "BGP specific commands\n" | |
1199 | "AS confederation parameters\n" | |
3a2d747c QY |
1200 | "AS number\n" |
1201 | "Set routing domain confederation AS\n") | |
718e3744 | 1202 | { |
d62a17ae | 1203 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1204 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1205 | |
d62a17ae | 1206 | return CMD_SUCCESS; |
718e3744 | 1207 | } |
1208 | ||
718e3744 | 1209 | DEFUN (bgp_confederation_peers, |
1210 | bgp_confederation_peers_cmd, | |
12dcf78e | 1211 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1212 | "BGP specific commands\n" |
1213 | "AS confederation parameters\n" | |
1214 | "Peer ASs in BGP confederation\n" | |
1215 | AS_STR) | |
1216 | { | |
d62a17ae | 1217 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1218 | int idx_asn = 3; | |
1219 | as_t as; | |
1220 | int i; | |
718e3744 | 1221 | |
d62a17ae | 1222 | for (i = idx_asn; i < argc; i++) { |
1223 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1224 | |
d62a17ae | 1225 | if (bgp->as == as) { |
1226 | vty_out(vty, | |
1227 | "%% Local member-AS not allowed in confed peer list\n"); | |
1228 | continue; | |
1229 | } | |
718e3744 | 1230 | |
d62a17ae | 1231 | bgp_confederation_peers_add(bgp, as); |
1232 | } | |
1233 | return CMD_SUCCESS; | |
718e3744 | 1234 | } |
1235 | ||
1236 | DEFUN (no_bgp_confederation_peers, | |
1237 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1238 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1239 | NO_STR |
1240 | "BGP specific commands\n" | |
1241 | "AS confederation parameters\n" | |
1242 | "Peer ASs in BGP confederation\n" | |
1243 | AS_STR) | |
1244 | { | |
d62a17ae | 1245 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1246 | int idx_asn = 4; | |
1247 | as_t as; | |
1248 | int i; | |
718e3744 | 1249 | |
d62a17ae | 1250 | for (i = idx_asn; i < argc; i++) { |
1251 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1252 | |
d62a17ae | 1253 | bgp_confederation_peers_remove(bgp, as); |
1254 | } | |
1255 | return CMD_SUCCESS; | |
718e3744 | 1256 | } |
6b0655a2 | 1257 | |
5e242b0d DS |
1258 | /** |
1259 | * Central routine for maximum-paths configuration. | |
1260 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1261 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1262 | */ | |
d62a17ae | 1263 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1264 | const char *mpaths, uint16_t options, |
d62a17ae | 1265 | int set) |
1266 | { | |
1267 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1268 | uint16_t maxpaths = 0; |
d62a17ae | 1269 | int ret; |
1270 | afi_t afi; | |
1271 | safi_t safi; | |
1272 | ||
1273 | afi = bgp_node_afi(vty); | |
1274 | safi = bgp_node_safi(vty); | |
1275 | ||
1276 | if (set) { | |
1277 | maxpaths = strtol(mpaths, NULL, 10); | |
1278 | if (maxpaths > multipath_num) { | |
1279 | vty_out(vty, | |
1280 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1281 | maxpaths, multipath_num); | |
1282 | return CMD_WARNING_CONFIG_FAILED; | |
1283 | } | |
1284 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1285 | options); | |
1286 | } else | |
1287 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1288 | ||
1289 | if (ret < 0) { | |
1290 | vty_out(vty, | |
1291 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1292 | (set == 1) ? "" : "un", | |
1293 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1294 | maxpaths, afi, safi); | |
1295 | return CMD_WARNING_CONFIG_FAILED; | |
1296 | } | |
1297 | ||
1298 | bgp_recalculate_all_bestpaths(bgp); | |
1299 | ||
1300 | return CMD_SUCCESS; | |
165b5fff JB |
1301 | } |
1302 | ||
abc920f8 DS |
1303 | DEFUN (bgp_maxmed_admin, |
1304 | bgp_maxmed_admin_cmd, | |
1305 | "bgp max-med administrative ", | |
1306 | BGP_STR | |
1307 | "Advertise routes with max-med\n" | |
1308 | "Administratively applied, for an indefinite period\n") | |
1309 | { | |
d62a17ae | 1310 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1311 | |
d62a17ae | 1312 | bgp->v_maxmed_admin = 1; |
1313 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1314 | |
d62a17ae | 1315 | bgp_maxmed_update(bgp); |
abc920f8 | 1316 | |
d62a17ae | 1317 | return CMD_SUCCESS; |
abc920f8 DS |
1318 | } |
1319 | ||
1320 | DEFUN (bgp_maxmed_admin_medv, | |
1321 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1322 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1323 | BGP_STR |
1324 | "Advertise routes with max-med\n" | |
1325 | "Administratively applied, for an indefinite period\n" | |
1326 | "Max MED value to be used\n") | |
1327 | { | |
d62a17ae | 1328 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1329 | int idx_number = 3; | |
abc920f8 | 1330 | |
d62a17ae | 1331 | bgp->v_maxmed_admin = 1; |
1332 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1333 | |
d62a17ae | 1334 | bgp_maxmed_update(bgp); |
abc920f8 | 1335 | |
d62a17ae | 1336 | return CMD_SUCCESS; |
abc920f8 DS |
1337 | } |
1338 | ||
1339 | DEFUN (no_bgp_maxmed_admin, | |
1340 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1341 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1342 | NO_STR |
1343 | BGP_STR | |
1344 | "Advertise routes with max-med\n" | |
838758ac DW |
1345 | "Administratively applied, for an indefinite period\n" |
1346 | "Max MED value to be used\n") | |
abc920f8 | 1347 | { |
d62a17ae | 1348 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1349 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1350 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1351 | bgp_maxmed_update(bgp); | |
abc920f8 | 1352 | |
d62a17ae | 1353 | return CMD_SUCCESS; |
abc920f8 DS |
1354 | } |
1355 | ||
abc920f8 DS |
1356 | DEFUN (bgp_maxmed_onstartup, |
1357 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1358 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1359 | BGP_STR |
1360 | "Advertise routes with max-med\n" | |
1361 | "Effective on a startup\n" | |
1362 | "Time (seconds) period for max-med\n" | |
1363 | "Max MED value to be used\n") | |
1364 | { | |
d62a17ae | 1365 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1366 | int idx = 0; | |
4668a151 | 1367 | |
d62a17ae | 1368 | argv_find(argv, argc, "(5-86400)", &idx); |
1369 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1370 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1371 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1372 | else | |
1373 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1374 | |
d62a17ae | 1375 | bgp_maxmed_update(bgp); |
abc920f8 | 1376 | |
d62a17ae | 1377 | return CMD_SUCCESS; |
abc920f8 DS |
1378 | } |
1379 | ||
1380 | DEFUN (no_bgp_maxmed_onstartup, | |
1381 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1382 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1383 | NO_STR |
1384 | BGP_STR | |
1385 | "Advertise routes with max-med\n" | |
838758ac DW |
1386 | "Effective on a startup\n" |
1387 | "Time (seconds) period for max-med\n" | |
1388 | "Max MED value to be used\n") | |
abc920f8 | 1389 | { |
d62a17ae | 1390 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1391 | |
d62a17ae | 1392 | /* Cancel max-med onstartup if its on */ |
1393 | if (bgp->t_maxmed_onstartup) { | |
1394 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1395 | bgp->maxmed_onstartup_over = 1; | |
1396 | } | |
abc920f8 | 1397 | |
d62a17ae | 1398 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1399 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1400 | |
d62a17ae | 1401 | bgp_maxmed_update(bgp); |
abc920f8 | 1402 | |
d62a17ae | 1403 | return CMD_SUCCESS; |
abc920f8 DS |
1404 | } |
1405 | ||
d62a17ae | 1406 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1407 | const char *wait) | |
f188f2c4 | 1408 | { |
d62a17ae | 1409 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1410 | uint16_t update_delay; |
1411 | uint16_t establish_wait; | |
f188f2c4 | 1412 | |
d62a17ae | 1413 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1414 | |
d62a17ae | 1415 | if (!wait) /* update-delay <delay> */ |
1416 | { | |
1417 | bgp->v_update_delay = update_delay; | |
1418 | bgp->v_establish_wait = bgp->v_update_delay; | |
1419 | return CMD_SUCCESS; | |
1420 | } | |
f188f2c4 | 1421 | |
d62a17ae | 1422 | /* update-delay <delay> <establish-wait> */ |
1423 | establish_wait = atoi(wait); | |
1424 | if (update_delay < establish_wait) { | |
1425 | vty_out(vty, | |
1426 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1427 | return CMD_WARNING_CONFIG_FAILED; | |
1428 | } | |
f188f2c4 | 1429 | |
d62a17ae | 1430 | bgp->v_update_delay = update_delay; |
1431 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1432 | |
d62a17ae | 1433 | return CMD_SUCCESS; |
f188f2c4 DS |
1434 | } |
1435 | ||
d62a17ae | 1436 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1437 | { |
d62a17ae | 1438 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1439 | |
d62a17ae | 1440 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1441 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1442 | |
d62a17ae | 1443 | return CMD_SUCCESS; |
f188f2c4 DS |
1444 | } |
1445 | ||
2b791107 | 1446 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1447 | { |
d62a17ae | 1448 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1449 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1450 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1451 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1452 | vty_out(vty, "\n"); | |
1453 | } | |
f188f2c4 DS |
1454 | } |
1455 | ||
1456 | ||
1457 | /* Update-delay configuration */ | |
1458 | DEFUN (bgp_update_delay, | |
1459 | bgp_update_delay_cmd, | |
6147e2c6 | 1460 | "update-delay (0-3600)", |
f188f2c4 DS |
1461 | "Force initial delay for best-path and updates\n" |
1462 | "Seconds\n") | |
1463 | { | |
d62a17ae | 1464 | int idx_number = 1; |
1465 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1466 | } |
1467 | ||
1468 | DEFUN (bgp_update_delay_establish_wait, | |
1469 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1470 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1471 | "Force initial delay for best-path and updates\n" |
1472 | "Seconds\n" | |
f188f2c4 DS |
1473 | "Seconds\n") |
1474 | { | |
d62a17ae | 1475 | int idx_number = 1; |
1476 | int idx_number_2 = 2; | |
1477 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1478 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1479 | } |
1480 | ||
1481 | /* Update-delay deconfiguration */ | |
1482 | DEFUN (no_bgp_update_delay, | |
1483 | no_bgp_update_delay_cmd, | |
838758ac DW |
1484 | "no update-delay [(0-3600) [(1-3600)]]", |
1485 | NO_STR | |
f188f2c4 | 1486 | "Force initial delay for best-path and updates\n" |
838758ac | 1487 | "Seconds\n" |
7111c1a0 | 1488 | "Seconds\n") |
f188f2c4 | 1489 | { |
d62a17ae | 1490 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1491 | } |
1492 | ||
5e242b0d | 1493 | |
d62a17ae | 1494 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, const char *num, |
1495 | char set) | |
cb1faec9 | 1496 | { |
d62a17ae | 1497 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1498 | |
555e09d4 QY |
1499 | if (set) { |
1500 | uint32_t quanta = strtoul(num, NULL, 10); | |
1501 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, | |
1502 | memory_order_relaxed); | |
1503 | } else { | |
1504 | atomic_store_explicit(&bgp->wpkt_quanta, BGP_WRITE_PACKET_MAX, | |
1505 | memory_order_relaxed); | |
1506 | } | |
1507 | ||
1508 | return CMD_SUCCESS; | |
1509 | } | |
1510 | ||
1511 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, const char *num, | |
1512 | char set) | |
1513 | { | |
1514 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1515 | ||
1516 | if (set) { | |
1517 | uint32_t quanta = strtoul(num, NULL, 10); | |
1518 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, | |
1519 | memory_order_relaxed); | |
1520 | } else { | |
1521 | atomic_store_explicit(&bgp->rpkt_quanta, BGP_READ_PACKET_MAX, | |
1522 | memory_order_relaxed); | |
1523 | } | |
cb1faec9 | 1524 | |
d62a17ae | 1525 | return CMD_SUCCESS; |
cb1faec9 DS |
1526 | } |
1527 | ||
2b791107 | 1528 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1529 | { |
555e09d4 QY |
1530 | uint32_t quanta = |
1531 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1532 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1533 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1534 | } |
1535 | ||
555e09d4 QY |
1536 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1537 | { | |
1538 | uint32_t quanta = | |
1539 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1540 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1541 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1542 | } |
cb1faec9 | 1543 | |
555e09d4 | 1544 | /* Packet quanta configuration */ |
cb1faec9 DS |
1545 | DEFUN (bgp_wpkt_quanta, |
1546 | bgp_wpkt_quanta_cmd, | |
555e09d4 | 1547 | "write-quanta (1-10)", |
cb1faec9 DS |
1548 | "How many packets to write to peer socket per run\n" |
1549 | "Number of packets\n") | |
1550 | { | |
d62a17ae | 1551 | int idx_number = 1; |
1552 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1553 | } |
1554 | ||
cb1faec9 DS |
1555 | DEFUN (no_bgp_wpkt_quanta, |
1556 | no_bgp_wpkt_quanta_cmd, | |
555e09d4 | 1557 | "no write-quanta (1-10)", |
d7fa34c1 | 1558 | NO_STR |
555e09d4 | 1559 | "How many packets to write to peer socket per I/O cycle\n" |
cb1faec9 DS |
1560 | "Number of packets\n") |
1561 | { | |
d62a17ae | 1562 | int idx_number = 2; |
1563 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1564 | } |
1565 | ||
555e09d4 QY |
1566 | DEFUN (bgp_rpkt_quanta, |
1567 | bgp_rpkt_quanta_cmd, | |
1568 | "read-quanta (1-10)", | |
1569 | "How many packets to read from peer socket per I/O cycle\n" | |
1570 | "Number of packets\n") | |
1571 | { | |
1572 | int idx_number = 1; | |
1573 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
1574 | } | |
1575 | ||
1576 | DEFUN (no_bgp_rpkt_quanta, | |
1577 | no_bgp_rpkt_quanta_cmd, | |
1578 | "no read-quanta (1-10)", | |
1579 | NO_STR | |
1580 | "How many packets to read from peer socket per I/O cycle\n" | |
1581 | "Number of packets\n") | |
1582 | { | |
1583 | int idx_number = 2; | |
1584 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
1585 | } | |
1586 | ||
2b791107 | 1587 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1588 | { |
37a333fe | 1589 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1590 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1591 | } |
1592 | ||
1593 | ||
1594 | DEFUN (bgp_coalesce_time, | |
1595 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1596 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1597 | "Subgroup coalesce timer\n" |
1598 | "Subgroup coalesce timer value (in ms)\n") | |
1599 | { | |
d62a17ae | 1600 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1601 | |
d62a17ae | 1602 | int idx = 0; |
1603 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1604 | bgp->heuristic_coalesce = false; |
d62a17ae | 1605 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1606 | return CMD_SUCCESS; | |
3f9c7369 DS |
1607 | } |
1608 | ||
1609 | DEFUN (no_bgp_coalesce_time, | |
1610 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1611 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1612 | NO_STR |
3f9c7369 DS |
1613 | "Subgroup coalesce timer\n" |
1614 | "Subgroup coalesce timer value (in ms)\n") | |
1615 | { | |
d62a17ae | 1616 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1617 | |
37a333fe | 1618 | bgp->heuristic_coalesce = true; |
d62a17ae | 1619 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1620 | return CMD_SUCCESS; | |
3f9c7369 DS |
1621 | } |
1622 | ||
5e242b0d DS |
1623 | /* Maximum-paths configuration */ |
1624 | DEFUN (bgp_maxpaths, | |
1625 | bgp_maxpaths_cmd, | |
6319fd63 | 1626 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1627 | "Forward packets over multiple paths\n" |
1628 | "Number of paths\n") | |
1629 | { | |
d62a17ae | 1630 | int idx_number = 1; |
1631 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1632 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1633 | } |
1634 | ||
d62a17ae | 1635 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1636 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1637 | "Forward packets over multiple paths\n" | |
1638 | "Number of paths\n") | |
596c17ba | 1639 | |
165b5fff JB |
1640 | DEFUN (bgp_maxpaths_ibgp, |
1641 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1642 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1643 | "Forward packets over multiple paths\n" |
1644 | "iBGP-multipath\n" | |
1645 | "Number of paths\n") | |
1646 | { | |
d62a17ae | 1647 | int idx_number = 2; |
1648 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1649 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1650 | } |
165b5fff | 1651 | |
d62a17ae | 1652 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1653 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1654 | "Forward packets over multiple paths\n" | |
1655 | "iBGP-multipath\n" | |
1656 | "Number of paths\n") | |
596c17ba | 1657 | |
5e242b0d DS |
1658 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1659 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1660 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1661 | "Forward packets over multiple paths\n" |
1662 | "iBGP-multipath\n" | |
1663 | "Number of paths\n" | |
1664 | "Match the cluster length\n") | |
1665 | { | |
d62a17ae | 1666 | int idx_number = 2; |
1667 | return bgp_maxpaths_config_vty( | |
1668 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1669 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1670 | } |
1671 | ||
d62a17ae | 1672 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1673 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1674 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1675 | "Forward packets over multiple paths\n" | |
1676 | "iBGP-multipath\n" | |
1677 | "Number of paths\n" | |
1678 | "Match the cluster length\n") | |
596c17ba | 1679 | |
165b5fff JB |
1680 | DEFUN (no_bgp_maxpaths, |
1681 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1682 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1683 | NO_STR |
1684 | "Forward packets over multiple paths\n" | |
1685 | "Number of paths\n") | |
1686 | { | |
d62a17ae | 1687 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1688 | } |
1689 | ||
d62a17ae | 1690 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1691 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1692 | "Forward packets over multiple paths\n" |
1693 | "Number of paths\n") | |
596c17ba | 1694 | |
165b5fff JB |
1695 | DEFUN (no_bgp_maxpaths_ibgp, |
1696 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1697 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1698 | NO_STR |
1699 | "Forward packets over multiple paths\n" | |
1700 | "iBGP-multipath\n" | |
838758ac DW |
1701 | "Number of paths\n" |
1702 | "Match the cluster length\n") | |
165b5fff | 1703 | { |
d62a17ae | 1704 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1705 | } |
1706 | ||
d62a17ae | 1707 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1708 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1709 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1710 | NO_STR | |
1711 | "Forward packets over multiple paths\n" | |
1712 | "iBGP-multipath\n" | |
1713 | "Number of paths\n" | |
1714 | "Match the cluster length\n") | |
596c17ba | 1715 | |
2b791107 | 1716 | void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 1717 | safi_t safi) |
165b5fff | 1718 | { |
d62a17ae | 1719 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1720 | vty_out(vty, " maximum-paths %d\n", |
1721 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1722 | } | |
165b5fff | 1723 | |
d62a17ae | 1724 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1725 | vty_out(vty, " maximum-paths ibgp %d", |
1726 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1727 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1728 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1729 | vty_out(vty, " equal-cluster-length"); | |
1730 | vty_out(vty, "\n"); | |
1731 | } | |
165b5fff | 1732 | } |
6b0655a2 | 1733 | |
718e3744 | 1734 | /* BGP timers. */ |
1735 | ||
1736 | DEFUN (bgp_timers, | |
1737 | bgp_timers_cmd, | |
6147e2c6 | 1738 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1739 | "Adjust routing timers\n" |
1740 | "BGP timers\n" | |
1741 | "Keepalive interval\n" | |
1742 | "Holdtime\n") | |
1743 | { | |
d62a17ae | 1744 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1745 | int idx_number = 2; | |
1746 | int idx_number_2 = 3; | |
1747 | unsigned long keepalive = 0; | |
1748 | unsigned long holdtime = 0; | |
718e3744 | 1749 | |
d62a17ae | 1750 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1751 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1752 | |
d62a17ae | 1753 | /* Holdtime value check. */ |
1754 | if (holdtime < 3 && holdtime != 0) { | |
1755 | vty_out(vty, | |
1756 | "%% hold time value must be either 0 or greater than 3\n"); | |
1757 | return CMD_WARNING_CONFIG_FAILED; | |
1758 | } | |
718e3744 | 1759 | |
d62a17ae | 1760 | bgp_timers_set(bgp, keepalive, holdtime); |
718e3744 | 1761 | |
d62a17ae | 1762 | return CMD_SUCCESS; |
718e3744 | 1763 | } |
1764 | ||
1765 | DEFUN (no_bgp_timers, | |
1766 | no_bgp_timers_cmd, | |
838758ac | 1767 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1768 | NO_STR |
1769 | "Adjust routing timers\n" | |
838758ac DW |
1770 | "BGP timers\n" |
1771 | "Keepalive interval\n" | |
1772 | "Holdtime\n") | |
718e3744 | 1773 | { |
d62a17ae | 1774 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1775 | bgp_timers_unset(bgp); | |
718e3744 | 1776 | |
d62a17ae | 1777 | return CMD_SUCCESS; |
718e3744 | 1778 | } |
1779 | ||
6b0655a2 | 1780 | |
718e3744 | 1781 | DEFUN (bgp_client_to_client_reflection, |
1782 | bgp_client_to_client_reflection_cmd, | |
1783 | "bgp client-to-client reflection", | |
1784 | "BGP specific commands\n" | |
1785 | "Configure client to client route reflection\n" | |
1786 | "reflection of routes allowed\n") | |
1787 | { | |
d62a17ae | 1788 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1789 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1790 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1791 | |
d62a17ae | 1792 | return CMD_SUCCESS; |
718e3744 | 1793 | } |
1794 | ||
1795 | DEFUN (no_bgp_client_to_client_reflection, | |
1796 | no_bgp_client_to_client_reflection_cmd, | |
1797 | "no bgp client-to-client reflection", | |
1798 | NO_STR | |
1799 | "BGP specific commands\n" | |
1800 | "Configure client to client route reflection\n" | |
1801 | "reflection of routes allowed\n") | |
1802 | { | |
d62a17ae | 1803 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1804 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1805 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1806 | |
d62a17ae | 1807 | return CMD_SUCCESS; |
718e3744 | 1808 | } |
1809 | ||
1810 | /* "bgp always-compare-med" configuration. */ | |
1811 | DEFUN (bgp_always_compare_med, | |
1812 | bgp_always_compare_med_cmd, | |
1813 | "bgp always-compare-med", | |
1814 | "BGP specific commands\n" | |
1815 | "Allow comparing MED from different neighbors\n") | |
1816 | { | |
d62a17ae | 1817 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1818 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1819 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1820 | |
d62a17ae | 1821 | return CMD_SUCCESS; |
718e3744 | 1822 | } |
1823 | ||
1824 | DEFUN (no_bgp_always_compare_med, | |
1825 | no_bgp_always_compare_med_cmd, | |
1826 | "no bgp always-compare-med", | |
1827 | NO_STR | |
1828 | "BGP specific commands\n" | |
1829 | "Allow comparing MED from different neighbors\n") | |
1830 | { | |
d62a17ae | 1831 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1832 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1833 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1834 | |
d62a17ae | 1835 | return CMD_SUCCESS; |
718e3744 | 1836 | } |
6b0655a2 | 1837 | |
9dac9fc8 DA |
1838 | |
1839 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, | |
1840 | "bgp ebgp-requires-policy", | |
1841 | "BGP specific commands\n" | |
1842 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
1843 | { | |
1844 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1845 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_ENABLED; | |
1846 | return CMD_SUCCESS; | |
1847 | } | |
1848 | ||
1849 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, | |
1850 | "no bgp ebgp-requires-policy", | |
1851 | NO_STR | |
1852 | "BGP specific commands\n" | |
1853 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
1854 | { | |
1855 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1856 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_DISABLED; | |
1857 | return CMD_SUCCESS; | |
1858 | } | |
1859 | ||
1860 | ||
718e3744 | 1861 | /* "bgp deterministic-med" configuration. */ |
1862 | DEFUN (bgp_deterministic_med, | |
1863 | bgp_deterministic_med_cmd, | |
1864 | "bgp deterministic-med", | |
1865 | "BGP specific commands\n" | |
1866 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1867 | { | |
d62a17ae | 1868 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 1869 | |
d62a17ae | 1870 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
1871 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1872 | bgp_recalculate_all_bestpaths(bgp); | |
1873 | } | |
7aafcaca | 1874 | |
d62a17ae | 1875 | return CMD_SUCCESS; |
718e3744 | 1876 | } |
1877 | ||
1878 | DEFUN (no_bgp_deterministic_med, | |
1879 | no_bgp_deterministic_med_cmd, | |
1880 | "no bgp deterministic-med", | |
1881 | NO_STR | |
1882 | "BGP specific commands\n" | |
1883 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1884 | { | |
d62a17ae | 1885 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1886 | int bestpath_per_as_used; | |
1887 | afi_t afi; | |
1888 | safi_t safi; | |
1889 | struct peer *peer; | |
1890 | struct listnode *node, *nnode; | |
1891 | ||
1892 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
1893 | bestpath_per_as_used = 0; | |
1894 | ||
1895 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc | 1896 | FOREACH_AFI_SAFI (afi, safi) |
dcc68b5e MS |
1897 | if (bgp_addpath_dmed_required( |
1898 | peer->addpath_type[afi][safi])) { | |
05c7a1cc QY |
1899 | bestpath_per_as_used = 1; |
1900 | break; | |
1901 | } | |
d62a17ae | 1902 | |
1903 | if (bestpath_per_as_used) | |
1904 | break; | |
1905 | } | |
1906 | ||
1907 | if (bestpath_per_as_used) { | |
1908 | vty_out(vty, | |
1909 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
1910 | return CMD_WARNING_CONFIG_FAILED; | |
1911 | } else { | |
1912 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1913 | bgp_recalculate_all_bestpaths(bgp); | |
1914 | } | |
1915 | } | |
1916 | ||
1917 | return CMD_SUCCESS; | |
718e3744 | 1918 | } |
538621f2 | 1919 | |
1920 | /* "bgp graceful-restart" configuration. */ | |
1921 | DEFUN (bgp_graceful_restart, | |
1922 | bgp_graceful_restart_cmd, | |
1923 | "bgp graceful-restart", | |
1924 | "BGP specific commands\n" | |
1925 | "Graceful restart capability parameters\n") | |
1926 | { | |
d62a17ae | 1927 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1928 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1929 | return CMD_SUCCESS; | |
538621f2 | 1930 | } |
1931 | ||
1932 | DEFUN (no_bgp_graceful_restart, | |
1933 | no_bgp_graceful_restart_cmd, | |
1934 | "no bgp graceful-restart", | |
1935 | NO_STR | |
1936 | "BGP specific commands\n" | |
1937 | "Graceful restart capability parameters\n") | |
1938 | { | |
d62a17ae | 1939 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1940 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1941 | return CMD_SUCCESS; | |
538621f2 | 1942 | } |
1943 | ||
93406d87 | 1944 | DEFUN (bgp_graceful_restart_stalepath_time, |
1945 | bgp_graceful_restart_stalepath_time_cmd, | |
c1779b7d | 1946 | "bgp graceful-restart stalepath-time (1-4095)", |
93406d87 | 1947 | "BGP specific commands\n" |
1948 | "Graceful restart capability parameters\n" | |
1949 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1950 | "Delay value (seconds)\n") | |
1951 | { | |
d62a17ae | 1952 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1953 | int idx_number = 3; | |
d7c0a89a | 1954 | uint32_t stalepath; |
93406d87 | 1955 | |
d62a17ae | 1956 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
1957 | bgp->stalepath_time = stalepath; | |
1958 | return CMD_SUCCESS; | |
93406d87 | 1959 | } |
1960 | ||
eb6f1b41 PG |
1961 | DEFUN (bgp_graceful_restart_restart_time, |
1962 | bgp_graceful_restart_restart_time_cmd, | |
c72d0314 | 1963 | "bgp graceful-restart restart-time (1-4095)", |
eb6f1b41 PG |
1964 | "BGP specific commands\n" |
1965 | "Graceful restart capability parameters\n" | |
1966 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1967 | "Delay value (seconds)\n") | |
1968 | { | |
d62a17ae | 1969 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1970 | int idx_number = 3; | |
d7c0a89a | 1971 | uint32_t restart; |
eb6f1b41 | 1972 | |
d62a17ae | 1973 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
1974 | bgp->restart_time = restart; | |
1975 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1976 | } |
1977 | ||
93406d87 | 1978 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1979 | no_bgp_graceful_restart_stalepath_time_cmd, | |
c1779b7d | 1980 | "no bgp graceful-restart stalepath-time [(1-4095)]", |
93406d87 | 1981 | NO_STR |
1982 | "BGP specific commands\n" | |
1983 | "Graceful restart capability parameters\n" | |
838758ac DW |
1984 | "Set the max time to hold onto restarting peer's stale paths\n" |
1985 | "Delay value (seconds)\n") | |
93406d87 | 1986 | { |
d62a17ae | 1987 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1988 | |
d62a17ae | 1989 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
1990 | return CMD_SUCCESS; | |
93406d87 | 1991 | } |
1992 | ||
eb6f1b41 PG |
1993 | DEFUN (no_bgp_graceful_restart_restart_time, |
1994 | no_bgp_graceful_restart_restart_time_cmd, | |
c72d0314 | 1995 | "no bgp graceful-restart restart-time [(1-4095)]", |
eb6f1b41 PG |
1996 | NO_STR |
1997 | "BGP specific commands\n" | |
1998 | "Graceful restart capability parameters\n" | |
838758ac DW |
1999 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
2000 | "Delay value (seconds)\n") | |
eb6f1b41 | 2001 | { |
d62a17ae | 2002 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2003 | |
d62a17ae | 2004 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2005 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2006 | } |
2007 | ||
43fc21b3 JC |
2008 | DEFUN (bgp_graceful_restart_preserve_fw, |
2009 | bgp_graceful_restart_preserve_fw_cmd, | |
2010 | "bgp graceful-restart preserve-fw-state", | |
2011 | "BGP specific commands\n" | |
2012 | "Graceful restart capability parameters\n" | |
2013 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2014 | { | |
d62a17ae | 2015 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2016 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2017 | return CMD_SUCCESS; | |
43fc21b3 JC |
2018 | } |
2019 | ||
2020 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2021 | no_bgp_graceful_restart_preserve_fw_cmd, | |
2022 | "no bgp graceful-restart preserve-fw-state", | |
2023 | NO_STR | |
2024 | "BGP specific commands\n" | |
2025 | "Graceful restart capability parameters\n" | |
2026 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2027 | { | |
d62a17ae | 2028 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2029 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2030 | return CMD_SUCCESS; | |
43fc21b3 JC |
2031 | } |
2032 | ||
7f323236 DW |
2033 | /* "bgp graceful-shutdown" configuration */ |
2034 | DEFUN (bgp_graceful_shutdown, | |
2035 | bgp_graceful_shutdown_cmd, | |
2036 | "bgp graceful-shutdown", | |
2037 | BGP_STR | |
2038 | "Graceful shutdown parameters\n") | |
2039 | { | |
2040 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2041 | ||
2042 | if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2043 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2044 | bgp_static_redo_import_check(bgp); | |
2045 | bgp_redistribute_redo(bgp); | |
2046 | bgp_clear_star_soft_out(vty, bgp->name); | |
2047 | bgp_clear_star_soft_in(vty, bgp->name); | |
2048 | } | |
2049 | ||
2050 | return CMD_SUCCESS; | |
2051 | } | |
2052 | ||
2053 | DEFUN (no_bgp_graceful_shutdown, | |
2054 | no_bgp_graceful_shutdown_cmd, | |
2055 | "no bgp graceful-shutdown", | |
2056 | NO_STR | |
2057 | BGP_STR | |
2058 | "Graceful shutdown parameters\n") | |
2059 | { | |
2060 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2061 | ||
2062 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2063 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2064 | bgp_static_redo_import_check(bgp); | |
2065 | bgp_redistribute_redo(bgp); | |
2066 | bgp_clear_star_soft_out(vty, bgp->name); | |
2067 | bgp_clear_star_soft_in(vty, bgp->name); | |
2068 | } | |
2069 | ||
2070 | return CMD_SUCCESS; | |
2071 | } | |
2072 | ||
718e3744 | 2073 | /* "bgp fast-external-failover" configuration. */ |
2074 | DEFUN (bgp_fast_external_failover, | |
2075 | bgp_fast_external_failover_cmd, | |
2076 | "bgp fast-external-failover", | |
2077 | BGP_STR | |
2078 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2079 | { | |
d62a17ae | 2080 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2081 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2082 | return CMD_SUCCESS; | |
718e3744 | 2083 | } |
2084 | ||
2085 | DEFUN (no_bgp_fast_external_failover, | |
2086 | no_bgp_fast_external_failover_cmd, | |
2087 | "no bgp fast-external-failover", | |
2088 | NO_STR | |
2089 | BGP_STR | |
2090 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2091 | { | |
d62a17ae | 2092 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2093 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2094 | return CMD_SUCCESS; | |
718e3744 | 2095 | } |
6b0655a2 | 2096 | |
718e3744 | 2097 | /* "bgp bestpath compare-routerid" configuration. */ |
2098 | DEFUN (bgp_bestpath_compare_router_id, | |
2099 | bgp_bestpath_compare_router_id_cmd, | |
2100 | "bgp bestpath compare-routerid", | |
2101 | "BGP specific commands\n" | |
2102 | "Change the default bestpath selection\n" | |
2103 | "Compare router-id for identical EBGP paths\n") | |
2104 | { | |
d62a17ae | 2105 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2106 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2107 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2108 | |
d62a17ae | 2109 | return CMD_SUCCESS; |
718e3744 | 2110 | } |
2111 | ||
2112 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2113 | no_bgp_bestpath_compare_router_id_cmd, | |
2114 | "no bgp bestpath compare-routerid", | |
2115 | NO_STR | |
2116 | "BGP specific commands\n" | |
2117 | "Change the default bestpath selection\n" | |
2118 | "Compare router-id for identical EBGP paths\n") | |
2119 | { | |
d62a17ae | 2120 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2121 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2122 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2123 | |
d62a17ae | 2124 | return CMD_SUCCESS; |
718e3744 | 2125 | } |
6b0655a2 | 2126 | |
718e3744 | 2127 | /* "bgp bestpath as-path ignore" configuration. */ |
2128 | DEFUN (bgp_bestpath_aspath_ignore, | |
2129 | bgp_bestpath_aspath_ignore_cmd, | |
2130 | "bgp bestpath as-path ignore", | |
2131 | "BGP specific commands\n" | |
2132 | "Change the default bestpath selection\n" | |
2133 | "AS-path attribute\n" | |
2134 | "Ignore as-path length in selecting a route\n") | |
2135 | { | |
d62a17ae | 2136 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2137 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2138 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2139 | |
d62a17ae | 2140 | return CMD_SUCCESS; |
718e3744 | 2141 | } |
2142 | ||
2143 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2144 | no_bgp_bestpath_aspath_ignore_cmd, | |
2145 | "no bgp bestpath as-path ignore", | |
2146 | NO_STR | |
2147 | "BGP specific commands\n" | |
2148 | "Change the default bestpath selection\n" | |
2149 | "AS-path attribute\n" | |
2150 | "Ignore as-path length in selecting a route\n") | |
2151 | { | |
d62a17ae | 2152 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2153 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2154 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2155 | |
d62a17ae | 2156 | return CMD_SUCCESS; |
718e3744 | 2157 | } |
6b0655a2 | 2158 | |
6811845b | 2159 | /* "bgp bestpath as-path confed" configuration. */ |
2160 | DEFUN (bgp_bestpath_aspath_confed, | |
2161 | bgp_bestpath_aspath_confed_cmd, | |
2162 | "bgp bestpath as-path confed", | |
2163 | "BGP specific commands\n" | |
2164 | "Change the default bestpath selection\n" | |
2165 | "AS-path attribute\n" | |
2166 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2167 | { | |
d62a17ae | 2168 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2169 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
2170 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2171 | |
d62a17ae | 2172 | return CMD_SUCCESS; |
6811845b | 2173 | } |
2174 | ||
2175 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2176 | no_bgp_bestpath_aspath_confed_cmd, | |
2177 | "no bgp bestpath as-path confed", | |
2178 | NO_STR | |
2179 | "BGP specific commands\n" | |
2180 | "Change the default bestpath selection\n" | |
2181 | "AS-path attribute\n" | |
2182 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2183 | { | |
d62a17ae | 2184 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2185 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
2186 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2187 | |
d62a17ae | 2188 | return CMD_SUCCESS; |
6811845b | 2189 | } |
6b0655a2 | 2190 | |
2fdd455c PM |
2191 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2192 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2193 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2194 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2195 | "BGP specific commands\n" |
2196 | "Change the default bestpath selection\n" | |
2197 | "AS-path attribute\n" | |
2198 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2199 | "Generate an AS_SET\n" |
16fc1eec DS |
2200 | "Do not generate an AS_SET\n") |
2201 | { | |
d62a17ae | 2202 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2203 | int idx = 0; | |
2204 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 2205 | |
d62a17ae | 2206 | /* no-as-set is now the default behavior so we can silently |
2207 | * ignore it */ | |
2208 | if (argv_find(argv, argc, "as-set", &idx)) | |
2209 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2210 | else | |
2211 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 2212 | |
d62a17ae | 2213 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2214 | |
d62a17ae | 2215 | return CMD_SUCCESS; |
16fc1eec DS |
2216 | } |
2217 | ||
219178b6 DW |
2218 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2219 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2220 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2221 | NO_STR |
2222 | "BGP specific commands\n" | |
2223 | "Change the default bestpath selection\n" | |
2224 | "AS-path attribute\n" | |
2225 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2226 | "Generate an AS_SET\n" |
16fc1eec DS |
2227 | "Do not generate an AS_SET\n") |
2228 | { | |
d62a17ae | 2229 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2230 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
2231 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2232 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2233 | |
d62a17ae | 2234 | return CMD_SUCCESS; |
2fdd455c | 2235 | } |
6b0655a2 | 2236 | |
848973c7 | 2237 | /* "bgp log-neighbor-changes" configuration. */ |
2238 | DEFUN (bgp_log_neighbor_changes, | |
2239 | bgp_log_neighbor_changes_cmd, | |
2240 | "bgp log-neighbor-changes", | |
2241 | "BGP specific commands\n" | |
2242 | "Log neighbor up/down and reset reason\n") | |
2243 | { | |
d62a17ae | 2244 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2245 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2246 | return CMD_SUCCESS; | |
848973c7 | 2247 | } |
2248 | ||
2249 | DEFUN (no_bgp_log_neighbor_changes, | |
2250 | no_bgp_log_neighbor_changes_cmd, | |
2251 | "no bgp log-neighbor-changes", | |
2252 | NO_STR | |
2253 | "BGP specific commands\n" | |
2254 | "Log neighbor up/down and reset reason\n") | |
2255 | { | |
d62a17ae | 2256 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2257 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2258 | return CMD_SUCCESS; | |
848973c7 | 2259 | } |
6b0655a2 | 2260 | |
718e3744 | 2261 | /* "bgp bestpath med" configuration. */ |
2262 | DEFUN (bgp_bestpath_med, | |
2263 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2264 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2265 | "BGP specific commands\n" |
2266 | "Change the default bestpath selection\n" | |
2267 | "MED attribute\n" | |
2268 | "Compare MED among confederation paths\n" | |
838758ac DW |
2269 | "Treat missing MED as the least preferred one\n" |
2270 | "Treat missing MED as the least preferred one\n" | |
2271 | "Compare MED among confederation paths\n") | |
718e3744 | 2272 | { |
d62a17ae | 2273 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2274 | |
d62a17ae | 2275 | int idx = 0; |
2276 | if (argv_find(argv, argc, "confed", &idx)) | |
2277 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2278 | idx = 0; | |
2279 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2280 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2281 | |
d62a17ae | 2282 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2283 | |
d62a17ae | 2284 | return CMD_SUCCESS; |
718e3744 | 2285 | } |
2286 | ||
718e3744 | 2287 | DEFUN (no_bgp_bestpath_med, |
2288 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2289 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2290 | NO_STR |
2291 | "BGP specific commands\n" | |
2292 | "Change the default bestpath selection\n" | |
2293 | "MED attribute\n" | |
2294 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2295 | "Treat missing MED as the least preferred one\n" |
2296 | "Treat missing MED as the least preferred one\n" | |
2297 | "Compare MED among confederation paths\n") | |
718e3744 | 2298 | { |
d62a17ae | 2299 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2300 | |
d62a17ae | 2301 | int idx = 0; |
2302 | if (argv_find(argv, argc, "confed", &idx)) | |
2303 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2304 | idx = 0; | |
2305 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2306 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2307 | |
d62a17ae | 2308 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2309 | |
d62a17ae | 2310 | return CMD_SUCCESS; |
718e3744 | 2311 | } |
2312 | ||
718e3744 | 2313 | /* "no bgp default ipv4-unicast". */ |
2314 | DEFUN (no_bgp_default_ipv4_unicast, | |
2315 | no_bgp_default_ipv4_unicast_cmd, | |
2316 | "no bgp default ipv4-unicast", | |
2317 | NO_STR | |
2318 | "BGP specific commands\n" | |
2319 | "Configure BGP defaults\n" | |
2320 | "Activate ipv4-unicast for a peer by default\n") | |
2321 | { | |
d62a17ae | 2322 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2323 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2324 | return CMD_SUCCESS; | |
718e3744 | 2325 | } |
2326 | ||
2327 | DEFUN (bgp_default_ipv4_unicast, | |
2328 | bgp_default_ipv4_unicast_cmd, | |
2329 | "bgp default ipv4-unicast", | |
2330 | "BGP specific commands\n" | |
2331 | "Configure BGP defaults\n" | |
2332 | "Activate ipv4-unicast for a peer by default\n") | |
2333 | { | |
d62a17ae | 2334 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2335 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2336 | return CMD_SUCCESS; | |
718e3744 | 2337 | } |
6b0655a2 | 2338 | |
04b6bdc0 DW |
2339 | /* Display hostname in certain command outputs */ |
2340 | DEFUN (bgp_default_show_hostname, | |
2341 | bgp_default_show_hostname_cmd, | |
2342 | "bgp default show-hostname", | |
2343 | "BGP specific commands\n" | |
2344 | "Configure BGP defaults\n" | |
0437e105 | 2345 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2346 | { |
d62a17ae | 2347 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2348 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2349 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2350 | } |
2351 | ||
2352 | DEFUN (no_bgp_default_show_hostname, | |
2353 | no_bgp_default_show_hostname_cmd, | |
2354 | "no bgp default show-hostname", | |
2355 | NO_STR | |
2356 | "BGP specific commands\n" | |
2357 | "Configure BGP defaults\n" | |
0437e105 | 2358 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2359 | { |
d62a17ae | 2360 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2361 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2362 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2363 | } |
2364 | ||
8233ef81 | 2365 | /* "bgp network import-check" configuration. */ |
718e3744 | 2366 | DEFUN (bgp_network_import_check, |
2367 | bgp_network_import_check_cmd, | |
5623e905 | 2368 | "bgp network import-check", |
718e3744 | 2369 | "BGP specific commands\n" |
2370 | "BGP network command\n" | |
5623e905 | 2371 | "Check BGP network route exists in IGP\n") |
718e3744 | 2372 | { |
d62a17ae | 2373 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2374 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2375 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
2376 | bgp_static_redo_import_check(bgp); | |
2377 | } | |
078430f6 | 2378 | |
d62a17ae | 2379 | return CMD_SUCCESS; |
718e3744 | 2380 | } |
2381 | ||
d62a17ae | 2382 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
2383 | "bgp network import-check exact", | |
2384 | "BGP specific commands\n" | |
2385 | "BGP network command\n" | |
2386 | "Check BGP network route exists in IGP\n" | |
2387 | "Match route precisely\n") | |
8233ef81 | 2388 | |
718e3744 | 2389 | DEFUN (no_bgp_network_import_check, |
2390 | no_bgp_network_import_check_cmd, | |
5623e905 | 2391 | "no bgp network import-check", |
718e3744 | 2392 | NO_STR |
2393 | "BGP specific commands\n" | |
2394 | "BGP network command\n" | |
2395 | "Check BGP network route exists in IGP\n") | |
2396 | { | |
d62a17ae | 2397 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2398 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2399 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
2400 | bgp_static_redo_import_check(bgp); | |
2401 | } | |
5623e905 | 2402 | |
d62a17ae | 2403 | return CMD_SUCCESS; |
718e3744 | 2404 | } |
6b0655a2 | 2405 | |
718e3744 | 2406 | DEFUN (bgp_default_local_preference, |
2407 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2408 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2409 | "BGP specific commands\n" |
2410 | "Configure BGP defaults\n" | |
2411 | "local preference (higher=more preferred)\n" | |
2412 | "Configure default local preference value\n") | |
2413 | { | |
d62a17ae | 2414 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2415 | int idx_number = 3; | |
d7c0a89a | 2416 | uint32_t local_pref; |
718e3744 | 2417 | |
d62a17ae | 2418 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2419 | |
d62a17ae | 2420 | bgp_default_local_preference_set(bgp, local_pref); |
2421 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 2422 | |
d62a17ae | 2423 | return CMD_SUCCESS; |
718e3744 | 2424 | } |
2425 | ||
2426 | DEFUN (no_bgp_default_local_preference, | |
2427 | no_bgp_default_local_preference_cmd, | |
838758ac | 2428 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2429 | NO_STR |
2430 | "BGP specific commands\n" | |
2431 | "Configure BGP defaults\n" | |
838758ac DW |
2432 | "local preference (higher=more preferred)\n" |
2433 | "Configure default local preference value\n") | |
718e3744 | 2434 | { |
d62a17ae | 2435 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2436 | bgp_default_local_preference_unset(bgp); | |
2437 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2438 | |
d62a17ae | 2439 | return CMD_SUCCESS; |
718e3744 | 2440 | } |
2441 | ||
6b0655a2 | 2442 | |
3f9c7369 DS |
2443 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2444 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2445 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2446 | "BGP specific commands\n" |
2447 | "Configure BGP defaults\n" | |
2448 | "subgroup-pkt-queue-max\n" | |
2449 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2450 | { |
d62a17ae | 2451 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2452 | int idx_number = 3; | |
d7c0a89a | 2453 | uint32_t max_size; |
8bd9d948 | 2454 | |
d62a17ae | 2455 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 2456 | |
d62a17ae | 2457 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 2458 | |
d62a17ae | 2459 | return CMD_SUCCESS; |
3f9c7369 DS |
2460 | } |
2461 | ||
2462 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2463 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2464 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2465 | NO_STR |
2466 | "BGP specific commands\n" | |
2467 | "Configure BGP defaults\n" | |
838758ac DW |
2468 | "subgroup-pkt-queue-max\n" |
2469 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2470 | { |
d62a17ae | 2471 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2472 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
2473 | return CMD_SUCCESS; | |
8bd9d948 DS |
2474 | } |
2475 | ||
813d4307 | 2476 | |
8bd9d948 DS |
2477 | DEFUN (bgp_rr_allow_outbound_policy, |
2478 | bgp_rr_allow_outbound_policy_cmd, | |
2479 | "bgp route-reflector allow-outbound-policy", | |
2480 | "BGP specific commands\n" | |
2481 | "Allow modifications made by out route-map\n" | |
2482 | "on ibgp neighbors\n") | |
2483 | { | |
d62a17ae | 2484 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2485 | |
d62a17ae | 2486 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2487 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2488 | update_group_announce_rrclients(bgp); | |
2489 | bgp_clear_star_soft_out(vty, bgp->name); | |
2490 | } | |
8bd9d948 | 2491 | |
d62a17ae | 2492 | return CMD_SUCCESS; |
8bd9d948 DS |
2493 | } |
2494 | ||
2495 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2496 | no_bgp_rr_allow_outbound_policy_cmd, | |
2497 | "no bgp route-reflector allow-outbound-policy", | |
2498 | NO_STR | |
2499 | "BGP specific commands\n" | |
2500 | "Allow modifications made by out route-map\n" | |
2501 | "on ibgp neighbors\n") | |
2502 | { | |
d62a17ae | 2503 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2504 | |
d62a17ae | 2505 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2506 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2507 | update_group_announce_rrclients(bgp); | |
2508 | bgp_clear_star_soft_out(vty, bgp->name); | |
2509 | } | |
8bd9d948 | 2510 | |
d62a17ae | 2511 | return CMD_SUCCESS; |
8bd9d948 DS |
2512 | } |
2513 | ||
f14e6fdb DS |
2514 | DEFUN (bgp_listen_limit, |
2515 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2516 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2517 | "BGP specific commands\n" |
2518 | "Configure BGP defaults\n" | |
2519 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2520 | "Configure Dynamic Neighbors listen limit value\n") | |
2521 | { | |
d62a17ae | 2522 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2523 | int idx_number = 3; | |
2524 | int listen_limit; | |
f14e6fdb | 2525 | |
d62a17ae | 2526 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 2527 | |
d62a17ae | 2528 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 2529 | |
d62a17ae | 2530 | return CMD_SUCCESS; |
f14e6fdb DS |
2531 | } |
2532 | ||
2533 | DEFUN (no_bgp_listen_limit, | |
2534 | no_bgp_listen_limit_cmd, | |
838758ac | 2535 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2536 | "BGP specific commands\n" |
2537 | "Configure BGP defaults\n" | |
2538 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2539 | "Configure Dynamic Neighbors listen limit value to default\n" |
2540 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2541 | { |
d62a17ae | 2542 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2543 | bgp_listen_limit_unset(bgp); | |
2544 | return CMD_SUCCESS; | |
f14e6fdb DS |
2545 | } |
2546 | ||
2547 | ||
20eb8864 | 2548 | /* |
2549 | * Check if this listen range is already configured. Check for exact | |
2550 | * match or overlap based on input. | |
2551 | */ | |
d62a17ae | 2552 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
2553 | struct prefix *range, int exact) | |
2554 | { | |
2555 | struct listnode *node, *nnode; | |
2556 | struct listnode *node1, *nnode1; | |
2557 | struct peer_group *group; | |
2558 | struct prefix *lr; | |
2559 | afi_t afi; | |
2560 | int match; | |
2561 | ||
2562 | afi = family2afi(range->family); | |
2563 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2564 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
2565 | lr)) { | |
2566 | if (exact) | |
2567 | match = prefix_same(range, lr); | |
2568 | else | |
2569 | match = (prefix_match(range, lr) | |
2570 | || prefix_match(lr, range)); | |
2571 | if (match) | |
2572 | return group; | |
2573 | } | |
2574 | } | |
2575 | ||
2576 | return NULL; | |
20eb8864 | 2577 | } |
2578 | ||
f14e6fdb DS |
2579 | DEFUN (bgp_listen_range, |
2580 | bgp_listen_range_cmd, | |
d7b9898c | 2581 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
f14e6fdb | 2582 | "BGP specific commands\n" |
d7fa34c1 QY |
2583 | "Configure BGP dynamic neighbors listen range\n" |
2584 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2585 | NEIGHBOR_ADDR_STR |
2586 | "Member of the peer-group\n" | |
2587 | "Peer-group name\n") | |
f14e6fdb | 2588 | { |
d62a17ae | 2589 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2590 | struct prefix range; | |
2591 | struct peer_group *group, *existing_group; | |
2592 | afi_t afi; | |
2593 | int ret; | |
2594 | int idx = 0; | |
2595 | ||
2596 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2597 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2598 | char *prefix = argv[idx]->arg; | |
d7b9898c | 2599 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 2600 | char *peergroup = argv[idx]->arg; |
2601 | ||
2602 | /* Convert IP prefix string to struct prefix. */ | |
2603 | ret = str2prefix(prefix, &range); | |
2604 | if (!ret) { | |
2605 | vty_out(vty, "%% Malformed listen range\n"); | |
2606 | return CMD_WARNING_CONFIG_FAILED; | |
2607 | } | |
2608 | ||
2609 | afi = family2afi(range.family); | |
2610 | ||
2611 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2612 | vty_out(vty, | |
2613 | "%% Malformed listen range (link-local address)\n"); | |
2614 | return CMD_WARNING_CONFIG_FAILED; | |
2615 | } | |
2616 | ||
2617 | apply_mask(&range); | |
2618 | ||
2619 | /* Check if same listen range is already configured. */ | |
2620 | existing_group = listen_range_exists(bgp, &range, 1); | |
2621 | if (existing_group) { | |
2622 | if (strcmp(existing_group->name, peergroup) == 0) | |
2623 | return CMD_SUCCESS; | |
2624 | else { | |
2625 | vty_out(vty, | |
2626 | "%% Same listen range is attached to peer-group %s\n", | |
2627 | existing_group->name); | |
2628 | return CMD_WARNING_CONFIG_FAILED; | |
2629 | } | |
2630 | } | |
2631 | ||
2632 | /* Check if an overlapping listen range exists. */ | |
2633 | if (listen_range_exists(bgp, &range, 0)) { | |
2634 | vty_out(vty, | |
2635 | "%% Listen range overlaps with existing listen range\n"); | |
2636 | return CMD_WARNING_CONFIG_FAILED; | |
2637 | } | |
2638 | ||
2639 | group = peer_group_lookup(bgp, peergroup); | |
2640 | if (!group) { | |
2641 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2642 | return CMD_WARNING_CONFIG_FAILED; | |
2643 | } | |
2644 | ||
2645 | ret = peer_group_listen_range_add(group, &range); | |
2646 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
2647 | } |
2648 | ||
2649 | DEFUN (no_bgp_listen_range, | |
2650 | no_bgp_listen_range_cmd, | |
d7b9898c | 2651 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 2652 | NO_STR |
f14e6fdb | 2653 | "BGP specific commands\n" |
d7fa34c1 QY |
2654 | "Unconfigure BGP dynamic neighbors listen range\n" |
2655 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2656 | NEIGHBOR_ADDR_STR | |
2657 | "Member of the peer-group\n" | |
2658 | "Peer-group name\n") | |
f14e6fdb | 2659 | { |
d62a17ae | 2660 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2661 | struct prefix range; | |
2662 | struct peer_group *group; | |
2663 | afi_t afi; | |
2664 | int ret; | |
2665 | int idx = 0; | |
2666 | ||
2667 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2668 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2669 | char *prefix = argv[idx]->arg; | |
2670 | argv_find(argv, argc, "WORD", &idx); | |
2671 | char *peergroup = argv[idx]->arg; | |
2672 | ||
2673 | /* Convert IP prefix string to struct prefix. */ | |
2674 | ret = str2prefix(prefix, &range); | |
2675 | if (!ret) { | |
2676 | vty_out(vty, "%% Malformed listen range\n"); | |
2677 | return CMD_WARNING_CONFIG_FAILED; | |
2678 | } | |
2679 | ||
2680 | afi = family2afi(range.family); | |
2681 | ||
2682 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2683 | vty_out(vty, | |
2684 | "%% Malformed listen range (link-local address)\n"); | |
2685 | return CMD_WARNING_CONFIG_FAILED; | |
2686 | } | |
2687 | ||
2688 | apply_mask(&range); | |
2689 | ||
2690 | group = peer_group_lookup(bgp, peergroup); | |
2691 | if (!group) { | |
2692 | vty_out(vty, "%% Peer-group does not exist\n"); | |
2693 | return CMD_WARNING_CONFIG_FAILED; | |
2694 | } | |
2695 | ||
2696 | ret = peer_group_listen_range_del(group, &range); | |
2697 | return bgp_vty_return(vty, ret); | |
2698 | } | |
2699 | ||
2b791107 | 2700 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 2701 | { |
2702 | struct peer_group *group; | |
2703 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2704 | struct prefix *range; | |
2705 | afi_t afi; | |
2706 | char buf[PREFIX2STR_BUFFER]; | |
2707 | ||
2708 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2709 | vty_out(vty, " bgp listen limit %d\n", | |
2710 | bgp->dynamic_neighbors_limit); | |
2711 | ||
2712 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2713 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
2714 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
2715 | nrnode, range)) { | |
2716 | prefix2str(range, buf, sizeof(buf)); | |
2717 | vty_out(vty, | |
2718 | " bgp listen range %s peer-group %s\n", | |
2719 | buf, group->name); | |
2720 | } | |
2721 | } | |
2722 | } | |
f14e6fdb DS |
2723 | } |
2724 | ||
2725 | ||
907f92c8 DS |
2726 | DEFUN (bgp_disable_connected_route_check, |
2727 | bgp_disable_connected_route_check_cmd, | |
2728 | "bgp disable-ebgp-connected-route-check", | |
2729 | "BGP specific commands\n" | |
2730 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2731 | { | |
d62a17ae | 2732 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2733 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2734 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2735 | |
d62a17ae | 2736 | return CMD_SUCCESS; |
907f92c8 DS |
2737 | } |
2738 | ||
2739 | DEFUN (no_bgp_disable_connected_route_check, | |
2740 | no_bgp_disable_connected_route_check_cmd, | |
2741 | "no bgp disable-ebgp-connected-route-check", | |
2742 | NO_STR | |
2743 | "BGP specific commands\n" | |
2744 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2745 | { | |
d62a17ae | 2746 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2747 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2748 | bgp_clear_star_soft_in(vty, bgp->name); | |
2749 | ||
2750 | return CMD_SUCCESS; | |
2751 | } | |
2752 | ||
2753 | ||
2754 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
2755 | const char *as_str, afi_t afi, safi_t safi) | |
2756 | { | |
2757 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2758 | int ret; | |
2759 | as_t as; | |
2760 | int as_type = AS_SPECIFIED; | |
2761 | union sockunion su; | |
2762 | ||
2763 | if (as_str[0] == 'i') { | |
2764 | as = 0; | |
2765 | as_type = AS_INTERNAL; | |
2766 | } else if (as_str[0] == 'e') { | |
2767 | as = 0; | |
2768 | as_type = AS_EXTERNAL; | |
2769 | } else { | |
2770 | /* Get AS number. */ | |
2771 | as = strtoul(as_str, NULL, 10); | |
2772 | } | |
2773 | ||
390485fd | 2774 | /* If peer is peer group or interface peer, call proper function. */ |
d62a17ae | 2775 | ret = str2sockunion(peer_str, &su); |
2776 | if (ret < 0) { | |
390485fd DS |
2777 | struct peer *peer; |
2778 | ||
2779 | /* Check if existing interface peer */ | |
2780 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
2781 | ||
d62a17ae | 2782 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, |
2783 | safi); | |
390485fd DS |
2784 | |
2785 | /* if not interface peer, check peer-group settings */ | |
2786 | if (ret < 0 && !peer) { | |
d62a17ae | 2787 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); |
2788 | if (ret < 0) { | |
2789 | vty_out(vty, | |
390485fd | 2790 | "%% Create the peer-group or interface first\n"); |
d62a17ae | 2791 | return CMD_WARNING_CONFIG_FAILED; |
2792 | } | |
2793 | return CMD_SUCCESS; | |
2794 | } | |
2795 | } else { | |
2796 | if (peer_address_self_check(bgp, &su)) { | |
2797 | vty_out(vty, | |
2798 | "%% Can not configure the local system as neighbor\n"); | |
2799 | return CMD_WARNING_CONFIG_FAILED; | |
2800 | } | |
2801 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
2802 | } | |
2803 | ||
2804 | /* This peer belongs to peer group. */ | |
2805 | switch (ret) { | |
2806 | case BGP_ERR_PEER_GROUP_MEMBER: | |
2807 | vty_out(vty, | |
faa16034 | 2808 | "%% Peer-group member cannot override remote-as of peer-group\n"); |
d62a17ae | 2809 | return CMD_WARNING_CONFIG_FAILED; |
2810 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
2811 | vty_out(vty, | |
faa16034 | 2812 | "%% Peer-group members must be all internal or all external\n"); |
d62a17ae | 2813 | return CMD_WARNING_CONFIG_FAILED; |
2814 | } | |
2815 | return bgp_vty_return(vty, ret); | |
718e3744 | 2816 | } |
2817 | ||
f26845f9 QY |
2818 | DEFUN (bgp_default_shutdown, |
2819 | bgp_default_shutdown_cmd, | |
2820 | "[no] bgp default shutdown", | |
2821 | NO_STR | |
2822 | BGP_STR | |
2823 | "Configure BGP defaults\n" | |
b012cbe2 | 2824 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
2825 | { |
2826 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2827 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
2828 | return CMD_SUCCESS; | |
2829 | } | |
2830 | ||
718e3744 | 2831 | DEFUN (neighbor_remote_as, |
2832 | neighbor_remote_as_cmd, | |
3a2d747c | 2833 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2834 | NEIGHBOR_STR |
2835 | NEIGHBOR_ADDR_STR2 | |
2836 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2837 | AS_STR |
3a2d747c QY |
2838 | "Internal BGP peer\n" |
2839 | "External BGP peer\n") | |
718e3744 | 2840 | { |
d62a17ae | 2841 | int idx_peer = 1; |
2842 | int idx_remote_as = 3; | |
2843 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
2844 | argv[idx_remote_as]->arg, AFI_IP, | |
2845 | SAFI_UNICAST); | |
2846 | } | |
2847 | ||
2848 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
2849 | afi_t afi, safi_t safi, int v6only, | |
2850 | const char *peer_group_name, | |
2851 | const char *as_str) | |
2852 | { | |
2853 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2854 | as_t as = 0; | |
2855 | int as_type = AS_UNSPECIFIED; | |
2856 | struct peer *peer; | |
2857 | struct peer_group *group; | |
2858 | int ret = 0; | |
2859 | union sockunion su; | |
2860 | ||
2861 | group = peer_group_lookup(bgp, conf_if); | |
2862 | ||
2863 | if (group) { | |
2864 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
2865 | return CMD_WARNING_CONFIG_FAILED; | |
2866 | } | |
2867 | ||
2868 | if (as_str) { | |
2869 | if (as_str[0] == 'i') { | |
2870 | as_type = AS_INTERNAL; | |
2871 | } else if (as_str[0] == 'e') { | |
2872 | as_type = AS_EXTERNAL; | |
2873 | } else { | |
2874 | /* Get AS number. */ | |
2875 | as = strtoul(as_str, NULL, 10); | |
2876 | as_type = AS_SPECIFIED; | |
2877 | } | |
2878 | } | |
2879 | ||
2880 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
2881 | if (peer) { | |
2882 | if (as_str) | |
cc4d4ce8 | 2883 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 2884 | afi, safi); |
2885 | } else { | |
2886 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2887 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
2888 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2889 | as_type, 0, 0, NULL); | |
2890 | else | |
2891 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2892 | as_type, afi, safi, NULL); | |
2893 | ||
2894 | if (!peer) { | |
2895 | vty_out(vty, "%% BGP failed to create peer\n"); | |
2896 | return CMD_WARNING_CONFIG_FAILED; | |
2897 | } | |
2898 | ||
2899 | if (v6only) | |
527de3dc | 2900 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2901 | |
2902 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
2903 | * this | |
2904 | * any unnumbered peer in order to not worry about run-time | |
2905 | * transitions | |
2906 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
2907 | * address | |
2908 | * gets deleted later etc.) | |
2909 | */ | |
2910 | if (peer->ifp) | |
2911 | bgp_zebra_initiate_radv(bgp, peer); | |
2912 | } | |
2913 | ||
2914 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
2915 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
2916 | if (v6only) | |
527de3dc | 2917 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2918 | else |
527de3dc | 2919 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2920 | |
2921 | /* v6only flag changed. Reset bgp seesion */ | |
2922 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2923 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2924 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2925 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2926 | } else | |
2927 | bgp_session_reset(peer); | |
2928 | } | |
2929 | ||
9fb964de PM |
2930 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
2931 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
2932 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 2933 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 2934 | } |
d62a17ae | 2935 | |
2936 | if (peer_group_name) { | |
2937 | group = peer_group_lookup(bgp, peer_group_name); | |
2938 | if (!group) { | |
2939 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2940 | return CMD_WARNING_CONFIG_FAILED; | |
2941 | } | |
2942 | ||
2943 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
2944 | } | |
2945 | ||
2946 | return bgp_vty_return(vty, ret); | |
a80beece DS |
2947 | } |
2948 | ||
4c48cf63 DW |
2949 | DEFUN (neighbor_interface_config, |
2950 | neighbor_interface_config_cmd, | |
d7b9898c | 2951 | "neighbor WORD interface [peer-group PGNAME]", |
4c48cf63 DW |
2952 | NEIGHBOR_STR |
2953 | "Interface name or neighbor tag\n" | |
31500417 DW |
2954 | "Enable BGP on interface\n" |
2955 | "Member of the peer-group\n" | |
16cedbb0 | 2956 | "Peer-group name\n") |
4c48cf63 | 2957 | { |
d62a17ae | 2958 | int idx_word = 1; |
2959 | int idx_peer_group_word = 4; | |
31500417 | 2960 | |
d62a17ae | 2961 | if (argc > idx_peer_group_word) |
2962 | return peer_conf_interface_get( | |
2963 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2964 | argv[idx_peer_group_word]->arg, NULL); | |
2965 | else | |
2966 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2967 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
2968 | } |
2969 | ||
4c48cf63 DW |
2970 | DEFUN (neighbor_interface_config_v6only, |
2971 | neighbor_interface_config_v6only_cmd, | |
d7b9898c | 2972 | "neighbor WORD interface v6only [peer-group PGNAME]", |
4c48cf63 DW |
2973 | NEIGHBOR_STR |
2974 | "Interface name or neighbor tag\n" | |
2975 | "Enable BGP on interface\n" | |
31500417 DW |
2976 | "Enable BGP with v6 link-local only\n" |
2977 | "Member of the peer-group\n" | |
16cedbb0 | 2978 | "Peer-group name\n") |
4c48cf63 | 2979 | { |
d62a17ae | 2980 | int idx_word = 1; |
2981 | int idx_peer_group_word = 5; | |
31500417 | 2982 | |
d62a17ae | 2983 | if (argc > idx_peer_group_word) |
2984 | return peer_conf_interface_get( | |
2985 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2986 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 2987 | |
d62a17ae | 2988 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
2989 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
2990 | } |
2991 | ||
a80beece | 2992 | |
b3a39dc5 DD |
2993 | DEFUN (neighbor_interface_config_remote_as, |
2994 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2995 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2996 | NEIGHBOR_STR |
2997 | "Interface name or neighbor tag\n" | |
2998 | "Enable BGP on interface\n" | |
3a2d747c | 2999 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3000 | AS_STR |
3a2d747c QY |
3001 | "Internal BGP peer\n" |
3002 | "External BGP peer\n") | |
b3a39dc5 | 3003 | { |
d62a17ae | 3004 | int idx_word = 1; |
3005 | int idx_remote_as = 4; | |
3006 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3007 | SAFI_UNICAST, 0, NULL, | |
3008 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3009 | } |
3010 | ||
3011 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
3012 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 3013 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3014 | NEIGHBOR_STR |
3015 | "Interface name or neighbor tag\n" | |
3a2d747c | 3016 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 3017 | "Enable BGP on interface\n" |
3a2d747c | 3018 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3019 | AS_STR |
3a2d747c QY |
3020 | "Internal BGP peer\n" |
3021 | "External BGP peer\n") | |
b3a39dc5 | 3022 | { |
d62a17ae | 3023 | int idx_word = 1; |
3024 | int idx_remote_as = 5; | |
3025 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3026 | SAFI_UNICAST, 1, NULL, | |
3027 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3028 | } |
3029 | ||
718e3744 | 3030 | DEFUN (neighbor_peer_group, |
3031 | neighbor_peer_group_cmd, | |
3032 | "neighbor WORD peer-group", | |
3033 | NEIGHBOR_STR | |
a80beece | 3034 | "Interface name or neighbor tag\n" |
718e3744 | 3035 | "Configure peer-group\n") |
3036 | { | |
d62a17ae | 3037 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3038 | int idx_word = 1; | |
3039 | struct peer *peer; | |
3040 | struct peer_group *group; | |
718e3744 | 3041 | |
d62a17ae | 3042 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
3043 | if (peer) { | |
3044 | vty_out(vty, "%% Name conflict with interface: \n"); | |
3045 | return CMD_WARNING_CONFIG_FAILED; | |
3046 | } | |
718e3744 | 3047 | |
d62a17ae | 3048 | group = peer_group_get(bgp, argv[idx_word]->arg); |
3049 | if (!group) { | |
3050 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
3051 | return CMD_WARNING_CONFIG_FAILED; | |
3052 | } | |
718e3744 | 3053 | |
d62a17ae | 3054 | return CMD_SUCCESS; |
718e3744 | 3055 | } |
3056 | ||
3057 | DEFUN (no_neighbor, | |
3058 | no_neighbor_cmd, | |
dab8cd00 | 3059 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 3060 | NO_STR |
3061 | NEIGHBOR_STR | |
3a2d747c QY |
3062 | NEIGHBOR_ADDR_STR2 |
3063 | "Specify a BGP neighbor\n" | |
3064 | AS_STR | |
3065 | "Internal BGP peer\n" | |
3066 | "External BGP peer\n") | |
718e3744 | 3067 | { |
d62a17ae | 3068 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3069 | int idx_peer = 2; | |
3070 | int ret; | |
3071 | union sockunion su; | |
3072 | struct peer_group *group; | |
3073 | struct peer *peer; | |
3074 | struct peer *other; | |
3075 | ||
3076 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3077 | if (ret < 0) { | |
3078 | /* look up for neighbor by interface name config. */ | |
3079 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3080 | if (peer) { | |
3081 | /* Request zebra to terminate IPv6 RAs on this | |
3082 | * interface. */ | |
3083 | if (peer->ifp) | |
3084 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3085 | peer_delete(peer); | |
3086 | return CMD_SUCCESS; | |
3087 | } | |
f14e6fdb | 3088 | |
d62a17ae | 3089 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
3090 | if (group) | |
3091 | peer_group_delete(group); | |
3092 | else { | |
3093 | vty_out(vty, "%% Create the peer-group first\n"); | |
3094 | return CMD_WARNING_CONFIG_FAILED; | |
3095 | } | |
3096 | } else { | |
3097 | peer = peer_lookup(bgp, &su); | |
3098 | if (peer) { | |
3099 | if (peer_dynamic_neighbor(peer)) { | |
3100 | vty_out(vty, | |
3101 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3102 | return CMD_WARNING_CONFIG_FAILED; | |
3103 | } | |
3104 | ||
3105 | other = peer->doppelganger; | |
3106 | peer_delete(peer); | |
3107 | if (other && other->status != Deleted) | |
3108 | peer_delete(other); | |
3109 | } | |
1ff9a340 | 3110 | } |
718e3744 | 3111 | |
d62a17ae | 3112 | return CMD_SUCCESS; |
718e3744 | 3113 | } |
3114 | ||
a80beece DS |
3115 | DEFUN (no_neighbor_interface_config, |
3116 | no_neighbor_interface_config_cmd, | |
d7b9898c | 3117 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3118 | NO_STR |
3119 | NEIGHBOR_STR | |
3120 | "Interface name\n" | |
31500417 DW |
3121 | "Configure BGP on interface\n" |
3122 | "Enable BGP with v6 link-local only\n" | |
3123 | "Member of the peer-group\n" | |
16cedbb0 | 3124 | "Peer-group name\n" |
3a2d747c QY |
3125 | "Specify a BGP neighbor\n" |
3126 | AS_STR | |
3127 | "Internal BGP peer\n" | |
3128 | "External BGP peer\n") | |
a80beece | 3129 | { |
d62a17ae | 3130 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3131 | int idx_word = 2; | |
3132 | struct peer *peer; | |
3133 | ||
3134 | /* look up for neighbor by interface name config. */ | |
3135 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3136 | if (peer) { | |
3137 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3138 | if (peer->ifp) | |
3139 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3140 | peer_delete(peer); | |
3141 | } else { | |
3142 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3143 | return CMD_WARNING_CONFIG_FAILED; | |
3144 | } | |
3145 | return CMD_SUCCESS; | |
a80beece DS |
3146 | } |
3147 | ||
718e3744 | 3148 | DEFUN (no_neighbor_peer_group, |
3149 | no_neighbor_peer_group_cmd, | |
3150 | "no neighbor WORD peer-group", | |
3151 | NO_STR | |
3152 | NEIGHBOR_STR | |
3153 | "Neighbor tag\n" | |
3154 | "Configure peer-group\n") | |
3155 | { | |
d62a17ae | 3156 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3157 | int idx_word = 2; | |
3158 | struct peer_group *group; | |
718e3744 | 3159 | |
d62a17ae | 3160 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
3161 | if (group) | |
3162 | peer_group_delete(group); | |
3163 | else { | |
3164 | vty_out(vty, "%% Create the peer-group first\n"); | |
3165 | return CMD_WARNING_CONFIG_FAILED; | |
3166 | } | |
3167 | return CMD_SUCCESS; | |
718e3744 | 3168 | } |
3169 | ||
a80beece DS |
3170 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3171 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3172 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3173 | NO_STR |
3174 | NEIGHBOR_STR | |
a80beece | 3175 | "Interface name or neighbor tag\n" |
718e3744 | 3176 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3177 | AS_STR |
3178 | "Internal BGP peer\n" | |
3179 | "External BGP peer\n") | |
718e3744 | 3180 | { |
d62a17ae | 3181 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3182 | int idx_word = 2; | |
3183 | struct peer_group *group; | |
3184 | struct peer *peer; | |
3185 | ||
3186 | /* look up for neighbor by interface name config. */ | |
3187 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3188 | if (peer) { | |
390485fd | 3189 | peer_as_change(peer, 0, AS_UNSPECIFIED); |
d62a17ae | 3190 | return CMD_SUCCESS; |
3191 | } | |
3192 | ||
3193 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3194 | if (group) | |
3195 | peer_group_remote_as_delete(group); | |
3196 | else { | |
3197 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3198 | return CMD_WARNING_CONFIG_FAILED; | |
3199 | } | |
3200 | return CMD_SUCCESS; | |
718e3744 | 3201 | } |
6b0655a2 | 3202 | |
718e3744 | 3203 | DEFUN (neighbor_local_as, |
3204 | neighbor_local_as_cmd, | |
9ccf14f7 | 3205 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3206 | NEIGHBOR_STR |
3207 | NEIGHBOR_ADDR_STR2 | |
3208 | "Specify a local-as number\n" | |
3209 | "AS number used as local AS\n") | |
3210 | { | |
d62a17ae | 3211 | int idx_peer = 1; |
3212 | int idx_number = 3; | |
3213 | struct peer *peer; | |
3214 | int ret; | |
3215 | as_t as; | |
718e3744 | 3216 | |
d62a17ae | 3217 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3218 | if (!peer) | |
3219 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3220 | |
d62a17ae | 3221 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3222 | ret = peer_local_as_set(peer, as, 0, 0); | |
3223 | return bgp_vty_return(vty, ret); | |
718e3744 | 3224 | } |
3225 | ||
3226 | DEFUN (neighbor_local_as_no_prepend, | |
3227 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3228 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3229 | NEIGHBOR_STR |
3230 | NEIGHBOR_ADDR_STR2 | |
3231 | "Specify a local-as number\n" | |
3232 | "AS number used as local AS\n" | |
3233 | "Do not prepend local-as to updates from ebgp peers\n") | |
3234 | { | |
d62a17ae | 3235 | int idx_peer = 1; |
3236 | int idx_number = 3; | |
3237 | struct peer *peer; | |
3238 | int ret; | |
3239 | as_t as; | |
718e3744 | 3240 | |
d62a17ae | 3241 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3242 | if (!peer) | |
3243 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3244 | |
d62a17ae | 3245 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3246 | ret = peer_local_as_set(peer, as, 1, 0); | |
3247 | return bgp_vty_return(vty, ret); | |
718e3744 | 3248 | } |
3249 | ||
9d3f9705 AC |
3250 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3251 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3252 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3253 | NEIGHBOR_STR |
3254 | NEIGHBOR_ADDR_STR2 | |
3255 | "Specify a local-as number\n" | |
3256 | "AS number used as local AS\n" | |
3257 | "Do not prepend local-as to updates from ebgp peers\n" | |
3258 | "Do not prepend local-as to updates from ibgp peers\n") | |
3259 | { | |
d62a17ae | 3260 | int idx_peer = 1; |
3261 | int idx_number = 3; | |
3262 | struct peer *peer; | |
3263 | int ret; | |
3264 | as_t as; | |
9d3f9705 | 3265 | |
d62a17ae | 3266 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3267 | if (!peer) | |
3268 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3269 | |
d62a17ae | 3270 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3271 | ret = peer_local_as_set(peer, as, 1, 1); | |
3272 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3273 | } |
3274 | ||
718e3744 | 3275 | DEFUN (no_neighbor_local_as, |
3276 | no_neighbor_local_as_cmd, | |
a636c635 | 3277 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3278 | NO_STR |
3279 | NEIGHBOR_STR | |
3280 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3281 | "Specify a local-as number\n" |
3282 | "AS number used as local AS\n" | |
3283 | "Do not prepend local-as to updates from ebgp peers\n" | |
3284 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3285 | { |
d62a17ae | 3286 | int idx_peer = 2; |
3287 | struct peer *peer; | |
3288 | int ret; | |
718e3744 | 3289 | |
d62a17ae | 3290 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3291 | if (!peer) | |
3292 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3293 | |
d62a17ae | 3294 | ret = peer_local_as_unset(peer); |
3295 | return bgp_vty_return(vty, ret); | |
718e3744 | 3296 | } |
3297 | ||
718e3744 | 3298 | |
3f9c7369 DS |
3299 | DEFUN (neighbor_solo, |
3300 | neighbor_solo_cmd, | |
9ccf14f7 | 3301 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3302 | NEIGHBOR_STR |
3303 | NEIGHBOR_ADDR_STR2 | |
3304 | "Solo peer - part of its own update group\n") | |
3305 | { | |
d62a17ae | 3306 | int idx_peer = 1; |
3307 | struct peer *peer; | |
3308 | int ret; | |
3f9c7369 | 3309 | |
d62a17ae | 3310 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3311 | if (!peer) | |
3312 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3313 | |
d62a17ae | 3314 | ret = update_group_adjust_soloness(peer, 1); |
3315 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3316 | } |
3317 | ||
3318 | DEFUN (no_neighbor_solo, | |
3319 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3320 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3321 | NO_STR |
3322 | NEIGHBOR_STR | |
3323 | NEIGHBOR_ADDR_STR2 | |
3324 | "Solo peer - part of its own update group\n") | |
3325 | { | |
d62a17ae | 3326 | int idx_peer = 2; |
3327 | struct peer *peer; | |
3328 | int ret; | |
3f9c7369 | 3329 | |
d62a17ae | 3330 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3331 | if (!peer) | |
3332 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3333 | |
d62a17ae | 3334 | ret = update_group_adjust_soloness(peer, 0); |
3335 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3336 | } |
3337 | ||
0df7c91f PJ |
3338 | DEFUN (neighbor_password, |
3339 | neighbor_password_cmd, | |
9ccf14f7 | 3340 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3341 | NEIGHBOR_STR |
3342 | NEIGHBOR_ADDR_STR2 | |
3343 | "Set a password\n" | |
3344 | "The password\n") | |
3345 | { | |
d62a17ae | 3346 | int idx_peer = 1; |
3347 | int idx_line = 3; | |
3348 | struct peer *peer; | |
3349 | int ret; | |
0df7c91f | 3350 | |
d62a17ae | 3351 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3352 | if (!peer) | |
3353 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3354 | |
d62a17ae | 3355 | ret = peer_password_set(peer, argv[idx_line]->arg); |
3356 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
3357 | } |
3358 | ||
3359 | DEFUN (no_neighbor_password, | |
3360 | no_neighbor_password_cmd, | |
a636c635 | 3361 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3362 | NO_STR |
3363 | NEIGHBOR_STR | |
3364 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3365 | "Set a password\n" |
3366 | "The password\n") | |
0df7c91f | 3367 | { |
d62a17ae | 3368 | int idx_peer = 2; |
3369 | struct peer *peer; | |
3370 | int ret; | |
0df7c91f | 3371 | |
d62a17ae | 3372 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3373 | if (!peer) | |
3374 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3375 | |
d62a17ae | 3376 | ret = peer_password_unset(peer); |
3377 | return bgp_vty_return(vty, ret); | |
0df7c91f | 3378 | } |
6b0655a2 | 3379 | |
718e3744 | 3380 | DEFUN (neighbor_activate, |
3381 | neighbor_activate_cmd, | |
9ccf14f7 | 3382 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3383 | NEIGHBOR_STR |
3384 | NEIGHBOR_ADDR_STR2 | |
3385 | "Enable the Address Family for this Neighbor\n") | |
3386 | { | |
d62a17ae | 3387 | int idx_peer = 1; |
3388 | int ret; | |
3389 | struct peer *peer; | |
718e3744 | 3390 | |
d62a17ae | 3391 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3392 | if (!peer) | |
3393 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3394 | |
d62a17ae | 3395 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3396 | return bgp_vty_return(vty, ret); | |
718e3744 | 3397 | } |
3398 | ||
d62a17ae | 3399 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
3400 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3401 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3402 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3403 | |
718e3744 | 3404 | DEFUN (no_neighbor_activate, |
3405 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3406 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3407 | NO_STR |
3408 | NEIGHBOR_STR | |
3409 | NEIGHBOR_ADDR_STR2 | |
3410 | "Enable the Address Family for this Neighbor\n") | |
3411 | { | |
d62a17ae | 3412 | int idx_peer = 2; |
3413 | int ret; | |
3414 | struct peer *peer; | |
718e3744 | 3415 | |
d62a17ae | 3416 | /* Lookup peer. */ |
3417 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3418 | if (!peer) | |
3419 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3420 | |
d62a17ae | 3421 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3422 | return bgp_vty_return(vty, ret); | |
718e3744 | 3423 | } |
6b0655a2 | 3424 | |
d62a17ae | 3425 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
3426 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3427 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3428 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3429 | |
718e3744 | 3430 | DEFUN (neighbor_set_peer_group, |
3431 | neighbor_set_peer_group_cmd, | |
d7b9898c | 3432 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 3433 | NEIGHBOR_STR |
a80beece | 3434 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3435 | "Member of the peer-group\n" |
16cedbb0 | 3436 | "Peer-group name\n") |
718e3744 | 3437 | { |
d62a17ae | 3438 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3439 | int idx_peer = 1; | |
3440 | int idx_word = 3; | |
3441 | int ret; | |
3442 | as_t as; | |
3443 | union sockunion su; | |
3444 | struct peer *peer; | |
3445 | struct peer_group *group; | |
3446 | ||
d62a17ae | 3447 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
3448 | if (ret < 0) { | |
3449 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3450 | if (!peer) { | |
3451 | vty_out(vty, "%% Malformed address or name: %s\n", | |
3452 | argv[idx_peer]->arg); | |
3453 | return CMD_WARNING_CONFIG_FAILED; | |
3454 | } | |
3455 | } else { | |
3456 | if (peer_address_self_check(bgp, &su)) { | |
3457 | vty_out(vty, | |
3458 | "%% Can not configure the local system as neighbor\n"); | |
3459 | return CMD_WARNING_CONFIG_FAILED; | |
3460 | } | |
3461 | ||
3462 | /* Disallow for dynamic neighbor. */ | |
3463 | peer = peer_lookup(bgp, &su); | |
3464 | if (peer && peer_dynamic_neighbor(peer)) { | |
3465 | vty_out(vty, | |
3466 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3467 | return CMD_WARNING_CONFIG_FAILED; | |
3468 | } | |
3469 | } | |
3470 | ||
3471 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3472 | if (!group) { | |
3473 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3474 | return CMD_WARNING_CONFIG_FAILED; | |
3475 | } | |
3476 | ||
3477 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3478 | ||
3479 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
3480 | vty_out(vty, | |
3481 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
3482 | as); | |
3483 | return CMD_WARNING_CONFIG_FAILED; | |
3484 | } | |
3485 | ||
3486 | return bgp_vty_return(vty, ret); | |
3487 | } | |
3488 | ||
3489 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 3490 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 3491 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
3492 | "Member of the peer-group\n" | |
3493 | "Peer-group name\n") | |
596c17ba | 3494 | |
718e3744 | 3495 | DEFUN (no_neighbor_set_peer_group, |
3496 | no_neighbor_set_peer_group_cmd, | |
d7b9898c | 3497 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 3498 | NO_STR |
3499 | NEIGHBOR_STR | |
a80beece | 3500 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3501 | "Member of the peer-group\n" |
16cedbb0 | 3502 | "Peer-group name\n") |
718e3744 | 3503 | { |
d62a17ae | 3504 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3505 | int idx_peer = 2; | |
3506 | int idx_word = 4; | |
3507 | int ret; | |
3508 | struct peer *peer; | |
3509 | struct peer_group *group; | |
3510 | ||
3511 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
3512 | if (!peer) | |
3513 | return CMD_WARNING_CONFIG_FAILED; | |
3514 | ||
3515 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3516 | if (!group) { | |
3517 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3518 | return CMD_WARNING_CONFIG_FAILED; | |
3519 | } | |
718e3744 | 3520 | |
827ed707 | 3521 | ret = peer_delete(peer); |
718e3744 | 3522 | |
d62a17ae | 3523 | return bgp_vty_return(vty, ret); |
718e3744 | 3524 | } |
6b0655a2 | 3525 | |
d62a17ae | 3526 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
d7b9898c | 3527 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 3528 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
3529 | "Member of the peer-group\n" | |
3530 | "Peer-group name\n") | |
596c17ba | 3531 | |
d62a17ae | 3532 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3533 | uint32_t flag, int set) |
718e3744 | 3534 | { |
d62a17ae | 3535 | int ret; |
3536 | struct peer *peer; | |
718e3744 | 3537 | |
d62a17ae | 3538 | peer = peer_and_group_lookup_vty(vty, ip_str); |
3539 | if (!peer) | |
3540 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3541 | |
7ebe625c QY |
3542 | /* |
3543 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3544 | * we should not accept disable-connected-check. | |
3545 | */ | |
3546 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3547 | vty_out(vty, | |
3548 | "%s is directly connected peer, cannot accept disable-" | |
3549 | "connected-check\n", | |
3550 | ip_str); | |
3551 | return CMD_WARNING_CONFIG_FAILED; | |
3552 | } | |
3553 | ||
d62a17ae | 3554 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3555 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 3556 | |
d62a17ae | 3557 | if (set) |
3558 | ret = peer_flag_set(peer, flag); | |
3559 | else | |
3560 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 3561 | |
d62a17ae | 3562 | return bgp_vty_return(vty, ret); |
718e3744 | 3563 | } |
3564 | ||
47cbc09b | 3565 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 3566 | { |
d62a17ae | 3567 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 3568 | } |
3569 | ||
d62a17ae | 3570 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3571 | uint32_t flag) |
718e3744 | 3572 | { |
d62a17ae | 3573 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 3574 | } |
3575 | ||
3576 | /* neighbor passive. */ | |
3577 | DEFUN (neighbor_passive, | |
3578 | neighbor_passive_cmd, | |
9ccf14f7 | 3579 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3580 | NEIGHBOR_STR |
3581 | NEIGHBOR_ADDR_STR2 | |
3582 | "Don't send open messages to this neighbor\n") | |
3583 | { | |
d62a17ae | 3584 | int idx_peer = 1; |
3585 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3586 | } |
3587 | ||
3588 | DEFUN (no_neighbor_passive, | |
3589 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3590 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3591 | NO_STR |
3592 | NEIGHBOR_STR | |
3593 | NEIGHBOR_ADDR_STR2 | |
3594 | "Don't send open messages to this neighbor\n") | |
3595 | { | |
d62a17ae | 3596 | int idx_peer = 2; |
3597 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3598 | } |
6b0655a2 | 3599 | |
718e3744 | 3600 | /* neighbor shutdown. */ |
73d70fa6 DL |
3601 | DEFUN (neighbor_shutdown_msg, |
3602 | neighbor_shutdown_msg_cmd, | |
3603 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3604 | NEIGHBOR_STR |
3605 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3606 | "Administratively shut down this neighbor\n" |
3607 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3608 | "Shutdown message\n") | |
718e3744 | 3609 | { |
d62a17ae | 3610 | int idx_peer = 1; |
73d70fa6 | 3611 | |
d62a17ae | 3612 | if (argc >= 5) { |
3613 | struct peer *peer = | |
3614 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3615 | char *message; | |
73d70fa6 | 3616 | |
d62a17ae | 3617 | if (!peer) |
3618 | return CMD_WARNING_CONFIG_FAILED; | |
3619 | message = argv_concat(argv, argc, 4); | |
3620 | peer_tx_shutdown_message_set(peer, message); | |
3621 | XFREE(MTYPE_TMP, message); | |
3622 | } | |
73d70fa6 | 3623 | |
d62a17ae | 3624 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3625 | } |
3626 | ||
d62a17ae | 3627 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
3628 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3629 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3630 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3631 | |
3632 | DEFUN (no_neighbor_shutdown_msg, | |
3633 | no_neighbor_shutdown_msg_cmd, | |
3634 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3635 | NO_STR | |
3636 | NEIGHBOR_STR | |
3637 | NEIGHBOR_ADDR_STR2 | |
3638 | "Administratively shut down this neighbor\n" | |
3639 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3640 | "Shutdown message\n") | |
718e3744 | 3641 | { |
d62a17ae | 3642 | int idx_peer = 2; |
73d70fa6 | 3643 | |
d62a17ae | 3644 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
3645 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 3646 | } |
6b0655a2 | 3647 | |
d62a17ae | 3648 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
3649 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3650 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3651 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 3652 | |
718e3744 | 3653 | /* neighbor capability dynamic. */ |
3654 | DEFUN (neighbor_capability_dynamic, | |
3655 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3656 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3657 | NEIGHBOR_STR |
3658 | NEIGHBOR_ADDR_STR2 | |
3659 | "Advertise capability to the peer\n" | |
3660 | "Advertise dynamic capability to this neighbor\n") | |
3661 | { | |
d62a17ae | 3662 | int idx_peer = 1; |
3663 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3664 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3665 | } |
3666 | ||
3667 | DEFUN (no_neighbor_capability_dynamic, | |
3668 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3669 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3670 | NO_STR |
3671 | NEIGHBOR_STR | |
3672 | NEIGHBOR_ADDR_STR2 | |
3673 | "Advertise capability to the peer\n" | |
3674 | "Advertise dynamic capability to this neighbor\n") | |
3675 | { | |
d62a17ae | 3676 | int idx_peer = 2; |
3677 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3678 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3679 | } |
6b0655a2 | 3680 | |
718e3744 | 3681 | /* neighbor dont-capability-negotiate */ |
3682 | DEFUN (neighbor_dont_capability_negotiate, | |
3683 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3684 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3685 | NEIGHBOR_STR |
3686 | NEIGHBOR_ADDR_STR2 | |
3687 | "Do not perform capability negotiation\n") | |
3688 | { | |
d62a17ae | 3689 | int idx_peer = 1; |
3690 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3691 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3692 | } |
3693 | ||
3694 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3695 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3696 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3697 | NO_STR |
3698 | NEIGHBOR_STR | |
3699 | NEIGHBOR_ADDR_STR2 | |
3700 | "Do not perform capability negotiation\n") | |
3701 | { | |
d62a17ae | 3702 | int idx_peer = 2; |
3703 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3704 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3705 | } |
6b0655a2 | 3706 | |
8a92a8a0 DS |
3707 | /* neighbor capability extended next hop encoding */ |
3708 | DEFUN (neighbor_capability_enhe, | |
3709 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3710 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3711 | NEIGHBOR_STR |
3712 | NEIGHBOR_ADDR_STR2 | |
3713 | "Advertise capability to the peer\n" | |
3714 | "Advertise extended next-hop capability to the peer\n") | |
3715 | { | |
d62a17ae | 3716 | int idx_peer = 1; |
3717 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3718 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3719 | } |
3720 | ||
3721 | DEFUN (no_neighbor_capability_enhe, | |
3722 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3723 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3724 | NO_STR |
3725 | NEIGHBOR_STR | |
3726 | NEIGHBOR_ADDR_STR2 | |
3727 | "Advertise capability to the peer\n" | |
3728 | "Advertise extended next-hop capability to the peer\n") | |
3729 | { | |
d62a17ae | 3730 | int idx_peer = 2; |
3731 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3732 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3733 | } |
3734 | ||
d62a17ae | 3735 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3736 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 3737 | int set) |
718e3744 | 3738 | { |
d62a17ae | 3739 | int ret; |
3740 | struct peer *peer; | |
718e3744 | 3741 | |
d62a17ae | 3742 | peer = peer_and_group_lookup_vty(vty, peer_str); |
3743 | if (!peer) | |
3744 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3745 | |
d62a17ae | 3746 | if (set) |
3747 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
3748 | else | |
3749 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 3750 | |
d62a17ae | 3751 | return bgp_vty_return(vty, ret); |
718e3744 | 3752 | } |
3753 | ||
d62a17ae | 3754 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3755 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3756 | { |
d62a17ae | 3757 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 3758 | } |
3759 | ||
d62a17ae | 3760 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3761 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3762 | { |
d62a17ae | 3763 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 3764 | } |
6b0655a2 | 3765 | |
718e3744 | 3766 | /* neighbor capability orf prefix-list. */ |
3767 | DEFUN (neighbor_capability_orf_prefix, | |
3768 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3769 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3770 | NEIGHBOR_STR |
3771 | NEIGHBOR_ADDR_STR2 | |
3772 | "Advertise capability to the peer\n" | |
3773 | "Advertise ORF capability to the peer\n" | |
3774 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3775 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3776 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3777 | "Capability to SEND the ORF to this neighbor\n") | |
3778 | { | |
d62a17ae | 3779 | int idx_peer = 1; |
3780 | int idx_send_recv = 5; | |
d7c0a89a | 3781 | uint16_t flag = 0; |
d62a17ae | 3782 | |
3783 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3784 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3785 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3786 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3787 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3788 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3789 | else { | |
3790 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3791 | return CMD_WARNING_CONFIG_FAILED; | |
3792 | } | |
3793 | ||
3794 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3795 | bgp_node_safi(vty), flag); | |
3796 | } | |
3797 | ||
3798 | ALIAS_HIDDEN( | |
3799 | neighbor_capability_orf_prefix, | |
3800 | neighbor_capability_orf_prefix_hidden_cmd, | |
3801 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3802 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3803 | "Advertise capability to the peer\n" | |
3804 | "Advertise ORF capability to the peer\n" | |
3805 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3806 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3807 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3808 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3809 | |
718e3744 | 3810 | DEFUN (no_neighbor_capability_orf_prefix, |
3811 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3812 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3813 | NO_STR |
3814 | NEIGHBOR_STR | |
3815 | NEIGHBOR_ADDR_STR2 | |
3816 | "Advertise capability to the peer\n" | |
3817 | "Advertise ORF capability to the peer\n" | |
3818 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3819 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3820 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3821 | "Capability to SEND the ORF to this neighbor\n") | |
3822 | { | |
d62a17ae | 3823 | int idx_peer = 2; |
3824 | int idx_send_recv = 6; | |
d7c0a89a | 3825 | uint16_t flag = 0; |
d62a17ae | 3826 | |
3827 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3828 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3829 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3830 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3831 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3832 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3833 | else { | |
3834 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3835 | return CMD_WARNING_CONFIG_FAILED; | |
3836 | } | |
3837 | ||
3838 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3839 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3840 | flag); | |
3841 | } | |
3842 | ||
3843 | ALIAS_HIDDEN( | |
3844 | no_neighbor_capability_orf_prefix, | |
3845 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
3846 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3847 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3848 | "Advertise capability to the peer\n" | |
3849 | "Advertise ORF capability to the peer\n" | |
3850 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3851 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3852 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3853 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3854 | |
718e3744 | 3855 | /* neighbor next-hop-self. */ |
3856 | DEFUN (neighbor_nexthop_self, | |
3857 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3858 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3859 | NEIGHBOR_STR |
3860 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3861 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3862 | { |
d62a17ae | 3863 | int idx_peer = 1; |
3864 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3865 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 3866 | } |
9e7a53c1 | 3867 | |
d62a17ae | 3868 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
3869 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3870 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3871 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3872 | |
a538debe DS |
3873 | /* neighbor next-hop-self. */ |
3874 | DEFUN (neighbor_nexthop_self_force, | |
3875 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3876 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3877 | NEIGHBOR_STR |
3878 | NEIGHBOR_ADDR_STR2 | |
3879 | "Disable the next hop calculation for this neighbor\n" | |
3880 | "Set the next hop to self for reflected routes\n") | |
3881 | { | |
d62a17ae | 3882 | int idx_peer = 1; |
3883 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3884 | bgp_node_safi(vty), | |
3885 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 3886 | } |
3887 | ||
d62a17ae | 3888 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3889 | neighbor_nexthop_self_force_hidden_cmd, | |
3890 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3891 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3892 | "Disable the next hop calculation for this neighbor\n" | |
3893 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3894 | |
1bc4e531 DA |
3895 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3896 | neighbor_nexthop_self_all_hidden_cmd, | |
3897 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
3898 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3899 | "Disable the next hop calculation for this neighbor\n" | |
3900 | "Set the next hop to self for reflected routes\n") | |
3901 | ||
718e3744 | 3902 | DEFUN (no_neighbor_nexthop_self, |
3903 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3904 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3905 | NO_STR |
3906 | NEIGHBOR_STR | |
3907 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3908 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3909 | { |
d62a17ae | 3910 | int idx_peer = 2; |
3911 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3912 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3913 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 3914 | } |
6b0655a2 | 3915 | |
d62a17ae | 3916 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
3917 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3918 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3919 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3920 | |
88b8ed8d | 3921 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3922 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3923 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3924 | NO_STR |
3925 | NEIGHBOR_STR | |
3926 | NEIGHBOR_ADDR_STR2 | |
3927 | "Disable the next hop calculation for this neighbor\n" | |
3928 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3929 | { |
d62a17ae | 3930 | int idx_peer = 2; |
3931 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3932 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3933 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 3934 | } |
a538debe | 3935 | |
d62a17ae | 3936 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
3937 | no_neighbor_nexthop_self_force_hidden_cmd, | |
3938 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3939 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3940 | "Disable the next hop calculation for this neighbor\n" | |
3941 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3942 | |
1bc4e531 DA |
3943 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
3944 | no_neighbor_nexthop_self_all_hidden_cmd, | |
3945 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
3946 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3947 | "Disable the next hop calculation for this neighbor\n" | |
3948 | "Set the next hop to self for reflected routes\n") | |
3949 | ||
c7122e14 DS |
3950 | /* neighbor as-override */ |
3951 | DEFUN (neighbor_as_override, | |
3952 | neighbor_as_override_cmd, | |
9ccf14f7 | 3953 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3954 | NEIGHBOR_STR |
3955 | NEIGHBOR_ADDR_STR2 | |
3956 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3957 | { | |
d62a17ae | 3958 | int idx_peer = 1; |
3959 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3960 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3961 | } |
3962 | ||
d62a17ae | 3963 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
3964 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3965 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3966 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3967 | |
c7122e14 DS |
3968 | DEFUN (no_neighbor_as_override, |
3969 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3970 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3971 | NO_STR |
3972 | NEIGHBOR_STR | |
3973 | NEIGHBOR_ADDR_STR2 | |
3974 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3975 | { | |
d62a17ae | 3976 | int idx_peer = 2; |
3977 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3978 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3979 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3980 | } |
3981 | ||
d62a17ae | 3982 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
3983 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3984 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3985 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3986 | |
718e3744 | 3987 | /* neighbor remove-private-AS. */ |
3988 | DEFUN (neighbor_remove_private_as, | |
3989 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3990 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3991 | NEIGHBOR_STR |
3992 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3993 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3994 | { |
d62a17ae | 3995 | int idx_peer = 1; |
3996 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3997 | bgp_node_safi(vty), | |
3998 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 3999 | } |
4000 | ||
d62a17ae | 4001 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
4002 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4003 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4004 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4005 | |
5000f21c DS |
4006 | DEFUN (neighbor_remove_private_as_all, |
4007 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 4008 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4009 | NEIGHBOR_STR |
4010 | NEIGHBOR_ADDR_STR2 | |
4011 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 4012 | "Apply to all AS numbers\n") |
5000f21c | 4013 | { |
d62a17ae | 4014 | int idx_peer = 1; |
4015 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4016 | bgp_node_safi(vty), | |
4017 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
4018 | } |
4019 | ||
d62a17ae | 4020 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
4021 | neighbor_remove_private_as_all_hidden_cmd, | |
4022 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4023 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4024 | "Remove private ASNs in outbound updates\n" | |
4025 | "Apply to all AS numbers") | |
596c17ba | 4026 | |
5000f21c DS |
4027 | DEFUN (neighbor_remove_private_as_replace_as, |
4028 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 4029 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4030 | NEIGHBOR_STR |
4031 | NEIGHBOR_ADDR_STR2 | |
4032 | "Remove private ASNs in outbound updates\n" | |
4033 | "Replace private ASNs with our ASN in outbound updates\n") | |
4034 | { | |
d62a17ae | 4035 | int idx_peer = 1; |
4036 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4037 | bgp_node_safi(vty), | |
4038 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
4039 | } |
4040 | ||
d62a17ae | 4041 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
4042 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
4043 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4044 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4045 | "Remove private ASNs in outbound updates\n" | |
4046 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4047 | |
5000f21c DS |
4048 | DEFUN (neighbor_remove_private_as_all_replace_as, |
4049 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 4050 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4051 | NEIGHBOR_STR |
4052 | NEIGHBOR_ADDR_STR2 | |
4053 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4054 | "Apply to all AS numbers\n" |
5000f21c DS |
4055 | "Replace private ASNs with our ASN in outbound updates\n") |
4056 | { | |
d62a17ae | 4057 | int idx_peer = 1; |
4058 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4059 | bgp_node_safi(vty), | |
4060 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
4061 | } |
4062 | ||
d62a17ae | 4063 | ALIAS_HIDDEN( |
4064 | neighbor_remove_private_as_all_replace_as, | |
4065 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4066 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4067 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4068 | "Remove private ASNs in outbound updates\n" | |
4069 | "Apply to all AS numbers\n" | |
4070 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4071 | |
718e3744 | 4072 | DEFUN (no_neighbor_remove_private_as, |
4073 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4074 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4075 | NO_STR |
4076 | NEIGHBOR_STR | |
4077 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4078 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4079 | { |
d62a17ae | 4080 | int idx_peer = 2; |
4081 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4082 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4083 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4084 | } |
6b0655a2 | 4085 | |
d62a17ae | 4086 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4087 | no_neighbor_remove_private_as_hidden_cmd, | |
4088 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4089 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4090 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4091 | |
88b8ed8d | 4092 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4093 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4094 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4095 | NO_STR |
4096 | NEIGHBOR_STR | |
4097 | NEIGHBOR_ADDR_STR2 | |
4098 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4099 | "Apply to all AS numbers\n") |
88b8ed8d | 4100 | { |
d62a17ae | 4101 | int idx_peer = 2; |
4102 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4103 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4104 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4105 | } |
5000f21c | 4106 | |
d62a17ae | 4107 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4108 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4109 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4110 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4111 | "Remove private ASNs in outbound updates\n" | |
4112 | "Apply to all AS numbers\n") | |
596c17ba | 4113 | |
88b8ed8d | 4114 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4115 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4116 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4117 | NO_STR |
4118 | NEIGHBOR_STR | |
4119 | NEIGHBOR_ADDR_STR2 | |
4120 | "Remove private ASNs in outbound updates\n" | |
4121 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4122 | { |
d62a17ae | 4123 | int idx_peer = 2; |
4124 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4125 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4126 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4127 | } |
5000f21c | 4128 | |
d62a17ae | 4129 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4130 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4131 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4132 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4133 | "Remove private ASNs in outbound updates\n" | |
4134 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4135 | |
88b8ed8d | 4136 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4137 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4138 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4139 | NO_STR |
4140 | NEIGHBOR_STR | |
4141 | NEIGHBOR_ADDR_STR2 | |
4142 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4143 | "Apply to all AS numbers\n" |
5000f21c | 4144 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4145 | { |
d62a17ae | 4146 | int idx_peer = 2; |
4147 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4148 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4149 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4150 | } |
5000f21c | 4151 | |
d62a17ae | 4152 | ALIAS_HIDDEN( |
4153 | no_neighbor_remove_private_as_all_replace_as, | |
4154 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4155 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4156 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4157 | "Remove private ASNs in outbound updates\n" | |
4158 | "Apply to all AS numbers\n" | |
4159 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4160 | |
5000f21c | 4161 | |
718e3744 | 4162 | /* neighbor send-community. */ |
4163 | DEFUN (neighbor_send_community, | |
4164 | neighbor_send_community_cmd, | |
9ccf14f7 | 4165 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4166 | NEIGHBOR_STR |
4167 | NEIGHBOR_ADDR_STR2 | |
4168 | "Send Community attribute to this neighbor\n") | |
4169 | { | |
d62a17ae | 4170 | int idx_peer = 1; |
27c05d4d | 4171 | |
d62a17ae | 4172 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4173 | bgp_node_safi(vty), | |
4174 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4175 | } |
4176 | ||
d62a17ae | 4177 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4178 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4179 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4180 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4181 | |
718e3744 | 4182 | DEFUN (no_neighbor_send_community, |
4183 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4184 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4185 | NO_STR |
4186 | NEIGHBOR_STR | |
4187 | NEIGHBOR_ADDR_STR2 | |
4188 | "Send Community attribute to this neighbor\n") | |
4189 | { | |
d62a17ae | 4190 | int idx_peer = 2; |
27c05d4d | 4191 | |
d62a17ae | 4192 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4193 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4194 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4195 | } |
6b0655a2 | 4196 | |
d62a17ae | 4197 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4198 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4199 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4200 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4201 | |
718e3744 | 4202 | /* neighbor send-community extended. */ |
4203 | DEFUN (neighbor_send_community_type, | |
4204 | neighbor_send_community_type_cmd, | |
57d187bc | 4205 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4206 | NEIGHBOR_STR |
4207 | NEIGHBOR_ADDR_STR2 | |
4208 | "Send Community attribute to this neighbor\n" | |
4209 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4210 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4211 | "Send Extended Community attributes\n" |
57d187bc JS |
4212 | "Send Standard Community attributes\n" |
4213 | "Send Large Community attributes\n") | |
718e3744 | 4214 | { |
27c05d4d | 4215 | int idx_peer = 1; |
d7c0a89a | 4216 | uint32_t flag = 0; |
27c05d4d | 4217 | const char *type = argv[argc - 1]->text; |
d62a17ae | 4218 | |
27c05d4d | 4219 | if (strmatch(type, "standard")) { |
d62a17ae | 4220 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
27c05d4d | 4221 | } else if (strmatch(type, "extended")) { |
d62a17ae | 4222 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); |
27c05d4d | 4223 | } else if (strmatch(type, "large")) { |
d62a17ae | 4224 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); |
27c05d4d | 4225 | } else if (strmatch(type, "both")) { |
d62a17ae | 4226 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4227 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d | 4228 | } else { /* if (strmatch(type, "all")) */ |
d62a17ae | 4229 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4230 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4231 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4232 | } | |
4233 | ||
27c05d4d | 4234 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
d62a17ae | 4235 | bgp_node_safi(vty), flag); |
4236 | } | |
4237 | ||
4238 | ALIAS_HIDDEN( | |
4239 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4240 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4241 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4242 | "Send Community attribute to this neighbor\n" | |
4243 | "Send Standard and Extended Community attributes\n" | |
4244 | "Send Standard, Large and Extended Community attributes\n" | |
4245 | "Send Extended Community attributes\n" | |
4246 | "Send Standard Community attributes\n" | |
4247 | "Send Large Community attributes\n") | |
596c17ba | 4248 | |
718e3744 | 4249 | DEFUN (no_neighbor_send_community_type, |
4250 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4251 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4252 | NO_STR |
4253 | NEIGHBOR_STR | |
4254 | NEIGHBOR_ADDR_STR2 | |
4255 | "Send Community attribute to this neighbor\n" | |
4256 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4257 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4258 | "Send Extended Community attributes\n" |
57d187bc JS |
4259 | "Send Standard Community attributes\n" |
4260 | "Send Large Community attributes\n") | |
718e3744 | 4261 | { |
d62a17ae | 4262 | int idx_peer = 2; |
27c05d4d | 4263 | uint32_t flag = 0; |
d62a17ae | 4264 | const char *type = argv[argc - 1]->text; |
4265 | ||
27c05d4d PM |
4266 | if (strmatch(type, "standard")) { |
4267 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4268 | } else if (strmatch(type, "extended")) { | |
4269 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4270 | } else if (strmatch(type, "large")) { | |
4271 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4272 | } else if (strmatch(type, "both")) { | |
4273 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4274 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4275 | } else { /* if (strmatch(type, "all")) */ | |
4276 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4277 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4278 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4279 | } | |
4280 | ||
4281 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4282 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4283 | flag); | |
d62a17ae | 4284 | } |
4285 | ||
4286 | ALIAS_HIDDEN( | |
4287 | no_neighbor_send_community_type, | |
4288 | no_neighbor_send_community_type_hidden_cmd, | |
4289 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4290 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4291 | "Send Community attribute to this neighbor\n" | |
4292 | "Send Standard and Extended Community attributes\n" | |
4293 | "Send Standard, Large and Extended Community attributes\n" | |
4294 | "Send Extended Community attributes\n" | |
4295 | "Send Standard Community attributes\n" | |
4296 | "Send Large Community attributes\n") | |
596c17ba | 4297 | |
718e3744 | 4298 | /* neighbor soft-reconfig. */ |
4299 | DEFUN (neighbor_soft_reconfiguration, | |
4300 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4301 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4302 | NEIGHBOR_STR |
4303 | NEIGHBOR_ADDR_STR2 | |
4304 | "Per neighbor soft reconfiguration\n" | |
4305 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4306 | { | |
d62a17ae | 4307 | int idx_peer = 1; |
4308 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4309 | bgp_node_safi(vty), | |
4310 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4311 | } |
4312 | ||
d62a17ae | 4313 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4314 | neighbor_soft_reconfiguration_hidden_cmd, | |
4315 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4316 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4317 | "Per neighbor soft reconfiguration\n" | |
4318 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4319 | |
718e3744 | 4320 | DEFUN (no_neighbor_soft_reconfiguration, |
4321 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4322 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4323 | NO_STR |
4324 | NEIGHBOR_STR | |
4325 | NEIGHBOR_ADDR_STR2 | |
4326 | "Per neighbor soft reconfiguration\n" | |
4327 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4328 | { | |
d62a17ae | 4329 | int idx_peer = 2; |
4330 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4331 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4332 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4333 | } |
6b0655a2 | 4334 | |
d62a17ae | 4335 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
4336 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4337 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4338 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4339 | "Per neighbor soft reconfiguration\n" | |
4340 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4341 | |
718e3744 | 4342 | DEFUN (neighbor_route_reflector_client, |
4343 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4344 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4345 | NEIGHBOR_STR |
4346 | NEIGHBOR_ADDR_STR2 | |
4347 | "Configure a neighbor as Route Reflector client\n") | |
4348 | { | |
d62a17ae | 4349 | int idx_peer = 1; |
4350 | struct peer *peer; | |
718e3744 | 4351 | |
4352 | ||
d62a17ae | 4353 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4354 | if (!peer) | |
4355 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4356 | |
d62a17ae | 4357 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4358 | bgp_node_safi(vty), | |
4359 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4360 | } |
4361 | ||
d62a17ae | 4362 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
4363 | neighbor_route_reflector_client_hidden_cmd, | |
4364 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4365 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4366 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4367 | |
718e3744 | 4368 | DEFUN (no_neighbor_route_reflector_client, |
4369 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4370 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4371 | NO_STR |
4372 | NEIGHBOR_STR | |
4373 | NEIGHBOR_ADDR_STR2 | |
4374 | "Configure a neighbor as Route Reflector client\n") | |
4375 | { | |
d62a17ae | 4376 | int idx_peer = 2; |
4377 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4378 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4379 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4380 | } |
6b0655a2 | 4381 | |
d62a17ae | 4382 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
4383 | no_neighbor_route_reflector_client_hidden_cmd, | |
4384 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4385 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4386 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4387 | |
718e3744 | 4388 | /* neighbor route-server-client. */ |
4389 | DEFUN (neighbor_route_server_client, | |
4390 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4391 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4392 | NEIGHBOR_STR |
4393 | NEIGHBOR_ADDR_STR2 | |
4394 | "Configure a neighbor as Route Server client\n") | |
4395 | { | |
d62a17ae | 4396 | int idx_peer = 1; |
4397 | struct peer *peer; | |
2a3d5731 | 4398 | |
d62a17ae | 4399 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4400 | if (!peer) | |
4401 | return CMD_WARNING_CONFIG_FAILED; | |
4402 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4403 | bgp_node_safi(vty), | |
4404 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4405 | } |
4406 | ||
d62a17ae | 4407 | ALIAS_HIDDEN(neighbor_route_server_client, |
4408 | neighbor_route_server_client_hidden_cmd, | |
4409 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4410 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4411 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4412 | |
718e3744 | 4413 | DEFUN (no_neighbor_route_server_client, |
4414 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4415 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4416 | NO_STR |
4417 | NEIGHBOR_STR | |
4418 | NEIGHBOR_ADDR_STR2 | |
4419 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4420 | { |
d62a17ae | 4421 | int idx_peer = 2; |
4422 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4423 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4424 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4425 | } |
6b0655a2 | 4426 | |
d62a17ae | 4427 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
4428 | no_neighbor_route_server_client_hidden_cmd, | |
4429 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4430 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4431 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4432 | |
fee0f4c6 | 4433 | DEFUN (neighbor_nexthop_local_unchanged, |
4434 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4435 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4436 | NEIGHBOR_STR |
4437 | NEIGHBOR_ADDR_STR2 | |
4438 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4439 | "Leave link-local nexthop unchanged for this peer\n") | |
4440 | { | |
d62a17ae | 4441 | int idx_peer = 1; |
4442 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4443 | bgp_node_safi(vty), | |
4444 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 4445 | } |
6b0655a2 | 4446 | |
fee0f4c6 | 4447 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4448 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4449 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4450 | NO_STR |
4451 | NEIGHBOR_STR | |
4452 | NEIGHBOR_ADDR_STR2 | |
4453 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4454 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4455 | { |
d62a17ae | 4456 | int idx_peer = 2; |
4457 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4458 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4459 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 4460 | } |
6b0655a2 | 4461 | |
718e3744 | 4462 | DEFUN (neighbor_attr_unchanged, |
4463 | neighbor_attr_unchanged_cmd, | |
a8206004 | 4464 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 4465 | NEIGHBOR_STR |
4466 | NEIGHBOR_ADDR_STR2 | |
4467 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4468 | "As-path attribute\n" | |
4469 | "Nexthop attribute\n" | |
a8206004 | 4470 | "Med attribute\n") |
718e3744 | 4471 | { |
d62a17ae | 4472 | int idx = 0; |
8eeb0335 DW |
4473 | char *peer_str = argv[1]->arg; |
4474 | struct peer *peer; | |
d7c0a89a | 4475 | uint16_t flags = 0; |
8eeb0335 DW |
4476 | afi_t afi = bgp_node_afi(vty); |
4477 | safi_t safi = bgp_node_safi(vty); | |
4478 | ||
4479 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4480 | if (!peer) | |
4481 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4482 | |
4483 | if (argv_find(argv, argc, "as-path", &idx)) | |
4484 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4485 | idx = 0; | |
4486 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4487 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4488 | idx = 0; | |
4489 | if (argv_find(argv, argc, "med", &idx)) | |
4490 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4491 | ||
8eeb0335 DW |
4492 | /* no flags means all of them! */ |
4493 | if (!flags) { | |
d62a17ae | 4494 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
4495 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4496 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 4497 | } else { |
a4d82a8a PZ |
4498 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
4499 | && peer_af_flag_check(peer, afi, safi, | |
4500 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
4501 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4502 | PEER_FLAG_AS_PATH_UNCHANGED); | |
4503 | } | |
4504 | ||
a4d82a8a PZ |
4505 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
4506 | && peer_af_flag_check(peer, afi, safi, | |
4507 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
4508 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4509 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
4510 | } | |
4511 | ||
a4d82a8a PZ |
4512 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
4513 | && peer_af_flag_check(peer, afi, safi, | |
4514 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
4515 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4516 | PEER_FLAG_MED_UNCHANGED); | |
4517 | } | |
d62a17ae | 4518 | } |
4519 | ||
8eeb0335 | 4520 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 4521 | } |
4522 | ||
4523 | ALIAS_HIDDEN( | |
4524 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
4525 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4526 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4527 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4528 | "As-path attribute\n" | |
4529 | "Nexthop attribute\n" | |
4530 | "Med attribute\n") | |
596c17ba | 4531 | |
718e3744 | 4532 | DEFUN (no_neighbor_attr_unchanged, |
4533 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 4534 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 4535 | NO_STR |
718e3744 | 4536 | NEIGHBOR_STR |
4537 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4538 | "BGP attribute is propagated unchanged to this neighbor\n" |
4539 | "As-path attribute\n" | |
40e718b5 | 4540 | "Nexthop attribute\n" |
a8206004 | 4541 | "Med attribute\n") |
718e3744 | 4542 | { |
d62a17ae | 4543 | int idx = 0; |
4544 | char *peer = argv[2]->arg; | |
d7c0a89a | 4545 | uint16_t flags = 0; |
d62a17ae | 4546 | |
4547 | if (argv_find(argv, argc, "as-path", &idx)) | |
4548 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4549 | idx = 0; | |
4550 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4551 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4552 | idx = 0; | |
4553 | if (argv_find(argv, argc, "med", &idx)) | |
4554 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4555 | ||
4556 | if (!flags) // no flags means all of them! | |
4557 | { | |
4558 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4559 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4560 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4561 | } | |
4562 | ||
4563 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
4564 | bgp_node_safi(vty), flags); | |
4565 | } | |
4566 | ||
4567 | ALIAS_HIDDEN( | |
4568 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
4569 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4570 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4571 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4572 | "As-path attribute\n" | |
4573 | "Nexthop attribute\n" | |
4574 | "Med attribute\n") | |
718e3744 | 4575 | |
718e3744 | 4576 | /* EBGP multihop configuration. */ |
d62a17ae | 4577 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
4578 | const char *ttl_str) | |
718e3744 | 4579 | { |
d62a17ae | 4580 | struct peer *peer; |
4581 | unsigned int ttl; | |
718e3744 | 4582 | |
d62a17ae | 4583 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4584 | if (!peer) | |
4585 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4586 | |
d62a17ae | 4587 | if (peer->conf_if) |
4588 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 4589 | |
d62a17ae | 4590 | if (!ttl_str) |
4591 | ttl = MAXTTL; | |
4592 | else | |
4593 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 4594 | |
d62a17ae | 4595 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 4596 | } |
4597 | ||
d62a17ae | 4598 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4599 | { |
d62a17ae | 4600 | struct peer *peer; |
718e3744 | 4601 | |
d62a17ae | 4602 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4603 | if (!peer) | |
4604 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4605 | |
d62a17ae | 4606 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 4607 | } |
4608 | ||
4609 | /* neighbor ebgp-multihop. */ | |
4610 | DEFUN (neighbor_ebgp_multihop, | |
4611 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4612 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4613 | NEIGHBOR_STR |
4614 | NEIGHBOR_ADDR_STR2 | |
4615 | "Allow EBGP neighbors not on directly connected networks\n") | |
4616 | { | |
d62a17ae | 4617 | int idx_peer = 1; |
4618 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4619 | } |
4620 | ||
4621 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4622 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4623 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4624 | NEIGHBOR_STR |
4625 | NEIGHBOR_ADDR_STR2 | |
4626 | "Allow EBGP neighbors not on directly connected networks\n" | |
4627 | "maximum hop count\n") | |
4628 | { | |
d62a17ae | 4629 | int idx_peer = 1; |
4630 | int idx_number = 3; | |
4631 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
4632 | argv[idx_number]->arg); | |
718e3744 | 4633 | } |
4634 | ||
4635 | DEFUN (no_neighbor_ebgp_multihop, | |
4636 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4637 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4638 | NO_STR |
4639 | NEIGHBOR_STR | |
4640 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4641 | "Allow EBGP neighbors not on directly connected networks\n" |
4642 | "maximum hop count\n") | |
718e3744 | 4643 | { |
d62a17ae | 4644 | int idx_peer = 2; |
4645 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4646 | } |
4647 | ||
6b0655a2 | 4648 | |
6ffd2079 | 4649 | /* disable-connected-check */ |
4650 | DEFUN (neighbor_disable_connected_check, | |
4651 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 4652 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4653 | NEIGHBOR_STR |
7ebe625c | 4654 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4655 | "one-hop away EBGP peer using loopback address\n" |
4656 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4657 | { |
d62a17ae | 4658 | int idx_peer = 1; |
4659 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4660 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4661 | } |
4662 | ||
4663 | DEFUN (no_neighbor_disable_connected_check, | |
4664 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 4665 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4666 | NO_STR |
4667 | NEIGHBOR_STR | |
7ebe625c | 4668 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4669 | "one-hop away EBGP peer using loopback address\n" |
4670 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4671 | { |
d62a17ae | 4672 | int idx_peer = 2; |
4673 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4674 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4675 | } |
4676 | ||
47cbc09b PM |
4677 | |
4678 | /* enforce-first-as */ | |
4679 | DEFUN (neighbor_enforce_first_as, | |
4680 | neighbor_enforce_first_as_cmd, | |
4681 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4682 | NEIGHBOR_STR | |
4683 | NEIGHBOR_ADDR_STR2 | |
4684 | "Enforce the first AS for EBGP routes\n") | |
4685 | { | |
4686 | int idx_peer = 1; | |
4687 | ||
4688 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4689 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4690 | } | |
4691 | ||
4692 | DEFUN (no_neighbor_enforce_first_as, | |
4693 | no_neighbor_enforce_first_as_cmd, | |
4694 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4695 | NO_STR | |
4696 | NEIGHBOR_STR | |
4697 | NEIGHBOR_ADDR_STR2 | |
4698 | "Enforce the first AS for EBGP routes\n") | |
4699 | { | |
4700 | int idx_peer = 2; | |
4701 | ||
4702 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4703 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4704 | } | |
4705 | ||
4706 | ||
718e3744 | 4707 | DEFUN (neighbor_description, |
4708 | neighbor_description_cmd, | |
e961923c | 4709 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4710 | NEIGHBOR_STR |
4711 | NEIGHBOR_ADDR_STR2 | |
4712 | "Neighbor specific description\n" | |
4713 | "Up to 80 characters describing this neighbor\n") | |
4714 | { | |
d62a17ae | 4715 | int idx_peer = 1; |
4716 | int idx_line = 3; | |
4717 | struct peer *peer; | |
4718 | char *str; | |
718e3744 | 4719 | |
d62a17ae | 4720 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4721 | if (!peer) | |
4722 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4723 | |
d62a17ae | 4724 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4725 | |
d62a17ae | 4726 | peer_description_set(peer, str); |
718e3744 | 4727 | |
d62a17ae | 4728 | XFREE(MTYPE_TMP, str); |
718e3744 | 4729 | |
d62a17ae | 4730 | return CMD_SUCCESS; |
718e3744 | 4731 | } |
4732 | ||
4733 | DEFUN (no_neighbor_description, | |
4734 | no_neighbor_description_cmd, | |
a14810f4 | 4735 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 4736 | NO_STR |
4737 | NEIGHBOR_STR | |
4738 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 4739 | "Neighbor specific description\n") |
718e3744 | 4740 | { |
d62a17ae | 4741 | int idx_peer = 2; |
4742 | struct peer *peer; | |
718e3744 | 4743 | |
d62a17ae | 4744 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4745 | if (!peer) | |
4746 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4747 | |
d62a17ae | 4748 | peer_description_unset(peer); |
718e3744 | 4749 | |
d62a17ae | 4750 | return CMD_SUCCESS; |
718e3744 | 4751 | } |
4752 | ||
a14810f4 PM |
4753 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
4754 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
4755 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4756 | "Neighbor specific description\n" | |
4757 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 4758 | |
718e3744 | 4759 | /* Neighbor update-source. */ |
d62a17ae | 4760 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
4761 | const char *source_str) | |
4762 | { | |
4763 | struct peer *peer; | |
4764 | struct prefix p; | |
a14810f4 | 4765 | union sockunion su; |
d62a17ae | 4766 | |
4767 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4768 | if (!peer) | |
4769 | return CMD_WARNING_CONFIG_FAILED; | |
4770 | ||
4771 | if (peer->conf_if) | |
4772 | return CMD_WARNING; | |
4773 | ||
4774 | if (source_str) { | |
a14810f4 | 4775 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 4776 | peer_update_source_addr_set(peer, &su); |
4777 | else { | |
4778 | if (str2prefix(source_str, &p)) { | |
4779 | vty_out(vty, | |
4780 | "%% Invalid update-source, remove prefix length \n"); | |
4781 | return CMD_WARNING_CONFIG_FAILED; | |
4782 | } else | |
4783 | peer_update_source_if_set(peer, source_str); | |
4784 | } | |
4785 | } else | |
4786 | peer_update_source_unset(peer); | |
4787 | ||
4788 | return CMD_SUCCESS; | |
4789 | } | |
4790 | ||
4791 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
4792 | "IPv4 address\n" \ | |
4793 | "IPv6 address\n" \ | |
4794 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4795 | |
718e3744 | 4796 | DEFUN (neighbor_update_source, |
4797 | neighbor_update_source_cmd, | |
9ccf14f7 | 4798 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4799 | NEIGHBOR_STR |
4800 | NEIGHBOR_ADDR_STR2 | |
4801 | "Source of routing updates\n" | |
369688c0 | 4802 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4803 | { |
d62a17ae | 4804 | int idx_peer = 1; |
4805 | int idx_peer_2 = 3; | |
4806 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
4807 | argv[idx_peer_2]->arg); | |
718e3744 | 4808 | } |
4809 | ||
4810 | DEFUN (no_neighbor_update_source, | |
4811 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4812 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4813 | NO_STR |
4814 | NEIGHBOR_STR | |
4815 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4816 | "Source of routing updates\n" |
4817 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4818 | { |
d62a17ae | 4819 | int idx_peer = 2; |
4820 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4821 | } |
6b0655a2 | 4822 | |
d62a17ae | 4823 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
4824 | afi_t afi, safi_t safi, | |
4825 | const char *rmap, int set) | |
718e3744 | 4826 | { |
d62a17ae | 4827 | int ret; |
4828 | struct peer *peer; | |
80912664 | 4829 | struct route_map *route_map = NULL; |
718e3744 | 4830 | |
d62a17ae | 4831 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4832 | if (!peer) | |
4833 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4834 | |
1de27621 | 4835 | if (set) { |
80912664 DS |
4836 | if (rmap) |
4837 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
1de27621 DA |
4838 | ret = peer_default_originate_set(peer, afi, safi, |
4839 | rmap, route_map); | |
4840 | } else | |
d62a17ae | 4841 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 4842 | |
d62a17ae | 4843 | return bgp_vty_return(vty, ret); |
718e3744 | 4844 | } |
4845 | ||
4846 | /* neighbor default-originate. */ | |
4847 | DEFUN (neighbor_default_originate, | |
4848 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4849 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4850 | NEIGHBOR_STR |
4851 | NEIGHBOR_ADDR_STR2 | |
4852 | "Originate default route to this neighbor\n") | |
4853 | { | |
d62a17ae | 4854 | int idx_peer = 1; |
4855 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4856 | bgp_node_afi(vty), | |
4857 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 4858 | } |
4859 | ||
d62a17ae | 4860 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
4861 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
4862 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4863 | "Originate default route to this neighbor\n") | |
596c17ba | 4864 | |
718e3744 | 4865 | DEFUN (neighbor_default_originate_rmap, |
4866 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4867 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4868 | NEIGHBOR_STR |
4869 | NEIGHBOR_ADDR_STR2 | |
4870 | "Originate default route to this neighbor\n" | |
4871 | "Route-map to specify criteria to originate default\n" | |
4872 | "route-map name\n") | |
4873 | { | |
d62a17ae | 4874 | int idx_peer = 1; |
4875 | int idx_word = 4; | |
4876 | return peer_default_originate_set_vty( | |
4877 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4878 | argv[idx_word]->arg, 1); | |
718e3744 | 4879 | } |
4880 | ||
d62a17ae | 4881 | ALIAS_HIDDEN( |
4882 | neighbor_default_originate_rmap, | |
4883 | neighbor_default_originate_rmap_hidden_cmd, | |
4884 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
4885 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4886 | "Originate default route to this neighbor\n" | |
4887 | "Route-map to specify criteria to originate default\n" | |
4888 | "route-map name\n") | |
596c17ba | 4889 | |
718e3744 | 4890 | DEFUN (no_neighbor_default_originate, |
4891 | no_neighbor_default_originate_cmd, | |
a636c635 | 4892 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4893 | NO_STR |
4894 | NEIGHBOR_STR | |
4895 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4896 | "Originate default route to this neighbor\n" |
4897 | "Route-map to specify criteria to originate default\n" | |
4898 | "route-map name\n") | |
718e3744 | 4899 | { |
d62a17ae | 4900 | int idx_peer = 2; |
4901 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4902 | bgp_node_afi(vty), | |
4903 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 4904 | } |
4905 | ||
d62a17ae | 4906 | ALIAS_HIDDEN( |
4907 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
4908 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
4909 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4910 | "Originate default route to this neighbor\n" | |
4911 | "Route-map to specify criteria to originate default\n" | |
4912 | "route-map name\n") | |
596c17ba | 4913 | |
6b0655a2 | 4914 | |
718e3744 | 4915 | /* Set neighbor's BGP port. */ |
d62a17ae | 4916 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
4917 | const char *port_str) | |
4918 | { | |
4919 | struct peer *peer; | |
d7c0a89a | 4920 | uint16_t port; |
d62a17ae | 4921 | struct servent *sp; |
4922 | ||
4923 | peer = peer_lookup_vty(vty, ip_str); | |
4924 | if (!peer) | |
4925 | return CMD_WARNING_CONFIG_FAILED; | |
4926 | ||
4927 | if (!port_str) { | |
4928 | sp = getservbyname("bgp", "tcp"); | |
4929 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
4930 | } else { | |
4931 | port = strtoul(port_str, NULL, 10); | |
4932 | } | |
718e3744 | 4933 | |
d62a17ae | 4934 | peer_port_set(peer, port); |
718e3744 | 4935 | |
d62a17ae | 4936 | return CMD_SUCCESS; |
718e3744 | 4937 | } |
4938 | ||
f418446b | 4939 | /* Set specified peer's BGP port. */ |
718e3744 | 4940 | DEFUN (neighbor_port, |
4941 | neighbor_port_cmd, | |
9ccf14f7 | 4942 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4943 | NEIGHBOR_STR |
4944 | NEIGHBOR_ADDR_STR | |
4945 | "Neighbor's BGP port\n" | |
4946 | "TCP port number\n") | |
4947 | { | |
d62a17ae | 4948 | int idx_ip = 1; |
4949 | int idx_number = 3; | |
4950 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
4951 | argv[idx_number]->arg); | |
718e3744 | 4952 | } |
4953 | ||
4954 | DEFUN (no_neighbor_port, | |
4955 | no_neighbor_port_cmd, | |
9ccf14f7 | 4956 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4957 | NO_STR |
4958 | NEIGHBOR_STR | |
4959 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4960 | "Neighbor's BGP port\n" |
4961 | "TCP port number\n") | |
718e3744 | 4962 | { |
d62a17ae | 4963 | int idx_ip = 2; |
4964 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4965 | } |
4966 | ||
6b0655a2 | 4967 | |
718e3744 | 4968 | /* neighbor weight. */ |
d62a17ae | 4969 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4970 | safi_t safi, const char *weight_str) | |
718e3744 | 4971 | { |
d62a17ae | 4972 | int ret; |
4973 | struct peer *peer; | |
4974 | unsigned long weight; | |
718e3744 | 4975 | |
d62a17ae | 4976 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4977 | if (!peer) | |
4978 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4979 | |
d62a17ae | 4980 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 4981 | |
d62a17ae | 4982 | ret = peer_weight_set(peer, afi, safi, weight); |
4983 | return bgp_vty_return(vty, ret); | |
718e3744 | 4984 | } |
4985 | ||
d62a17ae | 4986 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4987 | safi_t safi) | |
718e3744 | 4988 | { |
d62a17ae | 4989 | int ret; |
4990 | struct peer *peer; | |
718e3744 | 4991 | |
d62a17ae | 4992 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4993 | if (!peer) | |
4994 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4995 | |
d62a17ae | 4996 | ret = peer_weight_unset(peer, afi, safi); |
4997 | return bgp_vty_return(vty, ret); | |
718e3744 | 4998 | } |
4999 | ||
5000 | DEFUN (neighbor_weight, | |
5001 | neighbor_weight_cmd, | |
9ccf14f7 | 5002 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 5003 | NEIGHBOR_STR |
5004 | NEIGHBOR_ADDR_STR2 | |
5005 | "Set default weight for routes from this neighbor\n" | |
5006 | "default weight\n") | |
5007 | { | |
d62a17ae | 5008 | int idx_peer = 1; |
5009 | int idx_number = 3; | |
5010 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5011 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 5012 | } |
5013 | ||
d62a17ae | 5014 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
5015 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
5016 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5017 | "Set default weight for routes from this neighbor\n" | |
5018 | "default weight\n") | |
596c17ba | 5019 | |
718e3744 | 5020 | DEFUN (no_neighbor_weight, |
5021 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5022 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5023 | NO_STR |
5024 | NEIGHBOR_STR | |
5025 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5026 | "Set default weight for routes from this neighbor\n" |
5027 | "default weight\n") | |
718e3744 | 5028 | { |
d62a17ae | 5029 | int idx_peer = 2; |
5030 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
5031 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 5032 | } |
5033 | ||
d62a17ae | 5034 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
5035 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5036 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5037 | "Set default weight for routes from this neighbor\n" | |
5038 | "default weight\n") | |
596c17ba | 5039 | |
6b0655a2 | 5040 | |
718e3744 | 5041 | /* Override capability negotiation. */ |
5042 | DEFUN (neighbor_override_capability, | |
5043 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5044 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5045 | NEIGHBOR_STR |
5046 | NEIGHBOR_ADDR_STR2 | |
5047 | "Override capability negotiation result\n") | |
5048 | { | |
d62a17ae | 5049 | int idx_peer = 1; |
5050 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5051 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5052 | } |
5053 | ||
5054 | DEFUN (no_neighbor_override_capability, | |
5055 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5056 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5057 | NO_STR |
5058 | NEIGHBOR_STR | |
5059 | NEIGHBOR_ADDR_STR2 | |
5060 | "Override capability negotiation result\n") | |
5061 | { | |
d62a17ae | 5062 | int idx_peer = 2; |
5063 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5064 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5065 | } |
6b0655a2 | 5066 | |
718e3744 | 5067 | DEFUN (neighbor_strict_capability, |
5068 | neighbor_strict_capability_cmd, | |
9fb964de | 5069 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5070 | NEIGHBOR_STR |
9fb964de | 5071 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5072 | "Strict capability negotiation match\n") |
5073 | { | |
9fb964de PM |
5074 | int idx_peer = 1; |
5075 | ||
5076 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5077 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5078 | } |
5079 | ||
5080 | DEFUN (no_neighbor_strict_capability, | |
5081 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5082 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5083 | NO_STR |
5084 | NEIGHBOR_STR | |
9fb964de | 5085 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5086 | "Strict capability negotiation match\n") |
5087 | { | |
9fb964de PM |
5088 | int idx_peer = 2; |
5089 | ||
5090 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5091 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5092 | } |
6b0655a2 | 5093 | |
d62a17ae | 5094 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5095 | const char *keep_str, const char *hold_str) | |
718e3744 | 5096 | { |
d62a17ae | 5097 | int ret; |
5098 | struct peer *peer; | |
d7c0a89a QY |
5099 | uint32_t keepalive; |
5100 | uint32_t holdtime; | |
718e3744 | 5101 | |
d62a17ae | 5102 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5103 | if (!peer) | |
5104 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5105 | |
d62a17ae | 5106 | keepalive = strtoul(keep_str, NULL, 10); |
5107 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5108 | |
d62a17ae | 5109 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5110 | |
d62a17ae | 5111 | return bgp_vty_return(vty, ret); |
718e3744 | 5112 | } |
6b0655a2 | 5113 | |
d62a17ae | 5114 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5115 | { |
d62a17ae | 5116 | int ret; |
5117 | struct peer *peer; | |
718e3744 | 5118 | |
d62a17ae | 5119 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5120 | if (!peer) | |
5121 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5122 | |
d62a17ae | 5123 | ret = peer_timers_unset(peer); |
718e3744 | 5124 | |
d62a17ae | 5125 | return bgp_vty_return(vty, ret); |
718e3744 | 5126 | } |
5127 | ||
5128 | DEFUN (neighbor_timers, | |
5129 | neighbor_timers_cmd, | |
9ccf14f7 | 5130 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5131 | NEIGHBOR_STR |
5132 | NEIGHBOR_ADDR_STR2 | |
5133 | "BGP per neighbor timers\n" | |
5134 | "Keepalive interval\n" | |
5135 | "Holdtime\n") | |
5136 | { | |
d62a17ae | 5137 | int idx_peer = 1; |
5138 | int idx_number = 3; | |
5139 | int idx_number_2 = 4; | |
5140 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5141 | argv[idx_number]->arg, | |
5142 | argv[idx_number_2]->arg); | |
718e3744 | 5143 | } |
5144 | ||
5145 | DEFUN (no_neighbor_timers, | |
5146 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5147 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5148 | NO_STR |
5149 | NEIGHBOR_STR | |
5150 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5151 | "BGP per neighbor timers\n" |
5152 | "Keepalive interval\n" | |
5153 | "Holdtime\n") | |
718e3744 | 5154 | { |
d62a17ae | 5155 | int idx_peer = 2; |
5156 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5157 | } |
6b0655a2 | 5158 | |
813d4307 | 5159 | |
d62a17ae | 5160 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
5161 | const char *time_str) | |
718e3744 | 5162 | { |
d62a17ae | 5163 | int ret; |
5164 | struct peer *peer; | |
d7c0a89a | 5165 | uint32_t connect; |
718e3744 | 5166 | |
d62a17ae | 5167 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5168 | if (!peer) | |
5169 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5170 | |
d62a17ae | 5171 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5172 | |
d62a17ae | 5173 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5174 | |
d62a17ae | 5175 | return bgp_vty_return(vty, ret); |
718e3744 | 5176 | } |
5177 | ||
d62a17ae | 5178 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5179 | { |
d62a17ae | 5180 | int ret; |
5181 | struct peer *peer; | |
718e3744 | 5182 | |
d62a17ae | 5183 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5184 | if (!peer) | |
5185 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5186 | |
d62a17ae | 5187 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5188 | |
d62a17ae | 5189 | return bgp_vty_return(vty, ret); |
718e3744 | 5190 | } |
5191 | ||
5192 | DEFUN (neighbor_timers_connect, | |
5193 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5194 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5195 | NEIGHBOR_STR |
966f821c | 5196 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5197 | "BGP per neighbor timers\n" |
5198 | "BGP connect timer\n" | |
5199 | "Connect timer\n") | |
5200 | { | |
d62a17ae | 5201 | int idx_peer = 1; |
5202 | int idx_number = 4; | |
5203 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5204 | argv[idx_number]->arg); | |
718e3744 | 5205 | } |
5206 | ||
5207 | DEFUN (no_neighbor_timers_connect, | |
5208 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5209 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5210 | NO_STR |
5211 | NEIGHBOR_STR | |
966f821c | 5212 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5213 | "BGP per neighbor timers\n" |
8334fd5a DW |
5214 | "BGP connect timer\n" |
5215 | "Connect timer\n") | |
718e3744 | 5216 | { |
d62a17ae | 5217 | int idx_peer = 2; |
5218 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5219 | } |
5220 | ||
6b0655a2 | 5221 | |
d62a17ae | 5222 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5223 | const char *time_str, int set) | |
718e3744 | 5224 | { |
d62a17ae | 5225 | int ret; |
5226 | struct peer *peer; | |
d7c0a89a | 5227 | uint32_t routeadv = 0; |
718e3744 | 5228 | |
d62a17ae | 5229 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5230 | if (!peer) | |
5231 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5232 | |
d62a17ae | 5233 | if (time_str) |
5234 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5235 | |
d62a17ae | 5236 | if (set) |
5237 | ret = peer_advertise_interval_set(peer, routeadv); | |
5238 | else | |
5239 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5240 | |
d62a17ae | 5241 | return bgp_vty_return(vty, ret); |
718e3744 | 5242 | } |
5243 | ||
5244 | DEFUN (neighbor_advertise_interval, | |
5245 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5246 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5247 | NEIGHBOR_STR |
966f821c | 5248 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5249 | "Minimum interval between sending BGP routing updates\n" |
5250 | "time in seconds\n") | |
5251 | { | |
d62a17ae | 5252 | int idx_peer = 1; |
5253 | int idx_number = 3; | |
5254 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5255 | argv[idx_number]->arg, 1); | |
718e3744 | 5256 | } |
5257 | ||
5258 | DEFUN (no_neighbor_advertise_interval, | |
5259 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5260 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5261 | NO_STR |
5262 | NEIGHBOR_STR | |
966f821c | 5263 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5264 | "Minimum interval between sending BGP routing updates\n" |
5265 | "time in seconds\n") | |
718e3744 | 5266 | { |
d62a17ae | 5267 | int idx_peer = 2; |
5268 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5269 | } |
5270 | ||
6b0655a2 | 5271 | |
518f0eb1 DS |
5272 | /* Time to wait before processing route-map updates */ |
5273 | DEFUN (bgp_set_route_map_delay_timer, | |
5274 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5275 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5276 | SET_STR |
5277 | "BGP route-map delay timer\n" | |
5278 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5279 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5280 | { |
d62a17ae | 5281 | int idx_number = 3; |
d7c0a89a | 5282 | uint32_t rmap_delay_timer; |
d62a17ae | 5283 | |
5284 | if (argv[idx_number]->arg) { | |
5285 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
5286 | bm->rmap_update_timer = rmap_delay_timer; | |
5287 | ||
5288 | /* if the dynamic update handling is being disabled, and a timer | |
5289 | * is | |
5290 | * running, stop the timer and act as if the timer has already | |
5291 | * fired. | |
5292 | */ | |
5293 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
5294 | BGP_TIMER_OFF(bm->t_rmap_update); | |
5295 | thread_execute(bm->master, bgp_route_map_update_timer, | |
5296 | NULL, 0); | |
5297 | } | |
5298 | return CMD_SUCCESS; | |
5299 | } else { | |
5300 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5301 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5302 | } |
518f0eb1 DS |
5303 | } |
5304 | ||
5305 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5306 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5307 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5308 | NO_STR |
3a2d747c | 5309 | BGP_STR |
518f0eb1 | 5310 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5311 | "Reset to default time to wait for processing route-map changes\n" |
5312 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5313 | { |
518f0eb1 | 5314 | |
d62a17ae | 5315 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 5316 | |
d62a17ae | 5317 | return CMD_SUCCESS; |
518f0eb1 DS |
5318 | } |
5319 | ||
f414725f | 5320 | |
718e3744 | 5321 | /* neighbor interface */ |
d62a17ae | 5322 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
5323 | const char *str) | |
718e3744 | 5324 | { |
d62a17ae | 5325 | struct peer *peer; |
718e3744 | 5326 | |
d62a17ae | 5327 | peer = peer_lookup_vty(vty, ip_str); |
5328 | if (!peer || peer->conf_if) { | |
5329 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
5330 | return CMD_WARNING_CONFIG_FAILED; | |
5331 | } | |
718e3744 | 5332 | |
d62a17ae | 5333 | if (str) |
5334 | peer_interface_set(peer, str); | |
5335 | else | |
5336 | peer_interface_unset(peer); | |
718e3744 | 5337 | |
d62a17ae | 5338 | return CMD_SUCCESS; |
718e3744 | 5339 | } |
5340 | ||
5341 | DEFUN (neighbor_interface, | |
5342 | neighbor_interface_cmd, | |
9ccf14f7 | 5343 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5344 | NEIGHBOR_STR |
5345 | NEIGHBOR_ADDR_STR | |
5346 | "Interface\n" | |
5347 | "Interface name\n") | |
5348 | { | |
d62a17ae | 5349 | int idx_ip = 1; |
5350 | int idx_word = 3; | |
5351 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 5352 | } |
5353 | ||
5354 | DEFUN (no_neighbor_interface, | |
5355 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5356 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5357 | NO_STR |
5358 | NEIGHBOR_STR | |
16cedbb0 | 5359 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5360 | "Interface\n" |
5361 | "Interface name\n") | |
5362 | { | |
d62a17ae | 5363 | int idx_peer = 2; |
5364 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5365 | } |
6b0655a2 | 5366 | |
718e3744 | 5367 | DEFUN (neighbor_distribute_list, |
5368 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5369 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5370 | NEIGHBOR_STR |
5371 | NEIGHBOR_ADDR_STR2 | |
5372 | "Filter updates to/from this neighbor\n" | |
5373 | "IP access-list number\n" | |
5374 | "IP access-list number (expanded range)\n" | |
5375 | "IP Access-list name\n" | |
5376 | "Filter incoming updates\n" | |
5377 | "Filter outgoing updates\n") | |
5378 | { | |
d62a17ae | 5379 | int idx_peer = 1; |
5380 | int idx_acl = 3; | |
5381 | int direct, ret; | |
5382 | struct peer *peer; | |
a8206004 | 5383 | |
d62a17ae | 5384 | const char *pstr = argv[idx_peer]->arg; |
5385 | const char *acl = argv[idx_acl]->arg; | |
5386 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5387 | |
d62a17ae | 5388 | peer = peer_and_group_lookup_vty(vty, pstr); |
5389 | if (!peer) | |
5390 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5391 | |
d62a17ae | 5392 | /* Check filter direction. */ |
5393 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5394 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5395 | direct, acl); | |
a8206004 | 5396 | |
d62a17ae | 5397 | return bgp_vty_return(vty, ret); |
718e3744 | 5398 | } |
5399 | ||
d62a17ae | 5400 | ALIAS_HIDDEN( |
5401 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
5402 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5403 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5404 | "Filter updates to/from this neighbor\n" | |
5405 | "IP access-list number\n" | |
5406 | "IP access-list number (expanded range)\n" | |
5407 | "IP Access-list name\n" | |
5408 | "Filter incoming updates\n" | |
5409 | "Filter outgoing updates\n") | |
596c17ba | 5410 | |
718e3744 | 5411 | DEFUN (no_neighbor_distribute_list, |
5412 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5413 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5414 | NO_STR |
5415 | NEIGHBOR_STR | |
5416 | NEIGHBOR_ADDR_STR2 | |
5417 | "Filter updates to/from this neighbor\n" | |
5418 | "IP access-list number\n" | |
5419 | "IP access-list number (expanded range)\n" | |
5420 | "IP Access-list name\n" | |
5421 | "Filter incoming updates\n" | |
5422 | "Filter outgoing updates\n") | |
5423 | { | |
d62a17ae | 5424 | int idx_peer = 2; |
5425 | int direct, ret; | |
5426 | struct peer *peer; | |
a8206004 | 5427 | |
d62a17ae | 5428 | const char *pstr = argv[idx_peer]->arg; |
5429 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5430 | |
d62a17ae | 5431 | peer = peer_and_group_lookup_vty(vty, pstr); |
5432 | if (!peer) | |
5433 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5434 | |
d62a17ae | 5435 | /* Check filter direction. */ |
5436 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5437 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5438 | direct); | |
a8206004 | 5439 | |
d62a17ae | 5440 | return bgp_vty_return(vty, ret); |
718e3744 | 5441 | } |
6b0655a2 | 5442 | |
d62a17ae | 5443 | ALIAS_HIDDEN( |
5444 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
5445 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5446 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5447 | "Filter updates to/from this neighbor\n" | |
5448 | "IP access-list number\n" | |
5449 | "IP access-list number (expanded range)\n" | |
5450 | "IP Access-list name\n" | |
5451 | "Filter incoming updates\n" | |
5452 | "Filter outgoing updates\n") | |
596c17ba | 5453 | |
718e3744 | 5454 | /* Set prefix list to the peer. */ |
d62a17ae | 5455 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
5456 | afi_t afi, safi_t safi, | |
5457 | const char *name_str, | |
5458 | const char *direct_str) | |
718e3744 | 5459 | { |
d62a17ae | 5460 | int ret; |
d62a17ae | 5461 | int direct = FILTER_IN; |
cf9ac8bf | 5462 | struct peer *peer; |
718e3744 | 5463 | |
d62a17ae | 5464 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5465 | if (!peer) | |
5466 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5467 | |
d62a17ae | 5468 | /* Check filter direction. */ |
5469 | if (strncmp(direct_str, "i", 1) == 0) | |
5470 | direct = FILTER_IN; | |
5471 | else if (strncmp(direct_str, "o", 1) == 0) | |
5472 | direct = FILTER_OUT; | |
718e3744 | 5473 | |
d62a17ae | 5474 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 5475 | |
d62a17ae | 5476 | return bgp_vty_return(vty, ret); |
718e3744 | 5477 | } |
5478 | ||
d62a17ae | 5479 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
5480 | afi_t afi, safi_t safi, | |
5481 | const char *direct_str) | |
718e3744 | 5482 | { |
d62a17ae | 5483 | int ret; |
5484 | struct peer *peer; | |
5485 | int direct = FILTER_IN; | |
718e3744 | 5486 | |
d62a17ae | 5487 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5488 | if (!peer) | |
5489 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 5490 | |
d62a17ae | 5491 | /* Check filter direction. */ |
5492 | if (strncmp(direct_str, "i", 1) == 0) | |
5493 | direct = FILTER_IN; | |
5494 | else if (strncmp(direct_str, "o", 1) == 0) | |
5495 | direct = FILTER_OUT; | |
718e3744 | 5496 | |
d62a17ae | 5497 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 5498 | |
d62a17ae | 5499 | return bgp_vty_return(vty, ret); |
718e3744 | 5500 | } |
5501 | ||
5502 | DEFUN (neighbor_prefix_list, | |
5503 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5504 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5505 | NEIGHBOR_STR |
5506 | NEIGHBOR_ADDR_STR2 | |
5507 | "Filter updates to/from this neighbor\n" | |
5508 | "Name of a prefix list\n" | |
5509 | "Filter incoming updates\n" | |
5510 | "Filter outgoing updates\n") | |
5511 | { | |
d62a17ae | 5512 | int idx_peer = 1; |
5513 | int idx_word = 3; | |
5514 | int idx_in_out = 4; | |
5515 | return peer_prefix_list_set_vty( | |
5516 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5517 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5518 | } |
5519 | ||
d62a17ae | 5520 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
5521 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5522 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5523 | "Filter updates to/from this neighbor\n" | |
5524 | "Name of a prefix list\n" | |
5525 | "Filter incoming updates\n" | |
5526 | "Filter outgoing updates\n") | |
596c17ba | 5527 | |
718e3744 | 5528 | DEFUN (no_neighbor_prefix_list, |
5529 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5530 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5531 | NO_STR |
5532 | NEIGHBOR_STR | |
5533 | NEIGHBOR_ADDR_STR2 | |
5534 | "Filter updates to/from this neighbor\n" | |
5535 | "Name of a prefix list\n" | |
5536 | "Filter incoming updates\n" | |
5537 | "Filter outgoing updates\n") | |
5538 | { | |
d62a17ae | 5539 | int idx_peer = 2; |
5540 | int idx_in_out = 5; | |
5541 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
5542 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5543 | argv[idx_in_out]->arg); | |
718e3744 | 5544 | } |
6b0655a2 | 5545 | |
d62a17ae | 5546 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
5547 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5548 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5549 | "Filter updates to/from this neighbor\n" | |
5550 | "Name of a prefix list\n" | |
5551 | "Filter incoming updates\n" | |
5552 | "Filter outgoing updates\n") | |
596c17ba | 5553 | |
d62a17ae | 5554 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5555 | safi_t safi, const char *name_str, | |
5556 | const char *direct_str) | |
718e3744 | 5557 | { |
d62a17ae | 5558 | int ret; |
5559 | struct peer *peer; | |
5560 | int direct = FILTER_IN; | |
718e3744 | 5561 | |
d62a17ae | 5562 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5563 | if (!peer) | |
5564 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5565 | |
d62a17ae | 5566 | /* Check filter direction. */ |
5567 | if (strncmp(direct_str, "i", 1) == 0) | |
5568 | direct = FILTER_IN; | |
5569 | else if (strncmp(direct_str, "o", 1) == 0) | |
5570 | direct = FILTER_OUT; | |
718e3744 | 5571 | |
d62a17ae | 5572 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 5573 | |
d62a17ae | 5574 | return bgp_vty_return(vty, ret); |
718e3744 | 5575 | } |
5576 | ||
d62a17ae | 5577 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5578 | safi_t safi, const char *direct_str) | |
718e3744 | 5579 | { |
d62a17ae | 5580 | int ret; |
5581 | struct peer *peer; | |
5582 | int direct = FILTER_IN; | |
718e3744 | 5583 | |
d62a17ae | 5584 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5585 | if (!peer) | |
5586 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5587 | |
d62a17ae | 5588 | /* Check filter direction. */ |
5589 | if (strncmp(direct_str, "i", 1) == 0) | |
5590 | direct = FILTER_IN; | |
5591 | else if (strncmp(direct_str, "o", 1) == 0) | |
5592 | direct = FILTER_OUT; | |
718e3744 | 5593 | |
d62a17ae | 5594 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 5595 | |
d62a17ae | 5596 | return bgp_vty_return(vty, ret); |
718e3744 | 5597 | } |
5598 | ||
5599 | DEFUN (neighbor_filter_list, | |
5600 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5601 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5602 | NEIGHBOR_STR |
5603 | NEIGHBOR_ADDR_STR2 | |
5604 | "Establish BGP filters\n" | |
5605 | "AS path access-list name\n" | |
5606 | "Filter incoming routes\n" | |
5607 | "Filter outgoing routes\n") | |
5608 | { | |
d62a17ae | 5609 | int idx_peer = 1; |
5610 | int idx_word = 3; | |
5611 | int idx_in_out = 4; | |
5612 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5613 | bgp_node_safi(vty), argv[idx_word]->arg, | |
5614 | argv[idx_in_out]->arg); | |
718e3744 | 5615 | } |
5616 | ||
d62a17ae | 5617 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
5618 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5619 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5620 | "Establish BGP filters\n" | |
5621 | "AS path access-list name\n" | |
5622 | "Filter incoming routes\n" | |
5623 | "Filter outgoing routes\n") | |
596c17ba | 5624 | |
718e3744 | 5625 | DEFUN (no_neighbor_filter_list, |
5626 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5627 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5628 | NO_STR |
5629 | NEIGHBOR_STR | |
5630 | NEIGHBOR_ADDR_STR2 | |
5631 | "Establish BGP filters\n" | |
5632 | "AS path access-list name\n" | |
5633 | "Filter incoming routes\n" | |
5634 | "Filter outgoing routes\n") | |
5635 | { | |
d62a17ae | 5636 | int idx_peer = 2; |
5637 | int idx_in_out = 5; | |
5638 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
5639 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5640 | argv[idx_in_out]->arg); | |
718e3744 | 5641 | } |
6b0655a2 | 5642 | |
d62a17ae | 5643 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
5644 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5645 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5646 | "Establish BGP filters\n" | |
5647 | "AS path access-list name\n" | |
5648 | "Filter incoming routes\n" | |
5649 | "Filter outgoing routes\n") | |
596c17ba | 5650 | |
718e3744 | 5651 | /* Set route-map to the peer. */ |
d62a17ae | 5652 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
5653 | afi_t afi, safi_t safi, const char *name_str, | |
5654 | const char *direct_str) | |
718e3744 | 5655 | { |
d62a17ae | 5656 | int ret; |
5657 | struct peer *peer; | |
5658 | int direct = RMAP_IN; | |
1de27621 | 5659 | struct route_map *route_map; |
718e3744 | 5660 | |
d62a17ae | 5661 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5662 | if (!peer) | |
5663 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5664 | |
d62a17ae | 5665 | /* Check filter direction. */ |
5666 | if (strncmp(direct_str, "in", 2) == 0) | |
5667 | direct = RMAP_IN; | |
5668 | else if (strncmp(direct_str, "o", 1) == 0) | |
5669 | direct = RMAP_OUT; | |
718e3744 | 5670 | |
1de27621 DA |
5671 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
5672 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 5673 | |
d62a17ae | 5674 | return bgp_vty_return(vty, ret); |
718e3744 | 5675 | } |
5676 | ||
d62a17ae | 5677 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
5678 | afi_t afi, safi_t safi, | |
5679 | const char *direct_str) | |
718e3744 | 5680 | { |
d62a17ae | 5681 | int ret; |
5682 | struct peer *peer; | |
5683 | int direct = RMAP_IN; | |
718e3744 | 5684 | |
d62a17ae | 5685 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5686 | if (!peer) | |
5687 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5688 | |
d62a17ae | 5689 | /* Check filter direction. */ |
5690 | if (strncmp(direct_str, "in", 2) == 0) | |
5691 | direct = RMAP_IN; | |
5692 | else if (strncmp(direct_str, "o", 1) == 0) | |
5693 | direct = RMAP_OUT; | |
718e3744 | 5694 | |
d62a17ae | 5695 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 5696 | |
d62a17ae | 5697 | return bgp_vty_return(vty, ret); |
718e3744 | 5698 | } |
5699 | ||
5700 | DEFUN (neighbor_route_map, | |
5701 | neighbor_route_map_cmd, | |
9ccf14f7 | 5702 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5703 | NEIGHBOR_STR |
5704 | NEIGHBOR_ADDR_STR2 | |
5705 | "Apply route map to neighbor\n" | |
5706 | "Name of route map\n" | |
5707 | "Apply map to incoming routes\n" | |
2a3d5731 | 5708 | "Apply map to outbound routes\n") |
718e3744 | 5709 | { |
d62a17ae | 5710 | int idx_peer = 1; |
5711 | int idx_word = 3; | |
5712 | int idx_in_out = 4; | |
5713 | return peer_route_map_set_vty( | |
5714 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5715 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5716 | } |
5717 | ||
d62a17ae | 5718 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
5719 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5720 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5721 | "Apply route map to neighbor\n" | |
5722 | "Name of route map\n" | |
5723 | "Apply map to incoming routes\n" | |
5724 | "Apply map to outbound routes\n") | |
596c17ba | 5725 | |
718e3744 | 5726 | DEFUN (no_neighbor_route_map, |
5727 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5728 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5729 | NO_STR |
5730 | NEIGHBOR_STR | |
5731 | NEIGHBOR_ADDR_STR2 | |
5732 | "Apply route map to neighbor\n" | |
5733 | "Name of route map\n" | |
5734 | "Apply map to incoming routes\n" | |
2a3d5731 | 5735 | "Apply map to outbound routes\n") |
718e3744 | 5736 | { |
d62a17ae | 5737 | int idx_peer = 2; |
5738 | int idx_in_out = 5; | |
5739 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
5740 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5741 | argv[idx_in_out]->arg); | |
718e3744 | 5742 | } |
6b0655a2 | 5743 | |
d62a17ae | 5744 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
5745 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5746 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5747 | "Apply route map to neighbor\n" | |
5748 | "Name of route map\n" | |
5749 | "Apply map to incoming routes\n" | |
5750 | "Apply map to outbound routes\n") | |
596c17ba | 5751 | |
718e3744 | 5752 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 5753 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
5754 | afi_t afi, safi_t safi, | |
5755 | const char *name_str) | |
718e3744 | 5756 | { |
d62a17ae | 5757 | int ret; |
5758 | struct peer *peer; | |
1de27621 | 5759 | struct route_map *route_map; |
718e3744 | 5760 | |
d62a17ae | 5761 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5762 | if (!peer) | |
5763 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5764 | |
1de27621 DA |
5765 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
5766 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 5767 | |
d62a17ae | 5768 | return bgp_vty_return(vty, ret); |
718e3744 | 5769 | } |
5770 | ||
5771 | /* Unset route-map from the peer. */ | |
d62a17ae | 5772 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
5773 | afi_t afi, safi_t safi) | |
718e3744 | 5774 | { |
d62a17ae | 5775 | int ret; |
5776 | struct peer *peer; | |
718e3744 | 5777 | |
d62a17ae | 5778 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5779 | if (!peer) | |
5780 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5781 | |
d62a17ae | 5782 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 5783 | |
d62a17ae | 5784 | return bgp_vty_return(vty, ret); |
718e3744 | 5785 | } |
5786 | ||
5787 | DEFUN (neighbor_unsuppress_map, | |
5788 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5789 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5790 | NEIGHBOR_STR |
5791 | NEIGHBOR_ADDR_STR2 | |
5792 | "Route-map to selectively unsuppress suppressed routes\n" | |
5793 | "Name of route map\n") | |
5794 | { | |
d62a17ae | 5795 | int idx_peer = 1; |
5796 | int idx_word = 3; | |
5797 | return peer_unsuppress_map_set_vty( | |
5798 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5799 | argv[idx_word]->arg); | |
718e3744 | 5800 | } |
5801 | ||
d62a17ae | 5802 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
5803 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5804 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5805 | "Route-map to selectively unsuppress suppressed routes\n" | |
5806 | "Name of route map\n") | |
596c17ba | 5807 | |
718e3744 | 5808 | DEFUN (no_neighbor_unsuppress_map, |
5809 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5810 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5811 | NO_STR |
5812 | NEIGHBOR_STR | |
5813 | NEIGHBOR_ADDR_STR2 | |
5814 | "Route-map to selectively unsuppress suppressed routes\n" | |
5815 | "Name of route map\n") | |
5816 | { | |
d62a17ae | 5817 | int idx_peer = 2; |
5818 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
5819 | bgp_node_afi(vty), | |
5820 | bgp_node_safi(vty)); | |
718e3744 | 5821 | } |
6b0655a2 | 5822 | |
d62a17ae | 5823 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
5824 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5825 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5826 | "Route-map to selectively unsuppress suppressed routes\n" | |
5827 | "Name of route map\n") | |
596c17ba | 5828 | |
d62a17ae | 5829 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
5830 | afi_t afi, safi_t safi, | |
5831 | const char *num_str, | |
5832 | const char *threshold_str, int warning, | |
5833 | const char *restart_str) | |
718e3744 | 5834 | { |
d62a17ae | 5835 | int ret; |
5836 | struct peer *peer; | |
d7c0a89a QY |
5837 | uint32_t max; |
5838 | uint8_t threshold; | |
5839 | uint16_t restart; | |
718e3744 | 5840 | |
d62a17ae | 5841 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5842 | if (!peer) | |
5843 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5844 | |
d62a17ae | 5845 | max = strtoul(num_str, NULL, 10); |
5846 | if (threshold_str) | |
5847 | threshold = atoi(threshold_str); | |
5848 | else | |
5849 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5850 | |
d62a17ae | 5851 | if (restart_str) |
5852 | restart = atoi(restart_str); | |
5853 | else | |
5854 | restart = 0; | |
0a486e5f | 5855 | |
d62a17ae | 5856 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
5857 | restart); | |
718e3744 | 5858 | |
d62a17ae | 5859 | return bgp_vty_return(vty, ret); |
718e3744 | 5860 | } |
5861 | ||
d62a17ae | 5862 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
5863 | afi_t afi, safi_t safi) | |
718e3744 | 5864 | { |
d62a17ae | 5865 | int ret; |
5866 | struct peer *peer; | |
718e3744 | 5867 | |
d62a17ae | 5868 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5869 | if (!peer) | |
5870 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5871 | |
d62a17ae | 5872 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 5873 | |
d62a17ae | 5874 | return bgp_vty_return(vty, ret); |
718e3744 | 5875 | } |
5876 | ||
5877 | /* Maximum number of prefix configuration. prefix count is different | |
5878 | for each peer configuration. So this configuration can be set for | |
5879 | each peer configuration. */ | |
5880 | DEFUN (neighbor_maximum_prefix, | |
5881 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5882 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5883 | NEIGHBOR_STR |
5884 | NEIGHBOR_ADDR_STR2 | |
5885 | "Maximum number of prefix accept from this peer\n" | |
5886 | "maximum no. of prefix limit\n") | |
5887 | { | |
d62a17ae | 5888 | int idx_peer = 1; |
5889 | int idx_number = 3; | |
5890 | return peer_maximum_prefix_set_vty( | |
5891 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5892 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 5893 | } |
5894 | ||
d62a17ae | 5895 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
5896 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
5897 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5898 | "Maximum number of prefix accept from this peer\n" | |
5899 | "maximum no. of prefix limit\n") | |
596c17ba | 5900 | |
e0701b79 | 5901 | DEFUN (neighbor_maximum_prefix_threshold, |
5902 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5903 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5904 | NEIGHBOR_STR |
5905 | NEIGHBOR_ADDR_STR2 | |
5906 | "Maximum number of prefix accept from this peer\n" | |
5907 | "maximum no. of prefix limit\n" | |
5908 | "Threshold value (%) at which to generate a warning msg\n") | |
5909 | { | |
d62a17ae | 5910 | int idx_peer = 1; |
5911 | int idx_number = 3; | |
5912 | int idx_number_2 = 4; | |
5913 | return peer_maximum_prefix_set_vty( | |
5914 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5915 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 5916 | } |
e0701b79 | 5917 | |
d62a17ae | 5918 | ALIAS_HIDDEN( |
5919 | neighbor_maximum_prefix_threshold, | |
5920 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
5921 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
5922 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5923 | "Maximum number of prefix accept from this peer\n" | |
5924 | "maximum no. of prefix limit\n" | |
5925 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 5926 | |
718e3744 | 5927 | DEFUN (neighbor_maximum_prefix_warning, |
5928 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5929 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5930 | NEIGHBOR_STR |
5931 | NEIGHBOR_ADDR_STR2 | |
5932 | "Maximum number of prefix accept from this peer\n" | |
5933 | "maximum no. of prefix limit\n" | |
5934 | "Only give warning message when limit is exceeded\n") | |
5935 | { | |
d62a17ae | 5936 | int idx_peer = 1; |
5937 | int idx_number = 3; | |
5938 | return peer_maximum_prefix_set_vty( | |
5939 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5940 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 5941 | } |
5942 | ||
d62a17ae | 5943 | ALIAS_HIDDEN( |
5944 | neighbor_maximum_prefix_warning, | |
5945 | neighbor_maximum_prefix_warning_hidden_cmd, | |
5946 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
5947 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5948 | "Maximum number of prefix accept from this peer\n" | |
5949 | "maximum no. of prefix limit\n" | |
5950 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5951 | |
e0701b79 | 5952 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5953 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5954 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5955 | NEIGHBOR_STR |
5956 | NEIGHBOR_ADDR_STR2 | |
5957 | "Maximum number of prefix accept from this peer\n" | |
5958 | "maximum no. of prefix limit\n" | |
5959 | "Threshold value (%) at which to generate a warning msg\n" | |
5960 | "Only give warning message when limit is exceeded\n") | |
5961 | { | |
d62a17ae | 5962 | int idx_peer = 1; |
5963 | int idx_number = 3; | |
5964 | int idx_number_2 = 4; | |
5965 | return peer_maximum_prefix_set_vty( | |
5966 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5967 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5968 | } |
5969 | ||
d62a17ae | 5970 | ALIAS_HIDDEN( |
5971 | neighbor_maximum_prefix_threshold_warning, | |
5972 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
5973 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
5974 | NEIGHBOR_STR 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 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5979 | |
0a486e5f | 5980 | DEFUN (neighbor_maximum_prefix_restart, |
5981 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5982 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 5983 | NEIGHBOR_STR |
5984 | NEIGHBOR_ADDR_STR2 | |
5985 | "Maximum number of prefix accept from this peer\n" | |
5986 | "maximum no. of prefix limit\n" | |
5987 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 5988 | "Restart interval in minutes\n") |
0a486e5f | 5989 | { |
d62a17ae | 5990 | int idx_peer = 1; |
5991 | int idx_number = 3; | |
5992 | int idx_number_2 = 5; | |
5993 | return peer_maximum_prefix_set_vty( | |
5994 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5995 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 5996 | } |
5997 | ||
d62a17ae | 5998 | ALIAS_HIDDEN( |
5999 | neighbor_maximum_prefix_restart, | |
6000 | neighbor_maximum_prefix_restart_hidden_cmd, | |
6001 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
6002 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6003 | "Maximum number of prefix accept from this peer\n" | |
6004 | "maximum no. of prefix limit\n" | |
6005 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6006 | "Restart interval in minutes\n") |
596c17ba | 6007 | |
0a486e5f | 6008 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6009 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 6010 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 6011 | NEIGHBOR_STR |
6012 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6013 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 6014 | "maximum no. of prefix limit\n" |
6015 | "Threshold value (%) at which to generate a warning msg\n" | |
6016 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6017 | "Restart interval in minutes\n") |
0a486e5f | 6018 | { |
d62a17ae | 6019 | int idx_peer = 1; |
6020 | int idx_number = 3; | |
6021 | int idx_number_2 = 4; | |
6022 | int idx_number_3 = 6; | |
6023 | return peer_maximum_prefix_set_vty( | |
6024 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6025 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
6026 | argv[idx_number_3]->arg); | |
6027 | } | |
6028 | ||
6029 | ALIAS_HIDDEN( | |
6030 | neighbor_maximum_prefix_threshold_restart, | |
6031 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
6032 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
6033 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6034 | "Maximum number of prefixes to accept from this peer\n" | |
6035 | "maximum no. of prefix limit\n" | |
6036 | "Threshold value (%) at which to generate a warning msg\n" | |
6037 | "Restart bgp connection after limit is exceeded\n" | |
6038 | "Restart interval in minutes\n") | |
596c17ba | 6039 | |
718e3744 | 6040 | DEFUN (no_neighbor_maximum_prefix, |
6041 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 6042 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 6043 | NO_STR |
6044 | NEIGHBOR_STR | |
6045 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6046 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
6047 | "maximum no. of prefix limit\n" |
6048 | "Threshold value (%) at which to generate a warning msg\n" | |
6049 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6050 | "Restart interval in minutes\n" |
31500417 | 6051 | "Only give warning message when limit is exceeded\n") |
718e3744 | 6052 | { |
d62a17ae | 6053 | int idx_peer = 2; |
6054 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
6055 | bgp_node_afi(vty), | |
6056 | bgp_node_safi(vty)); | |
718e3744 | 6057 | } |
e52702f2 | 6058 | |
d62a17ae | 6059 | ALIAS_HIDDEN( |
6060 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
6061 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
6062 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6063 | "Maximum number of prefixes to accept from this peer\n" | |
6064 | "maximum no. of prefix limit\n" | |
6065 | "Threshold value (%) at which to generate a warning msg\n" | |
6066 | "Restart bgp connection after limit is exceeded\n" | |
6067 | "Restart interval in minutes\n" | |
6068 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6069 | |
718e3744 | 6070 | |
718e3744 | 6071 | /* "neighbor allowas-in" */ |
6072 | DEFUN (neighbor_allowas_in, | |
6073 | neighbor_allowas_in_cmd, | |
fd8503f5 | 6074 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6075 | NEIGHBOR_STR |
6076 | NEIGHBOR_ADDR_STR2 | |
31500417 | 6077 | "Accept as-path with my AS present in it\n" |
0437e105 | 6078 | "Number of occurences of AS number\n" |
fd8503f5 | 6079 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6080 | { |
d62a17ae | 6081 | int idx_peer = 1; |
6082 | int idx_number_origin = 3; | |
6083 | int ret; | |
6084 | int origin = 0; | |
6085 | struct peer *peer; | |
6086 | int allow_num = 0; | |
6087 | ||
6088 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6089 | if (!peer) | |
6090 | return CMD_WARNING_CONFIG_FAILED; | |
6091 | ||
6092 | if (argc <= idx_number_origin) | |
6093 | allow_num = 3; | |
6094 | else { | |
6095 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6096 | origin = 1; | |
6097 | else | |
6098 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6099 | } | |
6100 | ||
6101 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6102 | allow_num, origin); | |
6103 | ||
6104 | return bgp_vty_return(vty, ret); | |
6105 | } | |
6106 | ||
6107 | ALIAS_HIDDEN( | |
6108 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
6109 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6110 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6111 | "Accept as-path with my AS present in it\n" | |
0437e105 | 6112 | "Number of occurences of AS number\n" |
d62a17ae | 6113 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6114 | |
718e3744 | 6115 | DEFUN (no_neighbor_allowas_in, |
6116 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6117 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6118 | NO_STR |
6119 | NEIGHBOR_STR | |
6120 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6121 | "allow local ASN appears in aspath attribute\n" |
0437e105 | 6122 | "Number of occurences of AS number\n" |
fd8503f5 | 6123 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6124 | { |
d62a17ae | 6125 | int idx_peer = 2; |
6126 | int ret; | |
6127 | struct peer *peer; | |
718e3744 | 6128 | |
d62a17ae | 6129 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6130 | if (!peer) | |
6131 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6132 | |
d62a17ae | 6133 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6134 | bgp_node_safi(vty)); | |
718e3744 | 6135 | |
d62a17ae | 6136 | return bgp_vty_return(vty, ret); |
718e3744 | 6137 | } |
6b0655a2 | 6138 | |
d62a17ae | 6139 | ALIAS_HIDDEN( |
6140 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6141 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6142 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6143 | "allow local ASN appears in aspath attribute\n" | |
0437e105 | 6144 | "Number of occurences of AS number\n" |
d62a17ae | 6145 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6146 | |
fa411a21 NH |
6147 | DEFUN (neighbor_ttl_security, |
6148 | neighbor_ttl_security_cmd, | |
7ebe625c | 6149 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6150 | NEIGHBOR_STR |
7ebe625c | 6151 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6152 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6153 | "Specify the maximum number of hops to the BGP peer\n" |
6154 | "Number of hops to BGP peer\n") | |
fa411a21 | 6155 | { |
d62a17ae | 6156 | int idx_peer = 1; |
6157 | int idx_number = 4; | |
6158 | struct peer *peer; | |
6159 | int gtsm_hops; | |
6160 | ||
6161 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6162 | if (!peer) | |
6163 | return CMD_WARNING_CONFIG_FAILED; | |
6164 | ||
6165 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6166 | ||
7ebe625c QY |
6167 | /* |
6168 | * If 'neighbor swpX', then this is for directly connected peers, | |
6169 | * we should not accept a ttl-security hops value greater than 1. | |
6170 | */ | |
6171 | if (peer->conf_if && (gtsm_hops > 1)) { | |
6172 | vty_out(vty, | |
6173 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6174 | argv[idx_peer]->arg); | |
6175 | return CMD_WARNING_CONFIG_FAILED; | |
6176 | } | |
6177 | ||
d62a17ae | 6178 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6179 | } |
6180 | ||
6181 | DEFUN (no_neighbor_ttl_security, | |
6182 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6183 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6184 | NO_STR |
6185 | NEIGHBOR_STR | |
7ebe625c | 6186 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6187 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6188 | "Specify the maximum number of hops to the BGP peer\n" |
6189 | "Number of hops to BGP peer\n") | |
fa411a21 | 6190 | { |
d62a17ae | 6191 | int idx_peer = 2; |
6192 | struct peer *peer; | |
fa411a21 | 6193 | |
d62a17ae | 6194 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6195 | if (!peer) | |
6196 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6197 | |
d62a17ae | 6198 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6199 | } |
6b0655a2 | 6200 | |
adbac85e DW |
6201 | DEFUN (neighbor_addpath_tx_all_paths, |
6202 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6203 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6204 | NEIGHBOR_STR |
6205 | NEIGHBOR_ADDR_STR2 | |
6206 | "Use addpath to advertise all paths to a neighbor\n") | |
6207 | { | |
d62a17ae | 6208 | int idx_peer = 1; |
6209 | struct peer *peer; | |
adbac85e | 6210 | |
d62a17ae | 6211 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6212 | if (!peer) | |
6213 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6214 | |
dcc68b5e MS |
6215 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6216 | BGP_ADDPATH_ALL); | |
6217 | return CMD_SUCCESS; | |
adbac85e DW |
6218 | } |
6219 | ||
d62a17ae | 6220 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6221 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6222 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6223 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6224 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6225 | |
adbac85e DW |
6226 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6227 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6228 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6229 | NO_STR |
6230 | NEIGHBOR_STR | |
6231 | NEIGHBOR_ADDR_STR2 | |
6232 | "Use addpath to advertise all paths to a neighbor\n") | |
6233 | { | |
d62a17ae | 6234 | int idx_peer = 2; |
dcc68b5e MS |
6235 | struct peer *peer; |
6236 | ||
6237 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6238 | if (!peer) | |
6239 | return CMD_WARNING_CONFIG_FAILED; | |
6240 | ||
6241 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6242 | != BGP_ADDPATH_ALL) { | |
6243 | vty_out(vty, | |
6244 | "%% Peer not currently configured to transmit all paths."); | |
6245 | return CMD_WARNING_CONFIG_FAILED; | |
6246 | } | |
6247 | ||
6248 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6249 | BGP_ADDPATH_NONE); | |
6250 | ||
6251 | return CMD_SUCCESS; | |
adbac85e DW |
6252 | } |
6253 | ||
d62a17ae | 6254 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6255 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6256 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6257 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6258 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6259 | |
06370dac DW |
6260 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6261 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6262 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6263 | NEIGHBOR_STR |
6264 | NEIGHBOR_ADDR_STR2 | |
6265 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6266 | { | |
d62a17ae | 6267 | int idx_peer = 1; |
6268 | struct peer *peer; | |
06370dac | 6269 | |
d62a17ae | 6270 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6271 | if (!peer) | |
6272 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 6273 | |
dcc68b5e MS |
6274 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6275 | BGP_ADDPATH_BEST_PER_AS); | |
6276 | ||
6277 | return CMD_SUCCESS; | |
06370dac DW |
6278 | } |
6279 | ||
d62a17ae | 6280 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
6281 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6282 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6283 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6284 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6285 | |
06370dac DW |
6286 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
6287 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6288 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6289 | NO_STR |
6290 | NEIGHBOR_STR | |
6291 | NEIGHBOR_ADDR_STR2 | |
6292 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6293 | { | |
d62a17ae | 6294 | int idx_peer = 2; |
dcc68b5e MS |
6295 | struct peer *peer; |
6296 | ||
6297 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6298 | if (!peer) | |
6299 | return CMD_WARNING_CONFIG_FAILED; | |
6300 | ||
6301 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6302 | != BGP_ADDPATH_BEST_PER_AS) { | |
6303 | vty_out(vty, | |
6304 | "%% Peer not currently configured to transmit all best path per as."); | |
6305 | return CMD_WARNING_CONFIG_FAILED; | |
6306 | } | |
6307 | ||
6308 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6309 | BGP_ADDPATH_NONE); | |
6310 | ||
6311 | return CMD_SUCCESS; | |
06370dac DW |
6312 | } |
6313 | ||
d62a17ae | 6314 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
6315 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6316 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6317 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6318 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6319 | |
b9c7bc5a PZ |
6320 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
6321 | struct ecommunity **list) | |
ddb5b488 | 6322 | { |
b9c7bc5a PZ |
6323 | struct ecommunity *ecom = NULL; |
6324 | struct ecommunity *ecomadd; | |
ddb5b488 | 6325 | |
b9c7bc5a | 6326 | for (; argc; --argc, ++argv) { |
ddb5b488 | 6327 | |
b9c7bc5a PZ |
6328 | ecomadd = ecommunity_str2com(argv[0]->arg, |
6329 | ECOMMUNITY_ROUTE_TARGET, 0); | |
6330 | if (!ecomadd) { | |
6331 | vty_out(vty, "Malformed community-list value\n"); | |
6332 | if (ecom) | |
6333 | ecommunity_free(&ecom); | |
6334 | return CMD_WARNING_CONFIG_FAILED; | |
6335 | } | |
ddb5b488 | 6336 | |
b9c7bc5a PZ |
6337 | if (ecom) { |
6338 | ecommunity_merge(ecom, ecomadd); | |
6339 | ecommunity_free(&ecomadd); | |
6340 | } else { | |
6341 | ecom = ecomadd; | |
6342 | } | |
6343 | } | |
6344 | ||
6345 | if (*list) { | |
6346 | ecommunity_free(&*list); | |
ddb5b488 | 6347 | } |
b9c7bc5a PZ |
6348 | *list = ecom; |
6349 | ||
6350 | return CMD_SUCCESS; | |
ddb5b488 PZ |
6351 | } |
6352 | ||
0ca70ba5 DS |
6353 | /* |
6354 | * v2vimport is true if we are handling a `import vrf ...` command | |
6355 | */ | |
6356 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 6357 | { |
0ca70ba5 DS |
6358 | afi_t afi; |
6359 | ||
ddb5b488 | 6360 | switch (vty->node) { |
b9c7bc5a | 6361 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
6362 | afi = AFI_IP; |
6363 | break; | |
b9c7bc5a | 6364 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
6365 | afi = AFI_IP6; |
6366 | break; | |
ddb5b488 PZ |
6367 | default: |
6368 | vty_out(vty, | |
b9c7bc5a | 6369 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 6370 | return AFI_MAX; |
ddb5b488 | 6371 | } |
69b07479 | 6372 | |
0ca70ba5 DS |
6373 | if (!v2vimport) { |
6374 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6375 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
6376 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6377 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
6378 | vty_out(vty, | |
6379 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
6380 | return AFI_MAX; | |
6381 | } | |
6382 | } else { | |
6383 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6384 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
6385 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6386 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
6387 | vty_out(vty, | |
6388 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
6389 | return AFI_MAX; | |
6390 | } | |
6391 | } | |
6392 | return afi; | |
ddb5b488 PZ |
6393 | } |
6394 | ||
b9c7bc5a PZ |
6395 | DEFPY (af_rd_vpn_export, |
6396 | af_rd_vpn_export_cmd, | |
6397 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
6398 | NO_STR | |
ddb5b488 | 6399 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
6400 | "Between current address-family and vpn\n" |
6401 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6402 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
6403 | { | |
6404 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6405 | struct prefix_rd prd; | |
6406 | int ret; | |
ddb5b488 | 6407 | afi_t afi; |
b9c7bc5a PZ |
6408 | int idx = 0; |
6409 | int yes = 1; | |
ddb5b488 | 6410 | |
b9c7bc5a | 6411 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6412 | yes = 0; |
b9c7bc5a PZ |
6413 | |
6414 | if (yes) { | |
6415 | ret = str2prefix_rd(rd_str, &prd); | |
6416 | if (!ret) { | |
6417 | vty_out(vty, "%% Malformed rd\n"); | |
6418 | return CMD_WARNING_CONFIG_FAILED; | |
6419 | } | |
ddb5b488 PZ |
6420 | } |
6421 | ||
0ca70ba5 | 6422 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6423 | if (afi == AFI_MAX) |
6424 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6425 | |
69b07479 DS |
6426 | /* |
6427 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6428 | */ | |
6429 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6430 | bgp_get_default(), bgp); | |
ddb5b488 | 6431 | |
69b07479 DS |
6432 | if (yes) { |
6433 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
6434 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6435 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
6436 | } else { | |
6437 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6438 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
6439 | } |
6440 | ||
69b07479 DS |
6441 | /* post-change: re-export vpn routes */ |
6442 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6443 | bgp_get_default(), bgp); | |
6444 | ||
ddb5b488 PZ |
6445 | return CMD_SUCCESS; |
6446 | } | |
6447 | ||
b9c7bc5a PZ |
6448 | ALIAS (af_rd_vpn_export, |
6449 | af_no_rd_vpn_export_cmd, | |
6450 | "no rd vpn export", | |
ddb5b488 | 6451 | NO_STR |
b9c7bc5a PZ |
6452 | "Specify route distinguisher\n" |
6453 | "Between current address-family and vpn\n" | |
6454 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6455 | |
b9c7bc5a PZ |
6456 | DEFPY (af_label_vpn_export, |
6457 | af_label_vpn_export_cmd, | |
e70e9f8e | 6458 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 6459 | NO_STR |
ddb5b488 | 6460 | "label value for VRF\n" |
b9c7bc5a PZ |
6461 | "Between current address-family and vpn\n" |
6462 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
6463 | "Label Value <0-1048575>\n" |
6464 | "Automatically assign a label\n") | |
ddb5b488 PZ |
6465 | { |
6466 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6467 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 6468 | afi_t afi; |
b9c7bc5a PZ |
6469 | int idx = 0; |
6470 | int yes = 1; | |
6471 | ||
6472 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 6473 | yes = 0; |
ddb5b488 | 6474 | |
21a16cc2 PZ |
6475 | /* If "no ...", squash trailing parameter */ |
6476 | if (!yes) | |
6477 | label_auto = NULL; | |
6478 | ||
e70e9f8e PZ |
6479 | if (yes) { |
6480 | if (!label_auto) | |
6481 | label = label_val; /* parser should force unsigned */ | |
6482 | } | |
ddb5b488 | 6483 | |
0ca70ba5 | 6484 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6485 | if (afi == AFI_MAX) |
6486 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 6487 | |
e70e9f8e | 6488 | |
69b07479 DS |
6489 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
6490 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
6491 | /* no change */ | |
6492 | return CMD_SUCCESS; | |
e70e9f8e | 6493 | |
69b07479 DS |
6494 | /* |
6495 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6496 | */ | |
6497 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6498 | bgp_get_default(), bgp); | |
6499 | ||
6500 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
6501 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
6502 | ||
6503 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
6504 | ||
6505 | /* | |
6506 | * label has previously been automatically | |
6507 | * assigned by labelpool: release it | |
6508 | * | |
6509 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
6510 | * means the automatic assignment is in flight | |
6511 | * and therefore the labelpool callback must | |
6512 | * detect that the auto label is not needed. | |
6513 | */ | |
6514 | ||
6515 | bgp_lp_release(LP_TYPE_VRF, | |
6516 | &bgp->vpn_policy[afi], | |
6517 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 6518 | } |
69b07479 DS |
6519 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
6520 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6521 | } | |
ddb5b488 | 6522 | |
69b07479 DS |
6523 | bgp->vpn_policy[afi].tovpn_label = label; |
6524 | if (label_auto) { | |
6525 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6526 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6527 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
6528 | vpn_leak_label_callback); | |
ddb5b488 PZ |
6529 | } |
6530 | ||
69b07479 DS |
6531 | /* post-change: re-export vpn routes */ |
6532 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6533 | bgp_get_default(), bgp); | |
6534 | ||
ddb5b488 PZ |
6535 | return CMD_SUCCESS; |
6536 | } | |
6537 | ||
b9c7bc5a PZ |
6538 | ALIAS (af_label_vpn_export, |
6539 | af_no_label_vpn_export_cmd, | |
6540 | "no label vpn export", | |
6541 | NO_STR | |
6542 | "label value for VRF\n" | |
6543 | "Between current address-family and vpn\n" | |
6544 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6545 | |
b9c7bc5a PZ |
6546 | DEFPY (af_nexthop_vpn_export, |
6547 | af_nexthop_vpn_export_cmd, | |
6548 | "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str", | |
6549 | NO_STR | |
ddb5b488 | 6550 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
6551 | "Between current address-family and vpn\n" |
6552 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6553 | "IPv4 prefix\n" |
6554 | "IPv6 prefix\n") | |
6555 | { | |
6556 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 6557 | afi_t afi; |
ddb5b488 | 6558 | struct prefix p; |
b9c7bc5a PZ |
6559 | int idx = 0; |
6560 | int yes = 1; | |
ddb5b488 | 6561 | |
b9c7bc5a | 6562 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6563 | yes = 0; |
b9c7bc5a PZ |
6564 | |
6565 | if (yes) { | |
6566 | if (!sockunion2hostprefix(nexthop_str, &p)) | |
6567 | return CMD_WARNING_CONFIG_FAILED; | |
6568 | } | |
ddb5b488 | 6569 | |
0ca70ba5 | 6570 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6571 | if (afi == AFI_MAX) |
6572 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6573 | |
69b07479 DS |
6574 | /* |
6575 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6576 | */ | |
6577 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6578 | bgp_get_default(), bgp); | |
ddb5b488 | 6579 | |
69b07479 DS |
6580 | if (yes) { |
6581 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
6582 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6583 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
6584 | } else { | |
6585 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6586 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
6587 | } |
6588 | ||
69b07479 DS |
6589 | /* post-change: re-export vpn routes */ |
6590 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6591 | bgp_get_default(), bgp); | |
6592 | ||
ddb5b488 PZ |
6593 | return CMD_SUCCESS; |
6594 | } | |
6595 | ||
b9c7bc5a PZ |
6596 | ALIAS (af_nexthop_vpn_export, |
6597 | af_no_nexthop_vpn_export_cmd, | |
6598 | "no nexthop vpn export", | |
ddb5b488 | 6599 | NO_STR |
b9c7bc5a PZ |
6600 | "Specify next hop to use for VRF advertised prefixes\n" |
6601 | "Between current address-family and vpn\n" | |
6602 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6603 | |
b9c7bc5a | 6604 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 6605 | { |
b9c7bc5a PZ |
6606 | if (!strcmp(dstr, "import")) { |
6607 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6608 | } else if (!strcmp(dstr, "export")) { | |
6609 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6610 | } else if (!strcmp(dstr, "both")) { | |
6611 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6612 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6613 | } else { | |
6614 | vty_out(vty, "%% direction parse error\n"); | |
6615 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6616 | } |
ddb5b488 PZ |
6617 | return CMD_SUCCESS; |
6618 | } | |
6619 | ||
b9c7bc5a PZ |
6620 | DEFPY (af_rt_vpn_imexport, |
6621 | af_rt_vpn_imexport_cmd, | |
6622 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
6623 | NO_STR | |
6624 | "Specify route target list\n" | |
ddb5b488 | 6625 | "Specify route target list\n" |
b9c7bc5a PZ |
6626 | "Between current address-family and vpn\n" |
6627 | "For routes leaked from vpn to current address-family: match any\n" | |
6628 | "For routes leaked from current address-family to vpn: set\n" | |
6629 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
6630 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
6631 | { | |
6632 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6633 | int ret; | |
6634 | struct ecommunity *ecom = NULL; | |
6635 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6636 | vpn_policy_direction_t dir; |
6637 | afi_t afi; | |
6638 | int idx = 0; | |
b9c7bc5a | 6639 | int yes = 1; |
ddb5b488 | 6640 | |
b9c7bc5a | 6641 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6642 | yes = 0; |
b9c7bc5a | 6643 | |
0ca70ba5 | 6644 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6645 | if (afi == AFI_MAX) |
6646 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6647 | |
b9c7bc5a | 6648 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6649 | if (ret != CMD_SUCCESS) |
6650 | return ret; | |
6651 | ||
b9c7bc5a PZ |
6652 | if (yes) { |
6653 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
6654 | vty_out(vty, "%% Missing RTLIST\n"); | |
6655 | return CMD_WARNING_CONFIG_FAILED; | |
6656 | } | |
6657 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
6658 | if (ret != CMD_SUCCESS) { | |
6659 | return ret; | |
6660 | } | |
ddb5b488 PZ |
6661 | } |
6662 | ||
69b07479 DS |
6663 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6664 | if (!dodir[dir]) | |
ddb5b488 | 6665 | continue; |
ddb5b488 | 6666 | |
69b07479 | 6667 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6668 | |
69b07479 DS |
6669 | if (yes) { |
6670 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6671 | ecommunity_free( | |
6672 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6673 | bgp->vpn_policy[afi].rtlist[dir] = | |
6674 | ecommunity_dup(ecom); | |
6675 | } else { | |
6676 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6677 | ecommunity_free( | |
6678 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6679 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 6680 | } |
69b07479 DS |
6681 | |
6682 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 6683 | } |
69b07479 | 6684 | |
d555f3e9 PZ |
6685 | if (ecom) |
6686 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
6687 | |
6688 | return CMD_SUCCESS; | |
6689 | } | |
6690 | ||
b9c7bc5a PZ |
6691 | ALIAS (af_rt_vpn_imexport, |
6692 | af_no_rt_vpn_imexport_cmd, | |
6693 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
6694 | NO_STR |
6695 | "Specify route target list\n" | |
b9c7bc5a PZ |
6696 | "Specify route target list\n" |
6697 | "Between current address-family and vpn\n" | |
6698 | "For routes leaked from vpn to current address-family\n" | |
6699 | "For routes leaked from current address-family to vpn\n" | |
6700 | "both import and export\n") | |
6701 | ||
6702 | DEFPY (af_route_map_vpn_imexport, | |
6703 | af_route_map_vpn_imexport_cmd, | |
6704 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
6705 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
6706 | NO_STR | |
ddb5b488 | 6707 | "Specify route map\n" |
b9c7bc5a PZ |
6708 | "Between current address-family and vpn\n" |
6709 | "For routes leaked from vpn to current address-family\n" | |
6710 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6711 | "name of route-map\n") |
6712 | { | |
6713 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6714 | int ret; | |
6715 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6716 | vpn_policy_direction_t dir; |
6717 | afi_t afi; | |
ddb5b488 | 6718 | int idx = 0; |
b9c7bc5a | 6719 | int yes = 1; |
ddb5b488 | 6720 | |
b9c7bc5a | 6721 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6722 | yes = 0; |
b9c7bc5a | 6723 | |
0ca70ba5 | 6724 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6725 | if (afi == AFI_MAX) |
6726 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6727 | |
b9c7bc5a | 6728 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6729 | if (ret != CMD_SUCCESS) |
6730 | return ret; | |
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].rmap_name[dir]) | |
6740 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6741 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6742 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
6743 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6744 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 6745 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
6746 | if (!bgp->vpn_policy[afi].rmap[dir]) |
6747 | return CMD_SUCCESS; | |
6748 | } else { | |
6749 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6750 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6751 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6752 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6753 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 6754 | } |
69b07479 DS |
6755 | |
6756 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
6757 | } |
6758 | ||
6759 | return CMD_SUCCESS; | |
6760 | } | |
6761 | ||
b9c7bc5a PZ |
6762 | ALIAS (af_route_map_vpn_imexport, |
6763 | af_no_route_map_vpn_imexport_cmd, | |
6764 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
6765 | NO_STR |
6766 | "Specify route map\n" | |
b9c7bc5a PZ |
6767 | "Between current address-family and vpn\n" |
6768 | "For routes leaked from vpn to current address-family\n" | |
6769 | "For routes leaked from current address-family to vpn\n") | |
6770 | ||
bb4f6190 DS |
6771 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
6772 | "[no] import vrf route-map RMAP$rmap_str", | |
6773 | NO_STR | |
6774 | "Import routes from another VRF\n" | |
6775 | "Vrf routes being filtered\n" | |
6776 | "Specify route map\n" | |
6777 | "name of route-map\n") | |
6778 | { | |
6779 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
6780 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
6781 | afi_t afi; | |
6782 | int idx = 0; | |
6783 | int yes = 1; | |
6784 | struct bgp *bgp_default; | |
6785 | ||
6786 | if (argv_find(argv, argc, "no", &idx)) | |
6787 | yes = 0; | |
6788 | ||
0ca70ba5 | 6789 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
6790 | if (afi == AFI_MAX) |
6791 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
6792 | |
6793 | bgp_default = bgp_get_default(); | |
6794 | if (!bgp_default) { | |
6795 | int32_t ret; | |
6796 | as_t as = bgp->as; | |
6797 | ||
6798 | /* Auto-create assuming the same AS */ | |
6799 | ret = bgp_get(&bgp_default, &as, NULL, | |
6800 | BGP_INSTANCE_TYPE_DEFAULT); | |
6801 | ||
6802 | if (ret) { | |
6803 | vty_out(vty, | |
6804 | "VRF default is not configured as a bgp instance\n"); | |
6805 | return CMD_WARNING; | |
6806 | } | |
6807 | } | |
6808 | ||
69b07479 | 6809 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 6810 | |
69b07479 DS |
6811 | if (yes) { |
6812 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6813 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6814 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6815 | bgp->vpn_policy[afi].rmap_name[dir] = | |
6816 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6817 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 6818 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
6819 | if (!bgp->vpn_policy[afi].rmap[dir]) |
6820 | return CMD_SUCCESS; | |
6821 | } else { | |
6822 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6823 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6824 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6825 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6826 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
bb4f6190 DS |
6827 | } |
6828 | ||
69b07479 DS |
6829 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
6830 | ||
bb4f6190 DS |
6831 | return CMD_SUCCESS; |
6832 | } | |
6833 | ||
6834 | ALIAS(af_import_vrf_route_map, af_no_import_vrf_route_map_cmd, | |
6835 | "no import vrf route-map", | |
6836 | NO_STR | |
6837 | "Import routes from another VRF\n" | |
6838 | "Vrf routes being filtered\n" | |
6839 | "Specify route map\n") | |
6840 | ||
4d1b335c DA |
6841 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
6842 | "[no] import vrf VIEWVRFNAME$import_name", | |
6843 | NO_STR | |
6844 | "Import routes from another VRF\n" | |
6845 | "VRF to import from\n" | |
6846 | "The name of the VRF\n") | |
12a844a5 DS |
6847 | { |
6848 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6849 | struct listnode *node; | |
79ef8664 DS |
6850 | struct bgp *vrf_bgp, *bgp_default; |
6851 | int32_t ret = 0; | |
6852 | as_t as = bgp->as; | |
12a844a5 DS |
6853 | bool remove = false; |
6854 | int32_t idx = 0; | |
6855 | char *vname; | |
a8dadcf6 | 6856 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
6857 | safi_t safi; |
6858 | afi_t afi; | |
6859 | ||
867f0cca | 6860 | if (import_name == NULL) { |
6861 | vty_out(vty, "%% Missing import name\n"); | |
6862 | return CMD_WARNING; | |
6863 | } | |
6864 | ||
12a844a5 DS |
6865 | if (argv_find(argv, argc, "no", &idx)) |
6866 | remove = true; | |
6867 | ||
0ca70ba5 DS |
6868 | afi = vpn_policy_getafi(vty, bgp, true); |
6869 | if (afi == AFI_MAX) | |
6870 | return CMD_WARNING_CONFIG_FAILED; | |
6871 | ||
12a844a5 DS |
6872 | safi = bgp_node_safi(vty); |
6873 | ||
25679caa | 6874 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 6875 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
6876 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
6877 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
6878 | remove ? "unimport" : "import", import_name); | |
6879 | return CMD_WARNING; | |
6880 | } | |
6881 | ||
79ef8664 DS |
6882 | bgp_default = bgp_get_default(); |
6883 | if (!bgp_default) { | |
6884 | /* Auto-create assuming the same AS */ | |
6885 | ret = bgp_get(&bgp_default, &as, NULL, | |
6886 | BGP_INSTANCE_TYPE_DEFAULT); | |
6887 | ||
6888 | if (ret) { | |
6889 | vty_out(vty, | |
6890 | "VRF default is not configured as a bgp instance\n"); | |
6891 | return CMD_WARNING; | |
6892 | } | |
6893 | } | |
6894 | ||
12a844a5 DS |
6895 | vrf_bgp = bgp_lookup_by_name(import_name); |
6896 | if (!vrf_bgp) { | |
5742e42b | 6897 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
6898 | vrf_bgp = bgp_default; |
6899 | else | |
0fb8d6e6 DS |
6900 | /* Auto-create assuming the same AS */ |
6901 | ret = bgp_get(&vrf_bgp, &as, import_name, bgp_type); | |
a8dadcf6 | 6902 | |
6e2c7fe6 | 6903 | if (ret) { |
020a3f60 DS |
6904 | vty_out(vty, |
6905 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
6906 | import_name); |
6907 | return CMD_WARNING; | |
6908 | } | |
12a844a5 DS |
6909 | } |
6910 | ||
12a844a5 | 6911 | if (remove) { |
44338987 | 6912 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 6913 | } else { |
44338987 | 6914 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
6915 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
6916 | vname)) { | |
6917 | if (strcmp(vname, import_name) == 0) | |
6918 | return CMD_WARNING; | |
6919 | } | |
6920 | ||
44338987 | 6921 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
6922 | } |
6923 | ||
6924 | return CMD_SUCCESS; | |
6925 | } | |
6926 | ||
b9c7bc5a PZ |
6927 | /* This command is valid only in a bgp vrf instance or the default instance */ |
6928 | DEFPY (bgp_imexport_vpn, | |
6929 | bgp_imexport_vpn_cmd, | |
6930 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
6931 | NO_STR |
6932 | "Import routes to this address-family\n" | |
6933 | "Export routes from this address-family\n" | |
6934 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
6935 | { |
6936 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6937 | int previous_state; |
ddb5b488 | 6938 | afi_t afi; |
b9c7bc5a | 6939 | safi_t safi; |
ddb5b488 | 6940 | int idx = 0; |
b9c7bc5a PZ |
6941 | int yes = 1; |
6942 | int flag; | |
6943 | vpn_policy_direction_t dir; | |
ddb5b488 | 6944 | |
b9c7bc5a | 6945 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6946 | yes = 0; |
ddb5b488 | 6947 | |
b9c7bc5a PZ |
6948 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
6949 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 6950 | |
b9c7bc5a PZ |
6951 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
6952 | return CMD_WARNING_CONFIG_FAILED; | |
6953 | } | |
ddb5b488 | 6954 | |
b9c7bc5a PZ |
6955 | afi = bgp_node_afi(vty); |
6956 | safi = bgp_node_safi(vty); | |
6957 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
6958 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
6959 | return CMD_WARNING_CONFIG_FAILED; | |
6960 | } | |
ddb5b488 | 6961 | |
b9c7bc5a PZ |
6962 | if (!strcmp(direction_str, "import")) { |
6963 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
6964 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
6965 | } else if (!strcmp(direction_str, "export")) { | |
6966 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
6967 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
6968 | } else { | |
6969 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
6970 | return CMD_WARNING_CONFIG_FAILED; | |
6971 | } | |
6972 | ||
6973 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 6974 | |
b9c7bc5a PZ |
6975 | if (yes) { |
6976 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
6977 | if (!previous_state) { | |
6978 | /* trigger export current vrf */ | |
ddb5b488 PZ |
6979 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
6980 | } | |
b9c7bc5a PZ |
6981 | } else { |
6982 | if (previous_state) { | |
6983 | /* trigger un-export current vrf */ | |
6984 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
6985 | } | |
6986 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
6987 | } |
6988 | ||
6989 | return CMD_SUCCESS; | |
6990 | } | |
6991 | ||
301ad80a PG |
6992 | DEFPY (af_routetarget_import, |
6993 | af_routetarget_import_cmd, | |
6994 | "[no] <rt|route-target> redirect import RTLIST...", | |
6995 | NO_STR | |
6996 | "Specify route target list\n" | |
6997 | "Specify route target list\n" | |
6998 | "Flow-spec redirect type route target\n" | |
6999 | "Import routes to this address-family\n" | |
7000 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
7001 | { | |
7002 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7003 | int ret; | |
7004 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
7005 | afi_t afi; |
7006 | int idx = 0; | |
7007 | int yes = 1; | |
7008 | ||
7009 | if (argv_find(argv, argc, "no", &idx)) | |
7010 | yes = 0; | |
7011 | ||
0ca70ba5 | 7012 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7013 | if (afi == AFI_MAX) |
7014 | return CMD_WARNING_CONFIG_FAILED; | |
7015 | ||
301ad80a PG |
7016 | if (yes) { |
7017 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7018 | vty_out(vty, "%% Missing RTLIST\n"); | |
7019 | return CMD_WARNING_CONFIG_FAILED; | |
7020 | } | |
7021 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7022 | if (ret != CMD_SUCCESS) | |
7023 | return ret; | |
7024 | } | |
69b07479 DS |
7025 | |
7026 | if (yes) { | |
7027 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7028 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7029 | .import_redirect_rtlist); |
69b07479 DS |
7030 | bgp->vpn_policy[afi].import_redirect_rtlist = |
7031 | ecommunity_dup(ecom); | |
7032 | } else { | |
7033 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7034 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7035 | .import_redirect_rtlist); |
69b07479 | 7036 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 7037 | } |
69b07479 | 7038 | |
301ad80a PG |
7039 | if (ecom) |
7040 | ecommunity_free(&ecom); | |
7041 | ||
7042 | return CMD_SUCCESS; | |
7043 | } | |
7044 | ||
505e5056 | 7045 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 7046 | address_family_ipv4_safi_cmd, |
7047 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7048 | "Enter Address Family command mode\n" | |
7049 | "Address Family\n" | |
7050 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 7051 | { |
f51bae9c | 7052 | |
d62a17ae | 7053 | if (argc == 3) { |
2131d5cf | 7054 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7055 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7056 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7057 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7058 | && safi != SAFI_EVPN) { |
31947174 MK |
7059 | vty_out(vty, |
7060 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7061 | return CMD_WARNING_CONFIG_FAILED; |
7062 | } | |
d62a17ae | 7063 | vty->node = bgp_node_type(AFI_IP, safi); |
7064 | } else | |
7065 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 7066 | |
d62a17ae | 7067 | return CMD_SUCCESS; |
718e3744 | 7068 | } |
7069 | ||
505e5056 | 7070 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 7071 | address_family_ipv6_safi_cmd, |
7072 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7073 | "Enter Address Family command mode\n" | |
7074 | "Address Family\n" | |
7075 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 7076 | { |
d62a17ae | 7077 | if (argc == 3) { |
2131d5cf | 7078 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7079 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7080 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7081 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7082 | && safi != SAFI_EVPN) { |
31947174 MK |
7083 | vty_out(vty, |
7084 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7085 | return CMD_WARNING_CONFIG_FAILED; |
7086 | } | |
d62a17ae | 7087 | vty->node = bgp_node_type(AFI_IP6, safi); |
7088 | } else | |
7089 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 7090 | |
d62a17ae | 7091 | return CMD_SUCCESS; |
25ffbdc1 | 7092 | } |
718e3744 | 7093 | |
d6902373 | 7094 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 7095 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 7096 | address_family_vpnv4_cmd, |
8334fd5a | 7097 | "address-family vpnv4 [unicast]", |
718e3744 | 7098 | "Enter Address Family command mode\n" |
8c3deaae | 7099 | "Address Family\n" |
3a2d747c | 7100 | "Address Family modifier\n") |
718e3744 | 7101 | { |
d62a17ae | 7102 | vty->node = BGP_VPNV4_NODE; |
7103 | return CMD_SUCCESS; | |
718e3744 | 7104 | } |
7105 | ||
505e5056 | 7106 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 7107 | address_family_vpnv6_cmd, |
8334fd5a | 7108 | "address-family vpnv6 [unicast]", |
8ecd3266 | 7109 | "Enter Address Family command mode\n" |
8c3deaae | 7110 | "Address Family\n" |
3a2d747c | 7111 | "Address Family modifier\n") |
8ecd3266 | 7112 | { |
d62a17ae | 7113 | vty->node = BGP_VPNV6_NODE; |
7114 | return CMD_SUCCESS; | |
8ecd3266 | 7115 | } |
64e4a6c5 | 7116 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 7117 | |
505e5056 | 7118 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 7119 | address_family_evpn_cmd, |
7111c1a0 | 7120 | "address-family l2vpn evpn", |
4e0b7b6d | 7121 | "Enter Address Family command mode\n" |
7111c1a0 QY |
7122 | "Address Family\n" |
7123 | "Address Family modifier\n") | |
4e0b7b6d | 7124 | { |
2131d5cf | 7125 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7126 | vty->node = BGP_EVPN_NODE; |
7127 | return CMD_SUCCESS; | |
4e0b7b6d PG |
7128 | } |
7129 | ||
505e5056 | 7130 | DEFUN_NOSH (exit_address_family, |
718e3744 | 7131 | exit_address_family_cmd, |
7132 | "exit-address-family", | |
7133 | "Exit from Address Family configuration mode\n") | |
7134 | { | |
d62a17ae | 7135 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
7136 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
7137 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
7138 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
7139 | || vty->node == BGP_EVPN_NODE |
7140 | || vty->node == BGP_FLOWSPECV4_NODE | |
7141 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 7142 | vty->node = BGP_NODE; |
7143 | return CMD_SUCCESS; | |
718e3744 | 7144 | } |
6b0655a2 | 7145 | |
8ad7271d | 7146 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 7147 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
7148 | const char *ip_str, afi_t afi, safi_t safi, | |
7149 | struct prefix_rd *prd) | |
7150 | { | |
7151 | int ret; | |
7152 | struct prefix match; | |
7153 | struct bgp_node *rn; | |
7154 | struct bgp_node *rm; | |
7155 | struct bgp *bgp; | |
7156 | struct bgp_table *table; | |
7157 | struct bgp_table *rib; | |
7158 | ||
7159 | /* BGP structure lookup. */ | |
7160 | if (view_name) { | |
7161 | bgp = bgp_lookup_by_name(view_name); | |
7162 | if (bgp == NULL) { | |
7163 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
7164 | view_name); | |
7165 | return CMD_WARNING; | |
7166 | } | |
7167 | } else { | |
7168 | bgp = bgp_get_default(); | |
7169 | if (bgp == NULL) { | |
7170 | vty_out(vty, "%% No BGP process is configured\n"); | |
7171 | return CMD_WARNING; | |
7172 | } | |
7173 | } | |
7174 | ||
7175 | /* Check IP address argument. */ | |
7176 | ret = str2prefix(ip_str, &match); | |
7177 | if (!ret) { | |
7178 | vty_out(vty, "%% address is malformed\n"); | |
7179 | return CMD_WARNING; | |
7180 | } | |
7181 | ||
7182 | match.family = afi2family(afi); | |
7183 | rib = bgp->rib[afi][safi]; | |
7184 | ||
7185 | if (safi == SAFI_MPLS_VPN) { | |
7186 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
7187 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
7188 | continue; | |
7189 | ||
67009e22 DS |
7190 | table = bgp_node_get_bgp_table_info(rn); |
7191 | if (table != NULL) { | |
7192 | ||
d62a17ae | 7193 | if ((rm = bgp_node_match(table, &match)) |
7194 | != NULL) { | |
7195 | if (rm->p.prefixlen | |
7196 | == match.prefixlen) { | |
343cdb61 | 7197 | SET_FLAG(rm->flags, |
d62a17ae | 7198 | BGP_NODE_USER_CLEAR); |
7199 | bgp_process(bgp, rm, afi, safi); | |
7200 | } | |
7201 | bgp_unlock_node(rm); | |
7202 | } | |
7203 | } | |
7204 | } | |
7205 | } else { | |
7206 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
7207 | if (rn->p.prefixlen == match.prefixlen) { | |
7208 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
7209 | bgp_process(bgp, rn, afi, safi); | |
7210 | } | |
7211 | bgp_unlock_node(rn); | |
7212 | } | |
7213 | } | |
7214 | ||
7215 | return CMD_SUCCESS; | |
8ad7271d DS |
7216 | } |
7217 | ||
b09b5ae0 | 7218 | /* one clear bgp command to rule them all */ |
718e3744 | 7219 | DEFUN (clear_ip_bgp_all, |
7220 | clear_ip_bgp_all_cmd, | |
d7b9898c | 7221 | "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 | 7222 | CLEAR_STR |
7223 | IP_STR | |
7224 | BGP_STR | |
838758ac | 7225 | BGP_INSTANCE_HELP_STR |
510afcd6 | 7226 | BGP_AFI_HELP_STR |
fd5e7b70 | 7227 | "Address Family\n" |
510afcd6 | 7228 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 7229 | "Address Family modifier\n" |
b09b5ae0 DW |
7230 | "Clear all peers\n" |
7231 | "BGP neighbor address to clear\n" | |
a80beece | 7232 | "BGP IPv6 neighbor to clear\n" |
838758ac | 7233 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
7234 | "Clear peers with the AS number\n" |
7235 | "Clear all external peers\n" | |
718e3744 | 7236 | "Clear all members of peer-group\n" |
b09b5ae0 | 7237 | "BGP peer-group name\n" |
b09b5ae0 DW |
7238 | BGP_SOFT_STR |
7239 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
7240 | BGP_SOFT_OUT_STR |
7241 | BGP_SOFT_IN_STR | |
7242 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 7243 | BGP_SOFT_OUT_STR) |
718e3744 | 7244 | { |
d62a17ae | 7245 | char *vrf = NULL; |
7246 | ||
7247 | afi_t afi = AFI_IP6; | |
7248 | safi_t safi = SAFI_UNICAST; | |
7249 | enum clear_sort clr_sort = clear_peer; | |
7250 | enum bgp_clear_type clr_type; | |
7251 | char *clr_arg = NULL; | |
7252 | ||
7253 | int idx = 0; | |
7254 | ||
7255 | /* clear [ip] bgp */ | |
7256 | if (argv_find(argv, argc, "ip", &idx)) | |
7257 | afi = AFI_IP; | |
7258 | ||
9a8bdf1c PG |
7259 | /* [<vrf> VIEWVRFNAME] */ |
7260 | if (argv_find(argv, argc, "vrf", &idx)) { | |
7261 | vrf = argv[idx + 1]->arg; | |
7262 | idx += 2; | |
7263 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7264 | vrf = NULL; | |
7265 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7266 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 7267 | vrf = argv[idx + 1]->arg; |
7268 | idx += 2; | |
7269 | } | |
d62a17ae | 7270 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
7271 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
7272 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
7273 | ||
d7b9898c | 7274 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 7275 | if (argv_find(argv, argc, "*", &idx)) { |
7276 | clr_sort = clear_all; | |
7277 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
7278 | clr_sort = clear_peer; | |
7279 | clr_arg = argv[idx]->arg; | |
7280 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
7281 | clr_sort = clear_peer; | |
7282 | clr_arg = argv[idx]->arg; | |
7283 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
7284 | clr_sort = clear_group; | |
7285 | idx++; | |
7286 | clr_arg = argv[idx]->arg; | |
d7b9898c | 7287 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 7288 | clr_sort = clear_peer; |
7289 | clr_arg = argv[idx]->arg; | |
7290 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { | |
7291 | clr_sort = clear_as; | |
7292 | clr_arg = argv[idx]->arg; | |
7293 | } else if (argv_find(argv, argc, "external", &idx)) { | |
7294 | clr_sort = clear_external; | |
7295 | } | |
7296 | ||
7297 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
7298 | if (argv_find(argv, argc, "soft", &idx)) { | |
7299 | if (argv_find(argv, argc, "in", &idx) | |
7300 | || argv_find(argv, argc, "out", &idx)) | |
7301 | clr_type = strmatch(argv[idx]->text, "in") | |
7302 | ? BGP_CLEAR_SOFT_IN | |
7303 | : BGP_CLEAR_SOFT_OUT; | |
7304 | else | |
7305 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
7306 | } else if (argv_find(argv, argc, "in", &idx)) { | |
7307 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
7308 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
7309 | : BGP_CLEAR_SOFT_IN; | |
7310 | } else if (argv_find(argv, argc, "out", &idx)) { | |
7311 | clr_type = BGP_CLEAR_SOFT_OUT; | |
7312 | } else | |
7313 | clr_type = BGP_CLEAR_SOFT_NONE; | |
7314 | ||
7315 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 7316 | } |
01080f7c | 7317 | |
8ad7271d DS |
7318 | DEFUN (clear_ip_bgp_prefix, |
7319 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 7320 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
7321 | CLEAR_STR |
7322 | IP_STR | |
7323 | BGP_STR | |
838758ac | 7324 | BGP_INSTANCE_HELP_STR |
8ad7271d | 7325 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7326 | "IPv4 prefix\n") |
8ad7271d | 7327 | { |
d62a17ae | 7328 | char *vrf = NULL; |
7329 | char *prefix = NULL; | |
8ad7271d | 7330 | |
d62a17ae | 7331 | int idx = 0; |
01080f7c | 7332 | |
d62a17ae | 7333 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
7334 | if (argv_find(argv, argc, "vrf", &idx)) { |
7335 | vrf = argv[idx + 1]->arg; | |
7336 | idx += 2; | |
7337 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7338 | vrf = NULL; | |
7339 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7340 | /* [<view> VIEWVRFNAME] */ | |
7341 | vrf = argv[idx + 1]->arg; | |
7342 | idx += 2; | |
7343 | } | |
0c7b1b01 | 7344 | |
d62a17ae | 7345 | prefix = argv[argc - 1]->arg; |
8ad7271d | 7346 | |
d62a17ae | 7347 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 7348 | } |
8ad7271d | 7349 | |
b09b5ae0 DW |
7350 | DEFUN (clear_bgp_ipv6_safi_prefix, |
7351 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 7352 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7353 | CLEAR_STR |
3a2d747c | 7354 | IP_STR |
718e3744 | 7355 | BGP_STR |
8c3deaae | 7356 | "Address Family\n" |
46f296b4 | 7357 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7358 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7359 | "IPv6 prefix\n") |
718e3744 | 7360 | { |
9b475e76 PG |
7361 | int idx_safi = 0; |
7362 | int idx_ipv6_prefix = 0; | |
7363 | safi_t safi = SAFI_UNICAST; | |
7364 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7365 | argv[idx_ipv6_prefix]->arg : NULL; | |
7366 | ||
7367 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 7368 | return bgp_clear_prefix( |
9b475e76 PG |
7369 | vty, NULL, prefix, AFI_IP6, |
7370 | safi, NULL); | |
838758ac | 7371 | } |
01080f7c | 7372 | |
b09b5ae0 DW |
7373 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
7374 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 7375 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7376 | CLEAR_STR |
3a2d747c | 7377 | IP_STR |
718e3744 | 7378 | BGP_STR |
838758ac | 7379 | BGP_INSTANCE_HELP_STR |
8c3deaae | 7380 | "Address Family\n" |
46f296b4 | 7381 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7382 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7383 | "IPv6 prefix\n") |
718e3744 | 7384 | { |
9b475e76 | 7385 | int idx_safi = 0; |
9a8bdf1c | 7386 | int idx_vrfview = 0; |
9b475e76 PG |
7387 | int idx_ipv6_prefix = 0; |
7388 | safi_t safi = SAFI_UNICAST; | |
7389 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7390 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 7391 | char *vrfview = NULL; |
9b475e76 | 7392 | |
9a8bdf1c PG |
7393 | /* [<view|vrf> VIEWVRFNAME] */ |
7394 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
7395 | vrfview = argv[idx_vrfview + 1]->arg; | |
7396 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
7397 | vrfview = NULL; | |
7398 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
7399 | /* [<view> VIEWVRFNAME] */ | |
7400 | vrfview = argv[idx_vrfview + 1]->arg; | |
7401 | } | |
9b475e76 PG |
7402 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
7403 | ||
d62a17ae | 7404 | return bgp_clear_prefix( |
9b475e76 PG |
7405 | vty, vrfview, prefix, |
7406 | AFI_IP6, safi, NULL); | |
718e3744 | 7407 | } |
7408 | ||
b09b5ae0 DW |
7409 | DEFUN (show_bgp_views, |
7410 | show_bgp_views_cmd, | |
d6e3c605 | 7411 | "show [ip] bgp views", |
b09b5ae0 | 7412 | SHOW_STR |
d6e3c605 | 7413 | IP_STR |
01080f7c | 7414 | BGP_STR |
b09b5ae0 | 7415 | "Show the defined BGP views\n") |
01080f7c | 7416 | { |
d62a17ae | 7417 | struct list *inst = bm->bgp; |
7418 | struct listnode *node; | |
7419 | struct bgp *bgp; | |
01080f7c | 7420 | |
d62a17ae | 7421 | vty_out(vty, "Defined BGP views:\n"); |
7422 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7423 | /* Skip VRFs. */ | |
7424 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
7425 | continue; | |
7426 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
7427 | bgp->as); | |
7428 | } | |
e52702f2 | 7429 | |
d62a17ae | 7430 | return CMD_SUCCESS; |
e0081f70 ML |
7431 | } |
7432 | ||
8386ac43 | 7433 | DEFUN (show_bgp_vrfs, |
7434 | show_bgp_vrfs_cmd, | |
d6e3c605 | 7435 | "show [ip] bgp vrfs [json]", |
8386ac43 | 7436 | SHOW_STR |
d6e3c605 | 7437 | IP_STR |
8386ac43 | 7438 | BGP_STR |
7439 | "Show BGP VRFs\n" | |
9973d184 | 7440 | JSON_STR) |
8386ac43 | 7441 | { |
fe1dc5a3 | 7442 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 7443 | struct list *inst = bm->bgp; |
7444 | struct listnode *node; | |
7445 | struct bgp *bgp; | |
9f049418 | 7446 | bool uj = use_json(argc, argv); |
d62a17ae | 7447 | json_object *json = NULL; |
7448 | json_object *json_vrfs = NULL; | |
7449 | int count = 0; | |
d62a17ae | 7450 | |
d62a17ae | 7451 | if (uj) { |
7452 | json = json_object_new_object(); | |
7453 | json_vrfs = json_object_new_object(); | |
7454 | } | |
7455 | ||
7456 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7457 | const char *name, *type; | |
7458 | struct peer *peer; | |
7fe96307 | 7459 | struct listnode *node2, *nnode2; |
d62a17ae | 7460 | int peers_cfg, peers_estb; |
7461 | json_object *json_vrf = NULL; | |
d62a17ae | 7462 | |
7463 | /* Skip Views. */ | |
7464 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
7465 | continue; | |
7466 | ||
7467 | count++; | |
efb4077a | 7468 | if (!uj && count == 1) { |
fe1dc5a3 | 7469 | vty_out(vty, |
efb4077a | 7470 | "%4s %-5s %-16s %9s %10s %-37s\n", |
a4d82a8a | 7471 | "Type", "Id", "routerId", "#PeersVfg", |
efb4077a CS |
7472 | "#PeersEstb", "Name"); |
7473 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
7474 | "L3-VNI", "RouterMAC", "Interface"); | |
7475 | } | |
d62a17ae | 7476 | |
7477 | peers_cfg = peers_estb = 0; | |
7478 | if (uj) | |
7479 | json_vrf = json_object_new_object(); | |
7480 | ||
7481 | ||
7fe96307 | 7482 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 7483 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
7484 | continue; | |
7485 | peers_cfg++; | |
7486 | if (peer->status == Established) | |
7487 | peers_estb++; | |
7488 | } | |
7489 | ||
7490 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 7491 | name = VRF_DEFAULT_NAME; |
d62a17ae | 7492 | type = "DFLT"; |
7493 | } else { | |
7494 | name = bgp->name; | |
7495 | type = "VRF"; | |
7496 | } | |
7497 | ||
a8bf7d9c | 7498 | |
d62a17ae | 7499 | if (uj) { |
a4d82a8a PZ |
7500 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7501 | ? -1 | |
7502 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 7503 | json_object_string_add(json_vrf, "type", type); |
7504 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
7505 | json_object_string_add(json_vrf, "routerId", | |
7506 | inet_ntoa(bgp->router_id)); | |
7507 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
7508 | peers_cfg); | |
7509 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
7510 | peers_estb); | |
7511 | ||
fe1dc5a3 | 7512 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
7513 | json_object_string_add( |
7514 | json_vrf, "rmac", | |
7515 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
7516 | json_object_string_add(json_vrf, "interface", |
7517 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
7518 | bgp->vrf_id)); | |
d62a17ae | 7519 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 7520 | } else { |
fe1dc5a3 | 7521 | vty_out(vty, |
efb4077a | 7522 | "%4s %-5d %-16s %-9u %-10u %-37s\n", |
a4d82a8a PZ |
7523 | type, |
7524 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
7525 | : (int)bgp->vrf_id, | |
7526 | inet_ntoa(bgp->router_id), peers_cfg, | |
efb4077a CS |
7527 | peers_estb, name); |
7528 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", | |
7529 | bgp->l3vni, | |
7530 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
7531 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
7532 | bgp->vrf_id)); | |
7533 | } | |
d62a17ae | 7534 | } |
7535 | ||
7536 | if (uj) { | |
7537 | json_object_object_add(json, "vrfs", json_vrfs); | |
7538 | ||
7539 | json_object_int_add(json, "totalVrfs", count); | |
7540 | ||
996c9314 LB |
7541 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
7542 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 7543 | json_object_free(json); |
7544 | } else { | |
7545 | if (count) | |
7546 | vty_out(vty, | |
7547 | "\nTotal number of VRFs (including default): %d\n", | |
7548 | count); | |
7549 | } | |
7550 | ||
7551 | return CMD_SUCCESS; | |
8386ac43 | 7552 | } |
7553 | ||
48ecf8f5 DS |
7554 | DEFUN (show_bgp_mac_hash, |
7555 | show_bgp_mac_hash_cmd, | |
7556 | "show bgp mac hash", | |
7557 | SHOW_STR | |
7558 | BGP_STR | |
7559 | "Mac Address\n" | |
7560 | "Mac Address database\n") | |
7561 | { | |
7562 | bgp_mac_dump_table(vty); | |
7563 | ||
7564 | return CMD_SUCCESS; | |
7565 | } | |
acf71666 | 7566 | |
e3b78da8 | 7567 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 7568 | { |
0291c246 | 7569 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 7570 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 7571 | |
60466a63 | 7572 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
7573 | tip->refcnt); |
7574 | } | |
7575 | ||
7576 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
7577 | { | |
7578 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 7579 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
7580 | |
7581 | vty_out(vty, "Tunnel-ip database:\n"); | |
7582 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 7583 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
7584 | vty); |
7585 | } | |
7586 | ||
15c81ca4 DS |
7587 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
7588 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
7589 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
7590 | "martian next-hops\n" |
7591 | "martian next-hop database\n") | |
acf71666 | 7592 | { |
0291c246 | 7593 | struct bgp *bgp = NULL; |
15c81ca4 | 7594 | int idx = 0; |
9a8bdf1c PG |
7595 | char *name = NULL; |
7596 | ||
7597 | /* [<vrf> VIEWVRFNAME] */ | |
7598 | if (argv_find(argv, argc, "vrf", &idx)) { | |
7599 | name = argv[idx + 1]->arg; | |
7600 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
7601 | name = NULL; | |
7602 | } else if (argv_find(argv, argc, "view", &idx)) | |
7603 | /* [<view> VIEWVRFNAME] */ | |
7604 | name = argv[idx + 1]->arg; | |
7605 | if (name) | |
7606 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
7607 | else |
7608 | bgp = bgp_get_default(); | |
acf71666 | 7609 | |
acf71666 MK |
7610 | if (!bgp) { |
7611 | vty_out(vty, "%% No BGP process is configured\n"); | |
7612 | return CMD_WARNING; | |
7613 | } | |
7614 | bgp_show_martian_nexthops(vty, bgp); | |
7615 | ||
7616 | return CMD_SUCCESS; | |
7617 | } | |
7618 | ||
f412b39a | 7619 | DEFUN (show_bgp_memory, |
4bf6a362 | 7620 | show_bgp_memory_cmd, |
7fa12b13 | 7621 | "show [ip] bgp memory", |
4bf6a362 | 7622 | SHOW_STR |
3a2d747c | 7623 | IP_STR |
4bf6a362 PJ |
7624 | BGP_STR |
7625 | "Global BGP memory statistics\n") | |
7626 | { | |
d62a17ae | 7627 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
7628 | unsigned long count; | |
7629 | ||
7630 | /* RIB related usage stats */ | |
7631 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
7632 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
7633 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7634 | count * sizeof(struct bgp_node))); | |
7635 | ||
7636 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
7637 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
7638 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 7639 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 7640 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
7641 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
7642 | count, | |
4b7e6066 DS |
7643 | mtype_memstr( |
7644 | memstrbuf, sizeof(memstrbuf), | |
7645 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 7646 | |
7647 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
7648 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
7649 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7650 | count * sizeof(struct bgp_static))); | |
7651 | ||
7652 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
7653 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
7654 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7655 | count * sizeof(struct bpacket))); | |
7656 | ||
7657 | /* Adj-In/Out */ | |
7658 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
7659 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
7660 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7661 | count * sizeof(struct bgp_adj_in))); | |
7662 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
7663 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
7664 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7665 | count * sizeof(struct bgp_adj_out))); | |
7666 | ||
7667 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
7668 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
7669 | count, | |
7670 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7671 | count * sizeof(struct bgp_nexthop_cache))); | |
7672 | ||
7673 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
7674 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
7675 | count, | |
7676 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7677 | count * sizeof(struct bgp_damp_info))); | |
7678 | ||
7679 | /* Attributes */ | |
7680 | count = attr_count(); | |
7681 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
7682 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7683 | count * sizeof(struct attr))); | |
7684 | ||
7685 | if ((count = attr_unknown_count())) | |
7686 | vty_out(vty, "%ld unknown attributes\n", count); | |
7687 | ||
7688 | /* AS_PATH attributes */ | |
7689 | count = aspath_count(); | |
7690 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
7691 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7692 | count * sizeof(struct aspath))); | |
7693 | ||
7694 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
7695 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
7696 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7697 | count * sizeof(struct assegment))); | |
7698 | ||
7699 | /* Other attributes */ | |
7700 | if ((count = community_count())) | |
7701 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7702 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7703 | count * sizeof(struct community))); | |
d62a17ae | 7704 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
7705 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7706 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7707 | count * sizeof(struct ecommunity))); | |
d62a17ae | 7708 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
7709 | vty_out(vty, | |
7710 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
7711 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7712 | count * sizeof(struct lcommunity))); | |
d62a17ae | 7713 | |
7714 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
7715 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
7716 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7717 | count * sizeof(struct cluster_list))); | |
7718 | ||
7719 | /* Peer related usage */ | |
7720 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
7721 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
7722 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7723 | count * sizeof(struct peer))); | |
7724 | ||
7725 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
7726 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
7727 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7728 | count * sizeof(struct peer_group))); | |
7729 | ||
7730 | /* Other */ | |
d62a17ae | 7731 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
7732 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
7733 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7734 | count * sizeof(regex_t))); | |
d62a17ae | 7735 | return CMD_SUCCESS; |
4bf6a362 | 7736 | } |
fee0f4c6 | 7737 | |
57a9c8a8 DS |
7738 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
7739 | { | |
7740 | json_object *bestpath = json_object_new_object(); | |
7741 | ||
7742 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
7743 | json_object_string_add(bestpath, "asPath", "ignore"); | |
7744 | ||
7745 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
7746 | json_object_string_add(bestpath, "asPath", "confed"); | |
7747 | ||
7748 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
a4d82a8a PZ |
7749 | if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) |
7750 | json_object_string_add(bestpath, "multiPathRelax", | |
57a9c8a8 DS |
7751 | "as-set"); |
7752 | else | |
a4d82a8a | 7753 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
7754 | "true"); |
7755 | } else | |
a4d82a8a | 7756 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 DS |
7757 | |
7758 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
7759 | json_object_string_add(bestpath, "compareRouterId", "true"); | |
7760 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
7761 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
7762 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 7763 | json_object_string_add(bestpath, "med", "confed"); |
57a9c8a8 DS |
7764 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
7765 | json_object_string_add(bestpath, "med", | |
7766 | "missing-as-worst"); | |
7767 | else | |
7768 | json_object_string_add(bestpath, "med", "true"); | |
7769 | } | |
7770 | ||
7771 | json_object_object_add(json, "bestPath", bestpath); | |
7772 | } | |
7773 | ||
718e3744 | 7774 | /* Show BGP peer's summary information. */ |
d62a17ae | 7775 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
9f049418 | 7776 | bool use_json, json_object *json) |
d62a17ae | 7777 | { |
7778 | struct peer *peer; | |
7779 | struct listnode *node, *nnode; | |
7780 | unsigned int count = 0, dn_count = 0; | |
7781 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
7782 | char neighbor_buf[VTY_BUFSIZ]; | |
7783 | int neighbor_col_default_width = 16; | |
7784 | int len; | |
7785 | int max_neighbor_width = 0; | |
7786 | int pfx_rcd_safi; | |
7787 | json_object *json_peer = NULL; | |
7788 | json_object *json_peers = NULL; | |
50e05855 | 7789 | struct peer_af *paf; |
d62a17ae | 7790 | |
7791 | /* labeled-unicast routes are installed in the unicast table so in order | |
7792 | * to | |
7793 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
7794 | */ | |
7795 | if (safi == SAFI_LABELED_UNICAST) | |
7796 | pfx_rcd_safi = SAFI_UNICAST; | |
7797 | else | |
7798 | pfx_rcd_safi = safi; | |
7799 | ||
7800 | if (use_json) { | |
7801 | if (json == NULL) | |
7802 | json = json_object_new_object(); | |
7803 | ||
7804 | json_peers = json_object_new_object(); | |
7805 | } else { | |
7806 | /* Loop over all neighbors that will be displayed to determine | |
7807 | * how many | |
7808 | * characters are needed for the Neighbor column | |
7809 | */ | |
7810 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
7811 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7812 | continue; | |
7813 | ||
7814 | if (peer->afc[afi][safi]) { | |
7815 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7816 | if (peer_dynamic_neighbor(peer)) | |
7817 | dn_flag[0] = '*'; | |
7818 | ||
7819 | if (peer->hostname | |
7820 | && bgp_flag_check(bgp, | |
7821 | BGP_FLAG_SHOW_HOSTNAME)) | |
7822 | sprintf(neighbor_buf, "%s%s(%s) ", | |
7823 | dn_flag, peer->hostname, | |
7824 | peer->host); | |
7825 | else | |
7826 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
7827 | peer->host); | |
7828 | ||
7829 | len = strlen(neighbor_buf); | |
7830 | ||
7831 | if (len > max_neighbor_width) | |
7832 | max_neighbor_width = len; | |
7833 | } | |
7834 | } | |
f933309e | 7835 | |
d62a17ae | 7836 | /* Originally we displayed the Neighbor column as 16 |
7837 | * characters wide so make that the default | |
7838 | */ | |
7839 | if (max_neighbor_width < neighbor_col_default_width) | |
7840 | max_neighbor_width = neighbor_col_default_width; | |
7841 | } | |
f933309e | 7842 | |
d62a17ae | 7843 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
7844 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7845 | continue; | |
7846 | ||
ea47320b DL |
7847 | if (!peer->afc[afi][safi]) |
7848 | continue; | |
d62a17ae | 7849 | |
ea47320b DL |
7850 | if (!count) { |
7851 | unsigned long ents; | |
7852 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 7853 | int64_t vrf_id_ui; |
d62a17ae | 7854 | |
a4d82a8a PZ |
7855 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7856 | ? -1 | |
7857 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
7858 | |
7859 | /* Usage summary and header */ | |
7860 | if (use_json) { | |
7861 | json_object_string_add( | |
7862 | json, "routerId", | |
7863 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
7864 | json_object_int_add(json, "as", bgp->as); |
7865 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
7866 | json_object_string_add( |
7867 | json, "vrfName", | |
7868 | (bgp->inst_type | |
7869 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 7870 | ? VRF_DEFAULT_NAME |
ea47320b DL |
7871 | : bgp->name); |
7872 | } else { | |
7873 | vty_out(vty, | |
7874 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 7875 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
7876 | bgp->vrf_id == VRF_UNKNOWN |
7877 | ? -1 | |
7878 | : (int)bgp->vrf_id); | |
ea47320b DL |
7879 | vty_out(vty, "\n"); |
7880 | } | |
d62a17ae | 7881 | |
ea47320b | 7882 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 7883 | if (use_json) { |
ea47320b | 7884 | json_object_int_add( |
60466a63 | 7885 | json, "updateDelayLimit", |
ea47320b | 7886 | bgp->v_update_delay); |
d62a17ae | 7887 | |
ea47320b DL |
7888 | if (bgp->v_update_delay |
7889 | != bgp->v_establish_wait) | |
d62a17ae | 7890 | json_object_int_add( |
7891 | json, | |
ea47320b DL |
7892 | "updateDelayEstablishWait", |
7893 | bgp->v_establish_wait); | |
d62a17ae | 7894 | |
60466a63 | 7895 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
7896 | json_object_string_add( |
7897 | json, | |
7898 | "updateDelayFirstNeighbor", | |
7899 | bgp->update_delay_begin_time); | |
7900 | json_object_boolean_true_add( | |
7901 | json, | |
7902 | "updateDelayInProgress"); | |
7903 | } else { | |
7904 | if (bgp->update_delay_over) { | |
d62a17ae | 7905 | json_object_string_add( |
7906 | json, | |
7907 | "updateDelayFirstNeighbor", | |
7908 | bgp->update_delay_begin_time); | |
ea47320b | 7909 | json_object_string_add( |
d62a17ae | 7910 | json, |
ea47320b DL |
7911 | "updateDelayBestpathResumed", |
7912 | bgp->update_delay_end_time); | |
7913 | json_object_string_add( | |
d62a17ae | 7914 | json, |
ea47320b DL |
7915 | "updateDelayZebraUpdateResume", |
7916 | bgp->update_delay_zebra_resume_time); | |
7917 | json_object_string_add( | |
7918 | json, | |
7919 | "updateDelayPeerUpdateResume", | |
7920 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 7921 | } |
ea47320b DL |
7922 | } |
7923 | } else { | |
7924 | vty_out(vty, | |
7925 | "Read-only mode update-delay limit: %d seconds\n", | |
7926 | bgp->v_update_delay); | |
7927 | if (bgp->v_update_delay | |
7928 | != bgp->v_establish_wait) | |
d62a17ae | 7929 | vty_out(vty, |
ea47320b DL |
7930 | " Establish wait: %d seconds\n", |
7931 | bgp->v_establish_wait); | |
d62a17ae | 7932 | |
60466a63 | 7933 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
7934 | vty_out(vty, |
7935 | " First neighbor established: %s\n", | |
7936 | bgp->update_delay_begin_time); | |
7937 | vty_out(vty, | |
7938 | " Delay in progress\n"); | |
7939 | } else { | |
7940 | if (bgp->update_delay_over) { | |
d62a17ae | 7941 | vty_out(vty, |
7942 | " First neighbor established: %s\n", | |
7943 | bgp->update_delay_begin_time); | |
7944 | vty_out(vty, | |
ea47320b DL |
7945 | " Best-paths resumed: %s\n", |
7946 | bgp->update_delay_end_time); | |
7947 | vty_out(vty, | |
7948 | " zebra update resumed: %s\n", | |
7949 | bgp->update_delay_zebra_resume_time); | |
7950 | vty_out(vty, | |
7951 | " peers update resumed: %s\n", | |
7952 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 7953 | } |
7954 | } | |
7955 | } | |
ea47320b | 7956 | } |
d62a17ae | 7957 | |
ea47320b DL |
7958 | if (use_json) { |
7959 | if (bgp_maxmed_onstartup_configured(bgp) | |
7960 | && bgp->maxmed_active) | |
7961 | json_object_boolean_true_add( | |
60466a63 | 7962 | json, "maxMedOnStartup"); |
ea47320b DL |
7963 | if (bgp->v_maxmed_admin) |
7964 | json_object_boolean_true_add( | |
60466a63 | 7965 | json, "maxMedAdministrative"); |
d62a17ae | 7966 | |
ea47320b DL |
7967 | json_object_int_add( |
7968 | json, "tableVersion", | |
60466a63 | 7969 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 7970 | |
60466a63 QY |
7971 | ents = bgp_table_count(bgp->rib[afi][safi]); |
7972 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
7973 | json_object_int_add( |
7974 | json, "ribMemory", | |
7975 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 7976 | |
210ec2a0 | 7977 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
7978 | json_object_int_add(json, "peerCount", ents); |
7979 | json_object_int_add(json, "peerMemory", | |
7980 | ents * sizeof(struct peer)); | |
d62a17ae | 7981 | |
ea47320b DL |
7982 | if ((ents = listcount(bgp->group))) { |
7983 | json_object_int_add( | |
60466a63 | 7984 | json, "peerGroupCount", ents); |
ea47320b DL |
7985 | json_object_int_add( |
7986 | json, "peerGroupMemory", | |
996c9314 LB |
7987 | ents * sizeof(struct |
7988 | peer_group)); | |
ea47320b | 7989 | } |
d62a17ae | 7990 | |
ea47320b DL |
7991 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
7992 | BGP_CONFIG_DAMPENING)) | |
7993 | json_object_boolean_true_add( | |
60466a63 | 7994 | json, "dampeningEnabled"); |
ea47320b DL |
7995 | } else { |
7996 | if (bgp_maxmed_onstartup_configured(bgp) | |
7997 | && bgp->maxmed_active) | |
d62a17ae | 7998 | vty_out(vty, |
ea47320b DL |
7999 | "Max-med on-startup active\n"); |
8000 | if (bgp->v_maxmed_admin) | |
d62a17ae | 8001 | vty_out(vty, |
ea47320b | 8002 | "Max-med administrative active\n"); |
d62a17ae | 8003 | |
60466a63 QY |
8004 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
8005 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 8006 | |
60466a63 | 8007 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
8008 | vty_out(vty, |
8009 | "RIB entries %ld, using %s of memory\n", | |
8010 | ents, | |
996c9314 LB |
8011 | mtype_memstr(memstrbuf, |
8012 | sizeof(memstrbuf), | |
8013 | ents * sizeof(struct | |
8014 | bgp_node))); | |
ea47320b DL |
8015 | |
8016 | /* Peer related usage */ | |
210ec2a0 | 8017 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 8018 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
8019 | ents, |
8020 | mtype_memstr( | |
60466a63 QY |
8021 | memstrbuf, sizeof(memstrbuf), |
8022 | ents * sizeof(struct peer))); | |
ea47320b DL |
8023 | |
8024 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 8025 | vty_out(vty, |
ea47320b | 8026 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 8027 | ents, |
8028 | mtype_memstr( | |
8029 | memstrbuf, | |
8030 | sizeof(memstrbuf), | |
996c9314 LB |
8031 | ents * sizeof(struct |
8032 | peer_group))); | |
d62a17ae | 8033 | |
ea47320b DL |
8034 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8035 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 8036 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 8037 | vty_out(vty, "\n"); |
d62a17ae | 8038 | |
ea47320b DL |
8039 | /* Subtract 8 here because 'Neighbor' is |
8040 | * 8 characters */ | |
8041 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
8042 | vty_out(vty, "%*s", max_neighbor_width - 8, |
8043 | " "); | |
ea47320b DL |
8044 | vty_out(vty, |
8045 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); | |
d62a17ae | 8046 | } |
ea47320b | 8047 | } |
d62a17ae | 8048 | |
ea47320b | 8049 | count++; |
d62a17ae | 8050 | |
ea47320b DL |
8051 | if (use_json) { |
8052 | json_peer = json_object_new_object(); | |
d62a17ae | 8053 | |
b4e9dcba DD |
8054 | if (peer_dynamic_neighbor(peer)) { |
8055 | dn_count++; | |
60466a63 QY |
8056 | json_object_boolean_true_add(json_peer, |
8057 | "dynamicPeer"); | |
b4e9dcba | 8058 | } |
d62a17ae | 8059 | |
ea47320b | 8060 | if (peer->hostname) |
60466a63 | 8061 | json_object_string_add(json_peer, "hostname", |
ea47320b | 8062 | peer->hostname); |
d62a17ae | 8063 | |
ea47320b | 8064 | if (peer->domainname) |
60466a63 QY |
8065 | json_object_string_add(json_peer, "domainname", |
8066 | peer->domainname); | |
d62a17ae | 8067 | |
60466a63 | 8068 | json_object_int_add(json_peer, "remoteAs", peer->as); |
ea47320b | 8069 | json_object_int_add(json_peer, "version", 4); |
60466a63 | 8070 | json_object_int_add(json_peer, "msgRcvd", |
0112e9e0 | 8071 | PEER_TOTAL_RX(peer)); |
60466a63 | 8072 | json_object_int_add(json_peer, "msgSent", |
0112e9e0 | 8073 | PEER_TOTAL_TX(peer)); |
ea47320b DL |
8074 | |
8075 | json_object_int_add(json_peer, "tableVersion", | |
8076 | peer->version[afi][safi]); | |
8077 | json_object_int_add(json_peer, "outq", | |
8078 | peer->obuf->count); | |
8079 | json_object_int_add(json_peer, "inq", 0); | |
60466a63 QY |
8080 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
8081 | use_json, json_peer); | |
50e05855 AD |
8082 | |
8083 | /* | |
8084 | * Adding "pfxRcd" field to match with the corresponding | |
8085 | * CLI. "prefixReceivedCount" will be deprecated in | |
8086 | * future. | |
8087 | */ | |
60466a63 QY |
8088 | json_object_int_add(json_peer, "prefixReceivedCount", |
8089 | peer->pcount[afi][pfx_rcd_safi]); | |
50e05855 AD |
8090 | json_object_int_add(json_peer, "pfxRcd", |
8091 | peer->pcount[afi][pfx_rcd_safi]); | |
8092 | ||
8093 | paf = peer_af_find(peer, afi, pfx_rcd_safi); | |
8094 | if (paf && PAF_SUBGRP(paf)) | |
8095 | json_object_int_add(json_peer, | |
8096 | "pfxSnt", | |
8097 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 8098 | |
ea47320b | 8099 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
60466a63 | 8100 | json_object_string_add(json_peer, "state", |
ea47320b | 8101 | "Idle (Admin)"); |
9199a725 TM |
8102 | else if (peer->afc_recv[afi][safi]) |
8103 | json_object_string_add( | |
8104 | json_peer, "state", | |
8105 | lookup_msg(bgp_status_msg, peer->status, | |
8106 | NULL)); | |
60466a63 QY |
8107 | else if (CHECK_FLAG(peer->sflags, |
8108 | PEER_STATUS_PREFIX_OVERFLOW)) | |
8109 | json_object_string_add(json_peer, "state", | |
ea47320b DL |
8110 | "Idle (PfxCt)"); |
8111 | else | |
8112 | json_object_string_add( | |
8113 | json_peer, "state", | |
60466a63 QY |
8114 | lookup_msg(bgp_status_msg, peer->status, |
8115 | NULL)); | |
ea47320b DL |
8116 | |
8117 | if (peer->conf_if) | |
60466a63 | 8118 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
8119 | "interface"); |
8120 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
8121 | json_object_string_add(json_peer, "idType", |
8122 | "ipv4"); | |
ea47320b | 8123 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
8124 | json_object_string_add(json_peer, "idType", |
8125 | "ipv6"); | |
d62a17ae | 8126 | |
ea47320b DL |
8127 | json_object_object_add(json_peers, peer->host, |
8128 | json_peer); | |
8129 | } else { | |
8130 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8131 | if (peer_dynamic_neighbor(peer)) { | |
8132 | dn_count++; | |
8133 | dn_flag[0] = '*'; | |
8134 | } | |
d62a17ae | 8135 | |
ea47320b | 8136 | if (peer->hostname |
60466a63 | 8137 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
ea47320b | 8138 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
60466a63 | 8139 | peer->hostname, peer->host); |
ea47320b | 8140 | else |
60466a63 | 8141 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
ea47320b DL |
8142 | |
8143 | /* pad the neighbor column with spaces */ | |
8144 | if (len < max_neighbor_width) | |
60466a63 QY |
8145 | vty_out(vty, "%*s", max_neighbor_width - len, |
8146 | " "); | |
ea47320b | 8147 | |
86a55b99 | 8148 | vty_out(vty, "4 %10u %7u %7u %8" PRIu64 " %4d %4zd %8s", |
0112e9e0 QY |
8149 | peer->as, PEER_TOTAL_RX(peer), |
8150 | PEER_TOTAL_TX(peer), peer->version[afi][safi], | |
8151 | 0, peer->obuf->count, | |
d62a17ae | 8152 | peer_uptime(peer->uptime, timebuf, |
ea47320b | 8153 | BGP_UPTIME_LEN, 0, NULL)); |
d62a17ae | 8154 | |
ea47320b | 8155 | if (peer->status == Established) |
2f8f4f10 | 8156 | if (peer->afc_recv[afi][safi]) |
95077abf | 8157 | vty_out(vty, " %12ld", |
a4d82a8a PZ |
8158 | peer->pcount[afi] |
8159 | [pfx_rcd_safi]); | |
95077abf DW |
8160 | else |
8161 | vty_out(vty, " NoNeg"); | |
ea47320b | 8162 | else { |
60466a63 | 8163 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
ea47320b | 8164 | vty_out(vty, " Idle (Admin)"); |
60466a63 QY |
8165 | else if (CHECK_FLAG( |
8166 | peer->sflags, | |
8167 | PEER_STATUS_PREFIX_OVERFLOW)) | |
ea47320b | 8168 | vty_out(vty, " Idle (PfxCt)"); |
d62a17ae | 8169 | else |
ea47320b | 8170 | vty_out(vty, " %12s", |
60466a63 QY |
8171 | lookup_msg(bgp_status_msg, |
8172 | peer->status, NULL)); | |
d62a17ae | 8173 | } |
ea47320b | 8174 | vty_out(vty, "\n"); |
d62a17ae | 8175 | } |
8176 | } | |
f933309e | 8177 | |
d62a17ae | 8178 | if (use_json) { |
8179 | json_object_object_add(json, "peers", json_peers); | |
8180 | ||
8181 | json_object_int_add(json, "totalPeers", count); | |
8182 | json_object_int_add(json, "dynamicPeers", dn_count); | |
8183 | ||
57a9c8a8 DS |
8184 | bgp_show_bestpath_json(bgp, json); |
8185 | ||
996c9314 LB |
8186 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8187 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8188 | json_object_free(json); |
8189 | } else { | |
8190 | if (count) | |
8191 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8192 | else { | |
d6ceaca3 | 8193 | vty_out(vty, "No %s neighbor is configured\n", |
8194 | afi_safi_print(afi, safi)); | |
d62a17ae | 8195 | } |
b05a1c8b | 8196 | |
d6ceaca3 | 8197 | if (dn_count) { |
d62a17ae | 8198 | vty_out(vty, "* - dynamic neighbor\n"); |
8199 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
8200 | dn_count, bgp->dynamic_neighbors_limit); | |
8201 | } | |
8202 | } | |
1ff9a340 | 8203 | |
d62a17ae | 8204 | return CMD_SUCCESS; |
718e3744 | 8205 | } |
8206 | ||
d62a17ae | 8207 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
9f049418 | 8208 | int safi, bool use_json, |
d62a17ae | 8209 | json_object *json) |
8210 | { | |
8211 | int is_first = 1; | |
8212 | int afi_wildcard = (afi == AFI_MAX); | |
8213 | int safi_wildcard = (safi == SAFI_MAX); | |
8214 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 8215 | bool nbr_output = false; |
d62a17ae | 8216 | |
8217 | if (use_json && is_wildcard) | |
8218 | vty_out(vty, "{\n"); | |
8219 | if (afi_wildcard) | |
8220 | afi = 1; /* AFI_IP */ | |
8221 | while (afi < AFI_MAX) { | |
8222 | if (safi_wildcard) | |
8223 | safi = 1; /* SAFI_UNICAST */ | |
8224 | while (safi < SAFI_MAX) { | |
318cac96 | 8225 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 8226 | nbr_output = true; |
d62a17ae | 8227 | if (is_wildcard) { |
8228 | /* | |
8229 | * So limit output to those afi/safi | |
8230 | * pairs that | |
8231 | * actualy have something interesting in | |
8232 | * them | |
8233 | */ | |
8234 | if (use_json) { | |
8235 | json = json_object_new_object(); | |
8236 | ||
8237 | if (!is_first) | |
8238 | vty_out(vty, ",\n"); | |
8239 | else | |
8240 | is_first = 0; | |
8241 | ||
8242 | vty_out(vty, "\"%s\":", | |
8243 | afi_safi_json(afi, | |
8244 | safi)); | |
8245 | } else { | |
8246 | vty_out(vty, "\n%s Summary:\n", | |
8247 | afi_safi_print(afi, | |
8248 | safi)); | |
8249 | } | |
8250 | } | |
8251 | bgp_show_summary(vty, bgp, afi, safi, use_json, | |
8252 | json); | |
8253 | } | |
8254 | safi++; | |
d62a17ae | 8255 | if (!safi_wildcard) |
8256 | safi = SAFI_MAX; | |
8257 | } | |
8258 | afi++; | |
ee851c8c | 8259 | if (!afi_wildcard) |
d62a17ae | 8260 | afi = AFI_MAX; |
8261 | } | |
8262 | ||
8263 | if (use_json && is_wildcard) | |
8264 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
8265 | else if (!nbr_output) { |
8266 | if (use_json) | |
8267 | vty_out(vty, "{}\n"); | |
8268 | else | |
8269 | vty_out(vty, "%% No BGP neighbors found\n"); | |
8270 | } | |
d62a17ae | 8271 | } |
8272 | ||
8273 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
9f049418 | 8274 | safi_t safi, bool use_json) |
d62a17ae | 8275 | { |
8276 | struct listnode *node, *nnode; | |
8277 | struct bgp *bgp; | |
8278 | json_object *json = NULL; | |
8279 | int is_first = 1; | |
9f049418 | 8280 | bool nbr_output = false; |
d62a17ae | 8281 | |
8282 | if (use_json) | |
8283 | vty_out(vty, "{\n"); | |
8284 | ||
8285 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 8286 | nbr_output = true; |
d62a17ae | 8287 | if (use_json) { |
8288 | json = json_object_new_object(); | |
8289 | ||
8290 | if (!is_first) | |
8291 | vty_out(vty, ",\n"); | |
8292 | else | |
8293 | is_first = 0; | |
8294 | ||
8295 | vty_out(vty, "\"%s\":", | |
8296 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8297 | ? VRF_DEFAULT_NAME |
d62a17ae | 8298 | : bgp->name); |
8299 | } else { | |
8300 | vty_out(vty, "\nInstance %s:\n", | |
8301 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8302 | ? VRF_DEFAULT_NAME |
d62a17ae | 8303 | : bgp->name); |
8304 | } | |
8305 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, json); | |
8306 | } | |
8307 | ||
8308 | if (use_json) | |
8309 | vty_out(vty, "}\n"); | |
9f049418 DS |
8310 | else if (!nbr_output) |
8311 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 8312 | } |
8313 | ||
8314 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
9f049418 | 8315 | safi_t safi, bool use_json) |
d62a17ae | 8316 | { |
8317 | struct bgp *bgp; | |
8318 | ||
8319 | if (name) { | |
8320 | if (strmatch(name, "all")) { | |
8321 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
8322 | use_json); | |
8323 | return CMD_SUCCESS; | |
8324 | } else { | |
8325 | bgp = bgp_lookup_by_name(name); | |
8326 | ||
8327 | if (!bgp) { | |
8328 | if (use_json) | |
8329 | vty_out(vty, "{}\n"); | |
8330 | else | |
8331 | vty_out(vty, | |
ca61fd25 | 8332 | "%% BGP instance not found\n"); |
d62a17ae | 8333 | return CMD_WARNING; |
8334 | } | |
8335 | ||
8336 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, | |
8337 | NULL); | |
8338 | return CMD_SUCCESS; | |
8339 | } | |
8340 | } | |
8341 | ||
8342 | bgp = bgp_get_default(); | |
8343 | ||
8344 | if (bgp) | |
8345 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, NULL); | |
9f049418 | 8346 | else { |
ca61fd25 DS |
8347 | if (use_json) |
8348 | vty_out(vty, "{}\n"); | |
8349 | else | |
8350 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
8351 | return CMD_WARNING; |
8352 | } | |
d62a17ae | 8353 | |
8354 | return CMD_SUCCESS; | |
4fb25c53 DW |
8355 | } |
8356 | ||
716b2d8a | 8357 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 8358 | DEFUN (show_ip_bgp_summary, |
718e3744 | 8359 | show_ip_bgp_summary_cmd, |
dd6bd0f1 | 8360 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [json]", |
718e3744 | 8361 | SHOW_STR |
8362 | IP_STR | |
8363 | BGP_STR | |
8386ac43 | 8364 | BGP_INSTANCE_HELP_STR |
46f296b4 | 8365 | BGP_AFI_HELP_STR |
dd6bd0f1 | 8366 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 8367 | "Summary of BGP neighbor status\n" |
9973d184 | 8368 | JSON_STR) |
718e3744 | 8369 | { |
d62a17ae | 8370 | char *vrf = NULL; |
8371 | afi_t afi = AFI_MAX; | |
8372 | safi_t safi = SAFI_MAX; | |
8373 | ||
8374 | int idx = 0; | |
8375 | ||
8376 | /* show [ip] bgp */ | |
8377 | if (argv_find(argv, argc, "ip", &idx)) | |
8378 | afi = AFI_IP; | |
9a8bdf1c PG |
8379 | /* [<vrf> VIEWVRFNAME] */ |
8380 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8381 | vrf = argv[idx + 1]->arg; | |
8382 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8383 | vrf = NULL; | |
8384 | } else if (argv_find(argv, argc, "view", &idx)) | |
8385 | /* [<view> VIEWVRFNAME] */ | |
8386 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 8387 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8388 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
8389 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8390 | } | |
8391 | ||
9f049418 | 8392 | bool uj = use_json(argc, argv); |
d62a17ae | 8393 | |
8394 | return bgp_show_summary_vty(vty, vrf, afi, safi, uj); | |
8395 | } | |
8396 | ||
8397 | const char *afi_safi_print(afi_t afi, safi_t safi) | |
8398 | { | |
8399 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8400 | return "IPv4 Unicast"; | |
8401 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8402 | return "IPv4 Multicast"; | |
8403 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8404 | return "IPv4 Labeled Unicast"; | |
8405 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8406 | return "IPv4 VPN"; | |
8407 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8408 | return "IPv4 Encap"; | |
7c40bf39 | 8409 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8410 | return "IPv4 Flowspec"; | |
d62a17ae | 8411 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8412 | return "IPv6 Unicast"; | |
8413 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8414 | return "IPv6 Multicast"; | |
8415 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8416 | return "IPv6 Labeled Unicast"; | |
8417 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8418 | return "IPv6 VPN"; | |
8419 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8420 | return "IPv6 Encap"; | |
7c40bf39 | 8421 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8422 | return "IPv6 Flowspec"; | |
d62a17ae | 8423 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8424 | return "L2VPN EVPN"; | |
8425 | else | |
8426 | return "Unknown"; | |
538621f2 | 8427 | } |
8428 | ||
b9f77ec8 DS |
8429 | /* |
8430 | * Please note that we have intentionally camelCased | |
8431 | * the return strings here. So if you want | |
8432 | * to use this function, please ensure you | |
8433 | * are doing this within json output | |
8434 | */ | |
d62a17ae | 8435 | const char *afi_safi_json(afi_t afi, safi_t safi) |
8436 | { | |
8437 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8438 | return "ipv4Unicast"; | |
8439 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8440 | return "ipv4Multicast"; | |
8441 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8442 | return "ipv4LabeledUnicast"; | |
8443 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8444 | return "ipv4Vpn"; | |
8445 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8446 | return "ipv4Encap"; | |
7c40bf39 | 8447 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8448 | return "ipv4Flowspec"; | |
d62a17ae | 8449 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8450 | return "ipv6Unicast"; | |
8451 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8452 | return "ipv6Multicast"; | |
8453 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8454 | return "ipv6LabeledUnicast"; | |
8455 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8456 | return "ipv6Vpn"; | |
8457 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8458 | return "ipv6Encap"; | |
7c40bf39 | 8459 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8460 | return "ipv6Flowspec"; | |
d62a17ae | 8461 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8462 | return "l2VpnEvpn"; | |
8463 | else | |
8464 | return "Unknown"; | |
27162734 LB |
8465 | } |
8466 | ||
718e3744 | 8467 | /* Show BGP peer's information. */ |
d1927ebe | 8468 | enum show_type { show_all, show_peer, show_ipv4_all, show_ipv6_all, show_ipv4_peer, show_ipv6_peer }; |
d62a17ae | 8469 | |
8470 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
8471 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
8472 | uint16_t adv_smcap, uint16_t adv_rmcap, |
8473 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 8474 | bool use_json, json_object *json_pref) |
d62a17ae | 8475 | { |
8476 | /* Send-Mode */ | |
8477 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8478 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
8479 | if (use_json) { | |
8480 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8481 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8482 | json_object_string_add(json_pref, "sendMode", | |
8483 | "advertisedAndReceived"); | |
8484 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8485 | json_object_string_add(json_pref, "sendMode", | |
8486 | "advertised"); | |
8487 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8488 | json_object_string_add(json_pref, "sendMode", | |
8489 | "received"); | |
8490 | } else { | |
8491 | vty_out(vty, " Send-mode: "); | |
8492 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8493 | vty_out(vty, "advertised"); | |
8494 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8495 | vty_out(vty, "%sreceived", | |
8496 | CHECK_FLAG(p->af_cap[afi][safi], | |
8497 | adv_smcap) | |
8498 | ? ", " | |
8499 | : ""); | |
8500 | vty_out(vty, "\n"); | |
8501 | } | |
8502 | } | |
8503 | ||
8504 | /* Receive-Mode */ | |
8505 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8506 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
8507 | if (use_json) { | |
8508 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8509 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8510 | json_object_string_add(json_pref, "recvMode", | |
8511 | "advertisedAndReceived"); | |
8512 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8513 | json_object_string_add(json_pref, "recvMode", | |
8514 | "advertised"); | |
8515 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8516 | json_object_string_add(json_pref, "recvMode", | |
8517 | "received"); | |
8518 | } else { | |
8519 | vty_out(vty, " Receive-mode: "); | |
8520 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8521 | vty_out(vty, "advertised"); | |
8522 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8523 | vty_out(vty, "%sreceived", | |
8524 | CHECK_FLAG(p->af_cap[afi][safi], | |
8525 | adv_rmcap) | |
8526 | ? ", " | |
8527 | : ""); | |
8528 | vty_out(vty, "\n"); | |
8529 | } | |
8530 | } | |
8531 | } | |
8532 | ||
8533 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, | |
9f049418 | 8534 | safi_t safi, bool use_json, |
d62a17ae | 8535 | json_object *json_neigh) |
8536 | { | |
0291c246 MK |
8537 | struct bgp_filter *filter; |
8538 | struct peer_af *paf; | |
8539 | char orf_pfx_name[BUFSIZ]; | |
8540 | int orf_pfx_count; | |
8541 | json_object *json_af = NULL; | |
8542 | json_object *json_prefA = NULL; | |
8543 | json_object *json_prefB = NULL; | |
8544 | json_object *json_addr = NULL; | |
d62a17ae | 8545 | |
8546 | if (use_json) { | |
8547 | json_addr = json_object_new_object(); | |
8548 | json_af = json_object_new_object(); | |
8549 | filter = &p->filter[afi][safi]; | |
8550 | ||
8551 | if (peer_group_active(p)) | |
8552 | json_object_string_add(json_addr, "peerGroupMember", | |
8553 | p->group->name); | |
8554 | ||
8555 | paf = peer_af_find(p, afi, safi); | |
8556 | if (paf && PAF_SUBGRP(paf)) { | |
8557 | json_object_int_add(json_addr, "updateGroupId", | |
8558 | PAF_UPDGRP(paf)->id); | |
8559 | json_object_int_add(json_addr, "subGroupId", | |
8560 | PAF_SUBGRP(paf)->id); | |
8561 | json_object_int_add(json_addr, "packetQueueLength", | |
8562 | bpacket_queue_virtual_length(paf)); | |
8563 | } | |
8564 | ||
8565 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8566 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8567 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8568 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8569 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8570 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8571 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8572 | json_object_int_add(json_af, "orfType", | |
8573 | ORF_TYPE_PREFIX); | |
8574 | json_prefA = json_object_new_object(); | |
8575 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
8576 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
8577 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8578 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8579 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
8580 | use_json, json_prefA); | |
8581 | json_object_object_add(json_af, "orfPrefixList", | |
8582 | json_prefA); | |
8583 | } | |
8584 | ||
8585 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8586 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8587 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8588 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8589 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8590 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8591 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8592 | json_object_int_add(json_af, "orfOldType", | |
8593 | ORF_TYPE_PREFIX_OLD); | |
8594 | json_prefB = json_object_new_object(); | |
8595 | bgp_show_peer_afi_orf_cap( | |
8596 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8597 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8598 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8599 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
8600 | json_prefB); | |
8601 | json_object_object_add(json_af, "orfOldPrefixList", | |
8602 | json_prefB); | |
8603 | } | |
8604 | ||
8605 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8606 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8607 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8608 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8609 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8610 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8611 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8612 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8613 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8614 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8615 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8616 | json_object_object_add(json_addr, "afDependentCap", | |
8617 | json_af); | |
8618 | else | |
8619 | json_object_free(json_af); | |
8620 | ||
8621 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8622 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8623 | NULL, afi, orf_pfx_name, use_json); | |
8624 | ||
8625 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8626 | PEER_STATUS_ORF_PREFIX_SEND) | |
8627 | || orf_pfx_count) { | |
8628 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8629 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8630 | json_object_boolean_true_add(json_neigh, | |
8631 | "orfSent"); | |
8632 | if (orf_pfx_count) | |
8633 | json_object_int_add(json_addr, "orfRecvCounter", | |
8634 | orf_pfx_count); | |
8635 | } | |
8636 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8637 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8638 | json_object_string_add( | |
8639 | json_addr, "orfFirstUpdate", | |
8640 | "deferredUntilORFOrRouteRefreshRecvd"); | |
8641 | ||
8642 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8643 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8644 | json_object_boolean_true_add(json_addr, | |
8645 | "routeReflectorClient"); | |
8646 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8647 | PEER_FLAG_RSERVER_CLIENT)) | |
8648 | json_object_boolean_true_add(json_addr, | |
8649 | "routeServerClient"); | |
8650 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8651 | json_object_boolean_true_add(json_addr, | |
8652 | "inboundSoftConfigPermit"); | |
8653 | ||
8654 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8655 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8656 | json_object_boolean_true_add( | |
8657 | json_addr, | |
8658 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
8659 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8660 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8661 | json_object_boolean_true_add( | |
8662 | json_addr, | |
8663 | "privateAsNumsReplacedInUpdatesToNbr"); | |
8664 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8665 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8666 | json_object_boolean_true_add( | |
8667 | json_addr, | |
8668 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
8669 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8670 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8671 | json_object_boolean_true_add( | |
8672 | json_addr, | |
8673 | "privateAsNumsRemovedInUpdatesToNbr"); | |
8674 | ||
dcc68b5e MS |
8675 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
8676 | json_object_boolean_true_add( | |
8677 | json_addr, | |
8678 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
8679 | ->type_json_name); | |
d62a17ae | 8680 | |
8681 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8682 | json_object_string_add(json_addr, | |
8683 | "overrideASNsInOutboundUpdates", | |
8684 | "ifAspathEqualRemoteAs"); | |
8685 | ||
8686 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8687 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8688 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8689 | json_object_boolean_true_add(json_addr, | |
8690 | "routerAlwaysNextHop"); | |
8691 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8692 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8693 | json_object_boolean_true_add( | |
8694 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
8695 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8696 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
8697 | json_object_boolean_true_add( | |
8698 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
8699 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
8700 | json_object_boolean_true_add( | |
8701 | json_addr, "unchangedMedPropogatedToNbr"); | |
8702 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
8703 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8704 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
8705 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8706 | PEER_FLAG_SEND_COMMUNITY) | |
8707 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8708 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8709 | json_object_string_add(json_addr, | |
8710 | "commAttriSentToNbr", | |
8711 | "extendedAndStandard"); | |
8712 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8713 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8714 | json_object_string_add(json_addr, | |
8715 | "commAttriSentToNbr", | |
8716 | "extended"); | |
8717 | else | |
8718 | json_object_string_add(json_addr, | |
8719 | "commAttriSentToNbr", | |
8720 | "standard"); | |
8721 | } | |
8722 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8723 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
8724 | if (p->default_rmap[afi][safi].name) | |
8725 | json_object_string_add( | |
8726 | json_addr, "defaultRouteMap", | |
8727 | p->default_rmap[afi][safi].name); | |
8728 | ||
8729 | if (paf && PAF_SUBGRP(paf) | |
8730 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
8731 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
8732 | json_object_boolean_true_add(json_addr, | |
8733 | "defaultSent"); | |
8734 | else | |
8735 | json_object_boolean_true_add(json_addr, | |
8736 | "defaultNotSent"); | |
8737 | } | |
8738 | ||
dff8f48d | 8739 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 8740 | if (is_evpn_enabled()) |
60466a63 QY |
8741 | json_object_boolean_true_add( |
8742 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
8743 | } |
8744 | ||
d62a17ae | 8745 | if (filter->plist[FILTER_IN].name |
8746 | || filter->dlist[FILTER_IN].name | |
8747 | || filter->aslist[FILTER_IN].name | |
8748 | || filter->map[RMAP_IN].name) | |
8749 | json_object_boolean_true_add(json_addr, | |
8750 | "inboundPathPolicyConfig"); | |
8751 | if (filter->plist[FILTER_OUT].name | |
8752 | || filter->dlist[FILTER_OUT].name | |
8753 | || filter->aslist[FILTER_OUT].name | |
8754 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
8755 | json_object_boolean_true_add( | |
8756 | json_addr, "outboundPathPolicyConfig"); | |
8757 | ||
8758 | /* prefix-list */ | |
8759 | if (filter->plist[FILTER_IN].name) | |
8760 | json_object_string_add(json_addr, | |
8761 | "incomingUpdatePrefixFilterList", | |
8762 | filter->plist[FILTER_IN].name); | |
8763 | if (filter->plist[FILTER_OUT].name) | |
8764 | json_object_string_add(json_addr, | |
8765 | "outgoingUpdatePrefixFilterList", | |
8766 | filter->plist[FILTER_OUT].name); | |
8767 | ||
8768 | /* distribute-list */ | |
8769 | if (filter->dlist[FILTER_IN].name) | |
8770 | json_object_string_add( | |
8771 | json_addr, "incomingUpdateNetworkFilterList", | |
8772 | filter->dlist[FILTER_IN].name); | |
8773 | if (filter->dlist[FILTER_OUT].name) | |
8774 | json_object_string_add( | |
8775 | json_addr, "outgoingUpdateNetworkFilterList", | |
8776 | filter->dlist[FILTER_OUT].name); | |
8777 | ||
8778 | /* filter-list. */ | |
8779 | if (filter->aslist[FILTER_IN].name) | |
8780 | json_object_string_add(json_addr, | |
8781 | "incomingUpdateAsPathFilterList", | |
8782 | filter->aslist[FILTER_IN].name); | |
8783 | if (filter->aslist[FILTER_OUT].name) | |
8784 | json_object_string_add(json_addr, | |
8785 | "outgoingUpdateAsPathFilterList", | |
8786 | filter->aslist[FILTER_OUT].name); | |
8787 | ||
8788 | /* route-map. */ | |
8789 | if (filter->map[RMAP_IN].name) | |
8790 | json_object_string_add( | |
8791 | json_addr, "routeMapForIncomingAdvertisements", | |
8792 | filter->map[RMAP_IN].name); | |
8793 | if (filter->map[RMAP_OUT].name) | |
8794 | json_object_string_add( | |
8795 | json_addr, "routeMapForOutgoingAdvertisements", | |
8796 | filter->map[RMAP_OUT].name); | |
8797 | ||
9dac9fc8 DA |
8798 | /* ebgp-requires-policy (inbound) */ |
8799 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
8800 | && !bgp_inbound_policy_exists(p, filter)) | |
8801 | json_object_string_add( | |
8802 | json_addr, "inboundEbgpRequiresPolicy", | |
8803 | "Inbound updates discarded due to missing policy"); | |
8804 | ||
8805 | /* ebgp-requires-policy (outbound) */ | |
8806 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
8807 | && (!bgp_outbound_policy_exists(p, filter))) | |
8808 | json_object_string_add( | |
8809 | json_addr, "outboundEbgpRequiresPolicy", | |
8810 | "Outbound updates discarded due to missing policy"); | |
8811 | ||
d62a17ae | 8812 | /* unsuppress-map */ |
8813 | if (filter->usmap.name) | |
8814 | json_object_string_add(json_addr, | |
8815 | "selectiveUnsuppressRouteMap", | |
8816 | filter->usmap.name); | |
8817 | ||
8818 | /* Receive prefix count */ | |
8819 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
8820 | p->pcount[afi][safi]); | |
50e05855 AD |
8821 | if (paf && PAF_SUBGRP(paf)) |
8822 | json_object_int_add(json_addr, "sentPrefixCounter", | |
8823 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 8824 | |
8825 | /* Maximum prefix */ | |
8826 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
8827 | json_object_int_add(json_addr, "prefixAllowedMax", | |
8828 | p->pmax[afi][safi]); | |
8829 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8830 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
8831 | json_object_boolean_true_add( | |
8832 | json_addr, "prefixAllowedMaxWarning"); | |
8833 | json_object_int_add(json_addr, | |
8834 | "prefixAllowedWarningThresh", | |
8835 | p->pmax_threshold[afi][safi]); | |
8836 | if (p->pmax_restart[afi][safi]) | |
8837 | json_object_int_add( | |
8838 | json_addr, | |
8839 | "prefixAllowedRestartIntervalMsecs", | |
8840 | p->pmax_restart[afi][safi] * 60000); | |
8841 | } | |
8842 | json_object_object_add(json_neigh, afi_safi_print(afi, safi), | |
8843 | json_addr); | |
8844 | ||
8845 | } else { | |
8846 | filter = &p->filter[afi][safi]; | |
8847 | ||
8848 | vty_out(vty, " For address family: %s\n", | |
8849 | afi_safi_print(afi, safi)); | |
8850 | ||
8851 | if (peer_group_active(p)) | |
8852 | vty_out(vty, " %s peer-group member\n", | |
8853 | p->group->name); | |
8854 | ||
8855 | paf = peer_af_find(p, afi, safi); | |
8856 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
8857 | vty_out(vty, " Update group %" PRIu64 |
8858 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 8859 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
8860 | vty_out(vty, " Packet Queue length %d\n", | |
8861 | bpacket_queue_virtual_length(paf)); | |
8862 | } else { | |
8863 | vty_out(vty, " Not part of any update group\n"); | |
8864 | } | |
8865 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8866 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8867 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8868 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8869 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8870 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8871 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8872 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8873 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8874 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8875 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8876 | vty_out(vty, " AF-dependant capabilities:\n"); | |
8877 | ||
8878 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8879 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8880 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8881 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8882 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8883 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8884 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8885 | vty_out(vty, | |
8886 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8887 | ORF_TYPE_PREFIX); | |
8888 | bgp_show_peer_afi_orf_cap( | |
8889 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8890 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8891 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8892 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
8893 | } | |
8894 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8895 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8896 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8897 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8898 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8899 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8900 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8901 | vty_out(vty, | |
8902 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8903 | ORF_TYPE_PREFIX_OLD); | |
8904 | bgp_show_peer_afi_orf_cap( | |
8905 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8906 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8907 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8908 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
8909 | } | |
8910 | ||
8911 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8912 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8913 | NULL, afi, orf_pfx_name, use_json); | |
8914 | ||
8915 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8916 | PEER_STATUS_ORF_PREFIX_SEND) | |
8917 | || orf_pfx_count) { | |
8918 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
8919 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8920 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8921 | vty_out(vty, " sent;"); | |
8922 | if (orf_pfx_count) | |
8923 | vty_out(vty, " received (%d entries)", | |
8924 | orf_pfx_count); | |
8925 | vty_out(vty, "\n"); | |
8926 | } | |
8927 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8928 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8929 | vty_out(vty, | |
8930 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
8931 | ||
8932 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8933 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8934 | vty_out(vty, " Route-Reflector Client\n"); | |
8935 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8936 | PEER_FLAG_RSERVER_CLIENT)) | |
8937 | vty_out(vty, " Route-Server Client\n"); | |
8938 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8939 | vty_out(vty, | |
8940 | " Inbound soft reconfiguration allowed\n"); | |
8941 | ||
8942 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8943 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8944 | vty_out(vty, | |
8945 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
8946 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8947 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8948 | vty_out(vty, | |
8949 | " Private AS numbers replaced in updates to this neighbor\n"); | |
8950 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8951 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8952 | vty_out(vty, | |
8953 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
8954 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8955 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8956 | vty_out(vty, | |
8957 | " Private AS numbers removed in updates to this neighbor\n"); | |
8958 | ||
dcc68b5e MS |
8959 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
8960 | vty_out(vty, " %s\n", | |
8961 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
8962 | ->human_description); | |
d62a17ae | 8963 | |
8964 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8965 | vty_out(vty, | |
8966 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
8967 | ||
8968 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8969 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8970 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8971 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
8972 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8973 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8974 | vty_out(vty, | |
8975 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
8976 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8977 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
8978 | vty_out(vty, | |
8979 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
8980 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
8981 | vty_out(vty, | |
8982 | " MED is propagated unchanged to this neighbor\n"); | |
8983 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
8984 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8985 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
8986 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8987 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
8988 | vty_out(vty, | |
8989 | " Community attribute sent to this neighbor"); | |
8990 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8991 | PEER_FLAG_SEND_COMMUNITY) | |
8992 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8993 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
8994 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8995 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
8996 | vty_out(vty, "(all)\n"); | |
8997 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8998 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
8999 | vty_out(vty, "(large)\n"); | |
9000 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9001 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
9002 | vty_out(vty, "(extended)\n"); | |
9003 | else | |
9004 | vty_out(vty, "(standard)\n"); | |
9005 | } | |
9006 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9007 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
9008 | vty_out(vty, " Default information originate,"); | |
9009 | ||
9010 | if (p->default_rmap[afi][safi].name) | |
9011 | vty_out(vty, " default route-map %s%s,", | |
9012 | p->default_rmap[afi][safi].map ? "*" | |
9013 | : "", | |
9014 | p->default_rmap[afi][safi].name); | |
9015 | if (paf && PAF_SUBGRP(paf) | |
9016 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
9017 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
9018 | vty_out(vty, " default sent\n"); | |
9019 | else | |
9020 | vty_out(vty, " default not sent\n"); | |
9021 | } | |
9022 | ||
dff8f48d MK |
9023 | /* advertise-vni-all */ |
9024 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 9025 | if (is_evpn_enabled()) |
dff8f48d MK |
9026 | vty_out(vty, " advertise-all-vni\n"); |
9027 | } | |
9028 | ||
d62a17ae | 9029 | if (filter->plist[FILTER_IN].name |
9030 | || filter->dlist[FILTER_IN].name | |
9031 | || filter->aslist[FILTER_IN].name | |
9032 | || filter->map[RMAP_IN].name) | |
9033 | vty_out(vty, " Inbound path policy configured\n"); | |
9034 | if (filter->plist[FILTER_OUT].name | |
9035 | || filter->dlist[FILTER_OUT].name | |
9036 | || filter->aslist[FILTER_OUT].name | |
9037 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
9038 | vty_out(vty, " Outbound path policy configured\n"); | |
9039 | ||
9040 | /* prefix-list */ | |
9041 | if (filter->plist[FILTER_IN].name) | |
9042 | vty_out(vty, | |
9043 | " Incoming update prefix filter list is %s%s\n", | |
9044 | filter->plist[FILTER_IN].plist ? "*" : "", | |
9045 | filter->plist[FILTER_IN].name); | |
9046 | if (filter->plist[FILTER_OUT].name) | |
9047 | vty_out(vty, | |
9048 | " Outgoing update prefix filter list is %s%s\n", | |
9049 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
9050 | filter->plist[FILTER_OUT].name); | |
9051 | ||
9052 | /* distribute-list */ | |
9053 | if (filter->dlist[FILTER_IN].name) | |
9054 | vty_out(vty, | |
9055 | " Incoming update network filter list is %s%s\n", | |
9056 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
9057 | filter->dlist[FILTER_IN].name); | |
9058 | if (filter->dlist[FILTER_OUT].name) | |
9059 | vty_out(vty, | |
9060 | " Outgoing update network filter list is %s%s\n", | |
9061 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
9062 | filter->dlist[FILTER_OUT].name); | |
9063 | ||
9064 | /* filter-list. */ | |
9065 | if (filter->aslist[FILTER_IN].name) | |
9066 | vty_out(vty, | |
9067 | " Incoming update AS path filter list is %s%s\n", | |
9068 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
9069 | filter->aslist[FILTER_IN].name); | |
9070 | if (filter->aslist[FILTER_OUT].name) | |
9071 | vty_out(vty, | |
9072 | " Outgoing update AS path filter list is %s%s\n", | |
9073 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
9074 | filter->aslist[FILTER_OUT].name); | |
9075 | ||
9076 | /* route-map. */ | |
9077 | if (filter->map[RMAP_IN].name) | |
9078 | vty_out(vty, | |
9079 | " Route map for incoming advertisements is %s%s\n", | |
9080 | filter->map[RMAP_IN].map ? "*" : "", | |
9081 | filter->map[RMAP_IN].name); | |
9082 | if (filter->map[RMAP_OUT].name) | |
9083 | vty_out(vty, | |
9084 | " Route map for outgoing advertisements is %s%s\n", | |
9085 | filter->map[RMAP_OUT].map ? "*" : "", | |
9086 | filter->map[RMAP_OUT].name); | |
9087 | ||
9dac9fc8 DA |
9088 | /* ebgp-requires-policy (inbound) */ |
9089 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9090 | && !bgp_inbound_policy_exists(p, filter)) | |
9091 | vty_out(vty, | |
9092 | " Inbound updates discarded due to missing policy\n"); | |
9093 | ||
9094 | /* ebgp-requires-policy (outbound) */ | |
9095 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9096 | && !bgp_outbound_policy_exists(p, filter)) | |
9097 | vty_out(vty, | |
9098 | " Outbound updates discarded due to missing policy\n"); | |
9099 | ||
d62a17ae | 9100 | /* unsuppress-map */ |
9101 | if (filter->usmap.name) | |
9102 | vty_out(vty, | |
9103 | " Route map for selective unsuppress is %s%s\n", | |
9104 | filter->usmap.map ? "*" : "", | |
9105 | filter->usmap.name); | |
9106 | ||
9107 | /* Receive prefix count */ | |
9108 | vty_out(vty, " %ld accepted prefixes\n", p->pcount[afi][safi]); | |
9109 | ||
9110 | /* Maximum prefix */ | |
9111 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
9112 | vty_out(vty, " Maximum prefixes allowed %ld%s\n", | |
9113 | p->pmax[afi][safi], | |
9114 | CHECK_FLAG(p->af_flags[afi][safi], | |
9115 | PEER_FLAG_MAX_PREFIX_WARNING) | |
9116 | ? " (warning-only)" | |
9117 | : ""); | |
9118 | vty_out(vty, " Threshold for warning message %d%%", | |
9119 | p->pmax_threshold[afi][safi]); | |
9120 | if (p->pmax_restart[afi][safi]) | |
9121 | vty_out(vty, ", restart interval %d min", | |
9122 | p->pmax_restart[afi][safi]); | |
9123 | vty_out(vty, "\n"); | |
9124 | } | |
9125 | ||
9126 | vty_out(vty, "\n"); | |
9127 | } | |
9128 | } | |
9129 | ||
9f049418 | 9130 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 9131 | json_object *json) |
718e3744 | 9132 | { |
d62a17ae | 9133 | struct bgp *bgp; |
9134 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
9135 | char timebuf[BGP_UPTIME_LEN]; | |
9136 | char dn_flag[2]; | |
9137 | const char *subcode_str; | |
9138 | const char *code_str; | |
9139 | afi_t afi; | |
9140 | safi_t safi; | |
d7c0a89a QY |
9141 | uint16_t i; |
9142 | uint8_t *msg; | |
d62a17ae | 9143 | json_object *json_neigh = NULL; |
9144 | time_t epoch_tbuf; | |
718e3744 | 9145 | |
d62a17ae | 9146 | bgp = p->bgp; |
9147 | ||
9148 | if (use_json) | |
9149 | json_neigh = json_object_new_object(); | |
9150 | ||
9151 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9152 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
9153 | dn_flag[0] = '*'; | |
9154 | ||
9155 | if (!use_json) { | |
9156 | if (p->conf_if) /* Configured interface name. */ | |
9157 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
9158 | BGP_PEER_SU_UNSPEC(p) | |
9159 | ? "None" | |
9160 | : sockunion2str(&p->su, buf, | |
9161 | SU_ADDRSTRLEN)); | |
9162 | else /* Configured IP address. */ | |
9163 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
9164 | p->host); | |
9165 | } | |
9166 | ||
9167 | if (use_json) { | |
9168 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
9169 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
9170 | "none"); | |
9171 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
9172 | json_object_string_add( | |
9173 | json_neigh, "bgpNeighborAddr", | |
9174 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
9175 | ||
9176 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
9177 | ||
9178 | if (p->change_local_as) | |
9179 | json_object_int_add(json_neigh, "localAs", | |
9180 | p->change_local_as); | |
9181 | else | |
9182 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
9183 | ||
9184 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
9185 | json_object_boolean_true_add(json_neigh, | |
9186 | "localAsNoPrepend"); | |
9187 | ||
9188 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
9189 | json_object_boolean_true_add(json_neigh, | |
9190 | "localAsReplaceAs"); | |
9191 | } else { | |
9192 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
9193 | || (p->as_type == AS_INTERNAL)) | |
9194 | vty_out(vty, "remote AS %u, ", p->as); | |
9195 | else | |
9196 | vty_out(vty, "remote AS Unspecified, "); | |
9197 | vty_out(vty, "local AS %u%s%s, ", | |
9198 | p->change_local_as ? p->change_local_as : p->local_as, | |
9199 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
9200 | ? " no-prepend" | |
9201 | : "", | |
9202 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
9203 | ? " replace-as" | |
9204 | : ""); | |
9205 | } | |
faa16034 DS |
9206 | /* peer type internal or confed-internal */ |
9207 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 9208 | if (use_json) { |
9209 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9210 | json_object_boolean_true_add( | |
9211 | json_neigh, "nbrConfedInternalLink"); | |
9212 | else | |
9213 | json_object_boolean_true_add(json_neigh, | |
9214 | "nbrInternalLink"); | |
9215 | } else { | |
9216 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9217 | vty_out(vty, "confed-internal link\n"); | |
9218 | else | |
9219 | vty_out(vty, "internal link\n"); | |
9220 | } | |
faa16034 DS |
9221 | /* peer type external or confed-external */ |
9222 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 9223 | if (use_json) { |
9224 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9225 | json_object_boolean_true_add( | |
9226 | json_neigh, "nbrConfedExternalLink"); | |
9227 | else | |
9228 | json_object_boolean_true_add(json_neigh, | |
9229 | "nbrExternalLink"); | |
9230 | } else { | |
9231 | if (bgp_confederation_peers_check(bgp, p->as)) | |
9232 | vty_out(vty, "confed-external link\n"); | |
9233 | else | |
9234 | vty_out(vty, "external link\n"); | |
9235 | } | |
faa16034 DS |
9236 | } else { |
9237 | if (use_json) | |
9238 | json_object_boolean_true_add(json_neigh, | |
9239 | "nbrUnspecifiedLink"); | |
9240 | else | |
9241 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 9242 | } |
9243 | ||
9244 | /* Description. */ | |
9245 | if (p->desc) { | |
9246 | if (use_json) | |
9247 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
9248 | else | |
9249 | vty_out(vty, " Description: %s\n", p->desc); | |
9250 | } | |
9251 | ||
9252 | if (p->hostname) { | |
9253 | if (use_json) { | |
9254 | if (p->hostname) | |
9255 | json_object_string_add(json_neigh, "hostname", | |
9256 | p->hostname); | |
9257 | ||
9258 | if (p->domainname) | |
9259 | json_object_string_add(json_neigh, "domainname", | |
9260 | p->domainname); | |
9261 | } else { | |
9262 | if (p->domainname && (p->domainname[0] != '\0')) | |
9263 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
9264 | p->domainname); | |
9265 | else | |
9266 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
9267 | } | |
9268 | } | |
9269 | ||
9270 | /* Peer-group */ | |
9271 | if (p->group) { | |
9272 | if (use_json) { | |
9273 | json_object_string_add(json_neigh, "peerGroup", | |
9274 | p->group->name); | |
9275 | ||
9276 | if (dn_flag[0]) { | |
9277 | struct prefix prefix, *range = NULL; | |
9278 | ||
9279 | sockunion2hostprefix(&(p->su), &prefix); | |
9280 | range = peer_group_lookup_dynamic_neighbor_range( | |
9281 | p->group, &prefix); | |
9282 | ||
9283 | if (range) { | |
9284 | prefix2str(range, buf1, sizeof(buf1)); | |
9285 | json_object_string_add( | |
9286 | json_neigh, | |
9287 | "peerSubnetRangeGroup", buf1); | |
9288 | } | |
9289 | } | |
9290 | } else { | |
9291 | vty_out(vty, | |
9292 | " Member of peer-group %s for session parameters\n", | |
9293 | p->group->name); | |
9294 | ||
9295 | if (dn_flag[0]) { | |
9296 | struct prefix prefix, *range = NULL; | |
9297 | ||
9298 | sockunion2hostprefix(&(p->su), &prefix); | |
9299 | range = peer_group_lookup_dynamic_neighbor_range( | |
9300 | p->group, &prefix); | |
9301 | ||
9302 | if (range) { | |
9303 | prefix2str(range, buf1, sizeof(buf1)); | |
9304 | vty_out(vty, | |
9305 | " Belongs to the subnet range group: %s\n", | |
9306 | buf1); | |
9307 | } | |
9308 | } | |
9309 | } | |
9310 | } | |
9311 | ||
9312 | if (use_json) { | |
9313 | /* Administrative shutdown. */ | |
9314 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9315 | json_object_boolean_true_add(json_neigh, | |
9316 | "adminShutDown"); | |
9317 | ||
9318 | /* BGP Version. */ | |
9319 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
9320 | json_object_string_add( | |
9321 | json_neigh, "remoteRouterId", | |
9322 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
9323 | json_object_string_add( |
9324 | json_neigh, "localRouterId", | |
9325 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9326 | sizeof(buf1))); | |
d62a17ae | 9327 | |
9328 | /* Confederation */ | |
9329 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9330 | && bgp_confederation_peers_check(bgp, p->as)) | |
9331 | json_object_boolean_true_add(json_neigh, | |
9332 | "nbrCommonAdmin"); | |
9333 | ||
9334 | /* Status. */ | |
9335 | json_object_string_add( | |
9336 | json_neigh, "bgpState", | |
9337 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9338 | ||
9339 | if (p->status == Established) { | |
9340 | time_t uptime; | |
d62a17ae | 9341 | |
9342 | uptime = bgp_clock(); | |
9343 | uptime -= p->uptime; | |
d62a17ae | 9344 | epoch_tbuf = time(NULL) - uptime; |
9345 | ||
bee57a7a | 9346 | #if CONFDATE > 20200101 |
a4d82a8a PZ |
9347 | CPP_NOTICE( |
9348 | "bgpTimerUp should be deprecated and can be removed now"); | |
d3c7efed DS |
9349 | #endif |
9350 | /* | |
9351 | * bgpTimerUp was miliseconds that was accurate | |
9352 | * up to 1 day, then the value returned | |
9353 | * became garbage. So in order to provide | |
9354 | * some level of backwards compatability, | |
9355 | * we still provde the data, but now | |
9356 | * we are returning the correct value | |
9357 | * and also adding a new bgpTimerUpMsec | |
9358 | * which will allow us to deprecate | |
9359 | * this eventually | |
9360 | */ | |
d62a17ae | 9361 | json_object_int_add(json_neigh, "bgpTimerUp", |
e0330274 | 9362 | uptime * 1000); |
d3c7efed DS |
9363 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
9364 | uptime * 1000); | |
d62a17ae | 9365 | json_object_string_add(json_neigh, "bgpTimerUpString", |
9366 | peer_uptime(p->uptime, timebuf, | |
9367 | BGP_UPTIME_LEN, 0, | |
9368 | NULL)); | |
9369 | json_object_int_add(json_neigh, | |
9370 | "bgpTimerUpEstablishedEpoch", | |
9371 | epoch_tbuf); | |
9372 | } | |
9373 | ||
9374 | else if (p->status == Active) { | |
9375 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9376 | json_object_string_add(json_neigh, "bgpStateIs", | |
9377 | "passive"); | |
9378 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9379 | json_object_string_add(json_neigh, "bgpStateIs", | |
9380 | "passiveNSF"); | |
9381 | } | |
9382 | ||
9383 | /* read timer */ | |
9384 | time_t uptime; | |
9385 | struct tm *tm; | |
9386 | ||
9387 | uptime = bgp_clock(); | |
9388 | uptime -= p->readtime; | |
9389 | tm = gmtime(&uptime); | |
9390 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
9391 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9392 | + (tm->tm_hour * 3600000)); | |
9393 | ||
9394 | uptime = bgp_clock(); | |
9395 | uptime -= p->last_write; | |
9396 | tm = gmtime(&uptime); | |
9397 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
9398 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9399 | + (tm->tm_hour * 3600000)); | |
9400 | ||
9401 | uptime = bgp_clock(); | |
9402 | uptime -= p->update_time; | |
9403 | tm = gmtime(&uptime); | |
9404 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
9405 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9406 | + (tm->tm_hour * 3600000)); | |
9407 | ||
9408 | /* Configured timer values. */ | |
9409 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
9410 | p->v_holdtime * 1000); | |
9411 | json_object_int_add(json_neigh, | |
9412 | "bgpTimerKeepAliveIntervalMsecs", | |
9413 | p->v_keepalive * 1000); | |
b90a8e13 | 9414 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9415 | json_object_int_add(json_neigh, |
9416 | "bgpTimerConfiguredHoldTimeMsecs", | |
9417 | p->holdtime * 1000); | |
9418 | json_object_int_add( | |
9419 | json_neigh, | |
9420 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9421 | p->keepalive * 1000); | |
d25e4efc | 9422 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9423 | || (bgp->default_keepalive |
9424 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9425 | json_object_int_add(json_neigh, |
9426 | "bgpTimerConfiguredHoldTimeMsecs", | |
9427 | bgp->default_holdtime); | |
9428 | json_object_int_add( | |
9429 | json_neigh, | |
9430 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9431 | bgp->default_keepalive); | |
d62a17ae | 9432 | } |
9433 | } else { | |
9434 | /* Administrative shutdown. */ | |
9435 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9436 | vty_out(vty, " Administratively shut down\n"); | |
9437 | ||
9438 | /* BGP Version. */ | |
9439 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 9440 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 9441 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
9442 | vty_out(vty, ", local router ID %s\n", |
9443 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9444 | sizeof(buf1))); | |
d62a17ae | 9445 | |
9446 | /* Confederation */ | |
9447 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9448 | && bgp_confederation_peers_check(bgp, p->as)) | |
9449 | vty_out(vty, | |
9450 | " Neighbor under common administration\n"); | |
9451 | ||
9452 | /* Status. */ | |
9453 | vty_out(vty, " BGP state = %s", | |
9454 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9455 | ||
9456 | if (p->status == Established) | |
9457 | vty_out(vty, ", up for %8s", | |
9458 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
9459 | 0, NULL)); | |
9460 | ||
9461 | else if (p->status == Active) { | |
9462 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9463 | vty_out(vty, " (passive)"); | |
9464 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9465 | vty_out(vty, " (NSF passive)"); | |
9466 | } | |
9467 | vty_out(vty, "\n"); | |
9468 | ||
9469 | /* read timer */ | |
9470 | vty_out(vty, " Last read %s", | |
9471 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
9472 | NULL)); | |
9473 | vty_out(vty, ", Last write %s\n", | |
9474 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
9475 | NULL)); | |
9476 | ||
9477 | /* Configured timer values. */ | |
9478 | vty_out(vty, | |
9479 | " Hold time is %d, keepalive interval is %d seconds\n", | |
9480 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 9481 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9482 | vty_out(vty, " Configured hold time is %d", |
9483 | p->holdtime); | |
9484 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9485 | p->keepalive); | |
d25e4efc | 9486 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9487 | || (bgp->default_keepalive |
9488 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9489 | vty_out(vty, " Configured hold time is %d", |
9490 | bgp->default_holdtime); | |
9491 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9492 | bgp->default_keepalive); | |
d62a17ae | 9493 | } |
9494 | } | |
9495 | /* Capability. */ | |
9496 | if (p->status == Established) { | |
9497 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
9498 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
9499 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
9500 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
9501 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
9502 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
9503 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
9504 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
9505 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
9506 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
9507 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
9508 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 9509 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
9510 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 9511 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
9512 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 9513 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
9514 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 9515 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
9516 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
9517 | if (use_json) { | |
9518 | json_object *json_cap = NULL; | |
9519 | ||
9520 | json_cap = json_object_new_object(); | |
9521 | ||
9522 | /* AS4 */ | |
9523 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9524 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9525 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
9526 | && CHECK_FLAG(p->cap, | |
9527 | PEER_CAP_AS4_RCV)) | |
9528 | json_object_string_add( | |
9529 | json_cap, "4byteAs", | |
9530 | "advertisedAndReceived"); | |
9531 | else if (CHECK_FLAG(p->cap, | |
9532 | PEER_CAP_AS4_ADV)) | |
9533 | json_object_string_add( | |
9534 | json_cap, "4byteAs", | |
9535 | "advertised"); | |
9536 | else if (CHECK_FLAG(p->cap, | |
9537 | PEER_CAP_AS4_RCV)) | |
9538 | json_object_string_add( | |
9539 | json_cap, "4byteAs", | |
9540 | "received"); | |
9541 | } | |
9542 | ||
9543 | /* AddPath */ | |
9544 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9545 | || CHECK_FLAG(p->cap, | |
9546 | PEER_CAP_ADDPATH_ADV)) { | |
9547 | json_object *json_add = NULL; | |
9548 | const char *print_store; | |
9549 | ||
9550 | json_add = json_object_new_object(); | |
9551 | ||
05c7a1cc QY |
9552 | FOREACH_AFI_SAFI (afi, safi) { |
9553 | json_object *json_sub = NULL; | |
9554 | json_sub = | |
9555 | json_object_new_object(); | |
9556 | print_store = afi_safi_print( | |
9557 | afi, safi); | |
d62a17ae | 9558 | |
05c7a1cc QY |
9559 | if (CHECK_FLAG( |
9560 | p->af_cap[afi] | |
9561 | [safi], | |
9562 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9563 | || CHECK_FLAG( | |
9564 | p->af_cap[afi] | |
9565 | [safi], | |
9566 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 9567 | if (CHECK_FLAG( |
9568 | p->af_cap | |
9569 | [afi] | |
9570 | [safi], | |
9571 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 9572 | && CHECK_FLAG( |
d62a17ae | 9573 | p->af_cap |
9574 | [afi] | |
9575 | [safi], | |
05c7a1cc QY |
9576 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
9577 | json_object_boolean_true_add( | |
9578 | json_sub, | |
9579 | "txAdvertisedAndReceived"); | |
9580 | else if ( | |
9581 | CHECK_FLAG( | |
9582 | p->af_cap | |
9583 | [afi] | |
9584 | [safi], | |
9585 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
9586 | json_object_boolean_true_add( | |
9587 | json_sub, | |
9588 | "txAdvertised"); | |
9589 | else if ( | |
9590 | CHECK_FLAG( | |
9591 | p->af_cap | |
9592 | [afi] | |
9593 | [safi], | |
9594 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
9595 | json_object_boolean_true_add( | |
9596 | json_sub, | |
9597 | "txReceived"); | |
9598 | } | |
d62a17ae | 9599 | |
05c7a1cc QY |
9600 | if (CHECK_FLAG( |
9601 | p->af_cap[afi] | |
9602 | [safi], | |
9603 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9604 | || CHECK_FLAG( | |
9605 | p->af_cap[afi] | |
9606 | [safi], | |
9607 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 9608 | if (CHECK_FLAG( |
9609 | p->af_cap | |
9610 | [afi] | |
9611 | [safi], | |
9612 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 9613 | && CHECK_FLAG( |
d62a17ae | 9614 | p->af_cap |
9615 | [afi] | |
9616 | [safi], | |
9617 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
9618 | json_object_boolean_true_add( |
9619 | json_sub, | |
9620 | "rxAdvertisedAndReceived"); | |
9621 | else if ( | |
9622 | CHECK_FLAG( | |
9623 | p->af_cap | |
9624 | [afi] | |
9625 | [safi], | |
9626 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
9627 | json_object_boolean_true_add( | |
9628 | json_sub, | |
9629 | "rxAdvertised"); | |
9630 | else if ( | |
9631 | CHECK_FLAG( | |
9632 | p->af_cap | |
9633 | [afi] | |
9634 | [safi], | |
9635 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9636 | json_object_boolean_true_add( | |
9637 | json_sub, | |
9638 | "rxReceived"); | |
d62a17ae | 9639 | } |
9640 | ||
05c7a1cc QY |
9641 | if (CHECK_FLAG( |
9642 | p->af_cap[afi] | |
9643 | [safi], | |
9644 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9645 | || CHECK_FLAG( | |
9646 | p->af_cap[afi] | |
9647 | [safi], | |
9648 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
9649 | || CHECK_FLAG( | |
9650 | p->af_cap[afi] | |
9651 | [safi], | |
9652 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9653 | || CHECK_FLAG( | |
9654 | p->af_cap[afi] | |
9655 | [safi], | |
9656 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9657 | json_object_object_add( | |
9658 | json_add, | |
9659 | print_store, | |
9660 | json_sub); | |
9661 | else | |
9662 | json_object_free( | |
9663 | json_sub); | |
9664 | } | |
9665 | ||
d62a17ae | 9666 | json_object_object_add( |
9667 | json_cap, "addPath", json_add); | |
9668 | } | |
9669 | ||
9670 | /* Dynamic */ | |
9671 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
9672 | || CHECK_FLAG(p->cap, | |
9673 | PEER_CAP_DYNAMIC_ADV)) { | |
9674 | if (CHECK_FLAG(p->cap, | |
9675 | PEER_CAP_DYNAMIC_ADV) | |
9676 | && CHECK_FLAG(p->cap, | |
9677 | PEER_CAP_DYNAMIC_RCV)) | |
9678 | json_object_string_add( | |
9679 | json_cap, "dynamic", | |
9680 | "advertisedAndReceived"); | |
9681 | else if (CHECK_FLAG( | |
9682 | p->cap, | |
9683 | PEER_CAP_DYNAMIC_ADV)) | |
9684 | json_object_string_add( | |
9685 | json_cap, "dynamic", | |
9686 | "advertised"); | |
9687 | else if (CHECK_FLAG( | |
9688 | p->cap, | |
9689 | PEER_CAP_DYNAMIC_RCV)) | |
9690 | json_object_string_add( | |
9691 | json_cap, "dynamic", | |
9692 | "received"); | |
9693 | } | |
9694 | ||
9695 | /* Extended nexthop */ | |
9696 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
9697 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
9698 | json_object *json_nxt = NULL; | |
9699 | const char *print_store; | |
9700 | ||
9701 | ||
9702 | if (CHECK_FLAG(p->cap, | |
9703 | PEER_CAP_ENHE_ADV) | |
9704 | && CHECK_FLAG(p->cap, | |
9705 | PEER_CAP_ENHE_RCV)) | |
9706 | json_object_string_add( | |
9707 | json_cap, | |
9708 | "extendedNexthop", | |
9709 | "advertisedAndReceived"); | |
9710 | else if (CHECK_FLAG(p->cap, | |
9711 | PEER_CAP_ENHE_ADV)) | |
9712 | json_object_string_add( | |
9713 | json_cap, | |
9714 | "extendedNexthop", | |
9715 | "advertised"); | |
9716 | else if (CHECK_FLAG(p->cap, | |
9717 | PEER_CAP_ENHE_RCV)) | |
9718 | json_object_string_add( | |
9719 | json_cap, | |
9720 | "extendedNexthop", | |
9721 | "received"); | |
9722 | ||
9723 | if (CHECK_FLAG(p->cap, | |
9724 | PEER_CAP_ENHE_RCV)) { | |
9725 | json_nxt = | |
9726 | json_object_new_object(); | |
9727 | ||
9728 | for (safi = SAFI_UNICAST; | |
9729 | safi < SAFI_MAX; safi++) { | |
9730 | if (CHECK_FLAG( | |
9731 | p->af_cap | |
9732 | [AFI_IP] | |
9733 | [safi], | |
9734 | PEER_CAP_ENHE_AF_RCV)) { | |
9735 | print_store = afi_safi_print( | |
9736 | AFI_IP, | |
9737 | safi); | |
9738 | json_object_string_add( | |
9739 | json_nxt, | |
9740 | print_store, | |
54f29523 | 9741 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 9742 | } |
9743 | } | |
9744 | json_object_object_add( | |
9745 | json_cap, | |
9746 | "extendedNexthopFamililesByPeer", | |
9747 | json_nxt); | |
9748 | } | |
9749 | } | |
9750 | ||
9751 | /* Route Refresh */ | |
9752 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
9753 | || CHECK_FLAG(p->cap, | |
9754 | PEER_CAP_REFRESH_NEW_RCV) | |
9755 | || CHECK_FLAG(p->cap, | |
9756 | PEER_CAP_REFRESH_OLD_RCV)) { | |
9757 | if (CHECK_FLAG(p->cap, | |
9758 | PEER_CAP_REFRESH_ADV) | |
9759 | && (CHECK_FLAG( | |
9760 | p->cap, | |
9761 | PEER_CAP_REFRESH_NEW_RCV) | |
9762 | || CHECK_FLAG( | |
9763 | p->cap, | |
9764 | PEER_CAP_REFRESH_OLD_RCV))) { | |
9765 | if (CHECK_FLAG( | |
9766 | p->cap, | |
9767 | PEER_CAP_REFRESH_OLD_RCV) | |
9768 | && CHECK_FLAG( | |
9769 | p->cap, | |
9770 | PEER_CAP_REFRESH_NEW_RCV)) | |
9771 | json_object_string_add( | |
9772 | json_cap, | |
9773 | "routeRefresh", | |
9774 | "advertisedAndReceivedOldNew"); | |
9775 | else { | |
9776 | if (CHECK_FLAG( | |
9777 | p->cap, | |
9778 | PEER_CAP_REFRESH_OLD_RCV)) | |
9779 | json_object_string_add( | |
9780 | json_cap, | |
9781 | "routeRefresh", | |
9782 | "advertisedAndReceivedOld"); | |
9783 | else | |
9784 | json_object_string_add( | |
9785 | json_cap, | |
9786 | "routeRefresh", | |
9787 | "advertisedAndReceivedNew"); | |
9788 | } | |
9789 | } else if ( | |
9790 | CHECK_FLAG( | |
9791 | p->cap, | |
9792 | PEER_CAP_REFRESH_ADV)) | |
9793 | json_object_string_add( | |
9794 | json_cap, | |
9795 | "routeRefresh", | |
9796 | "advertised"); | |
9797 | else if ( | |
9798 | CHECK_FLAG( | |
9799 | p->cap, | |
9800 | PEER_CAP_REFRESH_NEW_RCV) | |
9801 | || CHECK_FLAG( | |
9802 | p->cap, | |
9803 | PEER_CAP_REFRESH_OLD_RCV)) | |
9804 | json_object_string_add( | |
9805 | json_cap, | |
9806 | "routeRefresh", | |
9807 | "received"); | |
9808 | } | |
9809 | ||
9810 | /* Multiprotocol Extensions */ | |
9811 | json_object *json_multi = NULL; | |
9812 | json_multi = json_object_new_object(); | |
9813 | ||
05c7a1cc QY |
9814 | FOREACH_AFI_SAFI (afi, safi) { |
9815 | if (p->afc_adv[afi][safi] | |
9816 | || p->afc_recv[afi][safi]) { | |
9817 | json_object *json_exten = NULL; | |
9818 | json_exten = | |
9819 | json_object_new_object(); | |
9820 | ||
d62a17ae | 9821 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
9822 | && p->afc_recv[afi][safi]) |
9823 | json_object_boolean_true_add( | |
9824 | json_exten, | |
9825 | "advertisedAndReceived"); | |
9826 | else if (p->afc_adv[afi][safi]) | |
9827 | json_object_boolean_true_add( | |
9828 | json_exten, | |
9829 | "advertised"); | |
9830 | else if (p->afc_recv[afi][safi]) | |
9831 | json_object_boolean_true_add( | |
9832 | json_exten, | |
9833 | "received"); | |
d62a17ae | 9834 | |
05c7a1cc QY |
9835 | json_object_object_add( |
9836 | json_multi, | |
9837 | afi_safi_print(afi, | |
9838 | safi), | |
9839 | json_exten); | |
d62a17ae | 9840 | } |
9841 | } | |
9842 | json_object_object_add( | |
9843 | json_cap, "multiprotocolExtensions", | |
9844 | json_multi); | |
9845 | ||
d77114b7 | 9846 | /* Hostname capabilities */ |
60466a63 | 9847 | json_object *json_hname = NULL; |
d77114b7 MK |
9848 | |
9849 | json_hname = json_object_new_object(); | |
9850 | ||
9851 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
9852 | json_object_string_add( | |
60466a63 QY |
9853 | json_hname, "advHostName", |
9854 | bgp->peer_self->hostname | |
9855 | ? bgp->peer_self | |
9856 | ->hostname | |
d77114b7 MK |
9857 | : "n/a"); |
9858 | json_object_string_add( | |
60466a63 QY |
9859 | json_hname, "advDomainName", |
9860 | bgp->peer_self->domainname | |
9861 | ? bgp->peer_self | |
9862 | ->domainname | |
d77114b7 MK |
9863 | : "n/a"); |
9864 | } | |
9865 | ||
9866 | ||
9867 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
9868 | json_object_string_add( | |
60466a63 QY |
9869 | json_hname, "rcvHostName", |
9870 | p->hostname ? p->hostname | |
9871 | : "n/a"); | |
d77114b7 | 9872 | json_object_string_add( |
60466a63 QY |
9873 | json_hname, "rcvDomainName", |
9874 | p->domainname ? p->domainname | |
9875 | : "n/a"); | |
d77114b7 MK |
9876 | } |
9877 | ||
60466a63 | 9878 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
9879 | json_hname); |
9880 | ||
d62a17ae | 9881 | /* Gracefull Restart */ |
9882 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
9883 | || CHECK_FLAG(p->cap, | |
9884 | PEER_CAP_RESTART_ADV)) { | |
9885 | if (CHECK_FLAG(p->cap, | |
9886 | PEER_CAP_RESTART_ADV) | |
9887 | && CHECK_FLAG(p->cap, | |
9888 | PEER_CAP_RESTART_RCV)) | |
9889 | json_object_string_add( | |
9890 | json_cap, | |
9891 | "gracefulRestart", | |
9892 | "advertisedAndReceived"); | |
9893 | else if (CHECK_FLAG( | |
9894 | p->cap, | |
9895 | PEER_CAP_RESTART_ADV)) | |
9896 | json_object_string_add( | |
9897 | json_cap, | |
9898 | "gracefulRestartCapability", | |
9899 | "advertised"); | |
9900 | else if (CHECK_FLAG( | |
9901 | p->cap, | |
9902 | PEER_CAP_RESTART_RCV)) | |
9903 | json_object_string_add( | |
9904 | json_cap, | |
9905 | "gracefulRestartCapability", | |
9906 | "received"); | |
9907 | ||
9908 | if (CHECK_FLAG(p->cap, | |
9909 | PEER_CAP_RESTART_RCV)) { | |
9910 | int restart_af_count = 0; | |
9911 | json_object *json_restart = | |
9912 | NULL; | |
9913 | json_restart = | |
9914 | json_object_new_object(); | |
9915 | ||
9916 | json_object_int_add( | |
9917 | json_cap, | |
9918 | "gracefulRestartRemoteTimerMsecs", | |
9919 | p->v_gr_restart * 1000); | |
9920 | ||
05c7a1cc QY |
9921 | FOREACH_AFI_SAFI (afi, safi) { |
9922 | if (CHECK_FLAG( | |
9923 | p->af_cap | |
9924 | [afi] | |
9925 | [safi], | |
9926 | PEER_CAP_RESTART_AF_RCV)) { | |
9927 | json_object * | |
9928 | json_sub = | |
9929 | NULL; | |
9930 | json_sub = | |
9931 | json_object_new_object(); | |
9932 | ||
d62a17ae | 9933 | if (CHECK_FLAG( |
9934 | p->af_cap | |
9935 | [afi] | |
9936 | [safi], | |
05c7a1cc QY |
9937 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
9938 | json_object_boolean_true_add( | |
9939 | json_sub, | |
9940 | "preserved"); | |
9941 | restart_af_count++; | |
9942 | json_object_object_add( | |
9943 | json_restart, | |
9944 | afi_safi_print( | |
9945 | afi, | |
9946 | safi), | |
9947 | json_sub); | |
d62a17ae | 9948 | } |
9949 | } | |
9950 | if (!restart_af_count) { | |
9951 | json_object_string_add( | |
9952 | json_cap, | |
9953 | "addressFamiliesByPeer", | |
9954 | "none"); | |
9955 | json_object_free( | |
9956 | json_restart); | |
9957 | } else | |
9958 | json_object_object_add( | |
9959 | json_cap, | |
9960 | "addressFamiliesByPeer", | |
9961 | json_restart); | |
9962 | } | |
9963 | } | |
9964 | json_object_object_add(json_neigh, | |
9965 | "neighborCapabilities", | |
9966 | json_cap); | |
9967 | } else { | |
9968 | vty_out(vty, " Neighbor capabilities:\n"); | |
9969 | ||
9970 | /* AS4 */ | |
9971 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9972 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9973 | vty_out(vty, " 4 Byte AS:"); | |
9974 | if (CHECK_FLAG(p->cap, | |
9975 | PEER_CAP_AS4_ADV)) | |
9976 | vty_out(vty, " advertised"); | |
9977 | if (CHECK_FLAG(p->cap, | |
9978 | PEER_CAP_AS4_RCV)) | |
9979 | vty_out(vty, " %sreceived", | |
9980 | CHECK_FLAG( | |
9981 | p->cap, | |
9982 | PEER_CAP_AS4_ADV) | |
9983 | ? "and " | |
9984 | : ""); | |
9985 | vty_out(vty, "\n"); | |
9986 | } | |
9987 | ||
9988 | /* AddPath */ | |
9989 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9990 | || CHECK_FLAG(p->cap, | |
9991 | PEER_CAP_ADDPATH_ADV)) { | |
9992 | vty_out(vty, " AddPath:\n"); | |
9993 | ||
05c7a1cc QY |
9994 | FOREACH_AFI_SAFI (afi, safi) { |
9995 | if (CHECK_FLAG( | |
9996 | p->af_cap[afi] | |
9997 | [safi], | |
9998 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9999 | || CHECK_FLAG( | |
10000 | p->af_cap[afi] | |
10001 | [safi], | |
10002 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
10003 | vty_out(vty, | |
10004 | " %s: TX ", | |
10005 | afi_safi_print( | |
10006 | afi, | |
10007 | safi)); | |
10008 | ||
d62a17ae | 10009 | if (CHECK_FLAG( |
10010 | p->af_cap | |
10011 | [afi] | |
10012 | [safi], | |
05c7a1cc | 10013 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 10014 | vty_out(vty, |
05c7a1cc | 10015 | "advertised %s", |
d62a17ae | 10016 | afi_safi_print( |
10017 | afi, | |
10018 | safi)); | |
10019 | ||
05c7a1cc QY |
10020 | if (CHECK_FLAG( |
10021 | p->af_cap | |
10022 | [afi] | |
10023 | [safi], | |
10024 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
10025 | vty_out(vty, | |
10026 | "%sreceived", | |
10027 | CHECK_FLAG( | |
10028 | p->af_cap | |
10029 | [afi] | |
10030 | [safi], | |
10031 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10032 | ? " and " | |
10033 | : ""); | |
d62a17ae | 10034 | |
05c7a1cc QY |
10035 | vty_out(vty, "\n"); |
10036 | } | |
d62a17ae | 10037 | |
05c7a1cc QY |
10038 | if (CHECK_FLAG( |
10039 | p->af_cap[afi] | |
10040 | [safi], | |
10041 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10042 | || CHECK_FLAG( | |
10043 | p->af_cap[afi] | |
10044 | [safi], | |
10045 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
10046 | vty_out(vty, | |
10047 | " %s: RX ", | |
10048 | afi_safi_print( | |
10049 | afi, | |
10050 | safi)); | |
d62a17ae | 10051 | |
10052 | if (CHECK_FLAG( | |
10053 | p->af_cap | |
10054 | [afi] | |
10055 | [safi], | |
05c7a1cc | 10056 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 10057 | vty_out(vty, |
05c7a1cc | 10058 | "advertised %s", |
d62a17ae | 10059 | afi_safi_print( |
10060 | afi, | |
10061 | safi)); | |
10062 | ||
05c7a1cc QY |
10063 | if (CHECK_FLAG( |
10064 | p->af_cap | |
10065 | [afi] | |
10066 | [safi], | |
10067 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 10068 | vty_out(vty, |
05c7a1cc QY |
10069 | "%sreceived", |
10070 | CHECK_FLAG( | |
10071 | p->af_cap | |
10072 | [afi] | |
10073 | [safi], | |
10074 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10075 | ? " and " | |
10076 | : ""); | |
10077 | ||
10078 | vty_out(vty, "\n"); | |
d62a17ae | 10079 | } |
05c7a1cc | 10080 | } |
d62a17ae | 10081 | } |
10082 | ||
10083 | /* Dynamic */ | |
10084 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
10085 | || CHECK_FLAG(p->cap, | |
10086 | PEER_CAP_DYNAMIC_ADV)) { | |
10087 | vty_out(vty, " Dynamic:"); | |
10088 | if (CHECK_FLAG(p->cap, | |
10089 | PEER_CAP_DYNAMIC_ADV)) | |
10090 | vty_out(vty, " advertised"); | |
10091 | if (CHECK_FLAG(p->cap, | |
10092 | PEER_CAP_DYNAMIC_RCV)) | |
10093 | vty_out(vty, " %sreceived", | |
10094 | CHECK_FLAG( | |
10095 | p->cap, | |
10096 | PEER_CAP_DYNAMIC_ADV) | |
10097 | ? "and " | |
10098 | : ""); | |
10099 | vty_out(vty, "\n"); | |
10100 | } | |
10101 | ||
10102 | /* Extended nexthop */ | |
10103 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
10104 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
10105 | vty_out(vty, " Extended nexthop:"); | |
10106 | if (CHECK_FLAG(p->cap, | |
10107 | PEER_CAP_ENHE_ADV)) | |
10108 | vty_out(vty, " advertised"); | |
10109 | if (CHECK_FLAG(p->cap, | |
10110 | PEER_CAP_ENHE_RCV)) | |
10111 | vty_out(vty, " %sreceived", | |
10112 | CHECK_FLAG( | |
10113 | p->cap, | |
10114 | PEER_CAP_ENHE_ADV) | |
10115 | ? "and " | |
10116 | : ""); | |
10117 | vty_out(vty, "\n"); | |
10118 | ||
10119 | if (CHECK_FLAG(p->cap, | |
10120 | PEER_CAP_ENHE_RCV)) { | |
10121 | vty_out(vty, | |
10122 | " Address families by peer:\n "); | |
10123 | for (safi = SAFI_UNICAST; | |
10124 | safi < SAFI_MAX; safi++) | |
10125 | if (CHECK_FLAG( | |
10126 | p->af_cap | |
10127 | [AFI_IP] | |
10128 | [safi], | |
10129 | PEER_CAP_ENHE_AF_RCV)) | |
10130 | vty_out(vty, | |
10131 | " %s\n", | |
10132 | afi_safi_print( | |
10133 | AFI_IP, | |
10134 | safi)); | |
10135 | } | |
10136 | } | |
10137 | ||
10138 | /* Route Refresh */ | |
10139 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
10140 | || CHECK_FLAG(p->cap, | |
10141 | PEER_CAP_REFRESH_NEW_RCV) | |
10142 | || CHECK_FLAG(p->cap, | |
10143 | PEER_CAP_REFRESH_OLD_RCV)) { | |
10144 | vty_out(vty, " Route refresh:"); | |
10145 | if (CHECK_FLAG(p->cap, | |
10146 | PEER_CAP_REFRESH_ADV)) | |
10147 | vty_out(vty, " advertised"); | |
10148 | if (CHECK_FLAG(p->cap, | |
10149 | PEER_CAP_REFRESH_NEW_RCV) | |
10150 | || CHECK_FLAG( | |
10151 | p->cap, | |
10152 | PEER_CAP_REFRESH_OLD_RCV)) | |
10153 | vty_out(vty, " %sreceived(%s)", | |
10154 | CHECK_FLAG( | |
10155 | p->cap, | |
10156 | PEER_CAP_REFRESH_ADV) | |
10157 | ? "and " | |
10158 | : "", | |
10159 | (CHECK_FLAG( | |
10160 | p->cap, | |
10161 | PEER_CAP_REFRESH_OLD_RCV) | |
10162 | && CHECK_FLAG( | |
10163 | p->cap, | |
10164 | PEER_CAP_REFRESH_NEW_RCV)) | |
10165 | ? "old & new" | |
10166 | : CHECK_FLAG( | |
10167 | p->cap, | |
10168 | PEER_CAP_REFRESH_OLD_RCV) | |
10169 | ? "old" | |
10170 | : "new"); | |
10171 | ||
10172 | vty_out(vty, "\n"); | |
10173 | } | |
10174 | ||
10175 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
10176 | FOREACH_AFI_SAFI (afi, safi) |
10177 | if (p->afc_adv[afi][safi] | |
10178 | || p->afc_recv[afi][safi]) { | |
10179 | vty_out(vty, | |
10180 | " Address Family %s:", | |
10181 | afi_safi_print(afi, | |
10182 | safi)); | |
10183 | if (p->afc_adv[afi][safi]) | |
d62a17ae | 10184 | vty_out(vty, |
05c7a1cc QY |
10185 | " advertised"); |
10186 | if (p->afc_recv[afi][safi]) | |
10187 | vty_out(vty, | |
10188 | " %sreceived", | |
10189 | p->afc_adv[afi] | |
10190 | [safi] | |
10191 | ? "and " | |
10192 | : ""); | |
10193 | vty_out(vty, "\n"); | |
10194 | } | |
d62a17ae | 10195 | |
10196 | /* Hostname capability */ | |
60466a63 | 10197 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
10198 | |
10199 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
10200 | vty_out(vty, |
10201 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
10202 | bgp->peer_self->hostname |
10203 | ? bgp->peer_self | |
10204 | ->hostname | |
d77114b7 | 10205 | : "n/a", |
60466a63 QY |
10206 | bgp->peer_self->domainname |
10207 | ? bgp->peer_self | |
10208 | ->domainname | |
d77114b7 MK |
10209 | : "n/a"); |
10210 | } else { | |
10211 | vty_out(vty, " not advertised"); | |
d62a17ae | 10212 | } |
10213 | ||
d77114b7 | 10214 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
10215 | vty_out(vty, |
10216 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
10217 | p->hostname ? p->hostname |
10218 | : "n/a", | |
10219 | p->domainname ? p->domainname | |
10220 | : "n/a"); | |
d77114b7 MK |
10221 | } else { |
10222 | vty_out(vty, " not received"); | |
10223 | } | |
10224 | ||
10225 | vty_out(vty, "\n"); | |
10226 | ||
d62a17ae | 10227 | /* Gracefull Restart */ |
10228 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
10229 | || CHECK_FLAG(p->cap, | |
10230 | PEER_CAP_RESTART_ADV)) { | |
10231 | vty_out(vty, | |
10232 | " Graceful Restart Capabilty:"); | |
10233 | if (CHECK_FLAG(p->cap, | |
10234 | PEER_CAP_RESTART_ADV)) | |
10235 | vty_out(vty, " advertised"); | |
10236 | if (CHECK_FLAG(p->cap, | |
10237 | PEER_CAP_RESTART_RCV)) | |
10238 | vty_out(vty, " %sreceived", | |
10239 | CHECK_FLAG( | |
10240 | p->cap, | |
10241 | PEER_CAP_RESTART_ADV) | |
10242 | ? "and " | |
10243 | : ""); | |
10244 | vty_out(vty, "\n"); | |
10245 | ||
10246 | if (CHECK_FLAG(p->cap, | |
10247 | PEER_CAP_RESTART_RCV)) { | |
10248 | int restart_af_count = 0; | |
10249 | ||
10250 | vty_out(vty, | |
10251 | " Remote Restart timer is %d seconds\n", | |
10252 | p->v_gr_restart); | |
10253 | vty_out(vty, | |
10254 | " Address families by peer:\n "); | |
10255 | ||
05c7a1cc QY |
10256 | FOREACH_AFI_SAFI (afi, safi) |
10257 | if (CHECK_FLAG( | |
10258 | p->af_cap | |
10259 | [afi] | |
10260 | [safi], | |
10261 | PEER_CAP_RESTART_AF_RCV)) { | |
10262 | vty_out(vty, | |
10263 | "%s%s(%s)", | |
10264 | restart_af_count | |
10265 | ? ", " | |
10266 | : "", | |
10267 | afi_safi_print( | |
10268 | afi, | |
10269 | safi), | |
10270 | CHECK_FLAG( | |
10271 | p->af_cap | |
10272 | [afi] | |
10273 | [safi], | |
10274 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
10275 | ? "preserved" | |
10276 | : "not preserved"); | |
10277 | restart_af_count++; | |
10278 | } | |
d62a17ae | 10279 | if (!restart_af_count) |
10280 | vty_out(vty, "none"); | |
10281 | vty_out(vty, "\n"); | |
10282 | } | |
10283 | } | |
10284 | } | |
10285 | } | |
10286 | } | |
10287 | ||
10288 | /* graceful restart information */ | |
10289 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || p->t_gr_restart | |
10290 | || p->t_gr_stale) { | |
10291 | json_object *json_grace = NULL; | |
10292 | json_object *json_grace_send = NULL; | |
10293 | json_object *json_grace_recv = NULL; | |
10294 | int eor_send_af_count = 0; | |
10295 | int eor_receive_af_count = 0; | |
10296 | ||
10297 | if (use_json) { | |
10298 | json_grace = json_object_new_object(); | |
10299 | json_grace_send = json_object_new_object(); | |
10300 | json_grace_recv = json_object_new_object(); | |
10301 | ||
10302 | if (p->status == Established) { | |
05c7a1cc QY |
10303 | FOREACH_AFI_SAFI (afi, safi) { |
10304 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10305 | PEER_STATUS_EOR_SEND)) { | |
10306 | json_object_boolean_true_add( | |
10307 | json_grace_send, | |
10308 | afi_safi_print(afi, | |
10309 | safi)); | |
10310 | eor_send_af_count++; | |
d62a17ae | 10311 | } |
10312 | } | |
05c7a1cc QY |
10313 | FOREACH_AFI_SAFI (afi, safi) { |
10314 | if (CHECK_FLAG( | |
10315 | p->af_sflags[afi][safi], | |
10316 | PEER_STATUS_EOR_RECEIVED)) { | |
10317 | json_object_boolean_true_add( | |
10318 | json_grace_recv, | |
10319 | afi_safi_print(afi, | |
10320 | safi)); | |
10321 | eor_receive_af_count++; | |
d62a17ae | 10322 | } |
10323 | } | |
10324 | } | |
10325 | ||
10326 | json_object_object_add(json_grace, "endOfRibSend", | |
10327 | json_grace_send); | |
10328 | json_object_object_add(json_grace, "endOfRibRecv", | |
10329 | json_grace_recv); | |
10330 | ||
10331 | if (p->t_gr_restart) | |
10332 | json_object_int_add(json_grace, | |
10333 | "gracefulRestartTimerMsecs", | |
10334 | thread_timer_remain_second( | |
10335 | p->t_gr_restart) | |
10336 | * 1000); | |
10337 | ||
10338 | if (p->t_gr_stale) | |
10339 | json_object_int_add( | |
10340 | json_grace, | |
10341 | "gracefulStalepathTimerMsecs", | |
10342 | thread_timer_remain_second( | |
10343 | p->t_gr_stale) | |
10344 | * 1000); | |
10345 | ||
10346 | json_object_object_add( | |
10347 | json_neigh, "gracefulRestartInfo", json_grace); | |
10348 | } else { | |
0437e105 | 10349 | vty_out(vty, " Graceful restart information:\n"); |
d62a17ae | 10350 | if (p->status == Established) { |
10351 | vty_out(vty, " End-of-RIB send: "); | |
05c7a1cc QY |
10352 | FOREACH_AFI_SAFI (afi, safi) { |
10353 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10354 | PEER_STATUS_EOR_SEND)) { | |
10355 | vty_out(vty, "%s%s", | |
10356 | eor_send_af_count ? ", " | |
10357 | : "", | |
10358 | afi_safi_print(afi, | |
10359 | safi)); | |
10360 | eor_send_af_count++; | |
d62a17ae | 10361 | } |
10362 | } | |
10363 | vty_out(vty, "\n"); | |
10364 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
10365 | FOREACH_AFI_SAFI (afi, safi) { |
10366 | if (CHECK_FLAG( | |
10367 | p->af_sflags[afi][safi], | |
10368 | PEER_STATUS_EOR_RECEIVED)) { | |
10369 | vty_out(vty, "%s%s", | |
10370 | eor_receive_af_count | |
10371 | ? ", " | |
10372 | : "", | |
10373 | afi_safi_print(afi, | |
10374 | safi)); | |
10375 | eor_receive_af_count++; | |
d62a17ae | 10376 | } |
10377 | } | |
10378 | vty_out(vty, "\n"); | |
10379 | } | |
10380 | ||
10381 | if (p->t_gr_restart) | |
10382 | vty_out(vty, | |
10383 | " The remaining time of restart timer is %ld\n", | |
10384 | thread_timer_remain_second( | |
10385 | p->t_gr_restart)); | |
10386 | ||
10387 | if (p->t_gr_stale) | |
10388 | vty_out(vty, | |
10389 | " The remaining time of stalepath timer is %ld\n", | |
10390 | thread_timer_remain_second( | |
10391 | p->t_gr_stale)); | |
10392 | } | |
10393 | } | |
10394 | if (use_json) { | |
10395 | json_object *json_stat = NULL; | |
10396 | json_stat = json_object_new_object(); | |
10397 | /* Packet counts. */ | |
10398 | json_object_int_add(json_stat, "depthInq", 0); | |
10399 | json_object_int_add(json_stat, "depthOutq", | |
10400 | (unsigned long)p->obuf->count); | |
0112e9e0 QY |
10401 | json_object_int_add(json_stat, "opensSent", |
10402 | atomic_load_explicit(&p->open_out, | |
10403 | memory_order_relaxed)); | |
10404 | json_object_int_add(json_stat, "opensRecv", | |
10405 | atomic_load_explicit(&p->open_in, | |
10406 | memory_order_relaxed)); | |
d62a17ae | 10407 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
10408 | atomic_load_explicit(&p->notify_out, |
10409 | memory_order_relaxed)); | |
d62a17ae | 10410 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
10411 | atomic_load_explicit(&p->notify_in, |
10412 | memory_order_relaxed)); | |
10413 | json_object_int_add(json_stat, "updatesSent", | |
10414 | atomic_load_explicit(&p->update_out, | |
10415 | memory_order_relaxed)); | |
10416 | json_object_int_add(json_stat, "updatesRecv", | |
10417 | atomic_load_explicit(&p->update_in, | |
10418 | memory_order_relaxed)); | |
d62a17ae | 10419 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
10420 | atomic_load_explicit(&p->keepalive_out, |
10421 | memory_order_relaxed)); | |
d62a17ae | 10422 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
10423 | atomic_load_explicit(&p->keepalive_in, |
10424 | memory_order_relaxed)); | |
d62a17ae | 10425 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
10426 | atomic_load_explicit(&p->refresh_out, |
10427 | memory_order_relaxed)); | |
d62a17ae | 10428 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
10429 | atomic_load_explicit(&p->refresh_in, |
10430 | memory_order_relaxed)); | |
d62a17ae | 10431 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
10432 | atomic_load_explicit(&p->dynamic_cap_out, |
10433 | memory_order_relaxed)); | |
d62a17ae | 10434 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
10435 | atomic_load_explicit(&p->dynamic_cap_in, |
10436 | memory_order_relaxed)); | |
10437 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
10438 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 10439 | json_object_object_add(json_neigh, "messageStats", json_stat); |
10440 | } else { | |
10441 | /* Packet counts. */ | |
10442 | vty_out(vty, " Message statistics:\n"); | |
10443 | vty_out(vty, " Inq depth is 0\n"); | |
10444 | vty_out(vty, " Outq depth is %lu\n", | |
10445 | (unsigned long)p->obuf->count); | |
10446 | vty_out(vty, " Sent Rcvd\n"); | |
0112e9e0 QY |
10447 | vty_out(vty, " Opens: %10d %10d\n", |
10448 | atomic_load_explicit(&p->open_out, | |
10449 | memory_order_relaxed), | |
10450 | atomic_load_explicit(&p->open_in, | |
10451 | memory_order_relaxed)); | |
10452 | vty_out(vty, " Notifications: %10d %10d\n", | |
10453 | atomic_load_explicit(&p->notify_out, | |
10454 | memory_order_relaxed), | |
10455 | atomic_load_explicit(&p->notify_in, | |
10456 | memory_order_relaxed)); | |
10457 | vty_out(vty, " Updates: %10d %10d\n", | |
10458 | atomic_load_explicit(&p->update_out, | |
10459 | memory_order_relaxed), | |
10460 | atomic_load_explicit(&p->update_in, | |
10461 | memory_order_relaxed)); | |
10462 | vty_out(vty, " Keepalives: %10d %10d\n", | |
10463 | atomic_load_explicit(&p->keepalive_out, | |
10464 | memory_order_relaxed), | |
10465 | atomic_load_explicit(&p->keepalive_in, | |
10466 | memory_order_relaxed)); | |
10467 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
10468 | atomic_load_explicit(&p->refresh_out, | |
10469 | memory_order_relaxed), | |
10470 | atomic_load_explicit(&p->refresh_in, | |
10471 | memory_order_relaxed)); | |
d62a17ae | 10472 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
10473 | atomic_load_explicit(&p->dynamic_cap_out, |
10474 | memory_order_relaxed), | |
10475 | atomic_load_explicit(&p->dynamic_cap_in, | |
10476 | memory_order_relaxed)); | |
10477 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
10478 | PEER_TOTAL_RX(p)); | |
d62a17ae | 10479 | } |
10480 | ||
10481 | if (use_json) { | |
10482 | /* advertisement-interval */ | |
10483 | json_object_int_add(json_neigh, | |
10484 | "minBtwnAdvertisementRunsTimerMsecs", | |
10485 | p->v_routeadv * 1000); | |
10486 | ||
10487 | /* Update-source. */ | |
10488 | if (p->update_if || p->update_source) { | |
10489 | if (p->update_if) | |
10490 | json_object_string_add(json_neigh, | |
10491 | "updateSource", | |
10492 | p->update_if); | |
10493 | else if (p->update_source) | |
10494 | json_object_string_add( | |
10495 | json_neigh, "updateSource", | |
10496 | sockunion2str(p->update_source, buf1, | |
10497 | SU_ADDRSTRLEN)); | |
10498 | } | |
10499 | } else { | |
10500 | /* advertisement-interval */ | |
10501 | vty_out(vty, | |
10502 | " Minimum time between advertisement runs is %d seconds\n", | |
10503 | p->v_routeadv); | |
10504 | ||
10505 | /* Update-source. */ | |
10506 | if (p->update_if || p->update_source) { | |
10507 | vty_out(vty, " Update source is "); | |
10508 | if (p->update_if) | |
10509 | vty_out(vty, "%s", p->update_if); | |
10510 | else if (p->update_source) | |
10511 | vty_out(vty, "%s", | |
10512 | sockunion2str(p->update_source, buf1, | |
10513 | SU_ADDRSTRLEN)); | |
10514 | vty_out(vty, "\n"); | |
10515 | } | |
10516 | ||
10517 | vty_out(vty, "\n"); | |
10518 | } | |
10519 | ||
10520 | /* Address Family Information */ | |
10521 | json_object *json_hold = NULL; | |
10522 | ||
10523 | if (use_json) | |
10524 | json_hold = json_object_new_object(); | |
10525 | ||
05c7a1cc QY |
10526 | FOREACH_AFI_SAFI (afi, safi) |
10527 | if (p->afc[afi][safi]) | |
10528 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
10529 | json_hold); | |
d62a17ae | 10530 | |
10531 | if (use_json) { | |
10532 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
10533 | json_hold); | |
10534 | json_object_int_add(json_neigh, "connectionsEstablished", | |
10535 | p->established); | |
10536 | json_object_int_add(json_neigh, "connectionsDropped", | |
10537 | p->dropped); | |
10538 | } else | |
10539 | vty_out(vty, " Connections established %d; dropped %d\n", | |
10540 | p->established, p->dropped); | |
10541 | ||
10542 | if (!p->last_reset) { | |
10543 | if (use_json) | |
10544 | json_object_string_add(json_neigh, "lastReset", | |
10545 | "never"); | |
10546 | else | |
10547 | vty_out(vty, " Last reset never\n"); | |
10548 | } else { | |
10549 | if (use_json) { | |
10550 | time_t uptime; | |
10551 | struct tm *tm; | |
10552 | ||
10553 | uptime = bgp_clock(); | |
10554 | uptime -= p->resettime; | |
10555 | tm = gmtime(&uptime); | |
10556 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
10557 | (tm->tm_sec * 1000) | |
10558 | + (tm->tm_min * 60000) | |
10559 | + (tm->tm_hour * 3600000)); | |
10560 | json_object_string_add( | |
10561 | json_neigh, "lastResetDueTo", | |
10562 | peer_down_str[(int)p->last_reset]); | |
10563 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10564 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10565 | char errorcodesubcode_hexstr[5]; | |
10566 | char errorcodesubcode_str[256]; | |
10567 | ||
10568 | code_str = bgp_notify_code_str(p->notify.code); | |
10569 | subcode_str = bgp_notify_subcode_str( | |
10570 | p->notify.code, p->notify.subcode); | |
10571 | ||
10572 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
10573 | p->notify.code, p->notify.subcode); | |
10574 | json_object_string_add(json_neigh, | |
10575 | "lastErrorCodeSubcode", | |
10576 | errorcodesubcode_hexstr); | |
10577 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10578 | code_str, subcode_str); | |
10579 | json_object_string_add(json_neigh, | |
10580 | "lastNotificationReason", | |
10581 | errorcodesubcode_str); | |
10582 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10583 | && p->notify.code == BGP_NOTIFY_CEASE | |
10584 | && (p->notify.subcode | |
10585 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10586 | || p->notify.subcode | |
10587 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10588 | && p->notify.length) { | |
10589 | char msgbuf[1024]; | |
10590 | const char *msg_str; | |
10591 | ||
10592 | msg_str = bgp_notify_admin_message( | |
10593 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10594 | (uint8_t *)p->notify.data, |
d62a17ae | 10595 | p->notify.length); |
10596 | if (msg_str) | |
10597 | json_object_string_add( | |
10598 | json_neigh, | |
10599 | "lastShutdownDescription", | |
10600 | msg_str); | |
10601 | } | |
10602 | } | |
10603 | } else { | |
10604 | vty_out(vty, " Last reset %s, ", | |
10605 | peer_uptime(p->resettime, timebuf, | |
10606 | BGP_UPTIME_LEN, 0, NULL)); | |
10607 | ||
10608 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10609 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10610 | code_str = bgp_notify_code_str(p->notify.code); | |
10611 | subcode_str = bgp_notify_subcode_str( | |
10612 | p->notify.code, p->notify.subcode); | |
10613 | vty_out(vty, "due to NOTIFICATION %s (%s%s)\n", | |
10614 | p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10615 | ? "sent" | |
10616 | : "received", | |
10617 | code_str, subcode_str); | |
10618 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10619 | && p->notify.code == BGP_NOTIFY_CEASE | |
10620 | && (p->notify.subcode | |
10621 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10622 | || p->notify.subcode | |
10623 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10624 | && p->notify.length) { | |
10625 | char msgbuf[1024]; | |
10626 | const char *msg_str; | |
10627 | ||
10628 | msg_str = bgp_notify_admin_message( | |
10629 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10630 | (uint8_t *)p->notify.data, |
d62a17ae | 10631 | p->notify.length); |
10632 | if (msg_str) | |
10633 | vty_out(vty, | |
10634 | " Message: \"%s\"\n", | |
10635 | msg_str); | |
10636 | } | |
10637 | } else { | |
10638 | vty_out(vty, "due to %s\n", | |
10639 | peer_down_str[(int)p->last_reset]); | |
10640 | } | |
10641 | ||
10642 | if (p->last_reset_cause_size) { | |
10643 | msg = p->last_reset_cause; | |
10644 | vty_out(vty, | |
10645 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
10646 | for (i = 1; i <= p->last_reset_cause_size; | |
10647 | i++) { | |
10648 | vty_out(vty, "%02X", *msg++); | |
10649 | ||
10650 | if (i != p->last_reset_cause_size) { | |
10651 | if (i % 16 == 0) { | |
10652 | vty_out(vty, "\n "); | |
10653 | } else if (i % 4 == 0) { | |
10654 | vty_out(vty, " "); | |
10655 | } | |
10656 | } | |
10657 | } | |
10658 | vty_out(vty, "\n"); | |
10659 | } | |
10660 | } | |
10661 | } | |
10662 | ||
10663 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
10664 | if (use_json) | |
10665 | json_object_boolean_true_add(json_neigh, | |
10666 | "prefixesConfigExceedMax"); | |
10667 | else | |
10668 | vty_out(vty, | |
10669 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
10670 | ||
10671 | if (p->t_pmax_restart) { | |
10672 | if (use_json) { | |
10673 | json_object_boolean_true_add( | |
10674 | json_neigh, "reducePrefixNumFrom"); | |
10675 | json_object_int_add(json_neigh, | |
10676 | "restartInTimerMsec", | |
10677 | thread_timer_remain_second( | |
10678 | p->t_pmax_restart) | |
10679 | * 1000); | |
10680 | } else | |
10681 | vty_out(vty, | |
10682 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
10683 | p->host, thread_timer_remain_second( |
10684 | p->t_pmax_restart)); | |
d62a17ae | 10685 | } else { |
10686 | if (use_json) | |
10687 | json_object_boolean_true_add( | |
10688 | json_neigh, | |
10689 | "reducePrefixNumAndClearIpBgp"); | |
10690 | else | |
10691 | vty_out(vty, | |
10692 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
10693 | p->host); | |
10694 | } | |
10695 | } | |
10696 | ||
10697 | /* EBGP Multihop and GTSM */ | |
10698 | if (p->sort != BGP_PEER_IBGP) { | |
10699 | if (use_json) { | |
10700 | if (p->gtsm_hops > 0) | |
10701 | json_object_int_add(json_neigh, | |
10702 | "externalBgpNbrMaxHopsAway", | |
10703 | p->gtsm_hops); | |
10704 | else if (p->ttl > 1) | |
10705 | json_object_int_add(json_neigh, | |
10706 | "externalBgpNbrMaxHopsAway", | |
10707 | p->ttl); | |
10708 | } else { | |
10709 | if (p->gtsm_hops > 0) | |
10710 | vty_out(vty, | |
10711 | " External BGP neighbor may be up to %d hops away.\n", | |
10712 | p->gtsm_hops); | |
10713 | else if (p->ttl > 1) | |
10714 | vty_out(vty, | |
10715 | " External BGP neighbor may be up to %d hops away.\n", | |
10716 | p->ttl); | |
10717 | } | |
10718 | } else { | |
10719 | if (p->gtsm_hops > 0) { | |
10720 | if (use_json) | |
10721 | json_object_int_add(json_neigh, | |
10722 | "internalBgpNbrMaxHopsAway", | |
10723 | p->gtsm_hops); | |
10724 | else | |
10725 | vty_out(vty, | |
10726 | " Internal BGP neighbor may be up to %d hops away.\n", | |
10727 | p->gtsm_hops); | |
10728 | } | |
10729 | } | |
10730 | ||
10731 | /* Local address. */ | |
10732 | if (p->su_local) { | |
10733 | if (use_json) { | |
10734 | json_object_string_add(json_neigh, "hostLocal", | |
10735 | sockunion2str(p->su_local, buf1, | |
10736 | SU_ADDRSTRLEN)); | |
10737 | json_object_int_add(json_neigh, "portLocal", | |
10738 | ntohs(p->su_local->sin.sin_port)); | |
10739 | } else | |
10740 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
10741 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
10742 | ntohs(p->su_local->sin.sin_port)); | |
10743 | } | |
10744 | ||
10745 | /* Remote address. */ | |
10746 | if (p->su_remote) { | |
10747 | if (use_json) { | |
10748 | json_object_string_add(json_neigh, "hostForeign", | |
10749 | sockunion2str(p->su_remote, buf1, | |
10750 | SU_ADDRSTRLEN)); | |
10751 | json_object_int_add(json_neigh, "portForeign", | |
10752 | ntohs(p->su_remote->sin.sin_port)); | |
10753 | } else | |
10754 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
10755 | sockunion2str(p->su_remote, buf1, | |
10756 | SU_ADDRSTRLEN), | |
10757 | ntohs(p->su_remote->sin.sin_port)); | |
10758 | } | |
10759 | ||
10760 | /* Nexthop display. */ | |
10761 | if (p->su_local) { | |
10762 | if (use_json) { | |
10763 | json_object_string_add(json_neigh, "nexthop", | |
10764 | inet_ntop(AF_INET, | |
10765 | &p->nexthop.v4, buf1, | |
10766 | sizeof(buf1))); | |
10767 | json_object_string_add(json_neigh, "nexthopGlobal", | |
10768 | inet_ntop(AF_INET6, | |
10769 | &p->nexthop.v6_global, | |
10770 | buf1, sizeof(buf1))); | |
10771 | json_object_string_add(json_neigh, "nexthopLocal", | |
10772 | inet_ntop(AF_INET6, | |
10773 | &p->nexthop.v6_local, | |
10774 | buf1, sizeof(buf1))); | |
10775 | if (p->shared_network) | |
10776 | json_object_string_add(json_neigh, | |
10777 | "bgpConnection", | |
10778 | "sharedNetwork"); | |
10779 | else | |
10780 | json_object_string_add(json_neigh, | |
10781 | "bgpConnection", | |
10782 | "nonSharedNetwork"); | |
10783 | } else { | |
10784 | vty_out(vty, "Nexthop: %s\n", | |
10785 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
10786 | sizeof(buf1))); | |
10787 | vty_out(vty, "Nexthop global: %s\n", | |
10788 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
10789 | sizeof(buf1))); | |
10790 | vty_out(vty, "Nexthop local: %s\n", | |
10791 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
10792 | sizeof(buf1))); | |
10793 | vty_out(vty, "BGP connection: %s\n", | |
10794 | p->shared_network ? "shared network" | |
10795 | : "non shared network"); | |
10796 | } | |
10797 | } | |
10798 | ||
10799 | /* Timer information. */ | |
10800 | if (use_json) { | |
10801 | json_object_int_add(json_neigh, "connectRetryTimer", | |
10802 | p->v_connect); | |
10803 | if (p->status == Established && p->rtt) | |
10804 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
10805 | p->rtt); | |
10806 | if (p->t_start) | |
10807 | json_object_int_add( | |
10808 | json_neigh, "nextStartTimerDueInMsecs", | |
10809 | thread_timer_remain_second(p->t_start) * 1000); | |
10810 | if (p->t_connect) | |
10811 | json_object_int_add( | |
10812 | json_neigh, "nextConnectTimerDueInMsecs", | |
10813 | thread_timer_remain_second(p->t_connect) | |
10814 | * 1000); | |
10815 | if (p->t_routeadv) { | |
10816 | json_object_int_add(json_neigh, "mraiInterval", | |
10817 | p->v_routeadv); | |
10818 | json_object_int_add( | |
10819 | json_neigh, "mraiTimerExpireInMsecs", | |
10820 | thread_timer_remain_second(p->t_routeadv) | |
10821 | * 1000); | |
10822 | } | |
10823 | if (p->password) | |
10824 | json_object_int_add(json_neigh, "authenticationEnabled", | |
10825 | 1); | |
10826 | ||
10827 | if (p->t_read) | |
10828 | json_object_string_add(json_neigh, "readThread", "on"); | |
10829 | else | |
10830 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
10831 | |
10832 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 10833 | json_object_string_add(json_neigh, "writeThread", "on"); |
10834 | else | |
10835 | json_object_string_add(json_neigh, "writeThread", | |
10836 | "off"); | |
10837 | } else { | |
10838 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
10839 | p->v_connect); | |
10840 | if (p->status == Established && p->rtt) | |
10841 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
10842 | p->rtt); | |
10843 | if (p->t_start) | |
10844 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
10845 | thread_timer_remain_second(p->t_start)); | |
10846 | if (p->t_connect) | |
10847 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
10848 | thread_timer_remain_second(p->t_connect)); | |
10849 | if (p->t_routeadv) | |
10850 | vty_out(vty, | |
10851 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
10852 | p->v_routeadv, | |
10853 | thread_timer_remain_second(p->t_routeadv)); | |
10854 | if (p->password) | |
10855 | vty_out(vty, "Peer Authentication Enabled\n"); | |
10856 | ||
cac9e917 | 10857 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
10858 | p->t_read ? "on" : "off", |
10859 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
10860 | ? "on" | |
cac9e917 | 10861 | : "off", p->fd); |
d62a17ae | 10862 | } |
10863 | ||
10864 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
10865 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
10866 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
10867 | ||
10868 | if (!use_json) | |
10869 | vty_out(vty, "\n"); | |
10870 | ||
10871 | /* BFD information. */ | |
10872 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
10873 | ||
10874 | if (use_json) { | |
10875 | if (p->conf_if) /* Configured interface name. */ | |
10876 | json_object_object_add(json, p->conf_if, json_neigh); | |
10877 | else /* Configured IP address. */ | |
10878 | json_object_object_add(json, p->host, json_neigh); | |
10879 | } | |
10880 | } | |
10881 | ||
10882 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, | |
10883 | enum show_type type, union sockunion *su, | |
9f049418 | 10884 | const char *conf_if, bool use_json, |
d62a17ae | 10885 | json_object *json) |
10886 | { | |
10887 | struct listnode *node, *nnode; | |
10888 | struct peer *peer; | |
10889 | int find = 0; | |
9f049418 | 10890 | bool nbr_output = false; |
d1927ebe AS |
10891 | afi_t afi = AFI_MAX; |
10892 | safi_t safi = SAFI_MAX; | |
10893 | ||
10894 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
10895 | afi = AFI_IP; | |
10896 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
10897 | afi = AFI_IP6; | |
10898 | } | |
d62a17ae | 10899 | |
10900 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
10901 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10902 | continue; | |
10903 | ||
10904 | switch (type) { | |
10905 | case show_all: | |
10906 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 10907 | nbr_output = true; |
d62a17ae | 10908 | break; |
10909 | case show_peer: | |
10910 | if (conf_if) { | |
10911 | if ((peer->conf_if | |
10912 | && !strcmp(peer->conf_if, conf_if)) | |
10913 | || (peer->hostname | |
10914 | && !strcmp(peer->hostname, conf_if))) { | |
10915 | find = 1; | |
10916 | bgp_show_peer(vty, peer, use_json, | |
10917 | json); | |
10918 | } | |
10919 | } else { | |
10920 | if (sockunion_same(&peer->su, su)) { | |
10921 | find = 1; | |
10922 | bgp_show_peer(vty, peer, use_json, | |
10923 | json); | |
10924 | } | |
10925 | } | |
10926 | break; | |
d1927ebe AS |
10927 | case show_ipv4_peer: |
10928 | case show_ipv6_peer: | |
10929 | FOREACH_SAFI (safi) { | |
10930 | if (peer->afc[afi][safi]) { | |
10931 | if (conf_if) { | |
10932 | if ((peer->conf_if | |
10933 | && !strcmp(peer->conf_if, conf_if)) | |
10934 | || (peer->hostname | |
10935 | && !strcmp(peer->hostname, conf_if))) { | |
10936 | find = 1; | |
10937 | bgp_show_peer(vty, peer, use_json, | |
10938 | json); | |
10939 | break; | |
10940 | } | |
10941 | } else { | |
10942 | if (sockunion_same(&peer->su, su)) { | |
10943 | find = 1; | |
10944 | bgp_show_peer(vty, peer, use_json, | |
10945 | json); | |
10946 | break; | |
10947 | } | |
10948 | } | |
10949 | } | |
10950 | } | |
10951 | break; | |
10952 | case show_ipv4_all: | |
10953 | case show_ipv6_all: | |
10954 | FOREACH_SAFI (safi) { | |
10955 | if (peer->afc[afi][safi]) { | |
10956 | bgp_show_peer(vty, peer, use_json, json); | |
10957 | nbr_output = true; | |
10958 | break; | |
10959 | } | |
10960 | } | |
10961 | break; | |
d62a17ae | 10962 | } |
10963 | } | |
10964 | ||
d1927ebe AS |
10965 | if ((type == show_peer || type == show_ipv4_peer || |
10966 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 10967 | if (use_json) |
10968 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
10969 | else | |
88b7d255 | 10970 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 10971 | } |
10972 | ||
d1927ebe AS |
10973 | if (type != show_peer && type != show_ipv4_peer && |
10974 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 10975 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 10976 | |
d62a17ae | 10977 | if (use_json) { |
996c9314 LB |
10978 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
10979 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 10980 | } else { |
10981 | vty_out(vty, "\n"); | |
10982 | } | |
10983 | ||
10984 | return CMD_SUCCESS; | |
10985 | } | |
10986 | ||
10987 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, | |
71aedaa3 DS |
10988 | enum show_type type, |
10989 | const char *ip_str, | |
9f049418 | 10990 | bool use_json) |
d62a17ae | 10991 | { |
0291c246 MK |
10992 | struct listnode *node, *nnode; |
10993 | struct bgp *bgp; | |
71aedaa3 | 10994 | union sockunion su; |
0291c246 | 10995 | json_object *json = NULL; |
71aedaa3 | 10996 | int ret, is_first = 1; |
9f049418 | 10997 | bool nbr_output = false; |
d62a17ae | 10998 | |
10999 | if (use_json) | |
11000 | vty_out(vty, "{\n"); | |
11001 | ||
11002 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 11003 | nbr_output = true; |
d62a17ae | 11004 | if (use_json) { |
11005 | if (!(json = json_object_new_object())) { | |
af4c2728 | 11006 | flog_err( |
e50f7cfd | 11007 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 11008 | "Unable to allocate memory for JSON object"); |
11009 | vty_out(vty, | |
11010 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
11011 | return; | |
11012 | } | |
11013 | ||
11014 | json_object_int_add(json, "vrfId", | |
11015 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
11016 | ? -1 |
11017 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 11018 | json_object_string_add( |
11019 | json, "vrfName", | |
11020 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11021 | ? VRF_DEFAULT_NAME |
d62a17ae | 11022 | : bgp->name); |
11023 | ||
11024 | if (!is_first) | |
11025 | vty_out(vty, ",\n"); | |
11026 | else | |
11027 | is_first = 0; | |
11028 | ||
11029 | vty_out(vty, "\"%s\":", | |
11030 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11031 | ? VRF_DEFAULT_NAME |
d62a17ae | 11032 | : bgp->name); |
11033 | } else { | |
11034 | vty_out(vty, "\nInstance %s:\n", | |
11035 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11036 | ? VRF_DEFAULT_NAME |
d62a17ae | 11037 | : bgp->name); |
11038 | } | |
71aedaa3 | 11039 | |
d1927ebe AS |
11040 | if (type == show_peer || type == show_ipv4_peer || |
11041 | type == show_ipv6_peer) { | |
71aedaa3 DS |
11042 | ret = str2sockunion(ip_str, &su); |
11043 | if (ret < 0) | |
11044 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
11045 | use_json, json); | |
11046 | else | |
11047 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
11048 | use_json, json); | |
11049 | } else { | |
d1927ebe | 11050 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
11051 | use_json, json); |
11052 | } | |
b77004d6 | 11053 | json_object_free(json); |
d62a17ae | 11054 | } |
11055 | ||
01cbfd04 | 11056 | if (use_json) { |
d62a17ae | 11057 | vty_out(vty, "}\n"); |
01cbfd04 QY |
11058 | json_object_free(json); |
11059 | } | |
9f049418 DS |
11060 | else if (!nbr_output) |
11061 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11062 | } |
11063 | ||
11064 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
11065 | enum show_type type, const char *ip_str, | |
9f049418 | 11066 | bool use_json) |
d62a17ae | 11067 | { |
11068 | int ret; | |
11069 | struct bgp *bgp; | |
11070 | union sockunion su; | |
11071 | json_object *json = NULL; | |
11072 | ||
11073 | if (name) { | |
11074 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
11075 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
11076 | use_json); | |
d62a17ae | 11077 | return CMD_SUCCESS; |
11078 | } else { | |
11079 | bgp = bgp_lookup_by_name(name); | |
11080 | if (!bgp) { | |
11081 | if (use_json) { | |
11082 | json = json_object_new_object(); | |
d62a17ae | 11083 | vty_out(vty, "%s\n", |
11084 | json_object_to_json_string_ext( | |
11085 | json, | |
11086 | JSON_C_TO_STRING_PRETTY)); | |
11087 | json_object_free(json); | |
11088 | } else | |
11089 | vty_out(vty, | |
9f049418 | 11090 | "%% BGP instance not found\n"); |
d62a17ae | 11091 | |
11092 | return CMD_WARNING; | |
11093 | } | |
11094 | } | |
11095 | } else { | |
11096 | bgp = bgp_get_default(); | |
11097 | } | |
11098 | ||
11099 | if (bgp) { | |
11100 | json = json_object_new_object(); | |
11101 | if (ip_str) { | |
11102 | ret = str2sockunion(ip_str, &su); | |
11103 | if (ret < 0) | |
11104 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
11105 | use_json, json); | |
11106 | else | |
11107 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
11108 | use_json, json); | |
11109 | } else { | |
11110 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
11111 | json); | |
11112 | } | |
11113 | json_object_free(json); | |
ca61fd25 DS |
11114 | } else { |
11115 | if (use_json) | |
11116 | vty_out(vty, "{}\n"); | |
11117 | else | |
11118 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11119 | } |
11120 | ||
11121 | return CMD_SUCCESS; | |
4fb25c53 DW |
11122 | } |
11123 | ||
716b2d8a | 11124 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 11125 | DEFUN (show_ip_bgp_neighbors, |
11126 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 11127 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 11128 | SHOW_STR |
11129 | IP_STR | |
11130 | BGP_STR | |
f2a8972b | 11131 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
11132 | "Address Family\n" |
11133 | "Address Family\n" | |
718e3744 | 11134 | "Detailed information on TCP and BGP neighbor connections\n" |
11135 | "Neighbor to display information about\n" | |
a80beece | 11136 | "Neighbor to display information about\n" |
91d37724 | 11137 | "Neighbor on BGP configured interface\n" |
9973d184 | 11138 | JSON_STR) |
718e3744 | 11139 | { |
d62a17ae | 11140 | char *vrf = NULL; |
11141 | char *sh_arg = NULL; | |
11142 | enum show_type sh_type; | |
d1927ebe | 11143 | afi_t afi = AFI_MAX; |
718e3744 | 11144 | |
9f049418 | 11145 | bool uj = use_json(argc, argv); |
718e3744 | 11146 | |
d62a17ae | 11147 | int idx = 0; |
718e3744 | 11148 | |
9a8bdf1c PG |
11149 | /* [<vrf> VIEWVRFNAME] */ |
11150 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11151 | vrf = argv[idx + 1]->arg; | |
11152 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11153 | vrf = NULL; | |
11154 | } else if (argv_find(argv, argc, "view", &idx)) | |
11155 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 11156 | vrf = argv[idx + 1]->arg; |
718e3744 | 11157 | |
d62a17ae | 11158 | idx++; |
d1927ebe AS |
11159 | |
11160 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
11161 | sh_type = show_ipv4_all; | |
11162 | afi = AFI_IP; | |
11163 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
11164 | sh_type = show_ipv6_all; | |
11165 | afi = AFI_IP6; | |
11166 | } else { | |
11167 | sh_type = show_all; | |
11168 | } | |
11169 | ||
d62a17ae | 11170 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
11171 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
11172 | || argv_find(argv, argc, "WORD", &idx)) { | |
11173 | sh_type = show_peer; | |
11174 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
11175 | } |
11176 | ||
11177 | if (sh_type == show_peer && afi == AFI_IP) { | |
11178 | sh_type = show_ipv4_peer; | |
11179 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
11180 | sh_type = show_ipv6_peer; | |
11181 | } | |
856ca177 | 11182 | |
d62a17ae | 11183 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 11184 | } |
11185 | ||
716b2d8a | 11186 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 11187 | paths' and `show ip mbgp paths'. Those functions results are the |
11188 | same.*/ | |
f412b39a | 11189 | DEFUN (show_ip_bgp_paths, |
718e3744 | 11190 | show_ip_bgp_paths_cmd, |
46f296b4 | 11191 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 11192 | SHOW_STR |
11193 | IP_STR | |
11194 | BGP_STR | |
46f296b4 | 11195 | BGP_SAFI_HELP_STR |
718e3744 | 11196 | "Path information\n") |
11197 | { | |
d62a17ae | 11198 | vty_out(vty, "Address Refcnt Path\n"); |
11199 | aspath_print_all_vty(vty); | |
11200 | return CMD_SUCCESS; | |
718e3744 | 11201 | } |
11202 | ||
718e3744 | 11203 | #include "hash.h" |
11204 | ||
e3b78da8 | 11205 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 11206 | struct vty *vty) |
718e3744 | 11207 | { |
d62a17ae | 11208 | struct community *com; |
718e3744 | 11209 | |
e3b78da8 | 11210 | com = (struct community *)bucket->data; |
3f65c5b1 | 11211 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 11212 | community_str(com, false)); |
718e3744 | 11213 | } |
11214 | ||
11215 | /* Show BGP's community internal data. */ | |
f412b39a | 11216 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 11217 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 11218 | "show [ip] bgp community-info", |
718e3744 | 11219 | SHOW_STR |
11220 | IP_STR | |
11221 | BGP_STR | |
11222 | "List all bgp community information\n") | |
11223 | { | |
d62a17ae | 11224 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 11225 | |
d62a17ae | 11226 | hash_iterate(community_hash(), |
e3b78da8 | 11227 | (void (*)(struct hash_bucket *, |
d62a17ae | 11228 | void *))community_show_all_iterator, |
11229 | vty); | |
718e3744 | 11230 | |
d62a17ae | 11231 | return CMD_SUCCESS; |
718e3744 | 11232 | } |
11233 | ||
e3b78da8 | 11234 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 11235 | struct vty *vty) |
57d187bc | 11236 | { |
d62a17ae | 11237 | struct lcommunity *lcom; |
57d187bc | 11238 | |
e3b78da8 | 11239 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 11240 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 11241 | lcommunity_str(lcom, false)); |
57d187bc JS |
11242 | } |
11243 | ||
11244 | /* Show BGP's community internal data. */ | |
11245 | DEFUN (show_ip_bgp_lcommunity_info, | |
11246 | show_ip_bgp_lcommunity_info_cmd, | |
11247 | "show ip bgp large-community-info", | |
11248 | SHOW_STR | |
11249 | IP_STR | |
11250 | BGP_STR | |
11251 | "List all bgp large-community information\n") | |
11252 | { | |
d62a17ae | 11253 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 11254 | |
d62a17ae | 11255 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 11256 | (void (*)(struct hash_bucket *, |
d62a17ae | 11257 | void *))lcommunity_show_all_iterator, |
11258 | vty); | |
57d187bc | 11259 | |
d62a17ae | 11260 | return CMD_SUCCESS; |
57d187bc JS |
11261 | } |
11262 | ||
11263 | ||
f412b39a | 11264 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 11265 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 11266 | "show [ip] bgp attribute-info", |
718e3744 | 11267 | SHOW_STR |
11268 | IP_STR | |
11269 | BGP_STR | |
11270 | "List all bgp attribute information\n") | |
11271 | { | |
d62a17ae | 11272 | attr_show_all(vty); |
11273 | return CMD_SUCCESS; | |
718e3744 | 11274 | } |
6b0655a2 | 11275 | |
03915806 CS |
11276 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
11277 | afi_t afi, safi_t safi, | |
11278 | bool use_json, json_object *json) | |
53089bec | 11279 | { |
11280 | struct bgp *bgp; | |
11281 | struct listnode *node; | |
11282 | char *vname; | |
11283 | char buf1[INET6_ADDRSTRLEN]; | |
11284 | char *ecom_str; | |
11285 | vpn_policy_direction_t dir; | |
11286 | ||
03915806 | 11287 | if (json) { |
b46dfd20 DS |
11288 | json_object *json_import_vrfs = NULL; |
11289 | json_object *json_export_vrfs = NULL; | |
11290 | ||
b46dfd20 DS |
11291 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
11292 | ||
53089bec | 11293 | if (!bgp) { |
b46dfd20 DS |
11294 | vty_out(vty, "%s\n", |
11295 | json_object_to_json_string_ext( | |
11296 | json, | |
11297 | JSON_C_TO_STRING_PRETTY)); | |
11298 | json_object_free(json); | |
11299 | ||
53089bec | 11300 | return CMD_WARNING; |
11301 | } | |
b46dfd20 | 11302 | |
94d4c685 DS |
11303 | /* Provide context for the block */ |
11304 | json_object_string_add(json, "vrf", name ? name : "default"); | |
11305 | json_object_string_add(json, "afiSafi", | |
11306 | afi_safi_print(afi, safi)); | |
11307 | ||
b46dfd20 DS |
11308 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11309 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
11310 | json_object_string_add(json, "importFromVrfs", "none"); | |
11311 | json_object_string_add(json, "importRts", "none"); | |
11312 | } else { | |
6ce24e52 DS |
11313 | json_import_vrfs = json_object_new_array(); |
11314 | ||
b46dfd20 DS |
11315 | for (ALL_LIST_ELEMENTS_RO( |
11316 | bgp->vpn_policy[afi].import_vrf, | |
11317 | node, vname)) | |
11318 | json_object_array_add(json_import_vrfs, | |
11319 | json_object_new_string(vname)); | |
11320 | ||
b20875ea CS |
11321 | json_object_object_add(json, "importFromVrfs", |
11322 | json_import_vrfs); | |
b46dfd20 | 11323 | dir = BGP_VPN_POLICY_DIR_FROMVPN; |
b20875ea CS |
11324 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
11325 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
11326 | bgp->vpn_policy[afi].rtlist[dir], |
11327 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
11328 | json_object_string_add(json, "importRts", |
11329 | ecom_str); | |
11330 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11331 | } else | |
11332 | json_object_string_add(json, "importRts", | |
11333 | "none"); | |
b46dfd20 DS |
11334 | } |
11335 | ||
11336 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
11337 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
11338 | json_object_string_add(json, "exportToVrfs", "none"); | |
11339 | json_object_string_add(json, "routeDistinguisher", | |
11340 | "none"); | |
11341 | json_object_string_add(json, "exportRts", "none"); | |
11342 | } else { | |
6ce24e52 DS |
11343 | json_export_vrfs = json_object_new_array(); |
11344 | ||
b46dfd20 DS |
11345 | for (ALL_LIST_ELEMENTS_RO( |
11346 | bgp->vpn_policy[afi].export_vrf, | |
11347 | node, vname)) | |
11348 | json_object_array_add(json_export_vrfs, | |
11349 | json_object_new_string(vname)); | |
11350 | json_object_object_add(json, "exportToVrfs", | |
11351 | json_export_vrfs); | |
11352 | json_object_string_add(json, "routeDistinguisher", | |
11353 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11354 | buf1, RD_ADDRSTRLEN)); | |
11355 | ||
11356 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
11357 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
11358 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
11359 | bgp->vpn_policy[afi].rtlist[dir], |
11360 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
11361 | json_object_string_add(json, "exportRts", |
11362 | ecom_str); | |
11363 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11364 | } else | |
11365 | json_object_string_add(json, "exportRts", | |
11366 | "none"); | |
b46dfd20 DS |
11367 | } |
11368 | ||
03915806 CS |
11369 | if (use_json) { |
11370 | vty_out(vty, "%s\n", | |
11371 | json_object_to_json_string_ext(json, | |
b46dfd20 | 11372 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
11373 | json_object_free(json); |
11374 | } | |
53089bec | 11375 | } else { |
b46dfd20 DS |
11376 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
11377 | ||
53089bec | 11378 | if (!bgp) { |
b46dfd20 | 11379 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 11380 | return CMD_WARNING; |
11381 | } | |
53089bec | 11382 | |
b46dfd20 DS |
11383 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11384 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
11385 | vty_out(vty, | |
11386 | "This VRF is not importing %s routes from any other VRF\n", | |
11387 | afi_safi_print(afi, safi)); | |
11388 | else { | |
11389 | vty_out(vty, | |
11390 | "This VRF is importing %s routes from the following VRFs:\n", | |
11391 | afi_safi_print(afi, safi)); | |
11392 | ||
11393 | for (ALL_LIST_ELEMENTS_RO( | |
11394 | bgp->vpn_policy[afi].import_vrf, | |
11395 | node, vname)) | |
11396 | vty_out(vty, " %s\n", vname); | |
11397 | ||
11398 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
b20875ea CS |
11399 | ecom_str = NULL; |
11400 | if (bgp->vpn_policy[afi].rtlist[dir]) { | |
11401 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
11402 | bgp->vpn_policy[afi].rtlist[dir], |
11403 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea | 11404 | vty_out(vty, "Import RT(s): %s\n", ecom_str); |
b46dfd20 | 11405 | |
b20875ea CS |
11406 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
11407 | } else | |
11408 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 11409 | } |
53089bec | 11410 | |
b46dfd20 DS |
11411 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11412 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
11413 | vty_out(vty, | |
11414 | "This VRF is not exporting %s routes to any other VRF\n", | |
53089bec | 11415 | afi_safi_print(afi, safi)); |
b46dfd20 DS |
11416 | else { |
11417 | vty_out(vty, | |
04c9077f | 11418 | "This VRF is exporting %s routes to the following VRFs:\n", |
53089bec | 11419 | afi_safi_print(afi, safi)); |
b46dfd20 DS |
11420 | |
11421 | for (ALL_LIST_ELEMENTS_RO( | |
11422 | bgp->vpn_policy[afi].export_vrf, | |
11423 | node, vname)) | |
11424 | vty_out(vty, " %s\n", vname); | |
11425 | ||
11426 | vty_out(vty, "RD: %s\n", | |
11427 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11428 | buf1, RD_ADDRSTRLEN)); | |
11429 | ||
11430 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
b20875ea CS |
11431 | if (bgp->vpn_policy[afi].rtlist[dir]) { |
11432 | ecom_str = ecommunity_ecom2str( | |
b46dfd20 DS |
11433 | bgp->vpn_policy[afi].rtlist[dir], |
11434 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
b20875ea CS |
11435 | vty_out(vty, "Export RT: %s\n", ecom_str); |
11436 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11437 | } else | |
11438 | vty_out(vty, "Import RT(s):\n"); | |
53089bec | 11439 | } |
53089bec | 11440 | } |
11441 | ||
11442 | return CMD_SUCCESS; | |
11443 | } | |
11444 | ||
03915806 CS |
11445 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
11446 | safi_t safi, bool use_json) | |
11447 | { | |
11448 | struct listnode *node, *nnode; | |
11449 | struct bgp *bgp; | |
11450 | char *vrf_name = NULL; | |
11451 | json_object *json = NULL; | |
11452 | json_object *json_vrf = NULL; | |
11453 | json_object *json_vrfs = NULL; | |
11454 | ||
11455 | if (use_json) { | |
11456 | json = json_object_new_object(); | |
11457 | json_vrfs = json_object_new_object(); | |
11458 | } | |
11459 | ||
11460 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
11461 | ||
11462 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
11463 | vrf_name = bgp->name; | |
11464 | ||
11465 | if (use_json) { | |
11466 | json_vrf = json_object_new_object(); | |
11467 | } else { | |
11468 | vty_out(vty, "\nInstance %s:\n", | |
11469 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
11470 | ? VRF_DEFAULT_NAME : bgp->name); | |
11471 | } | |
11472 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
11473 | if (use_json) { | |
11474 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
11475 | json_object_object_add(json_vrfs, | |
11476 | VRF_DEFAULT_NAME, json_vrf); | |
11477 | else | |
11478 | json_object_object_add(json_vrfs, vrf_name, | |
11479 | json_vrf); | |
11480 | } | |
11481 | } | |
11482 | ||
11483 | if (use_json) { | |
11484 | json_object_object_add(json, "vrfs", json_vrfs); | |
11485 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
11486 | JSON_C_TO_STRING_PRETTY)); | |
11487 | json_object_free(json); | |
11488 | } | |
11489 | ||
11490 | return CMD_SUCCESS; | |
11491 | } | |
11492 | ||
53089bec | 11493 | /* "show [ip] bgp route-leak" command. */ |
11494 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
11495 | show_ip_bgp_route_leak_cmd, |
11496 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
11497 | SHOW_STR |
11498 | IP_STR | |
11499 | BGP_STR | |
11500 | BGP_INSTANCE_HELP_STR | |
11501 | BGP_AFI_HELP_STR | |
11502 | BGP_SAFI_HELP_STR | |
11503 | "Route leaking information\n" | |
11504 | JSON_STR) | |
53089bec | 11505 | { |
11506 | char *vrf = NULL; | |
11507 | afi_t afi = AFI_MAX; | |
11508 | safi_t safi = SAFI_MAX; | |
11509 | ||
9f049418 | 11510 | bool uj = use_json(argc, argv); |
53089bec | 11511 | int idx = 0; |
03915806 | 11512 | json_object *json = NULL; |
53089bec | 11513 | |
11514 | /* show [ip] bgp */ | |
11515 | if (argv_find(argv, argc, "ip", &idx)) { | |
11516 | afi = AFI_IP; | |
11517 | safi = SAFI_UNICAST; | |
11518 | } | |
11519 | /* [vrf VIEWVRFNAME] */ | |
11520 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
11521 | vty_out(vty, |
11522 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 11523 | return CMD_WARNING; |
11524 | } | |
11525 | ||
9a8bdf1c PG |
11526 | if (argv_find(argv, argc, "vrf", &idx)) { |
11527 | vrf = argv[idx + 1]->arg; | |
11528 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11529 | vrf = NULL; | |
11530 | } | |
53089bec | 11531 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11532 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11533 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11534 | } | |
11535 | ||
11536 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
11537 | vty_out(vty, |
11538 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 11539 | return CMD_WARNING; |
11540 | } | |
11541 | ||
03915806 CS |
11542 | if (vrf && strmatch(vrf, "all")) |
11543 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
11544 | ||
11545 | if (uj) | |
11546 | json = json_object_new_object(); | |
11547 | ||
11548 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 11549 | } |
11550 | ||
d62a17ae | 11551 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
11552 | safi_t safi) | |
f186de26 | 11553 | { |
d62a17ae | 11554 | struct listnode *node, *nnode; |
11555 | struct bgp *bgp; | |
f186de26 | 11556 | |
d62a17ae | 11557 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
11558 | vty_out(vty, "\nInstance %s:\n", | |
11559 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11560 | ? VRF_DEFAULT_NAME |
d62a17ae | 11561 | : bgp->name); |
11562 | update_group_show(bgp, afi, safi, vty, 0); | |
11563 | } | |
f186de26 | 11564 | } |
11565 | ||
d62a17ae | 11566 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
11567 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 11568 | { |
d62a17ae | 11569 | struct bgp *bgp; |
4fb25c53 | 11570 | |
d62a17ae | 11571 | if (name) { |
11572 | if (strmatch(name, "all")) { | |
11573 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
11574 | return CMD_SUCCESS; | |
11575 | } else { | |
11576 | bgp = bgp_lookup_by_name(name); | |
11577 | } | |
11578 | } else { | |
11579 | bgp = bgp_get_default(); | |
11580 | } | |
4fb25c53 | 11581 | |
d62a17ae | 11582 | if (bgp) |
11583 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
11584 | return CMD_SUCCESS; | |
4fb25c53 DW |
11585 | } |
11586 | ||
8fe8a7f6 DS |
11587 | DEFUN (show_ip_bgp_updgrps, |
11588 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 11589 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 11590 | SHOW_STR |
11591 | IP_STR | |
11592 | BGP_STR | |
11593 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 11594 | BGP_AFI_HELP_STR |
9bedbb1e | 11595 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
11596 | "Detailed info about dynamic update groups\n" |
11597 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 11598 | { |
d62a17ae | 11599 | char *vrf = NULL; |
11600 | afi_t afi = AFI_IP6; | |
11601 | safi_t safi = SAFI_UNICAST; | |
11602 | uint64_t subgrp_id = 0; | |
11603 | ||
11604 | int idx = 0; | |
11605 | ||
11606 | /* show [ip] bgp */ | |
11607 | if (argv_find(argv, argc, "ip", &idx)) | |
11608 | afi = AFI_IP; | |
9a8bdf1c PG |
11609 | /* [<vrf> VIEWVRFNAME] */ |
11610 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11611 | vrf = argv[idx + 1]->arg; | |
11612 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11613 | vrf = NULL; | |
11614 | } else if (argv_find(argv, argc, "view", &idx)) | |
11615 | /* [<view> VIEWVRFNAME] */ | |
11616 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11617 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11618 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11619 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11620 | } | |
5bf15956 | 11621 | |
d62a17ae | 11622 | /* get subgroup id, if provided */ |
11623 | idx = argc - 1; | |
11624 | if (argv[idx]->type == VARIABLE_TKN) | |
11625 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 11626 | |
d62a17ae | 11627 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
11628 | } |
11629 | ||
f186de26 | 11630 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
11631 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 11632 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 11633 | SHOW_STR |
716b2d8a | 11634 | IP_STR |
f186de26 | 11635 | BGP_STR |
11636 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 11637 | "Detailed info about dynamic update groups\n") |
f186de26 | 11638 | { |
d62a17ae | 11639 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
11640 | return CMD_SUCCESS; | |
f186de26 | 11641 | } |
11642 | ||
43d3f4fc DS |
11643 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
11644 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
11645 | "show [ip] bgp l2vpn evpn update-groups", | |
11646 | SHOW_STR | |
11647 | IP_STR | |
11648 | BGP_STR | |
11649 | "l2vpn address family\n" | |
11650 | "evpn sub-address family\n" | |
11651 | "Detailed info about dynamic update groups\n") | |
11652 | { | |
11653 | char *vrf = NULL; | |
11654 | uint64_t subgrp_id = 0; | |
11655 | ||
11656 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
11657 | return CMD_SUCCESS; | |
11658 | } | |
11659 | ||
5bf15956 DW |
11660 | DEFUN (show_bgp_updgrps_stats, |
11661 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 11662 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 11663 | SHOW_STR |
716b2d8a | 11664 | IP_STR |
3f9c7369 | 11665 | BGP_STR |
0c7b1b01 | 11666 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
11667 | "Statistics\n") |
11668 | { | |
d62a17ae | 11669 | struct bgp *bgp; |
3f9c7369 | 11670 | |
d62a17ae | 11671 | bgp = bgp_get_default(); |
11672 | if (bgp) | |
11673 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 11674 | |
d62a17ae | 11675 | return CMD_SUCCESS; |
3f9c7369 DS |
11676 | } |
11677 | ||
8386ac43 | 11678 | DEFUN (show_bgp_instance_updgrps_stats, |
11679 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 11680 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 11681 | SHOW_STR |
716b2d8a | 11682 | IP_STR |
8386ac43 | 11683 | BGP_STR |
11684 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 11685 | "Detailed info about dynamic update groups\n" |
8386ac43 | 11686 | "Statistics\n") |
11687 | { | |
d62a17ae | 11688 | int idx_word = 3; |
11689 | struct bgp *bgp; | |
8386ac43 | 11690 | |
d62a17ae | 11691 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
11692 | if (bgp) | |
11693 | update_group_show_stats(bgp, vty); | |
8386ac43 | 11694 | |
d62a17ae | 11695 | return CMD_SUCCESS; |
8386ac43 | 11696 | } |
11697 | ||
d62a17ae | 11698 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
11699 | afi_t afi, safi_t safi, | |
11700 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 11701 | { |
d62a17ae | 11702 | struct bgp *bgp; |
8386ac43 | 11703 | |
d62a17ae | 11704 | if (name) |
11705 | bgp = bgp_lookup_by_name(name); | |
11706 | else | |
11707 | bgp = bgp_get_default(); | |
8386ac43 | 11708 | |
d62a17ae | 11709 | if (bgp) { |
11710 | if (!strcmp(what, "advertise-queue")) | |
11711 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
11712 | subgrp_id); | |
11713 | else if (!strcmp(what, "advertised-routes")) | |
11714 | update_group_show_advertised(bgp, afi, safi, vty, | |
11715 | subgrp_id); | |
11716 | else if (!strcmp(what, "packet-queue")) | |
11717 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
11718 | subgrp_id); | |
11719 | } | |
3f9c7369 DS |
11720 | } |
11721 | ||
dc64bdec QY |
11722 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
11723 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
11724 | "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", | |
11725 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
11726 | BGP_SAFI_HELP_STR | |
11727 | "Detailed info about dynamic update groups\n" | |
11728 | "Specific subgroup to display info for\n" | |
11729 | "Advertisement queue\n" | |
11730 | "Announced routes\n" | |
11731 | "Packet queue\n") | |
3f9c7369 | 11732 | { |
dc64bdec QY |
11733 | uint64_t subgrp_id = 0; |
11734 | afi_t afiz; | |
11735 | safi_t safiz; | |
11736 | if (sgid) | |
11737 | subgrp_id = strtoull(sgid, NULL, 10); | |
11738 | ||
11739 | if (!ip && !afi) | |
11740 | afiz = AFI_IP6; | |
11741 | if (!ip && afi) | |
11742 | afiz = bgp_vty_afi_from_str(afi); | |
11743 | if (ip && !afi) | |
11744 | afiz = AFI_IP; | |
11745 | if (ip && afi) { | |
11746 | afiz = bgp_vty_afi_from_str(afi); | |
11747 | if (afiz != AFI_IP) | |
11748 | vty_out(vty, | |
11749 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
11750 | return CMD_WARNING; | |
11751 | } | |
d62a17ae | 11752 | |
dc64bdec | 11753 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 11754 | |
dc64bdec | 11755 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 11756 | return CMD_SUCCESS; |
11757 | } | |
11758 | ||
d62a17ae | 11759 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
11760 | { | |
11761 | struct listnode *node, *nnode; | |
11762 | struct prefix *range; | |
11763 | struct peer *conf; | |
11764 | struct peer *peer; | |
11765 | char buf[PREFIX2STR_BUFFER]; | |
11766 | afi_t afi; | |
11767 | safi_t safi; | |
11768 | const char *peer_status; | |
11769 | const char *af_str; | |
11770 | int lr_count; | |
11771 | int dynamic; | |
11772 | int af_cfgd; | |
11773 | ||
11774 | conf = group->conf; | |
11775 | ||
11776 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
3b61f610 QY |
11777 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
11778 | group->name, conf->as); | |
d62a17ae | 11779 | } else if (conf->as_type == AS_INTERNAL) { |
3b61f610 QY |
11780 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
11781 | group->name, group->bgp->as); | |
d62a17ae | 11782 | } else { |
11783 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
11784 | } | |
f14e6fdb | 11785 | |
d62a17ae | 11786 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
11787 | vty_out(vty, " Peer-group type is internal\n"); | |
11788 | else | |
11789 | vty_out(vty, " Peer-group type is external\n"); | |
11790 | ||
11791 | /* Display AFs configured. */ | |
11792 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
11793 | FOREACH_AFI_SAFI (afi, safi) { |
11794 | if (conf->afc[afi][safi]) { | |
11795 | af_cfgd = 1; | |
11796 | vty_out(vty, " %s;", afi_safi_print(afi, safi)); | |
d62a17ae | 11797 | } |
05c7a1cc | 11798 | } |
d62a17ae | 11799 | if (!af_cfgd) |
11800 | vty_out(vty, " none\n"); | |
11801 | else | |
11802 | vty_out(vty, "\n"); | |
11803 | ||
11804 | /* Display listen ranges (for dynamic neighbors), if any */ | |
11805 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
11806 | if (afi == AFI_IP) | |
11807 | af_str = "IPv4"; | |
11808 | else if (afi == AFI_IP6) | |
11809 | af_str = "IPv6"; | |
11810 | else | |
11811 | af_str = "???"; | |
11812 | lr_count = listcount(group->listen_range[afi]); | |
11813 | if (lr_count) { | |
11814 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
11815 | af_str); | |
11816 | ||
11817 | ||
11818 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
11819 | nnode, range)) { | |
11820 | prefix2str(range, buf, sizeof(buf)); | |
11821 | vty_out(vty, " %s\n", buf); | |
11822 | } | |
11823 | } | |
11824 | } | |
f14e6fdb | 11825 | |
d62a17ae | 11826 | /* Display group members and their status */ |
11827 | if (listcount(group->peer)) { | |
11828 | vty_out(vty, " Peer-group members:\n"); | |
11829 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
11830 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
11831 | peer_status = "Idle (Admin)"; | |
11832 | else if (CHECK_FLAG(peer->sflags, | |
11833 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11834 | peer_status = "Idle (PfxCt)"; | |
11835 | else | |
11836 | peer_status = lookup_msg(bgp_status_msg, | |
11837 | peer->status, NULL); | |
11838 | ||
11839 | dynamic = peer_dynamic_neighbor(peer); | |
11840 | vty_out(vty, " %s %s %s \n", peer->host, | |
11841 | dynamic ? "(dynamic)" : "", peer_status); | |
11842 | } | |
11843 | } | |
f14e6fdb | 11844 | |
d62a17ae | 11845 | return CMD_SUCCESS; |
11846 | } | |
11847 | ||
ff9959b0 QY |
11848 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
11849 | const char *group_name) | |
d62a17ae | 11850 | { |
ff9959b0 | 11851 | struct bgp *bgp; |
d62a17ae | 11852 | struct listnode *node, *nnode; |
11853 | struct peer_group *group; | |
ff9959b0 QY |
11854 | bool found = false; |
11855 | ||
11856 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
11857 | ||
11858 | if (!bgp) { | |
9f049418 | 11859 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
11860 | return CMD_WARNING; |
11861 | } | |
d62a17ae | 11862 | |
11863 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
11864 | if (group_name) { |
11865 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 11866 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
11867 | found = true; |
11868 | break; | |
d62a17ae | 11869 | } |
ff9959b0 QY |
11870 | } else { |
11871 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 11872 | } |
f14e6fdb | 11873 | } |
f14e6fdb | 11874 | |
ff9959b0 | 11875 | if (group_name && !found) |
d62a17ae | 11876 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 11877 | |
d62a17ae | 11878 | return CMD_SUCCESS; |
f14e6fdb DS |
11879 | } |
11880 | ||
f14e6fdb DS |
11881 | DEFUN (show_ip_bgp_peer_groups, |
11882 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 11883 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
11884 | SHOW_STR |
11885 | IP_STR | |
11886 | BGP_STR | |
8386ac43 | 11887 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
11888 | "Detailed information on BGP peer groups\n" |
11889 | "Peer group name\n") | |
f14e6fdb | 11890 | { |
d62a17ae | 11891 | char *vrf, *pg; |
d62a17ae | 11892 | int idx = 0; |
f14e6fdb | 11893 | |
a4d82a8a PZ |
11894 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
11895 | : NULL; | |
d62a17ae | 11896 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 11897 | |
ff9959b0 | 11898 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 11899 | } |
3f9c7369 | 11900 | |
d6e3c605 | 11901 | |
718e3744 | 11902 | /* Redistribute VTY commands. */ |
11903 | ||
718e3744 | 11904 | DEFUN (bgp_redistribute_ipv4, |
11905 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 11906 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 11907 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11908 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 11909 | { |
d62a17ae | 11910 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11911 | int idx_protocol = 1; | |
11912 | int type; | |
718e3744 | 11913 | |
d62a17ae | 11914 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
11915 | if (type < 0) { | |
11916 | vty_out(vty, "%% Invalid route type\n"); | |
11917 | return CMD_WARNING_CONFIG_FAILED; | |
11918 | } | |
7f323236 | 11919 | |
d62a17ae | 11920 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 11921 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 11922 | } |
11923 | ||
d62a17ae | 11924 | ALIAS_HIDDEN( |
11925 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
11926 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
11927 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 11928 | |
718e3744 | 11929 | DEFUN (bgp_redistribute_ipv4_rmap, |
11930 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 11931 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 11932 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11933 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11934 | "Route map reference\n" |
11935 | "Pointer to route-map entries\n") | |
11936 | { | |
d62a17ae | 11937 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11938 | int idx_protocol = 1; | |
11939 | int idx_word = 3; | |
11940 | int type; | |
11941 | struct bgp_redist *red; | |
e923dd62 | 11942 | bool changed; |
1de27621 DA |
11943 | struct route_map *route_map = route_map_lookup_warn_noexist( |
11944 | vty, argv[idx_word]->arg); | |
718e3744 | 11945 | |
d62a17ae | 11946 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
11947 | if (type < 0) { | |
11948 | vty_out(vty, "%% Invalid route type\n"); | |
11949 | return CMD_WARNING_CONFIG_FAILED; | |
11950 | } | |
718e3744 | 11951 | |
d62a17ae | 11952 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
11953 | changed = |
11954 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 11955 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 11956 | } |
11957 | ||
d62a17ae | 11958 | ALIAS_HIDDEN( |
11959 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
11960 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
11961 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11962 | "Route map reference\n" | |
11963 | "Pointer to route-map entries\n") | |
596c17ba | 11964 | |
718e3744 | 11965 | DEFUN (bgp_redistribute_ipv4_metric, |
11966 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 11967 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 11968 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11969 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11970 | "Metric for redistributed routes\n" |
11971 | "Default metric\n") | |
11972 | { | |
d62a17ae | 11973 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11974 | int idx_protocol = 1; | |
11975 | int idx_number = 3; | |
11976 | int type; | |
d7c0a89a | 11977 | uint32_t metric; |
d62a17ae | 11978 | struct bgp_redist *red; |
e923dd62 | 11979 | bool changed; |
d62a17ae | 11980 | |
11981 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11982 | if (type < 0) { | |
11983 | vty_out(vty, "%% Invalid route type\n"); | |
11984 | return CMD_WARNING_CONFIG_FAILED; | |
11985 | } | |
11986 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11987 | ||
11988 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 11989 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
11990 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 11991 | } |
11992 | ||
11993 | ALIAS_HIDDEN( | |
11994 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
11995 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
11996 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11997 | "Metric for redistributed routes\n" | |
11998 | "Default metric\n") | |
596c17ba | 11999 | |
718e3744 | 12000 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
12001 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 12002 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 12003 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12004 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12005 | "Route map reference\n" |
12006 | "Pointer to route-map entries\n" | |
12007 | "Metric for redistributed routes\n" | |
12008 | "Default metric\n") | |
12009 | { | |
d62a17ae | 12010 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12011 | int idx_protocol = 1; | |
12012 | int idx_word = 3; | |
12013 | int idx_number = 5; | |
12014 | int type; | |
d7c0a89a | 12015 | uint32_t metric; |
d62a17ae | 12016 | struct bgp_redist *red; |
e923dd62 | 12017 | bool changed; |
1de27621 DA |
12018 | struct route_map *route_map = |
12019 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12020 | |
12021 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12022 | if (type < 0) { | |
12023 | vty_out(vty, "%% Invalid route type\n"); | |
12024 | return CMD_WARNING_CONFIG_FAILED; | |
12025 | } | |
12026 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
12027 | ||
12028 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
12029 | changed = |
12030 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12031 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
12032 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 12033 | } |
12034 | ||
12035 | ALIAS_HIDDEN( | |
12036 | bgp_redistribute_ipv4_rmap_metric, | |
12037 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
12038 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
12039 | " route-map WORD metric (0-4294967295)", | |
12040 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12041 | "Route map reference\n" | |
12042 | "Pointer to route-map entries\n" | |
12043 | "Metric for redistributed routes\n" | |
12044 | "Default metric\n") | |
596c17ba | 12045 | |
718e3744 | 12046 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
12047 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 12048 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 12049 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12050 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12051 | "Metric for redistributed routes\n" |
12052 | "Default metric\n" | |
12053 | "Route map reference\n" | |
12054 | "Pointer to route-map entries\n") | |
12055 | { | |
d62a17ae | 12056 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12057 | int idx_protocol = 1; | |
12058 | int idx_number = 3; | |
12059 | int idx_word = 5; | |
12060 | int type; | |
d7c0a89a | 12061 | uint32_t metric; |
d62a17ae | 12062 | struct bgp_redist *red; |
e923dd62 | 12063 | bool changed; |
1de27621 DA |
12064 | struct route_map *route_map = |
12065 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12066 | |
12067 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12068 | if (type < 0) { | |
12069 | vty_out(vty, "%% Invalid route type\n"); | |
12070 | return CMD_WARNING_CONFIG_FAILED; | |
12071 | } | |
12072 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
12073 | ||
12074 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 12075 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
12076 | changed |= |
12077 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12078 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 12079 | } |
12080 | ||
12081 | ALIAS_HIDDEN( | |
12082 | bgp_redistribute_ipv4_metric_rmap, | |
12083 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
12084 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
12085 | " metric (0-4294967295) route-map WORD", | |
12086 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12087 | "Metric for redistributed routes\n" | |
12088 | "Default metric\n" | |
12089 | "Route map reference\n" | |
12090 | "Pointer to route-map entries\n") | |
596c17ba | 12091 | |
7c8ff89e DS |
12092 | DEFUN (bgp_redistribute_ipv4_ospf, |
12093 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 12094 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
12095 | "Redistribute information from another routing protocol\n" |
12096 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12097 | "Non-main Kernel Routing Table\n" |
12098 | "Instance ID/Table ID\n") | |
7c8ff89e | 12099 | { |
d62a17ae | 12100 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12101 | int idx_ospf_table = 1; | |
12102 | int idx_number = 2; | |
d7c0a89a QY |
12103 | unsigned short instance; |
12104 | unsigned short protocol; | |
7c8ff89e | 12105 | |
d62a17ae | 12106 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 12107 | |
d62a17ae | 12108 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
12109 | protocol = ZEBRA_ROUTE_OSPF; | |
12110 | else | |
12111 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 12112 | |
d62a17ae | 12113 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 12114 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
12115 | } |
12116 | ||
d62a17ae | 12117 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
12118 | "redistribute <ospf|table> (1-65535)", | |
12119 | "Redistribute information from another routing protocol\n" | |
12120 | "Open Shortest Path First (OSPFv2)\n" | |
12121 | "Non-main Kernel Routing Table\n" | |
12122 | "Instance ID/Table ID\n") | |
596c17ba | 12123 | |
7c8ff89e DS |
12124 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
12125 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 12126 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
12127 | "Redistribute information from another routing protocol\n" |
12128 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12129 | "Non-main Kernel Routing Table\n" |
12130 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12131 | "Route map reference\n" |
12132 | "Pointer to route-map entries\n") | |
12133 | { | |
d62a17ae | 12134 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12135 | int idx_ospf_table = 1; | |
12136 | int idx_number = 2; | |
12137 | int idx_word = 4; | |
12138 | struct bgp_redist *red; | |
d7c0a89a | 12139 | unsigned short instance; |
d62a17ae | 12140 | int protocol; |
e923dd62 | 12141 | bool changed; |
1de27621 DA |
12142 | struct route_map *route_map = |
12143 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12144 | |
12145 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12146 | protocol = ZEBRA_ROUTE_OSPF; | |
12147 | else | |
12148 | protocol = ZEBRA_ROUTE_TABLE; | |
12149 | ||
12150 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12151 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
12152 | changed = |
12153 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12154 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 12155 | } |
12156 | ||
12157 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
12158 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
12159 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
12160 | "Redistribute information from another routing protocol\n" | |
12161 | "Open Shortest Path First (OSPFv2)\n" | |
12162 | "Non-main Kernel Routing Table\n" | |
12163 | "Instance ID/Table ID\n" | |
12164 | "Route map reference\n" | |
12165 | "Pointer to route-map entries\n") | |
596c17ba | 12166 | |
7c8ff89e DS |
12167 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
12168 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 12169 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
12170 | "Redistribute information from another routing protocol\n" |
12171 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12172 | "Non-main Kernel Routing Table\n" |
12173 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12174 | "Metric for redistributed routes\n" |
12175 | "Default metric\n") | |
12176 | { | |
d62a17ae | 12177 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12178 | int idx_ospf_table = 1; | |
12179 | int idx_number = 2; | |
12180 | int idx_number_2 = 4; | |
d7c0a89a | 12181 | uint32_t metric; |
d62a17ae | 12182 | struct bgp_redist *red; |
d7c0a89a | 12183 | unsigned short instance; |
d62a17ae | 12184 | int protocol; |
e923dd62 | 12185 | bool changed; |
d62a17ae | 12186 | |
12187 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12188 | protocol = ZEBRA_ROUTE_OSPF; | |
12189 | else | |
12190 | protocol = ZEBRA_ROUTE_TABLE; | |
12191 | ||
12192 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12193 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12194 | ||
12195 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 12196 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12197 | metric); | |
12198 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 12199 | } |
12200 | ||
12201 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
12202 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
12203 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
12204 | "Redistribute information from another routing protocol\n" | |
12205 | "Open Shortest Path First (OSPFv2)\n" | |
12206 | "Non-main Kernel Routing Table\n" | |
12207 | "Instance ID/Table ID\n" | |
12208 | "Metric for redistributed routes\n" | |
12209 | "Default metric\n") | |
596c17ba | 12210 | |
7c8ff89e DS |
12211 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
12212 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 12213 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
12214 | "Redistribute information from another routing protocol\n" |
12215 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12216 | "Non-main Kernel Routing Table\n" |
12217 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12218 | "Route map reference\n" |
12219 | "Pointer to route-map entries\n" | |
12220 | "Metric for redistributed routes\n" | |
12221 | "Default metric\n") | |
12222 | { | |
d62a17ae | 12223 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12224 | int idx_ospf_table = 1; | |
12225 | int idx_number = 2; | |
12226 | int idx_word = 4; | |
12227 | int idx_number_2 = 6; | |
d7c0a89a | 12228 | uint32_t metric; |
d62a17ae | 12229 | struct bgp_redist *red; |
d7c0a89a | 12230 | unsigned short instance; |
d62a17ae | 12231 | int protocol; |
e923dd62 | 12232 | bool changed; |
1de27621 DA |
12233 | struct route_map *route_map = |
12234 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12235 | |
12236 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12237 | protocol = ZEBRA_ROUTE_OSPF; | |
12238 | else | |
12239 | protocol = ZEBRA_ROUTE_TABLE; | |
12240 | ||
12241 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12242 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12243 | ||
12244 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
12245 | changed = |
12246 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12247 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12248 | metric); | |
12249 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 12250 | } |
12251 | ||
12252 | ALIAS_HIDDEN( | |
12253 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
12254 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
12255 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
12256 | "Redistribute information from another routing protocol\n" | |
12257 | "Open Shortest Path First (OSPFv2)\n" | |
12258 | "Non-main Kernel Routing Table\n" | |
12259 | "Instance ID/Table ID\n" | |
12260 | "Route map reference\n" | |
12261 | "Pointer to route-map entries\n" | |
12262 | "Metric for redistributed routes\n" | |
12263 | "Default metric\n") | |
596c17ba | 12264 | |
7c8ff89e DS |
12265 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
12266 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 12267 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
12268 | "Redistribute information from another routing protocol\n" |
12269 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12270 | "Non-main Kernel Routing Table\n" |
12271 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12272 | "Metric for redistributed routes\n" |
12273 | "Default metric\n" | |
12274 | "Route map reference\n" | |
12275 | "Pointer to route-map entries\n") | |
12276 | { | |
d62a17ae | 12277 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12278 | int idx_ospf_table = 1; | |
12279 | int idx_number = 2; | |
12280 | int idx_number_2 = 4; | |
12281 | int idx_word = 6; | |
d7c0a89a | 12282 | uint32_t metric; |
d62a17ae | 12283 | struct bgp_redist *red; |
d7c0a89a | 12284 | unsigned short instance; |
d62a17ae | 12285 | int protocol; |
e923dd62 | 12286 | bool changed; |
1de27621 DA |
12287 | struct route_map *route_map = |
12288 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12289 | |
12290 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12291 | protocol = ZEBRA_ROUTE_OSPF; | |
12292 | else | |
12293 | protocol = ZEBRA_ROUTE_TABLE; | |
12294 | ||
12295 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12296 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12297 | ||
12298 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 12299 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12300 | metric); | |
1de27621 DA |
12301 | changed |= |
12302 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12303 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 12304 | } |
12305 | ||
12306 | ALIAS_HIDDEN( | |
12307 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
12308 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
12309 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
12310 | "Redistribute information from another routing protocol\n" | |
12311 | "Open Shortest Path First (OSPFv2)\n" | |
12312 | "Non-main Kernel Routing Table\n" | |
12313 | "Instance ID/Table ID\n" | |
12314 | "Metric for redistributed routes\n" | |
12315 | "Default metric\n" | |
12316 | "Route map reference\n" | |
12317 | "Pointer to route-map entries\n") | |
596c17ba | 12318 | |
7c8ff89e DS |
12319 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
12320 | no_bgp_redistribute_ipv4_ospf_cmd, | |
e27957c0 | 12321 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
7c8ff89e DS |
12322 | NO_STR |
12323 | "Redistribute information from another routing protocol\n" | |
12324 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 12325 | "Non-main Kernel Routing Table\n" |
31500417 DW |
12326 | "Instance ID/Table ID\n" |
12327 | "Metric for redistributed routes\n" | |
12328 | "Default metric\n" | |
12329 | "Route map reference\n" | |
12330 | "Pointer to route-map entries\n") | |
7c8ff89e | 12331 | { |
d62a17ae | 12332 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12333 | int idx_ospf_table = 2; | |
12334 | int idx_number = 3; | |
d7c0a89a | 12335 | unsigned short instance; |
d62a17ae | 12336 | int protocol; |
12337 | ||
12338 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12339 | protocol = ZEBRA_ROUTE_OSPF; | |
12340 | else | |
12341 | protocol = ZEBRA_ROUTE_TABLE; | |
12342 | ||
12343 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12344 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
12345 | } | |
12346 | ||
12347 | ALIAS_HIDDEN( | |
12348 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
e27957c0 | 12349 | "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 12350 | NO_STR |
12351 | "Redistribute information from another routing protocol\n" | |
12352 | "Open Shortest Path First (OSPFv2)\n" | |
12353 | "Non-main Kernel Routing Table\n" | |
12354 | "Instance ID/Table ID\n" | |
12355 | "Metric for redistributed routes\n" | |
12356 | "Default metric\n" | |
12357 | "Route map reference\n" | |
12358 | "Pointer to route-map entries\n") | |
596c17ba | 12359 | |
718e3744 | 12360 | DEFUN (no_bgp_redistribute_ipv4, |
12361 | no_bgp_redistribute_ipv4_cmd, | |
e27957c0 | 12362 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 12363 | NO_STR |
12364 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12365 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
12366 | "Metric for redistributed routes\n" |
12367 | "Default metric\n" | |
12368 | "Route map reference\n" | |
12369 | "Pointer to route-map entries\n") | |
718e3744 | 12370 | { |
d62a17ae | 12371 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12372 | int idx_protocol = 2; | |
12373 | int type; | |
12374 | ||
12375 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12376 | if (type < 0) { | |
12377 | vty_out(vty, "%% Invalid route type\n"); | |
12378 | return CMD_WARNING_CONFIG_FAILED; | |
12379 | } | |
12380 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
12381 | } | |
12382 | ||
12383 | ALIAS_HIDDEN( | |
12384 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
12385 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
e27957c0 | 12386 | " [{metric (0-4294967295)|route-map WORD}]", |
d62a17ae | 12387 | NO_STR |
12388 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12389 | "Metric for redistributed routes\n" | |
12390 | "Default metric\n" | |
12391 | "Route map reference\n" | |
12392 | "Pointer to route-map entries\n") | |
596c17ba | 12393 | |
718e3744 | 12394 | DEFUN (bgp_redistribute_ipv6, |
12395 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 12396 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 12397 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12398 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 12399 | { |
d62a17ae | 12400 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12401 | int idx_protocol = 1; | |
12402 | int type; | |
718e3744 | 12403 | |
d62a17ae | 12404 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12405 | if (type < 0) { | |
12406 | vty_out(vty, "%% Invalid route type\n"); | |
12407 | return CMD_WARNING_CONFIG_FAILED; | |
12408 | } | |
718e3744 | 12409 | |
d62a17ae | 12410 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12411 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 12412 | } |
12413 | ||
12414 | DEFUN (bgp_redistribute_ipv6_rmap, | |
12415 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 12416 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 12417 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12418 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12419 | "Route map reference\n" |
12420 | "Pointer to route-map entries\n") | |
12421 | { | |
d62a17ae | 12422 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12423 | int idx_protocol = 1; | |
12424 | int idx_word = 3; | |
12425 | int type; | |
12426 | struct bgp_redist *red; | |
e923dd62 | 12427 | bool changed; |
1de27621 DA |
12428 | struct route_map *route_map = |
12429 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 12430 | |
d62a17ae | 12431 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12432 | if (type < 0) { | |
12433 | vty_out(vty, "%% Invalid route type\n"); | |
12434 | return CMD_WARNING_CONFIG_FAILED; | |
12435 | } | |
718e3744 | 12436 | |
d62a17ae | 12437 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
12438 | changed = |
12439 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12440 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 12441 | } |
12442 | ||
12443 | DEFUN (bgp_redistribute_ipv6_metric, | |
12444 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 12445 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 12446 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12447 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12448 | "Metric for redistributed routes\n" |
12449 | "Default metric\n") | |
12450 | { | |
d62a17ae | 12451 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12452 | int idx_protocol = 1; | |
12453 | int idx_number = 3; | |
12454 | int type; | |
d7c0a89a | 12455 | uint32_t metric; |
d62a17ae | 12456 | struct bgp_redist *red; |
e923dd62 | 12457 | bool changed; |
d62a17ae | 12458 | |
12459 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12460 | if (type < 0) { | |
12461 | vty_out(vty, "%% Invalid route type\n"); | |
12462 | return CMD_WARNING_CONFIG_FAILED; | |
12463 | } | |
12464 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12465 | |
d62a17ae | 12466 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12467 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
12468 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12469 | } |
12470 | ||
12471 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
12472 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 12473 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 12474 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12475 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12476 | "Route map reference\n" |
12477 | "Pointer to route-map entries\n" | |
12478 | "Metric for redistributed routes\n" | |
12479 | "Default metric\n") | |
12480 | { | |
d62a17ae | 12481 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12482 | int idx_protocol = 1; | |
12483 | int idx_word = 3; | |
12484 | int idx_number = 5; | |
12485 | int type; | |
d7c0a89a | 12486 | uint32_t metric; |
d62a17ae | 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); | |
d62a17ae | 12491 | |
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 | } | |
12497 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12498 | |
d62a17ae | 12499 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
12500 | changed = |
12501 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12502 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
12503 | metric); | |
12504 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12505 | } |
12506 | ||
12507 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
12508 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 12509 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 12510 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12511 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12512 | "Metric for redistributed routes\n" |
12513 | "Default metric\n" | |
12514 | "Route map reference\n" | |
12515 | "Pointer to route-map entries\n") | |
12516 | { | |
d62a17ae | 12517 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12518 | int idx_protocol = 1; | |
12519 | int idx_number = 3; | |
12520 | int idx_word = 5; | |
12521 | int type; | |
d7c0a89a | 12522 | uint32_t metric; |
d62a17ae | 12523 | struct bgp_redist *red; |
e923dd62 | 12524 | bool changed; |
1de27621 DA |
12525 | struct route_map *route_map = |
12526 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12527 | |
12528 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12529 | if (type < 0) { | |
12530 | vty_out(vty, "%% Invalid route type\n"); | |
12531 | return CMD_WARNING_CONFIG_FAILED; | |
12532 | } | |
12533 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12534 | |
d62a17ae | 12535 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12536 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
12537 | metric); | |
1de27621 DA |
12538 | changed |= |
12539 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12540 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 12541 | } |
12542 | ||
12543 | DEFUN (no_bgp_redistribute_ipv6, | |
12544 | no_bgp_redistribute_ipv6_cmd, | |
e27957c0 | 12545 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [{metric (0-4294967295)|route-map WORD}]", |
718e3744 | 12546 | NO_STR |
12547 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12548 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
12549 | "Metric for redistributed routes\n" |
12550 | "Default metric\n" | |
12551 | "Route map reference\n" | |
12552 | "Pointer to route-map entries\n") | |
718e3744 | 12553 | { |
d62a17ae | 12554 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12555 | int idx_protocol = 2; | |
12556 | int type; | |
718e3744 | 12557 | |
d62a17ae | 12558 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12559 | if (type < 0) { | |
12560 | vty_out(vty, "%% Invalid route type\n"); | |
12561 | return CMD_WARNING_CONFIG_FAILED; | |
12562 | } | |
718e3744 | 12563 | |
d62a17ae | 12564 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
12565 | } | |
12566 | ||
2b791107 | 12567 | void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 12568 | safi_t safi) |
d62a17ae | 12569 | { |
12570 | int i; | |
12571 | ||
12572 | /* Unicast redistribution only. */ | |
12573 | if (safi != SAFI_UNICAST) | |
2b791107 | 12574 | return; |
d62a17ae | 12575 | |
12576 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
12577 | /* Redistribute BGP does not make sense. */ | |
12578 | if (i != ZEBRA_ROUTE_BGP) { | |
12579 | struct list *red_list; | |
12580 | struct listnode *node; | |
12581 | struct bgp_redist *red; | |
12582 | ||
12583 | red_list = bgp->redist[afi][i]; | |
12584 | if (!red_list) | |
12585 | continue; | |
12586 | ||
12587 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 12588 | /* "redistribute" configuration. */ |
12589 | vty_out(vty, " redistribute %s", | |
12590 | zebra_route_string(i)); | |
12591 | if (red->instance) | |
12592 | vty_out(vty, " %d", red->instance); | |
12593 | if (red->redist_metric_flag) | |
12594 | vty_out(vty, " metric %u", | |
12595 | red->redist_metric); | |
12596 | if (red->rmap.name) | |
12597 | vty_out(vty, " route-map %s", | |
12598 | red->rmap.name); | |
12599 | vty_out(vty, "\n"); | |
12600 | } | |
12601 | } | |
12602 | } | |
718e3744 | 12603 | } |
6b0655a2 | 12604 | |
b9c7bc5a PZ |
12605 | /* This is part of the address-family block (unicast only) */ |
12606 | void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, | |
ddb5b488 PZ |
12607 | afi_t afi) |
12608 | { | |
b9c7bc5a | 12609 | int indent = 2; |
ddb5b488 | 12610 | |
8a066a70 PG |
12611 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
12612 | if (listcount(bgp->vpn_policy[afi].import_vrf)) | |
12613 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", | |
12614 | bgp->vpn_policy[afi] | |
bb4f6190 | 12615 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
12616 | else |
12617 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
12618 | bgp->vpn_policy[afi] | |
12619 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
12620 | } | |
12a844a5 DS |
12621 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
12622 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
12623 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
12624 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
12625 | return; | |
12626 | ||
e70e9f8e PZ |
12627 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
12628 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
12629 | ||
12630 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
12631 | ||
12632 | } else { | |
12633 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
12634 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
12635 | bgp->vpn_policy[afi].tovpn_label); | |
12636 | } | |
ddb5b488 PZ |
12637 | } |
12638 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12639 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
12640 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 12641 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
12642 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
12643 | sizeof(buf))); | |
12644 | } | |
12645 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12646 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
12647 | ||
12648 | char buf[PREFIX_STRLEN]; | |
12649 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
12650 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
12651 | sizeof(buf))) { | |
12652 | ||
b9c7bc5a PZ |
12653 | vty_out(vty, "%*snexthop vpn export %s\n", |
12654 | indent, "", buf); | |
ddb5b488 PZ |
12655 | } |
12656 | } | |
12657 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
12658 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
12659 | && ecommunity_cmp( | |
12660 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12661 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
12662 | ||
12663 | char *b = ecommunity_ecom2str( | |
12664 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12665 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12666 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
12667 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12668 | } else { | |
12669 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
12670 | char *b = ecommunity_ecom2str( | |
12671 | bgp->vpn_policy[afi] | |
12672 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12673 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12674 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12675 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
12676 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12677 | } | |
12678 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
12679 | char *b = ecommunity_ecom2str( | |
12680 | bgp->vpn_policy[afi] | |
12681 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12682 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12683 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12684 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
12685 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12686 | } | |
12687 | } | |
bb4f6190 DS |
12688 | |
12689 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 12690 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
12691 | bgp->vpn_policy[afi] |
12692 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 12693 | |
301ad80a PG |
12694 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
12695 | char *b = ecommunity_ecom2str( | |
12696 | bgp->vpn_policy[afi] | |
12697 | .import_redirect_rtlist, | |
12698 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12699 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 12700 | |
301ad80a PG |
12701 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
12702 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
12703 | } | |
ddb5b488 PZ |
12704 | } |
12705 | ||
12706 | ||
718e3744 | 12707 | /* BGP node structure. */ |
d62a17ae | 12708 | static struct cmd_node bgp_node = { |
9d303b37 | 12709 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 12710 | }; |
12711 | ||
d62a17ae | 12712 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 12713 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12714 | }; |
12715 | ||
d62a17ae | 12716 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 12717 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12718 | }; |
12719 | ||
d62a17ae | 12720 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 12721 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12722 | }; |
12723 | ||
d62a17ae | 12724 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 12725 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12726 | }; |
12727 | ||
d62a17ae | 12728 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 12729 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 12730 | }; |
12731 | ||
d62a17ae | 12732 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 12733 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12734 | }; |
12735 | ||
d62a17ae | 12736 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
12737 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 12738 | |
d62a17ae | 12739 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
12740 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 12741 | |
d62a17ae | 12742 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
12743 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 12744 | |
d62a17ae | 12745 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
12746 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 12747 | |
7c40bf39 | 12748 | static struct cmd_node bgp_flowspecv4_node = {BGP_FLOWSPECV4_NODE, |
12749 | "%s(config-router-af)# ", 1}; | |
12750 | ||
12751 | static struct cmd_node bgp_flowspecv6_node = {BGP_FLOWSPECV6_NODE, | |
12752 | "%s(config-router-af-vpnv6)# ", 1}; | |
12753 | ||
d62a17ae | 12754 | static void community_list_vty(void); |
1f8ae70b | 12755 | |
d62a17ae | 12756 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 12757 | { |
d62a17ae | 12758 | struct bgp *bgp; |
12759 | struct peer *peer; | |
d62a17ae | 12760 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 12761 | |
d62a17ae | 12762 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
12763 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
12764 | /* only provide suggestions on the appropriate input | |
12765 | * token type, | |
12766 | * they'll otherwise show up multiple times */ | |
12767 | enum cmd_token_type match_type; | |
12768 | char *name = peer->host; | |
d48ed3e0 | 12769 | |
d62a17ae | 12770 | if (peer->conf_if) { |
12771 | match_type = VARIABLE_TKN; | |
12772 | name = peer->conf_if; | |
12773 | } else if (strchr(peer->host, ':')) | |
12774 | match_type = IPV6_TKN; | |
12775 | else | |
12776 | match_type = IPV4_TKN; | |
d48ed3e0 | 12777 | |
d62a17ae | 12778 | if (token->type != match_type) |
12779 | continue; | |
d48ed3e0 | 12780 | |
d62a17ae | 12781 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
12782 | } | |
d62a17ae | 12783 | } |
b8a815e5 DL |
12784 | } |
12785 | ||
12786 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 12787 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
12788 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 12789 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 12790 | {.completions = NULL}}; |
12791 | ||
47a306a0 DS |
12792 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
12793 | { | |
12794 | struct bgp *bgp; | |
12795 | struct peer_group *group; | |
12796 | struct listnode *lnbgp, *lnpeer; | |
12797 | ||
12798 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
12799 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
12800 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
12801 | group->name)); | |
12802 | } | |
12803 | } | |
12804 | ||
12805 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
12806 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
12807 | {.completions = NULL} }; | |
12808 | ||
d62a17ae | 12809 | void bgp_vty_init(void) |
12810 | { | |
12811 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 12812 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 12813 | |
12814 | /* Install bgp top node. */ | |
12815 | install_node(&bgp_node, bgp_config_write); | |
12816 | install_node(&bgp_ipv4_unicast_node, NULL); | |
12817 | install_node(&bgp_ipv4_multicast_node, NULL); | |
12818 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
12819 | install_node(&bgp_ipv6_unicast_node, NULL); | |
12820 | install_node(&bgp_ipv6_multicast_node, NULL); | |
12821 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
12822 | install_node(&bgp_vpnv4_node, NULL); | |
12823 | install_node(&bgp_vpnv6_node, NULL); | |
12824 | install_node(&bgp_evpn_node, NULL); | |
12825 | install_node(&bgp_evpn_vni_node, NULL); | |
7c40bf39 | 12826 | install_node(&bgp_flowspecv4_node, NULL); |
12827 | install_node(&bgp_flowspecv6_node, NULL); | |
d62a17ae | 12828 | |
12829 | /* Install default VTY commands to new nodes. */ | |
12830 | install_default(BGP_NODE); | |
12831 | install_default(BGP_IPV4_NODE); | |
12832 | install_default(BGP_IPV4M_NODE); | |
12833 | install_default(BGP_IPV4L_NODE); | |
12834 | install_default(BGP_IPV6_NODE); | |
12835 | install_default(BGP_IPV6M_NODE); | |
12836 | install_default(BGP_IPV6L_NODE); | |
12837 | install_default(BGP_VPNV4_NODE); | |
12838 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 12839 | install_default(BGP_FLOWSPECV4_NODE); |
12840 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 12841 | install_default(BGP_EVPN_NODE); |
12842 | install_default(BGP_EVPN_VNI_NODE); | |
12843 | ||
8029b216 AK |
12844 | /* "bgp local-mac" hidden commands. */ |
12845 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
12846 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
12847 | ||
d62a17ae | 12848 | /* bgp route-map delay-timer commands. */ |
12849 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
12850 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
12851 | ||
12852 | /* Dummy commands (Currently not supported) */ | |
12853 | install_element(BGP_NODE, &no_synchronization_cmd); | |
12854 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
12855 | ||
12856 | /* "router bgp" commands. */ | |
12857 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
12858 | ||
12859 | /* "no router bgp" commands. */ | |
12860 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
12861 | ||
12862 | /* "bgp router-id" commands. */ | |
12863 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
12864 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
12865 | ||
12866 | /* "bgp cluster-id" commands. */ | |
12867 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
12868 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
12869 | ||
12870 | /* "bgp confederation" commands. */ | |
12871 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
12872 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
12873 | ||
12874 | /* "bgp confederation peers" commands. */ | |
12875 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
12876 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
12877 | ||
12878 | /* bgp max-med command */ | |
12879 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
12880 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
12881 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
12882 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
12883 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
12884 | ||
12885 | /* bgp disable-ebgp-connected-nh-check */ | |
12886 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
12887 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
12888 | ||
12889 | /* bgp update-delay command */ | |
12890 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
12891 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
12892 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
12893 | ||
12894 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
12895 | install_element(BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
555e09d4 QY |
12896 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
12897 | install_element(BGP_NODE, &no_bgp_rpkt_quanta_cmd); | |
d62a17ae | 12898 | |
12899 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
12900 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
12901 | ||
12902 | /* "maximum-paths" commands. */ | |
12903 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
12904 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
12905 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
12906 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
12907 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
12908 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
12909 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
12910 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
12911 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
12912 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
12913 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12914 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12915 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
12916 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12917 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12918 | ||
12919 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
12920 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
12921 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
12922 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12923 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12924 | ||
12925 | /* "timers bgp" commands. */ | |
12926 | install_element(BGP_NODE, &bgp_timers_cmd); | |
12927 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
12928 | ||
12929 | /* route-map delay-timer commands - per instance for backwards compat. | |
12930 | */ | |
12931 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
12932 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
12933 | ||
12934 | /* "bgp client-to-client reflection" commands */ | |
12935 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
12936 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
12937 | ||
12938 | /* "bgp always-compare-med" commands */ | |
12939 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
12940 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
12941 | ||
9dac9fc8 DA |
12942 | /* bgp ebgp-requires-policy */ |
12943 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
12944 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
12945 | ||
d62a17ae | 12946 | /* "bgp deterministic-med" commands */ |
12947 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
12948 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
12949 | ||
12950 | /* "bgp graceful-restart" commands */ | |
12951 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); | |
12952 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
12953 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); | |
12954 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
12955 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
12956 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
12957 | ||
12958 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); | |
12959 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
12960 | ||
7f323236 DW |
12961 | /* "bgp graceful-shutdown" commands */ |
12962 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
12963 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
12964 | ||
d62a17ae | 12965 | /* "bgp fast-external-failover" commands */ |
12966 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
12967 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
12968 | ||
d62a17ae | 12969 | /* "bgp bestpath compare-routerid" commands */ |
12970 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
12971 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
12972 | ||
12973 | /* "bgp bestpath as-path ignore" commands */ | |
12974 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
12975 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
12976 | ||
12977 | /* "bgp bestpath as-path confed" commands */ | |
12978 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
12979 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
12980 | ||
12981 | /* "bgp bestpath as-path multipath-relax" commands */ | |
12982 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
12983 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
12984 | ||
12985 | /* "bgp log-neighbor-changes" commands */ | |
12986 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
12987 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
12988 | ||
12989 | /* "bgp bestpath med" commands */ | |
12990 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
12991 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
12992 | ||
12993 | /* "no bgp default ipv4-unicast" commands. */ | |
12994 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
12995 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
12996 | ||
12997 | /* "bgp network import-check" commands. */ | |
12998 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
12999 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
13000 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
13001 | ||
13002 | /* "bgp default local-preference" commands. */ | |
13003 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
13004 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
13005 | ||
13006 | /* bgp default show-hostname */ | |
13007 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
13008 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
13009 | ||
13010 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
13011 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
13012 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
13013 | ||
13014 | /* bgp ibgp-allow-policy-mods command */ | |
13015 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
13016 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
13017 | ||
13018 | /* "bgp listen limit" commands. */ | |
13019 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
13020 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
13021 | ||
13022 | /* "bgp listen range" commands. */ | |
13023 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
13024 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
13025 | ||
8175f54a | 13026 | /* "bgp default shutdown" command */ |
f26845f9 QY |
13027 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
13028 | ||
d62a17ae | 13029 | /* "neighbor remote-as" commands. */ |
13030 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
13031 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
13032 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
13033 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
13034 | install_element(BGP_NODE, | |
13035 | &neighbor_interface_v6only_config_remote_as_cmd); | |
13036 | install_element(BGP_NODE, &no_neighbor_cmd); | |
13037 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
13038 | ||
13039 | /* "neighbor peer-group" commands. */ | |
13040 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
13041 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
13042 | install_element(BGP_NODE, | |
13043 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
13044 | ||
13045 | /* "neighbor local-as" commands. */ | |
13046 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
13047 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
13048 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
13049 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
13050 | ||
13051 | /* "neighbor solo" commands. */ | |
13052 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
13053 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
13054 | ||
13055 | /* "neighbor password" commands. */ | |
13056 | install_element(BGP_NODE, &neighbor_password_cmd); | |
13057 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
13058 | ||
13059 | /* "neighbor activate" commands. */ | |
13060 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
13061 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
13062 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
13063 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
13064 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
13065 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
13066 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
13067 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
13068 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 13069 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
13070 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 13071 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
13072 | ||
13073 | /* "no neighbor activate" commands. */ | |
13074 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
13075 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
13076 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
13077 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
13078 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
13079 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
13080 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
13081 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
13082 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 13083 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
13084 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 13085 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
13086 | ||
13087 | /* "neighbor peer-group" set commands. */ | |
13088 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
13089 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13090 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13091 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13092 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13093 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13094 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13095 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 13096 | install_element(BGP_FLOWSPECV4_NODE, |
13097 | &neighbor_set_peer_group_hidden_cmd); | |
13098 | install_element(BGP_FLOWSPECV6_NODE, | |
13099 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 13100 | |
13101 | /* "no neighbor peer-group unset" commands. */ | |
13102 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
13103 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13104 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13105 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13106 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13107 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13108 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13109 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 13110 | install_element(BGP_FLOWSPECV4_NODE, |
13111 | &no_neighbor_set_peer_group_hidden_cmd); | |
13112 | install_element(BGP_FLOWSPECV6_NODE, | |
13113 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 13114 | |
13115 | /* "neighbor softreconfiguration inbound" commands.*/ | |
13116 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
13117 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
13118 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
13119 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13120 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
13121 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13122 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
13123 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13124 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
13125 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13126 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
13127 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13128 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
13129 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13130 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
13131 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13132 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
13133 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 13134 | install_element(BGP_FLOWSPECV4_NODE, |
13135 | &neighbor_soft_reconfiguration_cmd); | |
13136 | install_element(BGP_FLOWSPECV4_NODE, | |
13137 | &no_neighbor_soft_reconfiguration_cmd); | |
13138 | install_element(BGP_FLOWSPECV6_NODE, | |
13139 | &neighbor_soft_reconfiguration_cmd); | |
13140 | install_element(BGP_FLOWSPECV6_NODE, | |
13141 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
13142 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
13143 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 13144 | |
13145 | /* "neighbor attribute-unchanged" commands. */ | |
13146 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
13147 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
13148 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
13149 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
13150 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
13151 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
13152 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
13153 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
13154 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
13155 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
13156 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
13157 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
13158 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
13159 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
13160 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
13161 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
13162 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
13163 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
13164 | ||
13165 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
13166 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
13167 | ||
13168 | /* "nexthop-local unchanged" commands */ | |
13169 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
13170 | install_element(BGP_IPV6_NODE, | |
13171 | &no_neighbor_nexthop_local_unchanged_cmd); | |
13172 | ||
13173 | /* "neighbor next-hop-self" commands. */ | |
13174 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
13175 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
13176 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
13177 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
13178 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
13179 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
13180 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
13181 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
13182 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
13183 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
13184 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
13185 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
13186 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
13187 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
13188 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
13189 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
13190 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
13191 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
13192 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
13193 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 13194 | |
13195 | /* "neighbor next-hop-self force" commands. */ | |
13196 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
13197 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
13198 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13199 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13200 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
13201 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13202 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
13203 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13204 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); | |
13205 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13206 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
13207 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13208 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
13209 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13210 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); | |
13211 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13212 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
13213 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13214 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); | |
13215 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13216 | ||
13217 | /* "neighbor as-override" commands. */ | |
13218 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
13219 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
13220 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
13221 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
13222 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
13223 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
13224 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
13225 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
13226 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
13227 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
13228 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
13229 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
13230 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
13231 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
13232 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
13233 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
13234 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
13235 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
13236 | ||
13237 | /* "neighbor remove-private-AS" commands. */ | |
13238 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
13239 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
13240 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
13241 | install_element(BGP_NODE, | |
13242 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
13243 | install_element(BGP_NODE, | |
13244 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
13245 | install_element(BGP_NODE, | |
13246 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
13247 | install_element(BGP_NODE, | |
13248 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
13249 | install_element( | |
13250 | BGP_NODE, | |
13251 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
13252 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
13253 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
13254 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
13255 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13256 | install_element(BGP_IPV4_NODE, | |
13257 | &neighbor_remove_private_as_replace_as_cmd); | |
13258 | install_element(BGP_IPV4_NODE, | |
13259 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13260 | install_element(BGP_IPV4_NODE, | |
13261 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13262 | install_element(BGP_IPV4_NODE, | |
13263 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13264 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
13265 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
13266 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
13267 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13268 | install_element(BGP_IPV4M_NODE, | |
13269 | &neighbor_remove_private_as_replace_as_cmd); | |
13270 | install_element(BGP_IPV4M_NODE, | |
13271 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13272 | install_element(BGP_IPV4M_NODE, | |
13273 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13274 | install_element(BGP_IPV4M_NODE, | |
13275 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13276 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
13277 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
13278 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
13279 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13280 | install_element(BGP_IPV4L_NODE, | |
13281 | &neighbor_remove_private_as_replace_as_cmd); | |
13282 | install_element(BGP_IPV4L_NODE, | |
13283 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13284 | install_element(BGP_IPV4L_NODE, | |
13285 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13286 | install_element(BGP_IPV4L_NODE, | |
13287 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13288 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
13289 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
13290 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
13291 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13292 | install_element(BGP_IPV6_NODE, | |
13293 | &neighbor_remove_private_as_replace_as_cmd); | |
13294 | install_element(BGP_IPV6_NODE, | |
13295 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13296 | install_element(BGP_IPV6_NODE, | |
13297 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13298 | install_element(BGP_IPV6_NODE, | |
13299 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13300 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
13301 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
13302 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
13303 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13304 | install_element(BGP_IPV6M_NODE, | |
13305 | &neighbor_remove_private_as_replace_as_cmd); | |
13306 | install_element(BGP_IPV6M_NODE, | |
13307 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13308 | install_element(BGP_IPV6M_NODE, | |
13309 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13310 | install_element(BGP_IPV6M_NODE, | |
13311 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13312 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
13313 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
13314 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
13315 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13316 | install_element(BGP_IPV6L_NODE, | |
13317 | &neighbor_remove_private_as_replace_as_cmd); | |
13318 | install_element(BGP_IPV6L_NODE, | |
13319 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13320 | install_element(BGP_IPV6L_NODE, | |
13321 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13322 | install_element(BGP_IPV6L_NODE, | |
13323 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13324 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
13325 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
13326 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
13327 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13328 | install_element(BGP_VPNV4_NODE, | |
13329 | &neighbor_remove_private_as_replace_as_cmd); | |
13330 | install_element(BGP_VPNV4_NODE, | |
13331 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13332 | install_element(BGP_VPNV4_NODE, | |
13333 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13334 | install_element(BGP_VPNV4_NODE, | |
13335 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13336 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
13337 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
13338 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
13339 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13340 | install_element(BGP_VPNV6_NODE, | |
13341 | &neighbor_remove_private_as_replace_as_cmd); | |
13342 | install_element(BGP_VPNV6_NODE, | |
13343 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13344 | install_element(BGP_VPNV6_NODE, | |
13345 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13346 | install_element(BGP_VPNV6_NODE, | |
13347 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13348 | ||
13349 | /* "neighbor send-community" commands.*/ | |
13350 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
13351 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
13352 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
13353 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
13354 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
13355 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
13356 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
13357 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
13358 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
13359 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
13360 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
13361 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
13362 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
13363 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
13364 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
13365 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
13366 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
13367 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
13368 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
13369 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
13370 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
13371 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
13372 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
13373 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
13374 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
13375 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
13376 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
13377 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
13378 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
13379 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
13380 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
13381 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
13382 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
13383 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
13384 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
13385 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
13386 | ||
13387 | /* "neighbor route-reflector" commands.*/ | |
13388 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
13389 | install_element(BGP_NODE, | |
13390 | &no_neighbor_route_reflector_client_hidden_cmd); | |
13391 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
13392 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
13393 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
13394 | install_element(BGP_IPV4M_NODE, | |
13395 | &no_neighbor_route_reflector_client_cmd); | |
13396 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
13397 | install_element(BGP_IPV4L_NODE, | |
13398 | &no_neighbor_route_reflector_client_cmd); | |
13399 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
13400 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
13401 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
13402 | install_element(BGP_IPV6M_NODE, | |
13403 | &no_neighbor_route_reflector_client_cmd); | |
13404 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
13405 | install_element(BGP_IPV6L_NODE, | |
13406 | &no_neighbor_route_reflector_client_cmd); | |
13407 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
13408 | install_element(BGP_VPNV4_NODE, | |
13409 | &no_neighbor_route_reflector_client_cmd); | |
13410 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
13411 | install_element(BGP_VPNV6_NODE, | |
13412 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 13413 | install_element(BGP_FLOWSPECV4_NODE, |
13414 | &neighbor_route_reflector_client_cmd); | |
13415 | install_element(BGP_FLOWSPECV4_NODE, | |
13416 | &no_neighbor_route_reflector_client_cmd); | |
13417 | install_element(BGP_FLOWSPECV6_NODE, | |
13418 | &neighbor_route_reflector_client_cmd); | |
13419 | install_element(BGP_FLOWSPECV6_NODE, | |
13420 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 13421 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
13422 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
13423 | ||
13424 | /* "neighbor route-server" commands.*/ | |
13425 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
13426 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
13427 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
13428 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
13429 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
13430 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
13431 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
13432 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
13433 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
13434 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
13435 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
13436 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
13437 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
13438 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
13439 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
13440 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
13441 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
13442 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
13443 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
13444 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 13445 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
13446 | install_element(BGP_FLOWSPECV4_NODE, | |
13447 | &no_neighbor_route_server_client_cmd); | |
13448 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
13449 | install_element(BGP_FLOWSPECV6_NODE, | |
13450 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 13451 | |
13452 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
13453 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
13454 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
13455 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13456 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13457 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13458 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13459 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13460 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13461 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13462 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13463 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13464 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13465 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13466 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13467 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13468 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13469 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13470 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13471 | ||
13472 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
13473 | install_element(BGP_NODE, | |
13474 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
13475 | install_element(BGP_NODE, | |
13476 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
13477 | install_element(BGP_IPV4_NODE, | |
13478 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13479 | install_element(BGP_IPV4_NODE, | |
13480 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13481 | install_element(BGP_IPV4M_NODE, | |
13482 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13483 | install_element(BGP_IPV4M_NODE, | |
13484 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13485 | install_element(BGP_IPV4L_NODE, | |
13486 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13487 | install_element(BGP_IPV4L_NODE, | |
13488 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13489 | install_element(BGP_IPV6_NODE, | |
13490 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13491 | install_element(BGP_IPV6_NODE, | |
13492 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13493 | install_element(BGP_IPV6M_NODE, | |
13494 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13495 | install_element(BGP_IPV6M_NODE, | |
13496 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13497 | install_element(BGP_IPV6L_NODE, | |
13498 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13499 | install_element(BGP_IPV6L_NODE, | |
13500 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13501 | install_element(BGP_VPNV4_NODE, | |
13502 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13503 | install_element(BGP_VPNV4_NODE, | |
13504 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13505 | install_element(BGP_VPNV6_NODE, | |
13506 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13507 | install_element(BGP_VPNV6_NODE, | |
13508 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13509 | ||
13510 | /* "neighbor passive" commands. */ | |
13511 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
13512 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
13513 | ||
13514 | ||
13515 | /* "neighbor shutdown" commands. */ | |
13516 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
13517 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
13518 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
13519 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
13520 | ||
13521 | /* "neighbor capability extended-nexthop" commands.*/ | |
13522 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
13523 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
13524 | ||
13525 | /* "neighbor capability orf prefix-list" commands.*/ | |
13526 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
13527 | install_element(BGP_NODE, | |
13528 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
13529 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
13530 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13531 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13532 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13533 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13534 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13535 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
13536 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13537 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13538 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13539 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13540 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13541 | ||
13542 | /* "neighbor capability dynamic" commands.*/ | |
13543 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
13544 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
13545 | ||
13546 | /* "neighbor dont-capability-negotiate" commands. */ | |
13547 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
13548 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
13549 | ||
13550 | /* "neighbor ebgp-multihop" commands. */ | |
13551 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
13552 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
13553 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
13554 | ||
13555 | /* "neighbor disable-connected-check" commands. */ | |
13556 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
13557 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
13558 | ||
47cbc09b PM |
13559 | /* "neighbor enforce-first-as" commands. */ |
13560 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
13561 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
13562 | ||
d62a17ae | 13563 | /* "neighbor description" commands. */ |
13564 | install_element(BGP_NODE, &neighbor_description_cmd); | |
13565 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 13566 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 13567 | |
13568 | /* "neighbor update-source" commands. "*/ | |
13569 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
13570 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
13571 | ||
13572 | /* "neighbor default-originate" commands. */ | |
13573 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
13574 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
13575 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
13576 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
13577 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
13578 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
13579 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
13580 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
13581 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
13582 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
13583 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
13584 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
13585 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
13586 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
13587 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
13588 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
13589 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
13590 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
13591 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
13592 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
13593 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
13594 | ||
13595 | /* "neighbor port" commands. */ | |
13596 | install_element(BGP_NODE, &neighbor_port_cmd); | |
13597 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
13598 | ||
13599 | /* "neighbor weight" commands. */ | |
13600 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
13601 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
13602 | ||
13603 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
13604 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
13605 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
13606 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
13607 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
13608 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
13609 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
13610 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
13611 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
13612 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
13613 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
13614 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
13615 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
13616 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
13617 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
13618 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
13619 | ||
13620 | /* "neighbor override-capability" commands. */ | |
13621 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
13622 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
13623 | ||
13624 | /* "neighbor strict-capability-match" commands. */ | |
13625 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
13626 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
13627 | ||
13628 | /* "neighbor timers" commands. */ | |
13629 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
13630 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
13631 | ||
13632 | /* "neighbor timers connect" commands. */ | |
13633 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
13634 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
13635 | ||
13636 | /* "neighbor advertisement-interval" commands. */ | |
13637 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
13638 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
13639 | ||
13640 | /* "neighbor interface" commands. */ | |
13641 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
13642 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
13643 | ||
13644 | /* "neighbor distribute" commands. */ | |
13645 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
13646 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
13647 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
13648 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
13649 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
13650 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
13651 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
13652 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
13653 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
13654 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
13655 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
13656 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
13657 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
13658 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
13659 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
13660 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
13661 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
13662 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
13663 | ||
13664 | /* "neighbor prefix-list" commands. */ | |
13665 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
13666 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
13667 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
13668 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
13669 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
13670 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
13671 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
13672 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
13673 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
13674 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
13675 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
13676 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
13677 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
13678 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
13679 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
13680 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
13681 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
13682 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 13683 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
13684 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
13685 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
13686 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 13687 | |
13688 | /* "neighbor filter-list" commands. */ | |
13689 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
13690 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
13691 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
13692 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
13693 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
13694 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
13695 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
13696 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
13697 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
13698 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
13699 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
13700 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
13701 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
13702 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
13703 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
13704 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
13705 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
13706 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 13707 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
13708 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
13709 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
13710 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 13711 | |
13712 | /* "neighbor route-map" commands. */ | |
13713 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
13714 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
13715 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
13716 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
13717 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
13718 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
13719 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
13720 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
13721 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
13722 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
13723 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
13724 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
13725 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
13726 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
13727 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
13728 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
13729 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
13730 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 13731 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
13732 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
13733 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
13734 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
13735 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
13736 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 13737 | |
13738 | /* "neighbor unsuppress-map" commands. */ | |
13739 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
13740 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
13741 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
13742 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13743 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
13744 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13745 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
13746 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13747 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
13748 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13749 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
13750 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13751 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
13752 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13753 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
13754 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13755 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
13756 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13757 | ||
13758 | /* "neighbor maximum-prefix" commands. */ | |
13759 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
13760 | install_element(BGP_NODE, | |
13761 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
13762 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
13763 | install_element(BGP_NODE, | |
13764 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
13765 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
13766 | install_element(BGP_NODE, | |
13767 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
13768 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
13769 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
13770 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13771 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13772 | install_element(BGP_IPV4_NODE, | |
13773 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13774 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13775 | install_element(BGP_IPV4_NODE, | |
13776 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13777 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13778 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
13779 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13780 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13781 | install_element(BGP_IPV4M_NODE, | |
13782 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13783 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13784 | install_element(BGP_IPV4M_NODE, | |
13785 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13786 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13787 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
13788 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13789 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13790 | install_element(BGP_IPV4L_NODE, | |
13791 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13792 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13793 | install_element(BGP_IPV4L_NODE, | |
13794 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13795 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13796 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
13797 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13798 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13799 | install_element(BGP_IPV6_NODE, | |
13800 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13801 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13802 | install_element(BGP_IPV6_NODE, | |
13803 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13804 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13805 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
13806 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13807 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13808 | install_element(BGP_IPV6M_NODE, | |
13809 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13810 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13811 | install_element(BGP_IPV6M_NODE, | |
13812 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13813 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13814 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
13815 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13816 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13817 | install_element(BGP_IPV6L_NODE, | |
13818 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13819 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13820 | install_element(BGP_IPV6L_NODE, | |
13821 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13822 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13823 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
13824 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13825 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13826 | install_element(BGP_VPNV4_NODE, | |
13827 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13828 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13829 | install_element(BGP_VPNV4_NODE, | |
13830 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13831 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13832 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
13833 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13834 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13835 | install_element(BGP_VPNV6_NODE, | |
13836 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13837 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13838 | install_element(BGP_VPNV6_NODE, | |
13839 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13840 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13841 | ||
13842 | /* "neighbor allowas-in" */ | |
13843 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
13844 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
13845 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
13846 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
13847 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
13848 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
13849 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
13850 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
13851 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
13852 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
13853 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
13854 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
13855 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
13856 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
13857 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
13858 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
13859 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
13860 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
13861 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
13862 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
13863 | ||
13864 | /* address-family commands. */ | |
13865 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
13866 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 13867 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 13868 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
13869 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 13870 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 13871 | |
d62a17ae | 13872 | install_element(BGP_NODE, &address_family_evpn_cmd); |
13873 | ||
13874 | /* "exit-address-family" command. */ | |
13875 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
13876 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
13877 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
13878 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
13879 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
13880 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
13881 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
13882 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 13883 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
13884 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 13885 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
13886 | ||
13887 | /* "clear ip bgp commands" */ | |
13888 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
13889 | ||
13890 | /* clear ip bgp prefix */ | |
13891 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
13892 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
13893 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
13894 | ||
13895 | /* "show [ip] bgp summary" commands. */ | |
13896 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 13897 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 13898 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 13899 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 13900 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
13901 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 13902 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
13903 | ||
13904 | /* "show [ip] bgp neighbors" commands. */ | |
13905 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
13906 | ||
13907 | /* "show [ip] bgp peer-group" commands. */ | |
13908 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
13909 | ||
13910 | /* "show [ip] bgp paths" commands. */ | |
13911 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
13912 | ||
13913 | /* "show [ip] bgp community" commands. */ | |
13914 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
13915 | ||
13916 | /* "show ip bgp large-community" commands. */ | |
13917 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
13918 | /* "show [ip] bgp attribute-info" commands. */ | |
13919 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 13920 | /* "show [ip] bgp route-leak" command */ |
13921 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 13922 | |
13923 | /* "redistribute" commands. */ | |
13924 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
13925 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
13926 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
13927 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
13928 | install_element(BGP_NODE, | |
13929 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
13930 | install_element(BGP_NODE, | |
13931 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
13932 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
13933 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
13934 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
13935 | install_element(BGP_NODE, | |
13936 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
13937 | install_element(BGP_NODE, | |
13938 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
13939 | install_element(BGP_NODE, | |
13940 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
13941 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
13942 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
13943 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
13944 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
13945 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
13946 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
13947 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
13948 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
13949 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
13950 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
13951 | install_element(BGP_IPV4_NODE, | |
13952 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
13953 | install_element(BGP_IPV4_NODE, | |
13954 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
13955 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
13956 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
13957 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
13958 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
13959 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
13960 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
13961 | ||
b9c7bc5a PZ |
13962 | /* import|export vpn [route-map WORD] */ |
13963 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
13964 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 13965 | |
12a844a5 DS |
13966 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
13967 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
13968 | ||
d62a17ae | 13969 | /* ttl_security commands */ |
13970 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
13971 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
13972 | ||
13973 | /* "show [ip] bgp memory" commands. */ | |
13974 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
13975 | ||
acf71666 MK |
13976 | /* "show bgp martian next-hop" */ |
13977 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
13978 | ||
48ecf8f5 DS |
13979 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
13980 | ||
d62a17ae | 13981 | /* "show [ip] bgp views" commands. */ |
13982 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
13983 | ||
13984 | /* "show [ip] bgp vrfs" commands. */ | |
13985 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
13986 | ||
13987 | /* Community-list. */ | |
13988 | community_list_vty(); | |
ddb5b488 PZ |
13989 | |
13990 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
13991 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
13992 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
13993 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
13994 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
13995 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
13996 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
13997 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
13998 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
13999 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
14000 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
14001 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
14002 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 14003 | |
301ad80a PG |
14004 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
14005 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
14006 | ||
b9c7bc5a PZ |
14007 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
14008 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
14009 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
14010 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
14011 | install_element(BGP_IPV4_NODE, &af_no_nexthop_vpn_export_cmd); | |
14012 | install_element(BGP_IPV6_NODE, &af_no_nexthop_vpn_export_cmd); | |
14013 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); | |
14014 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
14015 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
14016 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
14017 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
14018 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 14019 | } |
6b0655a2 | 14020 | |
718e3744 | 14021 | #include "memory.h" |
14022 | #include "bgp_regex.h" | |
14023 | #include "bgp_clist.h" | |
14024 | #include "bgp_ecommunity.h" | |
14025 | ||
14026 | /* VTY functions. */ | |
14027 | ||
14028 | /* Direction value to string conversion. */ | |
d62a17ae | 14029 | static const char *community_direct_str(int direct) |
14030 | { | |
14031 | switch (direct) { | |
14032 | case COMMUNITY_DENY: | |
14033 | return "deny"; | |
14034 | case COMMUNITY_PERMIT: | |
14035 | return "permit"; | |
14036 | default: | |
14037 | return "unknown"; | |
14038 | } | |
718e3744 | 14039 | } |
14040 | ||
14041 | /* Display error string. */ | |
d62a17ae | 14042 | static void community_list_perror(struct vty *vty, int ret) |
14043 | { | |
14044 | switch (ret) { | |
14045 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
14046 | vty_out(vty, "%% Can't find community-list\n"); | |
14047 | break; | |
14048 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
14049 | vty_out(vty, "%% Malformed community-list value\n"); | |
14050 | break; | |
14051 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
14052 | vty_out(vty, | |
14053 | "%% Community name conflict, previously defined as standard community\n"); | |
14054 | break; | |
14055 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
14056 | vty_out(vty, | |
14057 | "%% Community name conflict, previously defined as expanded community\n"); | |
14058 | break; | |
14059 | } | |
718e3744 | 14060 | } |
14061 | ||
5bf15956 DW |
14062 | /* "community-list" keyword help string. */ |
14063 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
14064 | ||
7336e101 SP |
14065 | /*community-list standard */ |
14066 | DEFUN (community_list_standard, | |
14067 | bgp_community_list_standard_cmd, | |
14068 | "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14069 | BGP_STR | |
718e3744 | 14070 | COMMUNITY_LIST_STR |
14071 | "Community list number (standard)\n" | |
5bf15956 | 14072 | "Add an standard community-list entry\n" |
718e3744 | 14073 | "Community list name\n" |
14074 | "Specify community to reject\n" | |
14075 | "Specify community to accept\n" | |
14076 | COMMUNITY_VAL_STR) | |
14077 | { | |
d62a17ae | 14078 | char *cl_name_or_number = NULL; |
14079 | int direct = 0; | |
14080 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 14081 | |
d62a17ae | 14082 | int idx = 0; |
7336e101 SP |
14083 | |
14084 | if (argv_find(argv, argc, "ip", &idx)) { | |
14085 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14086 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14087 | vty_out(vty, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
14088 | zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
14089 | } | |
14090 | ||
d62a17ae | 14091 | argv_find(argv, argc, "(1-99)", &idx); |
14092 | argv_find(argv, argc, "WORD", &idx); | |
14093 | cl_name_or_number = argv[idx]->arg; | |
14094 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14095 | : COMMUNITY_DENY; | |
14096 | argv_find(argv, argc, "AA:NN", &idx); | |
14097 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14098 | |
d62a17ae | 14099 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
14100 | style); | |
42f914d4 | 14101 | |
d62a17ae | 14102 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14103 | |
d62a17ae | 14104 | if (ret < 0) { |
14105 | /* Display error string. */ | |
14106 | community_list_perror(vty, ret); | |
14107 | return CMD_WARNING_CONFIG_FAILED; | |
14108 | } | |
42f914d4 | 14109 | |
d62a17ae | 14110 | return CMD_SUCCESS; |
718e3744 | 14111 | } |
14112 | ||
7336e101 SP |
14113 | #if CONFDATE > 20191005 |
14114 | CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command") | |
14115 | #endif | |
14116 | ALIAS (community_list_standard, | |
14117 | ip_community_list_standard_cmd, | |
14118 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 14119 | IP_STR |
14120 | COMMUNITY_LIST_STR | |
14121 | "Community list number (standard)\n" | |
5bf15956 DW |
14122 | "Add an standard community-list entry\n" |
14123 | "Community list name\n" | |
718e3744 | 14124 | "Specify community to reject\n" |
14125 | "Specify community to accept\n" | |
14126 | COMMUNITY_VAL_STR) | |
7336e101 SP |
14127 | |
14128 | DEFUN (no_community_list_standard_all, | |
14129 | no_bgp_community_list_standard_all_cmd, | |
14130 | "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14131 | NO_STR | |
14132 | BGP_STR | |
14133 | COMMUNITY_LIST_STR | |
14134 | "Community list number (standard)\n" | |
14135 | "Add an standard community-list entry\n" | |
14136 | "Community list name\n" | |
14137 | "Specify community to reject\n" | |
14138 | "Specify community to accept\n" | |
14139 | COMMUNITY_VAL_STR) | |
718e3744 | 14140 | { |
d62a17ae | 14141 | char *cl_name_or_number = NULL; |
174b5cb9 | 14142 | char *str = NULL; |
d62a17ae | 14143 | int direct = 0; |
14144 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 14145 | |
d62a17ae | 14146 | int idx = 0; |
7336e101 SP |
14147 | |
14148 | if (argv_find(argv, argc, "ip", &idx)) { | |
14149 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
14150 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14151 | vty_out(vty, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
14152 | zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used"); | |
14153 | } | |
14154 | ||
174b5cb9 DA |
14155 | argv_find(argv, argc, "permit", &idx); |
14156 | argv_find(argv, argc, "deny", &idx); | |
14157 | ||
14158 | if (idx) { | |
14159 | direct = argv_find(argv, argc, "permit", &idx) | |
14160 | ? COMMUNITY_PERMIT | |
14161 | : COMMUNITY_DENY; | |
14162 | ||
14163 | idx = 0; | |
14164 | argv_find(argv, argc, "AA:NN", &idx); | |
14165 | str = argv_concat(argv, argc, idx); | |
14166 | } | |
14167 | ||
14168 | idx = 0; | |
d62a17ae | 14169 | argv_find(argv, argc, "(1-99)", &idx); |
14170 | argv_find(argv, argc, "WORD", &idx); | |
14171 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 14172 | |
d62a17ae | 14173 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 14174 | direct, style); |
42f914d4 | 14175 | |
d62a17ae | 14176 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 14177 | |
d62a17ae | 14178 | if (ret < 0) { |
14179 | community_list_perror(vty, ret); | |
14180 | return CMD_WARNING_CONFIG_FAILED; | |
14181 | } | |
42f914d4 | 14182 | |
d62a17ae | 14183 | return CMD_SUCCESS; |
718e3744 | 14184 | } |
7336e101 SP |
14185 | ALIAS (no_community_list_standard_all, |
14186 | no_ip_community_list_standard_all_cmd, | |
14187 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14188 | NO_STR | |
718e3744 | 14189 | IP_STR |
14190 | COMMUNITY_LIST_STR | |
7336e101 SP |
14191 | "Community list number (standard)\n" |
14192 | "Add an standard community-list entry\n" | |
14193 | "Community list name\n" | |
14194 | "Specify community to reject\n" | |
14195 | "Specify community to accept\n" | |
14196 | COMMUNITY_VAL_STR) | |
14197 | ||
174b5cb9 DA |
14198 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
14199 | "no bgp community-list <(1-99)|standard WORD>", | |
14200 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
14201 | "Community list number (standard)\n" | |
14202 | "Add an standard community-list entry\n" | |
14203 | "Community list name\n") | |
14204 | ||
14205 | ALIAS(no_community_list_standard_all, no_ip_community_list_standard_all_list_cmd, | |
14206 | "no ip community-list <(1-99)|standard WORD>", | |
14207 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
14208 | "Community list number (standard)\n" | |
14209 | "Add an standard community-list entry\n" | |
14210 | "Community list name\n") | |
14211 | ||
7336e101 SP |
14212 | /*community-list expanded */ |
14213 | DEFUN (community_list_expanded_all, | |
14214 | bgp_community_list_expanded_all_cmd, | |
14215 | "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14216 | BGP_STR | |
14217 | COMMUNITY_LIST_STR | |
718e3744 | 14218 | "Community list number (expanded)\n" |
5bf15956 | 14219 | "Add an expanded community-list entry\n" |
718e3744 | 14220 | "Community list name\n" |
14221 | "Specify community to reject\n" | |
14222 | "Specify community to accept\n" | |
14223 | COMMUNITY_VAL_STR) | |
14224 | { | |
d62a17ae | 14225 | char *cl_name_or_number = NULL; |
14226 | int direct = 0; | |
14227 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 14228 | |
d62a17ae | 14229 | int idx = 0; |
7336e101 SP |
14230 | if (argv_find(argv, argc, "ip", &idx)) { |
14231 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14232 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14233 | vty_out(vty, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
14234 | zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
14235 | } | |
d62a17ae | 14236 | argv_find(argv, argc, "(100-500)", &idx); |
14237 | argv_find(argv, argc, "WORD", &idx); | |
14238 | cl_name_or_number = argv[idx]->arg; | |
14239 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14240 | : COMMUNITY_DENY; | |
14241 | argv_find(argv, argc, "AA:NN", &idx); | |
14242 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14243 | |
d62a17ae | 14244 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
14245 | style); | |
42f914d4 | 14246 | |
d62a17ae | 14247 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14248 | |
d62a17ae | 14249 | if (ret < 0) { |
14250 | /* Display error string. */ | |
14251 | community_list_perror(vty, ret); | |
14252 | return CMD_WARNING_CONFIG_FAILED; | |
14253 | } | |
42f914d4 | 14254 | |
d62a17ae | 14255 | return CMD_SUCCESS; |
718e3744 | 14256 | } |
14257 | ||
7336e101 SP |
14258 | ALIAS (community_list_expanded_all, |
14259 | ip_community_list_expanded_all_cmd, | |
14260 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
718e3744 | 14261 | IP_STR |
14262 | COMMUNITY_LIST_STR | |
5bf15956 DW |
14263 | "Community list number (expanded)\n" |
14264 | "Add an expanded community-list entry\n" | |
718e3744 | 14265 | "Community list name\n" |
14266 | "Specify community to reject\n" | |
14267 | "Specify community to accept\n" | |
5bf15956 | 14268 | COMMUNITY_VAL_STR) |
7336e101 SP |
14269 | |
14270 | DEFUN (no_community_list_expanded_all, | |
14271 | no_bgp_community_list_expanded_all_cmd, | |
14272 | "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14273 | NO_STR | |
14274 | BGP_STR | |
14275 | COMMUNITY_LIST_STR | |
14276 | "Community list number (expanded)\n" | |
14277 | "Add an expanded community-list entry\n" | |
14278 | "Community list name\n" | |
14279 | "Specify community to reject\n" | |
14280 | "Specify community to accept\n" | |
14281 | COMMUNITY_VAL_STR) | |
718e3744 | 14282 | { |
d62a17ae | 14283 | char *cl_name_or_number = NULL; |
174b5cb9 | 14284 | char *str = NULL; |
d62a17ae | 14285 | int direct = 0; |
14286 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 14287 | |
d62a17ae | 14288 | int idx = 0; |
7336e101 SP |
14289 | if (argv_find(argv, argc, "ip", &idx)) { |
14290 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14291 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
174b5cb9 DA |
14292 | vty_out(vty, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); |
14293 | zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
14294 | } | |
14295 | ||
3c4b8fe2 | 14296 | idx = 0; |
174b5cb9 DA |
14297 | argv_find(argv, argc, "permit", &idx); |
14298 | argv_find(argv, argc, "deny", &idx); | |
14299 | ||
14300 | if (idx) { | |
14301 | direct = argv_find(argv, argc, "permit", &idx) | |
14302 | ? COMMUNITY_PERMIT | |
14303 | : COMMUNITY_DENY; | |
14304 | ||
14305 | idx = 0; | |
14306 | argv_find(argv, argc, "AA:NN", &idx); | |
14307 | str = argv_concat(argv, argc, idx); | |
7336e101 | 14308 | } |
174b5cb9 DA |
14309 | |
14310 | idx = 0; | |
d62a17ae | 14311 | argv_find(argv, argc, "(100-500)", &idx); |
14312 | argv_find(argv, argc, "WORD", &idx); | |
14313 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 14314 | |
d62a17ae | 14315 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 14316 | direct, style); |
42f914d4 | 14317 | |
d62a17ae | 14318 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 14319 | |
d62a17ae | 14320 | if (ret < 0) { |
14321 | community_list_perror(vty, ret); | |
14322 | return CMD_WARNING_CONFIG_FAILED; | |
14323 | } | |
42f914d4 | 14324 | |
d62a17ae | 14325 | return CMD_SUCCESS; |
718e3744 | 14326 | } |
14327 | ||
7336e101 SP |
14328 | ALIAS (no_community_list_expanded_all, |
14329 | no_ip_community_list_expanded_all_cmd, | |
14330 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14331 | NO_STR | |
14332 | IP_STR | |
14333 | COMMUNITY_LIST_STR | |
14334 | "Community list number (expanded)\n" | |
14335 | "Add an expanded community-list entry\n" | |
14336 | "Community list name\n" | |
14337 | "Specify community to reject\n" | |
14338 | "Specify community to accept\n" | |
14339 | COMMUNITY_VAL_STR) | |
14340 | ||
174b5cb9 DA |
14341 | ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd, |
14342 | "no bgp community-list <(100-500)|expanded WORD>", | |
14343 | NO_STR IP_STR COMMUNITY_LIST_STR | |
14344 | "Community list number (expanded)\n" | |
14345 | "Add an expanded community-list entry\n" | |
14346 | "Community list name\n") | |
14347 | ||
14348 | ALIAS(no_community_list_expanded_all, no_ip_community_list_expanded_all_list_cmd, | |
14349 | "no ip community-list <(100-500)|expanded WORD>", | |
14350 | NO_STR IP_STR COMMUNITY_LIST_STR | |
14351 | "Community list number (expanded)\n" | |
14352 | "Add an expanded community-list entry\n" | |
14353 | "Community list name\n") | |
14354 | ||
8d9b8ed9 PM |
14355 | /* Return configuration string of community-list entry. */ |
14356 | static const char *community_list_config_str(struct community_entry *entry) | |
14357 | { | |
14358 | const char *str; | |
14359 | ||
14360 | if (entry->any) | |
14361 | str = ""; | |
14362 | else { | |
14363 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
14364 | str = community_str(entry->u.com, false); | |
14365 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
14366 | str = lcommunity_str(entry->u.lcom, false); | |
14367 | else | |
14368 | str = entry->config; | |
14369 | } | |
14370 | return str; | |
14371 | } | |
14372 | ||
d62a17ae | 14373 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 14374 | { |
d62a17ae | 14375 | struct community_entry *entry; |
718e3744 | 14376 | |
d62a17ae | 14377 | for (entry = list->head; entry; entry = entry->next) { |
14378 | if (entry == list->head) { | |
14379 | if (all_digit(list->name)) | |
14380 | vty_out(vty, "Community %s list %s\n", | |
14381 | entry->style == COMMUNITY_LIST_STANDARD | |
14382 | ? "standard" | |
14383 | : "(expanded) access", | |
14384 | list->name); | |
14385 | else | |
14386 | vty_out(vty, "Named Community %s list %s\n", | |
14387 | entry->style == COMMUNITY_LIST_STANDARD | |
14388 | ? "standard" | |
14389 | : "expanded", | |
14390 | list->name); | |
14391 | } | |
14392 | if (entry->any) | |
14393 | vty_out(vty, " %s\n", | |
14394 | community_direct_str(entry->direct)); | |
14395 | else | |
14396 | vty_out(vty, " %s %s\n", | |
14397 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14398 | community_list_config_str(entry)); |
d62a17ae | 14399 | } |
718e3744 | 14400 | } |
14401 | ||
7336e101 SP |
14402 | DEFUN (show_community_list, |
14403 | show_bgp_community_list_cmd, | |
14404 | "show bgp community-list", | |
718e3744 | 14405 | SHOW_STR |
7336e101 | 14406 | BGP_STR |
718e3744 | 14407 | "List community-list\n") |
14408 | { | |
d62a17ae | 14409 | struct community_list *list; |
14410 | struct community_list_master *cm; | |
718e3744 | 14411 | |
7336e101 SP |
14412 | int idx = 0; |
14413 | if (argv_find(argv, argc, "ip", &idx)) { | |
14414 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14415 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14416 | vty_out(vty, "'show bgp community-list <(1-500)|WORD>'\n"); | |
14417 | zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used"); | |
14418 | } | |
d62a17ae | 14419 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
14420 | if (!cm) | |
14421 | return CMD_SUCCESS; | |
718e3744 | 14422 | |
d62a17ae | 14423 | for (list = cm->num.head; list; list = list->next) |
14424 | community_list_show(vty, list); | |
718e3744 | 14425 | |
d62a17ae | 14426 | for (list = cm->str.head; list; list = list->next) |
14427 | community_list_show(vty, list); | |
718e3744 | 14428 | |
d62a17ae | 14429 | return CMD_SUCCESS; |
718e3744 | 14430 | } |
14431 | ||
7336e101 SP |
14432 | ALIAS (show_community_list, |
14433 | show_ip_community_list_cmd, | |
14434 | "show ip community-list", | |
718e3744 | 14435 | SHOW_STR |
14436 | IP_STR | |
7336e101 SP |
14437 | "List community-list\n") |
14438 | ||
14439 | DEFUN (show_community_list_arg, | |
14440 | show_bgp_community_list_arg_cmd, | |
14441 | "show bgp community-list <(1-500)|WORD>", | |
14442 | SHOW_STR | |
14443 | BGP_STR | |
718e3744 | 14444 | "List community-list\n" |
14445 | "Community-list number\n" | |
14446 | "Community-list name\n") | |
14447 | { | |
d62a17ae | 14448 | int idx_comm_list = 3; |
14449 | struct community_list *list; | |
718e3744 | 14450 | |
7336e101 SP |
14451 | int idx = 0; |
14452 | if (argv_find(argv, argc, "ip", &idx)) { | |
14453 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14454 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14455 | vty_out(vty, "'show bgp community-list <(1-500)|WORD>'\n"); | |
14456 | zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used"); | |
14457 | } | |
e237b0d2 | 14458 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 14459 | COMMUNITY_LIST_MASTER); |
14460 | if (!list) { | |
14461 | vty_out(vty, "%% Can't find community-list\n"); | |
14462 | return CMD_WARNING; | |
14463 | } | |
718e3744 | 14464 | |
d62a17ae | 14465 | community_list_show(vty, list); |
718e3744 | 14466 | |
d62a17ae | 14467 | return CMD_SUCCESS; |
718e3744 | 14468 | } |
6b0655a2 | 14469 | |
7336e101 SP |
14470 | ALIAS (show_community_list_arg, |
14471 | show_ip_community_list_arg_cmd, | |
14472 | "show ip community-list <(1-500)|WORD>", | |
14473 | SHOW_STR | |
14474 | IP_STR | |
14475 | "List community-list\n" | |
14476 | "Community-list number\n" | |
14477 | "Community-list name\n") | |
14478 | ||
57d187bc JS |
14479 | /* |
14480 | * Large Community code. | |
14481 | */ | |
d62a17ae | 14482 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
14483 | struct cmd_token **argv, int style, | |
14484 | int reject_all_digit_name) | |
14485 | { | |
14486 | int ret; | |
14487 | int direct; | |
14488 | char *str; | |
14489 | int idx = 0; | |
14490 | char *cl_name; | |
14491 | ||
7336e101 SP |
14492 | if (argv_find(argv, argc, "ip", &idx)) { |
14493 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14494 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14495 | vty_out(vty, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n"); | |
14496 | zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used"); | |
14497 | } | |
d62a17ae | 14498 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
14499 | : COMMUNITY_DENY; | |
14500 | ||
14501 | /* All digit name check. */ | |
14502 | idx = 0; | |
14503 | argv_find(argv, argc, "WORD", &idx); | |
14504 | argv_find(argv, argc, "(1-99)", &idx); | |
14505 | argv_find(argv, argc, "(100-500)", &idx); | |
14506 | cl_name = argv[idx]->arg; | |
14507 | if (reject_all_digit_name && all_digit(cl_name)) { | |
14508 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
14509 | return CMD_WARNING_CONFIG_FAILED; | |
14510 | } | |
14511 | ||
14512 | idx = 0; | |
14513 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
14514 | argv_find(argv, argc, "LINE", &idx); | |
14515 | /* Concat community string argument. */ | |
14516 | if (idx) | |
14517 | str = argv_concat(argv, argc, idx); | |
14518 | else | |
14519 | str = NULL; | |
14520 | ||
14521 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
14522 | ||
14523 | /* Free temporary community list string allocated by | |
14524 | argv_concat(). */ | |
0a22ddfb | 14525 | XFREE(MTYPE_TMP, str); |
d62a17ae | 14526 | |
14527 | if (ret < 0) { | |
14528 | community_list_perror(vty, ret); | |
14529 | return CMD_WARNING_CONFIG_FAILED; | |
14530 | } | |
14531 | return CMD_SUCCESS; | |
14532 | } | |
14533 | ||
14534 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
14535 | struct cmd_token **argv, int style) | |
14536 | { | |
14537 | int ret; | |
14538 | int direct = 0; | |
14539 | char *str = NULL; | |
14540 | int idx = 0; | |
14541 | ||
7336e101 SP |
14542 | if (argv_find(argv, argc, "ip", &idx)) { |
14543 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14544 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14545 | vty_out(vty, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n"); | |
16941c05 | 14546 | zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used"); |
7336e101 | 14547 | } |
d62a17ae | 14548 | argv_find(argv, argc, "permit", &idx); |
14549 | argv_find(argv, argc, "deny", &idx); | |
14550 | ||
14551 | if (idx) { | |
14552 | /* Check the list direct. */ | |
14553 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
14554 | direct = COMMUNITY_PERMIT; | |
14555 | else | |
14556 | direct = COMMUNITY_DENY; | |
14557 | ||
14558 | idx = 0; | |
14559 | argv_find(argv, argc, "LINE", &idx); | |
14560 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
14561 | /* Concat community string argument. */ | |
14562 | str = argv_concat(argv, argc, idx); | |
14563 | } | |
14564 | ||
14565 | idx = 0; | |
14566 | argv_find(argv, argc, "(1-99)", &idx); | |
14567 | argv_find(argv, argc, "(100-500)", &idx); | |
14568 | argv_find(argv, argc, "WORD", &idx); | |
14569 | ||
14570 | /* Unset community list. */ | |
14571 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
14572 | style); | |
14573 | ||
14574 | /* Free temporary community list string allocated by | |
14575 | argv_concat(). */ | |
0a22ddfb | 14576 | XFREE(MTYPE_TMP, str); |
d62a17ae | 14577 | |
14578 | if (ret < 0) { | |
14579 | community_list_perror(vty, ret); | |
14580 | return CMD_WARNING_CONFIG_FAILED; | |
14581 | } | |
14582 | ||
14583 | return CMD_SUCCESS; | |
57d187bc JS |
14584 | } |
14585 | ||
14586 | /* "large-community-list" keyword help string. */ | |
14587 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
14588 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
14589 | ||
7336e101 SP |
14590 | #if CONFDATE > 20191005 |
14591 | CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command") | |
14592 | #endif | |
14593 | DEFUN (lcommunity_list_standard, | |
14594 | bgp_lcommunity_list_standard_cmd, | |
14595 | "bgp large-community-list (1-99) <deny|permit>", | |
14596 | BGP_STR | |
14597 | LCOMMUNITY_LIST_STR | |
14598 | "Large Community list number (standard)\n" | |
14599 | "Specify large community to reject\n" | |
14600 | "Specify large community to accept\n") | |
14601 | { | |
14602 | return lcommunity_list_set_vty(vty, argc, argv, | |
14603 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
14604 | } | |
14605 | ||
14606 | ALIAS (lcommunity_list_standard, | |
57d187bc | 14607 | ip_lcommunity_list_standard_cmd, |
52951b63 DS |
14608 | "ip large-community-list (1-99) <deny|permit>", |
14609 | IP_STR | |
14610 | LCOMMUNITY_LIST_STR | |
14611 | "Large Community list number (standard)\n" | |
14612 | "Specify large community to reject\n" | |
7111c1a0 | 14613 | "Specify large community to accept\n") |
7336e101 SP |
14614 | |
14615 | DEFUN (lcommunity_list_standard1, | |
14616 | bgp_lcommunity_list_standard1_cmd, | |
14617 | "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
14618 | BGP_STR | |
14619 | LCOMMUNITY_LIST_STR | |
14620 | "Large Community list number (standard)\n" | |
14621 | "Specify large community to reject\n" | |
14622 | "Specify large community to accept\n" | |
14623 | LCOMMUNITY_VAL_STR) | |
52951b63 | 14624 | { |
d62a17ae | 14625 | return lcommunity_list_set_vty(vty, argc, argv, |
14626 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
14627 | } |
14628 | ||
7336e101 | 14629 | ALIAS (lcommunity_list_standard1, |
52951b63 DS |
14630 | ip_lcommunity_list_standard1_cmd, |
14631 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
14632 | IP_STR |
14633 | LCOMMUNITY_LIST_STR | |
14634 | "Large Community list number (standard)\n" | |
14635 | "Specify large community to reject\n" | |
14636 | "Specify large community to accept\n" | |
14637 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14638 | |
14639 | DEFUN (lcommunity_list_expanded, | |
14640 | bgp_lcommunity_list_expanded_cmd, | |
14641 | "bgp large-community-list (100-500) <deny|permit> LINE...", | |
14642 | BGP_STR | |
14643 | LCOMMUNITY_LIST_STR | |
14644 | "Large Community list number (expanded)\n" | |
14645 | "Specify large community to reject\n" | |
14646 | "Specify large community to accept\n" | |
14647 | "An ordered list as a regular-expression\n") | |
57d187bc | 14648 | { |
d62a17ae | 14649 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14650 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
14651 | } |
14652 | ||
7336e101 | 14653 | ALIAS (lcommunity_list_expanded, |
57d187bc JS |
14654 | ip_lcommunity_list_expanded_cmd, |
14655 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
14656 | IP_STR | |
14657 | LCOMMUNITY_LIST_STR | |
14658 | "Large Community list number (expanded)\n" | |
14659 | "Specify large community to reject\n" | |
14660 | "Specify large community to accept\n" | |
14661 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14662 | |
14663 | DEFUN (lcommunity_list_name_standard, | |
14664 | bgp_lcommunity_list_name_standard_cmd, | |
14665 | "bgp large-community-list standard WORD <deny|permit>", | |
14666 | BGP_STR | |
14667 | LCOMMUNITY_LIST_STR | |
14668 | "Specify standard large-community-list\n" | |
14669 | "Large Community list name\n" | |
14670 | "Specify large community to reject\n" | |
14671 | "Specify large community to accept\n") | |
57d187bc | 14672 | { |
d62a17ae | 14673 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14674 | LARGE_COMMUNITY_LIST_STANDARD, 1); |
57d187bc JS |
14675 | } |
14676 | ||
7336e101 | 14677 | ALIAS (lcommunity_list_name_standard, |
57d187bc | 14678 | ip_lcommunity_list_name_standard_cmd, |
52951b63 DS |
14679 | "ip large-community-list standard WORD <deny|permit>", |
14680 | IP_STR | |
14681 | LCOMMUNITY_LIST_STR | |
14682 | "Specify standard large-community-list\n" | |
14683 | "Large Community list name\n" | |
14684 | "Specify large community to reject\n" | |
14685 | "Specify large community to accept\n") | |
7336e101 SP |
14686 | |
14687 | DEFUN (lcommunity_list_name_standard1, | |
14688 | bgp_lcommunity_list_name_standard1_cmd, | |
14689 | "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
14690 | BGP_STR | |
14691 | LCOMMUNITY_LIST_STR | |
14692 | "Specify standard large-community-list\n" | |
14693 | "Large Community list name\n" | |
14694 | "Specify large community to reject\n" | |
14695 | "Specify large community to accept\n" | |
14696 | LCOMMUNITY_VAL_STR) | |
52951b63 | 14697 | { |
d62a17ae | 14698 | return lcommunity_list_set_vty(vty, argc, argv, |
14699 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
14700 | } |
14701 | ||
7336e101 | 14702 | ALIAS (lcommunity_list_name_standard1, |
52951b63 DS |
14703 | ip_lcommunity_list_name_standard1_cmd, |
14704 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
14705 | IP_STR |
14706 | LCOMMUNITY_LIST_STR | |
14707 | "Specify standard large-community-list\n" | |
14708 | "Large Community list name\n" | |
14709 | "Specify large community to reject\n" | |
14710 | "Specify large community to accept\n" | |
14711 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14712 | |
14713 | DEFUN (lcommunity_list_name_expanded, | |
14714 | bgp_lcommunity_list_name_expanded_cmd, | |
14715 | "bgp large-community-list expanded WORD <deny|permit> LINE...", | |
14716 | BGP_STR | |
14717 | LCOMMUNITY_LIST_STR | |
14718 | "Specify expanded large-community-list\n" | |
14719 | "Large Community list name\n" | |
14720 | "Specify large community to reject\n" | |
14721 | "Specify large community to accept\n" | |
14722 | "An ordered list as a regular-expression\n") | |
57d187bc | 14723 | { |
d62a17ae | 14724 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14725 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
14726 | } |
14727 | ||
7336e101 | 14728 | ALIAS (lcommunity_list_name_expanded, |
57d187bc JS |
14729 | ip_lcommunity_list_name_expanded_cmd, |
14730 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
14731 | IP_STR | |
14732 | LCOMMUNITY_LIST_STR | |
14733 | "Specify expanded large-community-list\n" | |
14734 | "Large Community list name\n" | |
14735 | "Specify large community to reject\n" | |
14736 | "Specify large community to accept\n" | |
14737 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14738 | |
14739 | DEFUN (no_lcommunity_list_standard_all, | |
14740 | no_bgp_lcommunity_list_standard_all_cmd, | |
14741 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", | |
14742 | NO_STR | |
14743 | BGP_STR | |
14744 | LCOMMUNITY_LIST_STR | |
14745 | "Large Community list number (standard)\n" | |
14746 | "Large Community list number (expanded)\n" | |
14747 | "Large Community list name\n") | |
57d187bc | 14748 | { |
7336e101 SP |
14749 | return lcommunity_list_unset_vty(vty, argc, argv, |
14750 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
14751 | } |
14752 | ||
7336e101 | 14753 | ALIAS (no_lcommunity_list_standard_all, |
57d187bc JS |
14754 | no_ip_lcommunity_list_standard_all_cmd, |
14755 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
14756 | NO_STR | |
14757 | IP_STR | |
14758 | LCOMMUNITY_LIST_STR | |
14759 | "Large Community list number (standard)\n" | |
14760 | "Large Community list number (expanded)\n" | |
14761 | "Large Community list name\n") | |
7336e101 SP |
14762 | |
14763 | DEFUN (no_lcommunity_list_name_expanded_all, | |
14764 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
14765 | "no bgp large-community-list expanded WORD", | |
14766 | NO_STR | |
14767 | BGP_STR | |
14768 | LCOMMUNITY_LIST_STR | |
14769 | "Specify expanded large-community-list\n" | |
14770 | "Large Community list name\n") | |
57d187bc | 14771 | { |
d62a17ae | 14772 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14773 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14774 | } |
14775 | ||
7336e101 | 14776 | ALIAS (no_lcommunity_list_name_expanded_all, |
57d187bc JS |
14777 | no_ip_lcommunity_list_name_expanded_all_cmd, |
14778 | "no ip large-community-list expanded WORD", | |
14779 | NO_STR | |
14780 | IP_STR | |
14781 | LCOMMUNITY_LIST_STR | |
14782 | "Specify expanded large-community-list\n" | |
14783 | "Large Community list name\n") | |
7336e101 SP |
14784 | |
14785 | DEFUN (no_lcommunity_list_standard, | |
14786 | no_bgp_lcommunity_list_standard_cmd, | |
14787 | "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
14788 | NO_STR | |
14789 | BGP_STR | |
14790 | LCOMMUNITY_LIST_STR | |
14791 | "Large Community list number (standard)\n" | |
14792 | "Specify large community to reject\n" | |
14793 | "Specify large community to accept\n" | |
14794 | LCOMMUNITY_VAL_STR) | |
57d187bc | 14795 | { |
d62a17ae | 14796 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14797 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
14798 | } |
14799 | ||
7336e101 | 14800 | ALIAS (no_lcommunity_list_standard, |
57d187bc JS |
14801 | no_ip_lcommunity_list_standard_cmd, |
14802 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
14803 | NO_STR | |
14804 | IP_STR | |
14805 | LCOMMUNITY_LIST_STR | |
14806 | "Large Community list number (standard)\n" | |
14807 | "Specify large community to reject\n" | |
14808 | "Specify large community to accept\n" | |
14809 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14810 | |
14811 | DEFUN (no_lcommunity_list_expanded, | |
14812 | no_bgp_lcommunity_list_expanded_cmd, | |
14813 | "no bgp large-community-list (100-500) <deny|permit> LINE...", | |
14814 | NO_STR | |
14815 | BGP_STR | |
14816 | LCOMMUNITY_LIST_STR | |
14817 | "Large Community list number (expanded)\n" | |
14818 | "Specify large community to reject\n" | |
14819 | "Specify large community to accept\n" | |
14820 | "An ordered list as a regular-expression\n") | |
57d187bc | 14821 | { |
d62a17ae | 14822 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14823 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14824 | } |
14825 | ||
7336e101 | 14826 | ALIAS (no_lcommunity_list_expanded, |
57d187bc JS |
14827 | no_ip_lcommunity_list_expanded_cmd, |
14828 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
14829 | NO_STR | |
14830 | IP_STR | |
14831 | LCOMMUNITY_LIST_STR | |
14832 | "Large Community list number (expanded)\n" | |
14833 | "Specify large community to reject\n" | |
14834 | "Specify large community to accept\n" | |
14835 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14836 | |
14837 | DEFUN (no_lcommunity_list_name_standard, | |
14838 | no_bgp_lcommunity_list_name_standard_cmd, | |
14839 | "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
14840 | NO_STR | |
14841 | BGP_STR | |
14842 | LCOMMUNITY_LIST_STR | |
14843 | "Specify standard large-community-list\n" | |
14844 | "Large Community list name\n" | |
14845 | "Specify large community to reject\n" | |
14846 | "Specify large community to accept\n" | |
14847 | LCOMMUNITY_VAL_STR) | |
57d187bc | 14848 | { |
d62a17ae | 14849 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14850 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
14851 | } |
14852 | ||
7336e101 | 14853 | ALIAS (no_lcommunity_list_name_standard, |
57d187bc JS |
14854 | no_ip_lcommunity_list_name_standard_cmd, |
14855 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
14856 | NO_STR | |
14857 | IP_STR | |
14858 | LCOMMUNITY_LIST_STR | |
14859 | "Specify standard large-community-list\n" | |
14860 | "Large Community list name\n" | |
14861 | "Specify large community to reject\n" | |
14862 | "Specify large community to accept\n" | |
14863 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14864 | |
14865 | DEFUN (no_lcommunity_list_name_expanded, | |
14866 | no_bgp_lcommunity_list_name_expanded_cmd, | |
14867 | "no bgp large-community-list expanded WORD <deny|permit> LINE...", | |
14868 | NO_STR | |
14869 | BGP_STR | |
14870 | LCOMMUNITY_LIST_STR | |
14871 | "Specify expanded large-community-list\n" | |
14872 | "Large community list name\n" | |
14873 | "Specify large community to reject\n" | |
14874 | "Specify large community to accept\n" | |
14875 | "An ordered list as a regular-expression\n") | |
57d187bc | 14876 | { |
d62a17ae | 14877 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14878 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14879 | } |
14880 | ||
7336e101 | 14881 | ALIAS (no_lcommunity_list_name_expanded, |
57d187bc JS |
14882 | no_ip_lcommunity_list_name_expanded_cmd, |
14883 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
14884 | NO_STR | |
14885 | IP_STR | |
14886 | LCOMMUNITY_LIST_STR | |
14887 | "Specify expanded large-community-list\n" | |
14888 | "Large community list name\n" | |
14889 | "Specify large community to reject\n" | |
14890 | "Specify large community to accept\n" | |
14891 | "An ordered list as a regular-expression\n") | |
d62a17ae | 14892 | |
14893 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) | |
14894 | { | |
14895 | struct community_entry *entry; | |
14896 | ||
14897 | for (entry = list->head; entry; entry = entry->next) { | |
14898 | if (entry == list->head) { | |
14899 | if (all_digit(list->name)) | |
14900 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 14901 | entry->style == |
14902 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 14903 | ? "standard" |
14904 | : "(expanded) access", | |
14905 | list->name); | |
14906 | else | |
14907 | vty_out(vty, | |
14908 | "Named large community %s list %s\n", | |
169b72c8 | 14909 | entry->style == |
14910 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 14911 | ? "standard" |
14912 | : "expanded", | |
14913 | list->name); | |
14914 | } | |
14915 | if (entry->any) | |
14916 | vty_out(vty, " %s\n", | |
14917 | community_direct_str(entry->direct)); | |
14918 | else | |
14919 | vty_out(vty, " %s %s\n", | |
14920 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14921 | community_list_config_str(entry)); |
d62a17ae | 14922 | } |
57d187bc JS |
14923 | } |
14924 | ||
7336e101 SP |
14925 | DEFUN (show_lcommunity_list, |
14926 | show_bgp_lcommunity_list_cmd, | |
14927 | "show bgp large-community-list", | |
57d187bc | 14928 | SHOW_STR |
7336e101 | 14929 | BGP_STR |
57d187bc JS |
14930 | "List large-community list\n") |
14931 | { | |
d62a17ae | 14932 | struct community_list *list; |
14933 | struct community_list_master *cm; | |
7336e101 SP |
14934 | int idx = 0; |
14935 | ||
14936 | if (argv_find(argv, argc, "ip", &idx)) { | |
14937 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14938 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14939 | vty_out(vty, "'show bgp large-community-list <(1-500)|WORD>'\n"); | |
14940 | zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used"); | |
14941 | } | |
57d187bc | 14942 | |
d62a17ae | 14943 | cm = community_list_master_lookup(bgp_clist, |
14944 | LARGE_COMMUNITY_LIST_MASTER); | |
14945 | if (!cm) | |
14946 | return CMD_SUCCESS; | |
57d187bc | 14947 | |
d62a17ae | 14948 | for (list = cm->num.head; list; list = list->next) |
14949 | lcommunity_list_show(vty, list); | |
57d187bc | 14950 | |
d62a17ae | 14951 | for (list = cm->str.head; list; list = list->next) |
14952 | lcommunity_list_show(vty, list); | |
57d187bc | 14953 | |
d62a17ae | 14954 | return CMD_SUCCESS; |
57d187bc JS |
14955 | } |
14956 | ||
7336e101 SP |
14957 | ALIAS (show_lcommunity_list, |
14958 | show_ip_lcommunity_list_cmd, | |
14959 | "show ip large-community-list", | |
57d187bc JS |
14960 | SHOW_STR |
14961 | IP_STR | |
7336e101 SP |
14962 | "List large-community list\n") |
14963 | ||
14964 | DEFUN (show_lcommunity_list_arg, | |
14965 | show_bgp_lcommunity_list_arg_cmd, | |
14966 | "show bgp large-community-list <(1-500)|WORD>", | |
14967 | SHOW_STR | |
14968 | BGP_STR | |
57d187bc JS |
14969 | "List large-community list\n" |
14970 | "large-community-list number\n" | |
14971 | "large-community-list name\n") | |
14972 | { | |
d62a17ae | 14973 | struct community_list *list; |
7336e101 SP |
14974 | int idx = 0; |
14975 | ||
14976 | if (argv_find(argv, argc, "ip", &idx)) { | |
14977 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14978 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14979 | vty_out(vty, "'show bgp large-community-list <(1-500)|WORD>'\n"); | |
14980 | zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used"); | |
14981 | } | |
57d187bc | 14982 | |
e237b0d2 | 14983 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 14984 | LARGE_COMMUNITY_LIST_MASTER); |
14985 | if (!list) { | |
14986 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
14987 | return CMD_WARNING; | |
14988 | } | |
57d187bc | 14989 | |
d62a17ae | 14990 | lcommunity_list_show(vty, list); |
57d187bc | 14991 | |
d62a17ae | 14992 | return CMD_SUCCESS; |
57d187bc JS |
14993 | } |
14994 | ||
7336e101 SP |
14995 | ALIAS (show_lcommunity_list_arg, |
14996 | show_ip_lcommunity_list_arg_cmd, | |
14997 | "show ip large-community-list <(1-500)|WORD>", | |
14998 | SHOW_STR | |
14999 | IP_STR | |
15000 | "List large-community list\n" | |
15001 | "large-community-list number\n" | |
15002 | "large-community-list name\n") | |
15003 | ||
718e3744 | 15004 | /* "extcommunity-list" keyword help string. */ |
15005 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
15006 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
15007 | ||
7336e101 SP |
15008 | DEFUN (extcommunity_list_standard, |
15009 | bgp_extcommunity_list_standard_cmd, | |
15010 | "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
15011 | BGP_STR | |
718e3744 | 15012 | EXTCOMMUNITY_LIST_STR |
15013 | "Extended Community list number (standard)\n" | |
718e3744 | 15014 | "Specify standard extcommunity-list\n" |
5bf15956 | 15015 | "Community list name\n" |
718e3744 | 15016 | "Specify community to reject\n" |
15017 | "Specify community to accept\n" | |
15018 | EXTCOMMUNITY_VAL_STR) | |
15019 | { | |
d62a17ae | 15020 | int style = EXTCOMMUNITY_LIST_STANDARD; |
15021 | int direct = 0; | |
15022 | char *cl_number_or_name = NULL; | |
42f914d4 | 15023 | |
d62a17ae | 15024 | int idx = 0; |
7336e101 SP |
15025 | if (argv_find(argv, argc, "ip", &idx)) { |
15026 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15027 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15028 | vty_out(vty, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15029 | zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15030 | } | |
d62a17ae | 15031 | argv_find(argv, argc, "(1-99)", &idx); |
15032 | argv_find(argv, argc, "WORD", &idx); | |
15033 | cl_number_or_name = argv[idx]->arg; | |
15034 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
15035 | : COMMUNITY_DENY; | |
15036 | argv_find(argv, argc, "AA:NN", &idx); | |
15037 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 15038 | |
d62a17ae | 15039 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
15040 | direct, style); | |
42f914d4 | 15041 | |
d62a17ae | 15042 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15043 | |
d62a17ae | 15044 | if (ret < 0) { |
15045 | community_list_perror(vty, ret); | |
15046 | return CMD_WARNING_CONFIG_FAILED; | |
15047 | } | |
42f914d4 | 15048 | |
d62a17ae | 15049 | return CMD_SUCCESS; |
718e3744 | 15050 | } |
15051 | ||
7336e101 SP |
15052 | #if CONFDATE > 20191005 |
15053 | CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command") | |
15054 | #endif | |
15055 | ALIAS (extcommunity_list_standard, | |
15056 | ip_extcommunity_list_standard_cmd, | |
15057 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 15058 | IP_STR |
15059 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
15060 | "Extended Community list number (standard)\n" |
15061 | "Specify standard extcommunity-list\n" | |
15062 | "Community list name\n" | |
15063 | "Specify community to reject\n" | |
15064 | "Specify community to accept\n" | |
15065 | EXTCOMMUNITY_VAL_STR) | |
15066 | ||
15067 | DEFUN (extcommunity_list_name_expanded, | |
15068 | bgp_extcommunity_list_name_expanded_cmd, | |
15069 | "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15070 | BGP_STR | |
15071 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 15072 | "Extended Community list number (expanded)\n" |
718e3744 | 15073 | "Specify expanded extcommunity-list\n" |
15074 | "Extended Community list name\n" | |
15075 | "Specify community to reject\n" | |
15076 | "Specify community to accept\n" | |
15077 | "An ordered list as a regular-expression\n") | |
15078 | { | |
d62a17ae | 15079 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
15080 | int direct = 0; | |
15081 | char *cl_number_or_name = NULL; | |
42f914d4 | 15082 | |
d62a17ae | 15083 | int idx = 0; |
7336e101 SP |
15084 | if (argv_find(argv, argc, "ip", &idx)) { |
15085 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15086 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15087 | vty_out(vty, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15088 | zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15089 | } | |
15090 | ||
d62a17ae | 15091 | argv_find(argv, argc, "(100-500)", &idx); |
15092 | argv_find(argv, argc, "WORD", &idx); | |
15093 | cl_number_or_name = argv[idx]->arg; | |
15094 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
15095 | : COMMUNITY_DENY; | |
15096 | argv_find(argv, argc, "LINE", &idx); | |
15097 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 15098 | |
d62a17ae | 15099 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
15100 | direct, style); | |
42f914d4 | 15101 | |
d62a17ae | 15102 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15103 | |
d62a17ae | 15104 | if (ret < 0) { |
15105 | community_list_perror(vty, ret); | |
15106 | return CMD_WARNING_CONFIG_FAILED; | |
15107 | } | |
42f914d4 | 15108 | |
d62a17ae | 15109 | return CMD_SUCCESS; |
718e3744 | 15110 | } |
15111 | ||
7336e101 SP |
15112 | ALIAS (extcommunity_list_name_expanded, |
15113 | ip_extcommunity_list_name_expanded_cmd, | |
15114 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
813d4307 DW |
15115 | IP_STR |
15116 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
15117 | "Extended Community list number (expanded)\n" |
15118 | "Specify expanded extcommunity-list\n" | |
15119 | "Extended Community list name\n" | |
15120 | "Specify community to reject\n" | |
15121 | "Specify community to accept\n" | |
15122 | "An ordered list as a regular-expression\n") | |
15123 | ||
15124 | DEFUN (no_extcommunity_list_standard_all, | |
15125 | no_bgp_extcommunity_list_standard_all_cmd, | |
15126 | "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
15127 | NO_STR | |
15128 | BGP_STR | |
15129 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 15130 | "Extended Community list number (standard)\n" |
718e3744 | 15131 | "Specify standard extcommunity-list\n" |
5bf15956 | 15132 | "Community list name\n" |
718e3744 | 15133 | "Specify community to reject\n" |
15134 | "Specify community to accept\n" | |
15135 | EXTCOMMUNITY_VAL_STR) | |
15136 | { | |
d62a17ae | 15137 | int style = EXTCOMMUNITY_LIST_STANDARD; |
15138 | int direct = 0; | |
15139 | char *cl_number_or_name = NULL; | |
d4455c89 | 15140 | char *str = NULL; |
42f914d4 | 15141 | |
d62a17ae | 15142 | int idx = 0; |
7336e101 SP |
15143 | if (argv_find(argv, argc, "ip", &idx)) { |
15144 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
15145 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15146 | vty_out(vty, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15147 | zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15148 | } | |
d4455c89 DA |
15149 | |
15150 | idx = 0; | |
15151 | argv_find(argv, argc, "permit", &idx); | |
15152 | argv_find(argv, argc, "deny", &idx); | |
15153 | ||
15154 | if (idx) { | |
15155 | direct = argv_find(argv, argc, "permit", &idx) | |
15156 | ? COMMUNITY_PERMIT | |
15157 | : COMMUNITY_DENY; | |
15158 | ||
15159 | idx = 0; | |
15160 | argv_find(argv, argc, "AA:NN", &idx); | |
15161 | str = argv_concat(argv, argc, idx); | |
15162 | } | |
15163 | ||
15164 | idx = 0; | |
d62a17ae | 15165 | argv_find(argv, argc, "(1-99)", &idx); |
15166 | argv_find(argv, argc, "WORD", &idx); | |
15167 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 15168 | |
d62a17ae | 15169 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 15170 | direct, style); |
42f914d4 | 15171 | |
d62a17ae | 15172 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15173 | |
d62a17ae | 15174 | if (ret < 0) { |
15175 | community_list_perror(vty, ret); | |
15176 | return CMD_WARNING_CONFIG_FAILED; | |
15177 | } | |
42f914d4 | 15178 | |
d62a17ae | 15179 | return CMD_SUCCESS; |
718e3744 | 15180 | } |
15181 | ||
7336e101 SP |
15182 | ALIAS (no_extcommunity_list_standard_all, |
15183 | no_ip_extcommunity_list_standard_all_cmd, | |
15184 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 15185 | NO_STR |
15186 | IP_STR | |
15187 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
15188 | "Extended Community list number (standard)\n" |
15189 | "Specify standard extcommunity-list\n" | |
15190 | "Community list name\n" | |
15191 | "Specify community to reject\n" | |
15192 | "Specify community to accept\n" | |
15193 | EXTCOMMUNITY_VAL_STR) | |
15194 | ||
d4455c89 DA |
15195 | ALIAS(no_extcommunity_list_standard_all, |
15196 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
15197 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
15198 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15199 | "Extended Community list number (standard)\n" | |
15200 | "Specify standard extcommunity-list\n" | |
15201 | "Community list name\n") | |
15202 | ||
15203 | ALIAS(no_extcommunity_list_standard_all, | |
15204 | no_ip_extcommunity_list_standard_all_list_cmd, | |
15205 | "no ip extcommunity-list <(1-99)|standard WORD>", | |
15206 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15207 | "Extended Community list number (standard)\n" | |
15208 | "Specify standard extcommunity-list\n" | |
15209 | "Community list name\n") | |
15210 | ||
7336e101 SP |
15211 | DEFUN (no_extcommunity_list_expanded_all, |
15212 | no_bgp_extcommunity_list_expanded_all_cmd, | |
15213 | "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15214 | NO_STR | |
15215 | BGP_STR | |
15216 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 15217 | "Extended Community list number (expanded)\n" |
718e3744 | 15218 | "Specify expanded extcommunity-list\n" |
5bf15956 | 15219 | "Extended Community list name\n" |
718e3744 | 15220 | "Specify community to reject\n" |
15221 | "Specify community to accept\n" | |
15222 | "An ordered list as a regular-expression\n") | |
15223 | { | |
d62a17ae | 15224 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
15225 | int direct = 0; | |
15226 | char *cl_number_or_name = NULL; | |
d4455c89 | 15227 | char *str = NULL; |
42f914d4 | 15228 | |
d62a17ae | 15229 | int idx = 0; |
7336e101 SP |
15230 | if (argv_find(argv, argc, "ip", &idx)) { |
15231 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15232 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15233 | vty_out(vty, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15234 | zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15235 | } | |
d4455c89 DA |
15236 | |
15237 | idx = 0; | |
15238 | argv_find(argv, argc, "permit", &idx); | |
15239 | argv_find(argv, argc, "deny", &idx); | |
15240 | ||
15241 | if (idx) { | |
15242 | direct = argv_find(argv, argc, "permit", &idx) | |
15243 | ? COMMUNITY_PERMIT | |
15244 | : COMMUNITY_DENY; | |
15245 | ||
15246 | idx = 0; | |
15247 | argv_find(argv, argc, "LINE", &idx); | |
15248 | str = argv_concat(argv, argc, idx); | |
15249 | } | |
15250 | ||
15251 | idx = 0; | |
d62a17ae | 15252 | argv_find(argv, argc, "(100-500)", &idx); |
15253 | argv_find(argv, argc, "WORD", &idx); | |
15254 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 15255 | |
d62a17ae | 15256 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 15257 | direct, style); |
42f914d4 | 15258 | |
d62a17ae | 15259 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15260 | |
d62a17ae | 15261 | if (ret < 0) { |
15262 | community_list_perror(vty, ret); | |
15263 | return CMD_WARNING_CONFIG_FAILED; | |
15264 | } | |
42f914d4 | 15265 | |
d62a17ae | 15266 | return CMD_SUCCESS; |
718e3744 | 15267 | } |
15268 | ||
7336e101 SP |
15269 | ALIAS (no_extcommunity_list_expanded_all, |
15270 | no_ip_extcommunity_list_expanded_all_cmd, | |
15271 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15272 | NO_STR | |
15273 | IP_STR | |
15274 | EXTCOMMUNITY_LIST_STR | |
15275 | "Extended Community list number (expanded)\n" | |
15276 | "Specify expanded extcommunity-list\n" | |
15277 | "Extended Community list name\n" | |
15278 | "Specify community to reject\n" | |
15279 | "Specify community to accept\n" | |
15280 | "An ordered list as a regular-expression\n") | |
15281 | ||
d4455c89 DA |
15282 | ALIAS(no_extcommunity_list_expanded_all, |
15283 | no_ip_extcommunity_list_expanded_all_list_cmd, | |
15284 | "no ip extcommunity-list <(100-500)|expanded WORD>", | |
15285 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15286 | "Extended Community list number (expanded)\n" | |
15287 | "Specify expanded extcommunity-list\n" | |
15288 | "Extended Community list name\n") | |
15289 | ||
15290 | ALIAS(no_extcommunity_list_expanded_all, | |
15291 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
15292 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
15293 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15294 | "Extended Community list number (expanded)\n" | |
15295 | "Specify expanded extcommunity-list\n" | |
15296 | "Extended Community list name\n") | |
15297 | ||
d62a17ae | 15298 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 15299 | { |
d62a17ae | 15300 | struct community_entry *entry; |
718e3744 | 15301 | |
d62a17ae | 15302 | for (entry = list->head; entry; entry = entry->next) { |
15303 | if (entry == list->head) { | |
15304 | if (all_digit(list->name)) | |
15305 | vty_out(vty, "Extended community %s list %s\n", | |
15306 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
15307 | ? "standard" | |
15308 | : "(expanded) access", | |
15309 | list->name); | |
15310 | else | |
15311 | vty_out(vty, | |
15312 | "Named extended community %s list %s\n", | |
15313 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
15314 | ? "standard" | |
15315 | : "expanded", | |
15316 | list->name); | |
15317 | } | |
15318 | if (entry->any) | |
15319 | vty_out(vty, " %s\n", | |
15320 | community_direct_str(entry->direct)); | |
15321 | else | |
15322 | vty_out(vty, " %s %s\n", | |
15323 | community_direct_str(entry->direct), | |
8d9b8ed9 | 15324 | community_list_config_str(entry)); |
d62a17ae | 15325 | } |
718e3744 | 15326 | } |
15327 | ||
7336e101 SP |
15328 | DEFUN (show_extcommunity_list, |
15329 | show_bgp_extcommunity_list_cmd, | |
15330 | "show bgp extcommunity-list", | |
718e3744 | 15331 | SHOW_STR |
7336e101 | 15332 | BGP_STR |
718e3744 | 15333 | "List extended-community list\n") |
15334 | { | |
d62a17ae | 15335 | struct community_list *list; |
15336 | struct community_list_master *cm; | |
7336e101 | 15337 | int idx = 0; |
718e3744 | 15338 | |
7336e101 SP |
15339 | if (argv_find(argv, argc, "ip", &idx)) { |
15340 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
15341 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15342 | vty_out(vty, "'show bgp extcommunity-list <(1-500)|WORD>'\n"); | |
15343 | zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used"); | |
15344 | } | |
d62a17ae | 15345 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
15346 | if (!cm) | |
15347 | return CMD_SUCCESS; | |
718e3744 | 15348 | |
d62a17ae | 15349 | for (list = cm->num.head; list; list = list->next) |
15350 | extcommunity_list_show(vty, list); | |
718e3744 | 15351 | |
d62a17ae | 15352 | for (list = cm->str.head; list; list = list->next) |
15353 | extcommunity_list_show(vty, list); | |
718e3744 | 15354 | |
d62a17ae | 15355 | return CMD_SUCCESS; |
718e3744 | 15356 | } |
15357 | ||
7336e101 SP |
15358 | ALIAS (show_extcommunity_list, |
15359 | show_ip_extcommunity_list_cmd, | |
15360 | "show ip extcommunity-list", | |
718e3744 | 15361 | SHOW_STR |
15362 | IP_STR | |
7336e101 SP |
15363 | "List extended-community list\n") |
15364 | ||
15365 | DEFUN (show_extcommunity_list_arg, | |
15366 | show_bgp_extcommunity_list_arg_cmd, | |
15367 | "show bgp extcommunity-list <(1-500)|WORD>", | |
15368 | SHOW_STR | |
15369 | BGP_STR | |
718e3744 | 15370 | "List extended-community list\n" |
15371 | "Extcommunity-list number\n" | |
15372 | "Extcommunity-list name\n") | |
15373 | { | |
d62a17ae | 15374 | int idx_comm_list = 3; |
15375 | struct community_list *list; | |
7336e101 | 15376 | int idx = 0; |
718e3744 | 15377 | |
7336e101 SP |
15378 | if (argv_find(argv, argc, "ip", &idx)) { |
15379 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15380 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15381 | vty_out(vty, "'show bgp extcommunity-list <(1-500)|WORD>'\n"); | |
15382 | zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used"); | |
15383 | } | |
e237b0d2 | 15384 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 15385 | EXTCOMMUNITY_LIST_MASTER); |
15386 | if (!list) { | |
15387 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
15388 | return CMD_WARNING; | |
15389 | } | |
718e3744 | 15390 | |
d62a17ae | 15391 | extcommunity_list_show(vty, list); |
718e3744 | 15392 | |
d62a17ae | 15393 | return CMD_SUCCESS; |
718e3744 | 15394 | } |
6b0655a2 | 15395 | |
7336e101 SP |
15396 | ALIAS (show_extcommunity_list_arg, |
15397 | show_ip_extcommunity_list_arg_cmd, | |
15398 | "show ip extcommunity-list <(1-500)|WORD>", | |
15399 | SHOW_STR | |
15400 | IP_STR | |
15401 | "List extended-community list\n" | |
15402 | "Extcommunity-list number\n" | |
15403 | "Extcommunity-list name\n") | |
15404 | ||
718e3744 | 15405 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 15406 | static int community_list_config_write(struct vty *vty) |
15407 | { | |
15408 | struct community_list *list; | |
15409 | struct community_entry *entry; | |
15410 | struct community_list_master *cm; | |
15411 | int write = 0; | |
15412 | ||
15413 | /* Community-list. */ | |
15414 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
15415 | ||
15416 | for (list = cm->num.head; list; list = list->next) | |
15417 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15418 | vty_out(vty, "bgp community-list %s %s %s\n", list->name, |
d62a17ae | 15419 | community_direct_str(entry->direct), |
15420 | community_list_config_str(entry)); | |
15421 | write++; | |
15422 | } | |
15423 | for (list = cm->str.head; list; list = list->next) | |
15424 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15425 | vty_out(vty, "bgp community-list %s %s %s %s\n", |
d62a17ae | 15426 | entry->style == COMMUNITY_LIST_STANDARD |
15427 | ? "standard" | |
15428 | : "expanded", | |
15429 | list->name, community_direct_str(entry->direct), | |
15430 | community_list_config_str(entry)); | |
15431 | write++; | |
15432 | } | |
15433 | ||
15434 | /* Extcommunity-list. */ | |
15435 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
15436 | ||
15437 | for (list = cm->num.head; list; list = list->next) | |
15438 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15439 | vty_out(vty, "bgp extcommunity-list %s %s %s\n", |
d62a17ae | 15440 | list->name, community_direct_str(entry->direct), |
15441 | community_list_config_str(entry)); | |
15442 | write++; | |
15443 | } | |
15444 | for (list = cm->str.head; list; list = list->next) | |
15445 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15446 | vty_out(vty, "bgp extcommunity-list %s %s %s %s\n", |
d62a17ae | 15447 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
15448 | ? "standard" | |
15449 | : "expanded", | |
15450 | list->name, community_direct_str(entry->direct), | |
15451 | community_list_config_str(entry)); | |
15452 | write++; | |
15453 | } | |
15454 | ||
15455 | ||
15456 | /* lcommunity-list. */ | |
15457 | cm = community_list_master_lookup(bgp_clist, | |
15458 | LARGE_COMMUNITY_LIST_MASTER); | |
15459 | ||
15460 | for (list = cm->num.head; list; list = list->next) | |
15461 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15462 | vty_out(vty, "bgp large-community-list %s %s %s\n", |
d62a17ae | 15463 | list->name, community_direct_str(entry->direct), |
15464 | community_list_config_str(entry)); | |
15465 | write++; | |
15466 | } | |
15467 | for (list = cm->str.head; list; list = list->next) | |
15468 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15469 | vty_out(vty, "bgp large-community-list %s %s %s %s\n", |
d62a17ae | 15470 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
15471 | ? "standard" | |
15472 | : "expanded", | |
15473 | list->name, community_direct_str(entry->direct), | |
15474 | community_list_config_str(entry)); | |
15475 | write++; | |
15476 | } | |
15477 | ||
15478 | return write; | |
15479 | } | |
15480 | ||
15481 | static struct cmd_node community_list_node = { | |
15482 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 15483 | }; |
15484 | ||
d62a17ae | 15485 | static void community_list_vty(void) |
15486 | { | |
15487 | install_node(&community_list_node, community_list_config_write); | |
15488 | ||
15489 | /* Community-list. */ | |
7336e101 SP |
15490 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
15491 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
15492 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 15493 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 15494 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 15495 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
15496 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
15497 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 15498 | install_element(CONFIG_NODE, &ip_community_list_standard_cmd); |
15499 | install_element(CONFIG_NODE, &ip_community_list_expanded_all_cmd); | |
15500 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_cmd); | |
174b5cb9 | 15501 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_list_cmd); |
d62a17ae | 15502 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); |
174b5cb9 | 15503 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_list_cmd); |
d62a17ae | 15504 | install_element(VIEW_NODE, &show_ip_community_list_cmd); |
15505 | install_element(VIEW_NODE, &show_ip_community_list_arg_cmd); | |
15506 | ||
15507 | /* Extcommunity-list. */ | |
7336e101 SP |
15508 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
15509 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
15510 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
15511 | install_element(CONFIG_NODE, |
15512 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 15513 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
15514 | install_element(CONFIG_NODE, |
15515 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
15516 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
15517 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 15518 | install_element(CONFIG_NODE, &ip_extcommunity_list_standard_cmd); |
15519 | install_element(CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); | |
15520 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); | |
d4455c89 | 15521 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_list_cmd); |
d62a17ae | 15522 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); |
d4455c89 | 15523 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_list_cmd); |
d62a17ae | 15524 | install_element(VIEW_NODE, &show_ip_extcommunity_list_cmd); |
15525 | install_element(VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
15526 | ||
15527 | /* Large Community List */ | |
7336e101 SP |
15528 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
15529 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard1_cmd); | |
15530 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); | |
15531 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
15532 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard1_cmd); | |
15533 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); | |
15534 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_all_cmd); | |
15535 | install_element(CONFIG_NODE, | |
15536 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
15537 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
15538 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
15539 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
15540 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
15541 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
15542 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
d62a17ae | 15543 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard_cmd); |
15544 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); | |
15545 | install_element(CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); | |
15546 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
15547 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); | |
15548 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); | |
15549 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
15550 | install_element(CONFIG_NODE, | |
15551 | &no_ip_lcommunity_list_name_expanded_all_cmd); | |
15552 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
15553 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
15554 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
15555 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
15556 | install_element(VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
15557 | install_element(VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 15558 | } |