]>
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) { | |
982 | case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: | |
983 | vty_out(vty, | |
984 | "Please specify 'bgp multiple-instance' first\n"); | |
985 | return CMD_WARNING_CONFIG_FAILED; | |
986 | case BGP_ERR_AS_MISMATCH: | |
987 | vty_out(vty, "BGP is already running; AS is %u\n", as); | |
988 | return CMD_WARNING_CONFIG_FAILED; | |
989 | case BGP_ERR_INSTANCE_MISMATCH: | |
990 | vty_out(vty, | |
991 | "BGP instance name and AS number mismatch\n"); | |
992 | vty_out(vty, | |
993 | "BGP instance is already running; AS is %u\n", | |
994 | as); | |
995 | return CMD_WARNING_CONFIG_FAILED; | |
996 | } | |
997 | ||
3bd70bf8 PZ |
998 | /* |
999 | * If we just instantiated the default instance, complete | |
1000 | * any pending VRF-VPN leaking that was configured via | |
1001 | * earlier "router bgp X vrf FOO" blocks. | |
1002 | */ | |
ecec9495 | 1003 | if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) |
3bd70bf8 PZ |
1004 | vpn_leak_postchange_all(); |
1005 | ||
d62a17ae | 1006 | /* Pending: handle when user tries to change a view to vrf n vv. |
1007 | */ | |
1008 | } | |
1009 | ||
0b5131c9 MK |
1010 | /* unset the auto created flag as the user config is now present */ |
1011 | UNSET_FLAG(bgp->vrf_flags, BGP_VRF_AUTO); | |
d62a17ae | 1012 | VTY_PUSH_CONTEXT(BGP_NODE, bgp); |
1013 | ||
1014 | return CMD_SUCCESS; | |
718e3744 | 1015 | } |
1016 | ||
718e3744 | 1017 | /* "no router bgp" commands. */ |
1018 | DEFUN (no_router_bgp, | |
1019 | no_router_bgp_cmd, | |
18c57037 | 1020 | "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]", |
718e3744 | 1021 | NO_STR |
1022 | ROUTER_STR | |
1023 | BGP_STR | |
31500417 DW |
1024 | AS_STR |
1025 | BGP_INSTANCE_HELP_STR) | |
718e3744 | 1026 | { |
d62a17ae | 1027 | int idx_asn = 3; |
1028 | int idx_vrf = 5; | |
1029 | as_t as; | |
1030 | struct bgp *bgp; | |
1031 | const char *name = NULL; | |
718e3744 | 1032 | |
d62a17ae | 1033 | // "no router bgp" without an ASN |
1034 | if (argc == 3) { | |
1035 | // Pending: Make VRF option available for ASN less config | |
1036 | bgp = bgp_get_default(); | |
718e3744 | 1037 | |
d62a17ae | 1038 | if (bgp == NULL) { |
1039 | vty_out(vty, "%% No BGP process is configured\n"); | |
1040 | return CMD_WARNING_CONFIG_FAILED; | |
1041 | } | |
7fb21a9f | 1042 | |
d62a17ae | 1043 | if (listcount(bm->bgp) > 1) { |
996c9314 | 1044 | vty_out(vty, "%% Please specify ASN and VRF\n"); |
d62a17ae | 1045 | return CMD_WARNING_CONFIG_FAILED; |
1046 | } | |
0b5131c9 MK |
1047 | |
1048 | if (bgp->l3vni) { | |
1049 | vty_out(vty, "%% Please unconfigure l3vni %u", | |
1050 | bgp->l3vni); | |
1051 | return CMD_WARNING_CONFIG_FAILED; | |
1052 | } | |
d62a17ae | 1053 | } else { |
1054 | as = strtoul(argv[idx_asn]->arg, NULL, 10); | |
7fb21a9f | 1055 | |
d62a17ae | 1056 | if (argc > 4) |
1057 | name = argv[idx_vrf]->arg; | |
7fb21a9f | 1058 | |
d62a17ae | 1059 | /* Lookup bgp structure. */ |
1060 | bgp = bgp_lookup(as, name); | |
1061 | if (!bgp) { | |
1062 | vty_out(vty, "%% Can't find BGP instance\n"); | |
1063 | return CMD_WARNING_CONFIG_FAILED; | |
1064 | } | |
0b5131c9 MK |
1065 | |
1066 | if (bgp->l3vni) { | |
dd5868c2 | 1067 | vty_out(vty, "%% Please unconfigure l3vni %u\n", |
0b5131c9 MK |
1068 | bgp->l3vni); |
1069 | return CMD_WARNING_CONFIG_FAILED; | |
1070 | } | |
dd5868c2 DS |
1071 | |
1072 | /* Cannot delete default instance if vrf instances exist */ | |
1073 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
1074 | struct listnode *node; | |
1075 | struct bgp *tmp_bgp; | |
1076 | ||
1077 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, tmp_bgp)) { | |
1078 | if (tmp_bgp->inst_type | |
1079 | == BGP_INSTANCE_TYPE_VRF) { | |
1080 | vty_out(vty, | |
1081 | "%% Cannot delete default BGP instance. Dependent VRF instances exist\n"); | |
1082 | return CMD_WARNING_CONFIG_FAILED; | |
1083 | } | |
1084 | } | |
1085 | } | |
d62a17ae | 1086 | } |
718e3744 | 1087 | |
d62a17ae | 1088 | bgp_delete(bgp); |
718e3744 | 1089 | |
d62a17ae | 1090 | return CMD_SUCCESS; |
718e3744 | 1091 | } |
1092 | ||
6b0655a2 | 1093 | |
718e3744 | 1094 | /* BGP router-id. */ |
1095 | ||
f787d7a0 | 1096 | DEFPY (bgp_router_id, |
718e3744 | 1097 | bgp_router_id_cmd, |
1098 | "bgp router-id A.B.C.D", | |
1099 | BGP_STR | |
1100 | "Override configured router identifier\n" | |
1101 | "Manually configured router identifier\n") | |
1102 | { | |
d62a17ae | 1103 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1104 | bgp_router_id_static_set(bgp, router_id); | |
1105 | return CMD_SUCCESS; | |
718e3744 | 1106 | } |
1107 | ||
f787d7a0 | 1108 | DEFPY (no_bgp_router_id, |
718e3744 | 1109 | no_bgp_router_id_cmd, |
31500417 | 1110 | "no bgp router-id [A.B.C.D]", |
718e3744 | 1111 | NO_STR |
1112 | BGP_STR | |
31500417 DW |
1113 | "Override configured router identifier\n" |
1114 | "Manually configured router identifier\n") | |
718e3744 | 1115 | { |
d62a17ae | 1116 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
718e3744 | 1117 | |
d62a17ae | 1118 | if (router_id_str) { |
1119 | if (!IPV4_ADDR_SAME(&bgp->router_id_static, &router_id)) { | |
1120 | vty_out(vty, "%% BGP router-id doesn't match\n"); | |
1121 | return CMD_WARNING_CONFIG_FAILED; | |
1122 | } | |
e018c7cc | 1123 | } |
718e3744 | 1124 | |
d62a17ae | 1125 | router_id.s_addr = 0; |
1126 | bgp_router_id_static_set(bgp, router_id); | |
718e3744 | 1127 | |
d62a17ae | 1128 | return CMD_SUCCESS; |
718e3744 | 1129 | } |
1130 | ||
6b0655a2 | 1131 | |
718e3744 | 1132 | /* BGP Cluster ID. */ |
718e3744 | 1133 | DEFUN (bgp_cluster_id, |
1134 | bgp_cluster_id_cmd, | |
838758ac | 1135 | "bgp cluster-id <A.B.C.D|(1-4294967295)>", |
718e3744 | 1136 | BGP_STR |
1137 | "Configure Route-Reflector Cluster-id\n" | |
838758ac DW |
1138 | "Route-Reflector Cluster-id in IP address format\n" |
1139 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1140 | { |
d62a17ae | 1141 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1142 | int idx_ipv4 = 2; | |
1143 | int ret; | |
1144 | struct in_addr cluster; | |
718e3744 | 1145 | |
d62a17ae | 1146 | ret = inet_aton(argv[idx_ipv4]->arg, &cluster); |
1147 | if (!ret) { | |
1148 | vty_out(vty, "%% Malformed bgp cluster identifier\n"); | |
1149 | return CMD_WARNING_CONFIG_FAILED; | |
1150 | } | |
718e3744 | 1151 | |
d62a17ae | 1152 | bgp_cluster_id_set(bgp, &cluster); |
1153 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1154 | |
d62a17ae | 1155 | return CMD_SUCCESS; |
718e3744 | 1156 | } |
1157 | ||
718e3744 | 1158 | DEFUN (no_bgp_cluster_id, |
1159 | no_bgp_cluster_id_cmd, | |
c7178fe7 | 1160 | "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]", |
718e3744 | 1161 | NO_STR |
1162 | BGP_STR | |
838758ac DW |
1163 | "Configure Route-Reflector Cluster-id\n" |
1164 | "Route-Reflector Cluster-id in IP address format\n" | |
1165 | "Route-Reflector Cluster-id as 32 bit quantity\n") | |
718e3744 | 1166 | { |
d62a17ae | 1167 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1168 | bgp_cluster_id_unset(bgp); | |
1169 | bgp_clear_star_soft_out(vty, bgp->name); | |
718e3744 | 1170 | |
d62a17ae | 1171 | return CMD_SUCCESS; |
718e3744 | 1172 | } |
1173 | ||
718e3744 | 1174 | DEFUN (bgp_confederation_identifier, |
1175 | bgp_confederation_identifier_cmd, | |
9ccf14f7 | 1176 | "bgp confederation identifier (1-4294967295)", |
718e3744 | 1177 | "BGP specific commands\n" |
1178 | "AS confederation parameters\n" | |
1179 | "AS number\n" | |
1180 | "Set routing domain confederation AS\n") | |
1181 | { | |
d62a17ae | 1182 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1183 | int idx_number = 3; | |
1184 | as_t as; | |
718e3744 | 1185 | |
d62a17ae | 1186 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 1187 | |
d62a17ae | 1188 | bgp_confederation_id_set(bgp, as); |
718e3744 | 1189 | |
d62a17ae | 1190 | return CMD_SUCCESS; |
718e3744 | 1191 | } |
1192 | ||
1193 | DEFUN (no_bgp_confederation_identifier, | |
1194 | no_bgp_confederation_identifier_cmd, | |
838758ac | 1195 | "no bgp confederation identifier [(1-4294967295)]", |
718e3744 | 1196 | NO_STR |
1197 | "BGP specific commands\n" | |
1198 | "AS confederation parameters\n" | |
3a2d747c QY |
1199 | "AS number\n" |
1200 | "Set routing domain confederation AS\n") | |
718e3744 | 1201 | { |
d62a17ae | 1202 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1203 | bgp_confederation_id_unset(bgp); | |
718e3744 | 1204 | |
d62a17ae | 1205 | return CMD_SUCCESS; |
718e3744 | 1206 | } |
1207 | ||
718e3744 | 1208 | DEFUN (bgp_confederation_peers, |
1209 | bgp_confederation_peers_cmd, | |
12dcf78e | 1210 | "bgp confederation peers (1-4294967295)...", |
718e3744 | 1211 | "BGP specific commands\n" |
1212 | "AS confederation parameters\n" | |
1213 | "Peer ASs in BGP confederation\n" | |
1214 | AS_STR) | |
1215 | { | |
d62a17ae | 1216 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1217 | int idx_asn = 3; | |
1218 | as_t as; | |
1219 | int i; | |
718e3744 | 1220 | |
d62a17ae | 1221 | for (i = idx_asn; i < argc; i++) { |
1222 | as = strtoul(argv[i]->arg, NULL, 10); | |
718e3744 | 1223 | |
d62a17ae | 1224 | if (bgp->as == as) { |
1225 | vty_out(vty, | |
1226 | "%% Local member-AS not allowed in confed peer list\n"); | |
1227 | continue; | |
1228 | } | |
718e3744 | 1229 | |
d62a17ae | 1230 | bgp_confederation_peers_add(bgp, as); |
1231 | } | |
1232 | return CMD_SUCCESS; | |
718e3744 | 1233 | } |
1234 | ||
1235 | DEFUN (no_bgp_confederation_peers, | |
1236 | no_bgp_confederation_peers_cmd, | |
e83a9414 | 1237 | "no bgp confederation peers (1-4294967295)...", |
718e3744 | 1238 | NO_STR |
1239 | "BGP specific commands\n" | |
1240 | "AS confederation parameters\n" | |
1241 | "Peer ASs in BGP confederation\n" | |
1242 | AS_STR) | |
1243 | { | |
d62a17ae | 1244 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1245 | int idx_asn = 4; | |
1246 | as_t as; | |
1247 | int i; | |
718e3744 | 1248 | |
d62a17ae | 1249 | for (i = idx_asn; i < argc; i++) { |
1250 | as = strtoul(argv[i]->arg, NULL, 10); | |
0b2aa3a0 | 1251 | |
d62a17ae | 1252 | bgp_confederation_peers_remove(bgp, as); |
1253 | } | |
1254 | return CMD_SUCCESS; | |
718e3744 | 1255 | } |
6b0655a2 | 1256 | |
5e242b0d DS |
1257 | /** |
1258 | * Central routine for maximum-paths configuration. | |
1259 | * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP | |
1260 | * @set: 1 for setting values, 0 for removing the max-paths config. | |
1261 | */ | |
d62a17ae | 1262 | static int bgp_maxpaths_config_vty(struct vty *vty, int peer_type, |
d7c0a89a | 1263 | const char *mpaths, uint16_t options, |
d62a17ae | 1264 | int set) |
1265 | { | |
1266 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
d7c0a89a | 1267 | uint16_t maxpaths = 0; |
d62a17ae | 1268 | int ret; |
1269 | afi_t afi; | |
1270 | safi_t safi; | |
1271 | ||
1272 | afi = bgp_node_afi(vty); | |
1273 | safi = bgp_node_safi(vty); | |
1274 | ||
1275 | if (set) { | |
1276 | maxpaths = strtol(mpaths, NULL, 10); | |
1277 | if (maxpaths > multipath_num) { | |
1278 | vty_out(vty, | |
1279 | "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d", | |
1280 | maxpaths, multipath_num); | |
1281 | return CMD_WARNING_CONFIG_FAILED; | |
1282 | } | |
1283 | ret = bgp_maximum_paths_set(bgp, afi, safi, peer_type, maxpaths, | |
1284 | options); | |
1285 | } else | |
1286 | ret = bgp_maximum_paths_unset(bgp, afi, safi, peer_type); | |
1287 | ||
1288 | if (ret < 0) { | |
1289 | vty_out(vty, | |
1290 | "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n", | |
1291 | (set == 1) ? "" : "un", | |
1292 | (peer_type == BGP_PEER_EBGP) ? "ebgp" : "ibgp", | |
1293 | maxpaths, afi, safi); | |
1294 | return CMD_WARNING_CONFIG_FAILED; | |
1295 | } | |
1296 | ||
1297 | bgp_recalculate_all_bestpaths(bgp); | |
1298 | ||
1299 | return CMD_SUCCESS; | |
165b5fff JB |
1300 | } |
1301 | ||
abc920f8 DS |
1302 | DEFUN (bgp_maxmed_admin, |
1303 | bgp_maxmed_admin_cmd, | |
1304 | "bgp max-med administrative ", | |
1305 | BGP_STR | |
1306 | "Advertise routes with max-med\n" | |
1307 | "Administratively applied, for an indefinite period\n") | |
1308 | { | |
d62a17ae | 1309 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1310 | |
d62a17ae | 1311 | bgp->v_maxmed_admin = 1; |
1312 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1313 | |
d62a17ae | 1314 | bgp_maxmed_update(bgp); |
abc920f8 | 1315 | |
d62a17ae | 1316 | return CMD_SUCCESS; |
abc920f8 DS |
1317 | } |
1318 | ||
1319 | DEFUN (bgp_maxmed_admin_medv, | |
1320 | bgp_maxmed_admin_medv_cmd, | |
4668a151 | 1321 | "bgp max-med administrative (0-4294967295)", |
abc920f8 DS |
1322 | BGP_STR |
1323 | "Advertise routes with max-med\n" | |
1324 | "Administratively applied, for an indefinite period\n" | |
1325 | "Max MED value to be used\n") | |
1326 | { | |
d62a17ae | 1327 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1328 | int idx_number = 3; | |
abc920f8 | 1329 | |
d62a17ae | 1330 | bgp->v_maxmed_admin = 1; |
1331 | bgp->maxmed_admin_value = strtoul(argv[idx_number]->arg, NULL, 10); | |
abc920f8 | 1332 | |
d62a17ae | 1333 | bgp_maxmed_update(bgp); |
abc920f8 | 1334 | |
d62a17ae | 1335 | return CMD_SUCCESS; |
abc920f8 DS |
1336 | } |
1337 | ||
1338 | DEFUN (no_bgp_maxmed_admin, | |
1339 | no_bgp_maxmed_admin_cmd, | |
4668a151 | 1340 | "no bgp max-med administrative [(0-4294967295)]", |
abc920f8 DS |
1341 | NO_STR |
1342 | BGP_STR | |
1343 | "Advertise routes with max-med\n" | |
838758ac DW |
1344 | "Administratively applied, for an indefinite period\n" |
1345 | "Max MED value to be used\n") | |
abc920f8 | 1346 | { |
d62a17ae | 1347 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1348 | bgp->v_maxmed_admin = BGP_MAXMED_ADMIN_UNCONFIGURED; | |
1349 | bgp->maxmed_admin_value = BGP_MAXMED_VALUE_DEFAULT; | |
1350 | bgp_maxmed_update(bgp); | |
abc920f8 | 1351 | |
d62a17ae | 1352 | return CMD_SUCCESS; |
abc920f8 DS |
1353 | } |
1354 | ||
abc920f8 DS |
1355 | DEFUN (bgp_maxmed_onstartup, |
1356 | bgp_maxmed_onstartup_cmd, | |
4668a151 | 1357 | "bgp max-med on-startup (5-86400) [(0-4294967295)]", |
abc920f8 DS |
1358 | BGP_STR |
1359 | "Advertise routes with max-med\n" | |
1360 | "Effective on a startup\n" | |
1361 | "Time (seconds) period for max-med\n" | |
1362 | "Max MED value to be used\n") | |
1363 | { | |
d62a17ae | 1364 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1365 | int idx = 0; | |
4668a151 | 1366 | |
d62a17ae | 1367 | argv_find(argv, argc, "(5-86400)", &idx); |
1368 | bgp->v_maxmed_onstartup = strtoul(argv[idx]->arg, NULL, 10); | |
1369 | if (argv_find(argv, argc, "(0-4294967295)", &idx)) | |
1370 | bgp->maxmed_onstartup_value = strtoul(argv[idx]->arg, NULL, 10); | |
1371 | else | |
1372 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
4668a151 | 1373 | |
d62a17ae | 1374 | bgp_maxmed_update(bgp); |
abc920f8 | 1375 | |
d62a17ae | 1376 | return CMD_SUCCESS; |
abc920f8 DS |
1377 | } |
1378 | ||
1379 | DEFUN (no_bgp_maxmed_onstartup, | |
1380 | no_bgp_maxmed_onstartup_cmd, | |
4668a151 | 1381 | "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]", |
abc920f8 DS |
1382 | NO_STR |
1383 | BGP_STR | |
1384 | "Advertise routes with max-med\n" | |
838758ac DW |
1385 | "Effective on a startup\n" |
1386 | "Time (seconds) period for max-med\n" | |
1387 | "Max MED value to be used\n") | |
abc920f8 | 1388 | { |
d62a17ae | 1389 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
abc920f8 | 1390 | |
d62a17ae | 1391 | /* Cancel max-med onstartup if its on */ |
1392 | if (bgp->t_maxmed_onstartup) { | |
1393 | THREAD_TIMER_OFF(bgp->t_maxmed_onstartup); | |
1394 | bgp->maxmed_onstartup_over = 1; | |
1395 | } | |
abc920f8 | 1396 | |
d62a17ae | 1397 | bgp->v_maxmed_onstartup = BGP_MAXMED_ONSTARTUP_UNCONFIGURED; |
1398 | bgp->maxmed_onstartup_value = BGP_MAXMED_VALUE_DEFAULT; | |
abc920f8 | 1399 | |
d62a17ae | 1400 | bgp_maxmed_update(bgp); |
abc920f8 | 1401 | |
d62a17ae | 1402 | return CMD_SUCCESS; |
abc920f8 DS |
1403 | } |
1404 | ||
d62a17ae | 1405 | static int bgp_update_delay_config_vty(struct vty *vty, const char *delay, |
1406 | const char *wait) | |
f188f2c4 | 1407 | { |
d62a17ae | 1408 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d7c0a89a QY |
1409 | uint16_t update_delay; |
1410 | uint16_t establish_wait; | |
f188f2c4 | 1411 | |
d62a17ae | 1412 | update_delay = strtoul(delay, NULL, 10); |
f188f2c4 | 1413 | |
d62a17ae | 1414 | if (!wait) /* update-delay <delay> */ |
1415 | { | |
1416 | bgp->v_update_delay = update_delay; | |
1417 | bgp->v_establish_wait = bgp->v_update_delay; | |
1418 | return CMD_SUCCESS; | |
1419 | } | |
f188f2c4 | 1420 | |
d62a17ae | 1421 | /* update-delay <delay> <establish-wait> */ |
1422 | establish_wait = atoi(wait); | |
1423 | if (update_delay < establish_wait) { | |
1424 | vty_out(vty, | |
1425 | "%%Failed: update-delay less than the establish-wait!\n"); | |
1426 | return CMD_WARNING_CONFIG_FAILED; | |
1427 | } | |
f188f2c4 | 1428 | |
d62a17ae | 1429 | bgp->v_update_delay = update_delay; |
1430 | bgp->v_establish_wait = establish_wait; | |
f188f2c4 | 1431 | |
d62a17ae | 1432 | return CMD_SUCCESS; |
f188f2c4 DS |
1433 | } |
1434 | ||
d62a17ae | 1435 | static int bgp_update_delay_deconfig_vty(struct vty *vty) |
f188f2c4 | 1436 | { |
d62a17ae | 1437 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
f188f2c4 | 1438 | |
d62a17ae | 1439 | bgp->v_update_delay = BGP_UPDATE_DELAY_DEF; |
1440 | bgp->v_establish_wait = bgp->v_update_delay; | |
f188f2c4 | 1441 | |
d62a17ae | 1442 | return CMD_SUCCESS; |
f188f2c4 DS |
1443 | } |
1444 | ||
2b791107 | 1445 | void bgp_config_write_update_delay(struct vty *vty, struct bgp *bgp) |
f188f2c4 | 1446 | { |
d62a17ae | 1447 | if (bgp->v_update_delay != BGP_UPDATE_DELAY_DEF) { |
1448 | vty_out(vty, " update-delay %d", bgp->v_update_delay); | |
1449 | if (bgp->v_update_delay != bgp->v_establish_wait) | |
1450 | vty_out(vty, " %d", bgp->v_establish_wait); | |
1451 | vty_out(vty, "\n"); | |
1452 | } | |
f188f2c4 DS |
1453 | } |
1454 | ||
1455 | ||
1456 | /* Update-delay configuration */ | |
1457 | DEFUN (bgp_update_delay, | |
1458 | bgp_update_delay_cmd, | |
6147e2c6 | 1459 | "update-delay (0-3600)", |
f188f2c4 DS |
1460 | "Force initial delay for best-path and updates\n" |
1461 | "Seconds\n") | |
1462 | { | |
d62a17ae | 1463 | int idx_number = 1; |
1464 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, NULL); | |
f188f2c4 DS |
1465 | } |
1466 | ||
1467 | DEFUN (bgp_update_delay_establish_wait, | |
1468 | bgp_update_delay_establish_wait_cmd, | |
6147e2c6 | 1469 | "update-delay (0-3600) (1-3600)", |
f188f2c4 DS |
1470 | "Force initial delay for best-path and updates\n" |
1471 | "Seconds\n" | |
f188f2c4 DS |
1472 | "Seconds\n") |
1473 | { | |
d62a17ae | 1474 | int idx_number = 1; |
1475 | int idx_number_2 = 2; | |
1476 | return bgp_update_delay_config_vty(vty, argv[idx_number]->arg, | |
1477 | argv[idx_number_2]->arg); | |
f188f2c4 DS |
1478 | } |
1479 | ||
1480 | /* Update-delay deconfiguration */ | |
1481 | DEFUN (no_bgp_update_delay, | |
1482 | no_bgp_update_delay_cmd, | |
838758ac DW |
1483 | "no update-delay [(0-3600) [(1-3600)]]", |
1484 | NO_STR | |
f188f2c4 | 1485 | "Force initial delay for best-path and updates\n" |
838758ac | 1486 | "Seconds\n" |
7111c1a0 | 1487 | "Seconds\n") |
f188f2c4 | 1488 | { |
d62a17ae | 1489 | return bgp_update_delay_deconfig_vty(vty); |
f188f2c4 DS |
1490 | } |
1491 | ||
5e242b0d | 1492 | |
d62a17ae | 1493 | static int bgp_wpkt_quanta_config_vty(struct vty *vty, const char *num, |
1494 | char set) | |
cb1faec9 | 1495 | { |
d62a17ae | 1496 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
cb1faec9 | 1497 | |
555e09d4 QY |
1498 | if (set) { |
1499 | uint32_t quanta = strtoul(num, NULL, 10); | |
1500 | atomic_store_explicit(&bgp->wpkt_quanta, quanta, | |
1501 | memory_order_relaxed); | |
1502 | } else { | |
1503 | atomic_store_explicit(&bgp->wpkt_quanta, BGP_WRITE_PACKET_MAX, | |
1504 | memory_order_relaxed); | |
1505 | } | |
1506 | ||
1507 | return CMD_SUCCESS; | |
1508 | } | |
1509 | ||
1510 | static int bgp_rpkt_quanta_config_vty(struct vty *vty, const char *num, | |
1511 | char set) | |
1512 | { | |
1513 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1514 | ||
1515 | if (set) { | |
1516 | uint32_t quanta = strtoul(num, NULL, 10); | |
1517 | atomic_store_explicit(&bgp->rpkt_quanta, quanta, | |
1518 | memory_order_relaxed); | |
1519 | } else { | |
1520 | atomic_store_explicit(&bgp->rpkt_quanta, BGP_READ_PACKET_MAX, | |
1521 | memory_order_relaxed); | |
1522 | } | |
cb1faec9 | 1523 | |
d62a17ae | 1524 | return CMD_SUCCESS; |
cb1faec9 DS |
1525 | } |
1526 | ||
2b791107 | 1527 | void bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp) |
cb1faec9 | 1528 | { |
555e09d4 QY |
1529 | uint32_t quanta = |
1530 | atomic_load_explicit(&bgp->wpkt_quanta, memory_order_relaxed); | |
1531 | if (quanta != BGP_WRITE_PACKET_MAX) | |
152456fe | 1532 | vty_out(vty, " write-quanta %d\n", quanta); |
cb1faec9 DS |
1533 | } |
1534 | ||
555e09d4 QY |
1535 | void bgp_config_write_rpkt_quanta(struct vty *vty, struct bgp *bgp) |
1536 | { | |
1537 | uint32_t quanta = | |
1538 | atomic_load_explicit(&bgp->rpkt_quanta, memory_order_relaxed); | |
1539 | if (quanta != BGP_READ_PACKET_MAX) | |
152456fe | 1540 | vty_out(vty, " read-quanta %d\n", quanta); |
555e09d4 | 1541 | } |
cb1faec9 | 1542 | |
555e09d4 | 1543 | /* Packet quanta configuration */ |
cb1faec9 DS |
1544 | DEFUN (bgp_wpkt_quanta, |
1545 | bgp_wpkt_quanta_cmd, | |
555e09d4 | 1546 | "write-quanta (1-10)", |
cb1faec9 DS |
1547 | "How many packets to write to peer socket per run\n" |
1548 | "Number of packets\n") | |
1549 | { | |
d62a17ae | 1550 | int idx_number = 1; |
1551 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
cb1faec9 DS |
1552 | } |
1553 | ||
cb1faec9 DS |
1554 | DEFUN (no_bgp_wpkt_quanta, |
1555 | no_bgp_wpkt_quanta_cmd, | |
555e09d4 | 1556 | "no write-quanta (1-10)", |
d7fa34c1 | 1557 | NO_STR |
555e09d4 | 1558 | "How many packets to write to peer socket per I/O cycle\n" |
cb1faec9 DS |
1559 | "Number of packets\n") |
1560 | { | |
d62a17ae | 1561 | int idx_number = 2; |
1562 | return bgp_wpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
cb1faec9 DS |
1563 | } |
1564 | ||
555e09d4 QY |
1565 | DEFUN (bgp_rpkt_quanta, |
1566 | bgp_rpkt_quanta_cmd, | |
1567 | "read-quanta (1-10)", | |
1568 | "How many packets to read from peer socket per I/O cycle\n" | |
1569 | "Number of packets\n") | |
1570 | { | |
1571 | int idx_number = 1; | |
1572 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 1); | |
1573 | } | |
1574 | ||
1575 | DEFUN (no_bgp_rpkt_quanta, | |
1576 | no_bgp_rpkt_quanta_cmd, | |
1577 | "no read-quanta (1-10)", | |
1578 | NO_STR | |
1579 | "How many packets to read from peer socket per I/O cycle\n" | |
1580 | "Number of packets\n") | |
1581 | { | |
1582 | int idx_number = 2; | |
1583 | return bgp_rpkt_quanta_config_vty(vty, argv[idx_number]->arg, 0); | |
1584 | } | |
1585 | ||
2b791107 | 1586 | void bgp_config_write_coalesce_time(struct vty *vty, struct bgp *bgp) |
3f9c7369 | 1587 | { |
37a333fe | 1588 | if (!bgp->heuristic_coalesce) |
d62a17ae | 1589 | vty_out(vty, " coalesce-time %u\n", bgp->coalesce_time); |
3f9c7369 DS |
1590 | } |
1591 | ||
1592 | ||
1593 | DEFUN (bgp_coalesce_time, | |
1594 | bgp_coalesce_time_cmd, | |
6147e2c6 | 1595 | "coalesce-time (0-4294967295)", |
3f9c7369 DS |
1596 | "Subgroup coalesce timer\n" |
1597 | "Subgroup coalesce timer value (in ms)\n") | |
1598 | { | |
d62a17ae | 1599 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1600 | |
d62a17ae | 1601 | int idx = 0; |
1602 | argv_find(argv, argc, "(0-4294967295)", &idx); | |
37a333fe | 1603 | bgp->heuristic_coalesce = false; |
d62a17ae | 1604 | bgp->coalesce_time = strtoul(argv[idx]->arg, NULL, 10); |
1605 | return CMD_SUCCESS; | |
3f9c7369 DS |
1606 | } |
1607 | ||
1608 | DEFUN (no_bgp_coalesce_time, | |
1609 | no_bgp_coalesce_time_cmd, | |
6147e2c6 | 1610 | "no coalesce-time (0-4294967295)", |
3a2d747c | 1611 | NO_STR |
3f9c7369 DS |
1612 | "Subgroup coalesce timer\n" |
1613 | "Subgroup coalesce timer value (in ms)\n") | |
1614 | { | |
d62a17ae | 1615 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
4668a151 | 1616 | |
37a333fe | 1617 | bgp->heuristic_coalesce = true; |
d62a17ae | 1618 | bgp->coalesce_time = BGP_DEFAULT_SUBGROUP_COALESCE_TIME; |
1619 | return CMD_SUCCESS; | |
3f9c7369 DS |
1620 | } |
1621 | ||
5e242b0d DS |
1622 | /* Maximum-paths configuration */ |
1623 | DEFUN (bgp_maxpaths, | |
1624 | bgp_maxpaths_cmd, | |
6319fd63 | 1625 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), |
5e242b0d DS |
1626 | "Forward packets over multiple paths\n" |
1627 | "Number of paths\n") | |
1628 | { | |
d62a17ae | 1629 | int idx_number = 1; |
1630 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, | |
1631 | argv[idx_number]->arg, 0, 1); | |
5e242b0d DS |
1632 | } |
1633 | ||
d62a17ae | 1634 | ALIAS_HIDDEN(bgp_maxpaths, bgp_maxpaths_hidden_cmd, |
1635 | "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1636 | "Forward packets over multiple paths\n" | |
1637 | "Number of paths\n") | |
596c17ba | 1638 | |
165b5fff JB |
1639 | DEFUN (bgp_maxpaths_ibgp, |
1640 | bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1641 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), |
165b5fff JB |
1642 | "Forward packets over multiple paths\n" |
1643 | "iBGP-multipath\n" | |
1644 | "Number of paths\n") | |
1645 | { | |
d62a17ae | 1646 | int idx_number = 2; |
1647 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, | |
1648 | argv[idx_number]->arg, 0, 1); | |
5e242b0d | 1649 | } |
165b5fff | 1650 | |
d62a17ae | 1651 | ALIAS_HIDDEN(bgp_maxpaths_ibgp, bgp_maxpaths_ibgp_hidden_cmd, |
1652 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM), | |
1653 | "Forward packets over multiple paths\n" | |
1654 | "iBGP-multipath\n" | |
1655 | "Number of paths\n") | |
596c17ba | 1656 | |
5e242b0d DS |
1657 | DEFUN (bgp_maxpaths_ibgp_cluster, |
1658 | bgp_maxpaths_ibgp_cluster_cmd, | |
6319fd63 | 1659 | "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM) " equal-cluster-length", |
5e242b0d DS |
1660 | "Forward packets over multiple paths\n" |
1661 | "iBGP-multipath\n" | |
1662 | "Number of paths\n" | |
1663 | "Match the cluster length\n") | |
1664 | { | |
d62a17ae | 1665 | int idx_number = 2; |
1666 | return bgp_maxpaths_config_vty( | |
1667 | vty, BGP_PEER_IBGP, argv[idx_number]->arg, | |
1668 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN, 1); | |
165b5fff JB |
1669 | } |
1670 | ||
d62a17ae | 1671 | ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster, bgp_maxpaths_ibgp_cluster_hidden_cmd, |
1672 | "maximum-paths ibgp " CMD_RANGE_STR( | |
1673 | 1, MULTIPATH_NUM) " equal-cluster-length", | |
1674 | "Forward packets over multiple paths\n" | |
1675 | "iBGP-multipath\n" | |
1676 | "Number of paths\n" | |
1677 | "Match the cluster length\n") | |
596c17ba | 1678 | |
165b5fff JB |
1679 | DEFUN (no_bgp_maxpaths, |
1680 | no_bgp_maxpaths_cmd, | |
6319fd63 | 1681 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", |
165b5fff JB |
1682 | NO_STR |
1683 | "Forward packets over multiple paths\n" | |
1684 | "Number of paths\n") | |
1685 | { | |
d62a17ae | 1686 | return bgp_maxpaths_config_vty(vty, BGP_PEER_EBGP, NULL, 0, 0); |
165b5fff JB |
1687 | } |
1688 | ||
d62a17ae | 1689 | ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, |
996c9314 | 1690 | "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR |
d62a17ae | 1691 | "Forward packets over multiple paths\n" |
1692 | "Number of paths\n") | |
596c17ba | 1693 | |
165b5fff JB |
1694 | DEFUN (no_bgp_maxpaths_ibgp, |
1695 | no_bgp_maxpaths_ibgp_cmd, | |
6319fd63 | 1696 | "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM) " [equal-cluster-length]]", |
165b5fff JB |
1697 | NO_STR |
1698 | "Forward packets over multiple paths\n" | |
1699 | "iBGP-multipath\n" | |
838758ac DW |
1700 | "Number of paths\n" |
1701 | "Match the cluster length\n") | |
165b5fff | 1702 | { |
d62a17ae | 1703 | return bgp_maxpaths_config_vty(vty, BGP_PEER_IBGP, NULL, 0, 0); |
165b5fff JB |
1704 | } |
1705 | ||
d62a17ae | 1706 | ALIAS_HIDDEN(no_bgp_maxpaths_ibgp, no_bgp_maxpaths_ibgp_hidden_cmd, |
1707 | "no maximum-paths ibgp [" CMD_RANGE_STR( | |
1708 | 1, MULTIPATH_NUM) " [equal-cluster-length]]", | |
1709 | NO_STR | |
1710 | "Forward packets over multiple paths\n" | |
1711 | "iBGP-multipath\n" | |
1712 | "Number of paths\n" | |
1713 | "Match the cluster length\n") | |
596c17ba | 1714 | |
2b791107 | 1715 | void bgp_config_write_maxpaths(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 1716 | safi_t safi) |
165b5fff | 1717 | { |
d62a17ae | 1718 | if (bgp->maxpaths[afi][safi].maxpaths_ebgp != MULTIPATH_NUM) { |
d62a17ae | 1719 | vty_out(vty, " maximum-paths %d\n", |
1720 | bgp->maxpaths[afi][safi].maxpaths_ebgp); | |
1721 | } | |
165b5fff | 1722 | |
d62a17ae | 1723 | if (bgp->maxpaths[afi][safi].maxpaths_ibgp != MULTIPATH_NUM) { |
d62a17ae | 1724 | vty_out(vty, " maximum-paths ibgp %d", |
1725 | bgp->maxpaths[afi][safi].maxpaths_ibgp); | |
1726 | if (CHECK_FLAG(bgp->maxpaths[afi][safi].ibgp_flags, | |
1727 | BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) | |
1728 | vty_out(vty, " equal-cluster-length"); | |
1729 | vty_out(vty, "\n"); | |
1730 | } | |
165b5fff | 1731 | } |
6b0655a2 | 1732 | |
718e3744 | 1733 | /* BGP timers. */ |
1734 | ||
1735 | DEFUN (bgp_timers, | |
1736 | bgp_timers_cmd, | |
6147e2c6 | 1737 | "timers bgp (0-65535) (0-65535)", |
718e3744 | 1738 | "Adjust routing timers\n" |
1739 | "BGP timers\n" | |
1740 | "Keepalive interval\n" | |
1741 | "Holdtime\n") | |
1742 | { | |
d62a17ae | 1743 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1744 | int idx_number = 2; | |
1745 | int idx_number_2 = 3; | |
1746 | unsigned long keepalive = 0; | |
1747 | unsigned long holdtime = 0; | |
718e3744 | 1748 | |
d62a17ae | 1749 | keepalive = strtoul(argv[idx_number]->arg, NULL, 10); |
1750 | holdtime = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
718e3744 | 1751 | |
d62a17ae | 1752 | /* Holdtime value check. */ |
1753 | if (holdtime < 3 && holdtime != 0) { | |
1754 | vty_out(vty, | |
1755 | "%% hold time value must be either 0 or greater than 3\n"); | |
1756 | return CMD_WARNING_CONFIG_FAILED; | |
1757 | } | |
718e3744 | 1758 | |
d62a17ae | 1759 | bgp_timers_set(bgp, keepalive, holdtime); |
718e3744 | 1760 | |
d62a17ae | 1761 | return CMD_SUCCESS; |
718e3744 | 1762 | } |
1763 | ||
1764 | DEFUN (no_bgp_timers, | |
1765 | no_bgp_timers_cmd, | |
838758ac | 1766 | "no timers bgp [(0-65535) (0-65535)]", |
718e3744 | 1767 | NO_STR |
1768 | "Adjust routing timers\n" | |
838758ac DW |
1769 | "BGP timers\n" |
1770 | "Keepalive interval\n" | |
1771 | "Holdtime\n") | |
718e3744 | 1772 | { |
d62a17ae | 1773 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1774 | bgp_timers_unset(bgp); | |
718e3744 | 1775 | |
d62a17ae | 1776 | return CMD_SUCCESS; |
718e3744 | 1777 | } |
1778 | ||
6b0655a2 | 1779 | |
718e3744 | 1780 | DEFUN (bgp_client_to_client_reflection, |
1781 | bgp_client_to_client_reflection_cmd, | |
1782 | "bgp client-to-client reflection", | |
1783 | "BGP specific commands\n" | |
1784 | "Configure client to client route reflection\n" | |
1785 | "reflection of routes allowed\n") | |
1786 | { | |
d62a17ae | 1787 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1788 | bgp_flag_unset(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1789 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1790 | |
d62a17ae | 1791 | return CMD_SUCCESS; |
718e3744 | 1792 | } |
1793 | ||
1794 | DEFUN (no_bgp_client_to_client_reflection, | |
1795 | no_bgp_client_to_client_reflection_cmd, | |
1796 | "no bgp client-to-client reflection", | |
1797 | NO_STR | |
1798 | "BGP specific commands\n" | |
1799 | "Configure client to client route reflection\n" | |
1800 | "reflection of routes allowed\n") | |
1801 | { | |
d62a17ae | 1802 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1803 | bgp_flag_set(bgp, BGP_FLAG_NO_CLIENT_TO_CLIENT); | |
1804 | bgp_clear_star_soft_out(vty, bgp->name); | |
7aafcaca | 1805 | |
d62a17ae | 1806 | return CMD_SUCCESS; |
718e3744 | 1807 | } |
1808 | ||
1809 | /* "bgp always-compare-med" configuration. */ | |
1810 | DEFUN (bgp_always_compare_med, | |
1811 | bgp_always_compare_med_cmd, | |
1812 | "bgp always-compare-med", | |
1813 | "BGP specific commands\n" | |
1814 | "Allow comparing MED from different neighbors\n") | |
1815 | { | |
d62a17ae | 1816 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1817 | bgp_flag_set(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1818 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1819 | |
d62a17ae | 1820 | return CMD_SUCCESS; |
718e3744 | 1821 | } |
1822 | ||
1823 | DEFUN (no_bgp_always_compare_med, | |
1824 | no_bgp_always_compare_med_cmd, | |
1825 | "no bgp always-compare-med", | |
1826 | NO_STR | |
1827 | "BGP specific commands\n" | |
1828 | "Allow comparing MED from different neighbors\n") | |
1829 | { | |
d62a17ae | 1830 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1831 | bgp_flag_unset(bgp, BGP_FLAG_ALWAYS_COMPARE_MED); | |
1832 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 1833 | |
d62a17ae | 1834 | return CMD_SUCCESS; |
718e3744 | 1835 | } |
6b0655a2 | 1836 | |
9dac9fc8 DA |
1837 | |
1838 | DEFUN(bgp_ebgp_requires_policy, bgp_ebgp_requires_policy_cmd, | |
1839 | "bgp ebgp-requires-policy", | |
1840 | "BGP specific commands\n" | |
1841 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
1842 | { | |
1843 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1844 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_ENABLED; | |
1845 | return CMD_SUCCESS; | |
1846 | } | |
1847 | ||
1848 | DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd, | |
1849 | "no bgp ebgp-requires-policy", | |
1850 | NO_STR | |
1851 | "BGP specific commands\n" | |
1852 | "Require in and out policy for eBGP peers (RFC8212)\n") | |
1853 | { | |
1854 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
1855 | bgp->ebgp_requires_policy = DEFAULT_EBGP_POLICY_DISABLED; | |
1856 | return CMD_SUCCESS; | |
1857 | } | |
1858 | ||
1859 | ||
718e3744 | 1860 | /* "bgp deterministic-med" configuration. */ |
1861 | DEFUN (bgp_deterministic_med, | |
1862 | bgp_deterministic_med_cmd, | |
1863 | "bgp deterministic-med", | |
1864 | "BGP specific commands\n" | |
1865 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1866 | { | |
d62a17ae | 1867 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1475ac87 | 1868 | |
d62a17ae | 1869 | if (!bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { |
1870 | bgp_flag_set(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1871 | bgp_recalculate_all_bestpaths(bgp); | |
1872 | } | |
7aafcaca | 1873 | |
d62a17ae | 1874 | return CMD_SUCCESS; |
718e3744 | 1875 | } |
1876 | ||
1877 | DEFUN (no_bgp_deterministic_med, | |
1878 | no_bgp_deterministic_med_cmd, | |
1879 | "no bgp deterministic-med", | |
1880 | NO_STR | |
1881 | "BGP specific commands\n" | |
1882 | "Pick the best-MED path among paths advertised from the neighboring AS\n") | |
1883 | { | |
d62a17ae | 1884 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1885 | int bestpath_per_as_used; | |
1886 | afi_t afi; | |
1887 | safi_t safi; | |
1888 | struct peer *peer; | |
1889 | struct listnode *node, *nnode; | |
1890 | ||
1891 | if (bgp_flag_check(bgp, BGP_FLAG_DETERMINISTIC_MED)) { | |
1892 | bestpath_per_as_used = 0; | |
1893 | ||
1894 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
05c7a1cc | 1895 | FOREACH_AFI_SAFI (afi, safi) |
dcc68b5e MS |
1896 | if (bgp_addpath_dmed_required( |
1897 | peer->addpath_type[afi][safi])) { | |
05c7a1cc QY |
1898 | bestpath_per_as_used = 1; |
1899 | break; | |
1900 | } | |
d62a17ae | 1901 | |
1902 | if (bestpath_per_as_used) | |
1903 | break; | |
1904 | } | |
1905 | ||
1906 | if (bestpath_per_as_used) { | |
1907 | vty_out(vty, | |
1908 | "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n"); | |
1909 | return CMD_WARNING_CONFIG_FAILED; | |
1910 | } else { | |
1911 | bgp_flag_unset(bgp, BGP_FLAG_DETERMINISTIC_MED); | |
1912 | bgp_recalculate_all_bestpaths(bgp); | |
1913 | } | |
1914 | } | |
1915 | ||
1916 | return CMD_SUCCESS; | |
718e3744 | 1917 | } |
538621f2 | 1918 | |
1919 | /* "bgp graceful-restart" configuration. */ | |
1920 | DEFUN (bgp_graceful_restart, | |
1921 | bgp_graceful_restart_cmd, | |
1922 | "bgp graceful-restart", | |
1923 | "BGP specific commands\n" | |
1924 | "Graceful restart capability parameters\n") | |
1925 | { | |
d62a17ae | 1926 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1927 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1928 | return CMD_SUCCESS; | |
538621f2 | 1929 | } |
1930 | ||
1931 | DEFUN (no_bgp_graceful_restart, | |
1932 | no_bgp_graceful_restart_cmd, | |
1933 | "no bgp graceful-restart", | |
1934 | NO_STR | |
1935 | "BGP specific commands\n" | |
1936 | "Graceful restart capability parameters\n") | |
1937 | { | |
d62a17ae | 1938 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1939 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_RESTART); | |
1940 | return CMD_SUCCESS; | |
538621f2 | 1941 | } |
1942 | ||
93406d87 | 1943 | DEFUN (bgp_graceful_restart_stalepath_time, |
1944 | bgp_graceful_restart_stalepath_time_cmd, | |
c1779b7d | 1945 | "bgp graceful-restart stalepath-time (1-4095)", |
93406d87 | 1946 | "BGP specific commands\n" |
1947 | "Graceful restart capability parameters\n" | |
1948 | "Set the max time to hold onto restarting peer's stale paths\n" | |
1949 | "Delay value (seconds)\n") | |
1950 | { | |
d62a17ae | 1951 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1952 | int idx_number = 3; | |
d7c0a89a | 1953 | uint32_t stalepath; |
93406d87 | 1954 | |
d62a17ae | 1955 | stalepath = strtoul(argv[idx_number]->arg, NULL, 10); |
1956 | bgp->stalepath_time = stalepath; | |
1957 | return CMD_SUCCESS; | |
93406d87 | 1958 | } |
1959 | ||
eb6f1b41 PG |
1960 | DEFUN (bgp_graceful_restart_restart_time, |
1961 | bgp_graceful_restart_restart_time_cmd, | |
c72d0314 | 1962 | "bgp graceful-restart restart-time (1-4095)", |
eb6f1b41 PG |
1963 | "BGP specific commands\n" |
1964 | "Graceful restart capability parameters\n" | |
1965 | "Set the time to wait to delete stale routes before a BGP open message is received\n" | |
1966 | "Delay value (seconds)\n") | |
1967 | { | |
d62a17ae | 1968 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
1969 | int idx_number = 3; | |
d7c0a89a | 1970 | uint32_t restart; |
eb6f1b41 | 1971 | |
d62a17ae | 1972 | restart = strtoul(argv[idx_number]->arg, NULL, 10); |
1973 | bgp->restart_time = restart; | |
1974 | return CMD_SUCCESS; | |
eb6f1b41 PG |
1975 | } |
1976 | ||
93406d87 | 1977 | DEFUN (no_bgp_graceful_restart_stalepath_time, |
1978 | no_bgp_graceful_restart_stalepath_time_cmd, | |
c1779b7d | 1979 | "no bgp graceful-restart stalepath-time [(1-4095)]", |
93406d87 | 1980 | NO_STR |
1981 | "BGP specific commands\n" | |
1982 | "Graceful restart capability parameters\n" | |
838758ac DW |
1983 | "Set the max time to hold onto restarting peer's stale paths\n" |
1984 | "Delay value (seconds)\n") | |
93406d87 | 1985 | { |
d62a17ae | 1986 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
93406d87 | 1987 | |
d62a17ae | 1988 | bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; |
1989 | return CMD_SUCCESS; | |
93406d87 | 1990 | } |
1991 | ||
eb6f1b41 PG |
1992 | DEFUN (no_bgp_graceful_restart_restart_time, |
1993 | no_bgp_graceful_restart_restart_time_cmd, | |
c72d0314 | 1994 | "no bgp graceful-restart restart-time [(1-4095)]", |
eb6f1b41 PG |
1995 | NO_STR |
1996 | "BGP specific commands\n" | |
1997 | "Graceful restart capability parameters\n" | |
838758ac DW |
1998 | "Set the time to wait to delete stale routes before a BGP open message is received\n" |
1999 | "Delay value (seconds)\n") | |
eb6f1b41 | 2000 | { |
d62a17ae | 2001 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
eb6f1b41 | 2002 | |
d62a17ae | 2003 | bgp->restart_time = BGP_DEFAULT_RESTART_TIME; |
2004 | return CMD_SUCCESS; | |
eb6f1b41 PG |
2005 | } |
2006 | ||
43fc21b3 JC |
2007 | DEFUN (bgp_graceful_restart_preserve_fw, |
2008 | bgp_graceful_restart_preserve_fw_cmd, | |
2009 | "bgp graceful-restart preserve-fw-state", | |
2010 | "BGP specific commands\n" | |
2011 | "Graceful restart capability parameters\n" | |
2012 | "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2013 | { | |
d62a17ae | 2014 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2015 | bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2016 | return CMD_SUCCESS; | |
43fc21b3 JC |
2017 | } |
2018 | ||
2019 | DEFUN (no_bgp_graceful_restart_preserve_fw, | |
2020 | no_bgp_graceful_restart_preserve_fw_cmd, | |
2021 | "no bgp graceful-restart preserve-fw-state", | |
2022 | NO_STR | |
2023 | "BGP specific commands\n" | |
2024 | "Graceful restart capability parameters\n" | |
2025 | "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") | |
2026 | { | |
d62a17ae | 2027 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2028 | bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); | |
2029 | return CMD_SUCCESS; | |
43fc21b3 JC |
2030 | } |
2031 | ||
7f323236 DW |
2032 | /* "bgp graceful-shutdown" configuration */ |
2033 | DEFUN (bgp_graceful_shutdown, | |
2034 | bgp_graceful_shutdown_cmd, | |
2035 | "bgp graceful-shutdown", | |
2036 | BGP_STR | |
2037 | "Graceful shutdown parameters\n") | |
2038 | { | |
2039 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2040 | ||
2041 | if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2042 | bgp_flag_set(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2043 | bgp_static_redo_import_check(bgp); | |
2044 | bgp_redistribute_redo(bgp); | |
2045 | bgp_clear_star_soft_out(vty, bgp->name); | |
2046 | bgp_clear_star_soft_in(vty, bgp->name); | |
2047 | } | |
2048 | ||
2049 | return CMD_SUCCESS; | |
2050 | } | |
2051 | ||
2052 | DEFUN (no_bgp_graceful_shutdown, | |
2053 | no_bgp_graceful_shutdown_cmd, | |
2054 | "no bgp graceful-shutdown", | |
2055 | NO_STR | |
2056 | BGP_STR | |
2057 | "Graceful shutdown parameters\n") | |
2058 | { | |
2059 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2060 | ||
2061 | if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { | |
2062 | bgp_flag_unset(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN); | |
2063 | bgp_static_redo_import_check(bgp); | |
2064 | bgp_redistribute_redo(bgp); | |
2065 | bgp_clear_star_soft_out(vty, bgp->name); | |
2066 | bgp_clear_star_soft_in(vty, bgp->name); | |
2067 | } | |
2068 | ||
2069 | return CMD_SUCCESS; | |
2070 | } | |
2071 | ||
718e3744 | 2072 | /* "bgp fast-external-failover" configuration. */ |
2073 | DEFUN (bgp_fast_external_failover, | |
2074 | bgp_fast_external_failover_cmd, | |
2075 | "bgp fast-external-failover", | |
2076 | BGP_STR | |
2077 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2078 | { | |
d62a17ae | 2079 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2080 | bgp_flag_unset(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2081 | return CMD_SUCCESS; | |
718e3744 | 2082 | } |
2083 | ||
2084 | DEFUN (no_bgp_fast_external_failover, | |
2085 | no_bgp_fast_external_failover_cmd, | |
2086 | "no bgp fast-external-failover", | |
2087 | NO_STR | |
2088 | BGP_STR | |
2089 | "Immediately reset session if a link to a directly connected external peer goes down\n") | |
2090 | { | |
d62a17ae | 2091 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2092 | bgp_flag_set(bgp, BGP_FLAG_NO_FAST_EXT_FAILOVER); | |
2093 | return CMD_SUCCESS; | |
718e3744 | 2094 | } |
6b0655a2 | 2095 | |
718e3744 | 2096 | /* "bgp bestpath compare-routerid" configuration. */ |
2097 | DEFUN (bgp_bestpath_compare_router_id, | |
2098 | bgp_bestpath_compare_router_id_cmd, | |
2099 | "bgp bestpath compare-routerid", | |
2100 | "BGP specific commands\n" | |
2101 | "Change the default bestpath selection\n" | |
2102 | "Compare router-id for identical EBGP paths\n") | |
2103 | { | |
d62a17ae | 2104 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2105 | bgp_flag_set(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2106 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2107 | |
d62a17ae | 2108 | return CMD_SUCCESS; |
718e3744 | 2109 | } |
2110 | ||
2111 | DEFUN (no_bgp_bestpath_compare_router_id, | |
2112 | no_bgp_bestpath_compare_router_id_cmd, | |
2113 | "no bgp bestpath compare-routerid", | |
2114 | NO_STR | |
2115 | "BGP specific commands\n" | |
2116 | "Change the default bestpath selection\n" | |
2117 | "Compare router-id for identical EBGP paths\n") | |
2118 | { | |
d62a17ae | 2119 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2120 | bgp_flag_unset(bgp, BGP_FLAG_COMPARE_ROUTER_ID); | |
2121 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2122 | |
d62a17ae | 2123 | return CMD_SUCCESS; |
718e3744 | 2124 | } |
6b0655a2 | 2125 | |
718e3744 | 2126 | /* "bgp bestpath as-path ignore" configuration. */ |
2127 | DEFUN (bgp_bestpath_aspath_ignore, | |
2128 | bgp_bestpath_aspath_ignore_cmd, | |
2129 | "bgp bestpath as-path ignore", | |
2130 | "BGP specific commands\n" | |
2131 | "Change the default bestpath selection\n" | |
2132 | "AS-path attribute\n" | |
2133 | "Ignore as-path length in selecting a route\n") | |
2134 | { | |
d62a17ae | 2135 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2136 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2137 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2138 | |
d62a17ae | 2139 | return CMD_SUCCESS; |
718e3744 | 2140 | } |
2141 | ||
2142 | DEFUN (no_bgp_bestpath_aspath_ignore, | |
2143 | no_bgp_bestpath_aspath_ignore_cmd, | |
2144 | "no bgp bestpath as-path ignore", | |
2145 | NO_STR | |
2146 | "BGP specific commands\n" | |
2147 | "Change the default bestpath selection\n" | |
2148 | "AS-path attribute\n" | |
2149 | "Ignore as-path length in selecting a route\n") | |
2150 | { | |
d62a17ae | 2151 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2152 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_IGNORE); | |
2153 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2154 | |
d62a17ae | 2155 | return CMD_SUCCESS; |
718e3744 | 2156 | } |
6b0655a2 | 2157 | |
6811845b | 2158 | /* "bgp bestpath as-path confed" configuration. */ |
2159 | DEFUN (bgp_bestpath_aspath_confed, | |
2160 | bgp_bestpath_aspath_confed_cmd, | |
2161 | "bgp bestpath as-path confed", | |
2162 | "BGP specific commands\n" | |
2163 | "Change the default bestpath selection\n" | |
2164 | "AS-path attribute\n" | |
2165 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2166 | { | |
d62a17ae | 2167 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2168 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_CONFED); | |
2169 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2170 | |
d62a17ae | 2171 | return CMD_SUCCESS; |
6811845b | 2172 | } |
2173 | ||
2174 | DEFUN (no_bgp_bestpath_aspath_confed, | |
2175 | no_bgp_bestpath_aspath_confed_cmd, | |
2176 | "no bgp bestpath as-path confed", | |
2177 | NO_STR | |
2178 | "BGP specific commands\n" | |
2179 | "Change the default bestpath selection\n" | |
2180 | "AS-path attribute\n" | |
2181 | "Compare path lengths including confederation sets & sequences in selecting a route\n") | |
2182 | { | |
d62a17ae | 2183 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2184 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_CONFED); | |
2185 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2186 | |
d62a17ae | 2187 | return CMD_SUCCESS; |
6811845b | 2188 | } |
6b0655a2 | 2189 | |
2fdd455c PM |
2190 | /* "bgp bestpath as-path multipath-relax" configuration. */ |
2191 | DEFUN (bgp_bestpath_aspath_multipath_relax, | |
2192 | bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2193 | "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2194 | "BGP specific commands\n" |
2195 | "Change the default bestpath selection\n" | |
2196 | "AS-path attribute\n" | |
2197 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2198 | "Generate an AS_SET\n" |
16fc1eec DS |
2199 | "Do not generate an AS_SET\n") |
2200 | { | |
d62a17ae | 2201 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2202 | int idx = 0; | |
2203 | bgp_flag_set(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
219178b6 | 2204 | |
d62a17ae | 2205 | /* no-as-set is now the default behavior so we can silently |
2206 | * ignore it */ | |
2207 | if (argv_find(argv, argc, "as-set", &idx)) | |
2208 | bgp_flag_set(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2209 | else | |
2210 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
219178b6 | 2211 | |
d62a17ae | 2212 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2213 | |
d62a17ae | 2214 | return CMD_SUCCESS; |
16fc1eec DS |
2215 | } |
2216 | ||
219178b6 DW |
2217 | DEFUN (no_bgp_bestpath_aspath_multipath_relax, |
2218 | no_bgp_bestpath_aspath_multipath_relax_cmd, | |
c7178fe7 | 2219 | "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]", |
16fc1eec DS |
2220 | NO_STR |
2221 | "BGP specific commands\n" | |
2222 | "Change the default bestpath selection\n" | |
2223 | "AS-path attribute\n" | |
2224 | "Allow load sharing across routes that have different AS paths (but same length)\n" | |
219178b6 | 2225 | "Generate an AS_SET\n" |
16fc1eec DS |
2226 | "Do not generate an AS_SET\n") |
2227 | { | |
d62a17ae | 2228 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2229 | bgp_flag_unset(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX); | |
2230 | bgp_flag_unset(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET); | |
2231 | bgp_recalculate_all_bestpaths(bgp); | |
7aafcaca | 2232 | |
d62a17ae | 2233 | return CMD_SUCCESS; |
2fdd455c | 2234 | } |
6b0655a2 | 2235 | |
848973c7 | 2236 | /* "bgp log-neighbor-changes" configuration. */ |
2237 | DEFUN (bgp_log_neighbor_changes, | |
2238 | bgp_log_neighbor_changes_cmd, | |
2239 | "bgp log-neighbor-changes", | |
2240 | "BGP specific commands\n" | |
2241 | "Log neighbor up/down and reset reason\n") | |
2242 | { | |
d62a17ae | 2243 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2244 | bgp_flag_set(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2245 | return CMD_SUCCESS; | |
848973c7 | 2246 | } |
2247 | ||
2248 | DEFUN (no_bgp_log_neighbor_changes, | |
2249 | no_bgp_log_neighbor_changes_cmd, | |
2250 | "no bgp log-neighbor-changes", | |
2251 | NO_STR | |
2252 | "BGP specific commands\n" | |
2253 | "Log neighbor up/down and reset reason\n") | |
2254 | { | |
d62a17ae | 2255 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2256 | bgp_flag_unset(bgp, BGP_FLAG_LOG_NEIGHBOR_CHANGES); | |
2257 | return CMD_SUCCESS; | |
848973c7 | 2258 | } |
6b0655a2 | 2259 | |
718e3744 | 2260 | /* "bgp bestpath med" configuration. */ |
2261 | DEFUN (bgp_bestpath_med, | |
2262 | bgp_bestpath_med_cmd, | |
2d8c1a4d | 2263 | "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2264 | "BGP specific commands\n" |
2265 | "Change the default bestpath selection\n" | |
2266 | "MED attribute\n" | |
2267 | "Compare MED among confederation paths\n" | |
838758ac DW |
2268 | "Treat missing MED as the least preferred one\n" |
2269 | "Treat missing MED as the least preferred one\n" | |
2270 | "Compare MED among confederation paths\n") | |
718e3744 | 2271 | { |
d62a17ae | 2272 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
6cbd1915 | 2273 | |
d62a17ae | 2274 | int idx = 0; |
2275 | if (argv_find(argv, argc, "confed", &idx)) | |
2276 | bgp_flag_set(bgp, BGP_FLAG_MED_CONFED); | |
2277 | idx = 0; | |
2278 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2279 | bgp_flag_set(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
e52702f2 | 2280 | |
d62a17ae | 2281 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2282 | |
d62a17ae | 2283 | return CMD_SUCCESS; |
718e3744 | 2284 | } |
2285 | ||
718e3744 | 2286 | DEFUN (no_bgp_bestpath_med, |
2287 | no_bgp_bestpath_med_cmd, | |
2d8c1a4d | 2288 | "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>", |
718e3744 | 2289 | NO_STR |
2290 | "BGP specific commands\n" | |
2291 | "Change the default bestpath selection\n" | |
2292 | "MED attribute\n" | |
2293 | "Compare MED among confederation paths\n" | |
3a2d747c QY |
2294 | "Treat missing MED as the least preferred one\n" |
2295 | "Treat missing MED as the least preferred one\n" | |
2296 | "Compare MED among confederation paths\n") | |
718e3744 | 2297 | { |
d62a17ae | 2298 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
e52702f2 | 2299 | |
d62a17ae | 2300 | int idx = 0; |
2301 | if (argv_find(argv, argc, "confed", &idx)) | |
2302 | bgp_flag_unset(bgp, BGP_FLAG_MED_CONFED); | |
2303 | idx = 0; | |
2304 | if (argv_find(argv, argc, "missing-as-worst", &idx)) | |
2305 | bgp_flag_unset(bgp, BGP_FLAG_MED_MISSING_AS_WORST); | |
718e3744 | 2306 | |
d62a17ae | 2307 | bgp_recalculate_all_bestpaths(bgp); |
7aafcaca | 2308 | |
d62a17ae | 2309 | return CMD_SUCCESS; |
718e3744 | 2310 | } |
2311 | ||
718e3744 | 2312 | /* "no bgp default ipv4-unicast". */ |
2313 | DEFUN (no_bgp_default_ipv4_unicast, | |
2314 | no_bgp_default_ipv4_unicast_cmd, | |
2315 | "no bgp default ipv4-unicast", | |
2316 | NO_STR | |
2317 | "BGP specific commands\n" | |
2318 | "Configure BGP defaults\n" | |
2319 | "Activate ipv4-unicast for a peer by default\n") | |
2320 | { | |
d62a17ae | 2321 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2322 | bgp_flag_set(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2323 | return CMD_SUCCESS; | |
718e3744 | 2324 | } |
2325 | ||
2326 | DEFUN (bgp_default_ipv4_unicast, | |
2327 | bgp_default_ipv4_unicast_cmd, | |
2328 | "bgp default ipv4-unicast", | |
2329 | "BGP specific commands\n" | |
2330 | "Configure BGP defaults\n" | |
2331 | "Activate ipv4-unicast for a peer by default\n") | |
2332 | { | |
d62a17ae | 2333 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2334 | bgp_flag_unset(bgp, BGP_FLAG_NO_DEFAULT_IPV4); | |
2335 | return CMD_SUCCESS; | |
718e3744 | 2336 | } |
6b0655a2 | 2337 | |
04b6bdc0 DW |
2338 | /* Display hostname in certain command outputs */ |
2339 | DEFUN (bgp_default_show_hostname, | |
2340 | bgp_default_show_hostname_cmd, | |
2341 | "bgp default show-hostname", | |
2342 | "BGP specific commands\n" | |
2343 | "Configure BGP defaults\n" | |
0437e105 | 2344 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2345 | { |
d62a17ae | 2346 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2347 | bgp_flag_set(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2348 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2349 | } |
2350 | ||
2351 | DEFUN (no_bgp_default_show_hostname, | |
2352 | no_bgp_default_show_hostname_cmd, | |
2353 | "no bgp default show-hostname", | |
2354 | NO_STR | |
2355 | "BGP specific commands\n" | |
2356 | "Configure BGP defaults\n" | |
0437e105 | 2357 | "Show hostname in certain command outputs\n") |
04b6bdc0 | 2358 | { |
d62a17ae | 2359 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2360 | bgp_flag_unset(bgp, BGP_FLAG_SHOW_HOSTNAME); | |
2361 | return CMD_SUCCESS; | |
04b6bdc0 DW |
2362 | } |
2363 | ||
8233ef81 | 2364 | /* "bgp network import-check" configuration. */ |
718e3744 | 2365 | DEFUN (bgp_network_import_check, |
2366 | bgp_network_import_check_cmd, | |
5623e905 | 2367 | "bgp network import-check", |
718e3744 | 2368 | "BGP specific commands\n" |
2369 | "BGP network command\n" | |
5623e905 | 2370 | "Check BGP network route exists in IGP\n") |
718e3744 | 2371 | { |
d62a17ae | 2372 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2373 | if (!bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2374 | bgp_flag_set(bgp, BGP_FLAG_IMPORT_CHECK); | |
2375 | bgp_static_redo_import_check(bgp); | |
2376 | } | |
078430f6 | 2377 | |
d62a17ae | 2378 | return CMD_SUCCESS; |
718e3744 | 2379 | } |
2380 | ||
d62a17ae | 2381 | ALIAS_HIDDEN(bgp_network_import_check, bgp_network_import_check_exact_cmd, |
2382 | "bgp network import-check exact", | |
2383 | "BGP specific commands\n" | |
2384 | "BGP network command\n" | |
2385 | "Check BGP network route exists in IGP\n" | |
2386 | "Match route precisely\n") | |
8233ef81 | 2387 | |
718e3744 | 2388 | DEFUN (no_bgp_network_import_check, |
2389 | no_bgp_network_import_check_cmd, | |
5623e905 | 2390 | "no bgp network import-check", |
718e3744 | 2391 | NO_STR |
2392 | "BGP specific commands\n" | |
2393 | "BGP network command\n" | |
2394 | "Check BGP network route exists in IGP\n") | |
2395 | { | |
d62a17ae | 2396 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2397 | if (bgp_flag_check(bgp, BGP_FLAG_IMPORT_CHECK)) { | |
2398 | bgp_flag_unset(bgp, BGP_FLAG_IMPORT_CHECK); | |
2399 | bgp_static_redo_import_check(bgp); | |
2400 | } | |
5623e905 | 2401 | |
d62a17ae | 2402 | return CMD_SUCCESS; |
718e3744 | 2403 | } |
6b0655a2 | 2404 | |
718e3744 | 2405 | DEFUN (bgp_default_local_preference, |
2406 | bgp_default_local_preference_cmd, | |
6147e2c6 | 2407 | "bgp default local-preference (0-4294967295)", |
718e3744 | 2408 | "BGP specific commands\n" |
2409 | "Configure BGP defaults\n" | |
2410 | "local preference (higher=more preferred)\n" | |
2411 | "Configure default local preference value\n") | |
2412 | { | |
d62a17ae | 2413 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2414 | int idx_number = 3; | |
d7c0a89a | 2415 | uint32_t local_pref; |
718e3744 | 2416 | |
d62a17ae | 2417 | local_pref = strtoul(argv[idx_number]->arg, NULL, 10); |
718e3744 | 2418 | |
d62a17ae | 2419 | bgp_default_local_preference_set(bgp, local_pref); |
2420 | bgp_clear_star_soft_in(vty, bgp->name); | |
718e3744 | 2421 | |
d62a17ae | 2422 | return CMD_SUCCESS; |
718e3744 | 2423 | } |
2424 | ||
2425 | DEFUN (no_bgp_default_local_preference, | |
2426 | no_bgp_default_local_preference_cmd, | |
838758ac | 2427 | "no bgp default local-preference [(0-4294967295)]", |
718e3744 | 2428 | NO_STR |
2429 | "BGP specific commands\n" | |
2430 | "Configure BGP defaults\n" | |
838758ac DW |
2431 | "local preference (higher=more preferred)\n" |
2432 | "Configure default local preference value\n") | |
718e3744 | 2433 | { |
d62a17ae | 2434 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2435 | bgp_default_local_preference_unset(bgp); | |
2436 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2437 | |
d62a17ae | 2438 | return CMD_SUCCESS; |
718e3744 | 2439 | } |
2440 | ||
6b0655a2 | 2441 | |
3f9c7369 DS |
2442 | DEFUN (bgp_default_subgroup_pkt_queue_max, |
2443 | bgp_default_subgroup_pkt_queue_max_cmd, | |
6147e2c6 | 2444 | "bgp default subgroup-pkt-queue-max (20-100)", |
3f9c7369 DS |
2445 | "BGP specific commands\n" |
2446 | "Configure BGP defaults\n" | |
2447 | "subgroup-pkt-queue-max\n" | |
2448 | "Configure subgroup packet queue max\n") | |
8bd9d948 | 2449 | { |
d62a17ae | 2450 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2451 | int idx_number = 3; | |
d7c0a89a | 2452 | uint32_t max_size; |
8bd9d948 | 2453 | |
d62a17ae | 2454 | max_size = strtoul(argv[idx_number]->arg, NULL, 10); |
3f9c7369 | 2455 | |
d62a17ae | 2456 | bgp_default_subgroup_pkt_queue_max_set(bgp, max_size); |
3f9c7369 | 2457 | |
d62a17ae | 2458 | return CMD_SUCCESS; |
3f9c7369 DS |
2459 | } |
2460 | ||
2461 | DEFUN (no_bgp_default_subgroup_pkt_queue_max, | |
2462 | no_bgp_default_subgroup_pkt_queue_max_cmd, | |
838758ac | 2463 | "no bgp default subgroup-pkt-queue-max [(20-100)]", |
3f9c7369 DS |
2464 | NO_STR |
2465 | "BGP specific commands\n" | |
2466 | "Configure BGP defaults\n" | |
838758ac DW |
2467 | "subgroup-pkt-queue-max\n" |
2468 | "Configure subgroup packet queue max\n") | |
3f9c7369 | 2469 | { |
d62a17ae | 2470 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2471 | bgp_default_subgroup_pkt_queue_max_unset(bgp); | |
2472 | return CMD_SUCCESS; | |
8bd9d948 DS |
2473 | } |
2474 | ||
813d4307 | 2475 | |
8bd9d948 DS |
2476 | DEFUN (bgp_rr_allow_outbound_policy, |
2477 | bgp_rr_allow_outbound_policy_cmd, | |
2478 | "bgp route-reflector allow-outbound-policy", | |
2479 | "BGP specific commands\n" | |
2480 | "Allow modifications made by out route-map\n" | |
2481 | "on ibgp neighbors\n") | |
2482 | { | |
d62a17ae | 2483 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2484 | |
d62a17ae | 2485 | if (!bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2486 | bgp_flag_set(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2487 | update_group_announce_rrclients(bgp); | |
2488 | bgp_clear_star_soft_out(vty, bgp->name); | |
2489 | } | |
8bd9d948 | 2490 | |
d62a17ae | 2491 | return CMD_SUCCESS; |
8bd9d948 DS |
2492 | } |
2493 | ||
2494 | DEFUN (no_bgp_rr_allow_outbound_policy, | |
2495 | no_bgp_rr_allow_outbound_policy_cmd, | |
2496 | "no bgp route-reflector allow-outbound-policy", | |
2497 | NO_STR | |
2498 | "BGP specific commands\n" | |
2499 | "Allow modifications made by out route-map\n" | |
2500 | "on ibgp neighbors\n") | |
2501 | { | |
d62a17ae | 2502 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
8bd9d948 | 2503 | |
d62a17ae | 2504 | if (bgp_flag_check(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY)) { |
2505 | bgp_flag_unset(bgp, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY); | |
2506 | update_group_announce_rrclients(bgp); | |
2507 | bgp_clear_star_soft_out(vty, bgp->name); | |
2508 | } | |
8bd9d948 | 2509 | |
d62a17ae | 2510 | return CMD_SUCCESS; |
8bd9d948 DS |
2511 | } |
2512 | ||
f14e6fdb DS |
2513 | DEFUN (bgp_listen_limit, |
2514 | bgp_listen_limit_cmd, | |
9ccf14f7 | 2515 | "bgp listen limit (1-5000)", |
f14e6fdb DS |
2516 | "BGP specific commands\n" |
2517 | "Configure BGP defaults\n" | |
2518 | "maximum number of BGP Dynamic Neighbors that can be created\n" | |
2519 | "Configure Dynamic Neighbors listen limit value\n") | |
2520 | { | |
d62a17ae | 2521 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2522 | int idx_number = 3; | |
2523 | int listen_limit; | |
f14e6fdb | 2524 | |
d62a17ae | 2525 | listen_limit = strtoul(argv[idx_number]->arg, NULL, 10); |
f14e6fdb | 2526 | |
d62a17ae | 2527 | bgp_listen_limit_set(bgp, listen_limit); |
f14e6fdb | 2528 | |
d62a17ae | 2529 | return CMD_SUCCESS; |
f14e6fdb DS |
2530 | } |
2531 | ||
2532 | DEFUN (no_bgp_listen_limit, | |
2533 | no_bgp_listen_limit_cmd, | |
838758ac | 2534 | "no bgp listen limit [(1-5000)]", |
f14e6fdb DS |
2535 | "BGP specific commands\n" |
2536 | "Configure BGP defaults\n" | |
2537 | "unset maximum number of BGP Dynamic Neighbors that can be created\n" | |
838758ac DW |
2538 | "Configure Dynamic Neighbors listen limit value to default\n" |
2539 | "Configure Dynamic Neighbors listen limit value\n") | |
f14e6fdb | 2540 | { |
d62a17ae | 2541 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2542 | bgp_listen_limit_unset(bgp); | |
2543 | return CMD_SUCCESS; | |
f14e6fdb DS |
2544 | } |
2545 | ||
2546 | ||
20eb8864 | 2547 | /* |
2548 | * Check if this listen range is already configured. Check for exact | |
2549 | * match or overlap based on input. | |
2550 | */ | |
d62a17ae | 2551 | static struct peer_group *listen_range_exists(struct bgp *bgp, |
2552 | struct prefix *range, int exact) | |
2553 | { | |
2554 | struct listnode *node, *nnode; | |
2555 | struct listnode *node1, *nnode1; | |
2556 | struct peer_group *group; | |
2557 | struct prefix *lr; | |
2558 | afi_t afi; | |
2559 | int match; | |
2560 | ||
2561 | afi = family2afi(range->family); | |
2562 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2563 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node1, nnode1, | |
2564 | lr)) { | |
2565 | if (exact) | |
2566 | match = prefix_same(range, lr); | |
2567 | else | |
2568 | match = (prefix_match(range, lr) | |
2569 | || prefix_match(lr, range)); | |
2570 | if (match) | |
2571 | return group; | |
2572 | } | |
2573 | } | |
2574 | ||
2575 | return NULL; | |
20eb8864 | 2576 | } |
2577 | ||
f14e6fdb DS |
2578 | DEFUN (bgp_listen_range, |
2579 | bgp_listen_range_cmd, | |
d7b9898c | 2580 | "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
f14e6fdb | 2581 | "BGP specific commands\n" |
d7fa34c1 QY |
2582 | "Configure BGP dynamic neighbors listen range\n" |
2583 | "Configure BGP dynamic neighbors listen range\n" | |
16cedbb0 QY |
2584 | NEIGHBOR_ADDR_STR |
2585 | "Member of the peer-group\n" | |
2586 | "Peer-group name\n") | |
f14e6fdb | 2587 | { |
d62a17ae | 2588 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2589 | struct prefix range; | |
2590 | struct peer_group *group, *existing_group; | |
2591 | afi_t afi; | |
2592 | int ret; | |
2593 | int idx = 0; | |
2594 | ||
2595 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2596 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2597 | char *prefix = argv[idx]->arg; | |
d7b9898c | 2598 | argv_find(argv, argc, "PGNAME", &idx); |
d62a17ae | 2599 | char *peergroup = argv[idx]->arg; |
2600 | ||
2601 | /* Convert IP prefix string to struct prefix. */ | |
2602 | ret = str2prefix(prefix, &range); | |
2603 | if (!ret) { | |
2604 | vty_out(vty, "%% Malformed listen range\n"); | |
2605 | return CMD_WARNING_CONFIG_FAILED; | |
2606 | } | |
2607 | ||
2608 | afi = family2afi(range.family); | |
2609 | ||
2610 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2611 | vty_out(vty, | |
2612 | "%% Malformed listen range (link-local address)\n"); | |
2613 | return CMD_WARNING_CONFIG_FAILED; | |
2614 | } | |
2615 | ||
2616 | apply_mask(&range); | |
2617 | ||
2618 | /* Check if same listen range is already configured. */ | |
2619 | existing_group = listen_range_exists(bgp, &range, 1); | |
2620 | if (existing_group) { | |
2621 | if (strcmp(existing_group->name, peergroup) == 0) | |
2622 | return CMD_SUCCESS; | |
2623 | else { | |
2624 | vty_out(vty, | |
2625 | "%% Same listen range is attached to peer-group %s\n", | |
2626 | existing_group->name); | |
2627 | return CMD_WARNING_CONFIG_FAILED; | |
2628 | } | |
2629 | } | |
2630 | ||
2631 | /* Check if an overlapping listen range exists. */ | |
2632 | if (listen_range_exists(bgp, &range, 0)) { | |
2633 | vty_out(vty, | |
2634 | "%% Listen range overlaps with existing listen range\n"); | |
2635 | return CMD_WARNING_CONFIG_FAILED; | |
2636 | } | |
2637 | ||
2638 | group = peer_group_lookup(bgp, peergroup); | |
2639 | if (!group) { | |
2640 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2641 | return CMD_WARNING_CONFIG_FAILED; | |
2642 | } | |
2643 | ||
2644 | ret = peer_group_listen_range_add(group, &range); | |
2645 | return bgp_vty_return(vty, ret); | |
f14e6fdb DS |
2646 | } |
2647 | ||
2648 | DEFUN (no_bgp_listen_range, | |
2649 | no_bgp_listen_range_cmd, | |
d7b9898c | 2650 | "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME", |
d7fa34c1 | 2651 | NO_STR |
f14e6fdb | 2652 | "BGP specific commands\n" |
d7fa34c1 QY |
2653 | "Unconfigure BGP dynamic neighbors listen range\n" |
2654 | "Unconfigure BGP dynamic neighbors listen range\n" | |
2655 | NEIGHBOR_ADDR_STR | |
2656 | "Member of the peer-group\n" | |
2657 | "Peer-group name\n") | |
f14e6fdb | 2658 | { |
d62a17ae | 2659 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2660 | struct prefix range; | |
2661 | struct peer_group *group; | |
2662 | afi_t afi; | |
2663 | int ret; | |
2664 | int idx = 0; | |
2665 | ||
2666 | argv_find(argv, argc, "A.B.C.D/M", &idx); | |
2667 | argv_find(argv, argc, "X:X::X:X/M", &idx); | |
2668 | char *prefix = argv[idx]->arg; | |
2669 | argv_find(argv, argc, "WORD", &idx); | |
2670 | char *peergroup = argv[idx]->arg; | |
2671 | ||
2672 | /* Convert IP prefix string to struct prefix. */ | |
2673 | ret = str2prefix(prefix, &range); | |
2674 | if (!ret) { | |
2675 | vty_out(vty, "%% Malformed listen range\n"); | |
2676 | return CMD_WARNING_CONFIG_FAILED; | |
2677 | } | |
2678 | ||
2679 | afi = family2afi(range.family); | |
2680 | ||
2681 | if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL(&range.u.prefix6)) { | |
2682 | vty_out(vty, | |
2683 | "%% Malformed listen range (link-local address)\n"); | |
2684 | return CMD_WARNING_CONFIG_FAILED; | |
2685 | } | |
2686 | ||
2687 | apply_mask(&range); | |
2688 | ||
2689 | group = peer_group_lookup(bgp, peergroup); | |
2690 | if (!group) { | |
2691 | vty_out(vty, "%% Peer-group does not exist\n"); | |
2692 | return CMD_WARNING_CONFIG_FAILED; | |
2693 | } | |
2694 | ||
2695 | ret = peer_group_listen_range_del(group, &range); | |
2696 | return bgp_vty_return(vty, ret); | |
2697 | } | |
2698 | ||
2b791107 | 2699 | void bgp_config_write_listen(struct vty *vty, struct bgp *bgp) |
d62a17ae | 2700 | { |
2701 | struct peer_group *group; | |
2702 | struct listnode *node, *nnode, *rnode, *nrnode; | |
2703 | struct prefix *range; | |
2704 | afi_t afi; | |
2705 | char buf[PREFIX2STR_BUFFER]; | |
2706 | ||
2707 | if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT) | |
2708 | vty_out(vty, " bgp listen limit %d\n", | |
2709 | bgp->dynamic_neighbors_limit); | |
2710 | ||
2711 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
2712 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
2713 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode, | |
2714 | nrnode, range)) { | |
2715 | prefix2str(range, buf, sizeof(buf)); | |
2716 | vty_out(vty, | |
2717 | " bgp listen range %s peer-group %s\n", | |
2718 | buf, group->name); | |
2719 | } | |
2720 | } | |
2721 | } | |
f14e6fdb DS |
2722 | } |
2723 | ||
2724 | ||
907f92c8 DS |
2725 | DEFUN (bgp_disable_connected_route_check, |
2726 | bgp_disable_connected_route_check_cmd, | |
2727 | "bgp disable-ebgp-connected-route-check", | |
2728 | "BGP specific commands\n" | |
2729 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2730 | { | |
d62a17ae | 2731 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2732 | bgp_flag_set(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2733 | bgp_clear_star_soft_in(vty, bgp->name); | |
7aafcaca | 2734 | |
d62a17ae | 2735 | return CMD_SUCCESS; |
907f92c8 DS |
2736 | } |
2737 | ||
2738 | DEFUN (no_bgp_disable_connected_route_check, | |
2739 | no_bgp_disable_connected_route_check_cmd, | |
2740 | "no bgp disable-ebgp-connected-route-check", | |
2741 | NO_STR | |
2742 | "BGP specific commands\n" | |
2743 | "Disable checking if nexthop is connected on ebgp sessions\n") | |
2744 | { | |
d62a17ae | 2745 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
2746 | bgp_flag_unset(bgp, BGP_FLAG_DISABLE_NH_CONNECTED_CHK); | |
2747 | bgp_clear_star_soft_in(vty, bgp->name); | |
2748 | ||
2749 | return CMD_SUCCESS; | |
2750 | } | |
2751 | ||
2752 | ||
2753 | static int peer_remote_as_vty(struct vty *vty, const char *peer_str, | |
2754 | const char *as_str, afi_t afi, safi_t safi) | |
2755 | { | |
2756 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2757 | int ret; | |
2758 | as_t as; | |
2759 | int as_type = AS_SPECIFIED; | |
2760 | union sockunion su; | |
2761 | ||
2762 | if (as_str[0] == 'i') { | |
2763 | as = 0; | |
2764 | as_type = AS_INTERNAL; | |
2765 | } else if (as_str[0] == 'e') { | |
2766 | as = 0; | |
2767 | as_type = AS_EXTERNAL; | |
2768 | } else { | |
2769 | /* Get AS number. */ | |
2770 | as = strtoul(as_str, NULL, 10); | |
2771 | } | |
2772 | ||
390485fd | 2773 | /* If peer is peer group or interface peer, call proper function. */ |
d62a17ae | 2774 | ret = str2sockunion(peer_str, &su); |
2775 | if (ret < 0) { | |
390485fd DS |
2776 | struct peer *peer; |
2777 | ||
2778 | /* Check if existing interface peer */ | |
2779 | peer = peer_lookup_by_conf_if(bgp, peer_str); | |
2780 | ||
d62a17ae | 2781 | ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi, |
2782 | safi); | |
390485fd DS |
2783 | |
2784 | /* if not interface peer, check peer-group settings */ | |
2785 | if (ret < 0 && !peer) { | |
d62a17ae | 2786 | ret = peer_group_remote_as(bgp, peer_str, &as, as_type); |
2787 | if (ret < 0) { | |
2788 | vty_out(vty, | |
390485fd | 2789 | "%% Create the peer-group or interface first\n"); |
d62a17ae | 2790 | return CMD_WARNING_CONFIG_FAILED; |
2791 | } | |
2792 | return CMD_SUCCESS; | |
2793 | } | |
2794 | } else { | |
2795 | if (peer_address_self_check(bgp, &su)) { | |
2796 | vty_out(vty, | |
2797 | "%% Can not configure the local system as neighbor\n"); | |
2798 | return CMD_WARNING_CONFIG_FAILED; | |
2799 | } | |
2800 | ret = peer_remote_as(bgp, &su, NULL, &as, as_type, afi, safi); | |
2801 | } | |
2802 | ||
2803 | /* This peer belongs to peer group. */ | |
2804 | switch (ret) { | |
2805 | case BGP_ERR_PEER_GROUP_MEMBER: | |
2806 | vty_out(vty, | |
faa16034 | 2807 | "%% Peer-group member cannot override remote-as of peer-group\n"); |
d62a17ae | 2808 | return CMD_WARNING_CONFIG_FAILED; |
2809 | case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT: | |
2810 | vty_out(vty, | |
faa16034 | 2811 | "%% Peer-group members must be all internal or all external\n"); |
d62a17ae | 2812 | return CMD_WARNING_CONFIG_FAILED; |
2813 | } | |
2814 | return bgp_vty_return(vty, ret); | |
718e3744 | 2815 | } |
2816 | ||
f26845f9 QY |
2817 | DEFUN (bgp_default_shutdown, |
2818 | bgp_default_shutdown_cmd, | |
2819 | "[no] bgp default shutdown", | |
2820 | NO_STR | |
2821 | BGP_STR | |
2822 | "Configure BGP defaults\n" | |
b012cbe2 | 2823 | "Apply administrative shutdown to newly configured peers\n") |
f26845f9 QY |
2824 | { |
2825 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2826 | bgp->autoshutdown = !strmatch(argv[0]->text, "no"); | |
2827 | return CMD_SUCCESS; | |
2828 | } | |
2829 | ||
718e3744 | 2830 | DEFUN (neighbor_remote_as, |
2831 | neighbor_remote_as_cmd, | |
3a2d747c | 2832 | "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>", |
718e3744 | 2833 | NEIGHBOR_STR |
2834 | NEIGHBOR_ADDR_STR2 | |
2835 | "Specify a BGP neighbor\n" | |
d7fa34c1 | 2836 | AS_STR |
3a2d747c QY |
2837 | "Internal BGP peer\n" |
2838 | "External BGP peer\n") | |
718e3744 | 2839 | { |
d62a17ae | 2840 | int idx_peer = 1; |
2841 | int idx_remote_as = 3; | |
2842 | return peer_remote_as_vty(vty, argv[idx_peer]->arg, | |
2843 | argv[idx_remote_as]->arg, AFI_IP, | |
2844 | SAFI_UNICAST); | |
2845 | } | |
2846 | ||
2847 | static int peer_conf_interface_get(struct vty *vty, const char *conf_if, | |
2848 | afi_t afi, safi_t safi, int v6only, | |
2849 | const char *peer_group_name, | |
2850 | const char *as_str) | |
2851 | { | |
2852 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
2853 | as_t as = 0; | |
2854 | int as_type = AS_UNSPECIFIED; | |
2855 | struct peer *peer; | |
2856 | struct peer_group *group; | |
2857 | int ret = 0; | |
2858 | union sockunion su; | |
2859 | ||
2860 | group = peer_group_lookup(bgp, conf_if); | |
2861 | ||
2862 | if (group) { | |
2863 | vty_out(vty, "%% Name conflict with peer-group \n"); | |
2864 | return CMD_WARNING_CONFIG_FAILED; | |
2865 | } | |
2866 | ||
2867 | if (as_str) { | |
2868 | if (as_str[0] == 'i') { | |
2869 | as_type = AS_INTERNAL; | |
2870 | } else if (as_str[0] == 'e') { | |
2871 | as_type = AS_EXTERNAL; | |
2872 | } else { | |
2873 | /* Get AS number. */ | |
2874 | as = strtoul(as_str, NULL, 10); | |
2875 | as_type = AS_SPECIFIED; | |
2876 | } | |
2877 | } | |
2878 | ||
2879 | peer = peer_lookup_by_conf_if(bgp, conf_if); | |
2880 | if (peer) { | |
2881 | if (as_str) | |
cc4d4ce8 | 2882 | ret = peer_remote_as(bgp, NULL, conf_if, &as, as_type, |
d62a17ae | 2883 | afi, safi); |
2884 | } else { | |
2885 | if (bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4) | |
2886 | && afi == AFI_IP && safi == SAFI_UNICAST) | |
2887 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2888 | as_type, 0, 0, NULL); | |
2889 | else | |
2890 | peer = peer_create(NULL, conf_if, bgp, bgp->as, as, | |
2891 | as_type, afi, safi, NULL); | |
2892 | ||
2893 | if (!peer) { | |
2894 | vty_out(vty, "%% BGP failed to create peer\n"); | |
2895 | return CMD_WARNING_CONFIG_FAILED; | |
2896 | } | |
2897 | ||
2898 | if (v6only) | |
527de3dc | 2899 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2900 | |
2901 | /* Request zebra to initiate IPv6 RAs on this interface. We do | |
2902 | * this | |
2903 | * any unnumbered peer in order to not worry about run-time | |
2904 | * transitions | |
2905 | * (e.g., peering is initially IPv4, but the IPv4 /30 or /31 | |
2906 | * address | |
2907 | * gets deleted later etc.) | |
2908 | */ | |
2909 | if (peer->ifp) | |
2910 | bgp_zebra_initiate_radv(bgp, peer); | |
2911 | } | |
2912 | ||
2913 | if ((v6only && !CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY)) | |
2914 | || (!v6only && CHECK_FLAG(peer->flags, PEER_FLAG_IFPEER_V6ONLY))) { | |
2915 | if (v6only) | |
527de3dc | 2916 | peer_flag_set(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2917 | else |
527de3dc | 2918 | peer_flag_unset(peer, PEER_FLAG_IFPEER_V6ONLY); |
d62a17ae | 2919 | |
2920 | /* v6only flag changed. Reset bgp seesion */ | |
2921 | if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) { | |
2922 | peer->last_reset = PEER_DOWN_V6ONLY_CHANGE; | |
2923 | bgp_notify_send(peer, BGP_NOTIFY_CEASE, | |
2924 | BGP_NOTIFY_CEASE_CONFIG_CHANGE); | |
2925 | } else | |
2926 | bgp_session_reset(peer); | |
2927 | } | |
2928 | ||
9fb964de PM |
2929 | if (!CHECK_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE)) { |
2930 | SET_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE); | |
2931 | SET_FLAG(peer->flags_invert, PEER_FLAG_CAPABILITY_ENHE); | |
dc2f50f3 | 2932 | SET_FLAG(peer->flags_override, PEER_FLAG_CAPABILITY_ENHE); |
9fb964de | 2933 | } |
d62a17ae | 2934 | |
2935 | if (peer_group_name) { | |
2936 | group = peer_group_lookup(bgp, peer_group_name); | |
2937 | if (!group) { | |
2938 | vty_out(vty, "%% Configure the peer-group first\n"); | |
2939 | return CMD_WARNING_CONFIG_FAILED; | |
2940 | } | |
2941 | ||
2942 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
2943 | } | |
2944 | ||
2945 | return bgp_vty_return(vty, ret); | |
a80beece DS |
2946 | } |
2947 | ||
4c48cf63 DW |
2948 | DEFUN (neighbor_interface_config, |
2949 | neighbor_interface_config_cmd, | |
d7b9898c | 2950 | "neighbor WORD interface [peer-group PGNAME]", |
4c48cf63 DW |
2951 | NEIGHBOR_STR |
2952 | "Interface name or neighbor tag\n" | |
31500417 DW |
2953 | "Enable BGP on interface\n" |
2954 | "Member of the peer-group\n" | |
16cedbb0 | 2955 | "Peer-group name\n") |
4c48cf63 | 2956 | { |
d62a17ae | 2957 | int idx_word = 1; |
2958 | int idx_peer_group_word = 4; | |
31500417 | 2959 | |
d62a17ae | 2960 | if (argc > idx_peer_group_word) |
2961 | return peer_conf_interface_get( | |
2962 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 0, | |
2963 | argv[idx_peer_group_word]->arg, NULL); | |
2964 | else | |
2965 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
2966 | SAFI_UNICAST, 0, NULL, NULL); | |
4c48cf63 DW |
2967 | } |
2968 | ||
4c48cf63 DW |
2969 | DEFUN (neighbor_interface_config_v6only, |
2970 | neighbor_interface_config_v6only_cmd, | |
d7b9898c | 2971 | "neighbor WORD interface v6only [peer-group PGNAME]", |
4c48cf63 DW |
2972 | NEIGHBOR_STR |
2973 | "Interface name or neighbor tag\n" | |
2974 | "Enable BGP on interface\n" | |
31500417 DW |
2975 | "Enable BGP with v6 link-local only\n" |
2976 | "Member of the peer-group\n" | |
16cedbb0 | 2977 | "Peer-group name\n") |
4c48cf63 | 2978 | { |
d62a17ae | 2979 | int idx_word = 1; |
2980 | int idx_peer_group_word = 5; | |
31500417 | 2981 | |
d62a17ae | 2982 | if (argc > idx_peer_group_word) |
2983 | return peer_conf_interface_get( | |
2984 | vty, argv[idx_word]->arg, AFI_IP, SAFI_UNICAST, 1, | |
2985 | argv[idx_peer_group_word]->arg, NULL); | |
31500417 | 2986 | |
d62a17ae | 2987 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, |
2988 | SAFI_UNICAST, 1, NULL, NULL); | |
4c48cf63 DW |
2989 | } |
2990 | ||
a80beece | 2991 | |
b3a39dc5 DD |
2992 | DEFUN (neighbor_interface_config_remote_as, |
2993 | neighbor_interface_config_remote_as_cmd, | |
3a2d747c | 2994 | "neighbor WORD interface remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
2995 | NEIGHBOR_STR |
2996 | "Interface name or neighbor tag\n" | |
2997 | "Enable BGP on interface\n" | |
3a2d747c | 2998 | "Specify a BGP neighbor\n" |
d7fa34c1 | 2999 | AS_STR |
3a2d747c QY |
3000 | "Internal BGP peer\n" |
3001 | "External BGP peer\n") | |
b3a39dc5 | 3002 | { |
d62a17ae | 3003 | int idx_word = 1; |
3004 | int idx_remote_as = 4; | |
3005 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3006 | SAFI_UNICAST, 0, NULL, | |
3007 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3008 | } |
3009 | ||
3010 | DEFUN (neighbor_interface_v6only_config_remote_as, | |
3011 | neighbor_interface_v6only_config_remote_as_cmd, | |
3a2d747c | 3012 | "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>", |
b3a39dc5 DD |
3013 | NEIGHBOR_STR |
3014 | "Interface name or neighbor tag\n" | |
3a2d747c | 3015 | "Enable BGP with v6 link-local only\n" |
b3a39dc5 | 3016 | "Enable BGP on interface\n" |
3a2d747c | 3017 | "Specify a BGP neighbor\n" |
d7fa34c1 | 3018 | AS_STR |
3a2d747c QY |
3019 | "Internal BGP peer\n" |
3020 | "External BGP peer\n") | |
b3a39dc5 | 3021 | { |
d62a17ae | 3022 | int idx_word = 1; |
3023 | int idx_remote_as = 5; | |
3024 | return peer_conf_interface_get(vty, argv[idx_word]->arg, AFI_IP, | |
3025 | SAFI_UNICAST, 1, NULL, | |
3026 | argv[idx_remote_as]->arg); | |
b3a39dc5 DD |
3027 | } |
3028 | ||
718e3744 | 3029 | DEFUN (neighbor_peer_group, |
3030 | neighbor_peer_group_cmd, | |
3031 | "neighbor WORD peer-group", | |
3032 | NEIGHBOR_STR | |
a80beece | 3033 | "Interface name or neighbor tag\n" |
718e3744 | 3034 | "Configure peer-group\n") |
3035 | { | |
d62a17ae | 3036 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3037 | int idx_word = 1; | |
3038 | struct peer *peer; | |
3039 | struct peer_group *group; | |
718e3744 | 3040 | |
d62a17ae | 3041 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); |
3042 | if (peer) { | |
3043 | vty_out(vty, "%% Name conflict with interface: \n"); | |
3044 | return CMD_WARNING_CONFIG_FAILED; | |
3045 | } | |
718e3744 | 3046 | |
d62a17ae | 3047 | group = peer_group_get(bgp, argv[idx_word]->arg); |
3048 | if (!group) { | |
3049 | vty_out(vty, "%% BGP failed to find or create peer-group\n"); | |
3050 | return CMD_WARNING_CONFIG_FAILED; | |
3051 | } | |
718e3744 | 3052 | |
d62a17ae | 3053 | return CMD_SUCCESS; |
718e3744 | 3054 | } |
3055 | ||
3056 | DEFUN (no_neighbor, | |
3057 | no_neighbor_cmd, | |
dab8cd00 | 3058 | "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>", |
718e3744 | 3059 | NO_STR |
3060 | NEIGHBOR_STR | |
3a2d747c QY |
3061 | NEIGHBOR_ADDR_STR2 |
3062 | "Specify a BGP neighbor\n" | |
3063 | AS_STR | |
3064 | "Internal BGP peer\n" | |
3065 | "External BGP peer\n") | |
718e3744 | 3066 | { |
d62a17ae | 3067 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3068 | int idx_peer = 2; | |
3069 | int ret; | |
3070 | union sockunion su; | |
3071 | struct peer_group *group; | |
3072 | struct peer *peer; | |
3073 | struct peer *other; | |
3074 | ||
3075 | ret = str2sockunion(argv[idx_peer]->arg, &su); | |
3076 | if (ret < 0) { | |
3077 | /* look up for neighbor by interface name config. */ | |
3078 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3079 | if (peer) { | |
3080 | /* Request zebra to terminate IPv6 RAs on this | |
3081 | * interface. */ | |
3082 | if (peer->ifp) | |
3083 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3084 | peer_delete(peer); | |
3085 | return CMD_SUCCESS; | |
3086 | } | |
f14e6fdb | 3087 | |
d62a17ae | 3088 | group = peer_group_lookup(bgp, argv[idx_peer]->arg); |
3089 | if (group) | |
3090 | peer_group_delete(group); | |
3091 | else { | |
3092 | vty_out(vty, "%% Create the peer-group first\n"); | |
3093 | return CMD_WARNING_CONFIG_FAILED; | |
3094 | } | |
3095 | } else { | |
3096 | peer = peer_lookup(bgp, &su); | |
3097 | if (peer) { | |
3098 | if (peer_dynamic_neighbor(peer)) { | |
3099 | vty_out(vty, | |
3100 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3101 | return CMD_WARNING_CONFIG_FAILED; | |
3102 | } | |
3103 | ||
3104 | other = peer->doppelganger; | |
3105 | peer_delete(peer); | |
3106 | if (other && other->status != Deleted) | |
3107 | peer_delete(other); | |
3108 | } | |
1ff9a340 | 3109 | } |
718e3744 | 3110 | |
d62a17ae | 3111 | return CMD_SUCCESS; |
718e3744 | 3112 | } |
3113 | ||
a80beece DS |
3114 | DEFUN (no_neighbor_interface_config, |
3115 | no_neighbor_interface_config_cmd, | |
d7b9898c | 3116 | "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]", |
a80beece DS |
3117 | NO_STR |
3118 | NEIGHBOR_STR | |
3119 | "Interface name\n" | |
31500417 DW |
3120 | "Configure BGP on interface\n" |
3121 | "Enable BGP with v6 link-local only\n" | |
3122 | "Member of the peer-group\n" | |
16cedbb0 | 3123 | "Peer-group name\n" |
3a2d747c QY |
3124 | "Specify a BGP neighbor\n" |
3125 | AS_STR | |
3126 | "Internal BGP peer\n" | |
3127 | "External BGP peer\n") | |
a80beece | 3128 | { |
d62a17ae | 3129 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3130 | int idx_word = 2; | |
3131 | struct peer *peer; | |
3132 | ||
3133 | /* look up for neighbor by interface name config. */ | |
3134 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3135 | if (peer) { | |
3136 | /* Request zebra to terminate IPv6 RAs on this interface. */ | |
3137 | if (peer->ifp) | |
3138 | bgp_zebra_terminate_radv(peer->bgp, peer); | |
3139 | peer_delete(peer); | |
3140 | } else { | |
3141 | vty_out(vty, "%% Create the bgp interface first\n"); | |
3142 | return CMD_WARNING_CONFIG_FAILED; | |
3143 | } | |
3144 | return CMD_SUCCESS; | |
a80beece DS |
3145 | } |
3146 | ||
718e3744 | 3147 | DEFUN (no_neighbor_peer_group, |
3148 | no_neighbor_peer_group_cmd, | |
3149 | "no neighbor WORD peer-group", | |
3150 | NO_STR | |
3151 | NEIGHBOR_STR | |
3152 | "Neighbor tag\n" | |
3153 | "Configure peer-group\n") | |
3154 | { | |
d62a17ae | 3155 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3156 | int idx_word = 2; | |
3157 | struct peer_group *group; | |
718e3744 | 3158 | |
d62a17ae | 3159 | group = peer_group_lookup(bgp, argv[idx_word]->arg); |
3160 | if (group) | |
3161 | peer_group_delete(group); | |
3162 | else { | |
3163 | vty_out(vty, "%% Create the peer-group first\n"); | |
3164 | return CMD_WARNING_CONFIG_FAILED; | |
3165 | } | |
3166 | return CMD_SUCCESS; | |
718e3744 | 3167 | } |
3168 | ||
a80beece DS |
3169 | DEFUN (no_neighbor_interface_peer_group_remote_as, |
3170 | no_neighbor_interface_peer_group_remote_as_cmd, | |
9ccf14f7 | 3171 | "no neighbor WORD remote-as <(1-4294967295)|internal|external>", |
718e3744 | 3172 | NO_STR |
3173 | NEIGHBOR_STR | |
a80beece | 3174 | "Interface name or neighbor tag\n" |
718e3744 | 3175 | "Specify a BGP neighbor\n" |
3a2d747c QY |
3176 | AS_STR |
3177 | "Internal BGP peer\n" | |
3178 | "External BGP peer\n") | |
718e3744 | 3179 | { |
d62a17ae | 3180 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3181 | int idx_word = 2; | |
3182 | struct peer_group *group; | |
3183 | struct peer *peer; | |
3184 | ||
3185 | /* look up for neighbor by interface name config. */ | |
3186 | peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg); | |
3187 | if (peer) { | |
390485fd | 3188 | peer_as_change(peer, 0, AS_UNSPECIFIED); |
d62a17ae | 3189 | return CMD_SUCCESS; |
3190 | } | |
3191 | ||
3192 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3193 | if (group) | |
3194 | peer_group_remote_as_delete(group); | |
3195 | else { | |
3196 | vty_out(vty, "%% Create the peer-group or interface first\n"); | |
3197 | return CMD_WARNING_CONFIG_FAILED; | |
3198 | } | |
3199 | return CMD_SUCCESS; | |
718e3744 | 3200 | } |
6b0655a2 | 3201 | |
718e3744 | 3202 | DEFUN (neighbor_local_as, |
3203 | neighbor_local_as_cmd, | |
9ccf14f7 | 3204 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)", |
718e3744 | 3205 | NEIGHBOR_STR |
3206 | NEIGHBOR_ADDR_STR2 | |
3207 | "Specify a local-as number\n" | |
3208 | "AS number used as local AS\n") | |
3209 | { | |
d62a17ae | 3210 | int idx_peer = 1; |
3211 | int idx_number = 3; | |
3212 | struct peer *peer; | |
3213 | int ret; | |
3214 | as_t as; | |
718e3744 | 3215 | |
d62a17ae | 3216 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3217 | if (!peer) | |
3218 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3219 | |
d62a17ae | 3220 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3221 | ret = peer_local_as_set(peer, as, 0, 0); | |
3222 | return bgp_vty_return(vty, ret); | |
718e3744 | 3223 | } |
3224 | ||
3225 | DEFUN (neighbor_local_as_no_prepend, | |
3226 | neighbor_local_as_no_prepend_cmd, | |
9ccf14f7 | 3227 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend", |
718e3744 | 3228 | NEIGHBOR_STR |
3229 | NEIGHBOR_ADDR_STR2 | |
3230 | "Specify a local-as number\n" | |
3231 | "AS number used as local AS\n" | |
3232 | "Do not prepend local-as to updates from ebgp peers\n") | |
3233 | { | |
d62a17ae | 3234 | int idx_peer = 1; |
3235 | int idx_number = 3; | |
3236 | struct peer *peer; | |
3237 | int ret; | |
3238 | as_t as; | |
718e3744 | 3239 | |
d62a17ae | 3240 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3241 | if (!peer) | |
3242 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3243 | |
d62a17ae | 3244 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3245 | ret = peer_local_as_set(peer, as, 1, 0); | |
3246 | return bgp_vty_return(vty, ret); | |
718e3744 | 3247 | } |
3248 | ||
9d3f9705 AC |
3249 | DEFUN (neighbor_local_as_no_prepend_replace_as, |
3250 | neighbor_local_as_no_prepend_replace_as_cmd, | |
9ccf14f7 | 3251 | "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as", |
9d3f9705 AC |
3252 | NEIGHBOR_STR |
3253 | NEIGHBOR_ADDR_STR2 | |
3254 | "Specify a local-as number\n" | |
3255 | "AS number used as local AS\n" | |
3256 | "Do not prepend local-as to updates from ebgp peers\n" | |
3257 | "Do not prepend local-as to updates from ibgp peers\n") | |
3258 | { | |
d62a17ae | 3259 | int idx_peer = 1; |
3260 | int idx_number = 3; | |
3261 | struct peer *peer; | |
3262 | int ret; | |
3263 | as_t as; | |
9d3f9705 | 3264 | |
d62a17ae | 3265 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3266 | if (!peer) | |
3267 | return CMD_WARNING_CONFIG_FAILED; | |
9d3f9705 | 3268 | |
d62a17ae | 3269 | as = strtoul(argv[idx_number]->arg, NULL, 10); |
3270 | ret = peer_local_as_set(peer, as, 1, 1); | |
3271 | return bgp_vty_return(vty, ret); | |
9d3f9705 AC |
3272 | } |
3273 | ||
718e3744 | 3274 | DEFUN (no_neighbor_local_as, |
3275 | no_neighbor_local_as_cmd, | |
a636c635 | 3276 | "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]", |
718e3744 | 3277 | NO_STR |
3278 | NEIGHBOR_STR | |
3279 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
3280 | "Specify a local-as number\n" |
3281 | "AS number used as local AS\n" | |
3282 | "Do not prepend local-as to updates from ebgp peers\n" | |
3283 | "Do not prepend local-as to updates from ibgp peers\n") | |
718e3744 | 3284 | { |
d62a17ae | 3285 | int idx_peer = 2; |
3286 | struct peer *peer; | |
3287 | int ret; | |
718e3744 | 3288 | |
d62a17ae | 3289 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3290 | if (!peer) | |
3291 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3292 | |
d62a17ae | 3293 | ret = peer_local_as_unset(peer); |
3294 | return bgp_vty_return(vty, ret); | |
718e3744 | 3295 | } |
3296 | ||
718e3744 | 3297 | |
3f9c7369 DS |
3298 | DEFUN (neighbor_solo, |
3299 | neighbor_solo_cmd, | |
9ccf14f7 | 3300 | "neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3301 | NEIGHBOR_STR |
3302 | NEIGHBOR_ADDR_STR2 | |
3303 | "Solo peer - part of its own update group\n") | |
3304 | { | |
d62a17ae | 3305 | int idx_peer = 1; |
3306 | struct peer *peer; | |
3307 | int ret; | |
3f9c7369 | 3308 | |
d62a17ae | 3309 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3310 | if (!peer) | |
3311 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3312 | |
d62a17ae | 3313 | ret = update_group_adjust_soloness(peer, 1); |
3314 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3315 | } |
3316 | ||
3317 | DEFUN (no_neighbor_solo, | |
3318 | no_neighbor_solo_cmd, | |
9ccf14f7 | 3319 | "no neighbor <A.B.C.D|X:X::X:X|WORD> solo", |
3f9c7369 DS |
3320 | NO_STR |
3321 | NEIGHBOR_STR | |
3322 | NEIGHBOR_ADDR_STR2 | |
3323 | "Solo peer - part of its own update group\n") | |
3324 | { | |
d62a17ae | 3325 | int idx_peer = 2; |
3326 | struct peer *peer; | |
3327 | int ret; | |
3f9c7369 | 3328 | |
d62a17ae | 3329 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3330 | if (!peer) | |
3331 | return CMD_WARNING_CONFIG_FAILED; | |
3f9c7369 | 3332 | |
d62a17ae | 3333 | ret = update_group_adjust_soloness(peer, 0); |
3334 | return bgp_vty_return(vty, ret); | |
3f9c7369 DS |
3335 | } |
3336 | ||
0df7c91f PJ |
3337 | DEFUN (neighbor_password, |
3338 | neighbor_password_cmd, | |
9ccf14f7 | 3339 | "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE", |
0df7c91f PJ |
3340 | NEIGHBOR_STR |
3341 | NEIGHBOR_ADDR_STR2 | |
3342 | "Set a password\n" | |
3343 | "The password\n") | |
3344 | { | |
d62a17ae | 3345 | int idx_peer = 1; |
3346 | int idx_line = 3; | |
3347 | struct peer *peer; | |
3348 | int ret; | |
0df7c91f | 3349 | |
d62a17ae | 3350 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3351 | if (!peer) | |
3352 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3353 | |
d62a17ae | 3354 | ret = peer_password_set(peer, argv[idx_line]->arg); |
3355 | return bgp_vty_return(vty, ret); | |
0df7c91f PJ |
3356 | } |
3357 | ||
3358 | DEFUN (no_neighbor_password, | |
3359 | no_neighbor_password_cmd, | |
a636c635 | 3360 | "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]", |
0df7c91f PJ |
3361 | NO_STR |
3362 | NEIGHBOR_STR | |
3363 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 QY |
3364 | "Set a password\n" |
3365 | "The password\n") | |
0df7c91f | 3366 | { |
d62a17ae | 3367 | int idx_peer = 2; |
3368 | struct peer *peer; | |
3369 | int ret; | |
0df7c91f | 3370 | |
d62a17ae | 3371 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3372 | if (!peer) | |
3373 | return CMD_WARNING_CONFIG_FAILED; | |
0df7c91f | 3374 | |
d62a17ae | 3375 | ret = peer_password_unset(peer); |
3376 | return bgp_vty_return(vty, ret); | |
0df7c91f | 3377 | } |
6b0655a2 | 3378 | |
718e3744 | 3379 | DEFUN (neighbor_activate, |
3380 | neighbor_activate_cmd, | |
9ccf14f7 | 3381 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3382 | NEIGHBOR_STR |
3383 | NEIGHBOR_ADDR_STR2 | |
3384 | "Enable the Address Family for this Neighbor\n") | |
3385 | { | |
d62a17ae | 3386 | int idx_peer = 1; |
3387 | int ret; | |
3388 | struct peer *peer; | |
718e3744 | 3389 | |
d62a17ae | 3390 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
3391 | if (!peer) | |
3392 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3393 | |
d62a17ae | 3394 | ret = peer_activate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3395 | return bgp_vty_return(vty, ret); | |
718e3744 | 3396 | } |
3397 | ||
d62a17ae | 3398 | ALIAS_HIDDEN(neighbor_activate, neighbor_activate_hidden_cmd, |
3399 | "neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3400 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3401 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3402 | |
718e3744 | 3403 | DEFUN (no_neighbor_activate, |
3404 | no_neighbor_activate_cmd, | |
9ccf14f7 | 3405 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", |
718e3744 | 3406 | NO_STR |
3407 | NEIGHBOR_STR | |
3408 | NEIGHBOR_ADDR_STR2 | |
3409 | "Enable the Address Family for this Neighbor\n") | |
3410 | { | |
d62a17ae | 3411 | int idx_peer = 2; |
3412 | int ret; | |
3413 | struct peer *peer; | |
718e3744 | 3414 | |
d62a17ae | 3415 | /* Lookup peer. */ |
3416 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3417 | if (!peer) | |
3418 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3419 | |
d62a17ae | 3420 | ret = peer_deactivate(peer, bgp_node_afi(vty), bgp_node_safi(vty)); |
3421 | return bgp_vty_return(vty, ret); | |
718e3744 | 3422 | } |
6b0655a2 | 3423 | |
d62a17ae | 3424 | ALIAS_HIDDEN(no_neighbor_activate, no_neighbor_activate_hidden_cmd, |
3425 | "no neighbor <A.B.C.D|X:X::X:X|WORD> activate", | |
3426 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3427 | "Enable the Address Family for this Neighbor\n") | |
596c17ba | 3428 | |
718e3744 | 3429 | DEFUN (neighbor_set_peer_group, |
3430 | neighbor_set_peer_group_cmd, | |
d7b9898c | 3431 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 3432 | NEIGHBOR_STR |
a80beece | 3433 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3434 | "Member of the peer-group\n" |
16cedbb0 | 3435 | "Peer-group name\n") |
718e3744 | 3436 | { |
d62a17ae | 3437 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3438 | int idx_peer = 1; | |
3439 | int idx_word = 3; | |
3440 | int ret; | |
3441 | as_t as; | |
3442 | union sockunion su; | |
3443 | struct peer *peer; | |
3444 | struct peer_group *group; | |
3445 | ||
d62a17ae | 3446 | ret = str2sockunion(argv[idx_peer]->arg, &su); |
3447 | if (ret < 0) { | |
3448 | peer = peer_lookup_by_conf_if(bgp, argv[idx_peer]->arg); | |
3449 | if (!peer) { | |
3450 | vty_out(vty, "%% Malformed address or name: %s\n", | |
3451 | argv[idx_peer]->arg); | |
3452 | return CMD_WARNING_CONFIG_FAILED; | |
3453 | } | |
3454 | } else { | |
3455 | if (peer_address_self_check(bgp, &su)) { | |
3456 | vty_out(vty, | |
3457 | "%% Can not configure the local system as neighbor\n"); | |
3458 | return CMD_WARNING_CONFIG_FAILED; | |
3459 | } | |
3460 | ||
3461 | /* Disallow for dynamic neighbor. */ | |
3462 | peer = peer_lookup(bgp, &su); | |
3463 | if (peer && peer_dynamic_neighbor(peer)) { | |
3464 | vty_out(vty, | |
3465 | "%% Operation not allowed on a dynamic neighbor\n"); | |
3466 | return CMD_WARNING_CONFIG_FAILED; | |
3467 | } | |
3468 | } | |
3469 | ||
3470 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3471 | if (!group) { | |
3472 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3473 | return CMD_WARNING_CONFIG_FAILED; | |
3474 | } | |
3475 | ||
3476 | ret = peer_group_bind(bgp, &su, peer, group, &as); | |
3477 | ||
3478 | if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT) { | |
3479 | vty_out(vty, | |
3480 | "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n", | |
3481 | as); | |
3482 | return CMD_WARNING_CONFIG_FAILED; | |
3483 | } | |
3484 | ||
3485 | return bgp_vty_return(vty, ret); | |
3486 | } | |
3487 | ||
3488 | ALIAS_HIDDEN(neighbor_set_peer_group, neighbor_set_peer_group_hidden_cmd, | |
d7b9898c | 3489 | "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 3490 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
3491 | "Member of the peer-group\n" | |
3492 | "Peer-group name\n") | |
596c17ba | 3493 | |
718e3744 | 3494 | DEFUN (no_neighbor_set_peer_group, |
3495 | no_neighbor_set_peer_group_cmd, | |
d7b9898c | 3496 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
718e3744 | 3497 | NO_STR |
3498 | NEIGHBOR_STR | |
a80beece | 3499 | NEIGHBOR_ADDR_STR2 |
718e3744 | 3500 | "Member of the peer-group\n" |
16cedbb0 | 3501 | "Peer-group name\n") |
718e3744 | 3502 | { |
d62a17ae | 3503 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
3504 | int idx_peer = 2; | |
3505 | int idx_word = 4; | |
3506 | int ret; | |
3507 | struct peer *peer; | |
3508 | struct peer_group *group; | |
3509 | ||
3510 | peer = peer_lookup_vty(vty, argv[idx_peer]->arg); | |
3511 | if (!peer) | |
3512 | return CMD_WARNING_CONFIG_FAILED; | |
3513 | ||
3514 | group = peer_group_lookup(bgp, argv[idx_word]->arg); | |
3515 | if (!group) { | |
3516 | vty_out(vty, "%% Configure the peer-group first\n"); | |
3517 | return CMD_WARNING_CONFIG_FAILED; | |
3518 | } | |
718e3744 | 3519 | |
827ed707 | 3520 | ret = peer_delete(peer); |
718e3744 | 3521 | |
d62a17ae | 3522 | return bgp_vty_return(vty, ret); |
718e3744 | 3523 | } |
6b0655a2 | 3524 | |
d62a17ae | 3525 | ALIAS_HIDDEN(no_neighbor_set_peer_group, no_neighbor_set_peer_group_hidden_cmd, |
d7b9898c | 3526 | "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME", |
d62a17ae | 3527 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 |
3528 | "Member of the peer-group\n" | |
3529 | "Peer-group name\n") | |
596c17ba | 3530 | |
d62a17ae | 3531 | static int peer_flag_modify_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3532 | uint32_t flag, int set) |
718e3744 | 3533 | { |
d62a17ae | 3534 | int ret; |
3535 | struct peer *peer; | |
718e3744 | 3536 | |
d62a17ae | 3537 | peer = peer_and_group_lookup_vty(vty, ip_str); |
3538 | if (!peer) | |
3539 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3540 | |
7ebe625c QY |
3541 | /* |
3542 | * If 'neighbor <interface>', then this is for directly connected peers, | |
3543 | * we should not accept disable-connected-check. | |
3544 | */ | |
3545 | if (peer->conf_if && (flag == PEER_FLAG_DISABLE_CONNECTED_CHECK)) { | |
3546 | vty_out(vty, | |
3547 | "%s is directly connected peer, cannot accept disable-" | |
3548 | "connected-check\n", | |
3549 | ip_str); | |
3550 | return CMD_WARNING_CONFIG_FAILED; | |
3551 | } | |
3552 | ||
d62a17ae | 3553 | if (!set && flag == PEER_FLAG_SHUTDOWN) |
3554 | peer_tx_shutdown_message_unset(peer); | |
ae9b0e11 | 3555 | |
d62a17ae | 3556 | if (set) |
3557 | ret = peer_flag_set(peer, flag); | |
3558 | else | |
3559 | ret = peer_flag_unset(peer, flag); | |
718e3744 | 3560 | |
d62a17ae | 3561 | return bgp_vty_return(vty, ret); |
718e3744 | 3562 | } |
3563 | ||
47cbc09b | 3564 | static int peer_flag_set_vty(struct vty *vty, const char *ip_str, uint32_t flag) |
718e3744 | 3565 | { |
d62a17ae | 3566 | return peer_flag_modify_vty(vty, ip_str, flag, 1); |
718e3744 | 3567 | } |
3568 | ||
d62a17ae | 3569 | static int peer_flag_unset_vty(struct vty *vty, const char *ip_str, |
47cbc09b | 3570 | uint32_t flag) |
718e3744 | 3571 | { |
d62a17ae | 3572 | return peer_flag_modify_vty(vty, ip_str, flag, 0); |
718e3744 | 3573 | } |
3574 | ||
3575 | /* neighbor passive. */ | |
3576 | DEFUN (neighbor_passive, | |
3577 | neighbor_passive_cmd, | |
9ccf14f7 | 3578 | "neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3579 | NEIGHBOR_STR |
3580 | NEIGHBOR_ADDR_STR2 | |
3581 | "Don't send open messages to this neighbor\n") | |
3582 | { | |
d62a17ae | 3583 | int idx_peer = 1; |
3584 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3585 | } |
3586 | ||
3587 | DEFUN (no_neighbor_passive, | |
3588 | no_neighbor_passive_cmd, | |
9ccf14f7 | 3589 | "no neighbor <A.B.C.D|X:X::X:X|WORD> passive", |
718e3744 | 3590 | NO_STR |
3591 | NEIGHBOR_STR | |
3592 | NEIGHBOR_ADDR_STR2 | |
3593 | "Don't send open messages to this neighbor\n") | |
3594 | { | |
d62a17ae | 3595 | int idx_peer = 2; |
3596 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, PEER_FLAG_PASSIVE); | |
718e3744 | 3597 | } |
6b0655a2 | 3598 | |
718e3744 | 3599 | /* neighbor shutdown. */ |
73d70fa6 DL |
3600 | DEFUN (neighbor_shutdown_msg, |
3601 | neighbor_shutdown_msg_cmd, | |
3602 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
718e3744 | 3603 | NEIGHBOR_STR |
3604 | NEIGHBOR_ADDR_STR2 | |
73d70fa6 DL |
3605 | "Administratively shut down this neighbor\n" |
3606 | "Add a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3607 | "Shutdown message\n") | |
718e3744 | 3608 | { |
d62a17ae | 3609 | int idx_peer = 1; |
73d70fa6 | 3610 | |
d62a17ae | 3611 | if (argc >= 5) { |
3612 | struct peer *peer = | |
3613 | peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
3614 | char *message; | |
73d70fa6 | 3615 | |
d62a17ae | 3616 | if (!peer) |
3617 | return CMD_WARNING_CONFIG_FAILED; | |
3618 | message = argv_concat(argv, argc, 4); | |
3619 | peer_tx_shutdown_message_set(peer, message); | |
3620 | XFREE(MTYPE_TMP, message); | |
3621 | } | |
73d70fa6 | 3622 | |
d62a17ae | 3623 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, PEER_FLAG_SHUTDOWN); |
718e3744 | 3624 | } |
3625 | ||
d62a17ae | 3626 | ALIAS(neighbor_shutdown_msg, neighbor_shutdown_cmd, |
3627 | "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3628 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3629 | "Administratively shut down this neighbor\n") | |
73d70fa6 DL |
3630 | |
3631 | DEFUN (no_neighbor_shutdown_msg, | |
3632 | no_neighbor_shutdown_msg_cmd, | |
3633 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...", | |
3634 | NO_STR | |
3635 | NEIGHBOR_STR | |
3636 | NEIGHBOR_ADDR_STR2 | |
3637 | "Administratively shut down this neighbor\n" | |
3638 | "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n" | |
3639 | "Shutdown message\n") | |
718e3744 | 3640 | { |
d62a17ae | 3641 | int idx_peer = 2; |
73d70fa6 | 3642 | |
d62a17ae | 3643 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, |
3644 | PEER_FLAG_SHUTDOWN); | |
718e3744 | 3645 | } |
6b0655a2 | 3646 | |
d62a17ae | 3647 | ALIAS(no_neighbor_shutdown_msg, no_neighbor_shutdown_cmd, |
3648 | "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown", | |
3649 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3650 | "Administratively shut down this neighbor\n") | |
73d70fa6 | 3651 | |
718e3744 | 3652 | /* neighbor capability dynamic. */ |
3653 | DEFUN (neighbor_capability_dynamic, | |
3654 | neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3655 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3656 | NEIGHBOR_STR |
3657 | NEIGHBOR_ADDR_STR2 | |
3658 | "Advertise capability to the peer\n" | |
3659 | "Advertise dynamic capability to this neighbor\n") | |
3660 | { | |
d62a17ae | 3661 | int idx_peer = 1; |
3662 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3663 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3664 | } |
3665 | ||
3666 | DEFUN (no_neighbor_capability_dynamic, | |
3667 | no_neighbor_capability_dynamic_cmd, | |
9ccf14f7 | 3668 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic", |
718e3744 | 3669 | NO_STR |
3670 | NEIGHBOR_STR | |
3671 | NEIGHBOR_ADDR_STR2 | |
3672 | "Advertise capability to the peer\n" | |
3673 | "Advertise dynamic capability to this neighbor\n") | |
3674 | { | |
d62a17ae | 3675 | int idx_peer = 2; |
3676 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3677 | PEER_FLAG_DYNAMIC_CAPABILITY); | |
718e3744 | 3678 | } |
6b0655a2 | 3679 | |
718e3744 | 3680 | /* neighbor dont-capability-negotiate */ |
3681 | DEFUN (neighbor_dont_capability_negotiate, | |
3682 | neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3683 | "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3684 | NEIGHBOR_STR |
3685 | NEIGHBOR_ADDR_STR2 | |
3686 | "Do not perform capability negotiation\n") | |
3687 | { | |
d62a17ae | 3688 | int idx_peer = 1; |
3689 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3690 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3691 | } |
3692 | ||
3693 | DEFUN (no_neighbor_dont_capability_negotiate, | |
3694 | no_neighbor_dont_capability_negotiate_cmd, | |
9ccf14f7 | 3695 | "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate", |
718e3744 | 3696 | NO_STR |
3697 | NEIGHBOR_STR | |
3698 | NEIGHBOR_ADDR_STR2 | |
3699 | "Do not perform capability negotiation\n") | |
3700 | { | |
d62a17ae | 3701 | int idx_peer = 2; |
3702 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3703 | PEER_FLAG_DONT_CAPABILITY); | |
718e3744 | 3704 | } |
6b0655a2 | 3705 | |
8a92a8a0 DS |
3706 | /* neighbor capability extended next hop encoding */ |
3707 | DEFUN (neighbor_capability_enhe, | |
3708 | neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3709 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3710 | NEIGHBOR_STR |
3711 | NEIGHBOR_ADDR_STR2 | |
3712 | "Advertise capability to the peer\n" | |
3713 | "Advertise extended next-hop capability to the peer\n") | |
3714 | { | |
d62a17ae | 3715 | int idx_peer = 1; |
3716 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
3717 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3718 | } |
3719 | ||
3720 | DEFUN (no_neighbor_capability_enhe, | |
3721 | no_neighbor_capability_enhe_cmd, | |
9ccf14f7 | 3722 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop", |
8a92a8a0 DS |
3723 | NO_STR |
3724 | NEIGHBOR_STR | |
3725 | NEIGHBOR_ADDR_STR2 | |
3726 | "Advertise capability to the peer\n" | |
3727 | "Advertise extended next-hop capability to the peer\n") | |
3728 | { | |
d62a17ae | 3729 | int idx_peer = 2; |
3730 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3731 | PEER_FLAG_CAPABILITY_ENHE); | |
8a92a8a0 DS |
3732 | } |
3733 | ||
d62a17ae | 3734 | static int peer_af_flag_modify_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3735 | afi_t afi, safi_t safi, uint32_t flag, |
d62a17ae | 3736 | int set) |
718e3744 | 3737 | { |
d62a17ae | 3738 | int ret; |
3739 | struct peer *peer; | |
718e3744 | 3740 | |
d62a17ae | 3741 | peer = peer_and_group_lookup_vty(vty, peer_str); |
3742 | if (!peer) | |
3743 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 3744 | |
d62a17ae | 3745 | if (set) |
3746 | ret = peer_af_flag_set(peer, afi, safi, flag); | |
3747 | else | |
3748 | ret = peer_af_flag_unset(peer, afi, safi, flag); | |
718e3744 | 3749 | |
d62a17ae | 3750 | return bgp_vty_return(vty, ret); |
718e3744 | 3751 | } |
3752 | ||
d62a17ae | 3753 | static int peer_af_flag_set_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3754 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3755 | { |
d62a17ae | 3756 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 1); |
718e3744 | 3757 | } |
3758 | ||
d62a17ae | 3759 | static int peer_af_flag_unset_vty(struct vty *vty, const char *peer_str, |
d7c0a89a | 3760 | afi_t afi, safi_t safi, uint32_t flag) |
718e3744 | 3761 | { |
d62a17ae | 3762 | return peer_af_flag_modify_vty(vty, peer_str, afi, safi, flag, 0); |
718e3744 | 3763 | } |
6b0655a2 | 3764 | |
718e3744 | 3765 | /* neighbor capability orf prefix-list. */ |
3766 | DEFUN (neighbor_capability_orf_prefix, | |
3767 | neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3768 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3769 | NEIGHBOR_STR |
3770 | NEIGHBOR_ADDR_STR2 | |
3771 | "Advertise capability to the peer\n" | |
3772 | "Advertise ORF capability to the peer\n" | |
3773 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3774 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3775 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3776 | "Capability to SEND the ORF to this neighbor\n") | |
3777 | { | |
d62a17ae | 3778 | int idx_peer = 1; |
3779 | int idx_send_recv = 5; | |
d7c0a89a | 3780 | uint16_t flag = 0; |
d62a17ae | 3781 | |
3782 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3783 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3784 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3785 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3786 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3787 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3788 | else { | |
3789 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3790 | return CMD_WARNING_CONFIG_FAILED; | |
3791 | } | |
3792 | ||
3793 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3794 | bgp_node_safi(vty), flag); | |
3795 | } | |
3796 | ||
3797 | ALIAS_HIDDEN( | |
3798 | neighbor_capability_orf_prefix, | |
3799 | neighbor_capability_orf_prefix_hidden_cmd, | |
3800 | "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3801 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3802 | "Advertise capability to the peer\n" | |
3803 | "Advertise ORF capability to the peer\n" | |
3804 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3805 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3806 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3807 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3808 | |
718e3744 | 3809 | DEFUN (no_neighbor_capability_orf_prefix, |
3810 | no_neighbor_capability_orf_prefix_cmd, | |
9ccf14f7 | 3811 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", |
718e3744 | 3812 | NO_STR |
3813 | NEIGHBOR_STR | |
3814 | NEIGHBOR_ADDR_STR2 | |
3815 | "Advertise capability to the peer\n" | |
3816 | "Advertise ORF capability to the peer\n" | |
3817 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3818 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3819 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3820 | "Capability to SEND the ORF to this neighbor\n") | |
3821 | { | |
d62a17ae | 3822 | int idx_peer = 2; |
3823 | int idx_send_recv = 6; | |
d7c0a89a | 3824 | uint16_t flag = 0; |
d62a17ae | 3825 | |
3826 | if (strmatch(argv[idx_send_recv]->text, "send")) | |
3827 | flag = PEER_FLAG_ORF_PREFIX_SM; | |
3828 | else if (strmatch(argv[idx_send_recv]->text, "receive")) | |
3829 | flag = PEER_FLAG_ORF_PREFIX_RM; | |
3830 | else if (strmatch(argv[idx_send_recv]->text, "both")) | |
3831 | flag = PEER_FLAG_ORF_PREFIX_SM | PEER_FLAG_ORF_PREFIX_RM; | |
3832 | else { | |
3833 | vty_out(vty, "%% BGP invalid orf prefix-list option\n"); | |
3834 | return CMD_WARNING_CONFIG_FAILED; | |
3835 | } | |
3836 | ||
3837 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3838 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3839 | flag); | |
3840 | } | |
3841 | ||
3842 | ALIAS_HIDDEN( | |
3843 | no_neighbor_capability_orf_prefix, | |
3844 | no_neighbor_capability_orf_prefix_hidden_cmd, | |
3845 | "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>", | |
3846 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3847 | "Advertise capability to the peer\n" | |
3848 | "Advertise ORF capability to the peer\n" | |
3849 | "Advertise prefixlist ORF capability to this neighbor\n" | |
3850 | "Capability to SEND and RECEIVE the ORF to/from this neighbor\n" | |
3851 | "Capability to RECEIVE the ORF from this neighbor\n" | |
3852 | "Capability to SEND the ORF to this neighbor\n") | |
596c17ba | 3853 | |
718e3744 | 3854 | /* neighbor next-hop-self. */ |
3855 | DEFUN (neighbor_nexthop_self, | |
3856 | neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3857 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3858 | NEIGHBOR_STR |
3859 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3860 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3861 | { |
d62a17ae | 3862 | int idx_peer = 1; |
3863 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3864 | bgp_node_safi(vty), PEER_FLAG_NEXTHOP_SELF); | |
a538debe | 3865 | } |
9e7a53c1 | 3866 | |
d62a17ae | 3867 | ALIAS_HIDDEN(neighbor_nexthop_self, neighbor_nexthop_self_hidden_cmd, |
3868 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3869 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3870 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3871 | |
a538debe DS |
3872 | /* neighbor next-hop-self. */ |
3873 | DEFUN (neighbor_nexthop_self_force, | |
3874 | neighbor_nexthop_self_force_cmd, | |
9ccf14f7 | 3875 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3876 | NEIGHBOR_STR |
3877 | NEIGHBOR_ADDR_STR2 | |
3878 | "Disable the next hop calculation for this neighbor\n" | |
3879 | "Set the next hop to self for reflected routes\n") | |
3880 | { | |
d62a17ae | 3881 | int idx_peer = 1; |
3882 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3883 | bgp_node_safi(vty), | |
3884 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
718e3744 | 3885 | } |
3886 | ||
d62a17ae | 3887 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3888 | neighbor_nexthop_self_force_hidden_cmd, | |
3889 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3890 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3891 | "Disable the next hop calculation for this neighbor\n" | |
3892 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3893 | |
1bc4e531 DA |
3894 | ALIAS_HIDDEN(neighbor_nexthop_self_force, |
3895 | neighbor_nexthop_self_all_hidden_cmd, | |
3896 | "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
3897 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3898 | "Disable the next hop calculation for this neighbor\n" | |
3899 | "Set the next hop to self for reflected routes\n") | |
3900 | ||
718e3744 | 3901 | DEFUN (no_neighbor_nexthop_self, |
3902 | no_neighbor_nexthop_self_cmd, | |
9ccf14f7 | 3903 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", |
718e3744 | 3904 | NO_STR |
3905 | NEIGHBOR_STR | |
3906 | NEIGHBOR_ADDR_STR2 | |
a538debe | 3907 | "Disable the next hop calculation for this neighbor\n") |
718e3744 | 3908 | { |
d62a17ae | 3909 | int idx_peer = 2; |
3910 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3911 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3912 | PEER_FLAG_NEXTHOP_SELF); | |
718e3744 | 3913 | } |
6b0655a2 | 3914 | |
d62a17ae | 3915 | ALIAS_HIDDEN(no_neighbor_nexthop_self, no_neighbor_nexthop_self_hidden_cmd, |
3916 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self", | |
3917 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3918 | "Disable the next hop calculation for this neighbor\n") | |
596c17ba | 3919 | |
88b8ed8d | 3920 | DEFUN (no_neighbor_nexthop_self_force, |
a538debe | 3921 | no_neighbor_nexthop_self_force_cmd, |
9ccf14f7 | 3922 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", |
a538debe DS |
3923 | NO_STR |
3924 | NEIGHBOR_STR | |
3925 | NEIGHBOR_ADDR_STR2 | |
3926 | "Disable the next hop calculation for this neighbor\n" | |
3927 | "Set the next hop to self for reflected routes\n") | |
88b8ed8d | 3928 | { |
d62a17ae | 3929 | int idx_peer = 2; |
3930 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3931 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3932 | PEER_FLAG_FORCE_NEXTHOP_SELF); | |
88b8ed8d | 3933 | } |
a538debe | 3934 | |
d62a17ae | 3935 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
3936 | no_neighbor_nexthop_self_force_hidden_cmd, | |
3937 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force", | |
3938 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3939 | "Disable the next hop calculation for this neighbor\n" | |
3940 | "Set the next hop to self for reflected routes\n") | |
596c17ba | 3941 | |
1bc4e531 DA |
3942 | ALIAS_HIDDEN(no_neighbor_nexthop_self_force, |
3943 | no_neighbor_nexthop_self_all_hidden_cmd, | |
3944 | "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all", | |
3945 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3946 | "Disable the next hop calculation for this neighbor\n" | |
3947 | "Set the next hop to self for reflected routes\n") | |
3948 | ||
c7122e14 DS |
3949 | /* neighbor as-override */ |
3950 | DEFUN (neighbor_as_override, | |
3951 | neighbor_as_override_cmd, | |
9ccf14f7 | 3952 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3953 | NEIGHBOR_STR |
3954 | NEIGHBOR_ADDR_STR2 | |
3955 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3956 | { | |
d62a17ae | 3957 | int idx_peer = 1; |
3958 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3959 | bgp_node_safi(vty), PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3960 | } |
3961 | ||
d62a17ae | 3962 | ALIAS_HIDDEN(neighbor_as_override, neighbor_as_override_hidden_cmd, |
3963 | "neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3964 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3965 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3966 | |
c7122e14 DS |
3967 | DEFUN (no_neighbor_as_override, |
3968 | no_neighbor_as_override_cmd, | |
9ccf14f7 | 3969 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", |
c7122e14 DS |
3970 | NO_STR |
3971 | NEIGHBOR_STR | |
3972 | NEIGHBOR_ADDR_STR2 | |
3973 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
3974 | { | |
d62a17ae | 3975 | int idx_peer = 2; |
3976 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
3977 | bgp_node_afi(vty), bgp_node_safi(vty), | |
3978 | PEER_FLAG_AS_OVERRIDE); | |
c7122e14 DS |
3979 | } |
3980 | ||
d62a17ae | 3981 | ALIAS_HIDDEN(no_neighbor_as_override, no_neighbor_as_override_hidden_cmd, |
3982 | "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override", | |
3983 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
3984 | "Override ASNs in outbound updates if aspath equals remote-as\n") | |
596c17ba | 3985 | |
718e3744 | 3986 | /* neighbor remove-private-AS. */ |
3987 | DEFUN (neighbor_remove_private_as, | |
3988 | neighbor_remove_private_as_cmd, | |
9ccf14f7 | 3989 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 3990 | NEIGHBOR_STR |
3991 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 3992 | "Remove private ASNs in outbound updates\n") |
718e3744 | 3993 | { |
d62a17ae | 3994 | int idx_peer = 1; |
3995 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
3996 | bgp_node_safi(vty), | |
3997 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 3998 | } |
3999 | ||
d62a17ae | 4000 | ALIAS_HIDDEN(neighbor_remove_private_as, neighbor_remove_private_as_hidden_cmd, |
4001 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4002 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4003 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4004 | |
5000f21c DS |
4005 | DEFUN (neighbor_remove_private_as_all, |
4006 | neighbor_remove_private_as_all_cmd, | |
9ccf14f7 | 4007 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4008 | NEIGHBOR_STR |
4009 | NEIGHBOR_ADDR_STR2 | |
4010 | "Remove private ASNs in outbound updates\n" | |
efd7904e | 4011 | "Apply to all AS numbers\n") |
5000f21c | 4012 | { |
d62a17ae | 4013 | int idx_peer = 1; |
4014 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4015 | bgp_node_safi(vty), | |
4016 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
5000f21c DS |
4017 | } |
4018 | ||
d62a17ae | 4019 | ALIAS_HIDDEN(neighbor_remove_private_as_all, |
4020 | neighbor_remove_private_as_all_hidden_cmd, | |
4021 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4022 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4023 | "Remove private ASNs in outbound updates\n" | |
4024 | "Apply to all AS numbers") | |
596c17ba | 4025 | |
5000f21c DS |
4026 | DEFUN (neighbor_remove_private_as_replace_as, |
4027 | neighbor_remove_private_as_replace_as_cmd, | |
9ccf14f7 | 4028 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4029 | NEIGHBOR_STR |
4030 | NEIGHBOR_ADDR_STR2 | |
4031 | "Remove private ASNs in outbound updates\n" | |
4032 | "Replace private ASNs with our ASN in outbound updates\n") | |
4033 | { | |
d62a17ae | 4034 | int idx_peer = 1; |
4035 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4036 | bgp_node_safi(vty), | |
4037 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
5000f21c DS |
4038 | } |
4039 | ||
d62a17ae | 4040 | ALIAS_HIDDEN(neighbor_remove_private_as_replace_as, |
4041 | neighbor_remove_private_as_replace_as_hidden_cmd, | |
4042 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4043 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4044 | "Remove private ASNs in outbound updates\n" | |
4045 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4046 | |
5000f21c DS |
4047 | DEFUN (neighbor_remove_private_as_all_replace_as, |
4048 | neighbor_remove_private_as_all_replace_as_cmd, | |
9ccf14f7 | 4049 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4050 | NEIGHBOR_STR |
4051 | NEIGHBOR_ADDR_STR2 | |
4052 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4053 | "Apply to all AS numbers\n" |
5000f21c DS |
4054 | "Replace private ASNs with our ASN in outbound updates\n") |
4055 | { | |
d62a17ae | 4056 | int idx_peer = 1; |
4057 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4058 | bgp_node_safi(vty), | |
4059 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
5000f21c DS |
4060 | } |
4061 | ||
d62a17ae | 4062 | ALIAS_HIDDEN( |
4063 | neighbor_remove_private_as_all_replace_as, | |
4064 | neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4065 | "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4066 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4067 | "Remove private ASNs in outbound updates\n" | |
4068 | "Apply to all AS numbers\n" | |
4069 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4070 | |
718e3744 | 4071 | DEFUN (no_neighbor_remove_private_as, |
4072 | no_neighbor_remove_private_as_cmd, | |
9ccf14f7 | 4073 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", |
718e3744 | 4074 | NO_STR |
4075 | NEIGHBOR_STR | |
4076 | NEIGHBOR_ADDR_STR2 | |
5000f21c | 4077 | "Remove private ASNs in outbound updates\n") |
718e3744 | 4078 | { |
d62a17ae | 4079 | int idx_peer = 2; |
4080 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4081 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4082 | PEER_FLAG_REMOVE_PRIVATE_AS); | |
718e3744 | 4083 | } |
6b0655a2 | 4084 | |
d62a17ae | 4085 | ALIAS_HIDDEN(no_neighbor_remove_private_as, |
4086 | no_neighbor_remove_private_as_hidden_cmd, | |
4087 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS", | |
4088 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4089 | "Remove private ASNs in outbound updates\n") | |
596c17ba | 4090 | |
88b8ed8d | 4091 | DEFUN (no_neighbor_remove_private_as_all, |
5000f21c | 4092 | no_neighbor_remove_private_as_all_cmd, |
9ccf14f7 | 4093 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", |
5000f21c DS |
4094 | NO_STR |
4095 | NEIGHBOR_STR | |
4096 | NEIGHBOR_ADDR_STR2 | |
4097 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4098 | "Apply to all AS numbers\n") |
88b8ed8d | 4099 | { |
d62a17ae | 4100 | int idx_peer = 2; |
4101 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4102 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4103 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL); | |
88b8ed8d | 4104 | } |
5000f21c | 4105 | |
d62a17ae | 4106 | ALIAS_HIDDEN(no_neighbor_remove_private_as_all, |
4107 | no_neighbor_remove_private_as_all_hidden_cmd, | |
4108 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", | |
4109 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4110 | "Remove private ASNs in outbound updates\n" | |
4111 | "Apply to all AS numbers\n") | |
596c17ba | 4112 | |
88b8ed8d | 4113 | DEFUN (no_neighbor_remove_private_as_replace_as, |
5000f21c | 4114 | no_neighbor_remove_private_as_replace_as_cmd, |
9ccf14f7 | 4115 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", |
5000f21c DS |
4116 | NO_STR |
4117 | NEIGHBOR_STR | |
4118 | NEIGHBOR_ADDR_STR2 | |
4119 | "Remove private ASNs in outbound updates\n" | |
4120 | "Replace private ASNs with our ASN in outbound updates\n") | |
88b8ed8d | 4121 | { |
d62a17ae | 4122 | int idx_peer = 2; |
4123 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4124 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4125 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE); | |
88b8ed8d | 4126 | } |
5000f21c | 4127 | |
d62a17ae | 4128 | ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as, |
4129 | no_neighbor_remove_private_as_replace_as_hidden_cmd, | |
4130 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS", | |
4131 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4132 | "Remove private ASNs in outbound updates\n" | |
4133 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4134 | |
88b8ed8d | 4135 | DEFUN (no_neighbor_remove_private_as_all_replace_as, |
5000f21c | 4136 | no_neighbor_remove_private_as_all_replace_as_cmd, |
9ccf14f7 | 4137 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", |
5000f21c DS |
4138 | NO_STR |
4139 | NEIGHBOR_STR | |
4140 | NEIGHBOR_ADDR_STR2 | |
4141 | "Remove private ASNs in outbound updates\n" | |
16cedbb0 | 4142 | "Apply to all AS numbers\n" |
5000f21c | 4143 | "Replace private ASNs with our ASN in outbound updates\n") |
88b8ed8d | 4144 | { |
d62a17ae | 4145 | int idx_peer = 2; |
4146 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4147 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4148 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE); | |
88b8ed8d | 4149 | } |
5000f21c | 4150 | |
d62a17ae | 4151 | ALIAS_HIDDEN( |
4152 | no_neighbor_remove_private_as_all_replace_as, | |
4153 | no_neighbor_remove_private_as_all_replace_as_hidden_cmd, | |
4154 | "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS", | |
4155 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4156 | "Remove private ASNs in outbound updates\n" | |
4157 | "Apply to all AS numbers\n" | |
4158 | "Replace private ASNs with our ASN in outbound updates\n") | |
596c17ba | 4159 | |
5000f21c | 4160 | |
718e3744 | 4161 | /* neighbor send-community. */ |
4162 | DEFUN (neighbor_send_community, | |
4163 | neighbor_send_community_cmd, | |
9ccf14f7 | 4164 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4165 | NEIGHBOR_STR |
4166 | NEIGHBOR_ADDR_STR2 | |
4167 | "Send Community attribute to this neighbor\n") | |
4168 | { | |
d62a17ae | 4169 | int idx_peer = 1; |
27c05d4d | 4170 | |
d62a17ae | 4171 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4172 | bgp_node_safi(vty), | |
4173 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4174 | } |
4175 | ||
d62a17ae | 4176 | ALIAS_HIDDEN(neighbor_send_community, neighbor_send_community_hidden_cmd, |
4177 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4178 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4179 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4180 | |
718e3744 | 4181 | DEFUN (no_neighbor_send_community, |
4182 | no_neighbor_send_community_cmd, | |
9ccf14f7 | 4183 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", |
718e3744 | 4184 | NO_STR |
4185 | NEIGHBOR_STR | |
4186 | NEIGHBOR_ADDR_STR2 | |
4187 | "Send Community attribute to this neighbor\n") | |
4188 | { | |
d62a17ae | 4189 | int idx_peer = 2; |
27c05d4d | 4190 | |
d62a17ae | 4191 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, |
4192 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4193 | PEER_FLAG_SEND_COMMUNITY); | |
718e3744 | 4194 | } |
6b0655a2 | 4195 | |
d62a17ae | 4196 | ALIAS_HIDDEN(no_neighbor_send_community, no_neighbor_send_community_hidden_cmd, |
4197 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community", | |
4198 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4199 | "Send Community attribute to this neighbor\n") | |
596c17ba | 4200 | |
718e3744 | 4201 | /* neighbor send-community extended. */ |
4202 | DEFUN (neighbor_send_community_type, | |
4203 | neighbor_send_community_type_cmd, | |
57d187bc | 4204 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4205 | NEIGHBOR_STR |
4206 | NEIGHBOR_ADDR_STR2 | |
4207 | "Send Community attribute to this neighbor\n" | |
4208 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4209 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4210 | "Send Extended Community attributes\n" |
57d187bc JS |
4211 | "Send Standard Community attributes\n" |
4212 | "Send Large Community attributes\n") | |
718e3744 | 4213 | { |
27c05d4d | 4214 | int idx_peer = 1; |
d7c0a89a | 4215 | uint32_t flag = 0; |
27c05d4d | 4216 | const char *type = argv[argc - 1]->text; |
d62a17ae | 4217 | |
27c05d4d | 4218 | if (strmatch(type, "standard")) { |
d62a17ae | 4219 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
27c05d4d | 4220 | } else if (strmatch(type, "extended")) { |
d62a17ae | 4221 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); |
27c05d4d | 4222 | } else if (strmatch(type, "large")) { |
d62a17ae | 4223 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); |
27c05d4d | 4224 | } else if (strmatch(type, "both")) { |
d62a17ae | 4225 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4226 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
27c05d4d | 4227 | } else { /* if (strmatch(type, "all")) */ |
d62a17ae | 4228 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); |
4229 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4230 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4231 | } | |
4232 | ||
27c05d4d | 4233 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
d62a17ae | 4234 | bgp_node_safi(vty), flag); |
4235 | } | |
4236 | ||
4237 | ALIAS_HIDDEN( | |
4238 | neighbor_send_community_type, neighbor_send_community_type_hidden_cmd, | |
4239 | "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4240 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4241 | "Send Community attribute to this neighbor\n" | |
4242 | "Send Standard and Extended Community attributes\n" | |
4243 | "Send Standard, Large and Extended Community attributes\n" | |
4244 | "Send Extended Community attributes\n" | |
4245 | "Send Standard Community attributes\n" | |
4246 | "Send Large Community attributes\n") | |
596c17ba | 4247 | |
718e3744 | 4248 | DEFUN (no_neighbor_send_community_type, |
4249 | no_neighbor_send_community_type_cmd, | |
57d187bc | 4250 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", |
718e3744 | 4251 | NO_STR |
4252 | NEIGHBOR_STR | |
4253 | NEIGHBOR_ADDR_STR2 | |
4254 | "Send Community attribute to this neighbor\n" | |
4255 | "Send Standard and Extended Community attributes\n" | |
57d187bc | 4256 | "Send Standard, Large and Extended Community attributes\n" |
718e3744 | 4257 | "Send Extended Community attributes\n" |
57d187bc JS |
4258 | "Send Standard Community attributes\n" |
4259 | "Send Large Community attributes\n") | |
718e3744 | 4260 | { |
d62a17ae | 4261 | int idx_peer = 2; |
27c05d4d | 4262 | uint32_t flag = 0; |
d62a17ae | 4263 | const char *type = argv[argc - 1]->text; |
4264 | ||
27c05d4d PM |
4265 | if (strmatch(type, "standard")) { |
4266 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4267 | } else if (strmatch(type, "extended")) { | |
4268 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4269 | } else if (strmatch(type, "large")) { | |
4270 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4271 | } else if (strmatch(type, "both")) { | |
4272 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4273 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4274 | } else { /* if (strmatch(type, "all")) */ | |
4275 | SET_FLAG(flag, PEER_FLAG_SEND_COMMUNITY); | |
4276 | SET_FLAG(flag, PEER_FLAG_SEND_EXT_COMMUNITY); | |
4277 | SET_FLAG(flag, PEER_FLAG_SEND_LARGE_COMMUNITY); | |
4278 | } | |
4279 | ||
4280 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4281 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4282 | flag); | |
d62a17ae | 4283 | } |
4284 | ||
4285 | ALIAS_HIDDEN( | |
4286 | no_neighbor_send_community_type, | |
4287 | no_neighbor_send_community_type_hidden_cmd, | |
4288 | "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>", | |
4289 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4290 | "Send Community attribute to this neighbor\n" | |
4291 | "Send Standard and Extended Community attributes\n" | |
4292 | "Send Standard, Large and Extended Community attributes\n" | |
4293 | "Send Extended Community attributes\n" | |
4294 | "Send Standard Community attributes\n" | |
4295 | "Send Large Community attributes\n") | |
596c17ba | 4296 | |
718e3744 | 4297 | /* neighbor soft-reconfig. */ |
4298 | DEFUN (neighbor_soft_reconfiguration, | |
4299 | neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4300 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4301 | NEIGHBOR_STR |
4302 | NEIGHBOR_ADDR_STR2 | |
4303 | "Per neighbor soft reconfiguration\n" | |
4304 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4305 | { | |
d62a17ae | 4306 | int idx_peer = 1; |
4307 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4308 | bgp_node_safi(vty), | |
4309 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4310 | } |
4311 | ||
d62a17ae | 4312 | ALIAS_HIDDEN(neighbor_soft_reconfiguration, |
4313 | neighbor_soft_reconfiguration_hidden_cmd, | |
4314 | "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4315 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4316 | "Per neighbor soft reconfiguration\n" | |
4317 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4318 | |
718e3744 | 4319 | DEFUN (no_neighbor_soft_reconfiguration, |
4320 | no_neighbor_soft_reconfiguration_cmd, | |
9ccf14f7 | 4321 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", |
718e3744 | 4322 | NO_STR |
4323 | NEIGHBOR_STR | |
4324 | NEIGHBOR_ADDR_STR2 | |
4325 | "Per neighbor soft reconfiguration\n" | |
4326 | "Allow inbound soft reconfiguration for this neighbor\n") | |
4327 | { | |
d62a17ae | 4328 | int idx_peer = 2; |
4329 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4330 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4331 | PEER_FLAG_SOFT_RECONFIG); | |
718e3744 | 4332 | } |
6b0655a2 | 4333 | |
d62a17ae | 4334 | ALIAS_HIDDEN(no_neighbor_soft_reconfiguration, |
4335 | no_neighbor_soft_reconfiguration_hidden_cmd, | |
4336 | "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound", | |
4337 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4338 | "Per neighbor soft reconfiguration\n" | |
4339 | "Allow inbound soft reconfiguration for this neighbor\n") | |
596c17ba | 4340 | |
718e3744 | 4341 | DEFUN (neighbor_route_reflector_client, |
4342 | neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4343 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4344 | NEIGHBOR_STR |
4345 | NEIGHBOR_ADDR_STR2 | |
4346 | "Configure a neighbor as Route Reflector client\n") | |
4347 | { | |
d62a17ae | 4348 | int idx_peer = 1; |
4349 | struct peer *peer; | |
718e3744 | 4350 | |
4351 | ||
d62a17ae | 4352 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4353 | if (!peer) | |
4354 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4355 | |
d62a17ae | 4356 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), |
4357 | bgp_node_safi(vty), | |
4358 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4359 | } |
4360 | ||
d62a17ae | 4361 | ALIAS_HIDDEN(neighbor_route_reflector_client, |
4362 | neighbor_route_reflector_client_hidden_cmd, | |
4363 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4364 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4365 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4366 | |
718e3744 | 4367 | DEFUN (no_neighbor_route_reflector_client, |
4368 | no_neighbor_route_reflector_client_cmd, | |
9ccf14f7 | 4369 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", |
718e3744 | 4370 | NO_STR |
4371 | NEIGHBOR_STR | |
4372 | NEIGHBOR_ADDR_STR2 | |
4373 | "Configure a neighbor as Route Reflector client\n") | |
4374 | { | |
d62a17ae | 4375 | int idx_peer = 2; |
4376 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4377 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4378 | PEER_FLAG_REFLECTOR_CLIENT); | |
718e3744 | 4379 | } |
6b0655a2 | 4380 | |
d62a17ae | 4381 | ALIAS_HIDDEN(no_neighbor_route_reflector_client, |
4382 | no_neighbor_route_reflector_client_hidden_cmd, | |
4383 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client", | |
4384 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4385 | "Configure a neighbor as Route Reflector client\n") | |
596c17ba | 4386 | |
718e3744 | 4387 | /* neighbor route-server-client. */ |
4388 | DEFUN (neighbor_route_server_client, | |
4389 | neighbor_route_server_client_cmd, | |
9ccf14f7 | 4390 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4391 | NEIGHBOR_STR |
4392 | NEIGHBOR_ADDR_STR2 | |
4393 | "Configure a neighbor as Route Server client\n") | |
4394 | { | |
d62a17ae | 4395 | int idx_peer = 1; |
4396 | struct peer *peer; | |
2a3d5731 | 4397 | |
d62a17ae | 4398 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4399 | if (!peer) | |
4400 | return CMD_WARNING_CONFIG_FAILED; | |
4401 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4402 | bgp_node_safi(vty), | |
4403 | PEER_FLAG_RSERVER_CLIENT); | |
718e3744 | 4404 | } |
4405 | ||
d62a17ae | 4406 | ALIAS_HIDDEN(neighbor_route_server_client, |
4407 | neighbor_route_server_client_hidden_cmd, | |
4408 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4409 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4410 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4411 | |
718e3744 | 4412 | DEFUN (no_neighbor_route_server_client, |
4413 | no_neighbor_route_server_client_cmd, | |
9ccf14f7 | 4414 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", |
718e3744 | 4415 | NO_STR |
4416 | NEIGHBOR_STR | |
4417 | NEIGHBOR_ADDR_STR2 | |
4418 | "Configure a neighbor as Route Server client\n") | |
fee0f4c6 | 4419 | { |
d62a17ae | 4420 | int idx_peer = 2; |
4421 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4422 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4423 | PEER_FLAG_RSERVER_CLIENT); | |
fee0f4c6 | 4424 | } |
6b0655a2 | 4425 | |
d62a17ae | 4426 | ALIAS_HIDDEN(no_neighbor_route_server_client, |
4427 | no_neighbor_route_server_client_hidden_cmd, | |
4428 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client", | |
4429 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4430 | "Configure a neighbor as Route Server client\n") | |
596c17ba | 4431 | |
fee0f4c6 | 4432 | DEFUN (neighbor_nexthop_local_unchanged, |
4433 | neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4434 | "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4435 | NEIGHBOR_STR |
4436 | NEIGHBOR_ADDR_STR2 | |
4437 | "Configure treatment of outgoing link-local nexthop attribute\n" | |
4438 | "Leave link-local nexthop unchanged for this peer\n") | |
4439 | { | |
d62a17ae | 4440 | int idx_peer = 1; |
4441 | return peer_af_flag_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
4442 | bgp_node_safi(vty), | |
4443 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
fee0f4c6 | 4444 | } |
6b0655a2 | 4445 | |
fee0f4c6 | 4446 | DEFUN (no_neighbor_nexthop_local_unchanged, |
4447 | no_neighbor_nexthop_local_unchanged_cmd, | |
9ccf14f7 | 4448 | "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged", |
fee0f4c6 | 4449 | NO_STR |
4450 | NEIGHBOR_STR | |
4451 | NEIGHBOR_ADDR_STR2 | |
4452 | "Configure treatment of outgoing link-local-nexthop attribute\n" | |
4453 | "Leave link-local nexthop unchanged for this peer\n") | |
718e3744 | 4454 | { |
d62a17ae | 4455 | int idx_peer = 2; |
4456 | return peer_af_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4457 | bgp_node_afi(vty), bgp_node_safi(vty), | |
4458 | PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED); | |
718e3744 | 4459 | } |
6b0655a2 | 4460 | |
718e3744 | 4461 | DEFUN (neighbor_attr_unchanged, |
4462 | neighbor_attr_unchanged_cmd, | |
a8206004 | 4463 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
718e3744 | 4464 | NEIGHBOR_STR |
4465 | NEIGHBOR_ADDR_STR2 | |
4466 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4467 | "As-path attribute\n" | |
4468 | "Nexthop attribute\n" | |
a8206004 | 4469 | "Med attribute\n") |
718e3744 | 4470 | { |
d62a17ae | 4471 | int idx = 0; |
8eeb0335 DW |
4472 | char *peer_str = argv[1]->arg; |
4473 | struct peer *peer; | |
d7c0a89a | 4474 | uint16_t flags = 0; |
8eeb0335 DW |
4475 | afi_t afi = bgp_node_afi(vty); |
4476 | safi_t safi = bgp_node_safi(vty); | |
4477 | ||
4478 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4479 | if (!peer) | |
4480 | return CMD_WARNING_CONFIG_FAILED; | |
d62a17ae | 4481 | |
4482 | if (argv_find(argv, argc, "as-path", &idx)) | |
4483 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4484 | idx = 0; | |
4485 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4486 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4487 | idx = 0; | |
4488 | if (argv_find(argv, argc, "med", &idx)) | |
4489 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4490 | ||
8eeb0335 DW |
4491 | /* no flags means all of them! */ |
4492 | if (!flags) { | |
d62a17ae | 4493 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); |
4494 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4495 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
8eeb0335 | 4496 | } else { |
a4d82a8a PZ |
4497 | if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) |
4498 | && peer_af_flag_check(peer, afi, safi, | |
4499 | PEER_FLAG_AS_PATH_UNCHANGED)) { | |
8eeb0335 DW |
4500 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4501 | PEER_FLAG_AS_PATH_UNCHANGED); | |
4502 | } | |
4503 | ||
a4d82a8a PZ |
4504 | if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) |
4505 | && peer_af_flag_check(peer, afi, safi, | |
4506 | PEER_FLAG_NEXTHOP_UNCHANGED)) { | |
8eeb0335 DW |
4507 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4508 | PEER_FLAG_NEXTHOP_UNCHANGED); | |
4509 | } | |
4510 | ||
a4d82a8a PZ |
4511 | if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) |
4512 | && peer_af_flag_check(peer, afi, safi, | |
4513 | PEER_FLAG_MED_UNCHANGED)) { | |
8eeb0335 DW |
4514 | peer_af_flag_unset_vty(vty, peer_str, afi, safi, |
4515 | PEER_FLAG_MED_UNCHANGED); | |
4516 | } | |
d62a17ae | 4517 | } |
4518 | ||
8eeb0335 | 4519 | return peer_af_flag_set_vty(vty, peer_str, afi, safi, flags); |
d62a17ae | 4520 | } |
4521 | ||
4522 | ALIAS_HIDDEN( | |
4523 | neighbor_attr_unchanged, neighbor_attr_unchanged_hidden_cmd, | |
4524 | "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4525 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4526 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4527 | "As-path attribute\n" | |
4528 | "Nexthop attribute\n" | |
4529 | "Med attribute\n") | |
596c17ba | 4530 | |
718e3744 | 4531 | DEFUN (no_neighbor_attr_unchanged, |
4532 | no_neighbor_attr_unchanged_cmd, | |
a8206004 | 4533 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", |
e52702f2 | 4534 | NO_STR |
718e3744 | 4535 | NEIGHBOR_STR |
4536 | NEIGHBOR_ADDR_STR2 | |
31500417 DW |
4537 | "BGP attribute is propagated unchanged to this neighbor\n" |
4538 | "As-path attribute\n" | |
40e718b5 | 4539 | "Nexthop attribute\n" |
a8206004 | 4540 | "Med attribute\n") |
718e3744 | 4541 | { |
d62a17ae | 4542 | int idx = 0; |
4543 | char *peer = argv[2]->arg; | |
d7c0a89a | 4544 | uint16_t flags = 0; |
d62a17ae | 4545 | |
4546 | if (argv_find(argv, argc, "as-path", &idx)) | |
4547 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4548 | idx = 0; | |
4549 | if (argv_find(argv, argc, "next-hop", &idx)) | |
4550 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4551 | idx = 0; | |
4552 | if (argv_find(argv, argc, "med", &idx)) | |
4553 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4554 | ||
4555 | if (!flags) // no flags means all of them! | |
4556 | { | |
4557 | SET_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED); | |
4558 | SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); | |
4559 | SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); | |
4560 | } | |
4561 | ||
4562 | return peer_af_flag_unset_vty(vty, peer, bgp_node_afi(vty), | |
4563 | bgp_node_safi(vty), flags); | |
4564 | } | |
4565 | ||
4566 | ALIAS_HIDDEN( | |
4567 | no_neighbor_attr_unchanged, no_neighbor_attr_unchanged_hidden_cmd, | |
4568 | "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]", | |
4569 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4570 | "BGP attribute is propagated unchanged to this neighbor\n" | |
4571 | "As-path attribute\n" | |
4572 | "Nexthop attribute\n" | |
4573 | "Med attribute\n") | |
718e3744 | 4574 | |
718e3744 | 4575 | /* EBGP multihop configuration. */ |
d62a17ae | 4576 | static int peer_ebgp_multihop_set_vty(struct vty *vty, const char *ip_str, |
4577 | const char *ttl_str) | |
718e3744 | 4578 | { |
d62a17ae | 4579 | struct peer *peer; |
4580 | unsigned int ttl; | |
718e3744 | 4581 | |
d62a17ae | 4582 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4583 | if (!peer) | |
4584 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4585 | |
d62a17ae | 4586 | if (peer->conf_if) |
4587 | return bgp_vty_return(vty, BGP_ERR_INVALID_FOR_DIRECT_PEER); | |
63fa10b5 | 4588 | |
d62a17ae | 4589 | if (!ttl_str) |
4590 | ttl = MAXTTL; | |
4591 | else | |
4592 | ttl = strtoul(ttl_str, NULL, 10); | |
718e3744 | 4593 | |
d62a17ae | 4594 | return bgp_vty_return(vty, peer_ebgp_multihop_set(peer, ttl)); |
718e3744 | 4595 | } |
4596 | ||
d62a17ae | 4597 | static int peer_ebgp_multihop_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 4598 | { |
d62a17ae | 4599 | struct peer *peer; |
718e3744 | 4600 | |
d62a17ae | 4601 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4602 | if (!peer) | |
4603 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4604 | |
d62a17ae | 4605 | return bgp_vty_return(vty, peer_ebgp_multihop_unset(peer)); |
718e3744 | 4606 | } |
4607 | ||
4608 | /* neighbor ebgp-multihop. */ | |
4609 | DEFUN (neighbor_ebgp_multihop, | |
4610 | neighbor_ebgp_multihop_cmd, | |
9ccf14f7 | 4611 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop", |
718e3744 | 4612 | NEIGHBOR_STR |
4613 | NEIGHBOR_ADDR_STR2 | |
4614 | "Allow EBGP neighbors not on directly connected networks\n") | |
4615 | { | |
d62a17ae | 4616 | int idx_peer = 1; |
4617 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4618 | } |
4619 | ||
4620 | DEFUN (neighbor_ebgp_multihop_ttl, | |
4621 | neighbor_ebgp_multihop_ttl_cmd, | |
9ccf14f7 | 4622 | "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)", |
718e3744 | 4623 | NEIGHBOR_STR |
4624 | NEIGHBOR_ADDR_STR2 | |
4625 | "Allow EBGP neighbors not on directly connected networks\n" | |
4626 | "maximum hop count\n") | |
4627 | { | |
d62a17ae | 4628 | int idx_peer = 1; |
4629 | int idx_number = 3; | |
4630 | return peer_ebgp_multihop_set_vty(vty, argv[idx_peer]->arg, | |
4631 | argv[idx_number]->arg); | |
718e3744 | 4632 | } |
4633 | ||
4634 | DEFUN (no_neighbor_ebgp_multihop, | |
4635 | no_neighbor_ebgp_multihop_cmd, | |
a636c635 | 4636 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]", |
718e3744 | 4637 | NO_STR |
4638 | NEIGHBOR_STR | |
4639 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4640 | "Allow EBGP neighbors not on directly connected networks\n" |
4641 | "maximum hop count\n") | |
718e3744 | 4642 | { |
d62a17ae | 4643 | int idx_peer = 2; |
4644 | return peer_ebgp_multihop_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 4645 | } |
4646 | ||
6b0655a2 | 4647 | |
6ffd2079 | 4648 | /* disable-connected-check */ |
4649 | DEFUN (neighbor_disable_connected_check, | |
4650 | neighbor_disable_connected_check_cmd, | |
7ebe625c | 4651 | "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4652 | NEIGHBOR_STR |
7ebe625c | 4653 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4654 | "one-hop away EBGP peer using loopback address\n" |
4655 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4656 | { |
d62a17ae | 4657 | int idx_peer = 1; |
4658 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4659 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4660 | } |
4661 | ||
4662 | DEFUN (no_neighbor_disable_connected_check, | |
4663 | no_neighbor_disable_connected_check_cmd, | |
7ebe625c | 4664 | "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>", |
6ffd2079 | 4665 | NO_STR |
4666 | NEIGHBOR_STR | |
7ebe625c | 4667 | NEIGHBOR_ADDR_STR2 |
a636c635 DW |
4668 | "one-hop away EBGP peer using loopback address\n" |
4669 | "Enforce EBGP neighbors perform multihop\n") | |
6ffd2079 | 4670 | { |
d62a17ae | 4671 | int idx_peer = 2; |
4672 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4673 | PEER_FLAG_DISABLE_CONNECTED_CHECK); | |
6ffd2079 | 4674 | } |
4675 | ||
47cbc09b PM |
4676 | |
4677 | /* enforce-first-as */ | |
4678 | DEFUN (neighbor_enforce_first_as, | |
4679 | neighbor_enforce_first_as_cmd, | |
4680 | "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4681 | NEIGHBOR_STR | |
4682 | NEIGHBOR_ADDR_STR2 | |
4683 | "Enforce the first AS for EBGP routes\n") | |
4684 | { | |
4685 | int idx_peer = 1; | |
4686 | ||
4687 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
4688 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4689 | } | |
4690 | ||
4691 | DEFUN (no_neighbor_enforce_first_as, | |
4692 | no_neighbor_enforce_first_as_cmd, | |
4693 | "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as", | |
4694 | NO_STR | |
4695 | NEIGHBOR_STR | |
4696 | NEIGHBOR_ADDR_STR2 | |
4697 | "Enforce the first AS for EBGP routes\n") | |
4698 | { | |
4699 | int idx_peer = 2; | |
4700 | ||
4701 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
4702 | PEER_FLAG_ENFORCE_FIRST_AS); | |
4703 | } | |
4704 | ||
4705 | ||
718e3744 | 4706 | DEFUN (neighbor_description, |
4707 | neighbor_description_cmd, | |
e961923c | 4708 | "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", |
718e3744 | 4709 | NEIGHBOR_STR |
4710 | NEIGHBOR_ADDR_STR2 | |
4711 | "Neighbor specific description\n" | |
4712 | "Up to 80 characters describing this neighbor\n") | |
4713 | { | |
d62a17ae | 4714 | int idx_peer = 1; |
4715 | int idx_line = 3; | |
4716 | struct peer *peer; | |
4717 | char *str; | |
718e3744 | 4718 | |
d62a17ae | 4719 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4720 | if (!peer) | |
4721 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4722 | |
d62a17ae | 4723 | str = argv_concat(argv, argc, idx_line); |
718e3744 | 4724 | |
d62a17ae | 4725 | peer_description_set(peer, str); |
718e3744 | 4726 | |
d62a17ae | 4727 | XFREE(MTYPE_TMP, str); |
718e3744 | 4728 | |
d62a17ae | 4729 | return CMD_SUCCESS; |
718e3744 | 4730 | } |
4731 | ||
4732 | DEFUN (no_neighbor_description, | |
4733 | no_neighbor_description_cmd, | |
a14810f4 | 4734 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description", |
718e3744 | 4735 | NO_STR |
4736 | NEIGHBOR_STR | |
4737 | NEIGHBOR_ADDR_STR2 | |
a14810f4 | 4738 | "Neighbor specific description\n") |
718e3744 | 4739 | { |
d62a17ae | 4740 | int idx_peer = 2; |
4741 | struct peer *peer; | |
718e3744 | 4742 | |
d62a17ae | 4743 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
4744 | if (!peer) | |
4745 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4746 | |
d62a17ae | 4747 | peer_description_unset(peer); |
718e3744 | 4748 | |
d62a17ae | 4749 | return CMD_SUCCESS; |
718e3744 | 4750 | } |
4751 | ||
a14810f4 PM |
4752 | ALIAS(no_neighbor_description, no_neighbor_description_comment_cmd, |
4753 | "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...", | |
4754 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4755 | "Neighbor specific description\n" | |
4756 | "Up to 80 characters describing this neighbor\n") | |
6b0655a2 | 4757 | |
718e3744 | 4758 | /* Neighbor update-source. */ |
d62a17ae | 4759 | static int peer_update_source_vty(struct vty *vty, const char *peer_str, |
4760 | const char *source_str) | |
4761 | { | |
4762 | struct peer *peer; | |
4763 | struct prefix p; | |
a14810f4 | 4764 | union sockunion su; |
d62a17ae | 4765 | |
4766 | peer = peer_and_group_lookup_vty(vty, peer_str); | |
4767 | if (!peer) | |
4768 | return CMD_WARNING_CONFIG_FAILED; | |
4769 | ||
4770 | if (peer->conf_if) | |
4771 | return CMD_WARNING; | |
4772 | ||
4773 | if (source_str) { | |
a14810f4 | 4774 | if (str2sockunion(source_str, &su) == 0) |
d62a17ae | 4775 | peer_update_source_addr_set(peer, &su); |
4776 | else { | |
4777 | if (str2prefix(source_str, &p)) { | |
4778 | vty_out(vty, | |
4779 | "%% Invalid update-source, remove prefix length \n"); | |
4780 | return CMD_WARNING_CONFIG_FAILED; | |
4781 | } else | |
4782 | peer_update_source_if_set(peer, source_str); | |
4783 | } | |
4784 | } else | |
4785 | peer_update_source_unset(peer); | |
4786 | ||
4787 | return CMD_SUCCESS; | |
4788 | } | |
4789 | ||
4790 | #define BGP_UPDATE_SOURCE_HELP_STR \ | |
4791 | "IPv4 address\n" \ | |
4792 | "IPv6 address\n" \ | |
4793 | "Interface name (requires zebra to be running)\n" | |
369688c0 | 4794 | |
718e3744 | 4795 | DEFUN (neighbor_update_source, |
4796 | neighbor_update_source_cmd, | |
9ccf14f7 | 4797 | "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>", |
718e3744 | 4798 | NEIGHBOR_STR |
4799 | NEIGHBOR_ADDR_STR2 | |
4800 | "Source of routing updates\n" | |
369688c0 | 4801 | BGP_UPDATE_SOURCE_HELP_STR) |
718e3744 | 4802 | { |
d62a17ae | 4803 | int idx_peer = 1; |
4804 | int idx_peer_2 = 3; | |
4805 | return peer_update_source_vty(vty, argv[idx_peer]->arg, | |
4806 | argv[idx_peer_2]->arg); | |
718e3744 | 4807 | } |
4808 | ||
4809 | DEFUN (no_neighbor_update_source, | |
4810 | no_neighbor_update_source_cmd, | |
c7178fe7 | 4811 | "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]", |
718e3744 | 4812 | NO_STR |
4813 | NEIGHBOR_STR | |
4814 | NEIGHBOR_ADDR_STR2 | |
dcb52bd5 DS |
4815 | "Source of routing updates\n" |
4816 | BGP_UPDATE_SOURCE_HELP_STR) | |
718e3744 | 4817 | { |
d62a17ae | 4818 | int idx_peer = 2; |
4819 | return peer_update_source_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 4820 | } |
6b0655a2 | 4821 | |
d62a17ae | 4822 | static int peer_default_originate_set_vty(struct vty *vty, const char *peer_str, |
4823 | afi_t afi, safi_t safi, | |
4824 | const char *rmap, int set) | |
718e3744 | 4825 | { |
d62a17ae | 4826 | int ret; |
4827 | struct peer *peer; | |
1de27621 | 4828 | struct route_map *route_map; |
718e3744 | 4829 | |
d62a17ae | 4830 | peer = peer_and_group_lookup_vty(vty, peer_str); |
4831 | if (!peer) | |
4832 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4833 | |
1de27621 DA |
4834 | if (set) { |
4835 | route_map = route_map_lookup_warn_noexist(vty, rmap); | |
4836 | ret = peer_default_originate_set(peer, afi, safi, | |
4837 | rmap, route_map); | |
4838 | } else | |
d62a17ae | 4839 | ret = peer_default_originate_unset(peer, afi, safi); |
718e3744 | 4840 | |
d62a17ae | 4841 | return bgp_vty_return(vty, ret); |
718e3744 | 4842 | } |
4843 | ||
4844 | /* neighbor default-originate. */ | |
4845 | DEFUN (neighbor_default_originate, | |
4846 | neighbor_default_originate_cmd, | |
9ccf14f7 | 4847 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", |
718e3744 | 4848 | NEIGHBOR_STR |
4849 | NEIGHBOR_ADDR_STR2 | |
4850 | "Originate default route to this neighbor\n") | |
4851 | { | |
d62a17ae | 4852 | int idx_peer = 1; |
4853 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4854 | bgp_node_afi(vty), | |
4855 | bgp_node_safi(vty), NULL, 1); | |
718e3744 | 4856 | } |
4857 | ||
d62a17ae | 4858 | ALIAS_HIDDEN(neighbor_default_originate, neighbor_default_originate_hidden_cmd, |
4859 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate", | |
4860 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4861 | "Originate default route to this neighbor\n") | |
596c17ba | 4862 | |
718e3744 | 4863 | DEFUN (neighbor_default_originate_rmap, |
4864 | neighbor_default_originate_rmap_cmd, | |
9ccf14f7 | 4865 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", |
718e3744 | 4866 | NEIGHBOR_STR |
4867 | NEIGHBOR_ADDR_STR2 | |
4868 | "Originate default route to this neighbor\n" | |
4869 | "Route-map to specify criteria to originate default\n" | |
4870 | "route-map name\n") | |
4871 | { | |
d62a17ae | 4872 | int idx_peer = 1; |
4873 | int idx_word = 4; | |
4874 | return peer_default_originate_set_vty( | |
4875 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
4876 | argv[idx_word]->arg, 1); | |
718e3744 | 4877 | } |
4878 | ||
d62a17ae | 4879 | ALIAS_HIDDEN( |
4880 | neighbor_default_originate_rmap, | |
4881 | neighbor_default_originate_rmap_hidden_cmd, | |
4882 | "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD", | |
4883 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4884 | "Originate default route to this neighbor\n" | |
4885 | "Route-map to specify criteria to originate default\n" | |
4886 | "route-map name\n") | |
596c17ba | 4887 | |
718e3744 | 4888 | DEFUN (no_neighbor_default_originate, |
4889 | no_neighbor_default_originate_cmd, | |
a636c635 | 4890 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", |
718e3744 | 4891 | NO_STR |
4892 | NEIGHBOR_STR | |
4893 | NEIGHBOR_ADDR_STR2 | |
a636c635 DW |
4894 | "Originate default route to this neighbor\n" |
4895 | "Route-map to specify criteria to originate default\n" | |
4896 | "route-map name\n") | |
718e3744 | 4897 | { |
d62a17ae | 4898 | int idx_peer = 2; |
4899 | return peer_default_originate_set_vty(vty, argv[idx_peer]->arg, | |
4900 | bgp_node_afi(vty), | |
4901 | bgp_node_safi(vty), NULL, 0); | |
718e3744 | 4902 | } |
4903 | ||
d62a17ae | 4904 | ALIAS_HIDDEN( |
4905 | no_neighbor_default_originate, no_neighbor_default_originate_hidden_cmd, | |
4906 | "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]", | |
4907 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
4908 | "Originate default route to this neighbor\n" | |
4909 | "Route-map to specify criteria to originate default\n" | |
4910 | "route-map name\n") | |
596c17ba | 4911 | |
6b0655a2 | 4912 | |
718e3744 | 4913 | /* Set neighbor's BGP port. */ |
d62a17ae | 4914 | static int peer_port_vty(struct vty *vty, const char *ip_str, int afi, |
4915 | const char *port_str) | |
4916 | { | |
4917 | struct peer *peer; | |
d7c0a89a | 4918 | uint16_t port; |
d62a17ae | 4919 | struct servent *sp; |
4920 | ||
4921 | peer = peer_lookup_vty(vty, ip_str); | |
4922 | if (!peer) | |
4923 | return CMD_WARNING_CONFIG_FAILED; | |
4924 | ||
4925 | if (!port_str) { | |
4926 | sp = getservbyname("bgp", "tcp"); | |
4927 | port = (sp == NULL) ? BGP_PORT_DEFAULT : ntohs(sp->s_port); | |
4928 | } else { | |
4929 | port = strtoul(port_str, NULL, 10); | |
4930 | } | |
718e3744 | 4931 | |
d62a17ae | 4932 | peer_port_set(peer, port); |
718e3744 | 4933 | |
d62a17ae | 4934 | return CMD_SUCCESS; |
718e3744 | 4935 | } |
4936 | ||
f418446b | 4937 | /* Set specified peer's BGP port. */ |
718e3744 | 4938 | DEFUN (neighbor_port, |
4939 | neighbor_port_cmd, | |
9ccf14f7 | 4940 | "neighbor <A.B.C.D|X:X::X:X> port (0-65535)", |
718e3744 | 4941 | NEIGHBOR_STR |
4942 | NEIGHBOR_ADDR_STR | |
4943 | "Neighbor's BGP port\n" | |
4944 | "TCP port number\n") | |
4945 | { | |
d62a17ae | 4946 | int idx_ip = 1; |
4947 | int idx_number = 3; | |
4948 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, | |
4949 | argv[idx_number]->arg); | |
718e3744 | 4950 | } |
4951 | ||
4952 | DEFUN (no_neighbor_port, | |
4953 | no_neighbor_port_cmd, | |
9ccf14f7 | 4954 | "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]", |
718e3744 | 4955 | NO_STR |
4956 | NEIGHBOR_STR | |
4957 | NEIGHBOR_ADDR_STR | |
8334fd5a DW |
4958 | "Neighbor's BGP port\n" |
4959 | "TCP port number\n") | |
718e3744 | 4960 | { |
d62a17ae | 4961 | int idx_ip = 2; |
4962 | return peer_port_vty(vty, argv[idx_ip]->arg, AFI_IP, NULL); | |
718e3744 | 4963 | } |
4964 | ||
6b0655a2 | 4965 | |
718e3744 | 4966 | /* neighbor weight. */ |
d62a17ae | 4967 | static int peer_weight_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4968 | safi_t safi, const char *weight_str) | |
718e3744 | 4969 | { |
d62a17ae | 4970 | int ret; |
4971 | struct peer *peer; | |
4972 | unsigned long weight; | |
718e3744 | 4973 | |
d62a17ae | 4974 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4975 | if (!peer) | |
4976 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4977 | |
d62a17ae | 4978 | weight = strtoul(weight_str, NULL, 10); |
718e3744 | 4979 | |
d62a17ae | 4980 | ret = peer_weight_set(peer, afi, safi, weight); |
4981 | return bgp_vty_return(vty, ret); | |
718e3744 | 4982 | } |
4983 | ||
d62a17ae | 4984 | static int peer_weight_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
4985 | safi_t safi) | |
718e3744 | 4986 | { |
d62a17ae | 4987 | int ret; |
4988 | struct peer *peer; | |
718e3744 | 4989 | |
d62a17ae | 4990 | peer = peer_and_group_lookup_vty(vty, ip_str); |
4991 | if (!peer) | |
4992 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 4993 | |
d62a17ae | 4994 | ret = peer_weight_unset(peer, afi, safi); |
4995 | return bgp_vty_return(vty, ret); | |
718e3744 | 4996 | } |
4997 | ||
4998 | DEFUN (neighbor_weight, | |
4999 | neighbor_weight_cmd, | |
9ccf14f7 | 5000 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", |
718e3744 | 5001 | NEIGHBOR_STR |
5002 | NEIGHBOR_ADDR_STR2 | |
5003 | "Set default weight for routes from this neighbor\n" | |
5004 | "default weight\n") | |
5005 | { | |
d62a17ae | 5006 | int idx_peer = 1; |
5007 | int idx_number = 3; | |
5008 | return peer_weight_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5009 | bgp_node_safi(vty), argv[idx_number]->arg); | |
718e3744 | 5010 | } |
5011 | ||
d62a17ae | 5012 | ALIAS_HIDDEN(neighbor_weight, neighbor_weight_hidden_cmd, |
5013 | "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)", | |
5014 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5015 | "Set default weight for routes from this neighbor\n" | |
5016 | "default weight\n") | |
596c17ba | 5017 | |
718e3744 | 5018 | DEFUN (no_neighbor_weight, |
5019 | no_neighbor_weight_cmd, | |
9ccf14f7 | 5020 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", |
718e3744 | 5021 | NO_STR |
5022 | NEIGHBOR_STR | |
5023 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5024 | "Set default weight for routes from this neighbor\n" |
5025 | "default weight\n") | |
718e3744 | 5026 | { |
d62a17ae | 5027 | int idx_peer = 2; |
5028 | return peer_weight_unset_vty(vty, argv[idx_peer]->arg, | |
5029 | bgp_node_afi(vty), bgp_node_safi(vty)); | |
718e3744 | 5030 | } |
5031 | ||
d62a17ae | 5032 | ALIAS_HIDDEN(no_neighbor_weight, no_neighbor_weight_hidden_cmd, |
5033 | "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]", | |
5034 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5035 | "Set default weight for routes from this neighbor\n" | |
5036 | "default weight\n") | |
596c17ba | 5037 | |
6b0655a2 | 5038 | |
718e3744 | 5039 | /* Override capability negotiation. */ |
5040 | DEFUN (neighbor_override_capability, | |
5041 | neighbor_override_capability_cmd, | |
9ccf14f7 | 5042 | "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5043 | NEIGHBOR_STR |
5044 | NEIGHBOR_ADDR_STR2 | |
5045 | "Override capability negotiation result\n") | |
5046 | { | |
d62a17ae | 5047 | int idx_peer = 1; |
5048 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
5049 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5050 | } |
5051 | ||
5052 | DEFUN (no_neighbor_override_capability, | |
5053 | no_neighbor_override_capability_cmd, | |
9ccf14f7 | 5054 | "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability", |
718e3744 | 5055 | NO_STR |
5056 | NEIGHBOR_STR | |
5057 | NEIGHBOR_ADDR_STR2 | |
5058 | "Override capability negotiation result\n") | |
5059 | { | |
d62a17ae | 5060 | int idx_peer = 2; |
5061 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
5062 | PEER_FLAG_OVERRIDE_CAPABILITY); | |
718e3744 | 5063 | } |
6b0655a2 | 5064 | |
718e3744 | 5065 | DEFUN (neighbor_strict_capability, |
5066 | neighbor_strict_capability_cmd, | |
9fb964de | 5067 | "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5068 | NEIGHBOR_STR |
9fb964de | 5069 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5070 | "Strict capability negotiation match\n") |
5071 | { | |
9fb964de PM |
5072 | int idx_peer = 1; |
5073 | ||
5074 | return peer_flag_set_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5075 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5076 | } |
5077 | ||
5078 | DEFUN (no_neighbor_strict_capability, | |
5079 | no_neighbor_strict_capability_cmd, | |
9fb964de | 5080 | "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match", |
718e3744 | 5081 | NO_STR |
5082 | NEIGHBOR_STR | |
9fb964de | 5083 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5084 | "Strict capability negotiation match\n") |
5085 | { | |
9fb964de PM |
5086 | int idx_peer = 2; |
5087 | ||
5088 | return peer_flag_unset_vty(vty, argv[idx_peer]->arg, | |
d62a17ae | 5089 | PEER_FLAG_STRICT_CAP_MATCH); |
718e3744 | 5090 | } |
6b0655a2 | 5091 | |
d62a17ae | 5092 | static int peer_timers_set_vty(struct vty *vty, const char *ip_str, |
5093 | const char *keep_str, const char *hold_str) | |
718e3744 | 5094 | { |
d62a17ae | 5095 | int ret; |
5096 | struct peer *peer; | |
d7c0a89a QY |
5097 | uint32_t keepalive; |
5098 | uint32_t holdtime; | |
718e3744 | 5099 | |
d62a17ae | 5100 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5101 | if (!peer) | |
5102 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5103 | |
d62a17ae | 5104 | keepalive = strtoul(keep_str, NULL, 10); |
5105 | holdtime = strtoul(hold_str, NULL, 10); | |
718e3744 | 5106 | |
d62a17ae | 5107 | ret = peer_timers_set(peer, keepalive, holdtime); |
718e3744 | 5108 | |
d62a17ae | 5109 | return bgp_vty_return(vty, ret); |
718e3744 | 5110 | } |
6b0655a2 | 5111 | |
d62a17ae | 5112 | static int peer_timers_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5113 | { |
d62a17ae | 5114 | int ret; |
5115 | struct peer *peer; | |
718e3744 | 5116 | |
d62a17ae | 5117 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5118 | if (!peer) | |
5119 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5120 | |
d62a17ae | 5121 | ret = peer_timers_unset(peer); |
718e3744 | 5122 | |
d62a17ae | 5123 | return bgp_vty_return(vty, ret); |
718e3744 | 5124 | } |
5125 | ||
5126 | DEFUN (neighbor_timers, | |
5127 | neighbor_timers_cmd, | |
9ccf14f7 | 5128 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)", |
718e3744 | 5129 | NEIGHBOR_STR |
5130 | NEIGHBOR_ADDR_STR2 | |
5131 | "BGP per neighbor timers\n" | |
5132 | "Keepalive interval\n" | |
5133 | "Holdtime\n") | |
5134 | { | |
d62a17ae | 5135 | int idx_peer = 1; |
5136 | int idx_number = 3; | |
5137 | int idx_number_2 = 4; | |
5138 | return peer_timers_set_vty(vty, argv[idx_peer]->arg, | |
5139 | argv[idx_number]->arg, | |
5140 | argv[idx_number_2]->arg); | |
718e3744 | 5141 | } |
5142 | ||
5143 | DEFUN (no_neighbor_timers, | |
5144 | no_neighbor_timers_cmd, | |
9ccf14f7 | 5145 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]", |
718e3744 | 5146 | NO_STR |
5147 | NEIGHBOR_STR | |
5148 | NEIGHBOR_ADDR_STR2 | |
8334fd5a DW |
5149 | "BGP per neighbor timers\n" |
5150 | "Keepalive interval\n" | |
5151 | "Holdtime\n") | |
718e3744 | 5152 | { |
d62a17ae | 5153 | int idx_peer = 2; |
5154 | return peer_timers_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5155 | } |
6b0655a2 | 5156 | |
813d4307 | 5157 | |
d62a17ae | 5158 | static int peer_timers_connect_set_vty(struct vty *vty, const char *ip_str, |
5159 | const char *time_str) | |
718e3744 | 5160 | { |
d62a17ae | 5161 | int ret; |
5162 | struct peer *peer; | |
d7c0a89a | 5163 | uint32_t connect; |
718e3744 | 5164 | |
d62a17ae | 5165 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5166 | if (!peer) | |
5167 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5168 | |
d62a17ae | 5169 | connect = strtoul(time_str, NULL, 10); |
718e3744 | 5170 | |
d62a17ae | 5171 | ret = peer_timers_connect_set(peer, connect); |
718e3744 | 5172 | |
d62a17ae | 5173 | return bgp_vty_return(vty, ret); |
718e3744 | 5174 | } |
5175 | ||
d62a17ae | 5176 | static int peer_timers_connect_unset_vty(struct vty *vty, const char *ip_str) |
718e3744 | 5177 | { |
d62a17ae | 5178 | int ret; |
5179 | struct peer *peer; | |
718e3744 | 5180 | |
d62a17ae | 5181 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5182 | if (!peer) | |
5183 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5184 | |
d62a17ae | 5185 | ret = peer_timers_connect_unset(peer); |
718e3744 | 5186 | |
d62a17ae | 5187 | return bgp_vty_return(vty, ret); |
718e3744 | 5188 | } |
5189 | ||
5190 | DEFUN (neighbor_timers_connect, | |
5191 | neighbor_timers_connect_cmd, | |
9ccf14f7 | 5192 | "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)", |
718e3744 | 5193 | NEIGHBOR_STR |
966f821c | 5194 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5195 | "BGP per neighbor timers\n" |
5196 | "BGP connect timer\n" | |
5197 | "Connect timer\n") | |
5198 | { | |
d62a17ae | 5199 | int idx_peer = 1; |
5200 | int idx_number = 4; | |
5201 | return peer_timers_connect_set_vty(vty, argv[idx_peer]->arg, | |
5202 | argv[idx_number]->arg); | |
718e3744 | 5203 | } |
5204 | ||
5205 | DEFUN (no_neighbor_timers_connect, | |
5206 | no_neighbor_timers_connect_cmd, | |
9ccf14f7 | 5207 | "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]", |
718e3744 | 5208 | NO_STR |
5209 | NEIGHBOR_STR | |
966f821c | 5210 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5211 | "BGP per neighbor timers\n" |
8334fd5a DW |
5212 | "BGP connect timer\n" |
5213 | "Connect timer\n") | |
718e3744 | 5214 | { |
d62a17ae | 5215 | int idx_peer = 2; |
5216 | return peer_timers_connect_unset_vty(vty, argv[idx_peer]->arg); | |
718e3744 | 5217 | } |
5218 | ||
6b0655a2 | 5219 | |
d62a17ae | 5220 | static int peer_advertise_interval_vty(struct vty *vty, const char *ip_str, |
5221 | const char *time_str, int set) | |
718e3744 | 5222 | { |
d62a17ae | 5223 | int ret; |
5224 | struct peer *peer; | |
d7c0a89a | 5225 | uint32_t routeadv = 0; |
718e3744 | 5226 | |
d62a17ae | 5227 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5228 | if (!peer) | |
5229 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5230 | |
d62a17ae | 5231 | if (time_str) |
5232 | routeadv = strtoul(time_str, NULL, 10); | |
718e3744 | 5233 | |
d62a17ae | 5234 | if (set) |
5235 | ret = peer_advertise_interval_set(peer, routeadv); | |
5236 | else | |
5237 | ret = peer_advertise_interval_unset(peer); | |
718e3744 | 5238 | |
d62a17ae | 5239 | return bgp_vty_return(vty, ret); |
718e3744 | 5240 | } |
5241 | ||
5242 | DEFUN (neighbor_advertise_interval, | |
5243 | neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5244 | "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)", |
718e3744 | 5245 | NEIGHBOR_STR |
966f821c | 5246 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5247 | "Minimum interval between sending BGP routing updates\n" |
5248 | "time in seconds\n") | |
5249 | { | |
d62a17ae | 5250 | int idx_peer = 1; |
5251 | int idx_number = 3; | |
5252 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, | |
5253 | argv[idx_number]->arg, 1); | |
718e3744 | 5254 | } |
5255 | ||
5256 | DEFUN (no_neighbor_advertise_interval, | |
5257 | no_neighbor_advertise_interval_cmd, | |
9ccf14f7 | 5258 | "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]", |
718e3744 | 5259 | NO_STR |
5260 | NEIGHBOR_STR | |
966f821c | 5261 | NEIGHBOR_ADDR_STR2 |
8334fd5a DW |
5262 | "Minimum interval between sending BGP routing updates\n" |
5263 | "time in seconds\n") | |
718e3744 | 5264 | { |
d62a17ae | 5265 | int idx_peer = 2; |
5266 | return peer_advertise_interval_vty(vty, argv[idx_peer]->arg, NULL, 0); | |
718e3744 | 5267 | } |
5268 | ||
6b0655a2 | 5269 | |
518f0eb1 DS |
5270 | /* Time to wait before processing route-map updates */ |
5271 | DEFUN (bgp_set_route_map_delay_timer, | |
5272 | bgp_set_route_map_delay_timer_cmd, | |
6147e2c6 | 5273 | "bgp route-map delay-timer (0-600)", |
518f0eb1 DS |
5274 | SET_STR |
5275 | "BGP route-map delay timer\n" | |
5276 | "Time in secs to wait before processing route-map changes\n" | |
f414725f | 5277 | "0 disables the timer, no route updates happen when route-maps change\n") |
518f0eb1 | 5278 | { |
d62a17ae | 5279 | int idx_number = 3; |
d7c0a89a | 5280 | uint32_t rmap_delay_timer; |
d62a17ae | 5281 | |
5282 | if (argv[idx_number]->arg) { | |
5283 | rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10); | |
5284 | bm->rmap_update_timer = rmap_delay_timer; | |
5285 | ||
5286 | /* if the dynamic update handling is being disabled, and a timer | |
5287 | * is | |
5288 | * running, stop the timer and act as if the timer has already | |
5289 | * fired. | |
5290 | */ | |
5291 | if (!rmap_delay_timer && bm->t_rmap_update) { | |
5292 | BGP_TIMER_OFF(bm->t_rmap_update); | |
5293 | thread_execute(bm->master, bgp_route_map_update_timer, | |
5294 | NULL, 0); | |
5295 | } | |
5296 | return CMD_SUCCESS; | |
5297 | } else { | |
5298 | vty_out(vty, "%% BGP invalid route-map delay-timer\n"); | |
5299 | return CMD_WARNING_CONFIG_FAILED; | |
518f0eb1 | 5300 | } |
518f0eb1 DS |
5301 | } |
5302 | ||
5303 | DEFUN (no_bgp_set_route_map_delay_timer, | |
5304 | no_bgp_set_route_map_delay_timer_cmd, | |
8334fd5a | 5305 | "no bgp route-map delay-timer [(0-600)]", |
518f0eb1 | 5306 | NO_STR |
3a2d747c | 5307 | BGP_STR |
518f0eb1 | 5308 | "Default BGP route-map delay timer\n" |
8334fd5a DW |
5309 | "Reset to default time to wait for processing route-map changes\n" |
5310 | "0 disables the timer, no route updates happen when route-maps change\n") | |
518f0eb1 | 5311 | { |
518f0eb1 | 5312 | |
d62a17ae | 5313 | bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; |
518f0eb1 | 5314 | |
d62a17ae | 5315 | return CMD_SUCCESS; |
518f0eb1 DS |
5316 | } |
5317 | ||
f414725f | 5318 | |
718e3744 | 5319 | /* neighbor interface */ |
d62a17ae | 5320 | static int peer_interface_vty(struct vty *vty, const char *ip_str, |
5321 | const char *str) | |
718e3744 | 5322 | { |
d62a17ae | 5323 | struct peer *peer; |
718e3744 | 5324 | |
d62a17ae | 5325 | peer = peer_lookup_vty(vty, ip_str); |
5326 | if (!peer || peer->conf_if) { | |
5327 | vty_out(vty, "%% BGP invalid peer %s\n", ip_str); | |
5328 | return CMD_WARNING_CONFIG_FAILED; | |
5329 | } | |
718e3744 | 5330 | |
d62a17ae | 5331 | if (str) |
5332 | peer_interface_set(peer, str); | |
5333 | else | |
5334 | peer_interface_unset(peer); | |
718e3744 | 5335 | |
d62a17ae | 5336 | return CMD_SUCCESS; |
718e3744 | 5337 | } |
5338 | ||
5339 | DEFUN (neighbor_interface, | |
5340 | neighbor_interface_cmd, | |
9ccf14f7 | 5341 | "neighbor <A.B.C.D|X:X::X:X> interface WORD", |
718e3744 | 5342 | NEIGHBOR_STR |
5343 | NEIGHBOR_ADDR_STR | |
5344 | "Interface\n" | |
5345 | "Interface name\n") | |
5346 | { | |
d62a17ae | 5347 | int idx_ip = 1; |
5348 | int idx_word = 3; | |
5349 | return peer_interface_vty(vty, argv[idx_ip]->arg, argv[idx_word]->arg); | |
718e3744 | 5350 | } |
5351 | ||
5352 | DEFUN (no_neighbor_interface, | |
5353 | no_neighbor_interface_cmd, | |
9ccf14f7 | 5354 | "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD", |
718e3744 | 5355 | NO_STR |
5356 | NEIGHBOR_STR | |
16cedbb0 | 5357 | NEIGHBOR_ADDR_STR2 |
718e3744 | 5358 | "Interface\n" |
5359 | "Interface name\n") | |
5360 | { | |
d62a17ae | 5361 | int idx_peer = 2; |
5362 | return peer_interface_vty(vty, argv[idx_peer]->arg, NULL); | |
718e3744 | 5363 | } |
6b0655a2 | 5364 | |
718e3744 | 5365 | DEFUN (neighbor_distribute_list, |
5366 | neighbor_distribute_list_cmd, | |
9ccf14f7 | 5367 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5368 | NEIGHBOR_STR |
5369 | NEIGHBOR_ADDR_STR2 | |
5370 | "Filter updates to/from this neighbor\n" | |
5371 | "IP access-list number\n" | |
5372 | "IP access-list number (expanded range)\n" | |
5373 | "IP Access-list name\n" | |
5374 | "Filter incoming updates\n" | |
5375 | "Filter outgoing updates\n") | |
5376 | { | |
d62a17ae | 5377 | int idx_peer = 1; |
5378 | int idx_acl = 3; | |
5379 | int direct, ret; | |
5380 | struct peer *peer; | |
a8206004 | 5381 | |
d62a17ae | 5382 | const char *pstr = argv[idx_peer]->arg; |
5383 | const char *acl = argv[idx_acl]->arg; | |
5384 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5385 | |
d62a17ae | 5386 | peer = peer_and_group_lookup_vty(vty, pstr); |
5387 | if (!peer) | |
5388 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5389 | |
d62a17ae | 5390 | /* Check filter direction. */ |
5391 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5392 | ret = peer_distribute_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5393 | direct, acl); | |
a8206004 | 5394 | |
d62a17ae | 5395 | return bgp_vty_return(vty, ret); |
718e3744 | 5396 | } |
5397 | ||
d62a17ae | 5398 | ALIAS_HIDDEN( |
5399 | neighbor_distribute_list, neighbor_distribute_list_hidden_cmd, | |
5400 | "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5401 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5402 | "Filter updates to/from this neighbor\n" | |
5403 | "IP access-list number\n" | |
5404 | "IP access-list number (expanded range)\n" | |
5405 | "IP Access-list name\n" | |
5406 | "Filter incoming updates\n" | |
5407 | "Filter outgoing updates\n") | |
596c17ba | 5408 | |
718e3744 | 5409 | DEFUN (no_neighbor_distribute_list, |
5410 | no_neighbor_distribute_list_cmd, | |
9ccf14f7 | 5411 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", |
718e3744 | 5412 | NO_STR |
5413 | NEIGHBOR_STR | |
5414 | NEIGHBOR_ADDR_STR2 | |
5415 | "Filter updates to/from this neighbor\n" | |
5416 | "IP access-list number\n" | |
5417 | "IP access-list number (expanded range)\n" | |
5418 | "IP Access-list name\n" | |
5419 | "Filter incoming updates\n" | |
5420 | "Filter outgoing updates\n") | |
5421 | { | |
d62a17ae | 5422 | int idx_peer = 2; |
5423 | int direct, ret; | |
5424 | struct peer *peer; | |
a8206004 | 5425 | |
d62a17ae | 5426 | const char *pstr = argv[idx_peer]->arg; |
5427 | const char *inout = argv[argc - 1]->text; | |
a8206004 | 5428 | |
d62a17ae | 5429 | peer = peer_and_group_lookup_vty(vty, pstr); |
5430 | if (!peer) | |
5431 | return CMD_WARNING_CONFIG_FAILED; | |
a8206004 | 5432 | |
d62a17ae | 5433 | /* Check filter direction. */ |
5434 | direct = strmatch(inout, "in") ? FILTER_IN : FILTER_OUT; | |
5435 | ret = peer_distribute_unset(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
5436 | direct); | |
a8206004 | 5437 | |
d62a17ae | 5438 | return bgp_vty_return(vty, ret); |
718e3744 | 5439 | } |
6b0655a2 | 5440 | |
d62a17ae | 5441 | ALIAS_HIDDEN( |
5442 | no_neighbor_distribute_list, no_neighbor_distribute_list_hidden_cmd, | |
5443 | "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>", | |
5444 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5445 | "Filter updates to/from this neighbor\n" | |
5446 | "IP access-list number\n" | |
5447 | "IP access-list number (expanded range)\n" | |
5448 | "IP Access-list name\n" | |
5449 | "Filter incoming updates\n" | |
5450 | "Filter outgoing updates\n") | |
596c17ba | 5451 | |
718e3744 | 5452 | /* Set prefix list to the peer. */ |
d62a17ae | 5453 | static int peer_prefix_list_set_vty(struct vty *vty, const char *ip_str, |
5454 | afi_t afi, safi_t safi, | |
5455 | const char *name_str, | |
5456 | const char *direct_str) | |
718e3744 | 5457 | { |
d62a17ae | 5458 | int ret; |
d62a17ae | 5459 | int direct = FILTER_IN; |
cf9ac8bf | 5460 | struct peer *peer; |
718e3744 | 5461 | |
d62a17ae | 5462 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5463 | if (!peer) | |
5464 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5465 | |
d62a17ae | 5466 | /* Check filter direction. */ |
5467 | if (strncmp(direct_str, "i", 1) == 0) | |
5468 | direct = FILTER_IN; | |
5469 | else if (strncmp(direct_str, "o", 1) == 0) | |
5470 | direct = FILTER_OUT; | |
718e3744 | 5471 | |
d62a17ae | 5472 | ret = peer_prefix_list_set(peer, afi, safi, direct, name_str); |
718e3744 | 5473 | |
d62a17ae | 5474 | return bgp_vty_return(vty, ret); |
718e3744 | 5475 | } |
5476 | ||
d62a17ae | 5477 | static int peer_prefix_list_unset_vty(struct vty *vty, const char *ip_str, |
5478 | afi_t afi, safi_t safi, | |
5479 | const char *direct_str) | |
718e3744 | 5480 | { |
d62a17ae | 5481 | int ret; |
5482 | struct peer *peer; | |
5483 | int direct = FILTER_IN; | |
718e3744 | 5484 | |
d62a17ae | 5485 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5486 | if (!peer) | |
5487 | return CMD_WARNING_CONFIG_FAILED; | |
e52702f2 | 5488 | |
d62a17ae | 5489 | /* Check filter direction. */ |
5490 | if (strncmp(direct_str, "i", 1) == 0) | |
5491 | direct = FILTER_IN; | |
5492 | else if (strncmp(direct_str, "o", 1) == 0) | |
5493 | direct = FILTER_OUT; | |
718e3744 | 5494 | |
d62a17ae | 5495 | ret = peer_prefix_list_unset(peer, afi, safi, direct); |
718e3744 | 5496 | |
d62a17ae | 5497 | return bgp_vty_return(vty, ret); |
718e3744 | 5498 | } |
5499 | ||
5500 | DEFUN (neighbor_prefix_list, | |
5501 | neighbor_prefix_list_cmd, | |
9ccf14f7 | 5502 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5503 | NEIGHBOR_STR |
5504 | NEIGHBOR_ADDR_STR2 | |
5505 | "Filter updates to/from this neighbor\n" | |
5506 | "Name of a prefix list\n" | |
5507 | "Filter incoming updates\n" | |
5508 | "Filter outgoing updates\n") | |
5509 | { | |
d62a17ae | 5510 | int idx_peer = 1; |
5511 | int idx_word = 3; | |
5512 | int idx_in_out = 4; | |
5513 | return peer_prefix_list_set_vty( | |
5514 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5515 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5516 | } |
5517 | ||
d62a17ae | 5518 | ALIAS_HIDDEN(neighbor_prefix_list, neighbor_prefix_list_hidden_cmd, |
5519 | "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5520 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5521 | "Filter updates to/from this neighbor\n" | |
5522 | "Name of a prefix list\n" | |
5523 | "Filter incoming updates\n" | |
5524 | "Filter outgoing updates\n") | |
596c17ba | 5525 | |
718e3744 | 5526 | DEFUN (no_neighbor_prefix_list, |
5527 | no_neighbor_prefix_list_cmd, | |
9ccf14f7 | 5528 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", |
718e3744 | 5529 | NO_STR |
5530 | NEIGHBOR_STR | |
5531 | NEIGHBOR_ADDR_STR2 | |
5532 | "Filter updates to/from this neighbor\n" | |
5533 | "Name of a prefix list\n" | |
5534 | "Filter incoming updates\n" | |
5535 | "Filter outgoing updates\n") | |
5536 | { | |
d62a17ae | 5537 | int idx_peer = 2; |
5538 | int idx_in_out = 5; | |
5539 | return peer_prefix_list_unset_vty(vty, argv[idx_peer]->arg, | |
5540 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5541 | argv[idx_in_out]->arg); | |
718e3744 | 5542 | } |
6b0655a2 | 5543 | |
d62a17ae | 5544 | ALIAS_HIDDEN(no_neighbor_prefix_list, no_neighbor_prefix_list_hidden_cmd, |
5545 | "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>", | |
5546 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5547 | "Filter updates to/from this neighbor\n" | |
5548 | "Name of a prefix list\n" | |
5549 | "Filter incoming updates\n" | |
5550 | "Filter outgoing updates\n") | |
596c17ba | 5551 | |
d62a17ae | 5552 | static int peer_aslist_set_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5553 | safi_t safi, const char *name_str, | |
5554 | const char *direct_str) | |
718e3744 | 5555 | { |
d62a17ae | 5556 | int ret; |
5557 | struct peer *peer; | |
5558 | int direct = FILTER_IN; | |
718e3744 | 5559 | |
d62a17ae | 5560 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5561 | if (!peer) | |
5562 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5563 | |
d62a17ae | 5564 | /* Check filter direction. */ |
5565 | if (strncmp(direct_str, "i", 1) == 0) | |
5566 | direct = FILTER_IN; | |
5567 | else if (strncmp(direct_str, "o", 1) == 0) | |
5568 | direct = FILTER_OUT; | |
718e3744 | 5569 | |
d62a17ae | 5570 | ret = peer_aslist_set(peer, afi, safi, direct, name_str); |
718e3744 | 5571 | |
d62a17ae | 5572 | return bgp_vty_return(vty, ret); |
718e3744 | 5573 | } |
5574 | ||
d62a17ae | 5575 | static int peer_aslist_unset_vty(struct vty *vty, const char *ip_str, afi_t afi, |
5576 | safi_t safi, const char *direct_str) | |
718e3744 | 5577 | { |
d62a17ae | 5578 | int ret; |
5579 | struct peer *peer; | |
5580 | int direct = FILTER_IN; | |
718e3744 | 5581 | |
d62a17ae | 5582 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5583 | if (!peer) | |
5584 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5585 | |
d62a17ae | 5586 | /* Check filter direction. */ |
5587 | if (strncmp(direct_str, "i", 1) == 0) | |
5588 | direct = FILTER_IN; | |
5589 | else if (strncmp(direct_str, "o", 1) == 0) | |
5590 | direct = FILTER_OUT; | |
718e3744 | 5591 | |
d62a17ae | 5592 | ret = peer_aslist_unset(peer, afi, safi, direct); |
718e3744 | 5593 | |
d62a17ae | 5594 | return bgp_vty_return(vty, ret); |
718e3744 | 5595 | } |
5596 | ||
5597 | DEFUN (neighbor_filter_list, | |
5598 | neighbor_filter_list_cmd, | |
9ccf14f7 | 5599 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5600 | NEIGHBOR_STR |
5601 | NEIGHBOR_ADDR_STR2 | |
5602 | "Establish BGP filters\n" | |
5603 | "AS path access-list name\n" | |
5604 | "Filter incoming routes\n" | |
5605 | "Filter outgoing routes\n") | |
5606 | { | |
d62a17ae | 5607 | int idx_peer = 1; |
5608 | int idx_word = 3; | |
5609 | int idx_in_out = 4; | |
5610 | return peer_aslist_set_vty(vty, argv[idx_peer]->arg, bgp_node_afi(vty), | |
5611 | bgp_node_safi(vty), argv[idx_word]->arg, | |
5612 | argv[idx_in_out]->arg); | |
718e3744 | 5613 | } |
5614 | ||
d62a17ae | 5615 | ALIAS_HIDDEN(neighbor_filter_list, neighbor_filter_list_hidden_cmd, |
5616 | "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5617 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5618 | "Establish BGP filters\n" | |
5619 | "AS path access-list name\n" | |
5620 | "Filter incoming routes\n" | |
5621 | "Filter outgoing routes\n") | |
596c17ba | 5622 | |
718e3744 | 5623 | DEFUN (no_neighbor_filter_list, |
5624 | no_neighbor_filter_list_cmd, | |
9ccf14f7 | 5625 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", |
718e3744 | 5626 | NO_STR |
5627 | NEIGHBOR_STR | |
5628 | NEIGHBOR_ADDR_STR2 | |
5629 | "Establish BGP filters\n" | |
5630 | "AS path access-list name\n" | |
5631 | "Filter incoming routes\n" | |
5632 | "Filter outgoing routes\n") | |
5633 | { | |
d62a17ae | 5634 | int idx_peer = 2; |
5635 | int idx_in_out = 5; | |
5636 | return peer_aslist_unset_vty(vty, argv[idx_peer]->arg, | |
5637 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5638 | argv[idx_in_out]->arg); | |
718e3744 | 5639 | } |
6b0655a2 | 5640 | |
d62a17ae | 5641 | ALIAS_HIDDEN(no_neighbor_filter_list, no_neighbor_filter_list_hidden_cmd, |
5642 | "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>", | |
5643 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5644 | "Establish BGP filters\n" | |
5645 | "AS path access-list name\n" | |
5646 | "Filter incoming routes\n" | |
5647 | "Filter outgoing routes\n") | |
596c17ba | 5648 | |
718e3744 | 5649 | /* Set route-map to the peer. */ |
d62a17ae | 5650 | static int peer_route_map_set_vty(struct vty *vty, const char *ip_str, |
5651 | afi_t afi, safi_t safi, const char *name_str, | |
5652 | const char *direct_str) | |
718e3744 | 5653 | { |
d62a17ae | 5654 | int ret; |
5655 | struct peer *peer; | |
5656 | int direct = RMAP_IN; | |
1de27621 | 5657 | struct route_map *route_map; |
718e3744 | 5658 | |
d62a17ae | 5659 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5660 | if (!peer) | |
5661 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5662 | |
d62a17ae | 5663 | /* Check filter direction. */ |
5664 | if (strncmp(direct_str, "in", 2) == 0) | |
5665 | direct = RMAP_IN; | |
5666 | else if (strncmp(direct_str, "o", 1) == 0) | |
5667 | direct = RMAP_OUT; | |
718e3744 | 5668 | |
1de27621 DA |
5669 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
5670 | ret = peer_route_map_set(peer, afi, safi, direct, name_str, route_map); | |
718e3744 | 5671 | |
d62a17ae | 5672 | return bgp_vty_return(vty, ret); |
718e3744 | 5673 | } |
5674 | ||
d62a17ae | 5675 | static int peer_route_map_unset_vty(struct vty *vty, const char *ip_str, |
5676 | afi_t afi, safi_t safi, | |
5677 | const char *direct_str) | |
718e3744 | 5678 | { |
d62a17ae | 5679 | int ret; |
5680 | struct peer *peer; | |
5681 | int direct = RMAP_IN; | |
718e3744 | 5682 | |
d62a17ae | 5683 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5684 | if (!peer) | |
5685 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5686 | |
d62a17ae | 5687 | /* Check filter direction. */ |
5688 | if (strncmp(direct_str, "in", 2) == 0) | |
5689 | direct = RMAP_IN; | |
5690 | else if (strncmp(direct_str, "o", 1) == 0) | |
5691 | direct = RMAP_OUT; | |
718e3744 | 5692 | |
d62a17ae | 5693 | ret = peer_route_map_unset(peer, afi, safi, direct); |
718e3744 | 5694 | |
d62a17ae | 5695 | return bgp_vty_return(vty, ret); |
718e3744 | 5696 | } |
5697 | ||
5698 | DEFUN (neighbor_route_map, | |
5699 | neighbor_route_map_cmd, | |
9ccf14f7 | 5700 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5701 | NEIGHBOR_STR |
5702 | NEIGHBOR_ADDR_STR2 | |
5703 | "Apply route map to neighbor\n" | |
5704 | "Name of route map\n" | |
5705 | "Apply map to incoming routes\n" | |
2a3d5731 | 5706 | "Apply map to outbound routes\n") |
718e3744 | 5707 | { |
d62a17ae | 5708 | int idx_peer = 1; |
5709 | int idx_word = 3; | |
5710 | int idx_in_out = 4; | |
5711 | return peer_route_map_set_vty( | |
5712 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5713 | argv[idx_word]->arg, argv[idx_in_out]->arg); | |
718e3744 | 5714 | } |
5715 | ||
d62a17ae | 5716 | ALIAS_HIDDEN(neighbor_route_map, neighbor_route_map_hidden_cmd, |
5717 | "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5718 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5719 | "Apply route map to neighbor\n" | |
5720 | "Name of route map\n" | |
5721 | "Apply map to incoming routes\n" | |
5722 | "Apply map to outbound routes\n") | |
596c17ba | 5723 | |
718e3744 | 5724 | DEFUN (no_neighbor_route_map, |
5725 | no_neighbor_route_map_cmd, | |
9ccf14f7 | 5726 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", |
718e3744 | 5727 | NO_STR |
5728 | NEIGHBOR_STR | |
5729 | NEIGHBOR_ADDR_STR2 | |
5730 | "Apply route map to neighbor\n" | |
5731 | "Name of route map\n" | |
5732 | "Apply map to incoming routes\n" | |
2a3d5731 | 5733 | "Apply map to outbound routes\n") |
718e3744 | 5734 | { |
d62a17ae | 5735 | int idx_peer = 2; |
5736 | int idx_in_out = 5; | |
5737 | return peer_route_map_unset_vty(vty, argv[idx_peer]->arg, | |
5738 | bgp_node_afi(vty), bgp_node_safi(vty), | |
5739 | argv[idx_in_out]->arg); | |
718e3744 | 5740 | } |
6b0655a2 | 5741 | |
d62a17ae | 5742 | ALIAS_HIDDEN(no_neighbor_route_map, no_neighbor_route_map_hidden_cmd, |
5743 | "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>", | |
5744 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5745 | "Apply route map to neighbor\n" | |
5746 | "Name of route map\n" | |
5747 | "Apply map to incoming routes\n" | |
5748 | "Apply map to outbound routes\n") | |
596c17ba | 5749 | |
718e3744 | 5750 | /* Set unsuppress-map to the peer. */ |
d62a17ae | 5751 | static int peer_unsuppress_map_set_vty(struct vty *vty, const char *ip_str, |
5752 | afi_t afi, safi_t safi, | |
5753 | const char *name_str) | |
718e3744 | 5754 | { |
d62a17ae | 5755 | int ret; |
5756 | struct peer *peer; | |
1de27621 | 5757 | struct route_map *route_map; |
718e3744 | 5758 | |
d62a17ae | 5759 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5760 | if (!peer) | |
5761 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5762 | |
1de27621 DA |
5763 | route_map = route_map_lookup_warn_noexist(vty, name_str); |
5764 | ret = peer_unsuppress_map_set(peer, afi, safi, name_str, route_map); | |
718e3744 | 5765 | |
d62a17ae | 5766 | return bgp_vty_return(vty, ret); |
718e3744 | 5767 | } |
5768 | ||
5769 | /* Unset route-map from the peer. */ | |
d62a17ae | 5770 | static int peer_unsuppress_map_unset_vty(struct vty *vty, const char *ip_str, |
5771 | afi_t afi, safi_t safi) | |
718e3744 | 5772 | { |
d62a17ae | 5773 | int ret; |
5774 | struct peer *peer; | |
718e3744 | 5775 | |
d62a17ae | 5776 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5777 | if (!peer) | |
5778 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5779 | |
d62a17ae | 5780 | ret = peer_unsuppress_map_unset(peer, afi, safi); |
718e3744 | 5781 | |
d62a17ae | 5782 | return bgp_vty_return(vty, ret); |
718e3744 | 5783 | } |
5784 | ||
5785 | DEFUN (neighbor_unsuppress_map, | |
5786 | neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5787 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5788 | NEIGHBOR_STR |
5789 | NEIGHBOR_ADDR_STR2 | |
5790 | "Route-map to selectively unsuppress suppressed routes\n" | |
5791 | "Name of route map\n") | |
5792 | { | |
d62a17ae | 5793 | int idx_peer = 1; |
5794 | int idx_word = 3; | |
5795 | return peer_unsuppress_map_set_vty( | |
5796 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5797 | argv[idx_word]->arg); | |
718e3744 | 5798 | } |
5799 | ||
d62a17ae | 5800 | ALIAS_HIDDEN(neighbor_unsuppress_map, neighbor_unsuppress_map_hidden_cmd, |
5801 | "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5802 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5803 | "Route-map to selectively unsuppress suppressed routes\n" | |
5804 | "Name of route map\n") | |
596c17ba | 5805 | |
718e3744 | 5806 | DEFUN (no_neighbor_unsuppress_map, |
5807 | no_neighbor_unsuppress_map_cmd, | |
9ccf14f7 | 5808 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", |
718e3744 | 5809 | NO_STR |
5810 | NEIGHBOR_STR | |
5811 | NEIGHBOR_ADDR_STR2 | |
5812 | "Route-map to selectively unsuppress suppressed routes\n" | |
5813 | "Name of route map\n") | |
5814 | { | |
d62a17ae | 5815 | int idx_peer = 2; |
5816 | return peer_unsuppress_map_unset_vty(vty, argv[idx_peer]->arg, | |
5817 | bgp_node_afi(vty), | |
5818 | bgp_node_safi(vty)); | |
718e3744 | 5819 | } |
6b0655a2 | 5820 | |
d62a17ae | 5821 | ALIAS_HIDDEN(no_neighbor_unsuppress_map, no_neighbor_unsuppress_map_hidden_cmd, |
5822 | "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD", | |
5823 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5824 | "Route-map to selectively unsuppress suppressed routes\n" | |
5825 | "Name of route map\n") | |
596c17ba | 5826 | |
d62a17ae | 5827 | static int peer_maximum_prefix_set_vty(struct vty *vty, const char *ip_str, |
5828 | afi_t afi, safi_t safi, | |
5829 | const char *num_str, | |
5830 | const char *threshold_str, int warning, | |
5831 | const char *restart_str) | |
718e3744 | 5832 | { |
d62a17ae | 5833 | int ret; |
5834 | struct peer *peer; | |
d7c0a89a QY |
5835 | uint32_t max; |
5836 | uint8_t threshold; | |
5837 | uint16_t restart; | |
718e3744 | 5838 | |
d62a17ae | 5839 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5840 | if (!peer) | |
5841 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5842 | |
d62a17ae | 5843 | max = strtoul(num_str, NULL, 10); |
5844 | if (threshold_str) | |
5845 | threshold = atoi(threshold_str); | |
5846 | else | |
5847 | threshold = MAXIMUM_PREFIX_THRESHOLD_DEFAULT; | |
718e3744 | 5848 | |
d62a17ae | 5849 | if (restart_str) |
5850 | restart = atoi(restart_str); | |
5851 | else | |
5852 | restart = 0; | |
0a486e5f | 5853 | |
d62a17ae | 5854 | ret = peer_maximum_prefix_set(peer, afi, safi, max, threshold, warning, |
5855 | restart); | |
718e3744 | 5856 | |
d62a17ae | 5857 | return bgp_vty_return(vty, ret); |
718e3744 | 5858 | } |
5859 | ||
d62a17ae | 5860 | static int peer_maximum_prefix_unset_vty(struct vty *vty, const char *ip_str, |
5861 | afi_t afi, safi_t safi) | |
718e3744 | 5862 | { |
d62a17ae | 5863 | int ret; |
5864 | struct peer *peer; | |
718e3744 | 5865 | |
d62a17ae | 5866 | peer = peer_and_group_lookup_vty(vty, ip_str); |
5867 | if (!peer) | |
5868 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 5869 | |
d62a17ae | 5870 | ret = peer_maximum_prefix_unset(peer, afi, safi); |
718e3744 | 5871 | |
d62a17ae | 5872 | return bgp_vty_return(vty, ret); |
718e3744 | 5873 | } |
5874 | ||
5875 | /* Maximum number of prefix configuration. prefix count is different | |
5876 | for each peer configuration. So this configuration can be set for | |
5877 | each peer configuration. */ | |
5878 | DEFUN (neighbor_maximum_prefix, | |
5879 | neighbor_maximum_prefix_cmd, | |
9ccf14f7 | 5880 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", |
718e3744 | 5881 | NEIGHBOR_STR |
5882 | NEIGHBOR_ADDR_STR2 | |
5883 | "Maximum number of prefix accept from this peer\n" | |
5884 | "maximum no. of prefix limit\n") | |
5885 | { | |
d62a17ae | 5886 | int idx_peer = 1; |
5887 | int idx_number = 3; | |
5888 | return peer_maximum_prefix_set_vty( | |
5889 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5890 | argv[idx_number]->arg, NULL, 0, NULL); | |
718e3744 | 5891 | } |
5892 | ||
d62a17ae | 5893 | ALIAS_HIDDEN(neighbor_maximum_prefix, neighbor_maximum_prefix_hidden_cmd, |
5894 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)", | |
5895 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5896 | "Maximum number of prefix accept from this peer\n" | |
5897 | "maximum no. of prefix limit\n") | |
596c17ba | 5898 | |
e0701b79 | 5899 | DEFUN (neighbor_maximum_prefix_threshold, |
5900 | neighbor_maximum_prefix_threshold_cmd, | |
9ccf14f7 | 5901 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", |
e0701b79 | 5902 | NEIGHBOR_STR |
5903 | NEIGHBOR_ADDR_STR2 | |
5904 | "Maximum number of prefix accept from this peer\n" | |
5905 | "maximum no. of prefix limit\n" | |
5906 | "Threshold value (%) at which to generate a warning msg\n") | |
5907 | { | |
d62a17ae | 5908 | int idx_peer = 1; |
5909 | int idx_number = 3; | |
5910 | int idx_number_2 = 4; | |
5911 | return peer_maximum_prefix_set_vty( | |
5912 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5913 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, NULL); | |
0a486e5f | 5914 | } |
e0701b79 | 5915 | |
d62a17ae | 5916 | ALIAS_HIDDEN( |
5917 | neighbor_maximum_prefix_threshold, | |
5918 | neighbor_maximum_prefix_threshold_hidden_cmd, | |
5919 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)", | |
5920 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5921 | "Maximum number of prefix accept from this peer\n" | |
5922 | "maximum no. of prefix limit\n" | |
5923 | "Threshold value (%) at which to generate a warning msg\n") | |
596c17ba | 5924 | |
718e3744 | 5925 | DEFUN (neighbor_maximum_prefix_warning, |
5926 | neighbor_maximum_prefix_warning_cmd, | |
9ccf14f7 | 5927 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", |
718e3744 | 5928 | NEIGHBOR_STR |
5929 | NEIGHBOR_ADDR_STR2 | |
5930 | "Maximum number of prefix accept from this peer\n" | |
5931 | "maximum no. of prefix limit\n" | |
5932 | "Only give warning message when limit is exceeded\n") | |
5933 | { | |
d62a17ae | 5934 | int idx_peer = 1; |
5935 | int idx_number = 3; | |
5936 | return peer_maximum_prefix_set_vty( | |
5937 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5938 | argv[idx_number]->arg, NULL, 1, NULL); | |
718e3744 | 5939 | } |
5940 | ||
d62a17ae | 5941 | ALIAS_HIDDEN( |
5942 | neighbor_maximum_prefix_warning, | |
5943 | neighbor_maximum_prefix_warning_hidden_cmd, | |
5944 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only", | |
5945 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5946 | "Maximum number of prefix accept from this peer\n" | |
5947 | "maximum no. of prefix limit\n" | |
5948 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5949 | |
e0701b79 | 5950 | DEFUN (neighbor_maximum_prefix_threshold_warning, |
5951 | neighbor_maximum_prefix_threshold_warning_cmd, | |
9ccf14f7 | 5952 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", |
e0701b79 | 5953 | NEIGHBOR_STR |
5954 | NEIGHBOR_ADDR_STR2 | |
5955 | "Maximum number of prefix accept from this peer\n" | |
5956 | "maximum no. of prefix limit\n" | |
5957 | "Threshold value (%) at which to generate a warning msg\n" | |
5958 | "Only give warning message when limit is exceeded\n") | |
5959 | { | |
d62a17ae | 5960 | int idx_peer = 1; |
5961 | int idx_number = 3; | |
5962 | int idx_number_2 = 4; | |
5963 | return peer_maximum_prefix_set_vty( | |
5964 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5965 | argv[idx_number]->arg, argv[idx_number_2]->arg, 1, NULL); | |
0a486e5f | 5966 | } |
5967 | ||
d62a17ae | 5968 | ALIAS_HIDDEN( |
5969 | neighbor_maximum_prefix_threshold_warning, | |
5970 | neighbor_maximum_prefix_threshold_warning_hidden_cmd, | |
5971 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only", | |
5972 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
5973 | "Maximum number of prefix accept from this peer\n" | |
5974 | "maximum no. of prefix limit\n" | |
5975 | "Threshold value (%) at which to generate a warning msg\n" | |
5976 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 5977 | |
0a486e5f | 5978 | DEFUN (neighbor_maximum_prefix_restart, |
5979 | neighbor_maximum_prefix_restart_cmd, | |
9ccf14f7 | 5980 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", |
0a486e5f | 5981 | NEIGHBOR_STR |
5982 | NEIGHBOR_ADDR_STR2 | |
5983 | "Maximum number of prefix accept from this peer\n" | |
5984 | "maximum no. of prefix limit\n" | |
5985 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 5986 | "Restart interval in minutes\n") |
0a486e5f | 5987 | { |
d62a17ae | 5988 | int idx_peer = 1; |
5989 | int idx_number = 3; | |
5990 | int idx_number_2 = 5; | |
5991 | return peer_maximum_prefix_set_vty( | |
5992 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
5993 | argv[idx_number]->arg, NULL, 0, argv[idx_number_2]->arg); | |
0a486e5f | 5994 | } |
5995 | ||
d62a17ae | 5996 | ALIAS_HIDDEN( |
5997 | neighbor_maximum_prefix_restart, | |
5998 | neighbor_maximum_prefix_restart_hidden_cmd, | |
5999 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)", | |
6000 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6001 | "Maximum number of prefix accept from this peer\n" | |
6002 | "maximum no. of prefix limit\n" | |
6003 | "Restart bgp connection after limit is exceeded\n" | |
efd7904e | 6004 | "Restart interval in minutes\n") |
596c17ba | 6005 | |
0a486e5f | 6006 | DEFUN (neighbor_maximum_prefix_threshold_restart, |
6007 | neighbor_maximum_prefix_threshold_restart_cmd, | |
9ccf14f7 | 6008 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", |
0a486e5f | 6009 | NEIGHBOR_STR |
6010 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6011 | "Maximum number of prefixes to accept from this peer\n" |
0a486e5f | 6012 | "maximum no. of prefix limit\n" |
6013 | "Threshold value (%) at which to generate a warning msg\n" | |
6014 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6015 | "Restart interval in minutes\n") |
0a486e5f | 6016 | { |
d62a17ae | 6017 | int idx_peer = 1; |
6018 | int idx_number = 3; | |
6019 | int idx_number_2 = 4; | |
6020 | int idx_number_3 = 6; | |
6021 | return peer_maximum_prefix_set_vty( | |
6022 | vty, argv[idx_peer]->arg, bgp_node_afi(vty), bgp_node_safi(vty), | |
6023 | argv[idx_number]->arg, argv[idx_number_2]->arg, 0, | |
6024 | argv[idx_number_3]->arg); | |
6025 | } | |
6026 | ||
6027 | ALIAS_HIDDEN( | |
6028 | neighbor_maximum_prefix_threshold_restart, | |
6029 | neighbor_maximum_prefix_threshold_restart_hidden_cmd, | |
6030 | "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)", | |
6031 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6032 | "Maximum number of prefixes to accept from this peer\n" | |
6033 | "maximum no. of prefix limit\n" | |
6034 | "Threshold value (%) at which to generate a warning msg\n" | |
6035 | "Restart bgp connection after limit is exceeded\n" | |
6036 | "Restart interval in minutes\n") | |
596c17ba | 6037 | |
718e3744 | 6038 | DEFUN (no_neighbor_maximum_prefix, |
6039 | no_neighbor_maximum_prefix_cmd, | |
d04c479d | 6040 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", |
718e3744 | 6041 | NO_STR |
6042 | NEIGHBOR_STR | |
6043 | NEIGHBOR_ADDR_STR2 | |
16cedbb0 | 6044 | "Maximum number of prefixes to accept from this peer\n" |
31500417 DW |
6045 | "maximum no. of prefix limit\n" |
6046 | "Threshold value (%) at which to generate a warning msg\n" | |
6047 | "Restart bgp connection after limit is exceeded\n" | |
16cedbb0 | 6048 | "Restart interval in minutes\n" |
31500417 | 6049 | "Only give warning message when limit is exceeded\n") |
718e3744 | 6050 | { |
d62a17ae | 6051 | int idx_peer = 2; |
6052 | return peer_maximum_prefix_unset_vty(vty, argv[idx_peer]->arg, | |
6053 | bgp_node_afi(vty), | |
6054 | bgp_node_safi(vty)); | |
718e3744 | 6055 | } |
e52702f2 | 6056 | |
d62a17ae | 6057 | ALIAS_HIDDEN( |
6058 | no_neighbor_maximum_prefix, no_neighbor_maximum_prefix_hidden_cmd, | |
6059 | "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]", | |
6060 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6061 | "Maximum number of prefixes to accept from this peer\n" | |
6062 | "maximum no. of prefix limit\n" | |
6063 | "Threshold value (%) at which to generate a warning msg\n" | |
6064 | "Restart bgp connection after limit is exceeded\n" | |
6065 | "Restart interval in minutes\n" | |
6066 | "Only give warning message when limit is exceeded\n") | |
596c17ba | 6067 | |
718e3744 | 6068 | |
718e3744 | 6069 | /* "neighbor allowas-in" */ |
6070 | DEFUN (neighbor_allowas_in, | |
6071 | neighbor_allowas_in_cmd, | |
fd8503f5 | 6072 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6073 | NEIGHBOR_STR |
6074 | NEIGHBOR_ADDR_STR2 | |
31500417 | 6075 | "Accept as-path with my AS present in it\n" |
0437e105 | 6076 | "Number of occurences of AS number\n" |
fd8503f5 | 6077 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6078 | { |
d62a17ae | 6079 | int idx_peer = 1; |
6080 | int idx_number_origin = 3; | |
6081 | int ret; | |
6082 | int origin = 0; | |
6083 | struct peer *peer; | |
6084 | int allow_num = 0; | |
6085 | ||
6086 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6087 | if (!peer) | |
6088 | return CMD_WARNING_CONFIG_FAILED; | |
6089 | ||
6090 | if (argc <= idx_number_origin) | |
6091 | allow_num = 3; | |
6092 | else { | |
6093 | if (argv[idx_number_origin]->type == WORD_TKN) | |
6094 | origin = 1; | |
6095 | else | |
6096 | allow_num = atoi(argv[idx_number_origin]->arg); | |
6097 | } | |
6098 | ||
6099 | ret = peer_allowas_in_set(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6100 | allow_num, origin); | |
6101 | ||
6102 | return bgp_vty_return(vty, ret); | |
6103 | } | |
6104 | ||
6105 | ALIAS_HIDDEN( | |
6106 | neighbor_allowas_in, neighbor_allowas_in_hidden_cmd, | |
6107 | "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6108 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6109 | "Accept as-path with my AS present in it\n" | |
0437e105 | 6110 | "Number of occurences of AS number\n" |
d62a17ae | 6111 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6112 | |
718e3744 | 6113 | DEFUN (no_neighbor_allowas_in, |
6114 | no_neighbor_allowas_in_cmd, | |
fd8503f5 | 6115 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", |
718e3744 | 6116 | NO_STR |
6117 | NEIGHBOR_STR | |
6118 | NEIGHBOR_ADDR_STR2 | |
8334fd5a | 6119 | "allow local ASN appears in aspath attribute\n" |
0437e105 | 6120 | "Number of occurences of AS number\n" |
fd8503f5 | 6121 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
718e3744 | 6122 | { |
d62a17ae | 6123 | int idx_peer = 2; |
6124 | int ret; | |
6125 | struct peer *peer; | |
718e3744 | 6126 | |
d62a17ae | 6127 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6128 | if (!peer) | |
6129 | return CMD_WARNING_CONFIG_FAILED; | |
718e3744 | 6130 | |
d62a17ae | 6131 | ret = peer_allowas_in_unset(peer, bgp_node_afi(vty), |
6132 | bgp_node_safi(vty)); | |
718e3744 | 6133 | |
d62a17ae | 6134 | return bgp_vty_return(vty, ret); |
718e3744 | 6135 | } |
6b0655a2 | 6136 | |
d62a17ae | 6137 | ALIAS_HIDDEN( |
6138 | no_neighbor_allowas_in, no_neighbor_allowas_in_hidden_cmd, | |
6139 | "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]", | |
6140 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6141 | "allow local ASN appears in aspath attribute\n" | |
0437e105 | 6142 | "Number of occurences of AS number\n" |
d62a17ae | 6143 | "Only accept my AS in the as-path if the route was originated in my AS\n") |
596c17ba | 6144 | |
fa411a21 NH |
6145 | DEFUN (neighbor_ttl_security, |
6146 | neighbor_ttl_security_cmd, | |
7ebe625c | 6147 | "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 | 6148 | NEIGHBOR_STR |
7ebe625c | 6149 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6150 | "BGP ttl-security parameters\n" |
d7fa34c1 QY |
6151 | "Specify the maximum number of hops to the BGP peer\n" |
6152 | "Number of hops to BGP peer\n") | |
fa411a21 | 6153 | { |
d62a17ae | 6154 | int idx_peer = 1; |
6155 | int idx_number = 4; | |
6156 | struct peer *peer; | |
6157 | int gtsm_hops; | |
6158 | ||
6159 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6160 | if (!peer) | |
6161 | return CMD_WARNING_CONFIG_FAILED; | |
6162 | ||
6163 | gtsm_hops = strtoul(argv[idx_number]->arg, NULL, 10); | |
6164 | ||
7ebe625c QY |
6165 | /* |
6166 | * If 'neighbor swpX', then this is for directly connected peers, | |
6167 | * we should not accept a ttl-security hops value greater than 1. | |
6168 | */ | |
6169 | if (peer->conf_if && (gtsm_hops > 1)) { | |
6170 | vty_out(vty, | |
6171 | "%s is directly connected peer, hops cannot exceed 1\n", | |
6172 | argv[idx_peer]->arg); | |
6173 | return CMD_WARNING_CONFIG_FAILED; | |
6174 | } | |
6175 | ||
d62a17ae | 6176 | return bgp_vty_return(vty, peer_ttl_security_hops_set(peer, gtsm_hops)); |
fa411a21 NH |
6177 | } |
6178 | ||
6179 | DEFUN (no_neighbor_ttl_security, | |
6180 | no_neighbor_ttl_security_cmd, | |
7ebe625c | 6181 | "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)", |
fa411a21 NH |
6182 | NO_STR |
6183 | NEIGHBOR_STR | |
7ebe625c | 6184 | NEIGHBOR_ADDR_STR2 |
16cedbb0 | 6185 | "BGP ttl-security parameters\n" |
3a2d747c QY |
6186 | "Specify the maximum number of hops to the BGP peer\n" |
6187 | "Number of hops to BGP peer\n") | |
fa411a21 | 6188 | { |
d62a17ae | 6189 | int idx_peer = 2; |
6190 | struct peer *peer; | |
fa411a21 | 6191 | |
d62a17ae | 6192 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6193 | if (!peer) | |
6194 | return CMD_WARNING_CONFIG_FAILED; | |
fa411a21 | 6195 | |
d62a17ae | 6196 | return bgp_vty_return(vty, peer_ttl_security_hops_unset(peer)); |
fa411a21 | 6197 | } |
6b0655a2 | 6198 | |
adbac85e DW |
6199 | DEFUN (neighbor_addpath_tx_all_paths, |
6200 | neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6201 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6202 | NEIGHBOR_STR |
6203 | NEIGHBOR_ADDR_STR2 | |
6204 | "Use addpath to advertise all paths to a neighbor\n") | |
6205 | { | |
d62a17ae | 6206 | int idx_peer = 1; |
6207 | struct peer *peer; | |
adbac85e | 6208 | |
d62a17ae | 6209 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6210 | if (!peer) | |
6211 | return CMD_WARNING_CONFIG_FAILED; | |
adbac85e | 6212 | |
dcc68b5e MS |
6213 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6214 | BGP_ADDPATH_ALL); | |
6215 | return CMD_SUCCESS; | |
adbac85e DW |
6216 | } |
6217 | ||
d62a17ae | 6218 | ALIAS_HIDDEN(neighbor_addpath_tx_all_paths, |
6219 | neighbor_addpath_tx_all_paths_hidden_cmd, | |
6220 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6221 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6222 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6223 | |
adbac85e DW |
6224 | DEFUN (no_neighbor_addpath_tx_all_paths, |
6225 | no_neighbor_addpath_tx_all_paths_cmd, | |
9ccf14f7 | 6226 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", |
adbac85e DW |
6227 | NO_STR |
6228 | NEIGHBOR_STR | |
6229 | NEIGHBOR_ADDR_STR2 | |
6230 | "Use addpath to advertise all paths to a neighbor\n") | |
6231 | { | |
d62a17ae | 6232 | int idx_peer = 2; |
dcc68b5e MS |
6233 | struct peer *peer; |
6234 | ||
6235 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6236 | if (!peer) | |
6237 | return CMD_WARNING_CONFIG_FAILED; | |
6238 | ||
6239 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6240 | != BGP_ADDPATH_ALL) { | |
6241 | vty_out(vty, | |
6242 | "%% Peer not currently configured to transmit all paths."); | |
6243 | return CMD_WARNING_CONFIG_FAILED; | |
6244 | } | |
6245 | ||
6246 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6247 | BGP_ADDPATH_NONE); | |
6248 | ||
6249 | return CMD_SUCCESS; | |
adbac85e DW |
6250 | } |
6251 | ||
d62a17ae | 6252 | ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths, |
6253 | no_neighbor_addpath_tx_all_paths_hidden_cmd, | |
6254 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths", | |
6255 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6256 | "Use addpath to advertise all paths to a neighbor\n") | |
596c17ba | 6257 | |
06370dac DW |
6258 | DEFUN (neighbor_addpath_tx_bestpath_per_as, |
6259 | neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6260 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6261 | NEIGHBOR_STR |
6262 | NEIGHBOR_ADDR_STR2 | |
6263 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6264 | { | |
d62a17ae | 6265 | int idx_peer = 1; |
6266 | struct peer *peer; | |
06370dac | 6267 | |
d62a17ae | 6268 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); |
6269 | if (!peer) | |
6270 | return CMD_WARNING_CONFIG_FAILED; | |
06370dac | 6271 | |
dcc68b5e MS |
6272 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), |
6273 | BGP_ADDPATH_BEST_PER_AS); | |
6274 | ||
6275 | return CMD_SUCCESS; | |
06370dac DW |
6276 | } |
6277 | ||
d62a17ae | 6278 | ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as, |
6279 | neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6280 | "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6281 | NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6282 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6283 | |
06370dac DW |
6284 | DEFUN (no_neighbor_addpath_tx_bestpath_per_as, |
6285 | no_neighbor_addpath_tx_bestpath_per_as_cmd, | |
9ccf14f7 | 6286 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", |
06370dac DW |
6287 | NO_STR |
6288 | NEIGHBOR_STR | |
6289 | NEIGHBOR_ADDR_STR2 | |
6290 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
6291 | { | |
d62a17ae | 6292 | int idx_peer = 2; |
dcc68b5e MS |
6293 | struct peer *peer; |
6294 | ||
6295 | peer = peer_and_group_lookup_vty(vty, argv[idx_peer]->arg); | |
6296 | if (!peer) | |
6297 | return CMD_WARNING_CONFIG_FAILED; | |
6298 | ||
6299 | if (peer->addpath_type[bgp_node_afi(vty)][bgp_node_safi(vty)] | |
6300 | != BGP_ADDPATH_BEST_PER_AS) { | |
6301 | vty_out(vty, | |
6302 | "%% Peer not currently configured to transmit all best path per as."); | |
6303 | return CMD_WARNING_CONFIG_FAILED; | |
6304 | } | |
6305 | ||
6306 | bgp_addpath_set_peer_type(peer, bgp_node_afi(vty), bgp_node_safi(vty), | |
6307 | BGP_ADDPATH_NONE); | |
6308 | ||
6309 | return CMD_SUCCESS; | |
06370dac DW |
6310 | } |
6311 | ||
d62a17ae | 6312 | ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as, |
6313 | no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd, | |
6314 | "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS", | |
6315 | NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 | |
6316 | "Use addpath to advertise the bestpath per each neighboring AS\n") | |
596c17ba | 6317 | |
b9c7bc5a PZ |
6318 | static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv, |
6319 | struct ecommunity **list) | |
ddb5b488 | 6320 | { |
b9c7bc5a PZ |
6321 | struct ecommunity *ecom = NULL; |
6322 | struct ecommunity *ecomadd; | |
ddb5b488 | 6323 | |
b9c7bc5a | 6324 | for (; argc; --argc, ++argv) { |
ddb5b488 | 6325 | |
b9c7bc5a PZ |
6326 | ecomadd = ecommunity_str2com(argv[0]->arg, |
6327 | ECOMMUNITY_ROUTE_TARGET, 0); | |
6328 | if (!ecomadd) { | |
6329 | vty_out(vty, "Malformed community-list value\n"); | |
6330 | if (ecom) | |
6331 | ecommunity_free(&ecom); | |
6332 | return CMD_WARNING_CONFIG_FAILED; | |
6333 | } | |
ddb5b488 | 6334 | |
b9c7bc5a PZ |
6335 | if (ecom) { |
6336 | ecommunity_merge(ecom, ecomadd); | |
6337 | ecommunity_free(&ecomadd); | |
6338 | } else { | |
6339 | ecom = ecomadd; | |
6340 | } | |
6341 | } | |
6342 | ||
6343 | if (*list) { | |
6344 | ecommunity_free(&*list); | |
ddb5b488 | 6345 | } |
b9c7bc5a PZ |
6346 | *list = ecom; |
6347 | ||
6348 | return CMD_SUCCESS; | |
ddb5b488 PZ |
6349 | } |
6350 | ||
0ca70ba5 DS |
6351 | /* |
6352 | * v2vimport is true if we are handling a `import vrf ...` command | |
6353 | */ | |
6354 | static afi_t vpn_policy_getafi(struct vty *vty, struct bgp *bgp, bool v2vimport) | |
ddb5b488 | 6355 | { |
0ca70ba5 DS |
6356 | afi_t afi; |
6357 | ||
ddb5b488 | 6358 | switch (vty->node) { |
b9c7bc5a | 6359 | case BGP_IPV4_NODE: |
0ca70ba5 DS |
6360 | afi = AFI_IP; |
6361 | break; | |
b9c7bc5a | 6362 | case BGP_IPV6_NODE: |
0ca70ba5 DS |
6363 | afi = AFI_IP6; |
6364 | break; | |
ddb5b488 PZ |
6365 | default: |
6366 | vty_out(vty, | |
b9c7bc5a | 6367 | "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n"); |
69b07479 | 6368 | return AFI_MAX; |
ddb5b488 | 6369 | } |
69b07479 | 6370 | |
0ca70ba5 DS |
6371 | if (!v2vimport) { |
6372 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6373 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
6374 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6375 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
6376 | vty_out(vty, | |
6377 | "%% error: Please unconfigure import vrf commands before using vpn commands\n"); | |
6378 | return AFI_MAX; | |
6379 | } | |
6380 | } else { | |
6381 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6382 | BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT) | |
6383 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
6384 | BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT)) { | |
6385 | vty_out(vty, | |
6386 | "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n"); | |
6387 | return AFI_MAX; | |
6388 | } | |
6389 | } | |
6390 | return afi; | |
ddb5b488 PZ |
6391 | } |
6392 | ||
b9c7bc5a PZ |
6393 | DEFPY (af_rd_vpn_export, |
6394 | af_rd_vpn_export_cmd, | |
6395 | "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str", | |
6396 | NO_STR | |
ddb5b488 | 6397 | "Specify route distinguisher\n" |
b9c7bc5a PZ |
6398 | "Between current address-family and vpn\n" |
6399 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6400 | "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n") |
6401 | { | |
6402 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6403 | struct prefix_rd prd; | |
6404 | int ret; | |
ddb5b488 | 6405 | afi_t afi; |
b9c7bc5a PZ |
6406 | int idx = 0; |
6407 | int yes = 1; | |
ddb5b488 | 6408 | |
b9c7bc5a | 6409 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6410 | yes = 0; |
b9c7bc5a PZ |
6411 | |
6412 | if (yes) { | |
6413 | ret = str2prefix_rd(rd_str, &prd); | |
6414 | if (!ret) { | |
6415 | vty_out(vty, "%% Malformed rd\n"); | |
6416 | return CMD_WARNING_CONFIG_FAILED; | |
6417 | } | |
ddb5b488 PZ |
6418 | } |
6419 | ||
0ca70ba5 | 6420 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6421 | if (afi == AFI_MAX) |
6422 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6423 | |
69b07479 DS |
6424 | /* |
6425 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6426 | */ | |
6427 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6428 | bgp_get_default(), bgp); | |
ddb5b488 | 6429 | |
69b07479 DS |
6430 | if (yes) { |
6431 | bgp->vpn_policy[afi].tovpn_rd = prd; | |
6432 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6433 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
6434 | } else { | |
6435 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6436 | BGP_VPN_POLICY_TOVPN_RD_SET); | |
ddb5b488 PZ |
6437 | } |
6438 | ||
69b07479 DS |
6439 | /* post-change: re-export vpn routes */ |
6440 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6441 | bgp_get_default(), bgp); | |
6442 | ||
ddb5b488 PZ |
6443 | return CMD_SUCCESS; |
6444 | } | |
6445 | ||
b9c7bc5a PZ |
6446 | ALIAS (af_rd_vpn_export, |
6447 | af_no_rd_vpn_export_cmd, | |
6448 | "no rd vpn export", | |
ddb5b488 | 6449 | NO_STR |
b9c7bc5a PZ |
6450 | "Specify route distinguisher\n" |
6451 | "Between current address-family and vpn\n" | |
6452 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6453 | |
b9c7bc5a PZ |
6454 | DEFPY (af_label_vpn_export, |
6455 | af_label_vpn_export_cmd, | |
e70e9f8e | 6456 | "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>", |
b9c7bc5a | 6457 | NO_STR |
ddb5b488 | 6458 | "label value for VRF\n" |
b9c7bc5a PZ |
6459 | "Between current address-family and vpn\n" |
6460 | "For routes leaked from current address-family to vpn\n" | |
e70e9f8e PZ |
6461 | "Label Value <0-1048575>\n" |
6462 | "Automatically assign a label\n") | |
ddb5b488 PZ |
6463 | { |
6464 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6465 | mpls_label_t label = MPLS_LABEL_NONE; |
ddb5b488 | 6466 | afi_t afi; |
b9c7bc5a PZ |
6467 | int idx = 0; |
6468 | int yes = 1; | |
6469 | ||
6470 | if (argv_find(argv, argc, "no", &idx)) | |
d555f3e9 | 6471 | yes = 0; |
ddb5b488 | 6472 | |
21a16cc2 PZ |
6473 | /* If "no ...", squash trailing parameter */ |
6474 | if (!yes) | |
6475 | label_auto = NULL; | |
6476 | ||
e70e9f8e PZ |
6477 | if (yes) { |
6478 | if (!label_auto) | |
6479 | label = label_val; /* parser should force unsigned */ | |
6480 | } | |
ddb5b488 | 6481 | |
0ca70ba5 | 6482 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6483 | if (afi == AFI_MAX) |
6484 | return CMD_WARNING_CONFIG_FAILED; | |
e70e9f8e | 6485 | |
e70e9f8e | 6486 | |
69b07479 DS |
6487 | if (label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, |
6488 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) | |
6489 | /* no change */ | |
6490 | return CMD_SUCCESS; | |
e70e9f8e | 6491 | |
69b07479 DS |
6492 | /* |
6493 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6494 | */ | |
6495 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6496 | bgp_get_default(), bgp); | |
6497 | ||
6498 | if (!label_auto && CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
6499 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
6500 | ||
6501 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
6502 | ||
6503 | /* | |
6504 | * label has previously been automatically | |
6505 | * assigned by labelpool: release it | |
6506 | * | |
6507 | * NB if tovpn_label == MPLS_LABEL_NONE it | |
6508 | * means the automatic assignment is in flight | |
6509 | * and therefore the labelpool callback must | |
6510 | * detect that the auto label is not needed. | |
6511 | */ | |
6512 | ||
6513 | bgp_lp_release(LP_TYPE_VRF, | |
6514 | &bgp->vpn_policy[afi], | |
6515 | bgp->vpn_policy[afi].tovpn_label); | |
e70e9f8e | 6516 | } |
69b07479 DS |
6517 | UNSET_FLAG(bgp->vpn_policy[afi].flags, |
6518 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6519 | } | |
ddb5b488 | 6520 | |
69b07479 DS |
6521 | bgp->vpn_policy[afi].tovpn_label = label; |
6522 | if (label_auto) { | |
6523 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6524 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO); | |
6525 | bgp_lp_get(LP_TYPE_VRF, &bgp->vpn_policy[afi], | |
6526 | vpn_leak_label_callback); | |
ddb5b488 PZ |
6527 | } |
6528 | ||
69b07479 DS |
6529 | /* post-change: re-export vpn routes */ |
6530 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6531 | bgp_get_default(), bgp); | |
6532 | ||
ddb5b488 PZ |
6533 | return CMD_SUCCESS; |
6534 | } | |
6535 | ||
b9c7bc5a PZ |
6536 | ALIAS (af_label_vpn_export, |
6537 | af_no_label_vpn_export_cmd, | |
6538 | "no label vpn export", | |
6539 | NO_STR | |
6540 | "label value for VRF\n" | |
6541 | "Between current address-family and vpn\n" | |
6542 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6543 | |
b9c7bc5a PZ |
6544 | DEFPY (af_nexthop_vpn_export, |
6545 | af_nexthop_vpn_export_cmd, | |
6546 | "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str", | |
6547 | NO_STR | |
ddb5b488 | 6548 | "Specify next hop to use for VRF advertised prefixes\n" |
b9c7bc5a PZ |
6549 | "Between current address-family and vpn\n" |
6550 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6551 | "IPv4 prefix\n" |
6552 | "IPv6 prefix\n") | |
6553 | { | |
6554 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
ddb5b488 | 6555 | afi_t afi; |
ddb5b488 | 6556 | struct prefix p; |
b9c7bc5a PZ |
6557 | int idx = 0; |
6558 | int yes = 1; | |
ddb5b488 | 6559 | |
b9c7bc5a | 6560 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6561 | yes = 0; |
b9c7bc5a PZ |
6562 | |
6563 | if (yes) { | |
6564 | if (!sockunion2hostprefix(nexthop_str, &p)) | |
6565 | return CMD_WARNING_CONFIG_FAILED; | |
6566 | } | |
ddb5b488 | 6567 | |
0ca70ba5 | 6568 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6569 | if (afi == AFI_MAX) |
6570 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6571 | |
69b07479 DS |
6572 | /* |
6573 | * pre-change: un-export vpn routes (vpn->vrf routes unaffected) | |
6574 | */ | |
6575 | vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6576 | bgp_get_default(), bgp); | |
ddb5b488 | 6577 | |
69b07479 DS |
6578 | if (yes) { |
6579 | bgp->vpn_policy[afi].tovpn_nexthop = p; | |
6580 | SET_FLAG(bgp->vpn_policy[afi].flags, | |
6581 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
6582 | } else { | |
6583 | UNSET_FLAG(bgp->vpn_policy[afi].flags, | |
6584 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); | |
ddb5b488 PZ |
6585 | } |
6586 | ||
69b07479 DS |
6587 | /* post-change: re-export vpn routes */ |
6588 | vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN, afi, | |
6589 | bgp_get_default(), bgp); | |
6590 | ||
ddb5b488 PZ |
6591 | return CMD_SUCCESS; |
6592 | } | |
6593 | ||
b9c7bc5a PZ |
6594 | ALIAS (af_nexthop_vpn_export, |
6595 | af_no_nexthop_vpn_export_cmd, | |
6596 | "no nexthop vpn export", | |
ddb5b488 | 6597 | NO_STR |
b9c7bc5a PZ |
6598 | "Specify next hop to use for VRF advertised prefixes\n" |
6599 | "Between current address-family and vpn\n" | |
6600 | "For routes leaked from current address-family to vpn\n") | |
ddb5b488 | 6601 | |
b9c7bc5a | 6602 | static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) |
ddb5b488 | 6603 | { |
b9c7bc5a PZ |
6604 | if (!strcmp(dstr, "import")) { |
6605 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6606 | } else if (!strcmp(dstr, "export")) { | |
6607 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6608 | } else if (!strcmp(dstr, "both")) { | |
6609 | dodir[BGP_VPN_POLICY_DIR_FROMVPN] = 1; | |
6610 | dodir[BGP_VPN_POLICY_DIR_TOVPN] = 1; | |
6611 | } else { | |
6612 | vty_out(vty, "%% direction parse error\n"); | |
6613 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6614 | } |
ddb5b488 PZ |
6615 | return CMD_SUCCESS; |
6616 | } | |
6617 | ||
b9c7bc5a PZ |
6618 | DEFPY (af_rt_vpn_imexport, |
6619 | af_rt_vpn_imexport_cmd, | |
6620 | "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...", | |
6621 | NO_STR | |
6622 | "Specify route target list\n" | |
ddb5b488 | 6623 | "Specify route target list\n" |
b9c7bc5a PZ |
6624 | "Between current address-family and vpn\n" |
6625 | "For routes leaked from vpn to current address-family: match any\n" | |
6626 | "For routes leaked from current address-family to vpn: set\n" | |
6627 | "both import: match any and export: set\n" | |
ddb5b488 PZ |
6628 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") |
6629 | { | |
6630 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6631 | int ret; | |
6632 | struct ecommunity *ecom = NULL; | |
6633 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6634 | vpn_policy_direction_t dir; |
6635 | afi_t afi; | |
6636 | int idx = 0; | |
b9c7bc5a | 6637 | int yes = 1; |
ddb5b488 | 6638 | |
b9c7bc5a | 6639 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6640 | yes = 0; |
b9c7bc5a | 6641 | |
0ca70ba5 | 6642 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6643 | if (afi == AFI_MAX) |
6644 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6645 | |
b9c7bc5a | 6646 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6647 | if (ret != CMD_SUCCESS) |
6648 | return ret; | |
6649 | ||
b9c7bc5a PZ |
6650 | if (yes) { |
6651 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
6652 | vty_out(vty, "%% Missing RTLIST\n"); | |
6653 | return CMD_WARNING_CONFIG_FAILED; | |
6654 | } | |
6655 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
6656 | if (ret != CMD_SUCCESS) { | |
6657 | return ret; | |
6658 | } | |
ddb5b488 PZ |
6659 | } |
6660 | ||
69b07479 DS |
6661 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6662 | if (!dodir[dir]) | |
ddb5b488 | 6663 | continue; |
ddb5b488 | 6664 | |
69b07479 | 6665 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6666 | |
69b07479 DS |
6667 | if (yes) { |
6668 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6669 | ecommunity_free( | |
6670 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6671 | bgp->vpn_policy[afi].rtlist[dir] = | |
6672 | ecommunity_dup(ecom); | |
6673 | } else { | |
6674 | if (bgp->vpn_policy[afi].rtlist[dir]) | |
6675 | ecommunity_free( | |
6676 | &bgp->vpn_policy[afi].rtlist[dir]); | |
6677 | bgp->vpn_policy[afi].rtlist[dir] = NULL; | |
ddb5b488 | 6678 | } |
69b07479 DS |
6679 | |
6680 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 | 6681 | } |
69b07479 | 6682 | |
d555f3e9 PZ |
6683 | if (ecom) |
6684 | ecommunity_free(&ecom); | |
ddb5b488 PZ |
6685 | |
6686 | return CMD_SUCCESS; | |
6687 | } | |
6688 | ||
b9c7bc5a PZ |
6689 | ALIAS (af_rt_vpn_imexport, |
6690 | af_no_rt_vpn_imexport_cmd, | |
6691 | "no <rt|route-target> vpn <import|export|both>$direction_str", | |
ddb5b488 PZ |
6692 | NO_STR |
6693 | "Specify route target list\n" | |
b9c7bc5a PZ |
6694 | "Specify route target list\n" |
6695 | "Between current address-family and vpn\n" | |
6696 | "For routes leaked from vpn to current address-family\n" | |
6697 | "For routes leaked from current address-family to vpn\n" | |
6698 | "both import and export\n") | |
6699 | ||
6700 | DEFPY (af_route_map_vpn_imexport, | |
6701 | af_route_map_vpn_imexport_cmd, | |
6702 | /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */ | |
6703 | "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str", | |
6704 | NO_STR | |
ddb5b488 | 6705 | "Specify route map\n" |
b9c7bc5a PZ |
6706 | "Between current address-family and vpn\n" |
6707 | "For routes leaked from vpn to current address-family\n" | |
6708 | "For routes leaked from current address-family to vpn\n" | |
ddb5b488 PZ |
6709 | "name of route-map\n") |
6710 | { | |
6711 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6712 | int ret; | |
6713 | int dodir[BGP_VPN_POLICY_DIR_MAX] = {0}; | |
ddb5b488 PZ |
6714 | vpn_policy_direction_t dir; |
6715 | afi_t afi; | |
ddb5b488 | 6716 | int idx = 0; |
b9c7bc5a | 6717 | int yes = 1; |
ddb5b488 | 6718 | |
b9c7bc5a | 6719 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6720 | yes = 0; |
b9c7bc5a | 6721 | |
0ca70ba5 | 6722 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
6723 | if (afi == AFI_MAX) |
6724 | return CMD_WARNING_CONFIG_FAILED; | |
ddb5b488 | 6725 | |
b9c7bc5a | 6726 | ret = vpn_policy_getdirs(vty, direction_str, dodir); |
ddb5b488 PZ |
6727 | if (ret != CMD_SUCCESS) |
6728 | return ret; | |
6729 | ||
69b07479 DS |
6730 | for (dir = 0; dir < BGP_VPN_POLICY_DIR_MAX; ++dir) { |
6731 | if (!dodir[dir]) | |
ddb5b488 | 6732 | continue; |
ddb5b488 | 6733 | |
69b07479 | 6734 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
ddb5b488 | 6735 | |
69b07479 DS |
6736 | if (yes) { |
6737 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6738 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6739 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6740 | bgp->vpn_policy[afi].rmap_name[dir] = XSTRDUP( | |
6741 | MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6742 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 6743 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
6744 | if (!bgp->vpn_policy[afi].rmap[dir]) |
6745 | return CMD_SUCCESS; | |
6746 | } else { | |
6747 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6748 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6749 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6750 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6751 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
ddb5b488 | 6752 | } |
69b07479 DS |
6753 | |
6754 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); | |
ddb5b488 PZ |
6755 | } |
6756 | ||
6757 | return CMD_SUCCESS; | |
6758 | } | |
6759 | ||
b9c7bc5a PZ |
6760 | ALIAS (af_route_map_vpn_imexport, |
6761 | af_no_route_map_vpn_imexport_cmd, | |
6762 | "no route-map vpn <import|export>$direction_str", | |
ddb5b488 PZ |
6763 | NO_STR |
6764 | "Specify route map\n" | |
b9c7bc5a PZ |
6765 | "Between current address-family and vpn\n" |
6766 | "For routes leaked from vpn to current address-family\n" | |
6767 | "For routes leaked from current address-family to vpn\n") | |
6768 | ||
bb4f6190 DS |
6769 | DEFPY(af_import_vrf_route_map, af_import_vrf_route_map_cmd, |
6770 | "[no] import vrf route-map RMAP$rmap_str", | |
6771 | NO_STR | |
6772 | "Import routes from another VRF\n" | |
6773 | "Vrf routes being filtered\n" | |
6774 | "Specify route map\n" | |
6775 | "name of route-map\n") | |
6776 | { | |
6777 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
bb4f6190 DS |
6778 | vpn_policy_direction_t dir = BGP_VPN_POLICY_DIR_FROMVPN; |
6779 | afi_t afi; | |
6780 | int idx = 0; | |
6781 | int yes = 1; | |
6782 | struct bgp *bgp_default; | |
6783 | ||
6784 | if (argv_find(argv, argc, "no", &idx)) | |
6785 | yes = 0; | |
6786 | ||
0ca70ba5 | 6787 | afi = vpn_policy_getafi(vty, bgp, true); |
69b07479 DS |
6788 | if (afi == AFI_MAX) |
6789 | return CMD_WARNING_CONFIG_FAILED; | |
bb4f6190 DS |
6790 | |
6791 | bgp_default = bgp_get_default(); | |
6792 | if (!bgp_default) { | |
6793 | int32_t ret; | |
6794 | as_t as = bgp->as; | |
6795 | ||
6796 | /* Auto-create assuming the same AS */ | |
6797 | ret = bgp_get(&bgp_default, &as, NULL, | |
6798 | BGP_INSTANCE_TYPE_DEFAULT); | |
6799 | ||
6800 | if (ret) { | |
6801 | vty_out(vty, | |
6802 | "VRF default is not configured as a bgp instance\n"); | |
6803 | return CMD_WARNING; | |
6804 | } | |
6805 | } | |
6806 | ||
69b07479 | 6807 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); |
bb4f6190 | 6808 | |
69b07479 DS |
6809 | if (yes) { |
6810 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6811 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6812 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6813 | bgp->vpn_policy[afi].rmap_name[dir] = | |
6814 | XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str); | |
6815 | bgp->vpn_policy[afi].rmap[dir] = | |
1de27621 | 6816 | route_map_lookup_warn_noexist(vty, rmap_str); |
69b07479 DS |
6817 | if (!bgp->vpn_policy[afi].rmap[dir]) |
6818 | return CMD_SUCCESS; | |
6819 | } else { | |
6820 | if (bgp->vpn_policy[afi].rmap_name[dir]) | |
6821 | XFREE(MTYPE_ROUTE_MAP_NAME, | |
6822 | bgp->vpn_policy[afi].rmap_name[dir]); | |
6823 | bgp->vpn_policy[afi].rmap_name[dir] = NULL; | |
6824 | bgp->vpn_policy[afi].rmap[dir] = NULL; | |
bb4f6190 DS |
6825 | } |
6826 | ||
69b07479 DS |
6827 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
6828 | ||
bb4f6190 DS |
6829 | return CMD_SUCCESS; |
6830 | } | |
6831 | ||
6832 | ALIAS(af_import_vrf_route_map, af_no_import_vrf_route_map_cmd, | |
6833 | "no import vrf route-map", | |
6834 | NO_STR | |
6835 | "Import routes from another VRF\n" | |
6836 | "Vrf routes being filtered\n" | |
6837 | "Specify route map\n") | |
6838 | ||
4d1b335c DA |
6839 | DEFPY(bgp_imexport_vrf, bgp_imexport_vrf_cmd, |
6840 | "[no] import vrf VIEWVRFNAME$import_name", | |
6841 | NO_STR | |
6842 | "Import routes from another VRF\n" | |
6843 | "VRF to import from\n" | |
6844 | "The name of the VRF\n") | |
12a844a5 DS |
6845 | { |
6846 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
6847 | struct listnode *node; | |
79ef8664 DS |
6848 | struct bgp *vrf_bgp, *bgp_default; |
6849 | int32_t ret = 0; | |
6850 | as_t as = bgp->as; | |
12a844a5 DS |
6851 | bool remove = false; |
6852 | int32_t idx = 0; | |
6853 | char *vname; | |
a8dadcf6 | 6854 | enum bgp_instance_type bgp_type = BGP_INSTANCE_TYPE_VRF; |
12a844a5 DS |
6855 | safi_t safi; |
6856 | afi_t afi; | |
6857 | ||
867f0cca | 6858 | if (import_name == NULL) { |
6859 | vty_out(vty, "%% Missing import name\n"); | |
6860 | return CMD_WARNING; | |
6861 | } | |
6862 | ||
12a844a5 DS |
6863 | if (argv_find(argv, argc, "no", &idx)) |
6864 | remove = true; | |
6865 | ||
0ca70ba5 DS |
6866 | afi = vpn_policy_getafi(vty, bgp, true); |
6867 | if (afi == AFI_MAX) | |
6868 | return CMD_WARNING_CONFIG_FAILED; | |
6869 | ||
12a844a5 DS |
6870 | safi = bgp_node_safi(vty); |
6871 | ||
25679caa | 6872 | if (((BGP_INSTANCE_TYPE_DEFAULT == bgp->inst_type) |
5742e42b | 6873 | && (strcmp(import_name, VRF_DEFAULT_NAME) == 0)) |
25679caa DS |
6874 | || (bgp->name && (strcmp(import_name, bgp->name) == 0))) { |
6875 | vty_out(vty, "%% Cannot %s vrf %s into itself\n", | |
6876 | remove ? "unimport" : "import", import_name); | |
6877 | return CMD_WARNING; | |
6878 | } | |
6879 | ||
79ef8664 DS |
6880 | bgp_default = bgp_get_default(); |
6881 | if (!bgp_default) { | |
6882 | /* Auto-create assuming the same AS */ | |
6883 | ret = bgp_get(&bgp_default, &as, NULL, | |
6884 | BGP_INSTANCE_TYPE_DEFAULT); | |
6885 | ||
6886 | if (ret) { | |
6887 | vty_out(vty, | |
6888 | "VRF default is not configured as a bgp instance\n"); | |
6889 | return CMD_WARNING; | |
6890 | } | |
6891 | } | |
6892 | ||
12a844a5 DS |
6893 | vrf_bgp = bgp_lookup_by_name(import_name); |
6894 | if (!vrf_bgp) { | |
5742e42b | 6895 | if (strcmp(import_name, VRF_DEFAULT_NAME) == 0) |
79ef8664 DS |
6896 | vrf_bgp = bgp_default; |
6897 | else | |
0fb8d6e6 DS |
6898 | /* Auto-create assuming the same AS */ |
6899 | ret = bgp_get(&vrf_bgp, &as, import_name, bgp_type); | |
a8dadcf6 | 6900 | |
6e2c7fe6 | 6901 | if (ret) { |
020a3f60 DS |
6902 | vty_out(vty, |
6903 | "VRF %s is not configured as a bgp instance\n", | |
6e2c7fe6 DS |
6904 | import_name); |
6905 | return CMD_WARNING; | |
6906 | } | |
12a844a5 DS |
6907 | } |
6908 | ||
12a844a5 | 6909 | if (remove) { |
44338987 | 6910 | vrf_unimport_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 | 6911 | } else { |
44338987 | 6912 | /* Already importing from "import_vrf"? */ |
12a844a5 DS |
6913 | for (ALL_LIST_ELEMENTS_RO(bgp->vpn_policy[afi].import_vrf, node, |
6914 | vname)) { | |
6915 | if (strcmp(vname, import_name) == 0) | |
6916 | return CMD_WARNING; | |
6917 | } | |
6918 | ||
44338987 | 6919 | vrf_import_from_vrf(bgp, vrf_bgp, afi, safi); |
12a844a5 DS |
6920 | } |
6921 | ||
6922 | return CMD_SUCCESS; | |
6923 | } | |
6924 | ||
b9c7bc5a PZ |
6925 | /* This command is valid only in a bgp vrf instance or the default instance */ |
6926 | DEFPY (bgp_imexport_vpn, | |
6927 | bgp_imexport_vpn_cmd, | |
6928 | "[no] <import|export>$direction_str vpn", | |
c7109e09 PZ |
6929 | NO_STR |
6930 | "Import routes to this address-family\n" | |
6931 | "Export routes from this address-family\n" | |
6932 | "to/from default instance VPN RIB\n") | |
ddb5b488 PZ |
6933 | { |
6934 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
b9c7bc5a | 6935 | int previous_state; |
ddb5b488 | 6936 | afi_t afi; |
b9c7bc5a | 6937 | safi_t safi; |
ddb5b488 | 6938 | int idx = 0; |
b9c7bc5a PZ |
6939 | int yes = 1; |
6940 | int flag; | |
6941 | vpn_policy_direction_t dir; | |
ddb5b488 | 6942 | |
b9c7bc5a | 6943 | if (argv_find(argv, argc, "no", &idx)) |
d555f3e9 | 6944 | yes = 0; |
ddb5b488 | 6945 | |
b9c7bc5a PZ |
6946 | if (BGP_INSTANCE_TYPE_VRF != bgp->inst_type && |
6947 | BGP_INSTANCE_TYPE_DEFAULT != bgp->inst_type) { | |
ddb5b488 | 6948 | |
b9c7bc5a PZ |
6949 | vty_out(vty, "%% import|export vpn valid only for bgp vrf or default instance\n"); |
6950 | return CMD_WARNING_CONFIG_FAILED; | |
6951 | } | |
ddb5b488 | 6952 | |
b9c7bc5a PZ |
6953 | afi = bgp_node_afi(vty); |
6954 | safi = bgp_node_safi(vty); | |
6955 | if ((SAFI_UNICAST != safi) || ((AFI_IP != afi) && (AFI_IP6 != afi))) { | |
6956 | vty_out(vty, "%% import|export vpn valid only for unicast ipv4|ipv6\n"); | |
6957 | return CMD_WARNING_CONFIG_FAILED; | |
6958 | } | |
ddb5b488 | 6959 | |
b9c7bc5a PZ |
6960 | if (!strcmp(direction_str, "import")) { |
6961 | flag = BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT; | |
6962 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
6963 | } else if (!strcmp(direction_str, "export")) { | |
6964 | flag = BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT; | |
6965 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
6966 | } else { | |
6967 | vty_out(vty, "%% unknown direction %s\n", direction_str); | |
6968 | return CMD_WARNING_CONFIG_FAILED; | |
6969 | } | |
6970 | ||
6971 | previous_state = CHECK_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 | 6972 | |
b9c7bc5a PZ |
6973 | if (yes) { |
6974 | SET_FLAG(bgp->af_flags[afi][safi], flag); | |
6975 | if (!previous_state) { | |
6976 | /* trigger export current vrf */ | |
ddb5b488 PZ |
6977 | vpn_leak_postchange(dir, afi, bgp_get_default(), bgp); |
6978 | } | |
b9c7bc5a PZ |
6979 | } else { |
6980 | if (previous_state) { | |
6981 | /* trigger un-export current vrf */ | |
6982 | vpn_leak_prechange(dir, afi, bgp_get_default(), bgp); | |
6983 | } | |
6984 | UNSET_FLAG(bgp->af_flags[afi][safi], flag); | |
ddb5b488 PZ |
6985 | } |
6986 | ||
6987 | return CMD_SUCCESS; | |
6988 | } | |
6989 | ||
301ad80a PG |
6990 | DEFPY (af_routetarget_import, |
6991 | af_routetarget_import_cmd, | |
6992 | "[no] <rt|route-target> redirect import RTLIST...", | |
6993 | NO_STR | |
6994 | "Specify route target list\n" | |
6995 | "Specify route target list\n" | |
6996 | "Flow-spec redirect type route target\n" | |
6997 | "Import routes to this address-family\n" | |
6998 | "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n") | |
6999 | { | |
7000 | VTY_DECLVAR_CONTEXT(bgp, bgp); | |
7001 | int ret; | |
7002 | struct ecommunity *ecom = NULL; | |
301ad80a PG |
7003 | afi_t afi; |
7004 | int idx = 0; | |
7005 | int yes = 1; | |
7006 | ||
7007 | if (argv_find(argv, argc, "no", &idx)) | |
7008 | yes = 0; | |
7009 | ||
0ca70ba5 | 7010 | afi = vpn_policy_getafi(vty, bgp, false); |
69b07479 DS |
7011 | if (afi == AFI_MAX) |
7012 | return CMD_WARNING_CONFIG_FAILED; | |
7013 | ||
301ad80a PG |
7014 | if (yes) { |
7015 | if (!argv_find(argv, argc, "RTLIST", &idx)) { | |
7016 | vty_out(vty, "%% Missing RTLIST\n"); | |
7017 | return CMD_WARNING_CONFIG_FAILED; | |
7018 | } | |
7019 | ret = set_ecom_list(vty, argc - idx, argv + idx, &ecom); | |
7020 | if (ret != CMD_SUCCESS) | |
7021 | return ret; | |
7022 | } | |
69b07479 DS |
7023 | |
7024 | if (yes) { | |
7025 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7026 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7027 | .import_redirect_rtlist); |
69b07479 DS |
7028 | bgp->vpn_policy[afi].import_redirect_rtlist = |
7029 | ecommunity_dup(ecom); | |
7030 | } else { | |
7031 | if (bgp->vpn_policy[afi].import_redirect_rtlist) | |
7032 | ecommunity_free(&bgp->vpn_policy[afi] | |
301ad80a | 7033 | .import_redirect_rtlist); |
69b07479 | 7034 | bgp->vpn_policy[afi].import_redirect_rtlist = NULL; |
301ad80a | 7035 | } |
69b07479 | 7036 | |
301ad80a PG |
7037 | if (ecom) |
7038 | ecommunity_free(&ecom); | |
7039 | ||
7040 | return CMD_SUCCESS; | |
7041 | } | |
7042 | ||
505e5056 | 7043 | DEFUN_NOSH (address_family_ipv4_safi, |
7c40bf39 | 7044 | address_family_ipv4_safi_cmd, |
7045 | "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7046 | "Enter Address Family command mode\n" | |
7047 | "Address Family\n" | |
7048 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
718e3744 | 7049 | { |
f51bae9c | 7050 | |
d62a17ae | 7051 | if (argc == 3) { |
2131d5cf | 7052 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7053 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7054 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7055 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7056 | && safi != SAFI_EVPN) { |
31947174 MK |
7057 | vty_out(vty, |
7058 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7059 | return CMD_WARNING_CONFIG_FAILED; |
7060 | } | |
d62a17ae | 7061 | vty->node = bgp_node_type(AFI_IP, safi); |
7062 | } else | |
7063 | vty->node = BGP_IPV4_NODE; | |
718e3744 | 7064 | |
d62a17ae | 7065 | return CMD_SUCCESS; |
718e3744 | 7066 | } |
7067 | ||
505e5056 | 7068 | DEFUN_NOSH (address_family_ipv6_safi, |
7c40bf39 | 7069 | address_family_ipv6_safi_cmd, |
7070 | "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]", | |
7071 | "Enter Address Family command mode\n" | |
7072 | "Address Family\n" | |
7073 | BGP_SAFI_WITH_LABEL_HELP_STR) | |
25ffbdc1 | 7074 | { |
d62a17ae | 7075 | if (argc == 3) { |
2131d5cf | 7076 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7077 | safi_t safi = bgp_vty_safi_from_str(argv[2]->text); |
a4d82a8a PZ |
7078 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT |
7079 | && safi != SAFI_UNICAST && safi != SAFI_MULTICAST | |
9d00a487 | 7080 | && safi != SAFI_EVPN) { |
31947174 MK |
7081 | vty_out(vty, |
7082 | "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); | |
2131d5cf LB |
7083 | return CMD_WARNING_CONFIG_FAILED; |
7084 | } | |
d62a17ae | 7085 | vty->node = bgp_node_type(AFI_IP6, safi); |
7086 | } else | |
7087 | vty->node = BGP_IPV6_NODE; | |
25ffbdc1 | 7088 | |
d62a17ae | 7089 | return CMD_SUCCESS; |
25ffbdc1 | 7090 | } |
718e3744 | 7091 | |
d6902373 | 7092 | #ifdef KEEP_OLD_VPN_COMMANDS |
505e5056 | 7093 | DEFUN_NOSH (address_family_vpnv4, |
718e3744 | 7094 | address_family_vpnv4_cmd, |
8334fd5a | 7095 | "address-family vpnv4 [unicast]", |
718e3744 | 7096 | "Enter Address Family command mode\n" |
8c3deaae | 7097 | "Address Family\n" |
3a2d747c | 7098 | "Address Family modifier\n") |
718e3744 | 7099 | { |
d62a17ae | 7100 | vty->node = BGP_VPNV4_NODE; |
7101 | return CMD_SUCCESS; | |
718e3744 | 7102 | } |
7103 | ||
505e5056 | 7104 | DEFUN_NOSH (address_family_vpnv6, |
8ecd3266 | 7105 | address_family_vpnv6_cmd, |
8334fd5a | 7106 | "address-family vpnv6 [unicast]", |
8ecd3266 | 7107 | "Enter Address Family command mode\n" |
8c3deaae | 7108 | "Address Family\n" |
3a2d747c | 7109 | "Address Family modifier\n") |
8ecd3266 | 7110 | { |
d62a17ae | 7111 | vty->node = BGP_VPNV6_NODE; |
7112 | return CMD_SUCCESS; | |
8ecd3266 | 7113 | } |
64e4a6c5 | 7114 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
d6902373 | 7115 | |
505e5056 | 7116 | DEFUN_NOSH (address_family_evpn, |
4e0b7b6d | 7117 | address_family_evpn_cmd, |
7111c1a0 | 7118 | "address-family l2vpn evpn", |
4e0b7b6d | 7119 | "Enter Address Family command mode\n" |
7111c1a0 QY |
7120 | "Address Family\n" |
7121 | "Address Family modifier\n") | |
4e0b7b6d | 7122 | { |
2131d5cf | 7123 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
d62a17ae | 7124 | vty->node = BGP_EVPN_NODE; |
7125 | return CMD_SUCCESS; | |
4e0b7b6d PG |
7126 | } |
7127 | ||
505e5056 | 7128 | DEFUN_NOSH (exit_address_family, |
718e3744 | 7129 | exit_address_family_cmd, |
7130 | "exit-address-family", | |
7131 | "Exit from Address Family configuration mode\n") | |
7132 | { | |
d62a17ae | 7133 | if (vty->node == BGP_IPV4_NODE || vty->node == BGP_IPV4M_NODE |
7134 | || vty->node == BGP_IPV4L_NODE || vty->node == BGP_VPNV4_NODE | |
7135 | || vty->node == BGP_IPV6_NODE || vty->node == BGP_IPV6M_NODE | |
7136 | || vty->node == BGP_IPV6L_NODE || vty->node == BGP_VPNV6_NODE | |
925bf671 PG |
7137 | || vty->node == BGP_EVPN_NODE |
7138 | || vty->node == BGP_FLOWSPECV4_NODE | |
7139 | || vty->node == BGP_FLOWSPECV6_NODE) | |
d62a17ae | 7140 | vty->node = BGP_NODE; |
7141 | return CMD_SUCCESS; | |
718e3744 | 7142 | } |
6b0655a2 | 7143 | |
8ad7271d | 7144 | /* Recalculate bestpath and re-advertise a prefix */ |
d62a17ae | 7145 | static int bgp_clear_prefix(struct vty *vty, const char *view_name, |
7146 | const char *ip_str, afi_t afi, safi_t safi, | |
7147 | struct prefix_rd *prd) | |
7148 | { | |
7149 | int ret; | |
7150 | struct prefix match; | |
7151 | struct bgp_node *rn; | |
7152 | struct bgp_node *rm; | |
7153 | struct bgp *bgp; | |
7154 | struct bgp_table *table; | |
7155 | struct bgp_table *rib; | |
7156 | ||
7157 | /* BGP structure lookup. */ | |
7158 | if (view_name) { | |
7159 | bgp = bgp_lookup_by_name(view_name); | |
7160 | if (bgp == NULL) { | |
7161 | vty_out(vty, "%% Can't find BGP instance %s\n", | |
7162 | view_name); | |
7163 | return CMD_WARNING; | |
7164 | } | |
7165 | } else { | |
7166 | bgp = bgp_get_default(); | |
7167 | if (bgp == NULL) { | |
7168 | vty_out(vty, "%% No BGP process is configured\n"); | |
7169 | return CMD_WARNING; | |
7170 | } | |
7171 | } | |
7172 | ||
7173 | /* Check IP address argument. */ | |
7174 | ret = str2prefix(ip_str, &match); | |
7175 | if (!ret) { | |
7176 | vty_out(vty, "%% address is malformed\n"); | |
7177 | return CMD_WARNING; | |
7178 | } | |
7179 | ||
7180 | match.family = afi2family(afi); | |
7181 | rib = bgp->rib[afi][safi]; | |
7182 | ||
7183 | if (safi == SAFI_MPLS_VPN) { | |
7184 | for (rn = bgp_table_top(rib); rn; rn = bgp_route_next(rn)) { | |
7185 | if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0) | |
7186 | continue; | |
7187 | ||
67009e22 DS |
7188 | table = bgp_node_get_bgp_table_info(rn); |
7189 | if (table != NULL) { | |
7190 | ||
d62a17ae | 7191 | if ((rm = bgp_node_match(table, &match)) |
7192 | != NULL) { | |
7193 | if (rm->p.prefixlen | |
7194 | == match.prefixlen) { | |
343cdb61 | 7195 | SET_FLAG(rm->flags, |
d62a17ae | 7196 | BGP_NODE_USER_CLEAR); |
7197 | bgp_process(bgp, rm, afi, safi); | |
7198 | } | |
7199 | bgp_unlock_node(rm); | |
7200 | } | |
7201 | } | |
7202 | } | |
7203 | } else { | |
7204 | if ((rn = bgp_node_match(rib, &match)) != NULL) { | |
7205 | if (rn->p.prefixlen == match.prefixlen) { | |
7206 | SET_FLAG(rn->flags, BGP_NODE_USER_CLEAR); | |
7207 | bgp_process(bgp, rn, afi, safi); | |
7208 | } | |
7209 | bgp_unlock_node(rn); | |
7210 | } | |
7211 | } | |
7212 | ||
7213 | return CMD_SUCCESS; | |
8ad7271d DS |
7214 | } |
7215 | ||
b09b5ae0 | 7216 | /* one clear bgp command to rule them all */ |
718e3744 | 7217 | DEFUN (clear_ip_bgp_all, |
7218 | clear_ip_bgp_all_cmd, | |
d7b9898c | 7219 | "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 | 7220 | CLEAR_STR |
7221 | IP_STR | |
7222 | BGP_STR | |
838758ac | 7223 | BGP_INSTANCE_HELP_STR |
510afcd6 | 7224 | BGP_AFI_HELP_STR |
fd5e7b70 | 7225 | "Address Family\n" |
510afcd6 | 7226 | BGP_SAFI_WITH_LABEL_HELP_STR |
fd5e7b70 | 7227 | "Address Family modifier\n" |
b09b5ae0 DW |
7228 | "Clear all peers\n" |
7229 | "BGP neighbor address to clear\n" | |
a80beece | 7230 | "BGP IPv6 neighbor to clear\n" |
838758ac | 7231 | "BGP neighbor on interface to clear\n" |
b09b5ae0 DW |
7232 | "Clear peers with the AS number\n" |
7233 | "Clear all external peers\n" | |
718e3744 | 7234 | "Clear all members of peer-group\n" |
b09b5ae0 | 7235 | "BGP peer-group name\n" |
b09b5ae0 DW |
7236 | BGP_SOFT_STR |
7237 | BGP_SOFT_IN_STR | |
b09b5ae0 DW |
7238 | BGP_SOFT_OUT_STR |
7239 | BGP_SOFT_IN_STR | |
7240 | "Push out prefix-list ORF and do inbound soft reconfig\n" | |
b09b5ae0 | 7241 | BGP_SOFT_OUT_STR) |
718e3744 | 7242 | { |
d62a17ae | 7243 | char *vrf = NULL; |
7244 | ||
7245 | afi_t afi = AFI_IP6; | |
7246 | safi_t safi = SAFI_UNICAST; | |
7247 | enum clear_sort clr_sort = clear_peer; | |
7248 | enum bgp_clear_type clr_type; | |
7249 | char *clr_arg = NULL; | |
7250 | ||
7251 | int idx = 0; | |
7252 | ||
7253 | /* clear [ip] bgp */ | |
7254 | if (argv_find(argv, argc, "ip", &idx)) | |
7255 | afi = AFI_IP; | |
7256 | ||
9a8bdf1c PG |
7257 | /* [<vrf> VIEWVRFNAME] */ |
7258 | if (argv_find(argv, argc, "vrf", &idx)) { | |
7259 | vrf = argv[idx + 1]->arg; | |
7260 | idx += 2; | |
7261 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7262 | vrf = NULL; | |
7263 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7264 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 7265 | vrf = argv[idx + 1]->arg; |
7266 | idx += 2; | |
7267 | } | |
d62a17ae | 7268 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
7269 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) | |
7270 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
7271 | ||
d7b9898c | 7272 | /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */ |
d62a17ae | 7273 | if (argv_find(argv, argc, "*", &idx)) { |
7274 | clr_sort = clear_all; | |
7275 | } else if (argv_find(argv, argc, "A.B.C.D", &idx)) { | |
7276 | clr_sort = clear_peer; | |
7277 | clr_arg = argv[idx]->arg; | |
7278 | } else if (argv_find(argv, argc, "X:X::X:X", &idx)) { | |
7279 | clr_sort = clear_peer; | |
7280 | clr_arg = argv[idx]->arg; | |
7281 | } else if (argv_find(argv, argc, "peer-group", &idx)) { | |
7282 | clr_sort = clear_group; | |
7283 | idx++; | |
7284 | clr_arg = argv[idx]->arg; | |
d7b9898c | 7285 | } else if (argv_find(argv, argc, "PGNAME", &idx)) { |
d62a17ae | 7286 | clr_sort = clear_peer; |
7287 | clr_arg = argv[idx]->arg; | |
7288 | } else if (argv_find(argv, argc, "(1-4294967295)", &idx)) { | |
7289 | clr_sort = clear_as; | |
7290 | clr_arg = argv[idx]->arg; | |
7291 | } else if (argv_find(argv, argc, "external", &idx)) { | |
7292 | clr_sort = clear_external; | |
7293 | } | |
7294 | ||
7295 | /* [<soft [<in|out>]|in [prefix-filter]|out>] */ | |
7296 | if (argv_find(argv, argc, "soft", &idx)) { | |
7297 | if (argv_find(argv, argc, "in", &idx) | |
7298 | || argv_find(argv, argc, "out", &idx)) | |
7299 | clr_type = strmatch(argv[idx]->text, "in") | |
7300 | ? BGP_CLEAR_SOFT_IN | |
7301 | : BGP_CLEAR_SOFT_OUT; | |
7302 | else | |
7303 | clr_type = BGP_CLEAR_SOFT_BOTH; | |
7304 | } else if (argv_find(argv, argc, "in", &idx)) { | |
7305 | clr_type = argv_find(argv, argc, "prefix-filter", &idx) | |
7306 | ? BGP_CLEAR_SOFT_IN_ORF_PREFIX | |
7307 | : BGP_CLEAR_SOFT_IN; | |
7308 | } else if (argv_find(argv, argc, "out", &idx)) { | |
7309 | clr_type = BGP_CLEAR_SOFT_OUT; | |
7310 | } else | |
7311 | clr_type = BGP_CLEAR_SOFT_NONE; | |
7312 | ||
7313 | return bgp_clear_vty(vty, vrf, afi, safi, clr_sort, clr_type, clr_arg); | |
838758ac | 7314 | } |
01080f7c | 7315 | |
8ad7271d DS |
7316 | DEFUN (clear_ip_bgp_prefix, |
7317 | clear_ip_bgp_prefix_cmd, | |
18c57037 | 7318 | "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M", |
8ad7271d DS |
7319 | CLEAR_STR |
7320 | IP_STR | |
7321 | BGP_STR | |
838758ac | 7322 | BGP_INSTANCE_HELP_STR |
8ad7271d | 7323 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7324 | "IPv4 prefix\n") |
8ad7271d | 7325 | { |
d62a17ae | 7326 | char *vrf = NULL; |
7327 | char *prefix = NULL; | |
8ad7271d | 7328 | |
d62a17ae | 7329 | int idx = 0; |
01080f7c | 7330 | |
d62a17ae | 7331 | /* [<view|vrf> VIEWVRFNAME] */ |
9a8bdf1c PG |
7332 | if (argv_find(argv, argc, "vrf", &idx)) { |
7333 | vrf = argv[idx + 1]->arg; | |
7334 | idx += 2; | |
7335 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
7336 | vrf = NULL; | |
7337 | } else if (argv_find(argv, argc, "view", &idx)) { | |
7338 | /* [<view> VIEWVRFNAME] */ | |
7339 | vrf = argv[idx + 1]->arg; | |
7340 | idx += 2; | |
7341 | } | |
0c7b1b01 | 7342 | |
d62a17ae | 7343 | prefix = argv[argc - 1]->arg; |
8ad7271d | 7344 | |
d62a17ae | 7345 | return bgp_clear_prefix(vty, vrf, prefix, AFI_IP, SAFI_UNICAST, NULL); |
838758ac | 7346 | } |
8ad7271d | 7347 | |
b09b5ae0 DW |
7348 | DEFUN (clear_bgp_ipv6_safi_prefix, |
7349 | clear_bgp_ipv6_safi_prefix_cmd, | |
46f296b4 | 7350 | "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7351 | CLEAR_STR |
3a2d747c | 7352 | IP_STR |
718e3744 | 7353 | BGP_STR |
8c3deaae | 7354 | "Address Family\n" |
46f296b4 | 7355 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7356 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7357 | "IPv6 prefix\n") |
718e3744 | 7358 | { |
9b475e76 PG |
7359 | int idx_safi = 0; |
7360 | int idx_ipv6_prefix = 0; | |
7361 | safi_t safi = SAFI_UNICAST; | |
7362 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7363 | argv[idx_ipv6_prefix]->arg : NULL; | |
7364 | ||
7365 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); | |
d62a17ae | 7366 | return bgp_clear_prefix( |
9b475e76 PG |
7367 | vty, NULL, prefix, AFI_IP6, |
7368 | safi, NULL); | |
838758ac | 7369 | } |
01080f7c | 7370 | |
b09b5ae0 DW |
7371 | DEFUN (clear_bgp_instance_ipv6_safi_prefix, |
7372 | clear_bgp_instance_ipv6_safi_prefix_cmd, | |
18c57037 | 7373 | "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", |
718e3744 | 7374 | CLEAR_STR |
3a2d747c | 7375 | IP_STR |
718e3744 | 7376 | BGP_STR |
838758ac | 7377 | BGP_INSTANCE_HELP_STR |
8c3deaae | 7378 | "Address Family\n" |
46f296b4 | 7379 | BGP_SAFI_HELP_STR |
b09b5ae0 | 7380 | "Clear bestpath and re-advertise\n" |
0c7b1b01 | 7381 | "IPv6 prefix\n") |
718e3744 | 7382 | { |
9b475e76 | 7383 | int idx_safi = 0; |
9a8bdf1c | 7384 | int idx_vrfview = 0; |
9b475e76 PG |
7385 | int idx_ipv6_prefix = 0; |
7386 | safi_t safi = SAFI_UNICAST; | |
7387 | char *prefix = argv_find(argv, argc, "X:X::X:X/M", &idx_ipv6_prefix) ? | |
7388 | argv[idx_ipv6_prefix]->arg : NULL; | |
9a8bdf1c | 7389 | char *vrfview = NULL; |
9b475e76 | 7390 | |
9a8bdf1c PG |
7391 | /* [<view|vrf> VIEWVRFNAME] */ |
7392 | if (argv_find(argv, argc, "vrf", &idx_vrfview)) { | |
7393 | vrfview = argv[idx_vrfview + 1]->arg; | |
7394 | if (vrfview && strmatch(vrfview, VRF_DEFAULT_NAME)) | |
7395 | vrfview = NULL; | |
7396 | } else if (argv_find(argv, argc, "view", &idx_vrfview)) { | |
7397 | /* [<view> VIEWVRFNAME] */ | |
7398 | vrfview = argv[idx_vrfview + 1]->arg; | |
7399 | } | |
9b475e76 PG |
7400 | argv_find_and_parse_safi(argv, argc, &idx_safi, &safi); |
7401 | ||
d62a17ae | 7402 | return bgp_clear_prefix( |
9b475e76 PG |
7403 | vty, vrfview, prefix, |
7404 | AFI_IP6, safi, NULL); | |
718e3744 | 7405 | } |
7406 | ||
b09b5ae0 DW |
7407 | DEFUN (show_bgp_views, |
7408 | show_bgp_views_cmd, | |
d6e3c605 | 7409 | "show [ip] bgp views", |
b09b5ae0 | 7410 | SHOW_STR |
d6e3c605 | 7411 | IP_STR |
01080f7c | 7412 | BGP_STR |
b09b5ae0 | 7413 | "Show the defined BGP views\n") |
01080f7c | 7414 | { |
d62a17ae | 7415 | struct list *inst = bm->bgp; |
7416 | struct listnode *node; | |
7417 | struct bgp *bgp; | |
01080f7c | 7418 | |
d62a17ae | 7419 | vty_out(vty, "Defined BGP views:\n"); |
7420 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7421 | /* Skip VRFs. */ | |
7422 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) | |
7423 | continue; | |
7424 | vty_out(vty, "\t%s (AS%u)\n", bgp->name ? bgp->name : "(null)", | |
7425 | bgp->as); | |
7426 | } | |
e52702f2 | 7427 | |
d62a17ae | 7428 | return CMD_SUCCESS; |
e0081f70 ML |
7429 | } |
7430 | ||
8386ac43 | 7431 | DEFUN (show_bgp_vrfs, |
7432 | show_bgp_vrfs_cmd, | |
d6e3c605 | 7433 | "show [ip] bgp vrfs [json]", |
8386ac43 | 7434 | SHOW_STR |
d6e3c605 | 7435 | IP_STR |
8386ac43 | 7436 | BGP_STR |
7437 | "Show BGP VRFs\n" | |
9973d184 | 7438 | JSON_STR) |
8386ac43 | 7439 | { |
fe1dc5a3 | 7440 | char buf[ETHER_ADDR_STRLEN]; |
d62a17ae | 7441 | struct list *inst = bm->bgp; |
7442 | struct listnode *node; | |
7443 | struct bgp *bgp; | |
9f049418 | 7444 | bool uj = use_json(argc, argv); |
d62a17ae | 7445 | json_object *json = NULL; |
7446 | json_object *json_vrfs = NULL; | |
7447 | int count = 0; | |
d62a17ae | 7448 | |
d62a17ae | 7449 | if (uj) { |
7450 | json = json_object_new_object(); | |
7451 | json_vrfs = json_object_new_object(); | |
7452 | } | |
7453 | ||
7454 | for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { | |
7455 | const char *name, *type; | |
7456 | struct peer *peer; | |
7fe96307 | 7457 | struct listnode *node2, *nnode2; |
d62a17ae | 7458 | int peers_cfg, peers_estb; |
7459 | json_object *json_vrf = NULL; | |
d62a17ae | 7460 | |
7461 | /* Skip Views. */ | |
7462 | if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW) | |
7463 | continue; | |
7464 | ||
7465 | count++; | |
efb4077a | 7466 | if (!uj && count == 1) { |
fe1dc5a3 | 7467 | vty_out(vty, |
efb4077a | 7468 | "%4s %-5s %-16s %9s %10s %-37s\n", |
a4d82a8a | 7469 | "Type", "Id", "routerId", "#PeersVfg", |
efb4077a CS |
7470 | "#PeersEstb", "Name"); |
7471 | vty_out(vty, "%11s %-16s %-21s %-6s\n", " ", | |
7472 | "L3-VNI", "RouterMAC", "Interface"); | |
7473 | } | |
d62a17ae | 7474 | |
7475 | peers_cfg = peers_estb = 0; | |
7476 | if (uj) | |
7477 | json_vrf = json_object_new_object(); | |
7478 | ||
7479 | ||
7fe96307 | 7480 | for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { |
d62a17ae | 7481 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) |
7482 | continue; | |
7483 | peers_cfg++; | |
7484 | if (peer->status == Established) | |
7485 | peers_estb++; | |
7486 | } | |
7487 | ||
7488 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) { | |
5742e42b | 7489 | name = VRF_DEFAULT_NAME; |
d62a17ae | 7490 | type = "DFLT"; |
7491 | } else { | |
7492 | name = bgp->name; | |
7493 | type = "VRF"; | |
7494 | } | |
7495 | ||
a8bf7d9c | 7496 | |
d62a17ae | 7497 | if (uj) { |
a4d82a8a PZ |
7498 | int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7499 | ? -1 | |
7500 | : (int64_t)bgp->vrf_id; | |
d62a17ae | 7501 | json_object_string_add(json_vrf, "type", type); |
7502 | json_object_int_add(json_vrf, "vrfId", vrf_id_ui); | |
7503 | json_object_string_add(json_vrf, "routerId", | |
7504 | inet_ntoa(bgp->router_id)); | |
7505 | json_object_int_add(json_vrf, "numConfiguredPeers", | |
7506 | peers_cfg); | |
7507 | json_object_int_add(json_vrf, "numEstablishedPeers", | |
7508 | peers_estb); | |
7509 | ||
fe1dc5a3 | 7510 | json_object_int_add(json_vrf, "l3vni", bgp->l3vni); |
a4d82a8a PZ |
7511 | json_object_string_add( |
7512 | json_vrf, "rmac", | |
7513 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); | |
efb4077a CS |
7514 | json_object_string_add(json_vrf, "interface", |
7515 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
7516 | bgp->vrf_id)); | |
d62a17ae | 7517 | json_object_object_add(json_vrfs, name, json_vrf); |
efb4077a | 7518 | } else { |
fe1dc5a3 | 7519 | vty_out(vty, |
efb4077a | 7520 | "%4s %-5d %-16s %-9u %-10u %-37s\n", |
a4d82a8a PZ |
7521 | type, |
7522 | bgp->vrf_id == VRF_UNKNOWN ? -1 | |
7523 | : (int)bgp->vrf_id, | |
7524 | inet_ntoa(bgp->router_id), peers_cfg, | |
efb4077a CS |
7525 | peers_estb, name); |
7526 | vty_out(vty,"%11s %-16u %-21s %-20s\n", " ", | |
7527 | bgp->l3vni, | |
7528 | prefix_mac2str(&bgp->rmac, buf, sizeof(buf)), | |
7529 | ifindex2ifname(bgp->l3vni_svi_ifindex, | |
7530 | bgp->vrf_id)); | |
7531 | } | |
d62a17ae | 7532 | } |
7533 | ||
7534 | if (uj) { | |
7535 | json_object_object_add(json, "vrfs", json_vrfs); | |
7536 | ||
7537 | json_object_int_add(json, "totalVrfs", count); | |
7538 | ||
996c9314 LB |
7539 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
7540 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 7541 | json_object_free(json); |
7542 | } else { | |
7543 | if (count) | |
7544 | vty_out(vty, | |
7545 | "\nTotal number of VRFs (including default): %d\n", | |
7546 | count); | |
7547 | } | |
7548 | ||
7549 | return CMD_SUCCESS; | |
8386ac43 | 7550 | } |
7551 | ||
48ecf8f5 DS |
7552 | DEFUN (show_bgp_mac_hash, |
7553 | show_bgp_mac_hash_cmd, | |
7554 | "show bgp mac hash", | |
7555 | SHOW_STR | |
7556 | BGP_STR | |
7557 | "Mac Address\n" | |
7558 | "Mac Address database\n") | |
7559 | { | |
7560 | bgp_mac_dump_table(vty); | |
7561 | ||
7562 | return CMD_SUCCESS; | |
7563 | } | |
acf71666 | 7564 | |
e3b78da8 | 7565 | static void show_tip_entry(struct hash_bucket *bucket, void *args) |
acf71666 | 7566 | { |
0291c246 | 7567 | struct vty *vty = (struct vty *)args; |
e3b78da8 | 7568 | struct tip_addr *tip = (struct tip_addr *)bucket->data; |
acf71666 | 7569 | |
60466a63 | 7570 | vty_out(vty, "addr: %s, count: %d\n", inet_ntoa(tip->addr), |
acf71666 MK |
7571 | tip->refcnt); |
7572 | } | |
7573 | ||
7574 | static void bgp_show_martian_nexthops(struct vty *vty, struct bgp *bgp) | |
7575 | { | |
7576 | vty_out(vty, "self nexthop database:\n"); | |
af97a18b | 7577 | bgp_nexthop_show_address_hash(vty, bgp); |
acf71666 MK |
7578 | |
7579 | vty_out(vty, "Tunnel-ip database:\n"); | |
7580 | hash_iterate(bgp->tip_hash, | |
e3b78da8 | 7581 | (void (*)(struct hash_bucket *, void *))show_tip_entry, |
acf71666 MK |
7582 | vty); |
7583 | } | |
7584 | ||
15c81ca4 DS |
7585 | DEFUN(show_bgp_martian_nexthop_db, show_bgp_martian_nexthop_db_cmd, |
7586 | "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop", | |
7587 | SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR | |
60466a63 QY |
7588 | "martian next-hops\n" |
7589 | "martian next-hop database\n") | |
acf71666 | 7590 | { |
0291c246 | 7591 | struct bgp *bgp = NULL; |
15c81ca4 | 7592 | int idx = 0; |
9a8bdf1c PG |
7593 | char *name = NULL; |
7594 | ||
7595 | /* [<vrf> VIEWVRFNAME] */ | |
7596 | if (argv_find(argv, argc, "vrf", &idx)) { | |
7597 | name = argv[idx + 1]->arg; | |
7598 | if (name && strmatch(name, VRF_DEFAULT_NAME)) | |
7599 | name = NULL; | |
7600 | } else if (argv_find(argv, argc, "view", &idx)) | |
7601 | /* [<view> VIEWVRFNAME] */ | |
7602 | name = argv[idx + 1]->arg; | |
7603 | if (name) | |
7604 | bgp = bgp_lookup_by_name(name); | |
15c81ca4 DS |
7605 | else |
7606 | bgp = bgp_get_default(); | |
acf71666 | 7607 | |
acf71666 MK |
7608 | if (!bgp) { |
7609 | vty_out(vty, "%% No BGP process is configured\n"); | |
7610 | return CMD_WARNING; | |
7611 | } | |
7612 | bgp_show_martian_nexthops(vty, bgp); | |
7613 | ||
7614 | return CMD_SUCCESS; | |
7615 | } | |
7616 | ||
f412b39a | 7617 | DEFUN (show_bgp_memory, |
4bf6a362 | 7618 | show_bgp_memory_cmd, |
7fa12b13 | 7619 | "show [ip] bgp memory", |
4bf6a362 | 7620 | SHOW_STR |
3a2d747c | 7621 | IP_STR |
4bf6a362 PJ |
7622 | BGP_STR |
7623 | "Global BGP memory statistics\n") | |
7624 | { | |
d62a17ae | 7625 | char memstrbuf[MTYPE_MEMSTR_LEN]; |
7626 | unsigned long count; | |
7627 | ||
7628 | /* RIB related usage stats */ | |
7629 | count = mtype_stats_alloc(MTYPE_BGP_NODE); | |
7630 | vty_out(vty, "%ld RIB nodes, using %s of memory\n", count, | |
7631 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7632 | count * sizeof(struct bgp_node))); | |
7633 | ||
7634 | count = mtype_stats_alloc(MTYPE_BGP_ROUTE); | |
7635 | vty_out(vty, "%ld BGP routes, using %s of memory\n", count, | |
7636 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
4b7e6066 | 7637 | count * sizeof(struct bgp_path_info))); |
d62a17ae | 7638 | if ((count = mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA))) |
7639 | vty_out(vty, "%ld BGP route ancillaries, using %s of memory\n", | |
7640 | count, | |
4b7e6066 DS |
7641 | mtype_memstr( |
7642 | memstrbuf, sizeof(memstrbuf), | |
7643 | count * sizeof(struct bgp_path_info_extra))); | |
d62a17ae | 7644 | |
7645 | if ((count = mtype_stats_alloc(MTYPE_BGP_STATIC))) | |
7646 | vty_out(vty, "%ld Static routes, using %s of memory\n", count, | |
7647 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7648 | count * sizeof(struct bgp_static))); | |
7649 | ||
7650 | if ((count = mtype_stats_alloc(MTYPE_BGP_PACKET))) | |
7651 | vty_out(vty, "%ld Packets, using %s of memory\n", count, | |
7652 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7653 | count * sizeof(struct bpacket))); | |
7654 | ||
7655 | /* Adj-In/Out */ | |
7656 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_IN))) | |
7657 | vty_out(vty, "%ld Adj-In entries, using %s of memory\n", count, | |
7658 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7659 | count * sizeof(struct bgp_adj_in))); | |
7660 | if ((count = mtype_stats_alloc(MTYPE_BGP_ADJ_OUT))) | |
7661 | vty_out(vty, "%ld Adj-Out entries, using %s of memory\n", count, | |
7662 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7663 | count * sizeof(struct bgp_adj_out))); | |
7664 | ||
7665 | if ((count = mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE))) | |
7666 | vty_out(vty, "%ld Nexthop cache entries, using %s of memory\n", | |
7667 | count, | |
7668 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7669 | count * sizeof(struct bgp_nexthop_cache))); | |
7670 | ||
7671 | if ((count = mtype_stats_alloc(MTYPE_BGP_DAMP_INFO))) | |
7672 | vty_out(vty, "%ld Dampening entries, using %s of memory\n", | |
7673 | count, | |
7674 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7675 | count * sizeof(struct bgp_damp_info))); | |
7676 | ||
7677 | /* Attributes */ | |
7678 | count = attr_count(); | |
7679 | vty_out(vty, "%ld BGP attributes, using %s of memory\n", count, | |
7680 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7681 | count * sizeof(struct attr))); | |
7682 | ||
7683 | if ((count = attr_unknown_count())) | |
7684 | vty_out(vty, "%ld unknown attributes\n", count); | |
7685 | ||
7686 | /* AS_PATH attributes */ | |
7687 | count = aspath_count(); | |
7688 | vty_out(vty, "%ld BGP AS-PATH entries, using %s of memory\n", count, | |
7689 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7690 | count * sizeof(struct aspath))); | |
7691 | ||
7692 | count = mtype_stats_alloc(MTYPE_AS_SEG); | |
7693 | vty_out(vty, "%ld BGP AS-PATH segments, using %s of memory\n", count, | |
7694 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7695 | count * sizeof(struct assegment))); | |
7696 | ||
7697 | /* Other attributes */ | |
7698 | if ((count = community_count())) | |
7699 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7700 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7701 | count * sizeof(struct community))); | |
d62a17ae | 7702 | if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) |
7703 | vty_out(vty, "%ld BGP community entries, using %s of memory\n", | |
996c9314 LB |
7704 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7705 | count * sizeof(struct ecommunity))); | |
d62a17ae | 7706 | if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) |
7707 | vty_out(vty, | |
7708 | "%ld BGP large-community entries, using %s of memory\n", | |
996c9314 LB |
7709 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7710 | count * sizeof(struct lcommunity))); | |
d62a17ae | 7711 | |
7712 | if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) | |
7713 | vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, | |
7714 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7715 | count * sizeof(struct cluster_list))); | |
7716 | ||
7717 | /* Peer related usage */ | |
7718 | count = mtype_stats_alloc(MTYPE_BGP_PEER); | |
7719 | vty_out(vty, "%ld peers, using %s of memory\n", count, | |
7720 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7721 | count * sizeof(struct peer))); | |
7722 | ||
7723 | if ((count = mtype_stats_alloc(MTYPE_PEER_GROUP))) | |
7724 | vty_out(vty, "%ld peer groups, using %s of memory\n", count, | |
7725 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7726 | count * sizeof(struct peer_group))); | |
7727 | ||
7728 | /* Other */ | |
7729 | if ((count = mtype_stats_alloc(MTYPE_HASH))) | |
7730 | vty_out(vty, "%ld hash tables, using %s of memory\n", count, | |
7731 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
7732 | count * sizeof(struct hash))); | |
7733 | if ((count = mtype_stats_alloc(MTYPE_HASH_BACKET))) | |
7734 | vty_out(vty, "%ld hash buckets, using %s of memory\n", count, | |
7735 | mtype_memstr(memstrbuf, sizeof(memstrbuf), | |
e3b78da8 | 7736 | count * sizeof(struct hash_bucket))); |
d62a17ae | 7737 | if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) |
7738 | vty_out(vty, "%ld compiled regexes, using %s of memory\n", | |
996c9314 LB |
7739 | count, mtype_memstr(memstrbuf, sizeof(memstrbuf), |
7740 | count * sizeof(regex_t))); | |
d62a17ae | 7741 | return CMD_SUCCESS; |
4bf6a362 | 7742 | } |
fee0f4c6 | 7743 | |
57a9c8a8 DS |
7744 | static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) |
7745 | { | |
7746 | json_object *bestpath = json_object_new_object(); | |
7747 | ||
7748 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_IGNORE)) | |
7749 | json_object_string_add(bestpath, "asPath", "ignore"); | |
7750 | ||
7751 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_CONFED)) | |
7752 | json_object_string_add(bestpath, "asPath", "confed"); | |
7753 | ||
7754 | if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { | |
a4d82a8a PZ |
7755 | if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) |
7756 | json_object_string_add(bestpath, "multiPathRelax", | |
57a9c8a8 DS |
7757 | "as-set"); |
7758 | else | |
a4d82a8a | 7759 | json_object_string_add(bestpath, "multiPathRelax", |
57a9c8a8 DS |
7760 | "true"); |
7761 | } else | |
a4d82a8a | 7762 | json_object_string_add(bestpath, "multiPathRelax", "false"); |
57a9c8a8 DS |
7763 | |
7764 | if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) | |
7765 | json_object_string_add(bestpath, "compareRouterId", "true"); | |
7766 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) | |
7767 | || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { | |
7768 | if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) | |
a4d82a8a | 7769 | json_object_string_add(bestpath, "med", "confed"); |
57a9c8a8 DS |
7770 | if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) |
7771 | json_object_string_add(bestpath, "med", | |
7772 | "missing-as-worst"); | |
7773 | else | |
7774 | json_object_string_add(bestpath, "med", "true"); | |
7775 | } | |
7776 | ||
7777 | json_object_object_add(json, "bestPath", bestpath); | |
7778 | } | |
7779 | ||
718e3744 | 7780 | /* Show BGP peer's summary information. */ |
d62a17ae | 7781 | static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, |
9f049418 | 7782 | bool use_json, json_object *json) |
d62a17ae | 7783 | { |
7784 | struct peer *peer; | |
7785 | struct listnode *node, *nnode; | |
7786 | unsigned int count = 0, dn_count = 0; | |
7787 | char timebuf[BGP_UPTIME_LEN], dn_flag[2]; | |
7788 | char neighbor_buf[VTY_BUFSIZ]; | |
7789 | int neighbor_col_default_width = 16; | |
7790 | int len; | |
7791 | int max_neighbor_width = 0; | |
7792 | int pfx_rcd_safi; | |
7793 | json_object *json_peer = NULL; | |
7794 | json_object *json_peers = NULL; | |
50e05855 | 7795 | struct peer_af *paf; |
d62a17ae | 7796 | |
7797 | /* labeled-unicast routes are installed in the unicast table so in order | |
7798 | * to | |
7799 | * display the correct PfxRcd value we must look at SAFI_UNICAST | |
7800 | */ | |
7801 | if (safi == SAFI_LABELED_UNICAST) | |
7802 | pfx_rcd_safi = SAFI_UNICAST; | |
7803 | else | |
7804 | pfx_rcd_safi = safi; | |
7805 | ||
7806 | if (use_json) { | |
7807 | if (json == NULL) | |
7808 | json = json_object_new_object(); | |
7809 | ||
7810 | json_peers = json_object_new_object(); | |
7811 | } else { | |
7812 | /* Loop over all neighbors that will be displayed to determine | |
7813 | * how many | |
7814 | * characters are needed for the Neighbor column | |
7815 | */ | |
7816 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
7817 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7818 | continue; | |
7819 | ||
7820 | if (peer->afc[afi][safi]) { | |
7821 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
7822 | if (peer_dynamic_neighbor(peer)) | |
7823 | dn_flag[0] = '*'; | |
7824 | ||
7825 | if (peer->hostname | |
7826 | && bgp_flag_check(bgp, | |
7827 | BGP_FLAG_SHOW_HOSTNAME)) | |
7828 | sprintf(neighbor_buf, "%s%s(%s) ", | |
7829 | dn_flag, peer->hostname, | |
7830 | peer->host); | |
7831 | else | |
7832 | sprintf(neighbor_buf, "%s%s ", dn_flag, | |
7833 | peer->host); | |
7834 | ||
7835 | len = strlen(neighbor_buf); | |
7836 | ||
7837 | if (len > max_neighbor_width) | |
7838 | max_neighbor_width = len; | |
7839 | } | |
7840 | } | |
f933309e | 7841 | |
d62a17ae | 7842 | /* Originally we displayed the Neighbor column as 16 |
7843 | * characters wide so make that the default | |
7844 | */ | |
7845 | if (max_neighbor_width < neighbor_col_default_width) | |
7846 | max_neighbor_width = neighbor_col_default_width; | |
7847 | } | |
f933309e | 7848 | |
d62a17ae | 7849 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { |
7850 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
7851 | continue; | |
7852 | ||
ea47320b DL |
7853 | if (!peer->afc[afi][safi]) |
7854 | continue; | |
d62a17ae | 7855 | |
ea47320b DL |
7856 | if (!count) { |
7857 | unsigned long ents; | |
7858 | char memstrbuf[MTYPE_MEMSTR_LEN]; | |
a8bf7d9c | 7859 | int64_t vrf_id_ui; |
d62a17ae | 7860 | |
a4d82a8a PZ |
7861 | vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) |
7862 | ? -1 | |
7863 | : (int64_t)bgp->vrf_id; | |
ea47320b DL |
7864 | |
7865 | /* Usage summary and header */ | |
7866 | if (use_json) { | |
7867 | json_object_string_add( | |
7868 | json, "routerId", | |
7869 | inet_ntoa(bgp->router_id)); | |
60466a63 QY |
7870 | json_object_int_add(json, "as", bgp->as); |
7871 | json_object_int_add(json, "vrfId", vrf_id_ui); | |
ea47320b DL |
7872 | json_object_string_add( |
7873 | json, "vrfName", | |
7874 | (bgp->inst_type | |
7875 | == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 7876 | ? VRF_DEFAULT_NAME |
ea47320b DL |
7877 | : bgp->name); |
7878 | } else { | |
7879 | vty_out(vty, | |
7880 | "BGP router identifier %s, local AS number %u vrf-id %d", | |
60466a63 | 7881 | inet_ntoa(bgp->router_id), bgp->as, |
a4d82a8a PZ |
7882 | bgp->vrf_id == VRF_UNKNOWN |
7883 | ? -1 | |
7884 | : (int)bgp->vrf_id); | |
ea47320b DL |
7885 | vty_out(vty, "\n"); |
7886 | } | |
d62a17ae | 7887 | |
ea47320b | 7888 | if (bgp_update_delay_configured(bgp)) { |
d62a17ae | 7889 | if (use_json) { |
ea47320b | 7890 | json_object_int_add( |
60466a63 | 7891 | json, "updateDelayLimit", |
ea47320b | 7892 | bgp->v_update_delay); |
d62a17ae | 7893 | |
ea47320b DL |
7894 | if (bgp->v_update_delay |
7895 | != bgp->v_establish_wait) | |
d62a17ae | 7896 | json_object_int_add( |
7897 | json, | |
ea47320b DL |
7898 | "updateDelayEstablishWait", |
7899 | bgp->v_establish_wait); | |
d62a17ae | 7900 | |
60466a63 | 7901 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
7902 | json_object_string_add( |
7903 | json, | |
7904 | "updateDelayFirstNeighbor", | |
7905 | bgp->update_delay_begin_time); | |
7906 | json_object_boolean_true_add( | |
7907 | json, | |
7908 | "updateDelayInProgress"); | |
7909 | } else { | |
7910 | if (bgp->update_delay_over) { | |
d62a17ae | 7911 | json_object_string_add( |
7912 | json, | |
7913 | "updateDelayFirstNeighbor", | |
7914 | bgp->update_delay_begin_time); | |
ea47320b | 7915 | json_object_string_add( |
d62a17ae | 7916 | json, |
ea47320b DL |
7917 | "updateDelayBestpathResumed", |
7918 | bgp->update_delay_end_time); | |
7919 | json_object_string_add( | |
d62a17ae | 7920 | json, |
ea47320b DL |
7921 | "updateDelayZebraUpdateResume", |
7922 | bgp->update_delay_zebra_resume_time); | |
7923 | json_object_string_add( | |
7924 | json, | |
7925 | "updateDelayPeerUpdateResume", | |
7926 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 7927 | } |
ea47320b DL |
7928 | } |
7929 | } else { | |
7930 | vty_out(vty, | |
7931 | "Read-only mode update-delay limit: %d seconds\n", | |
7932 | bgp->v_update_delay); | |
7933 | if (bgp->v_update_delay | |
7934 | != bgp->v_establish_wait) | |
d62a17ae | 7935 | vty_out(vty, |
ea47320b DL |
7936 | " Establish wait: %d seconds\n", |
7937 | bgp->v_establish_wait); | |
d62a17ae | 7938 | |
60466a63 | 7939 | if (bgp_update_delay_active(bgp)) { |
ea47320b DL |
7940 | vty_out(vty, |
7941 | " First neighbor established: %s\n", | |
7942 | bgp->update_delay_begin_time); | |
7943 | vty_out(vty, | |
7944 | " Delay in progress\n"); | |
7945 | } else { | |
7946 | if (bgp->update_delay_over) { | |
d62a17ae | 7947 | vty_out(vty, |
7948 | " First neighbor established: %s\n", | |
7949 | bgp->update_delay_begin_time); | |
7950 | vty_out(vty, | |
ea47320b DL |
7951 | " Best-paths resumed: %s\n", |
7952 | bgp->update_delay_end_time); | |
7953 | vty_out(vty, | |
7954 | " zebra update resumed: %s\n", | |
7955 | bgp->update_delay_zebra_resume_time); | |
7956 | vty_out(vty, | |
7957 | " peers update resumed: %s\n", | |
7958 | bgp->update_delay_peers_resume_time); | |
d62a17ae | 7959 | } |
7960 | } | |
7961 | } | |
ea47320b | 7962 | } |
d62a17ae | 7963 | |
ea47320b DL |
7964 | if (use_json) { |
7965 | if (bgp_maxmed_onstartup_configured(bgp) | |
7966 | && bgp->maxmed_active) | |
7967 | json_object_boolean_true_add( | |
60466a63 | 7968 | json, "maxMedOnStartup"); |
ea47320b DL |
7969 | if (bgp->v_maxmed_admin) |
7970 | json_object_boolean_true_add( | |
60466a63 | 7971 | json, "maxMedAdministrative"); |
d62a17ae | 7972 | |
ea47320b DL |
7973 | json_object_int_add( |
7974 | json, "tableVersion", | |
60466a63 | 7975 | bgp_table_version(bgp->rib[afi][safi])); |
ea47320b | 7976 | |
60466a63 QY |
7977 | ents = bgp_table_count(bgp->rib[afi][safi]); |
7978 | json_object_int_add(json, "ribCount", ents); | |
ea47320b DL |
7979 | json_object_int_add( |
7980 | json, "ribMemory", | |
7981 | ents * sizeof(struct bgp_node)); | |
d62a17ae | 7982 | |
210ec2a0 | 7983 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 QY |
7984 | json_object_int_add(json, "peerCount", ents); |
7985 | json_object_int_add(json, "peerMemory", | |
7986 | ents * sizeof(struct peer)); | |
d62a17ae | 7987 | |
ea47320b DL |
7988 | if ((ents = listcount(bgp->group))) { |
7989 | json_object_int_add( | |
60466a63 | 7990 | json, "peerGroupCount", ents); |
ea47320b DL |
7991 | json_object_int_add( |
7992 | json, "peerGroupMemory", | |
996c9314 LB |
7993 | ents * sizeof(struct |
7994 | peer_group)); | |
ea47320b | 7995 | } |
d62a17ae | 7996 | |
ea47320b DL |
7997 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
7998 | BGP_CONFIG_DAMPENING)) | |
7999 | json_object_boolean_true_add( | |
60466a63 | 8000 | json, "dampeningEnabled"); |
ea47320b DL |
8001 | } else { |
8002 | if (bgp_maxmed_onstartup_configured(bgp) | |
8003 | && bgp->maxmed_active) | |
d62a17ae | 8004 | vty_out(vty, |
ea47320b DL |
8005 | "Max-med on-startup active\n"); |
8006 | if (bgp->v_maxmed_admin) | |
d62a17ae | 8007 | vty_out(vty, |
ea47320b | 8008 | "Max-med administrative active\n"); |
d62a17ae | 8009 | |
60466a63 QY |
8010 | vty_out(vty, "BGP table version %" PRIu64 "\n", |
8011 | bgp_table_version(bgp->rib[afi][safi])); | |
d62a17ae | 8012 | |
60466a63 | 8013 | ents = bgp_table_count(bgp->rib[afi][safi]); |
ea47320b DL |
8014 | vty_out(vty, |
8015 | "RIB entries %ld, using %s of memory\n", | |
8016 | ents, | |
996c9314 LB |
8017 | mtype_memstr(memstrbuf, |
8018 | sizeof(memstrbuf), | |
8019 | ents * sizeof(struct | |
8020 | bgp_node))); | |
ea47320b DL |
8021 | |
8022 | /* Peer related usage */ | |
210ec2a0 | 8023 | ents = bgp->af_peer_count[afi][safi]; |
60466a63 | 8024 | vty_out(vty, "Peers %ld, using %s of memory\n", |
ea47320b DL |
8025 | ents, |
8026 | mtype_memstr( | |
60466a63 QY |
8027 | memstrbuf, sizeof(memstrbuf), |
8028 | ents * sizeof(struct peer))); | |
ea47320b DL |
8029 | |
8030 | if ((ents = listcount(bgp->group))) | |
d62a17ae | 8031 | vty_out(vty, |
ea47320b | 8032 | "Peer groups %ld, using %s of memory\n", |
d62a17ae | 8033 | ents, |
8034 | mtype_memstr( | |
8035 | memstrbuf, | |
8036 | sizeof(memstrbuf), | |
996c9314 LB |
8037 | ents * sizeof(struct |
8038 | peer_group))); | |
d62a17ae | 8039 | |
ea47320b DL |
8040 | if (CHECK_FLAG(bgp->af_flags[afi][safi], |
8041 | BGP_CONFIG_DAMPENING)) | |
60466a63 | 8042 | vty_out(vty, "Dampening enabled.\n"); |
ea47320b | 8043 | vty_out(vty, "\n"); |
d62a17ae | 8044 | |
ea47320b DL |
8045 | /* Subtract 8 here because 'Neighbor' is |
8046 | * 8 characters */ | |
8047 | vty_out(vty, "Neighbor"); | |
60466a63 QY |
8048 | vty_out(vty, "%*s", max_neighbor_width - 8, |
8049 | " "); | |
ea47320b DL |
8050 | vty_out(vty, |
8051 | "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n"); | |
d62a17ae | 8052 | } |
ea47320b | 8053 | } |
d62a17ae | 8054 | |
ea47320b | 8055 | count++; |
d62a17ae | 8056 | |
ea47320b DL |
8057 | if (use_json) { |
8058 | json_peer = json_object_new_object(); | |
d62a17ae | 8059 | |
b4e9dcba DD |
8060 | if (peer_dynamic_neighbor(peer)) { |
8061 | dn_count++; | |
60466a63 QY |
8062 | json_object_boolean_true_add(json_peer, |
8063 | "dynamicPeer"); | |
b4e9dcba | 8064 | } |
d62a17ae | 8065 | |
ea47320b | 8066 | if (peer->hostname) |
60466a63 | 8067 | json_object_string_add(json_peer, "hostname", |
ea47320b | 8068 | peer->hostname); |
d62a17ae | 8069 | |
ea47320b | 8070 | if (peer->domainname) |
60466a63 QY |
8071 | json_object_string_add(json_peer, "domainname", |
8072 | peer->domainname); | |
d62a17ae | 8073 | |
60466a63 | 8074 | json_object_int_add(json_peer, "remoteAs", peer->as); |
ea47320b | 8075 | json_object_int_add(json_peer, "version", 4); |
60466a63 | 8076 | json_object_int_add(json_peer, "msgRcvd", |
0112e9e0 | 8077 | PEER_TOTAL_RX(peer)); |
60466a63 | 8078 | json_object_int_add(json_peer, "msgSent", |
0112e9e0 | 8079 | PEER_TOTAL_TX(peer)); |
ea47320b DL |
8080 | |
8081 | json_object_int_add(json_peer, "tableVersion", | |
8082 | peer->version[afi][safi]); | |
8083 | json_object_int_add(json_peer, "outq", | |
8084 | peer->obuf->count); | |
8085 | json_object_int_add(json_peer, "inq", 0); | |
60466a63 QY |
8086 | peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, |
8087 | use_json, json_peer); | |
50e05855 AD |
8088 | |
8089 | /* | |
8090 | * Adding "pfxRcd" field to match with the corresponding | |
8091 | * CLI. "prefixReceivedCount" will be deprecated in | |
8092 | * future. | |
8093 | */ | |
60466a63 QY |
8094 | json_object_int_add(json_peer, "prefixReceivedCount", |
8095 | peer->pcount[afi][pfx_rcd_safi]); | |
50e05855 AD |
8096 | json_object_int_add(json_peer, "pfxRcd", |
8097 | peer->pcount[afi][pfx_rcd_safi]); | |
8098 | ||
8099 | paf = peer_af_find(peer, afi, pfx_rcd_safi); | |
8100 | if (paf && PAF_SUBGRP(paf)) | |
8101 | json_object_int_add(json_peer, | |
8102 | "pfxSnt", | |
8103 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 8104 | |
ea47320b | 8105 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
60466a63 | 8106 | json_object_string_add(json_peer, "state", |
ea47320b | 8107 | "Idle (Admin)"); |
9199a725 TM |
8108 | else if (peer->afc_recv[afi][safi]) |
8109 | json_object_string_add( | |
8110 | json_peer, "state", | |
8111 | lookup_msg(bgp_status_msg, peer->status, | |
8112 | NULL)); | |
60466a63 QY |
8113 | else if (CHECK_FLAG(peer->sflags, |
8114 | PEER_STATUS_PREFIX_OVERFLOW)) | |
8115 | json_object_string_add(json_peer, "state", | |
ea47320b DL |
8116 | "Idle (PfxCt)"); |
8117 | else | |
8118 | json_object_string_add( | |
8119 | json_peer, "state", | |
60466a63 QY |
8120 | lookup_msg(bgp_status_msg, peer->status, |
8121 | NULL)); | |
ea47320b DL |
8122 | |
8123 | if (peer->conf_if) | |
60466a63 | 8124 | json_object_string_add(json_peer, "idType", |
ea47320b DL |
8125 | "interface"); |
8126 | else if (peer->su.sa.sa_family == AF_INET) | |
60466a63 QY |
8127 | json_object_string_add(json_peer, "idType", |
8128 | "ipv4"); | |
ea47320b | 8129 | else if (peer->su.sa.sa_family == AF_INET6) |
60466a63 QY |
8130 | json_object_string_add(json_peer, "idType", |
8131 | "ipv6"); | |
d62a17ae | 8132 | |
ea47320b DL |
8133 | json_object_object_add(json_peers, peer->host, |
8134 | json_peer); | |
8135 | } else { | |
8136 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
8137 | if (peer_dynamic_neighbor(peer)) { | |
8138 | dn_count++; | |
8139 | dn_flag[0] = '*'; | |
8140 | } | |
d62a17ae | 8141 | |
ea47320b | 8142 | if (peer->hostname |
60466a63 | 8143 | && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) |
ea47320b | 8144 | len = vty_out(vty, "%s%s(%s)", dn_flag, |
60466a63 | 8145 | peer->hostname, peer->host); |
ea47320b | 8146 | else |
60466a63 | 8147 | len = vty_out(vty, "%s%s", dn_flag, peer->host); |
ea47320b DL |
8148 | |
8149 | /* pad the neighbor column with spaces */ | |
8150 | if (len < max_neighbor_width) | |
60466a63 QY |
8151 | vty_out(vty, "%*s", max_neighbor_width - len, |
8152 | " "); | |
ea47320b | 8153 | |
86a55b99 | 8154 | vty_out(vty, "4 %10u %7u %7u %8" PRIu64 " %4d %4zd %8s", |
0112e9e0 QY |
8155 | peer->as, PEER_TOTAL_RX(peer), |
8156 | PEER_TOTAL_TX(peer), peer->version[afi][safi], | |
8157 | 0, peer->obuf->count, | |
d62a17ae | 8158 | peer_uptime(peer->uptime, timebuf, |
ea47320b | 8159 | BGP_UPTIME_LEN, 0, NULL)); |
d62a17ae | 8160 | |
ea47320b | 8161 | if (peer->status == Established) |
2f8f4f10 | 8162 | if (peer->afc_recv[afi][safi]) |
95077abf | 8163 | vty_out(vty, " %12ld", |
a4d82a8a PZ |
8164 | peer->pcount[afi] |
8165 | [pfx_rcd_safi]); | |
95077abf DW |
8166 | else |
8167 | vty_out(vty, " NoNeg"); | |
ea47320b | 8168 | else { |
60466a63 | 8169 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) |
ea47320b | 8170 | vty_out(vty, " Idle (Admin)"); |
60466a63 QY |
8171 | else if (CHECK_FLAG( |
8172 | peer->sflags, | |
8173 | PEER_STATUS_PREFIX_OVERFLOW)) | |
ea47320b | 8174 | vty_out(vty, " Idle (PfxCt)"); |
d62a17ae | 8175 | else |
ea47320b | 8176 | vty_out(vty, " %12s", |
60466a63 QY |
8177 | lookup_msg(bgp_status_msg, |
8178 | peer->status, NULL)); | |
d62a17ae | 8179 | } |
ea47320b | 8180 | vty_out(vty, "\n"); |
d62a17ae | 8181 | } |
8182 | } | |
f933309e | 8183 | |
d62a17ae | 8184 | if (use_json) { |
8185 | json_object_object_add(json, "peers", json_peers); | |
8186 | ||
8187 | json_object_int_add(json, "totalPeers", count); | |
8188 | json_object_int_add(json, "dynamicPeers", dn_count); | |
8189 | ||
57a9c8a8 DS |
8190 | bgp_show_bestpath_json(bgp, json); |
8191 | ||
996c9314 LB |
8192 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
8193 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 8194 | json_object_free(json); |
8195 | } else { | |
8196 | if (count) | |
8197 | vty_out(vty, "\nTotal number of neighbors %d\n", count); | |
8198 | else { | |
d6ceaca3 | 8199 | vty_out(vty, "No %s neighbor is configured\n", |
8200 | afi_safi_print(afi, safi)); | |
d62a17ae | 8201 | } |
b05a1c8b | 8202 | |
d6ceaca3 | 8203 | if (dn_count) { |
d62a17ae | 8204 | vty_out(vty, "* - dynamic neighbor\n"); |
8205 | vty_out(vty, "%d dynamic neighbor(s), limit %d\n", | |
8206 | dn_count, bgp->dynamic_neighbors_limit); | |
8207 | } | |
8208 | } | |
1ff9a340 | 8209 | |
d62a17ae | 8210 | return CMD_SUCCESS; |
718e3744 | 8211 | } |
8212 | ||
d62a17ae | 8213 | static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi, |
9f049418 | 8214 | int safi, bool use_json, |
d62a17ae | 8215 | json_object *json) |
8216 | { | |
8217 | int is_first = 1; | |
8218 | int afi_wildcard = (afi == AFI_MAX); | |
8219 | int safi_wildcard = (safi == SAFI_MAX); | |
8220 | int is_wildcard = (afi_wildcard || safi_wildcard); | |
9f049418 | 8221 | bool nbr_output = false; |
d62a17ae | 8222 | |
8223 | if (use_json && is_wildcard) | |
8224 | vty_out(vty, "{\n"); | |
8225 | if (afi_wildcard) | |
8226 | afi = 1; /* AFI_IP */ | |
8227 | while (afi < AFI_MAX) { | |
8228 | if (safi_wildcard) | |
8229 | safi = 1; /* SAFI_UNICAST */ | |
8230 | while (safi < SAFI_MAX) { | |
318cac96 | 8231 | if (bgp_afi_safi_peer_exists(bgp, afi, safi)) { |
9f049418 | 8232 | nbr_output = true; |
d62a17ae | 8233 | if (is_wildcard) { |
8234 | /* | |
8235 | * So limit output to those afi/safi | |
8236 | * pairs that | |
8237 | * actualy have something interesting in | |
8238 | * them | |
8239 | */ | |
8240 | if (use_json) { | |
8241 | json = json_object_new_object(); | |
8242 | ||
8243 | if (!is_first) | |
8244 | vty_out(vty, ",\n"); | |
8245 | else | |
8246 | is_first = 0; | |
8247 | ||
8248 | vty_out(vty, "\"%s\":", | |
8249 | afi_safi_json(afi, | |
8250 | safi)); | |
8251 | } else { | |
8252 | vty_out(vty, "\n%s Summary:\n", | |
8253 | afi_safi_print(afi, | |
8254 | safi)); | |
8255 | } | |
8256 | } | |
8257 | bgp_show_summary(vty, bgp, afi, safi, use_json, | |
8258 | json); | |
8259 | } | |
8260 | safi++; | |
d62a17ae | 8261 | if (!safi_wildcard) |
8262 | safi = SAFI_MAX; | |
8263 | } | |
8264 | afi++; | |
ee851c8c | 8265 | if (!afi_wildcard) |
d62a17ae | 8266 | afi = AFI_MAX; |
8267 | } | |
8268 | ||
8269 | if (use_json && is_wildcard) | |
8270 | vty_out(vty, "}\n"); | |
ca61fd25 DS |
8271 | else if (!nbr_output) { |
8272 | if (use_json) | |
8273 | vty_out(vty, "{}\n"); | |
8274 | else | |
8275 | vty_out(vty, "%% No BGP neighbors found\n"); | |
8276 | } | |
d62a17ae | 8277 | } |
8278 | ||
8279 | static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi, | |
9f049418 | 8280 | safi_t safi, bool use_json) |
d62a17ae | 8281 | { |
8282 | struct listnode *node, *nnode; | |
8283 | struct bgp *bgp; | |
8284 | json_object *json = NULL; | |
8285 | int is_first = 1; | |
9f049418 | 8286 | bool nbr_output = false; |
d62a17ae | 8287 | |
8288 | if (use_json) | |
8289 | vty_out(vty, "{\n"); | |
8290 | ||
8291 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 8292 | nbr_output = true; |
d62a17ae | 8293 | if (use_json) { |
8294 | json = json_object_new_object(); | |
8295 | ||
8296 | if (!is_first) | |
8297 | vty_out(vty, ",\n"); | |
8298 | else | |
8299 | is_first = 0; | |
8300 | ||
8301 | vty_out(vty, "\"%s\":", | |
8302 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8303 | ? VRF_DEFAULT_NAME |
d62a17ae | 8304 | : bgp->name); |
8305 | } else { | |
8306 | vty_out(vty, "\nInstance %s:\n", | |
8307 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 8308 | ? VRF_DEFAULT_NAME |
d62a17ae | 8309 | : bgp->name); |
8310 | } | |
8311 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, json); | |
8312 | } | |
8313 | ||
8314 | if (use_json) | |
8315 | vty_out(vty, "}\n"); | |
9f049418 DS |
8316 | else if (!nbr_output) |
8317 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 8318 | } |
8319 | ||
8320 | int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi, | |
9f049418 | 8321 | safi_t safi, bool use_json) |
d62a17ae | 8322 | { |
8323 | struct bgp *bgp; | |
8324 | ||
8325 | if (name) { | |
8326 | if (strmatch(name, "all")) { | |
8327 | bgp_show_all_instances_summary_vty(vty, afi, safi, | |
8328 | use_json); | |
8329 | return CMD_SUCCESS; | |
8330 | } else { | |
8331 | bgp = bgp_lookup_by_name(name); | |
8332 | ||
8333 | if (!bgp) { | |
8334 | if (use_json) | |
8335 | vty_out(vty, "{}\n"); | |
8336 | else | |
8337 | vty_out(vty, | |
ca61fd25 | 8338 | "%% BGP instance not found\n"); |
d62a17ae | 8339 | return CMD_WARNING; |
8340 | } | |
8341 | ||
8342 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, | |
8343 | NULL); | |
8344 | return CMD_SUCCESS; | |
8345 | } | |
8346 | } | |
8347 | ||
8348 | bgp = bgp_get_default(); | |
8349 | ||
8350 | if (bgp) | |
8351 | bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, NULL); | |
9f049418 | 8352 | else { |
ca61fd25 DS |
8353 | if (use_json) |
8354 | vty_out(vty, "{}\n"); | |
8355 | else | |
8356 | vty_out(vty, "%% BGP instance not found\n"); | |
9f049418 DS |
8357 | return CMD_WARNING; |
8358 | } | |
d62a17ae | 8359 | |
8360 | return CMD_SUCCESS; | |
4fb25c53 DW |
8361 | } |
8362 | ||
716b2d8a | 8363 | /* `show [ip] bgp summary' commands. */ |
47fc97cc | 8364 | DEFUN (show_ip_bgp_summary, |
718e3744 | 8365 | show_ip_bgp_summary_cmd, |
dd6bd0f1 | 8366 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] summary [json]", |
718e3744 | 8367 | SHOW_STR |
8368 | IP_STR | |
8369 | BGP_STR | |
8386ac43 | 8370 | BGP_INSTANCE_HELP_STR |
46f296b4 | 8371 | BGP_AFI_HELP_STR |
dd6bd0f1 | 8372 | BGP_SAFI_WITH_LABEL_HELP_STR |
b05a1c8b | 8373 | "Summary of BGP neighbor status\n" |
9973d184 | 8374 | JSON_STR) |
718e3744 | 8375 | { |
d62a17ae | 8376 | char *vrf = NULL; |
8377 | afi_t afi = AFI_MAX; | |
8378 | safi_t safi = SAFI_MAX; | |
8379 | ||
8380 | int idx = 0; | |
8381 | ||
8382 | /* show [ip] bgp */ | |
8383 | if (argv_find(argv, argc, "ip", &idx)) | |
8384 | afi = AFI_IP; | |
9a8bdf1c PG |
8385 | /* [<vrf> VIEWVRFNAME] */ |
8386 | if (argv_find(argv, argc, "vrf", &idx)) { | |
8387 | vrf = argv[idx + 1]->arg; | |
8388 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
8389 | vrf = NULL; | |
8390 | } else if (argv_find(argv, argc, "view", &idx)) | |
8391 | /* [<view> VIEWVRFNAME] */ | |
8392 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 8393 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
8394 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
8395 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
8396 | } | |
8397 | ||
9f049418 | 8398 | bool uj = use_json(argc, argv); |
d62a17ae | 8399 | |
8400 | return bgp_show_summary_vty(vty, vrf, afi, safi, uj); | |
8401 | } | |
8402 | ||
8403 | const char *afi_safi_print(afi_t afi, safi_t safi) | |
8404 | { | |
8405 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8406 | return "IPv4 Unicast"; | |
8407 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8408 | return "IPv4 Multicast"; | |
8409 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8410 | return "IPv4 Labeled Unicast"; | |
8411 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8412 | return "IPv4 VPN"; | |
8413 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8414 | return "IPv4 Encap"; | |
7c40bf39 | 8415 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8416 | return "IPv4 Flowspec"; | |
d62a17ae | 8417 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8418 | return "IPv6 Unicast"; | |
8419 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8420 | return "IPv6 Multicast"; | |
8421 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8422 | return "IPv6 Labeled Unicast"; | |
8423 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8424 | return "IPv6 VPN"; | |
8425 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8426 | return "IPv6 Encap"; | |
7c40bf39 | 8427 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8428 | return "IPv6 Flowspec"; | |
d62a17ae | 8429 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8430 | return "L2VPN EVPN"; | |
8431 | else | |
8432 | return "Unknown"; | |
538621f2 | 8433 | } |
8434 | ||
b9f77ec8 DS |
8435 | /* |
8436 | * Please note that we have intentionally camelCased | |
8437 | * the return strings here. So if you want | |
8438 | * to use this function, please ensure you | |
8439 | * are doing this within json output | |
8440 | */ | |
d62a17ae | 8441 | const char *afi_safi_json(afi_t afi, safi_t safi) |
8442 | { | |
8443 | if (afi == AFI_IP && safi == SAFI_UNICAST) | |
8444 | return "ipv4Unicast"; | |
8445 | else if (afi == AFI_IP && safi == SAFI_MULTICAST) | |
8446 | return "ipv4Multicast"; | |
8447 | else if (afi == AFI_IP && safi == SAFI_LABELED_UNICAST) | |
8448 | return "ipv4LabeledUnicast"; | |
8449 | else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) | |
8450 | return "ipv4Vpn"; | |
8451 | else if (afi == AFI_IP && safi == SAFI_ENCAP) | |
8452 | return "ipv4Encap"; | |
7c40bf39 | 8453 | else if (afi == AFI_IP && safi == SAFI_FLOWSPEC) |
8454 | return "ipv4Flowspec"; | |
d62a17ae | 8455 | else if (afi == AFI_IP6 && safi == SAFI_UNICAST) |
8456 | return "ipv6Unicast"; | |
8457 | else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) | |
8458 | return "ipv6Multicast"; | |
8459 | else if (afi == AFI_IP6 && safi == SAFI_LABELED_UNICAST) | |
8460 | return "ipv6LabeledUnicast"; | |
8461 | else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) | |
8462 | return "ipv6Vpn"; | |
8463 | else if (afi == AFI_IP6 && safi == SAFI_ENCAP) | |
8464 | return "ipv6Encap"; | |
7c40bf39 | 8465 | else if (afi == AFI_IP6 && safi == SAFI_FLOWSPEC) |
8466 | return "ipv6Flowspec"; | |
d62a17ae | 8467 | else if (afi == AFI_L2VPN && safi == SAFI_EVPN) |
8468 | return "l2VpnEvpn"; | |
8469 | else | |
8470 | return "Unknown"; | |
27162734 LB |
8471 | } |
8472 | ||
718e3744 | 8473 | /* Show BGP peer's information. */ |
d1927ebe | 8474 | enum show_type { show_all, show_peer, show_ipv4_all, show_ipv6_all, show_ipv4_peer, show_ipv6_peer }; |
d62a17ae | 8475 | |
8476 | static void bgp_show_peer_afi_orf_cap(struct vty *vty, struct peer *p, | |
8477 | afi_t afi, safi_t safi, | |
d7c0a89a QY |
8478 | uint16_t adv_smcap, uint16_t adv_rmcap, |
8479 | uint16_t rcv_smcap, uint16_t rcv_rmcap, | |
9f049418 | 8480 | bool use_json, json_object *json_pref) |
d62a17ae | 8481 | { |
8482 | /* Send-Mode */ | |
8483 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8484 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) { | |
8485 | if (use_json) { | |
8486 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap) | |
8487 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8488 | json_object_string_add(json_pref, "sendMode", | |
8489 | "advertisedAndReceived"); | |
8490 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8491 | json_object_string_add(json_pref, "sendMode", | |
8492 | "advertised"); | |
8493 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8494 | json_object_string_add(json_pref, "sendMode", | |
8495 | "received"); | |
8496 | } else { | |
8497 | vty_out(vty, " Send-mode: "); | |
8498 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_smcap)) | |
8499 | vty_out(vty, "advertised"); | |
8500 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_smcap)) | |
8501 | vty_out(vty, "%sreceived", | |
8502 | CHECK_FLAG(p->af_cap[afi][safi], | |
8503 | adv_smcap) | |
8504 | ? ", " | |
8505 | : ""); | |
8506 | vty_out(vty, "\n"); | |
8507 | } | |
8508 | } | |
8509 | ||
8510 | /* Receive-Mode */ | |
8511 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8512 | || CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) { | |
8513 | if (use_json) { | |
8514 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap) | |
8515 | && CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8516 | json_object_string_add(json_pref, "recvMode", | |
8517 | "advertisedAndReceived"); | |
8518 | else if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8519 | json_object_string_add(json_pref, "recvMode", | |
8520 | "advertised"); | |
8521 | else if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8522 | json_object_string_add(json_pref, "recvMode", | |
8523 | "received"); | |
8524 | } else { | |
8525 | vty_out(vty, " Receive-mode: "); | |
8526 | if (CHECK_FLAG(p->af_cap[afi][safi], adv_rmcap)) | |
8527 | vty_out(vty, "advertised"); | |
8528 | if (CHECK_FLAG(p->af_cap[afi][safi], rcv_rmcap)) | |
8529 | vty_out(vty, "%sreceived", | |
8530 | CHECK_FLAG(p->af_cap[afi][safi], | |
8531 | adv_rmcap) | |
8532 | ? ", " | |
8533 | : ""); | |
8534 | vty_out(vty, "\n"); | |
8535 | } | |
8536 | } | |
8537 | } | |
8538 | ||
8539 | static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, | |
9f049418 | 8540 | safi_t safi, bool use_json, |
d62a17ae | 8541 | json_object *json_neigh) |
8542 | { | |
0291c246 MK |
8543 | struct bgp_filter *filter; |
8544 | struct peer_af *paf; | |
8545 | char orf_pfx_name[BUFSIZ]; | |
8546 | int orf_pfx_count; | |
8547 | json_object *json_af = NULL; | |
8548 | json_object *json_prefA = NULL; | |
8549 | json_object *json_prefB = NULL; | |
8550 | json_object *json_addr = NULL; | |
d62a17ae | 8551 | |
8552 | if (use_json) { | |
8553 | json_addr = json_object_new_object(); | |
8554 | json_af = json_object_new_object(); | |
8555 | filter = &p->filter[afi][safi]; | |
8556 | ||
8557 | if (peer_group_active(p)) | |
8558 | json_object_string_add(json_addr, "peerGroupMember", | |
8559 | p->group->name); | |
8560 | ||
8561 | paf = peer_af_find(p, afi, safi); | |
8562 | if (paf && PAF_SUBGRP(paf)) { | |
8563 | json_object_int_add(json_addr, "updateGroupId", | |
8564 | PAF_UPDGRP(paf)->id); | |
8565 | json_object_int_add(json_addr, "subGroupId", | |
8566 | PAF_SUBGRP(paf)->id); | |
8567 | json_object_int_add(json_addr, "packetQueueLength", | |
8568 | bpacket_queue_virtual_length(paf)); | |
8569 | } | |
8570 | ||
8571 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8572 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8573 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8574 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8575 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8576 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8577 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8578 | json_object_int_add(json_af, "orfType", | |
8579 | ORF_TYPE_PREFIX); | |
8580 | json_prefA = json_object_new_object(); | |
8581 | bgp_show_peer_afi_orf_cap(vty, p, afi, safi, | |
8582 | PEER_CAP_ORF_PREFIX_SM_ADV, | |
8583 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8584 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8585 | PEER_CAP_ORF_PREFIX_RM_RCV, | |
8586 | use_json, json_prefA); | |
8587 | json_object_object_add(json_af, "orfPrefixList", | |
8588 | json_prefA); | |
8589 | } | |
8590 | ||
8591 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8592 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8593 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8594 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8595 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8596 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8597 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8598 | json_object_int_add(json_af, "orfOldType", | |
8599 | ORF_TYPE_PREFIX_OLD); | |
8600 | json_prefB = json_object_new_object(); | |
8601 | bgp_show_peer_afi_orf_cap( | |
8602 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8603 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8604 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8605 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, | |
8606 | json_prefB); | |
8607 | json_object_object_add(json_af, "orfOldPrefixList", | |
8608 | json_prefB); | |
8609 | } | |
8610 | ||
8611 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8612 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8613 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8614 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8615 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8616 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8617 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8618 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8619 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8620 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8621 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8622 | json_object_object_add(json_addr, "afDependentCap", | |
8623 | json_af); | |
8624 | else | |
8625 | json_object_free(json_af); | |
8626 | ||
8627 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8628 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8629 | NULL, afi, orf_pfx_name, use_json); | |
8630 | ||
8631 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8632 | PEER_STATUS_ORF_PREFIX_SEND) | |
8633 | || orf_pfx_count) { | |
8634 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8635 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8636 | json_object_boolean_true_add(json_neigh, | |
8637 | "orfSent"); | |
8638 | if (orf_pfx_count) | |
8639 | json_object_int_add(json_addr, "orfRecvCounter", | |
8640 | orf_pfx_count); | |
8641 | } | |
8642 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8643 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8644 | json_object_string_add( | |
8645 | json_addr, "orfFirstUpdate", | |
8646 | "deferredUntilORFOrRouteRefreshRecvd"); | |
8647 | ||
8648 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8649 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8650 | json_object_boolean_true_add(json_addr, | |
8651 | "routeReflectorClient"); | |
8652 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8653 | PEER_FLAG_RSERVER_CLIENT)) | |
8654 | json_object_boolean_true_add(json_addr, | |
8655 | "routeServerClient"); | |
8656 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8657 | json_object_boolean_true_add(json_addr, | |
8658 | "inboundSoftConfigPermit"); | |
8659 | ||
8660 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8661 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8662 | json_object_boolean_true_add( | |
8663 | json_addr, | |
8664 | "privateAsNumsAllReplacedInUpdatesToNbr"); | |
8665 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8666 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8667 | json_object_boolean_true_add( | |
8668 | json_addr, | |
8669 | "privateAsNumsReplacedInUpdatesToNbr"); | |
8670 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8671 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8672 | json_object_boolean_true_add( | |
8673 | json_addr, | |
8674 | "privateAsNumsAllRemovedInUpdatesToNbr"); | |
8675 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8676 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8677 | json_object_boolean_true_add( | |
8678 | json_addr, | |
8679 | "privateAsNumsRemovedInUpdatesToNbr"); | |
8680 | ||
dcc68b5e MS |
8681 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
8682 | json_object_boolean_true_add( | |
8683 | json_addr, | |
8684 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
8685 | ->type_json_name); | |
d62a17ae | 8686 | |
8687 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8688 | json_object_string_add(json_addr, | |
8689 | "overrideASNsInOutboundUpdates", | |
8690 | "ifAspathEqualRemoteAs"); | |
8691 | ||
8692 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8693 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8694 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8695 | json_object_boolean_true_add(json_addr, | |
8696 | "routerAlwaysNextHop"); | |
8697 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8698 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8699 | json_object_boolean_true_add( | |
8700 | json_addr, "unchangedAsPathPropogatedToNbr"); | |
8701 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8702 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
8703 | json_object_boolean_true_add( | |
8704 | json_addr, "unchangedNextHopPropogatedToNbr"); | |
8705 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
8706 | json_object_boolean_true_add( | |
8707 | json_addr, "unchangedMedPropogatedToNbr"); | |
8708 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
8709 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8710 | PEER_FLAG_SEND_EXT_COMMUNITY)) { | |
8711 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8712 | PEER_FLAG_SEND_COMMUNITY) | |
8713 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8714 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8715 | json_object_string_add(json_addr, | |
8716 | "commAttriSentToNbr", | |
8717 | "extendedAndStandard"); | |
8718 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8719 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
8720 | json_object_string_add(json_addr, | |
8721 | "commAttriSentToNbr", | |
8722 | "extended"); | |
8723 | else | |
8724 | json_object_string_add(json_addr, | |
8725 | "commAttriSentToNbr", | |
8726 | "standard"); | |
8727 | } | |
8728 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8729 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
8730 | if (p->default_rmap[afi][safi].name) | |
8731 | json_object_string_add( | |
8732 | json_addr, "defaultRouteMap", | |
8733 | p->default_rmap[afi][safi].name); | |
8734 | ||
8735 | if (paf && PAF_SUBGRP(paf) | |
8736 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
8737 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
8738 | json_object_boolean_true_add(json_addr, | |
8739 | "defaultSent"); | |
8740 | else | |
8741 | json_object_boolean_true_add(json_addr, | |
8742 | "defaultNotSent"); | |
8743 | } | |
8744 | ||
dff8f48d | 8745 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { |
94c2f693 | 8746 | if (is_evpn_enabled()) |
60466a63 QY |
8747 | json_object_boolean_true_add( |
8748 | json_addr, "advertiseAllVnis"); | |
dff8f48d MK |
8749 | } |
8750 | ||
d62a17ae | 8751 | if (filter->plist[FILTER_IN].name |
8752 | || filter->dlist[FILTER_IN].name | |
8753 | || filter->aslist[FILTER_IN].name | |
8754 | || filter->map[RMAP_IN].name) | |
8755 | json_object_boolean_true_add(json_addr, | |
8756 | "inboundPathPolicyConfig"); | |
8757 | if (filter->plist[FILTER_OUT].name | |
8758 | || filter->dlist[FILTER_OUT].name | |
8759 | || filter->aslist[FILTER_OUT].name | |
8760 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
8761 | json_object_boolean_true_add( | |
8762 | json_addr, "outboundPathPolicyConfig"); | |
8763 | ||
8764 | /* prefix-list */ | |
8765 | if (filter->plist[FILTER_IN].name) | |
8766 | json_object_string_add(json_addr, | |
8767 | "incomingUpdatePrefixFilterList", | |
8768 | filter->plist[FILTER_IN].name); | |
8769 | if (filter->plist[FILTER_OUT].name) | |
8770 | json_object_string_add(json_addr, | |
8771 | "outgoingUpdatePrefixFilterList", | |
8772 | filter->plist[FILTER_OUT].name); | |
8773 | ||
8774 | /* distribute-list */ | |
8775 | if (filter->dlist[FILTER_IN].name) | |
8776 | json_object_string_add( | |
8777 | json_addr, "incomingUpdateNetworkFilterList", | |
8778 | filter->dlist[FILTER_IN].name); | |
8779 | if (filter->dlist[FILTER_OUT].name) | |
8780 | json_object_string_add( | |
8781 | json_addr, "outgoingUpdateNetworkFilterList", | |
8782 | filter->dlist[FILTER_OUT].name); | |
8783 | ||
8784 | /* filter-list. */ | |
8785 | if (filter->aslist[FILTER_IN].name) | |
8786 | json_object_string_add(json_addr, | |
8787 | "incomingUpdateAsPathFilterList", | |
8788 | filter->aslist[FILTER_IN].name); | |
8789 | if (filter->aslist[FILTER_OUT].name) | |
8790 | json_object_string_add(json_addr, | |
8791 | "outgoingUpdateAsPathFilterList", | |
8792 | filter->aslist[FILTER_OUT].name); | |
8793 | ||
8794 | /* route-map. */ | |
8795 | if (filter->map[RMAP_IN].name) | |
8796 | json_object_string_add( | |
8797 | json_addr, "routeMapForIncomingAdvertisements", | |
8798 | filter->map[RMAP_IN].name); | |
8799 | if (filter->map[RMAP_OUT].name) | |
8800 | json_object_string_add( | |
8801 | json_addr, "routeMapForOutgoingAdvertisements", | |
8802 | filter->map[RMAP_OUT].name); | |
8803 | ||
9dac9fc8 DA |
8804 | /* ebgp-requires-policy (inbound) */ |
8805 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
8806 | && !bgp_inbound_policy_exists(p, filter)) | |
8807 | json_object_string_add( | |
8808 | json_addr, "inboundEbgpRequiresPolicy", | |
8809 | "Inbound updates discarded due to missing policy"); | |
8810 | ||
8811 | /* ebgp-requires-policy (outbound) */ | |
8812 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
8813 | && (!bgp_outbound_policy_exists(p, filter))) | |
8814 | json_object_string_add( | |
8815 | json_addr, "outboundEbgpRequiresPolicy", | |
8816 | "Outbound updates discarded due to missing policy"); | |
8817 | ||
d62a17ae | 8818 | /* unsuppress-map */ |
8819 | if (filter->usmap.name) | |
8820 | json_object_string_add(json_addr, | |
8821 | "selectiveUnsuppressRouteMap", | |
8822 | filter->usmap.name); | |
8823 | ||
8824 | /* Receive prefix count */ | |
8825 | json_object_int_add(json_addr, "acceptedPrefixCounter", | |
8826 | p->pcount[afi][safi]); | |
50e05855 AD |
8827 | if (paf && PAF_SUBGRP(paf)) |
8828 | json_object_int_add(json_addr, "sentPrefixCounter", | |
8829 | (PAF_SUBGRP(paf))->scount); | |
d62a17ae | 8830 | |
8831 | /* Maximum prefix */ | |
8832 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
8833 | json_object_int_add(json_addr, "prefixAllowedMax", | |
8834 | p->pmax[afi][safi]); | |
8835 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8836 | PEER_FLAG_MAX_PREFIX_WARNING)) | |
8837 | json_object_boolean_true_add( | |
8838 | json_addr, "prefixAllowedMaxWarning"); | |
8839 | json_object_int_add(json_addr, | |
8840 | "prefixAllowedWarningThresh", | |
8841 | p->pmax_threshold[afi][safi]); | |
8842 | if (p->pmax_restart[afi][safi]) | |
8843 | json_object_int_add( | |
8844 | json_addr, | |
8845 | "prefixAllowedRestartIntervalMsecs", | |
8846 | p->pmax_restart[afi][safi] * 60000); | |
8847 | } | |
8848 | json_object_object_add(json_neigh, afi_safi_print(afi, safi), | |
8849 | json_addr); | |
8850 | ||
8851 | } else { | |
8852 | filter = &p->filter[afi][safi]; | |
8853 | ||
8854 | vty_out(vty, " For address family: %s\n", | |
8855 | afi_safi_print(afi, safi)); | |
8856 | ||
8857 | if (peer_group_active(p)) | |
8858 | vty_out(vty, " %s peer-group member\n", | |
8859 | p->group->name); | |
8860 | ||
8861 | paf = peer_af_find(p, afi, safi); | |
8862 | if (paf && PAF_SUBGRP(paf)) { | |
996c9314 LB |
8863 | vty_out(vty, " Update group %" PRIu64 |
8864 | ", subgroup %" PRIu64 "\n", | |
d62a17ae | 8865 | PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); |
8866 | vty_out(vty, " Packet Queue length %d\n", | |
8867 | bpacket_queue_virtual_length(paf)); | |
8868 | } else { | |
8869 | vty_out(vty, " Not part of any update group\n"); | |
8870 | } | |
8871 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8872 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8873 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8874 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8875 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8876 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8877 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8878 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8879 | PEER_CAP_ORF_PREFIX_RM_RCV) | |
8880 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8881 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) | |
8882 | vty_out(vty, " AF-dependant capabilities:\n"); | |
8883 | ||
8884 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8885 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8886 | PEER_CAP_ORF_PREFIX_SM_RCV) | |
8887 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8888 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8889 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8890 | PEER_CAP_ORF_PREFIX_RM_RCV)) { | |
8891 | vty_out(vty, | |
8892 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8893 | ORF_TYPE_PREFIX); | |
8894 | bgp_show_peer_afi_orf_cap( | |
8895 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8896 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8897 | PEER_CAP_ORF_PREFIX_SM_RCV, | |
8898 | PEER_CAP_ORF_PREFIX_RM_RCV, use_json, NULL); | |
8899 | } | |
8900 | if (CHECK_FLAG(p->af_cap[afi][safi], PEER_CAP_ORF_PREFIX_SM_ADV) | |
8901 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8902 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV) | |
8903 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8904 | PEER_CAP_ORF_PREFIX_RM_ADV) | |
8905 | || CHECK_FLAG(p->af_cap[afi][safi], | |
8906 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV)) { | |
8907 | vty_out(vty, | |
8908 | " Outbound Route Filter (ORF) type (%d) Prefix-list:\n", | |
8909 | ORF_TYPE_PREFIX_OLD); | |
8910 | bgp_show_peer_afi_orf_cap( | |
8911 | vty, p, afi, safi, PEER_CAP_ORF_PREFIX_SM_ADV, | |
8912 | PEER_CAP_ORF_PREFIX_RM_ADV, | |
8913 | PEER_CAP_ORF_PREFIX_SM_OLD_RCV, | |
8914 | PEER_CAP_ORF_PREFIX_RM_OLD_RCV, use_json, NULL); | |
8915 | } | |
8916 | ||
8917 | sprintf(orf_pfx_name, "%s.%d.%d", p->host, afi, safi); | |
8918 | orf_pfx_count = prefix_bgp_show_prefix_list( | |
8919 | NULL, afi, orf_pfx_name, use_json); | |
8920 | ||
8921 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8922 | PEER_STATUS_ORF_PREFIX_SEND) | |
8923 | || orf_pfx_count) { | |
8924 | vty_out(vty, " Outbound Route Filter (ORF):"); | |
8925 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8926 | PEER_STATUS_ORF_PREFIX_SEND)) | |
8927 | vty_out(vty, " sent;"); | |
8928 | if (orf_pfx_count) | |
8929 | vty_out(vty, " received (%d entries)", | |
8930 | orf_pfx_count); | |
8931 | vty_out(vty, "\n"); | |
8932 | } | |
8933 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
8934 | PEER_STATUS_ORF_WAIT_REFRESH)) | |
8935 | vty_out(vty, | |
8936 | " First update is deferred until ORF or ROUTE-REFRESH is received\n"); | |
8937 | ||
8938 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8939 | PEER_FLAG_REFLECTOR_CLIENT)) | |
8940 | vty_out(vty, " Route-Reflector Client\n"); | |
8941 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8942 | PEER_FLAG_RSERVER_CLIENT)) | |
8943 | vty_out(vty, " Route-Server Client\n"); | |
8944 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)) | |
8945 | vty_out(vty, | |
8946 | " Inbound soft reconfiguration allowed\n"); | |
8947 | ||
8948 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8949 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE)) | |
8950 | vty_out(vty, | |
8951 | " Private AS numbers (all) replaced in updates to this neighbor\n"); | |
8952 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8953 | PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE)) | |
8954 | vty_out(vty, | |
8955 | " Private AS numbers replaced in updates to this neighbor\n"); | |
8956 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8957 | PEER_FLAG_REMOVE_PRIVATE_AS_ALL)) | |
8958 | vty_out(vty, | |
8959 | " Private AS numbers (all) removed in updates to this neighbor\n"); | |
8960 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
8961 | PEER_FLAG_REMOVE_PRIVATE_AS)) | |
8962 | vty_out(vty, | |
8963 | " Private AS numbers removed in updates to this neighbor\n"); | |
8964 | ||
dcc68b5e MS |
8965 | if (p->addpath_type[afi][safi] != BGP_ADDPATH_NONE) |
8966 | vty_out(vty, " %s\n", | |
8967 | bgp_addpath_names(p->addpath_type[afi][safi]) | |
8968 | ->human_description); | |
d62a17ae | 8969 | |
8970 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_AS_OVERRIDE)) | |
8971 | vty_out(vty, | |
8972 | " Override ASNs in outbound updates if aspath equals remote-as\n"); | |
8973 | ||
8974 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) | |
8975 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8976 | PEER_FLAG_FORCE_NEXTHOP_SELF)) | |
8977 | vty_out(vty, " NEXT_HOP is always this router\n"); | |
8978 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8979 | PEER_FLAG_AS_PATH_UNCHANGED)) | |
8980 | vty_out(vty, | |
8981 | " AS_PATH is propagated unchanged to this neighbor\n"); | |
8982 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8983 | PEER_FLAG_NEXTHOP_UNCHANGED)) | |
8984 | vty_out(vty, | |
8985 | " NEXT_HOP is propagated unchanged to this neighbor\n"); | |
8986 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MED_UNCHANGED)) | |
8987 | vty_out(vty, | |
8988 | " MED is propagated unchanged to this neighbor\n"); | |
8989 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY) | |
8990 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8991 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
8992 | || CHECK_FLAG(p->af_flags[afi][safi], | |
8993 | PEER_FLAG_SEND_LARGE_COMMUNITY)) { | |
8994 | vty_out(vty, | |
8995 | " Community attribute sent to this neighbor"); | |
8996 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
8997 | PEER_FLAG_SEND_COMMUNITY) | |
8998 | && CHECK_FLAG(p->af_flags[afi][safi], | |
8999 | PEER_FLAG_SEND_EXT_COMMUNITY) | |
9000 | && CHECK_FLAG(p->af_flags[afi][safi], | |
9001 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
9002 | vty_out(vty, "(all)\n"); | |
9003 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9004 | PEER_FLAG_SEND_LARGE_COMMUNITY)) | |
9005 | vty_out(vty, "(large)\n"); | |
9006 | else if (CHECK_FLAG(p->af_flags[afi][safi], | |
9007 | PEER_FLAG_SEND_EXT_COMMUNITY)) | |
9008 | vty_out(vty, "(extended)\n"); | |
9009 | else | |
9010 | vty_out(vty, "(standard)\n"); | |
9011 | } | |
9012 | if (CHECK_FLAG(p->af_flags[afi][safi], | |
9013 | PEER_FLAG_DEFAULT_ORIGINATE)) { | |
9014 | vty_out(vty, " Default information originate,"); | |
9015 | ||
9016 | if (p->default_rmap[afi][safi].name) | |
9017 | vty_out(vty, " default route-map %s%s,", | |
9018 | p->default_rmap[afi][safi].map ? "*" | |
9019 | : "", | |
9020 | p->default_rmap[afi][safi].name); | |
9021 | if (paf && PAF_SUBGRP(paf) | |
9022 | && CHECK_FLAG(PAF_SUBGRP(paf)->sflags, | |
9023 | SUBGRP_STATUS_DEFAULT_ORIGINATE)) | |
9024 | vty_out(vty, " default sent\n"); | |
9025 | else | |
9026 | vty_out(vty, " default not sent\n"); | |
9027 | } | |
9028 | ||
dff8f48d MK |
9029 | /* advertise-vni-all */ |
9030 | if (afi == AFI_L2VPN && safi == SAFI_EVPN) { | |
94c2f693 | 9031 | if (is_evpn_enabled()) |
dff8f48d MK |
9032 | vty_out(vty, " advertise-all-vni\n"); |
9033 | } | |
9034 | ||
d62a17ae | 9035 | if (filter->plist[FILTER_IN].name |
9036 | || filter->dlist[FILTER_IN].name | |
9037 | || filter->aslist[FILTER_IN].name | |
9038 | || filter->map[RMAP_IN].name) | |
9039 | vty_out(vty, " Inbound path policy configured\n"); | |
9040 | if (filter->plist[FILTER_OUT].name | |
9041 | || filter->dlist[FILTER_OUT].name | |
9042 | || filter->aslist[FILTER_OUT].name | |
9043 | || filter->map[RMAP_OUT].name || filter->usmap.name) | |
9044 | vty_out(vty, " Outbound path policy configured\n"); | |
9045 | ||
9046 | /* prefix-list */ | |
9047 | if (filter->plist[FILTER_IN].name) | |
9048 | vty_out(vty, | |
9049 | " Incoming update prefix filter list is %s%s\n", | |
9050 | filter->plist[FILTER_IN].plist ? "*" : "", | |
9051 | filter->plist[FILTER_IN].name); | |
9052 | if (filter->plist[FILTER_OUT].name) | |
9053 | vty_out(vty, | |
9054 | " Outgoing update prefix filter list is %s%s\n", | |
9055 | filter->plist[FILTER_OUT].plist ? "*" : "", | |
9056 | filter->plist[FILTER_OUT].name); | |
9057 | ||
9058 | /* distribute-list */ | |
9059 | if (filter->dlist[FILTER_IN].name) | |
9060 | vty_out(vty, | |
9061 | " Incoming update network filter list is %s%s\n", | |
9062 | filter->dlist[FILTER_IN].alist ? "*" : "", | |
9063 | filter->dlist[FILTER_IN].name); | |
9064 | if (filter->dlist[FILTER_OUT].name) | |
9065 | vty_out(vty, | |
9066 | " Outgoing update network filter list is %s%s\n", | |
9067 | filter->dlist[FILTER_OUT].alist ? "*" : "", | |
9068 | filter->dlist[FILTER_OUT].name); | |
9069 | ||
9070 | /* filter-list. */ | |
9071 | if (filter->aslist[FILTER_IN].name) | |
9072 | vty_out(vty, | |
9073 | " Incoming update AS path filter list is %s%s\n", | |
9074 | filter->aslist[FILTER_IN].aslist ? "*" : "", | |
9075 | filter->aslist[FILTER_IN].name); | |
9076 | if (filter->aslist[FILTER_OUT].name) | |
9077 | vty_out(vty, | |
9078 | " Outgoing update AS path filter list is %s%s\n", | |
9079 | filter->aslist[FILTER_OUT].aslist ? "*" : "", | |
9080 | filter->aslist[FILTER_OUT].name); | |
9081 | ||
9082 | /* route-map. */ | |
9083 | if (filter->map[RMAP_IN].name) | |
9084 | vty_out(vty, | |
9085 | " Route map for incoming advertisements is %s%s\n", | |
9086 | filter->map[RMAP_IN].map ? "*" : "", | |
9087 | filter->map[RMAP_IN].name); | |
9088 | if (filter->map[RMAP_OUT].name) | |
9089 | vty_out(vty, | |
9090 | " Route map for outgoing advertisements is %s%s\n", | |
9091 | filter->map[RMAP_OUT].map ? "*" : "", | |
9092 | filter->map[RMAP_OUT].name); | |
9093 | ||
9dac9fc8 DA |
9094 | /* ebgp-requires-policy (inbound) */ |
9095 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9096 | && !bgp_inbound_policy_exists(p, filter)) | |
9097 | vty_out(vty, | |
9098 | " Inbound updates discarded due to missing policy\n"); | |
9099 | ||
9100 | /* ebgp-requires-policy (outbound) */ | |
9101 | if (p->bgp->ebgp_requires_policy == DEFAULT_EBGP_POLICY_ENABLED | |
9102 | && !bgp_outbound_policy_exists(p, filter)) | |
9103 | vty_out(vty, | |
9104 | " Outbound updates discarded due to missing policy\n"); | |
9105 | ||
d62a17ae | 9106 | /* unsuppress-map */ |
9107 | if (filter->usmap.name) | |
9108 | vty_out(vty, | |
9109 | " Route map for selective unsuppress is %s%s\n", | |
9110 | filter->usmap.map ? "*" : "", | |
9111 | filter->usmap.name); | |
9112 | ||
9113 | /* Receive prefix count */ | |
9114 | vty_out(vty, " %ld accepted prefixes\n", p->pcount[afi][safi]); | |
9115 | ||
9116 | /* Maximum prefix */ | |
9117 | if (CHECK_FLAG(p->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) { | |
9118 | vty_out(vty, " Maximum prefixes allowed %ld%s\n", | |
9119 | p->pmax[afi][safi], | |
9120 | CHECK_FLAG(p->af_flags[afi][safi], | |
9121 | PEER_FLAG_MAX_PREFIX_WARNING) | |
9122 | ? " (warning-only)" | |
9123 | : ""); | |
9124 | vty_out(vty, " Threshold for warning message %d%%", | |
9125 | p->pmax_threshold[afi][safi]); | |
9126 | if (p->pmax_restart[afi][safi]) | |
9127 | vty_out(vty, ", restart interval %d min", | |
9128 | p->pmax_restart[afi][safi]); | |
9129 | vty_out(vty, "\n"); | |
9130 | } | |
9131 | ||
9132 | vty_out(vty, "\n"); | |
9133 | } | |
9134 | } | |
9135 | ||
9f049418 | 9136 | static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, |
d62a17ae | 9137 | json_object *json) |
718e3744 | 9138 | { |
d62a17ae | 9139 | struct bgp *bgp; |
9140 | char buf1[PREFIX2STR_BUFFER], buf[SU_ADDRSTRLEN]; | |
9141 | char timebuf[BGP_UPTIME_LEN]; | |
9142 | char dn_flag[2]; | |
9143 | const char *subcode_str; | |
9144 | const char *code_str; | |
9145 | afi_t afi; | |
9146 | safi_t safi; | |
d7c0a89a QY |
9147 | uint16_t i; |
9148 | uint8_t *msg; | |
d62a17ae | 9149 | json_object *json_neigh = NULL; |
9150 | time_t epoch_tbuf; | |
718e3744 | 9151 | |
d62a17ae | 9152 | bgp = p->bgp; |
9153 | ||
9154 | if (use_json) | |
9155 | json_neigh = json_object_new_object(); | |
9156 | ||
9157 | memset(dn_flag, '\0', sizeof(dn_flag)); | |
9158 | if (!p->conf_if && peer_dynamic_neighbor(p)) | |
9159 | dn_flag[0] = '*'; | |
9160 | ||
9161 | if (!use_json) { | |
9162 | if (p->conf_if) /* Configured interface name. */ | |
9163 | vty_out(vty, "BGP neighbor on %s: %s, ", p->conf_if, | |
9164 | BGP_PEER_SU_UNSPEC(p) | |
9165 | ? "None" | |
9166 | : sockunion2str(&p->su, buf, | |
9167 | SU_ADDRSTRLEN)); | |
9168 | else /* Configured IP address. */ | |
9169 | vty_out(vty, "BGP neighbor is %s%s, ", dn_flag, | |
9170 | p->host); | |
9171 | } | |
9172 | ||
9173 | if (use_json) { | |
9174 | if (p->conf_if && BGP_PEER_SU_UNSPEC(p)) | |
9175 | json_object_string_add(json_neigh, "bgpNeighborAddr", | |
9176 | "none"); | |
9177 | else if (p->conf_if && !BGP_PEER_SU_UNSPEC(p)) | |
9178 | json_object_string_add( | |
9179 | json_neigh, "bgpNeighborAddr", | |
9180 | sockunion2str(&p->su, buf, SU_ADDRSTRLEN)); | |
9181 | ||
9182 | json_object_int_add(json_neigh, "remoteAs", p->as); | |
9183 | ||
9184 | if (p->change_local_as) | |
9185 | json_object_int_add(json_neigh, "localAs", | |
9186 | p->change_local_as); | |
9187 | else | |
9188 | json_object_int_add(json_neigh, "localAs", p->local_as); | |
9189 | ||
9190 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) | |
9191 | json_object_boolean_true_add(json_neigh, | |
9192 | "localAsNoPrepend"); | |
9193 | ||
9194 | if (CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS)) | |
9195 | json_object_boolean_true_add(json_neigh, | |
9196 | "localAsReplaceAs"); | |
9197 | } else { | |
9198 | if ((p->as_type == AS_SPECIFIED) || (p->as_type == AS_EXTERNAL) | |
9199 | || (p->as_type == AS_INTERNAL)) | |
9200 | vty_out(vty, "remote AS %u, ", p->as); | |
9201 | else | |
9202 | vty_out(vty, "remote AS Unspecified, "); | |
9203 | vty_out(vty, "local AS %u%s%s, ", | |
9204 | p->change_local_as ? p->change_local_as : p->local_as, | |
9205 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) | |
9206 | ? " no-prepend" | |
9207 | : "", | |
9208 | CHECK_FLAG(p->flags, PEER_FLAG_LOCAL_AS_REPLACE_AS) | |
9209 | ? " replace-as" | |
9210 | : ""); | |
9211 | } | |
faa16034 DS |
9212 | /* peer type internal or confed-internal */ |
9213 | if ((p->as == p->local_as) || (p->as_type == AS_INTERNAL)) { | |
d62a17ae | 9214 | if (use_json) { |
9215 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9216 | json_object_boolean_true_add( | |
9217 | json_neigh, "nbrConfedInternalLink"); | |
9218 | else | |
9219 | json_object_boolean_true_add(json_neigh, | |
9220 | "nbrInternalLink"); | |
9221 | } else { | |
9222 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9223 | vty_out(vty, "confed-internal link\n"); | |
9224 | else | |
9225 | vty_out(vty, "internal link\n"); | |
9226 | } | |
faa16034 DS |
9227 | /* peer type external or confed-external */ |
9228 | } else if (p->as || (p->as_type == AS_EXTERNAL)) { | |
d62a17ae | 9229 | if (use_json) { |
9230 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) | |
9231 | json_object_boolean_true_add( | |
9232 | json_neigh, "nbrConfedExternalLink"); | |
9233 | else | |
9234 | json_object_boolean_true_add(json_neigh, | |
9235 | "nbrExternalLink"); | |
9236 | } else { | |
9237 | if (bgp_confederation_peers_check(bgp, p->as)) | |
9238 | vty_out(vty, "confed-external link\n"); | |
9239 | else | |
9240 | vty_out(vty, "external link\n"); | |
9241 | } | |
faa16034 DS |
9242 | } else { |
9243 | if (use_json) | |
9244 | json_object_boolean_true_add(json_neigh, | |
9245 | "nbrUnspecifiedLink"); | |
9246 | else | |
9247 | vty_out(vty, "unspecified link\n"); | |
d62a17ae | 9248 | } |
9249 | ||
9250 | /* Description. */ | |
9251 | if (p->desc) { | |
9252 | if (use_json) | |
9253 | json_object_string_add(json_neigh, "nbrDesc", p->desc); | |
9254 | else | |
9255 | vty_out(vty, " Description: %s\n", p->desc); | |
9256 | } | |
9257 | ||
9258 | if (p->hostname) { | |
9259 | if (use_json) { | |
9260 | if (p->hostname) | |
9261 | json_object_string_add(json_neigh, "hostname", | |
9262 | p->hostname); | |
9263 | ||
9264 | if (p->domainname) | |
9265 | json_object_string_add(json_neigh, "domainname", | |
9266 | p->domainname); | |
9267 | } else { | |
9268 | if (p->domainname && (p->domainname[0] != '\0')) | |
9269 | vty_out(vty, "Hostname: %s.%s\n", p->hostname, | |
9270 | p->domainname); | |
9271 | else | |
9272 | vty_out(vty, "Hostname: %s\n", p->hostname); | |
9273 | } | |
9274 | } | |
9275 | ||
9276 | /* Peer-group */ | |
9277 | if (p->group) { | |
9278 | if (use_json) { | |
9279 | json_object_string_add(json_neigh, "peerGroup", | |
9280 | p->group->name); | |
9281 | ||
9282 | if (dn_flag[0]) { | |
9283 | struct prefix prefix, *range = NULL; | |
9284 | ||
9285 | sockunion2hostprefix(&(p->su), &prefix); | |
9286 | range = peer_group_lookup_dynamic_neighbor_range( | |
9287 | p->group, &prefix); | |
9288 | ||
9289 | if (range) { | |
9290 | prefix2str(range, buf1, sizeof(buf1)); | |
9291 | json_object_string_add( | |
9292 | json_neigh, | |
9293 | "peerSubnetRangeGroup", buf1); | |
9294 | } | |
9295 | } | |
9296 | } else { | |
9297 | vty_out(vty, | |
9298 | " Member of peer-group %s for session parameters\n", | |
9299 | p->group->name); | |
9300 | ||
9301 | if (dn_flag[0]) { | |
9302 | struct prefix prefix, *range = NULL; | |
9303 | ||
9304 | sockunion2hostprefix(&(p->su), &prefix); | |
9305 | range = peer_group_lookup_dynamic_neighbor_range( | |
9306 | p->group, &prefix); | |
9307 | ||
9308 | if (range) { | |
9309 | prefix2str(range, buf1, sizeof(buf1)); | |
9310 | vty_out(vty, | |
9311 | " Belongs to the subnet range group: %s\n", | |
9312 | buf1); | |
9313 | } | |
9314 | } | |
9315 | } | |
9316 | } | |
9317 | ||
9318 | if (use_json) { | |
9319 | /* Administrative shutdown. */ | |
9320 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9321 | json_object_boolean_true_add(json_neigh, | |
9322 | "adminShutDown"); | |
9323 | ||
9324 | /* BGP Version. */ | |
9325 | json_object_int_add(json_neigh, "bgpVersion", 4); | |
9326 | json_object_string_add( | |
9327 | json_neigh, "remoteRouterId", | |
9328 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); | |
d0086e8e AD |
9329 | json_object_string_add( |
9330 | json_neigh, "localRouterId", | |
9331 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9332 | sizeof(buf1))); | |
d62a17ae | 9333 | |
9334 | /* Confederation */ | |
9335 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9336 | && bgp_confederation_peers_check(bgp, p->as)) | |
9337 | json_object_boolean_true_add(json_neigh, | |
9338 | "nbrCommonAdmin"); | |
9339 | ||
9340 | /* Status. */ | |
9341 | json_object_string_add( | |
9342 | json_neigh, "bgpState", | |
9343 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9344 | ||
9345 | if (p->status == Established) { | |
9346 | time_t uptime; | |
d62a17ae | 9347 | |
9348 | uptime = bgp_clock(); | |
9349 | uptime -= p->uptime; | |
d62a17ae | 9350 | epoch_tbuf = time(NULL) - uptime; |
9351 | ||
bee57a7a | 9352 | #if CONFDATE > 20200101 |
a4d82a8a PZ |
9353 | CPP_NOTICE( |
9354 | "bgpTimerUp should be deprecated and can be removed now"); | |
d3c7efed DS |
9355 | #endif |
9356 | /* | |
9357 | * bgpTimerUp was miliseconds that was accurate | |
9358 | * up to 1 day, then the value returned | |
9359 | * became garbage. So in order to provide | |
9360 | * some level of backwards compatability, | |
9361 | * we still provde the data, but now | |
9362 | * we are returning the correct value | |
9363 | * and also adding a new bgpTimerUpMsec | |
9364 | * which will allow us to deprecate | |
9365 | * this eventually | |
9366 | */ | |
d62a17ae | 9367 | json_object_int_add(json_neigh, "bgpTimerUp", |
e0330274 | 9368 | uptime * 1000); |
d3c7efed DS |
9369 | json_object_int_add(json_neigh, "bgpTimerUpMsec", |
9370 | uptime * 1000); | |
d62a17ae | 9371 | json_object_string_add(json_neigh, "bgpTimerUpString", |
9372 | peer_uptime(p->uptime, timebuf, | |
9373 | BGP_UPTIME_LEN, 0, | |
9374 | NULL)); | |
9375 | json_object_int_add(json_neigh, | |
9376 | "bgpTimerUpEstablishedEpoch", | |
9377 | epoch_tbuf); | |
9378 | } | |
9379 | ||
9380 | else if (p->status == Active) { | |
9381 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9382 | json_object_string_add(json_neigh, "bgpStateIs", | |
9383 | "passive"); | |
9384 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9385 | json_object_string_add(json_neigh, "bgpStateIs", | |
9386 | "passiveNSF"); | |
9387 | } | |
9388 | ||
9389 | /* read timer */ | |
9390 | time_t uptime; | |
9391 | struct tm *tm; | |
9392 | ||
9393 | uptime = bgp_clock(); | |
9394 | uptime -= p->readtime; | |
9395 | tm = gmtime(&uptime); | |
9396 | json_object_int_add(json_neigh, "bgpTimerLastRead", | |
9397 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9398 | + (tm->tm_hour * 3600000)); | |
9399 | ||
9400 | uptime = bgp_clock(); | |
9401 | uptime -= p->last_write; | |
9402 | tm = gmtime(&uptime); | |
9403 | json_object_int_add(json_neigh, "bgpTimerLastWrite", | |
9404 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9405 | + (tm->tm_hour * 3600000)); | |
9406 | ||
9407 | uptime = bgp_clock(); | |
9408 | uptime -= p->update_time; | |
9409 | tm = gmtime(&uptime); | |
9410 | json_object_int_add(json_neigh, "bgpInUpdateElapsedTimeMsecs", | |
9411 | (tm->tm_sec * 1000) + (tm->tm_min * 60000) | |
9412 | + (tm->tm_hour * 3600000)); | |
9413 | ||
9414 | /* Configured timer values. */ | |
9415 | json_object_int_add(json_neigh, "bgpTimerHoldTimeMsecs", | |
9416 | p->v_holdtime * 1000); | |
9417 | json_object_int_add(json_neigh, | |
9418 | "bgpTimerKeepAliveIntervalMsecs", | |
9419 | p->v_keepalive * 1000); | |
b90a8e13 | 9420 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9421 | json_object_int_add(json_neigh, |
9422 | "bgpTimerConfiguredHoldTimeMsecs", | |
9423 | p->holdtime * 1000); | |
9424 | json_object_int_add( | |
9425 | json_neigh, | |
9426 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9427 | p->keepalive * 1000); | |
d25e4efc | 9428 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9429 | || (bgp->default_keepalive |
9430 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9431 | json_object_int_add(json_neigh, |
9432 | "bgpTimerConfiguredHoldTimeMsecs", | |
9433 | bgp->default_holdtime); | |
9434 | json_object_int_add( | |
9435 | json_neigh, | |
9436 | "bgpTimerConfiguredKeepAliveIntervalMsecs", | |
9437 | bgp->default_keepalive); | |
d62a17ae | 9438 | } |
9439 | } else { | |
9440 | /* Administrative shutdown. */ | |
9441 | if (CHECK_FLAG(p->flags, PEER_FLAG_SHUTDOWN)) | |
9442 | vty_out(vty, " Administratively shut down\n"); | |
9443 | ||
9444 | /* BGP Version. */ | |
9445 | vty_out(vty, " BGP version 4"); | |
0e38aeb4 | 9446 | vty_out(vty, ", remote router ID %s", |
d62a17ae | 9447 | inet_ntop(AF_INET, &p->remote_id, buf1, sizeof(buf1))); |
0e38aeb4 AD |
9448 | vty_out(vty, ", local router ID %s\n", |
9449 | inet_ntop(AF_INET, &bgp->router_id, buf1, | |
9450 | sizeof(buf1))); | |
d62a17ae | 9451 | |
9452 | /* Confederation */ | |
9453 | if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION) | |
9454 | && bgp_confederation_peers_check(bgp, p->as)) | |
9455 | vty_out(vty, | |
9456 | " Neighbor under common administration\n"); | |
9457 | ||
9458 | /* Status. */ | |
9459 | vty_out(vty, " BGP state = %s", | |
9460 | lookup_msg(bgp_status_msg, p->status, NULL)); | |
9461 | ||
9462 | if (p->status == Established) | |
9463 | vty_out(vty, ", up for %8s", | |
9464 | peer_uptime(p->uptime, timebuf, BGP_UPTIME_LEN, | |
9465 | 0, NULL)); | |
9466 | ||
9467 | else if (p->status == Active) { | |
9468 | if (CHECK_FLAG(p->flags, PEER_FLAG_PASSIVE)) | |
9469 | vty_out(vty, " (passive)"); | |
9470 | else if (CHECK_FLAG(p->sflags, PEER_STATUS_NSF_WAIT)) | |
9471 | vty_out(vty, " (NSF passive)"); | |
9472 | } | |
9473 | vty_out(vty, "\n"); | |
9474 | ||
9475 | /* read timer */ | |
9476 | vty_out(vty, " Last read %s", | |
9477 | peer_uptime(p->readtime, timebuf, BGP_UPTIME_LEN, 0, | |
9478 | NULL)); | |
9479 | vty_out(vty, ", Last write %s\n", | |
9480 | peer_uptime(p->last_write, timebuf, BGP_UPTIME_LEN, 0, | |
9481 | NULL)); | |
9482 | ||
9483 | /* Configured timer values. */ | |
9484 | vty_out(vty, | |
9485 | " Hold time is %d, keepalive interval is %d seconds\n", | |
9486 | p->v_holdtime, p->v_keepalive); | |
b90a8e13 | 9487 | if (CHECK_FLAG(p->flags, PEER_FLAG_TIMER)) { |
d62a17ae | 9488 | vty_out(vty, " Configured hold time is %d", |
9489 | p->holdtime); | |
9490 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9491 | p->keepalive); | |
d25e4efc | 9492 | } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) |
a4d82a8a PZ |
9493 | || (bgp->default_keepalive |
9494 | != BGP_DEFAULT_KEEPALIVE)) { | |
d25e4efc DS |
9495 | vty_out(vty, " Configured hold time is %d", |
9496 | bgp->default_holdtime); | |
9497 | vty_out(vty, ", keepalive interval is %d seconds\n", | |
9498 | bgp->default_keepalive); | |
d62a17ae | 9499 | } |
9500 | } | |
9501 | /* Capability. */ | |
9502 | if (p->status == Established) { | |
9503 | if (p->cap || p->afc_adv[AFI_IP][SAFI_UNICAST] | |
9504 | || p->afc_recv[AFI_IP][SAFI_UNICAST] | |
9505 | || p->afc_adv[AFI_IP][SAFI_MULTICAST] | |
9506 | || p->afc_recv[AFI_IP][SAFI_MULTICAST] | |
9507 | || p->afc_adv[AFI_IP6][SAFI_UNICAST] | |
9508 | || p->afc_recv[AFI_IP6][SAFI_UNICAST] | |
9509 | || p->afc_adv[AFI_IP6][SAFI_MULTICAST] | |
9510 | || p->afc_recv[AFI_IP6][SAFI_MULTICAST] | |
9511 | || p->afc_adv[AFI_IP6][SAFI_MPLS_VPN] | |
9512 | || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] | |
9513 | || p->afc_adv[AFI_IP6][SAFI_ENCAP] | |
9514 | || p->afc_recv[AFI_IP6][SAFI_ENCAP] | |
7c40bf39 | 9515 | || p->afc_adv[AFI_IP6][SAFI_FLOWSPEC] |
9516 | || p->afc_recv[AFI_IP6][SAFI_FLOWSPEC] | |
d62a17ae | 9517 | || p->afc_adv[AFI_IP][SAFI_ENCAP] |
9518 | || p->afc_recv[AFI_IP][SAFI_ENCAP] | |
7c40bf39 | 9519 | || p->afc_adv[AFI_IP][SAFI_FLOWSPEC] |
9520 | || p->afc_recv[AFI_IP][SAFI_FLOWSPEC] | |
d62a17ae | 9521 | || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] |
9522 | || p->afc_recv[AFI_IP][SAFI_MPLS_VPN]) { | |
9523 | if (use_json) { | |
9524 | json_object *json_cap = NULL; | |
9525 | ||
9526 | json_cap = json_object_new_object(); | |
9527 | ||
9528 | /* AS4 */ | |
9529 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9530 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9531 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV) | |
9532 | && CHECK_FLAG(p->cap, | |
9533 | PEER_CAP_AS4_RCV)) | |
9534 | json_object_string_add( | |
9535 | json_cap, "4byteAs", | |
9536 | "advertisedAndReceived"); | |
9537 | else if (CHECK_FLAG(p->cap, | |
9538 | PEER_CAP_AS4_ADV)) | |
9539 | json_object_string_add( | |
9540 | json_cap, "4byteAs", | |
9541 | "advertised"); | |
9542 | else if (CHECK_FLAG(p->cap, | |
9543 | PEER_CAP_AS4_RCV)) | |
9544 | json_object_string_add( | |
9545 | json_cap, "4byteAs", | |
9546 | "received"); | |
9547 | } | |
9548 | ||
9549 | /* AddPath */ | |
9550 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9551 | || CHECK_FLAG(p->cap, | |
9552 | PEER_CAP_ADDPATH_ADV)) { | |
9553 | json_object *json_add = NULL; | |
9554 | const char *print_store; | |
9555 | ||
9556 | json_add = json_object_new_object(); | |
9557 | ||
05c7a1cc QY |
9558 | FOREACH_AFI_SAFI (afi, safi) { |
9559 | json_object *json_sub = NULL; | |
9560 | json_sub = | |
9561 | json_object_new_object(); | |
9562 | print_store = afi_safi_print( | |
9563 | afi, safi); | |
d62a17ae | 9564 | |
05c7a1cc QY |
9565 | if (CHECK_FLAG( |
9566 | p->af_cap[afi] | |
9567 | [safi], | |
9568 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9569 | || CHECK_FLAG( | |
9570 | p->af_cap[afi] | |
9571 | [safi], | |
9572 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
d62a17ae | 9573 | if (CHECK_FLAG( |
9574 | p->af_cap | |
9575 | [afi] | |
9576 | [safi], | |
9577 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
05c7a1cc | 9578 | && CHECK_FLAG( |
d62a17ae | 9579 | p->af_cap |
9580 | [afi] | |
9581 | [safi], | |
05c7a1cc QY |
9582 | PEER_CAP_ADDPATH_AF_TX_RCV)) |
9583 | json_object_boolean_true_add( | |
9584 | json_sub, | |
9585 | "txAdvertisedAndReceived"); | |
9586 | else if ( | |
9587 | CHECK_FLAG( | |
9588 | p->af_cap | |
9589 | [afi] | |
9590 | [safi], | |
9591 | PEER_CAP_ADDPATH_AF_TX_ADV)) | |
9592 | json_object_boolean_true_add( | |
9593 | json_sub, | |
9594 | "txAdvertised"); | |
9595 | else if ( | |
9596 | CHECK_FLAG( | |
9597 | p->af_cap | |
9598 | [afi] | |
9599 | [safi], | |
9600 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
9601 | json_object_boolean_true_add( | |
9602 | json_sub, | |
9603 | "txReceived"); | |
9604 | } | |
d62a17ae | 9605 | |
05c7a1cc QY |
9606 | if (CHECK_FLAG( |
9607 | p->af_cap[afi] | |
9608 | [safi], | |
9609 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9610 | || CHECK_FLAG( | |
9611 | p->af_cap[afi] | |
9612 | [safi], | |
9613 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
d62a17ae | 9614 | if (CHECK_FLAG( |
9615 | p->af_cap | |
9616 | [afi] | |
9617 | [safi], | |
9618 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
05c7a1cc | 9619 | && CHECK_FLAG( |
d62a17ae | 9620 | p->af_cap |
9621 | [afi] | |
9622 | [safi], | |
9623 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
05c7a1cc QY |
9624 | json_object_boolean_true_add( |
9625 | json_sub, | |
9626 | "rxAdvertisedAndReceived"); | |
9627 | else if ( | |
9628 | CHECK_FLAG( | |
9629 | p->af_cap | |
9630 | [afi] | |
9631 | [safi], | |
9632 | PEER_CAP_ADDPATH_AF_RX_ADV)) | |
9633 | json_object_boolean_true_add( | |
9634 | json_sub, | |
9635 | "rxAdvertised"); | |
9636 | else if ( | |
9637 | CHECK_FLAG( | |
9638 | p->af_cap | |
9639 | [afi] | |
9640 | [safi], | |
9641 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9642 | json_object_boolean_true_add( | |
9643 | json_sub, | |
9644 | "rxReceived"); | |
d62a17ae | 9645 | } |
9646 | ||
05c7a1cc QY |
9647 | if (CHECK_FLAG( |
9648 | p->af_cap[afi] | |
9649 | [safi], | |
9650 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
9651 | || CHECK_FLAG( | |
9652 | p->af_cap[afi] | |
9653 | [safi], | |
9654 | PEER_CAP_ADDPATH_AF_TX_RCV) | |
9655 | || CHECK_FLAG( | |
9656 | p->af_cap[afi] | |
9657 | [safi], | |
9658 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
9659 | || CHECK_FLAG( | |
9660 | p->af_cap[afi] | |
9661 | [safi], | |
9662 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
9663 | json_object_object_add( | |
9664 | json_add, | |
9665 | print_store, | |
9666 | json_sub); | |
9667 | else | |
9668 | json_object_free( | |
9669 | json_sub); | |
9670 | } | |
9671 | ||
d62a17ae | 9672 | json_object_object_add( |
9673 | json_cap, "addPath", json_add); | |
9674 | } | |
9675 | ||
9676 | /* Dynamic */ | |
9677 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
9678 | || CHECK_FLAG(p->cap, | |
9679 | PEER_CAP_DYNAMIC_ADV)) { | |
9680 | if (CHECK_FLAG(p->cap, | |
9681 | PEER_CAP_DYNAMIC_ADV) | |
9682 | && CHECK_FLAG(p->cap, | |
9683 | PEER_CAP_DYNAMIC_RCV)) | |
9684 | json_object_string_add( | |
9685 | json_cap, "dynamic", | |
9686 | "advertisedAndReceived"); | |
9687 | else if (CHECK_FLAG( | |
9688 | p->cap, | |
9689 | PEER_CAP_DYNAMIC_ADV)) | |
9690 | json_object_string_add( | |
9691 | json_cap, "dynamic", | |
9692 | "advertised"); | |
9693 | else if (CHECK_FLAG( | |
9694 | p->cap, | |
9695 | PEER_CAP_DYNAMIC_RCV)) | |
9696 | json_object_string_add( | |
9697 | json_cap, "dynamic", | |
9698 | "received"); | |
9699 | } | |
9700 | ||
9701 | /* Extended nexthop */ | |
9702 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
9703 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
9704 | json_object *json_nxt = NULL; | |
9705 | const char *print_store; | |
9706 | ||
9707 | ||
9708 | if (CHECK_FLAG(p->cap, | |
9709 | PEER_CAP_ENHE_ADV) | |
9710 | && CHECK_FLAG(p->cap, | |
9711 | PEER_CAP_ENHE_RCV)) | |
9712 | json_object_string_add( | |
9713 | json_cap, | |
9714 | "extendedNexthop", | |
9715 | "advertisedAndReceived"); | |
9716 | else if (CHECK_FLAG(p->cap, | |
9717 | PEER_CAP_ENHE_ADV)) | |
9718 | json_object_string_add( | |
9719 | json_cap, | |
9720 | "extendedNexthop", | |
9721 | "advertised"); | |
9722 | else if (CHECK_FLAG(p->cap, | |
9723 | PEER_CAP_ENHE_RCV)) | |
9724 | json_object_string_add( | |
9725 | json_cap, | |
9726 | "extendedNexthop", | |
9727 | "received"); | |
9728 | ||
9729 | if (CHECK_FLAG(p->cap, | |
9730 | PEER_CAP_ENHE_RCV)) { | |
9731 | json_nxt = | |
9732 | json_object_new_object(); | |
9733 | ||
9734 | for (safi = SAFI_UNICAST; | |
9735 | safi < SAFI_MAX; safi++) { | |
9736 | if (CHECK_FLAG( | |
9737 | p->af_cap | |
9738 | [AFI_IP] | |
9739 | [safi], | |
9740 | PEER_CAP_ENHE_AF_RCV)) { | |
9741 | print_store = afi_safi_print( | |
9742 | AFI_IP, | |
9743 | safi); | |
9744 | json_object_string_add( | |
9745 | json_nxt, | |
9746 | print_store, | |
54f29523 | 9747 | "recieved"); /* misspelled for compatibility */ |
d62a17ae | 9748 | } |
9749 | } | |
9750 | json_object_object_add( | |
9751 | json_cap, | |
9752 | "extendedNexthopFamililesByPeer", | |
9753 | json_nxt); | |
9754 | } | |
9755 | } | |
9756 | ||
9757 | /* Route Refresh */ | |
9758 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
9759 | || CHECK_FLAG(p->cap, | |
9760 | PEER_CAP_REFRESH_NEW_RCV) | |
9761 | || CHECK_FLAG(p->cap, | |
9762 | PEER_CAP_REFRESH_OLD_RCV)) { | |
9763 | if (CHECK_FLAG(p->cap, | |
9764 | PEER_CAP_REFRESH_ADV) | |
9765 | && (CHECK_FLAG( | |
9766 | p->cap, | |
9767 | PEER_CAP_REFRESH_NEW_RCV) | |
9768 | || CHECK_FLAG( | |
9769 | p->cap, | |
9770 | PEER_CAP_REFRESH_OLD_RCV))) { | |
9771 | if (CHECK_FLAG( | |
9772 | p->cap, | |
9773 | PEER_CAP_REFRESH_OLD_RCV) | |
9774 | && CHECK_FLAG( | |
9775 | p->cap, | |
9776 | PEER_CAP_REFRESH_NEW_RCV)) | |
9777 | json_object_string_add( | |
9778 | json_cap, | |
9779 | "routeRefresh", | |
9780 | "advertisedAndReceivedOldNew"); | |
9781 | else { | |
9782 | if (CHECK_FLAG( | |
9783 | p->cap, | |
9784 | PEER_CAP_REFRESH_OLD_RCV)) | |
9785 | json_object_string_add( | |
9786 | json_cap, | |
9787 | "routeRefresh", | |
9788 | "advertisedAndReceivedOld"); | |
9789 | else | |
9790 | json_object_string_add( | |
9791 | json_cap, | |
9792 | "routeRefresh", | |
9793 | "advertisedAndReceivedNew"); | |
9794 | } | |
9795 | } else if ( | |
9796 | CHECK_FLAG( | |
9797 | p->cap, | |
9798 | PEER_CAP_REFRESH_ADV)) | |
9799 | json_object_string_add( | |
9800 | json_cap, | |
9801 | "routeRefresh", | |
9802 | "advertised"); | |
9803 | else if ( | |
9804 | CHECK_FLAG( | |
9805 | p->cap, | |
9806 | PEER_CAP_REFRESH_NEW_RCV) | |
9807 | || CHECK_FLAG( | |
9808 | p->cap, | |
9809 | PEER_CAP_REFRESH_OLD_RCV)) | |
9810 | json_object_string_add( | |
9811 | json_cap, | |
9812 | "routeRefresh", | |
9813 | "received"); | |
9814 | } | |
9815 | ||
9816 | /* Multiprotocol Extensions */ | |
9817 | json_object *json_multi = NULL; | |
9818 | json_multi = json_object_new_object(); | |
9819 | ||
05c7a1cc QY |
9820 | FOREACH_AFI_SAFI (afi, safi) { |
9821 | if (p->afc_adv[afi][safi] | |
9822 | || p->afc_recv[afi][safi]) { | |
9823 | json_object *json_exten = NULL; | |
9824 | json_exten = | |
9825 | json_object_new_object(); | |
9826 | ||
d62a17ae | 9827 | if (p->afc_adv[afi][safi] |
05c7a1cc QY |
9828 | && p->afc_recv[afi][safi]) |
9829 | json_object_boolean_true_add( | |
9830 | json_exten, | |
9831 | "advertisedAndReceived"); | |
9832 | else if (p->afc_adv[afi][safi]) | |
9833 | json_object_boolean_true_add( | |
9834 | json_exten, | |
9835 | "advertised"); | |
9836 | else if (p->afc_recv[afi][safi]) | |
9837 | json_object_boolean_true_add( | |
9838 | json_exten, | |
9839 | "received"); | |
d62a17ae | 9840 | |
05c7a1cc QY |
9841 | json_object_object_add( |
9842 | json_multi, | |
9843 | afi_safi_print(afi, | |
9844 | safi), | |
9845 | json_exten); | |
d62a17ae | 9846 | } |
9847 | } | |
9848 | json_object_object_add( | |
9849 | json_cap, "multiprotocolExtensions", | |
9850 | json_multi); | |
9851 | ||
d77114b7 | 9852 | /* Hostname capabilities */ |
60466a63 | 9853 | json_object *json_hname = NULL; |
d77114b7 MK |
9854 | |
9855 | json_hname = json_object_new_object(); | |
9856 | ||
9857 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
9858 | json_object_string_add( | |
60466a63 QY |
9859 | json_hname, "advHostName", |
9860 | bgp->peer_self->hostname | |
9861 | ? bgp->peer_self | |
9862 | ->hostname | |
d77114b7 MK |
9863 | : "n/a"); |
9864 | json_object_string_add( | |
60466a63 QY |
9865 | json_hname, "advDomainName", |
9866 | bgp->peer_self->domainname | |
9867 | ? bgp->peer_self | |
9868 | ->domainname | |
d77114b7 MK |
9869 | : "n/a"); |
9870 | } | |
9871 | ||
9872 | ||
9873 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { | |
9874 | json_object_string_add( | |
60466a63 QY |
9875 | json_hname, "rcvHostName", |
9876 | p->hostname ? p->hostname | |
9877 | : "n/a"); | |
d77114b7 | 9878 | json_object_string_add( |
60466a63 QY |
9879 | json_hname, "rcvDomainName", |
9880 | p->domainname ? p->domainname | |
9881 | : "n/a"); | |
d77114b7 MK |
9882 | } |
9883 | ||
60466a63 | 9884 | json_object_object_add(json_cap, "hostName", |
d77114b7 MK |
9885 | json_hname); |
9886 | ||
d62a17ae | 9887 | /* Gracefull Restart */ |
9888 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
9889 | || CHECK_FLAG(p->cap, | |
9890 | PEER_CAP_RESTART_ADV)) { | |
9891 | if (CHECK_FLAG(p->cap, | |
9892 | PEER_CAP_RESTART_ADV) | |
9893 | && CHECK_FLAG(p->cap, | |
9894 | PEER_CAP_RESTART_RCV)) | |
9895 | json_object_string_add( | |
9896 | json_cap, | |
9897 | "gracefulRestart", | |
9898 | "advertisedAndReceived"); | |
9899 | else if (CHECK_FLAG( | |
9900 | p->cap, | |
9901 | PEER_CAP_RESTART_ADV)) | |
9902 | json_object_string_add( | |
9903 | json_cap, | |
9904 | "gracefulRestartCapability", | |
9905 | "advertised"); | |
9906 | else if (CHECK_FLAG( | |
9907 | p->cap, | |
9908 | PEER_CAP_RESTART_RCV)) | |
9909 | json_object_string_add( | |
9910 | json_cap, | |
9911 | "gracefulRestartCapability", | |
9912 | "received"); | |
9913 | ||
9914 | if (CHECK_FLAG(p->cap, | |
9915 | PEER_CAP_RESTART_RCV)) { | |
9916 | int restart_af_count = 0; | |
9917 | json_object *json_restart = | |
9918 | NULL; | |
9919 | json_restart = | |
9920 | json_object_new_object(); | |
9921 | ||
9922 | json_object_int_add( | |
9923 | json_cap, | |
9924 | "gracefulRestartRemoteTimerMsecs", | |
9925 | p->v_gr_restart * 1000); | |
9926 | ||
05c7a1cc QY |
9927 | FOREACH_AFI_SAFI (afi, safi) { |
9928 | if (CHECK_FLAG( | |
9929 | p->af_cap | |
9930 | [afi] | |
9931 | [safi], | |
9932 | PEER_CAP_RESTART_AF_RCV)) { | |
9933 | json_object * | |
9934 | json_sub = | |
9935 | NULL; | |
9936 | json_sub = | |
9937 | json_object_new_object(); | |
9938 | ||
d62a17ae | 9939 | if (CHECK_FLAG( |
9940 | p->af_cap | |
9941 | [afi] | |
9942 | [safi], | |
05c7a1cc QY |
9943 | PEER_CAP_RESTART_AF_PRESERVE_RCV)) |
9944 | json_object_boolean_true_add( | |
9945 | json_sub, | |
9946 | "preserved"); | |
9947 | restart_af_count++; | |
9948 | json_object_object_add( | |
9949 | json_restart, | |
9950 | afi_safi_print( | |
9951 | afi, | |
9952 | safi), | |
9953 | json_sub); | |
d62a17ae | 9954 | } |
9955 | } | |
9956 | if (!restart_af_count) { | |
9957 | json_object_string_add( | |
9958 | json_cap, | |
9959 | "addressFamiliesByPeer", | |
9960 | "none"); | |
9961 | json_object_free( | |
9962 | json_restart); | |
9963 | } else | |
9964 | json_object_object_add( | |
9965 | json_cap, | |
9966 | "addressFamiliesByPeer", | |
9967 | json_restart); | |
9968 | } | |
9969 | } | |
9970 | json_object_object_add(json_neigh, | |
9971 | "neighborCapabilities", | |
9972 | json_cap); | |
9973 | } else { | |
9974 | vty_out(vty, " Neighbor capabilities:\n"); | |
9975 | ||
9976 | /* AS4 */ | |
9977 | if (CHECK_FLAG(p->cap, PEER_CAP_AS4_RCV) | |
9978 | || CHECK_FLAG(p->cap, PEER_CAP_AS4_ADV)) { | |
9979 | vty_out(vty, " 4 Byte AS:"); | |
9980 | if (CHECK_FLAG(p->cap, | |
9981 | PEER_CAP_AS4_ADV)) | |
9982 | vty_out(vty, " advertised"); | |
9983 | if (CHECK_FLAG(p->cap, | |
9984 | PEER_CAP_AS4_RCV)) | |
9985 | vty_out(vty, " %sreceived", | |
9986 | CHECK_FLAG( | |
9987 | p->cap, | |
9988 | PEER_CAP_AS4_ADV) | |
9989 | ? "and " | |
9990 | : ""); | |
9991 | vty_out(vty, "\n"); | |
9992 | } | |
9993 | ||
9994 | /* AddPath */ | |
9995 | if (CHECK_FLAG(p->cap, PEER_CAP_ADDPATH_RCV) | |
9996 | || CHECK_FLAG(p->cap, | |
9997 | PEER_CAP_ADDPATH_ADV)) { | |
9998 | vty_out(vty, " AddPath:\n"); | |
9999 | ||
05c7a1cc QY |
10000 | FOREACH_AFI_SAFI (afi, safi) { |
10001 | if (CHECK_FLAG( | |
10002 | p->af_cap[afi] | |
10003 | [safi], | |
10004 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10005 | || CHECK_FLAG( | |
10006 | p->af_cap[afi] | |
10007 | [safi], | |
10008 | PEER_CAP_ADDPATH_AF_TX_RCV)) { | |
10009 | vty_out(vty, | |
10010 | " %s: TX ", | |
10011 | afi_safi_print( | |
10012 | afi, | |
10013 | safi)); | |
10014 | ||
d62a17ae | 10015 | if (CHECK_FLAG( |
10016 | p->af_cap | |
10017 | [afi] | |
10018 | [safi], | |
05c7a1cc | 10019 | PEER_CAP_ADDPATH_AF_TX_ADV)) |
d62a17ae | 10020 | vty_out(vty, |
05c7a1cc | 10021 | "advertised %s", |
d62a17ae | 10022 | afi_safi_print( |
10023 | afi, | |
10024 | safi)); | |
10025 | ||
05c7a1cc QY |
10026 | if (CHECK_FLAG( |
10027 | p->af_cap | |
10028 | [afi] | |
10029 | [safi], | |
10030 | PEER_CAP_ADDPATH_AF_TX_RCV)) | |
10031 | vty_out(vty, | |
10032 | "%sreceived", | |
10033 | CHECK_FLAG( | |
10034 | p->af_cap | |
10035 | [afi] | |
10036 | [safi], | |
10037 | PEER_CAP_ADDPATH_AF_TX_ADV) | |
10038 | ? " and " | |
10039 | : ""); | |
d62a17ae | 10040 | |
05c7a1cc QY |
10041 | vty_out(vty, "\n"); |
10042 | } | |
d62a17ae | 10043 | |
05c7a1cc QY |
10044 | if (CHECK_FLAG( |
10045 | p->af_cap[afi] | |
10046 | [safi], | |
10047 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10048 | || CHECK_FLAG( | |
10049 | p->af_cap[afi] | |
10050 | [safi], | |
10051 | PEER_CAP_ADDPATH_AF_RX_RCV)) { | |
10052 | vty_out(vty, | |
10053 | " %s: RX ", | |
10054 | afi_safi_print( | |
10055 | afi, | |
10056 | safi)); | |
d62a17ae | 10057 | |
10058 | if (CHECK_FLAG( | |
10059 | p->af_cap | |
10060 | [afi] | |
10061 | [safi], | |
05c7a1cc | 10062 | PEER_CAP_ADDPATH_AF_RX_ADV)) |
d62a17ae | 10063 | vty_out(vty, |
05c7a1cc | 10064 | "advertised %s", |
d62a17ae | 10065 | afi_safi_print( |
10066 | afi, | |
10067 | safi)); | |
10068 | ||
05c7a1cc QY |
10069 | if (CHECK_FLAG( |
10070 | p->af_cap | |
10071 | [afi] | |
10072 | [safi], | |
10073 | PEER_CAP_ADDPATH_AF_RX_RCV)) | |
d62a17ae | 10074 | vty_out(vty, |
05c7a1cc QY |
10075 | "%sreceived", |
10076 | CHECK_FLAG( | |
10077 | p->af_cap | |
10078 | [afi] | |
10079 | [safi], | |
10080 | PEER_CAP_ADDPATH_AF_RX_ADV) | |
10081 | ? " and " | |
10082 | : ""); | |
10083 | ||
10084 | vty_out(vty, "\n"); | |
d62a17ae | 10085 | } |
05c7a1cc | 10086 | } |
d62a17ae | 10087 | } |
10088 | ||
10089 | /* Dynamic */ | |
10090 | if (CHECK_FLAG(p->cap, PEER_CAP_DYNAMIC_RCV) | |
10091 | || CHECK_FLAG(p->cap, | |
10092 | PEER_CAP_DYNAMIC_ADV)) { | |
10093 | vty_out(vty, " Dynamic:"); | |
10094 | if (CHECK_FLAG(p->cap, | |
10095 | PEER_CAP_DYNAMIC_ADV)) | |
10096 | vty_out(vty, " advertised"); | |
10097 | if (CHECK_FLAG(p->cap, | |
10098 | PEER_CAP_DYNAMIC_RCV)) | |
10099 | vty_out(vty, " %sreceived", | |
10100 | CHECK_FLAG( | |
10101 | p->cap, | |
10102 | PEER_CAP_DYNAMIC_ADV) | |
10103 | ? "and " | |
10104 | : ""); | |
10105 | vty_out(vty, "\n"); | |
10106 | } | |
10107 | ||
10108 | /* Extended nexthop */ | |
10109 | if (CHECK_FLAG(p->cap, PEER_CAP_ENHE_RCV) | |
10110 | || CHECK_FLAG(p->cap, PEER_CAP_ENHE_ADV)) { | |
10111 | vty_out(vty, " Extended nexthop:"); | |
10112 | if (CHECK_FLAG(p->cap, | |
10113 | PEER_CAP_ENHE_ADV)) | |
10114 | vty_out(vty, " advertised"); | |
10115 | if (CHECK_FLAG(p->cap, | |
10116 | PEER_CAP_ENHE_RCV)) | |
10117 | vty_out(vty, " %sreceived", | |
10118 | CHECK_FLAG( | |
10119 | p->cap, | |
10120 | PEER_CAP_ENHE_ADV) | |
10121 | ? "and " | |
10122 | : ""); | |
10123 | vty_out(vty, "\n"); | |
10124 | ||
10125 | if (CHECK_FLAG(p->cap, | |
10126 | PEER_CAP_ENHE_RCV)) { | |
10127 | vty_out(vty, | |
10128 | " Address families by peer:\n "); | |
10129 | for (safi = SAFI_UNICAST; | |
10130 | safi < SAFI_MAX; safi++) | |
10131 | if (CHECK_FLAG( | |
10132 | p->af_cap | |
10133 | [AFI_IP] | |
10134 | [safi], | |
10135 | PEER_CAP_ENHE_AF_RCV)) | |
10136 | vty_out(vty, | |
10137 | " %s\n", | |
10138 | afi_safi_print( | |
10139 | AFI_IP, | |
10140 | safi)); | |
10141 | } | |
10142 | } | |
10143 | ||
10144 | /* Route Refresh */ | |
10145 | if (CHECK_FLAG(p->cap, PEER_CAP_REFRESH_ADV) | |
10146 | || CHECK_FLAG(p->cap, | |
10147 | PEER_CAP_REFRESH_NEW_RCV) | |
10148 | || CHECK_FLAG(p->cap, | |
10149 | PEER_CAP_REFRESH_OLD_RCV)) { | |
10150 | vty_out(vty, " Route refresh:"); | |
10151 | if (CHECK_FLAG(p->cap, | |
10152 | PEER_CAP_REFRESH_ADV)) | |
10153 | vty_out(vty, " advertised"); | |
10154 | if (CHECK_FLAG(p->cap, | |
10155 | PEER_CAP_REFRESH_NEW_RCV) | |
10156 | || CHECK_FLAG( | |
10157 | p->cap, | |
10158 | PEER_CAP_REFRESH_OLD_RCV)) | |
10159 | vty_out(vty, " %sreceived(%s)", | |
10160 | CHECK_FLAG( | |
10161 | p->cap, | |
10162 | PEER_CAP_REFRESH_ADV) | |
10163 | ? "and " | |
10164 | : "", | |
10165 | (CHECK_FLAG( | |
10166 | p->cap, | |
10167 | PEER_CAP_REFRESH_OLD_RCV) | |
10168 | && CHECK_FLAG( | |
10169 | p->cap, | |
10170 | PEER_CAP_REFRESH_NEW_RCV)) | |
10171 | ? "old & new" | |
10172 | : CHECK_FLAG( | |
10173 | p->cap, | |
10174 | PEER_CAP_REFRESH_OLD_RCV) | |
10175 | ? "old" | |
10176 | : "new"); | |
10177 | ||
10178 | vty_out(vty, "\n"); | |
10179 | } | |
10180 | ||
10181 | /* Multiprotocol Extensions */ | |
05c7a1cc QY |
10182 | FOREACH_AFI_SAFI (afi, safi) |
10183 | if (p->afc_adv[afi][safi] | |
10184 | || p->afc_recv[afi][safi]) { | |
10185 | vty_out(vty, | |
10186 | " Address Family %s:", | |
10187 | afi_safi_print(afi, | |
10188 | safi)); | |
10189 | if (p->afc_adv[afi][safi]) | |
d62a17ae | 10190 | vty_out(vty, |
05c7a1cc QY |
10191 | " advertised"); |
10192 | if (p->afc_recv[afi][safi]) | |
10193 | vty_out(vty, | |
10194 | " %sreceived", | |
10195 | p->afc_adv[afi] | |
10196 | [safi] | |
10197 | ? "and " | |
10198 | : ""); | |
10199 | vty_out(vty, "\n"); | |
10200 | } | |
d62a17ae | 10201 | |
10202 | /* Hostname capability */ | |
60466a63 | 10203 | vty_out(vty, " Hostname Capability:"); |
d77114b7 MK |
10204 | |
10205 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_ADV)) { | |
57f7feb6 MK |
10206 | vty_out(vty, |
10207 | " advertised (name: %s,domain name: %s)", | |
60466a63 QY |
10208 | bgp->peer_self->hostname |
10209 | ? bgp->peer_self | |
10210 | ->hostname | |
d77114b7 | 10211 | : "n/a", |
60466a63 QY |
10212 | bgp->peer_self->domainname |
10213 | ? bgp->peer_self | |
10214 | ->domainname | |
d77114b7 MK |
10215 | : "n/a"); |
10216 | } else { | |
10217 | vty_out(vty, " not advertised"); | |
d62a17ae | 10218 | } |
10219 | ||
d77114b7 | 10220 | if (CHECK_FLAG(p->cap, PEER_CAP_HOSTNAME_RCV)) { |
57f7feb6 MK |
10221 | vty_out(vty, |
10222 | " received (name: %s,domain name: %s)", | |
60466a63 QY |
10223 | p->hostname ? p->hostname |
10224 | : "n/a", | |
10225 | p->domainname ? p->domainname | |
10226 | : "n/a"); | |
d77114b7 MK |
10227 | } else { |
10228 | vty_out(vty, " not received"); | |
10229 | } | |
10230 | ||
10231 | vty_out(vty, "\n"); | |
10232 | ||
d62a17ae | 10233 | /* Gracefull Restart */ |
10234 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) | |
10235 | || CHECK_FLAG(p->cap, | |
10236 | PEER_CAP_RESTART_ADV)) { | |
10237 | vty_out(vty, | |
10238 | " Graceful Restart Capabilty:"); | |
10239 | if (CHECK_FLAG(p->cap, | |
10240 | PEER_CAP_RESTART_ADV)) | |
10241 | vty_out(vty, " advertised"); | |
10242 | if (CHECK_FLAG(p->cap, | |
10243 | PEER_CAP_RESTART_RCV)) | |
10244 | vty_out(vty, " %sreceived", | |
10245 | CHECK_FLAG( | |
10246 | p->cap, | |
10247 | PEER_CAP_RESTART_ADV) | |
10248 | ? "and " | |
10249 | : ""); | |
10250 | vty_out(vty, "\n"); | |
10251 | ||
10252 | if (CHECK_FLAG(p->cap, | |
10253 | PEER_CAP_RESTART_RCV)) { | |
10254 | int restart_af_count = 0; | |
10255 | ||
10256 | vty_out(vty, | |
10257 | " Remote Restart timer is %d seconds\n", | |
10258 | p->v_gr_restart); | |
10259 | vty_out(vty, | |
10260 | " Address families by peer:\n "); | |
10261 | ||
05c7a1cc QY |
10262 | FOREACH_AFI_SAFI (afi, safi) |
10263 | if (CHECK_FLAG( | |
10264 | p->af_cap | |
10265 | [afi] | |
10266 | [safi], | |
10267 | PEER_CAP_RESTART_AF_RCV)) { | |
10268 | vty_out(vty, | |
10269 | "%s%s(%s)", | |
10270 | restart_af_count | |
10271 | ? ", " | |
10272 | : "", | |
10273 | afi_safi_print( | |
10274 | afi, | |
10275 | safi), | |
10276 | CHECK_FLAG( | |
10277 | p->af_cap | |
10278 | [afi] | |
10279 | [safi], | |
10280 | PEER_CAP_RESTART_AF_PRESERVE_RCV) | |
10281 | ? "preserved" | |
10282 | : "not preserved"); | |
10283 | restart_af_count++; | |
10284 | } | |
d62a17ae | 10285 | if (!restart_af_count) |
10286 | vty_out(vty, "none"); | |
10287 | vty_out(vty, "\n"); | |
10288 | } | |
10289 | } | |
10290 | } | |
10291 | } | |
10292 | } | |
10293 | ||
10294 | /* graceful restart information */ | |
10295 | if (CHECK_FLAG(p->cap, PEER_CAP_RESTART_RCV) || p->t_gr_restart | |
10296 | || p->t_gr_stale) { | |
10297 | json_object *json_grace = NULL; | |
10298 | json_object *json_grace_send = NULL; | |
10299 | json_object *json_grace_recv = NULL; | |
10300 | int eor_send_af_count = 0; | |
10301 | int eor_receive_af_count = 0; | |
10302 | ||
10303 | if (use_json) { | |
10304 | json_grace = json_object_new_object(); | |
10305 | json_grace_send = json_object_new_object(); | |
10306 | json_grace_recv = json_object_new_object(); | |
10307 | ||
10308 | if (p->status == Established) { | |
05c7a1cc QY |
10309 | FOREACH_AFI_SAFI (afi, safi) { |
10310 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10311 | PEER_STATUS_EOR_SEND)) { | |
10312 | json_object_boolean_true_add( | |
10313 | json_grace_send, | |
10314 | afi_safi_print(afi, | |
10315 | safi)); | |
10316 | eor_send_af_count++; | |
d62a17ae | 10317 | } |
10318 | } | |
05c7a1cc QY |
10319 | FOREACH_AFI_SAFI (afi, safi) { |
10320 | if (CHECK_FLAG( | |
10321 | p->af_sflags[afi][safi], | |
10322 | PEER_STATUS_EOR_RECEIVED)) { | |
10323 | json_object_boolean_true_add( | |
10324 | json_grace_recv, | |
10325 | afi_safi_print(afi, | |
10326 | safi)); | |
10327 | eor_receive_af_count++; | |
d62a17ae | 10328 | } |
10329 | } | |
10330 | } | |
10331 | ||
10332 | json_object_object_add(json_grace, "endOfRibSend", | |
10333 | json_grace_send); | |
10334 | json_object_object_add(json_grace, "endOfRibRecv", | |
10335 | json_grace_recv); | |
10336 | ||
10337 | if (p->t_gr_restart) | |
10338 | json_object_int_add(json_grace, | |
10339 | "gracefulRestartTimerMsecs", | |
10340 | thread_timer_remain_second( | |
10341 | p->t_gr_restart) | |
10342 | * 1000); | |
10343 | ||
10344 | if (p->t_gr_stale) | |
10345 | json_object_int_add( | |
10346 | json_grace, | |
10347 | "gracefulStalepathTimerMsecs", | |
10348 | thread_timer_remain_second( | |
10349 | p->t_gr_stale) | |
10350 | * 1000); | |
10351 | ||
10352 | json_object_object_add( | |
10353 | json_neigh, "gracefulRestartInfo", json_grace); | |
10354 | } else { | |
0437e105 | 10355 | vty_out(vty, " Graceful restart information:\n"); |
d62a17ae | 10356 | if (p->status == Established) { |
10357 | vty_out(vty, " End-of-RIB send: "); | |
05c7a1cc QY |
10358 | FOREACH_AFI_SAFI (afi, safi) { |
10359 | if (CHECK_FLAG(p->af_sflags[afi][safi], | |
10360 | PEER_STATUS_EOR_SEND)) { | |
10361 | vty_out(vty, "%s%s", | |
10362 | eor_send_af_count ? ", " | |
10363 | : "", | |
10364 | afi_safi_print(afi, | |
10365 | safi)); | |
10366 | eor_send_af_count++; | |
d62a17ae | 10367 | } |
10368 | } | |
10369 | vty_out(vty, "\n"); | |
10370 | vty_out(vty, " End-of-RIB received: "); | |
05c7a1cc QY |
10371 | FOREACH_AFI_SAFI (afi, safi) { |
10372 | if (CHECK_FLAG( | |
10373 | p->af_sflags[afi][safi], | |
10374 | PEER_STATUS_EOR_RECEIVED)) { | |
10375 | vty_out(vty, "%s%s", | |
10376 | eor_receive_af_count | |
10377 | ? ", " | |
10378 | : "", | |
10379 | afi_safi_print(afi, | |
10380 | safi)); | |
10381 | eor_receive_af_count++; | |
d62a17ae | 10382 | } |
10383 | } | |
10384 | vty_out(vty, "\n"); | |
10385 | } | |
10386 | ||
10387 | if (p->t_gr_restart) | |
10388 | vty_out(vty, | |
10389 | " The remaining time of restart timer is %ld\n", | |
10390 | thread_timer_remain_second( | |
10391 | p->t_gr_restart)); | |
10392 | ||
10393 | if (p->t_gr_stale) | |
10394 | vty_out(vty, | |
10395 | " The remaining time of stalepath timer is %ld\n", | |
10396 | thread_timer_remain_second( | |
10397 | p->t_gr_stale)); | |
10398 | } | |
10399 | } | |
10400 | if (use_json) { | |
10401 | json_object *json_stat = NULL; | |
10402 | json_stat = json_object_new_object(); | |
10403 | /* Packet counts. */ | |
10404 | json_object_int_add(json_stat, "depthInq", 0); | |
10405 | json_object_int_add(json_stat, "depthOutq", | |
10406 | (unsigned long)p->obuf->count); | |
0112e9e0 QY |
10407 | json_object_int_add(json_stat, "opensSent", |
10408 | atomic_load_explicit(&p->open_out, | |
10409 | memory_order_relaxed)); | |
10410 | json_object_int_add(json_stat, "opensRecv", | |
10411 | atomic_load_explicit(&p->open_in, | |
10412 | memory_order_relaxed)); | |
d62a17ae | 10413 | json_object_int_add(json_stat, "notificationsSent", |
0112e9e0 QY |
10414 | atomic_load_explicit(&p->notify_out, |
10415 | memory_order_relaxed)); | |
d62a17ae | 10416 | json_object_int_add(json_stat, "notificationsRecv", |
0112e9e0 QY |
10417 | atomic_load_explicit(&p->notify_in, |
10418 | memory_order_relaxed)); | |
10419 | json_object_int_add(json_stat, "updatesSent", | |
10420 | atomic_load_explicit(&p->update_out, | |
10421 | memory_order_relaxed)); | |
10422 | json_object_int_add(json_stat, "updatesRecv", | |
10423 | atomic_load_explicit(&p->update_in, | |
10424 | memory_order_relaxed)); | |
d62a17ae | 10425 | json_object_int_add(json_stat, "keepalivesSent", |
0112e9e0 QY |
10426 | atomic_load_explicit(&p->keepalive_out, |
10427 | memory_order_relaxed)); | |
d62a17ae | 10428 | json_object_int_add(json_stat, "keepalivesRecv", |
0112e9e0 QY |
10429 | atomic_load_explicit(&p->keepalive_in, |
10430 | memory_order_relaxed)); | |
d62a17ae | 10431 | json_object_int_add(json_stat, "routeRefreshSent", |
0112e9e0 QY |
10432 | atomic_load_explicit(&p->refresh_out, |
10433 | memory_order_relaxed)); | |
d62a17ae | 10434 | json_object_int_add(json_stat, "routeRefreshRecv", |
0112e9e0 QY |
10435 | atomic_load_explicit(&p->refresh_in, |
10436 | memory_order_relaxed)); | |
d62a17ae | 10437 | json_object_int_add(json_stat, "capabilitySent", |
0112e9e0 QY |
10438 | atomic_load_explicit(&p->dynamic_cap_out, |
10439 | memory_order_relaxed)); | |
d62a17ae | 10440 | json_object_int_add(json_stat, "capabilityRecv", |
0112e9e0 QY |
10441 | atomic_load_explicit(&p->dynamic_cap_in, |
10442 | memory_order_relaxed)); | |
10443 | json_object_int_add(json_stat, "totalSent", PEER_TOTAL_TX(p)); | |
10444 | json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); | |
d62a17ae | 10445 | json_object_object_add(json_neigh, "messageStats", json_stat); |
10446 | } else { | |
10447 | /* Packet counts. */ | |
10448 | vty_out(vty, " Message statistics:\n"); | |
10449 | vty_out(vty, " Inq depth is 0\n"); | |
10450 | vty_out(vty, " Outq depth is %lu\n", | |
10451 | (unsigned long)p->obuf->count); | |
10452 | vty_out(vty, " Sent Rcvd\n"); | |
0112e9e0 QY |
10453 | vty_out(vty, " Opens: %10d %10d\n", |
10454 | atomic_load_explicit(&p->open_out, | |
10455 | memory_order_relaxed), | |
10456 | atomic_load_explicit(&p->open_in, | |
10457 | memory_order_relaxed)); | |
10458 | vty_out(vty, " Notifications: %10d %10d\n", | |
10459 | atomic_load_explicit(&p->notify_out, | |
10460 | memory_order_relaxed), | |
10461 | atomic_load_explicit(&p->notify_in, | |
10462 | memory_order_relaxed)); | |
10463 | vty_out(vty, " Updates: %10d %10d\n", | |
10464 | atomic_load_explicit(&p->update_out, | |
10465 | memory_order_relaxed), | |
10466 | atomic_load_explicit(&p->update_in, | |
10467 | memory_order_relaxed)); | |
10468 | vty_out(vty, " Keepalives: %10d %10d\n", | |
10469 | atomic_load_explicit(&p->keepalive_out, | |
10470 | memory_order_relaxed), | |
10471 | atomic_load_explicit(&p->keepalive_in, | |
10472 | memory_order_relaxed)); | |
10473 | vty_out(vty, " Route Refresh: %10d %10d\n", | |
10474 | atomic_load_explicit(&p->refresh_out, | |
10475 | memory_order_relaxed), | |
10476 | atomic_load_explicit(&p->refresh_in, | |
10477 | memory_order_relaxed)); | |
d62a17ae | 10478 | vty_out(vty, " Capability: %10d %10d\n", |
0112e9e0 QY |
10479 | atomic_load_explicit(&p->dynamic_cap_out, |
10480 | memory_order_relaxed), | |
10481 | atomic_load_explicit(&p->dynamic_cap_in, | |
10482 | memory_order_relaxed)); | |
10483 | vty_out(vty, " Total: %10d %10d\n", PEER_TOTAL_TX(p), | |
10484 | PEER_TOTAL_RX(p)); | |
d62a17ae | 10485 | } |
10486 | ||
10487 | if (use_json) { | |
10488 | /* advertisement-interval */ | |
10489 | json_object_int_add(json_neigh, | |
10490 | "minBtwnAdvertisementRunsTimerMsecs", | |
10491 | p->v_routeadv * 1000); | |
10492 | ||
10493 | /* Update-source. */ | |
10494 | if (p->update_if || p->update_source) { | |
10495 | if (p->update_if) | |
10496 | json_object_string_add(json_neigh, | |
10497 | "updateSource", | |
10498 | p->update_if); | |
10499 | else if (p->update_source) | |
10500 | json_object_string_add( | |
10501 | json_neigh, "updateSource", | |
10502 | sockunion2str(p->update_source, buf1, | |
10503 | SU_ADDRSTRLEN)); | |
10504 | } | |
10505 | } else { | |
10506 | /* advertisement-interval */ | |
10507 | vty_out(vty, | |
10508 | " Minimum time between advertisement runs is %d seconds\n", | |
10509 | p->v_routeadv); | |
10510 | ||
10511 | /* Update-source. */ | |
10512 | if (p->update_if || p->update_source) { | |
10513 | vty_out(vty, " Update source is "); | |
10514 | if (p->update_if) | |
10515 | vty_out(vty, "%s", p->update_if); | |
10516 | else if (p->update_source) | |
10517 | vty_out(vty, "%s", | |
10518 | sockunion2str(p->update_source, buf1, | |
10519 | SU_ADDRSTRLEN)); | |
10520 | vty_out(vty, "\n"); | |
10521 | } | |
10522 | ||
10523 | vty_out(vty, "\n"); | |
10524 | } | |
10525 | ||
10526 | /* Address Family Information */ | |
10527 | json_object *json_hold = NULL; | |
10528 | ||
10529 | if (use_json) | |
10530 | json_hold = json_object_new_object(); | |
10531 | ||
05c7a1cc QY |
10532 | FOREACH_AFI_SAFI (afi, safi) |
10533 | if (p->afc[afi][safi]) | |
10534 | bgp_show_peer_afi(vty, p, afi, safi, use_json, | |
10535 | json_hold); | |
d62a17ae | 10536 | |
10537 | if (use_json) { | |
10538 | json_object_object_add(json_neigh, "addressFamilyInfo", | |
10539 | json_hold); | |
10540 | json_object_int_add(json_neigh, "connectionsEstablished", | |
10541 | p->established); | |
10542 | json_object_int_add(json_neigh, "connectionsDropped", | |
10543 | p->dropped); | |
10544 | } else | |
10545 | vty_out(vty, " Connections established %d; dropped %d\n", | |
10546 | p->established, p->dropped); | |
10547 | ||
10548 | if (!p->last_reset) { | |
10549 | if (use_json) | |
10550 | json_object_string_add(json_neigh, "lastReset", | |
10551 | "never"); | |
10552 | else | |
10553 | vty_out(vty, " Last reset never\n"); | |
10554 | } else { | |
10555 | if (use_json) { | |
10556 | time_t uptime; | |
10557 | struct tm *tm; | |
10558 | ||
10559 | uptime = bgp_clock(); | |
10560 | uptime -= p->resettime; | |
10561 | tm = gmtime(&uptime); | |
10562 | json_object_int_add(json_neigh, "lastResetTimerMsecs", | |
10563 | (tm->tm_sec * 1000) | |
10564 | + (tm->tm_min * 60000) | |
10565 | + (tm->tm_hour * 3600000)); | |
10566 | json_object_string_add( | |
10567 | json_neigh, "lastResetDueTo", | |
10568 | peer_down_str[(int)p->last_reset]); | |
10569 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10570 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10571 | char errorcodesubcode_hexstr[5]; | |
10572 | char errorcodesubcode_str[256]; | |
10573 | ||
10574 | code_str = bgp_notify_code_str(p->notify.code); | |
10575 | subcode_str = bgp_notify_subcode_str( | |
10576 | p->notify.code, p->notify.subcode); | |
10577 | ||
10578 | sprintf(errorcodesubcode_hexstr, "%02X%02X", | |
10579 | p->notify.code, p->notify.subcode); | |
10580 | json_object_string_add(json_neigh, | |
10581 | "lastErrorCodeSubcode", | |
10582 | errorcodesubcode_hexstr); | |
10583 | snprintf(errorcodesubcode_str, 255, "%s%s", | |
10584 | code_str, subcode_str); | |
10585 | json_object_string_add(json_neigh, | |
10586 | "lastNotificationReason", | |
10587 | errorcodesubcode_str); | |
10588 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10589 | && p->notify.code == BGP_NOTIFY_CEASE | |
10590 | && (p->notify.subcode | |
10591 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10592 | || p->notify.subcode | |
10593 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10594 | && p->notify.length) { | |
10595 | char msgbuf[1024]; | |
10596 | const char *msg_str; | |
10597 | ||
10598 | msg_str = bgp_notify_admin_message( | |
10599 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10600 | (uint8_t *)p->notify.data, |
d62a17ae | 10601 | p->notify.length); |
10602 | if (msg_str) | |
10603 | json_object_string_add( | |
10604 | json_neigh, | |
10605 | "lastShutdownDescription", | |
10606 | msg_str); | |
10607 | } | |
10608 | } | |
10609 | } else { | |
10610 | vty_out(vty, " Last reset %s, ", | |
10611 | peer_uptime(p->resettime, timebuf, | |
10612 | BGP_UPTIME_LEN, 0, NULL)); | |
10613 | ||
10614 | if (p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10615 | || p->last_reset == PEER_DOWN_NOTIFY_RECEIVED) { | |
10616 | code_str = bgp_notify_code_str(p->notify.code); | |
10617 | subcode_str = bgp_notify_subcode_str( | |
10618 | p->notify.code, p->notify.subcode); | |
10619 | vty_out(vty, "due to NOTIFICATION %s (%s%s)\n", | |
10620 | p->last_reset == PEER_DOWN_NOTIFY_SEND | |
10621 | ? "sent" | |
10622 | : "received", | |
10623 | code_str, subcode_str); | |
10624 | if (p->last_reset == PEER_DOWN_NOTIFY_RECEIVED | |
10625 | && p->notify.code == BGP_NOTIFY_CEASE | |
10626 | && (p->notify.subcode | |
10627 | == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN | |
10628 | || p->notify.subcode | |
10629 | == BGP_NOTIFY_CEASE_ADMIN_RESET) | |
10630 | && p->notify.length) { | |
10631 | char msgbuf[1024]; | |
10632 | const char *msg_str; | |
10633 | ||
10634 | msg_str = bgp_notify_admin_message( | |
10635 | msgbuf, sizeof(msgbuf), | |
d7c0a89a | 10636 | (uint8_t *)p->notify.data, |
d62a17ae | 10637 | p->notify.length); |
10638 | if (msg_str) | |
10639 | vty_out(vty, | |
10640 | " Message: \"%s\"\n", | |
10641 | msg_str); | |
10642 | } | |
10643 | } else { | |
10644 | vty_out(vty, "due to %s\n", | |
10645 | peer_down_str[(int)p->last_reset]); | |
10646 | } | |
10647 | ||
10648 | if (p->last_reset_cause_size) { | |
10649 | msg = p->last_reset_cause; | |
10650 | vty_out(vty, | |
10651 | " Message received that caused BGP to send a NOTIFICATION:\n "); | |
10652 | for (i = 1; i <= p->last_reset_cause_size; | |
10653 | i++) { | |
10654 | vty_out(vty, "%02X", *msg++); | |
10655 | ||
10656 | if (i != p->last_reset_cause_size) { | |
10657 | if (i % 16 == 0) { | |
10658 | vty_out(vty, "\n "); | |
10659 | } else if (i % 4 == 0) { | |
10660 | vty_out(vty, " "); | |
10661 | } | |
10662 | } | |
10663 | } | |
10664 | vty_out(vty, "\n"); | |
10665 | } | |
10666 | } | |
10667 | } | |
10668 | ||
10669 | if (CHECK_FLAG(p->sflags, PEER_STATUS_PREFIX_OVERFLOW)) { | |
10670 | if (use_json) | |
10671 | json_object_boolean_true_add(json_neigh, | |
10672 | "prefixesConfigExceedMax"); | |
10673 | else | |
10674 | vty_out(vty, | |
10675 | " Peer had exceeded the max. no. of prefixes configured.\n"); | |
10676 | ||
10677 | if (p->t_pmax_restart) { | |
10678 | if (use_json) { | |
10679 | json_object_boolean_true_add( | |
10680 | json_neigh, "reducePrefixNumFrom"); | |
10681 | json_object_int_add(json_neigh, | |
10682 | "restartInTimerMsec", | |
10683 | thread_timer_remain_second( | |
10684 | p->t_pmax_restart) | |
10685 | * 1000); | |
10686 | } else | |
10687 | vty_out(vty, | |
10688 | " Reduce the no. of prefix from %s, will restart in %ld seconds\n", | |
996c9314 LB |
10689 | p->host, thread_timer_remain_second( |
10690 | p->t_pmax_restart)); | |
d62a17ae | 10691 | } else { |
10692 | if (use_json) | |
10693 | json_object_boolean_true_add( | |
10694 | json_neigh, | |
10695 | "reducePrefixNumAndClearIpBgp"); | |
10696 | else | |
10697 | vty_out(vty, | |
10698 | " Reduce the no. of prefix and clear ip bgp %s to restore peering\n", | |
10699 | p->host); | |
10700 | } | |
10701 | } | |
10702 | ||
10703 | /* EBGP Multihop and GTSM */ | |
10704 | if (p->sort != BGP_PEER_IBGP) { | |
10705 | if (use_json) { | |
10706 | if (p->gtsm_hops > 0) | |
10707 | json_object_int_add(json_neigh, | |
10708 | "externalBgpNbrMaxHopsAway", | |
10709 | p->gtsm_hops); | |
10710 | else if (p->ttl > 1) | |
10711 | json_object_int_add(json_neigh, | |
10712 | "externalBgpNbrMaxHopsAway", | |
10713 | p->ttl); | |
10714 | } else { | |
10715 | if (p->gtsm_hops > 0) | |
10716 | vty_out(vty, | |
10717 | " External BGP neighbor may be up to %d hops away.\n", | |
10718 | p->gtsm_hops); | |
10719 | else if (p->ttl > 1) | |
10720 | vty_out(vty, | |
10721 | " External BGP neighbor may be up to %d hops away.\n", | |
10722 | p->ttl); | |
10723 | } | |
10724 | } else { | |
10725 | if (p->gtsm_hops > 0) { | |
10726 | if (use_json) | |
10727 | json_object_int_add(json_neigh, | |
10728 | "internalBgpNbrMaxHopsAway", | |
10729 | p->gtsm_hops); | |
10730 | else | |
10731 | vty_out(vty, | |
10732 | " Internal BGP neighbor may be up to %d hops away.\n", | |
10733 | p->gtsm_hops); | |
10734 | } | |
10735 | } | |
10736 | ||
10737 | /* Local address. */ | |
10738 | if (p->su_local) { | |
10739 | if (use_json) { | |
10740 | json_object_string_add(json_neigh, "hostLocal", | |
10741 | sockunion2str(p->su_local, buf1, | |
10742 | SU_ADDRSTRLEN)); | |
10743 | json_object_int_add(json_neigh, "portLocal", | |
10744 | ntohs(p->su_local->sin.sin_port)); | |
10745 | } else | |
10746 | vty_out(vty, "Local host: %s, Local port: %d\n", | |
10747 | sockunion2str(p->su_local, buf1, SU_ADDRSTRLEN), | |
10748 | ntohs(p->su_local->sin.sin_port)); | |
10749 | } | |
10750 | ||
10751 | /* Remote address. */ | |
10752 | if (p->su_remote) { | |
10753 | if (use_json) { | |
10754 | json_object_string_add(json_neigh, "hostForeign", | |
10755 | sockunion2str(p->su_remote, buf1, | |
10756 | SU_ADDRSTRLEN)); | |
10757 | json_object_int_add(json_neigh, "portForeign", | |
10758 | ntohs(p->su_remote->sin.sin_port)); | |
10759 | } else | |
10760 | vty_out(vty, "Foreign host: %s, Foreign port: %d\n", | |
10761 | sockunion2str(p->su_remote, buf1, | |
10762 | SU_ADDRSTRLEN), | |
10763 | ntohs(p->su_remote->sin.sin_port)); | |
10764 | } | |
10765 | ||
10766 | /* Nexthop display. */ | |
10767 | if (p->su_local) { | |
10768 | if (use_json) { | |
10769 | json_object_string_add(json_neigh, "nexthop", | |
10770 | inet_ntop(AF_INET, | |
10771 | &p->nexthop.v4, buf1, | |
10772 | sizeof(buf1))); | |
10773 | json_object_string_add(json_neigh, "nexthopGlobal", | |
10774 | inet_ntop(AF_INET6, | |
10775 | &p->nexthop.v6_global, | |
10776 | buf1, sizeof(buf1))); | |
10777 | json_object_string_add(json_neigh, "nexthopLocal", | |
10778 | inet_ntop(AF_INET6, | |
10779 | &p->nexthop.v6_local, | |
10780 | buf1, sizeof(buf1))); | |
10781 | if (p->shared_network) | |
10782 | json_object_string_add(json_neigh, | |
10783 | "bgpConnection", | |
10784 | "sharedNetwork"); | |
10785 | else | |
10786 | json_object_string_add(json_neigh, | |
10787 | "bgpConnection", | |
10788 | "nonSharedNetwork"); | |
10789 | } else { | |
10790 | vty_out(vty, "Nexthop: %s\n", | |
10791 | inet_ntop(AF_INET, &p->nexthop.v4, buf1, | |
10792 | sizeof(buf1))); | |
10793 | vty_out(vty, "Nexthop global: %s\n", | |
10794 | inet_ntop(AF_INET6, &p->nexthop.v6_global, buf1, | |
10795 | sizeof(buf1))); | |
10796 | vty_out(vty, "Nexthop local: %s\n", | |
10797 | inet_ntop(AF_INET6, &p->nexthop.v6_local, buf1, | |
10798 | sizeof(buf1))); | |
10799 | vty_out(vty, "BGP connection: %s\n", | |
10800 | p->shared_network ? "shared network" | |
10801 | : "non shared network"); | |
10802 | } | |
10803 | } | |
10804 | ||
10805 | /* Timer information. */ | |
10806 | if (use_json) { | |
10807 | json_object_int_add(json_neigh, "connectRetryTimer", | |
10808 | p->v_connect); | |
10809 | if (p->status == Established && p->rtt) | |
10810 | json_object_int_add(json_neigh, "estimatedRttInMsecs", | |
10811 | p->rtt); | |
10812 | if (p->t_start) | |
10813 | json_object_int_add( | |
10814 | json_neigh, "nextStartTimerDueInMsecs", | |
10815 | thread_timer_remain_second(p->t_start) * 1000); | |
10816 | if (p->t_connect) | |
10817 | json_object_int_add( | |
10818 | json_neigh, "nextConnectTimerDueInMsecs", | |
10819 | thread_timer_remain_second(p->t_connect) | |
10820 | * 1000); | |
10821 | if (p->t_routeadv) { | |
10822 | json_object_int_add(json_neigh, "mraiInterval", | |
10823 | p->v_routeadv); | |
10824 | json_object_int_add( | |
10825 | json_neigh, "mraiTimerExpireInMsecs", | |
10826 | thread_timer_remain_second(p->t_routeadv) | |
10827 | * 1000); | |
10828 | } | |
10829 | if (p->password) | |
10830 | json_object_int_add(json_neigh, "authenticationEnabled", | |
10831 | 1); | |
10832 | ||
10833 | if (p->t_read) | |
10834 | json_object_string_add(json_neigh, "readThread", "on"); | |
10835 | else | |
10836 | json_object_string_add(json_neigh, "readThread", "off"); | |
49507a6f QY |
10837 | |
10838 | if (CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON)) | |
d62a17ae | 10839 | json_object_string_add(json_neigh, "writeThread", "on"); |
10840 | else | |
10841 | json_object_string_add(json_neigh, "writeThread", | |
10842 | "off"); | |
10843 | } else { | |
10844 | vty_out(vty, "BGP Connect Retry Timer in Seconds: %d\n", | |
10845 | p->v_connect); | |
10846 | if (p->status == Established && p->rtt) | |
10847 | vty_out(vty, "Estimated round trip time: %d ms\n", | |
10848 | p->rtt); | |
10849 | if (p->t_start) | |
10850 | vty_out(vty, "Next start timer due in %ld seconds\n", | |
10851 | thread_timer_remain_second(p->t_start)); | |
10852 | if (p->t_connect) | |
10853 | vty_out(vty, "Next connect timer due in %ld seconds\n", | |
10854 | thread_timer_remain_second(p->t_connect)); | |
10855 | if (p->t_routeadv) | |
10856 | vty_out(vty, | |
10857 | "MRAI (interval %u) timer expires in %ld seconds\n", | |
10858 | p->v_routeadv, | |
10859 | thread_timer_remain_second(p->t_routeadv)); | |
10860 | if (p->password) | |
10861 | vty_out(vty, "Peer Authentication Enabled\n"); | |
10862 | ||
cac9e917 | 10863 | vty_out(vty, "Read thread: %s Write thread: %s FD used: %d\n", |
49507a6f QY |
10864 | p->t_read ? "on" : "off", |
10865 | CHECK_FLAG(p->thread_flags, PEER_THREAD_WRITES_ON) | |
10866 | ? "on" | |
cac9e917 | 10867 | : "off", p->fd); |
d62a17ae | 10868 | } |
10869 | ||
10870 | if (p->notify.code == BGP_NOTIFY_OPEN_ERR | |
10871 | && p->notify.subcode == BGP_NOTIFY_OPEN_UNSUP_CAPBL) | |
10872 | bgp_capability_vty_out(vty, p, use_json, json_neigh); | |
10873 | ||
10874 | if (!use_json) | |
10875 | vty_out(vty, "\n"); | |
10876 | ||
10877 | /* BFD information. */ | |
10878 | bgp_bfd_show_info(vty, p, use_json, json_neigh); | |
10879 | ||
10880 | if (use_json) { | |
10881 | if (p->conf_if) /* Configured interface name. */ | |
10882 | json_object_object_add(json, p->conf_if, json_neigh); | |
10883 | else /* Configured IP address. */ | |
10884 | json_object_object_add(json, p->host, json_neigh); | |
10885 | } | |
10886 | } | |
10887 | ||
10888 | static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, | |
10889 | enum show_type type, union sockunion *su, | |
9f049418 | 10890 | const char *conf_if, bool use_json, |
d62a17ae | 10891 | json_object *json) |
10892 | { | |
10893 | struct listnode *node, *nnode; | |
10894 | struct peer *peer; | |
10895 | int find = 0; | |
9f049418 | 10896 | bool nbr_output = false; |
d1927ebe AS |
10897 | afi_t afi = AFI_MAX; |
10898 | safi_t safi = SAFI_MAX; | |
10899 | ||
10900 | if (type == show_ipv4_peer || type == show_ipv4_all) { | |
10901 | afi = AFI_IP; | |
10902 | } else if (type == show_ipv6_peer || type == show_ipv6_all) { | |
10903 | afi = AFI_IP6; | |
10904 | } | |
d62a17ae | 10905 | |
10906 | for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { | |
10907 | if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) | |
10908 | continue; | |
10909 | ||
10910 | switch (type) { | |
10911 | case show_all: | |
10912 | bgp_show_peer(vty, peer, use_json, json); | |
9f049418 | 10913 | nbr_output = true; |
d62a17ae | 10914 | break; |
10915 | case show_peer: | |
10916 | if (conf_if) { | |
10917 | if ((peer->conf_if | |
10918 | && !strcmp(peer->conf_if, conf_if)) | |
10919 | || (peer->hostname | |
10920 | && !strcmp(peer->hostname, conf_if))) { | |
10921 | find = 1; | |
10922 | bgp_show_peer(vty, peer, use_json, | |
10923 | json); | |
10924 | } | |
10925 | } else { | |
10926 | if (sockunion_same(&peer->su, su)) { | |
10927 | find = 1; | |
10928 | bgp_show_peer(vty, peer, use_json, | |
10929 | json); | |
10930 | } | |
10931 | } | |
10932 | break; | |
d1927ebe AS |
10933 | case show_ipv4_peer: |
10934 | case show_ipv6_peer: | |
10935 | FOREACH_SAFI (safi) { | |
10936 | if (peer->afc[afi][safi]) { | |
10937 | if (conf_if) { | |
10938 | if ((peer->conf_if | |
10939 | && !strcmp(peer->conf_if, conf_if)) | |
10940 | || (peer->hostname | |
10941 | && !strcmp(peer->hostname, conf_if))) { | |
10942 | find = 1; | |
10943 | bgp_show_peer(vty, peer, use_json, | |
10944 | json); | |
10945 | break; | |
10946 | } | |
10947 | } else { | |
10948 | if (sockunion_same(&peer->su, su)) { | |
10949 | find = 1; | |
10950 | bgp_show_peer(vty, peer, use_json, | |
10951 | json); | |
10952 | break; | |
10953 | } | |
10954 | } | |
10955 | } | |
10956 | } | |
10957 | break; | |
10958 | case show_ipv4_all: | |
10959 | case show_ipv6_all: | |
10960 | FOREACH_SAFI (safi) { | |
10961 | if (peer->afc[afi][safi]) { | |
10962 | bgp_show_peer(vty, peer, use_json, json); | |
10963 | nbr_output = true; | |
10964 | break; | |
10965 | } | |
10966 | } | |
10967 | break; | |
d62a17ae | 10968 | } |
10969 | } | |
10970 | ||
d1927ebe AS |
10971 | if ((type == show_peer || type == show_ipv4_peer || |
10972 | type == show_ipv6_peer) && !find) { | |
d62a17ae | 10973 | if (use_json) |
10974 | json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); | |
10975 | else | |
88b7d255 | 10976 | vty_out(vty, "%% No such neighbor in this view/vrf\n"); |
d62a17ae | 10977 | } |
10978 | ||
d1927ebe AS |
10979 | if (type != show_peer && type != show_ipv4_peer && |
10980 | type != show_ipv6_peer && !nbr_output && !use_json) | |
94d4c685 | 10981 | vty_out(vty, "%% No BGP neighbors found\n"); |
9f049418 | 10982 | |
d62a17ae | 10983 | if (use_json) { |
996c9314 LB |
10984 | vty_out(vty, "%s\n", json_object_to_json_string_ext( |
10985 | json, JSON_C_TO_STRING_PRETTY)); | |
d62a17ae | 10986 | } else { |
10987 | vty_out(vty, "\n"); | |
10988 | } | |
10989 | ||
10990 | return CMD_SUCCESS; | |
10991 | } | |
10992 | ||
10993 | static void bgp_show_all_instances_neighbors_vty(struct vty *vty, | |
71aedaa3 DS |
10994 | enum show_type type, |
10995 | const char *ip_str, | |
9f049418 | 10996 | bool use_json) |
d62a17ae | 10997 | { |
0291c246 MK |
10998 | struct listnode *node, *nnode; |
10999 | struct bgp *bgp; | |
71aedaa3 | 11000 | union sockunion su; |
0291c246 | 11001 | json_object *json = NULL; |
71aedaa3 | 11002 | int ret, is_first = 1; |
9f049418 | 11003 | bool nbr_output = false; |
d62a17ae | 11004 | |
11005 | if (use_json) | |
11006 | vty_out(vty, "{\n"); | |
11007 | ||
11008 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
9f049418 | 11009 | nbr_output = true; |
d62a17ae | 11010 | if (use_json) { |
11011 | if (!(json = json_object_new_object())) { | |
af4c2728 | 11012 | flog_err( |
e50f7cfd | 11013 | EC_BGP_JSON_MEM_ERROR, |
d62a17ae | 11014 | "Unable to allocate memory for JSON object"); |
11015 | vty_out(vty, | |
11016 | "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n"); | |
11017 | return; | |
11018 | } | |
11019 | ||
11020 | json_object_int_add(json, "vrfId", | |
11021 | (bgp->vrf_id == VRF_UNKNOWN) | |
a4d82a8a PZ |
11022 | ? -1 |
11023 | : (int64_t)bgp->vrf_id); | |
d62a17ae | 11024 | json_object_string_add( |
11025 | json, "vrfName", | |
11026 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11027 | ? VRF_DEFAULT_NAME |
d62a17ae | 11028 | : bgp->name); |
11029 | ||
11030 | if (!is_first) | |
11031 | vty_out(vty, ",\n"); | |
11032 | else | |
11033 | is_first = 0; | |
11034 | ||
11035 | vty_out(vty, "\"%s\":", | |
11036 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11037 | ? VRF_DEFAULT_NAME |
d62a17ae | 11038 | : bgp->name); |
11039 | } else { | |
11040 | vty_out(vty, "\nInstance %s:\n", | |
11041 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11042 | ? VRF_DEFAULT_NAME |
d62a17ae | 11043 | : bgp->name); |
11044 | } | |
71aedaa3 | 11045 | |
d1927ebe AS |
11046 | if (type == show_peer || type == show_ipv4_peer || |
11047 | type == show_ipv6_peer) { | |
71aedaa3 DS |
11048 | ret = str2sockunion(ip_str, &su); |
11049 | if (ret < 0) | |
11050 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
11051 | use_json, json); | |
11052 | else | |
11053 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
11054 | use_json, json); | |
11055 | } else { | |
d1927ebe | 11056 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, |
71aedaa3 DS |
11057 | use_json, json); |
11058 | } | |
b77004d6 | 11059 | json_object_free(json); |
d62a17ae | 11060 | } |
11061 | ||
01cbfd04 | 11062 | if (use_json) { |
d62a17ae | 11063 | vty_out(vty, "}\n"); |
01cbfd04 QY |
11064 | json_object_free(json); |
11065 | } | |
9f049418 DS |
11066 | else if (!nbr_output) |
11067 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11068 | } |
11069 | ||
11070 | static int bgp_show_neighbor_vty(struct vty *vty, const char *name, | |
11071 | enum show_type type, const char *ip_str, | |
9f049418 | 11072 | bool use_json) |
d62a17ae | 11073 | { |
11074 | int ret; | |
11075 | struct bgp *bgp; | |
11076 | union sockunion su; | |
11077 | json_object *json = NULL; | |
11078 | ||
11079 | if (name) { | |
11080 | if (strmatch(name, "all")) { | |
71aedaa3 DS |
11081 | bgp_show_all_instances_neighbors_vty(vty, type, ip_str, |
11082 | use_json); | |
d62a17ae | 11083 | return CMD_SUCCESS; |
11084 | } else { | |
11085 | bgp = bgp_lookup_by_name(name); | |
11086 | if (!bgp) { | |
11087 | if (use_json) { | |
11088 | json = json_object_new_object(); | |
d62a17ae | 11089 | vty_out(vty, "%s\n", |
11090 | json_object_to_json_string_ext( | |
11091 | json, | |
11092 | JSON_C_TO_STRING_PRETTY)); | |
11093 | json_object_free(json); | |
11094 | } else | |
11095 | vty_out(vty, | |
9f049418 | 11096 | "%% BGP instance not found\n"); |
d62a17ae | 11097 | |
11098 | return CMD_WARNING; | |
11099 | } | |
11100 | } | |
11101 | } else { | |
11102 | bgp = bgp_get_default(); | |
11103 | } | |
11104 | ||
11105 | if (bgp) { | |
11106 | json = json_object_new_object(); | |
11107 | if (ip_str) { | |
11108 | ret = str2sockunion(ip_str, &su); | |
11109 | if (ret < 0) | |
11110 | bgp_show_neighbor(vty, bgp, type, NULL, ip_str, | |
11111 | use_json, json); | |
11112 | else | |
11113 | bgp_show_neighbor(vty, bgp, type, &su, NULL, | |
11114 | use_json, json); | |
11115 | } else { | |
11116 | bgp_show_neighbor(vty, bgp, type, NULL, NULL, use_json, | |
11117 | json); | |
11118 | } | |
11119 | json_object_free(json); | |
ca61fd25 DS |
11120 | } else { |
11121 | if (use_json) | |
11122 | vty_out(vty, "{}\n"); | |
11123 | else | |
11124 | vty_out(vty, "%% BGP instance not found\n"); | |
d62a17ae | 11125 | } |
11126 | ||
11127 | return CMD_SUCCESS; | |
4fb25c53 DW |
11128 | } |
11129 | ||
716b2d8a | 11130 | /* "show [ip] bgp neighbors" commands. */ |
718e3744 | 11131 | DEFUN (show_ip_bgp_neighbors, |
11132 | show_ip_bgp_neighbors_cmd, | |
24345e82 | 11133 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]", |
718e3744 | 11134 | SHOW_STR |
11135 | IP_STR | |
11136 | BGP_STR | |
f2a8972b | 11137 | BGP_INSTANCE_HELP_STR |
8c3deaae QY |
11138 | "Address Family\n" |
11139 | "Address Family\n" | |
718e3744 | 11140 | "Detailed information on TCP and BGP neighbor connections\n" |
11141 | "Neighbor to display information about\n" | |
a80beece | 11142 | "Neighbor to display information about\n" |
91d37724 | 11143 | "Neighbor on BGP configured interface\n" |
9973d184 | 11144 | JSON_STR) |
718e3744 | 11145 | { |
d62a17ae | 11146 | char *vrf = NULL; |
11147 | char *sh_arg = NULL; | |
11148 | enum show_type sh_type; | |
d1927ebe | 11149 | afi_t afi = AFI_MAX; |
718e3744 | 11150 | |
9f049418 | 11151 | bool uj = use_json(argc, argv); |
718e3744 | 11152 | |
d62a17ae | 11153 | int idx = 0; |
718e3744 | 11154 | |
9a8bdf1c PG |
11155 | /* [<vrf> VIEWVRFNAME] */ |
11156 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11157 | vrf = argv[idx + 1]->arg; | |
11158 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11159 | vrf = NULL; | |
11160 | } else if (argv_find(argv, argc, "view", &idx)) | |
11161 | /* [<view> VIEWVRFNAME] */ | |
d62a17ae | 11162 | vrf = argv[idx + 1]->arg; |
718e3744 | 11163 | |
d62a17ae | 11164 | idx++; |
d1927ebe AS |
11165 | |
11166 | if (argv_find(argv, argc, "ipv4", &idx)) { | |
11167 | sh_type = show_ipv4_all; | |
11168 | afi = AFI_IP; | |
11169 | } else if (argv_find(argv, argc, "ipv6", &idx)) { | |
11170 | sh_type = show_ipv6_all; | |
11171 | afi = AFI_IP6; | |
11172 | } else { | |
11173 | sh_type = show_all; | |
11174 | } | |
11175 | ||
d62a17ae | 11176 | if (argv_find(argv, argc, "A.B.C.D", &idx) |
11177 | || argv_find(argv, argc, "X:X::X:X", &idx) | |
11178 | || argv_find(argv, argc, "WORD", &idx)) { | |
11179 | sh_type = show_peer; | |
11180 | sh_arg = argv[idx]->arg; | |
d1927ebe AS |
11181 | } |
11182 | ||
11183 | if (sh_type == show_peer && afi == AFI_IP) { | |
11184 | sh_type = show_ipv4_peer; | |
11185 | } else if (sh_type == show_peer && afi == AFI_IP6) { | |
11186 | sh_type = show_ipv6_peer; | |
11187 | } | |
856ca177 | 11188 | |
d62a17ae | 11189 | return bgp_show_neighbor_vty(vty, vrf, sh_type, sh_arg, uj); |
718e3744 | 11190 | } |
11191 | ||
716b2d8a | 11192 | /* Show BGP's AS paths internal data. There are both `show [ip] bgp |
718e3744 | 11193 | paths' and `show ip mbgp paths'. Those functions results are the |
11194 | same.*/ | |
f412b39a | 11195 | DEFUN (show_ip_bgp_paths, |
718e3744 | 11196 | show_ip_bgp_paths_cmd, |
46f296b4 | 11197 | "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", |
718e3744 | 11198 | SHOW_STR |
11199 | IP_STR | |
11200 | BGP_STR | |
46f296b4 | 11201 | BGP_SAFI_HELP_STR |
718e3744 | 11202 | "Path information\n") |
11203 | { | |
d62a17ae | 11204 | vty_out(vty, "Address Refcnt Path\n"); |
11205 | aspath_print_all_vty(vty); | |
11206 | return CMD_SUCCESS; | |
718e3744 | 11207 | } |
11208 | ||
718e3744 | 11209 | #include "hash.h" |
11210 | ||
e3b78da8 | 11211 | static void community_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 11212 | struct vty *vty) |
718e3744 | 11213 | { |
d62a17ae | 11214 | struct community *com; |
718e3744 | 11215 | |
e3b78da8 | 11216 | com = (struct community *)bucket->data; |
3f65c5b1 | 11217 | vty_out(vty, "[%p] (%ld) %s\n", (void *)com, com->refcnt, |
a69ea8ae | 11218 | community_str(com, false)); |
718e3744 | 11219 | } |
11220 | ||
11221 | /* Show BGP's community internal data. */ | |
f412b39a | 11222 | DEFUN (show_ip_bgp_community_info, |
718e3744 | 11223 | show_ip_bgp_community_info_cmd, |
bec37ba5 | 11224 | "show [ip] bgp community-info", |
718e3744 | 11225 | SHOW_STR |
11226 | IP_STR | |
11227 | BGP_STR | |
11228 | "List all bgp community information\n") | |
11229 | { | |
d62a17ae | 11230 | vty_out(vty, "Address Refcnt Community\n"); |
718e3744 | 11231 | |
d62a17ae | 11232 | hash_iterate(community_hash(), |
e3b78da8 | 11233 | (void (*)(struct hash_bucket *, |
d62a17ae | 11234 | void *))community_show_all_iterator, |
11235 | vty); | |
718e3744 | 11236 | |
d62a17ae | 11237 | return CMD_SUCCESS; |
718e3744 | 11238 | } |
11239 | ||
e3b78da8 | 11240 | static void lcommunity_show_all_iterator(struct hash_bucket *bucket, |
d62a17ae | 11241 | struct vty *vty) |
57d187bc | 11242 | { |
d62a17ae | 11243 | struct lcommunity *lcom; |
57d187bc | 11244 | |
e3b78da8 | 11245 | lcom = (struct lcommunity *)bucket->data; |
3f65c5b1 | 11246 | vty_out(vty, "[%p] (%ld) %s\n", (void *)lcom, lcom->refcnt, |
8d9b8ed9 | 11247 | lcommunity_str(lcom, false)); |
57d187bc JS |
11248 | } |
11249 | ||
11250 | /* Show BGP's community internal data. */ | |
11251 | DEFUN (show_ip_bgp_lcommunity_info, | |
11252 | show_ip_bgp_lcommunity_info_cmd, | |
11253 | "show ip bgp large-community-info", | |
11254 | SHOW_STR | |
11255 | IP_STR | |
11256 | BGP_STR | |
11257 | "List all bgp large-community information\n") | |
11258 | { | |
d62a17ae | 11259 | vty_out(vty, "Address Refcnt Large-community\n"); |
57d187bc | 11260 | |
d62a17ae | 11261 | hash_iterate(lcommunity_hash(), |
e3b78da8 | 11262 | (void (*)(struct hash_bucket *, |
d62a17ae | 11263 | void *))lcommunity_show_all_iterator, |
11264 | vty); | |
57d187bc | 11265 | |
d62a17ae | 11266 | return CMD_SUCCESS; |
57d187bc JS |
11267 | } |
11268 | ||
11269 | ||
f412b39a | 11270 | DEFUN (show_ip_bgp_attr_info, |
718e3744 | 11271 | show_ip_bgp_attr_info_cmd, |
bec37ba5 | 11272 | "show [ip] bgp attribute-info", |
718e3744 | 11273 | SHOW_STR |
11274 | IP_STR | |
11275 | BGP_STR | |
11276 | "List all bgp attribute information\n") | |
11277 | { | |
d62a17ae | 11278 | attr_show_all(vty); |
11279 | return CMD_SUCCESS; | |
718e3744 | 11280 | } |
6b0655a2 | 11281 | |
03915806 CS |
11282 | static int bgp_show_route_leak_vty(struct vty *vty, const char *name, |
11283 | afi_t afi, safi_t safi, | |
11284 | bool use_json, json_object *json) | |
53089bec | 11285 | { |
11286 | struct bgp *bgp; | |
11287 | struct listnode *node; | |
11288 | char *vname; | |
11289 | char buf1[INET6_ADDRSTRLEN]; | |
11290 | char *ecom_str; | |
11291 | vpn_policy_direction_t dir; | |
11292 | ||
03915806 | 11293 | if (json) { |
b46dfd20 DS |
11294 | json_object *json_import_vrfs = NULL; |
11295 | json_object *json_export_vrfs = NULL; | |
11296 | ||
b46dfd20 DS |
11297 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
11298 | ||
53089bec | 11299 | if (!bgp) { |
b46dfd20 DS |
11300 | vty_out(vty, "%s\n", |
11301 | json_object_to_json_string_ext( | |
11302 | json, | |
11303 | JSON_C_TO_STRING_PRETTY)); | |
11304 | json_object_free(json); | |
11305 | ||
53089bec | 11306 | return CMD_WARNING; |
11307 | } | |
b46dfd20 | 11308 | |
94d4c685 DS |
11309 | /* Provide context for the block */ |
11310 | json_object_string_add(json, "vrf", name ? name : "default"); | |
11311 | json_object_string_add(json, "afiSafi", | |
11312 | afi_safi_print(afi, safi)); | |
11313 | ||
b46dfd20 DS |
11314 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11315 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) { | |
11316 | json_object_string_add(json, "importFromVrfs", "none"); | |
11317 | json_object_string_add(json, "importRts", "none"); | |
11318 | } else { | |
6ce24e52 DS |
11319 | json_import_vrfs = json_object_new_array(); |
11320 | ||
b46dfd20 DS |
11321 | for (ALL_LIST_ELEMENTS_RO( |
11322 | bgp->vpn_policy[afi].import_vrf, | |
11323 | node, vname)) | |
11324 | json_object_array_add(json_import_vrfs, | |
11325 | json_object_new_string(vname)); | |
11326 | ||
11327 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
11328 | ecom_str = ecommunity_ecom2str( | |
11329 | bgp->vpn_policy[afi].rtlist[dir], | |
11330 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11331 | json_object_object_add(json, "importFromVrfs", | |
11332 | json_import_vrfs); | |
11333 | json_object_string_add(json, "importRts", ecom_str); | |
11334 | ||
11335 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11336 | } | |
11337 | ||
11338 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], | |
11339 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) { | |
11340 | json_object_string_add(json, "exportToVrfs", "none"); | |
11341 | json_object_string_add(json, "routeDistinguisher", | |
11342 | "none"); | |
11343 | json_object_string_add(json, "exportRts", "none"); | |
11344 | } else { | |
6ce24e52 DS |
11345 | json_export_vrfs = json_object_new_array(); |
11346 | ||
b46dfd20 DS |
11347 | for (ALL_LIST_ELEMENTS_RO( |
11348 | bgp->vpn_policy[afi].export_vrf, | |
11349 | node, vname)) | |
11350 | json_object_array_add(json_export_vrfs, | |
11351 | json_object_new_string(vname)); | |
11352 | json_object_object_add(json, "exportToVrfs", | |
11353 | json_export_vrfs); | |
11354 | json_object_string_add(json, "routeDistinguisher", | |
11355 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11356 | buf1, RD_ADDRSTRLEN)); | |
11357 | ||
11358 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
11359 | ecom_str = ecommunity_ecom2str( | |
11360 | bgp->vpn_policy[afi].rtlist[dir], | |
11361 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11362 | json_object_string_add(json, "exportRts", ecom_str); | |
11363 | ||
11364 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
11365 | } | |
11366 | ||
03915806 CS |
11367 | if (use_json) { |
11368 | vty_out(vty, "%s\n", | |
11369 | json_object_to_json_string_ext(json, | |
b46dfd20 | 11370 | JSON_C_TO_STRING_PRETTY)); |
03915806 CS |
11371 | json_object_free(json); |
11372 | } | |
53089bec | 11373 | } else { |
b46dfd20 DS |
11374 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); |
11375 | ||
53089bec | 11376 | if (!bgp) { |
b46dfd20 | 11377 | vty_out(vty, "%% No such BGP instance exist\n"); |
53089bec | 11378 | return CMD_WARNING; |
11379 | } | |
53089bec | 11380 | |
b46dfd20 DS |
11381 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11382 | BGP_CONFIG_VRF_TO_VRF_IMPORT)) | |
11383 | vty_out(vty, | |
11384 | "This VRF is not importing %s routes from any other VRF\n", | |
11385 | afi_safi_print(afi, safi)); | |
11386 | else { | |
11387 | vty_out(vty, | |
11388 | "This VRF is importing %s routes from the following VRFs:\n", | |
11389 | afi_safi_print(afi, safi)); | |
11390 | ||
11391 | for (ALL_LIST_ELEMENTS_RO( | |
11392 | bgp->vpn_policy[afi].import_vrf, | |
11393 | node, vname)) | |
11394 | vty_out(vty, " %s\n", vname); | |
11395 | ||
11396 | dir = BGP_VPN_POLICY_DIR_FROMVPN; | |
11397 | ecom_str = ecommunity_ecom2str( | |
11398 | bgp->vpn_policy[afi].rtlist[dir], | |
11399 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11400 | vty_out(vty, "Import RT(s): %s\n", ecom_str); | |
11401 | ||
11402 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); | |
53089bec | 11403 | } |
53089bec | 11404 | |
b46dfd20 DS |
11405 | if (!CHECK_FLAG(bgp->af_flags[afi][safi], |
11406 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
11407 | vty_out(vty, | |
11408 | "This VRF is not exporting %s routes to any other VRF\n", | |
53089bec | 11409 | afi_safi_print(afi, safi)); |
b46dfd20 DS |
11410 | else { |
11411 | vty_out(vty, | |
04c9077f | 11412 | "This VRF is exporting %s routes to the following VRFs:\n", |
53089bec | 11413 | afi_safi_print(afi, safi)); |
b46dfd20 DS |
11414 | |
11415 | for (ALL_LIST_ELEMENTS_RO( | |
11416 | bgp->vpn_policy[afi].export_vrf, | |
11417 | node, vname)) | |
11418 | vty_out(vty, " %s\n", vname); | |
11419 | ||
11420 | vty_out(vty, "RD: %s\n", | |
11421 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, | |
11422 | buf1, RD_ADDRSTRLEN)); | |
11423 | ||
11424 | dir = BGP_VPN_POLICY_DIR_TOVPN; | |
11425 | ecom_str = ecommunity_ecom2str( | |
11426 | bgp->vpn_policy[afi].rtlist[dir], | |
11427 | ECOMMUNITY_FORMAT_ROUTE_MAP, 0); | |
11428 | vty_out(vty, "Export RT: %s\n", ecom_str); | |
04c9077f | 11429 | XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); |
53089bec | 11430 | } |
53089bec | 11431 | } |
11432 | ||
11433 | return CMD_SUCCESS; | |
11434 | } | |
11435 | ||
03915806 CS |
11436 | static int bgp_show_all_instance_route_leak_vty(struct vty *vty, afi_t afi, |
11437 | safi_t safi, bool use_json) | |
11438 | { | |
11439 | struct listnode *node, *nnode; | |
11440 | struct bgp *bgp; | |
11441 | char *vrf_name = NULL; | |
11442 | json_object *json = NULL; | |
11443 | json_object *json_vrf = NULL; | |
11444 | json_object *json_vrfs = NULL; | |
11445 | ||
11446 | if (use_json) { | |
11447 | json = json_object_new_object(); | |
11448 | json_vrfs = json_object_new_object(); | |
11449 | } | |
11450 | ||
11451 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { | |
11452 | ||
11453 | if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) | |
11454 | vrf_name = bgp->name; | |
11455 | ||
11456 | if (use_json) { | |
11457 | json_vrf = json_object_new_object(); | |
11458 | } else { | |
11459 | vty_out(vty, "\nInstance %s:\n", | |
11460 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
11461 | ? VRF_DEFAULT_NAME : bgp->name); | |
11462 | } | |
11463 | bgp_show_route_leak_vty(vty, vrf_name, afi, safi, 0, json_vrf); | |
11464 | if (use_json) { | |
11465 | if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
11466 | json_object_object_add(json_vrfs, | |
11467 | VRF_DEFAULT_NAME, json_vrf); | |
11468 | else | |
11469 | json_object_object_add(json_vrfs, vrf_name, | |
11470 | json_vrf); | |
11471 | } | |
11472 | } | |
11473 | ||
11474 | if (use_json) { | |
11475 | json_object_object_add(json, "vrfs", json_vrfs); | |
11476 | vty_out(vty, "%s\n", json_object_to_json_string_ext(json, | |
11477 | JSON_C_TO_STRING_PRETTY)); | |
11478 | json_object_free(json); | |
11479 | } | |
11480 | ||
11481 | return CMD_SUCCESS; | |
11482 | } | |
11483 | ||
53089bec | 11484 | /* "show [ip] bgp route-leak" command. */ |
11485 | DEFUN (show_ip_bgp_route_leak, | |
04c9077f DS |
11486 | show_ip_bgp_route_leak_cmd, |
11487 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] route-leak [json]", | |
b46dfd20 DS |
11488 | SHOW_STR |
11489 | IP_STR | |
11490 | BGP_STR | |
11491 | BGP_INSTANCE_HELP_STR | |
11492 | BGP_AFI_HELP_STR | |
11493 | BGP_SAFI_HELP_STR | |
11494 | "Route leaking information\n" | |
11495 | JSON_STR) | |
53089bec | 11496 | { |
11497 | char *vrf = NULL; | |
11498 | afi_t afi = AFI_MAX; | |
11499 | safi_t safi = SAFI_MAX; | |
11500 | ||
9f049418 | 11501 | bool uj = use_json(argc, argv); |
53089bec | 11502 | int idx = 0; |
03915806 | 11503 | json_object *json = NULL; |
53089bec | 11504 | |
11505 | /* show [ip] bgp */ | |
11506 | if (argv_find(argv, argc, "ip", &idx)) { | |
11507 | afi = AFI_IP; | |
11508 | safi = SAFI_UNICAST; | |
11509 | } | |
11510 | /* [vrf VIEWVRFNAME] */ | |
11511 | if (argv_find(argv, argc, "view", &idx)) { | |
020a3f60 DS |
11512 | vty_out(vty, |
11513 | "%% This command is not applicable to BGP views\n"); | |
53089bec | 11514 | return CMD_WARNING; |
11515 | } | |
11516 | ||
9a8bdf1c PG |
11517 | if (argv_find(argv, argc, "vrf", &idx)) { |
11518 | vrf = argv[idx + 1]->arg; | |
11519 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11520 | vrf = NULL; | |
11521 | } | |
53089bec | 11522 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11523 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11524 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11525 | } | |
11526 | ||
11527 | if (!((afi == AFI_IP || afi == AFI_IP6) && safi == SAFI_UNICAST)) { | |
020a3f60 DS |
11528 | vty_out(vty, |
11529 | "%% This command is applicable only for unicast ipv4|ipv6\n"); | |
53089bec | 11530 | return CMD_WARNING; |
11531 | } | |
11532 | ||
03915806 CS |
11533 | if (vrf && strmatch(vrf, "all")) |
11534 | return bgp_show_all_instance_route_leak_vty(vty, afi, safi, uj); | |
11535 | ||
11536 | if (uj) | |
11537 | json = json_object_new_object(); | |
11538 | ||
11539 | return bgp_show_route_leak_vty(vty, vrf, afi, safi, uj, json); | |
53089bec | 11540 | } |
11541 | ||
d62a17ae | 11542 | static void bgp_show_all_instances_updgrps_vty(struct vty *vty, afi_t afi, |
11543 | safi_t safi) | |
f186de26 | 11544 | { |
d62a17ae | 11545 | struct listnode *node, *nnode; |
11546 | struct bgp *bgp; | |
f186de26 | 11547 | |
d62a17ae | 11548 | for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp)) { |
11549 | vty_out(vty, "\nInstance %s:\n", | |
11550 | (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) | |
5742e42b | 11551 | ? VRF_DEFAULT_NAME |
d62a17ae | 11552 | : bgp->name); |
11553 | update_group_show(bgp, afi, safi, vty, 0); | |
11554 | } | |
f186de26 | 11555 | } |
11556 | ||
d62a17ae | 11557 | static int bgp_show_update_groups(struct vty *vty, const char *name, int afi, |
11558 | int safi, uint64_t subgrp_id) | |
4fb25c53 | 11559 | { |
d62a17ae | 11560 | struct bgp *bgp; |
4fb25c53 | 11561 | |
d62a17ae | 11562 | if (name) { |
11563 | if (strmatch(name, "all")) { | |
11564 | bgp_show_all_instances_updgrps_vty(vty, afi, safi); | |
11565 | return CMD_SUCCESS; | |
11566 | } else { | |
11567 | bgp = bgp_lookup_by_name(name); | |
11568 | } | |
11569 | } else { | |
11570 | bgp = bgp_get_default(); | |
11571 | } | |
4fb25c53 | 11572 | |
d62a17ae | 11573 | if (bgp) |
11574 | update_group_show(bgp, afi, safi, vty, subgrp_id); | |
11575 | return CMD_SUCCESS; | |
4fb25c53 DW |
11576 | } |
11577 | ||
8fe8a7f6 DS |
11578 | DEFUN (show_ip_bgp_updgrps, |
11579 | show_ip_bgp_updgrps_cmd, | |
c1a44e43 | 11580 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]] update-groups [SUBGROUP-ID]", |
8386ac43 | 11581 | SHOW_STR |
11582 | IP_STR | |
11583 | BGP_STR | |
11584 | BGP_INSTANCE_HELP_STR | |
c9e571b4 | 11585 | BGP_AFI_HELP_STR |
9bedbb1e | 11586 | BGP_SAFI_WITH_LABEL_HELP_STR |
5bf15956 DW |
11587 | "Detailed info about dynamic update groups\n" |
11588 | "Specific subgroup to display detailed info for\n") | |
8386ac43 | 11589 | { |
d62a17ae | 11590 | char *vrf = NULL; |
11591 | afi_t afi = AFI_IP6; | |
11592 | safi_t safi = SAFI_UNICAST; | |
11593 | uint64_t subgrp_id = 0; | |
11594 | ||
11595 | int idx = 0; | |
11596 | ||
11597 | /* show [ip] bgp */ | |
11598 | if (argv_find(argv, argc, "ip", &idx)) | |
11599 | afi = AFI_IP; | |
9a8bdf1c PG |
11600 | /* [<vrf> VIEWVRFNAME] */ |
11601 | if (argv_find(argv, argc, "vrf", &idx)) { | |
11602 | vrf = argv[idx + 1]->arg; | |
11603 | if (vrf && strmatch(vrf, VRF_DEFAULT_NAME)) | |
11604 | vrf = NULL; | |
11605 | } else if (argv_find(argv, argc, "view", &idx)) | |
11606 | /* [<view> VIEWVRFNAME] */ | |
11607 | vrf = argv[idx + 1]->arg; | |
d62a17ae | 11608 | /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ |
11609 | if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { | |
11610 | argv_find_and_parse_safi(argv, argc, &idx, &safi); | |
11611 | } | |
5bf15956 | 11612 | |
d62a17ae | 11613 | /* get subgroup id, if provided */ |
11614 | idx = argc - 1; | |
11615 | if (argv[idx]->type == VARIABLE_TKN) | |
11616 | subgrp_id = strtoull(argv[idx]->arg, NULL, 10); | |
5bf15956 | 11617 | |
d62a17ae | 11618 | return (bgp_show_update_groups(vty, vrf, afi, safi, subgrp_id)); |
8fe8a7f6 DS |
11619 | } |
11620 | ||
f186de26 | 11621 | DEFUN (show_bgp_instance_all_ipv6_updgrps, |
11622 | show_bgp_instance_all_ipv6_updgrps_cmd, | |
716b2d8a | 11623 | "show [ip] bgp <view|vrf> all update-groups", |
f186de26 | 11624 | SHOW_STR |
716b2d8a | 11625 | IP_STR |
f186de26 | 11626 | BGP_STR |
11627 | BGP_INSTANCE_ALL_HELP_STR | |
0c7b1b01 | 11628 | "Detailed info about dynamic update groups\n") |
f186de26 | 11629 | { |
d62a17ae | 11630 | bgp_show_all_instances_updgrps_vty(vty, AFI_IP6, SAFI_UNICAST); |
11631 | return CMD_SUCCESS; | |
f186de26 | 11632 | } |
11633 | ||
43d3f4fc DS |
11634 | DEFUN (show_bgp_l2vpn_evpn_updgrps, |
11635 | show_bgp_l2vpn_evpn_updgrps_cmd, | |
11636 | "show [ip] bgp l2vpn evpn update-groups", | |
11637 | SHOW_STR | |
11638 | IP_STR | |
11639 | BGP_STR | |
11640 | "l2vpn address family\n" | |
11641 | "evpn sub-address family\n" | |
11642 | "Detailed info about dynamic update groups\n") | |
11643 | { | |
11644 | char *vrf = NULL; | |
11645 | uint64_t subgrp_id = 0; | |
11646 | ||
11647 | bgp_show_update_groups(vty, vrf, AFI_L2VPN, SAFI_EVPN, subgrp_id); | |
11648 | return CMD_SUCCESS; | |
11649 | } | |
11650 | ||
5bf15956 DW |
11651 | DEFUN (show_bgp_updgrps_stats, |
11652 | show_bgp_updgrps_stats_cmd, | |
716b2d8a | 11653 | "show [ip] bgp update-groups statistics", |
3f9c7369 | 11654 | SHOW_STR |
716b2d8a | 11655 | IP_STR |
3f9c7369 | 11656 | BGP_STR |
0c7b1b01 | 11657 | "Detailed info about dynamic update groups\n" |
3f9c7369 DS |
11658 | "Statistics\n") |
11659 | { | |
d62a17ae | 11660 | struct bgp *bgp; |
3f9c7369 | 11661 | |
d62a17ae | 11662 | bgp = bgp_get_default(); |
11663 | if (bgp) | |
11664 | update_group_show_stats(bgp, vty); | |
3f9c7369 | 11665 | |
d62a17ae | 11666 | return CMD_SUCCESS; |
3f9c7369 DS |
11667 | } |
11668 | ||
8386ac43 | 11669 | DEFUN (show_bgp_instance_updgrps_stats, |
11670 | show_bgp_instance_updgrps_stats_cmd, | |
18c57037 | 11671 | "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics", |
8386ac43 | 11672 | SHOW_STR |
716b2d8a | 11673 | IP_STR |
8386ac43 | 11674 | BGP_STR |
11675 | BGP_INSTANCE_HELP_STR | |
0c7b1b01 | 11676 | "Detailed info about dynamic update groups\n" |
8386ac43 | 11677 | "Statistics\n") |
11678 | { | |
d62a17ae | 11679 | int idx_word = 3; |
11680 | struct bgp *bgp; | |
8386ac43 | 11681 | |
d62a17ae | 11682 | bgp = bgp_lookup_by_name(argv[idx_word]->arg); |
11683 | if (bgp) | |
11684 | update_group_show_stats(bgp, vty); | |
8386ac43 | 11685 | |
d62a17ae | 11686 | return CMD_SUCCESS; |
8386ac43 | 11687 | } |
11688 | ||
d62a17ae | 11689 | static void show_bgp_updgrps_adj_info_aux(struct vty *vty, const char *name, |
11690 | afi_t afi, safi_t safi, | |
11691 | const char *what, uint64_t subgrp_id) | |
3f9c7369 | 11692 | { |
d62a17ae | 11693 | struct bgp *bgp; |
8386ac43 | 11694 | |
d62a17ae | 11695 | if (name) |
11696 | bgp = bgp_lookup_by_name(name); | |
11697 | else | |
11698 | bgp = bgp_get_default(); | |
8386ac43 | 11699 | |
d62a17ae | 11700 | if (bgp) { |
11701 | if (!strcmp(what, "advertise-queue")) | |
11702 | update_group_show_adj_queue(bgp, afi, safi, vty, | |
11703 | subgrp_id); | |
11704 | else if (!strcmp(what, "advertised-routes")) | |
11705 | update_group_show_advertised(bgp, afi, safi, vty, | |
11706 | subgrp_id); | |
11707 | else if (!strcmp(what, "packet-queue")) | |
11708 | update_group_show_packet_queue(bgp, afi, safi, vty, | |
11709 | subgrp_id); | |
11710 | } | |
3f9c7369 DS |
11711 | } |
11712 | ||
dc64bdec QY |
11713 | DEFPY(show_ip_bgp_instance_updgrps_adj_s, |
11714 | show_ip_bgp_instance_updgrps_adj_s_cmd, | |
11715 | "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", | |
11716 | SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR | |
11717 | BGP_SAFI_HELP_STR | |
11718 | "Detailed info about dynamic update groups\n" | |
11719 | "Specific subgroup to display info for\n" | |
11720 | "Advertisement queue\n" | |
11721 | "Announced routes\n" | |
11722 | "Packet queue\n") | |
3f9c7369 | 11723 | { |
dc64bdec QY |
11724 | uint64_t subgrp_id = 0; |
11725 | afi_t afiz; | |
11726 | safi_t safiz; | |
11727 | if (sgid) | |
11728 | subgrp_id = strtoull(sgid, NULL, 10); | |
11729 | ||
11730 | if (!ip && !afi) | |
11731 | afiz = AFI_IP6; | |
11732 | if (!ip && afi) | |
11733 | afiz = bgp_vty_afi_from_str(afi); | |
11734 | if (ip && !afi) | |
11735 | afiz = AFI_IP; | |
11736 | if (ip && afi) { | |
11737 | afiz = bgp_vty_afi_from_str(afi); | |
11738 | if (afiz != AFI_IP) | |
11739 | vty_out(vty, | |
11740 | "%% Cannot specify both 'ip' and 'ipv6'\n"); | |
11741 | return CMD_WARNING; | |
11742 | } | |
d62a17ae | 11743 | |
dc64bdec | 11744 | safiz = safi ? bgp_vty_safi_from_str(safi) : SAFI_UNICAST; |
d62a17ae | 11745 | |
dc64bdec | 11746 | show_bgp_updgrps_adj_info_aux(vty, vrf, afiz, safiz, rtq, subgrp_id); |
d62a17ae | 11747 | return CMD_SUCCESS; |
11748 | } | |
11749 | ||
d62a17ae | 11750 | static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group) |
11751 | { | |
11752 | struct listnode *node, *nnode; | |
11753 | struct prefix *range; | |
11754 | struct peer *conf; | |
11755 | struct peer *peer; | |
11756 | char buf[PREFIX2STR_BUFFER]; | |
11757 | afi_t afi; | |
11758 | safi_t safi; | |
11759 | const char *peer_status; | |
11760 | const char *af_str; | |
11761 | int lr_count; | |
11762 | int dynamic; | |
11763 | int af_cfgd; | |
11764 | ||
11765 | conf = group->conf; | |
11766 | ||
11767 | if (conf->as_type == AS_SPECIFIED || conf->as_type == AS_EXTERNAL) { | |
3b61f610 QY |
11768 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
11769 | group->name, conf->as); | |
d62a17ae | 11770 | } else if (conf->as_type == AS_INTERNAL) { |
3b61f610 QY |
11771 | vty_out(vty, "\nBGP peer-group %s, remote AS %" PRIu32 "\n", |
11772 | group->name, group->bgp->as); | |
d62a17ae | 11773 | } else { |
11774 | vty_out(vty, "\nBGP peer-group %s\n", group->name); | |
11775 | } | |
f14e6fdb | 11776 | |
d62a17ae | 11777 | if ((group->bgp->as == conf->as) || (conf->as_type == AS_INTERNAL)) |
11778 | vty_out(vty, " Peer-group type is internal\n"); | |
11779 | else | |
11780 | vty_out(vty, " Peer-group type is external\n"); | |
11781 | ||
11782 | /* Display AFs configured. */ | |
11783 | vty_out(vty, " Configured address-families:"); | |
05c7a1cc QY |
11784 | FOREACH_AFI_SAFI (afi, safi) { |
11785 | if (conf->afc[afi][safi]) { | |
11786 | af_cfgd = 1; | |
11787 | vty_out(vty, " %s;", afi_safi_print(afi, safi)); | |
d62a17ae | 11788 | } |
05c7a1cc | 11789 | } |
d62a17ae | 11790 | if (!af_cfgd) |
11791 | vty_out(vty, " none\n"); | |
11792 | else | |
11793 | vty_out(vty, "\n"); | |
11794 | ||
11795 | /* Display listen ranges (for dynamic neighbors), if any */ | |
11796 | for (afi = AFI_IP; afi < AFI_MAX; afi++) { | |
11797 | if (afi == AFI_IP) | |
11798 | af_str = "IPv4"; | |
11799 | else if (afi == AFI_IP6) | |
11800 | af_str = "IPv6"; | |
11801 | else | |
11802 | af_str = "???"; | |
11803 | lr_count = listcount(group->listen_range[afi]); | |
11804 | if (lr_count) { | |
11805 | vty_out(vty, " %d %s listen range(s)\n", lr_count, | |
11806 | af_str); | |
11807 | ||
11808 | ||
11809 | for (ALL_LIST_ELEMENTS(group->listen_range[afi], node, | |
11810 | nnode, range)) { | |
11811 | prefix2str(range, buf, sizeof(buf)); | |
11812 | vty_out(vty, " %s\n", buf); | |
11813 | } | |
11814 | } | |
11815 | } | |
f14e6fdb | 11816 | |
d62a17ae | 11817 | /* Display group members and their status */ |
11818 | if (listcount(group->peer)) { | |
11819 | vty_out(vty, " Peer-group members:\n"); | |
11820 | for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) { | |
11821 | if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN)) | |
11822 | peer_status = "Idle (Admin)"; | |
11823 | else if (CHECK_FLAG(peer->sflags, | |
11824 | PEER_STATUS_PREFIX_OVERFLOW)) | |
11825 | peer_status = "Idle (PfxCt)"; | |
11826 | else | |
11827 | peer_status = lookup_msg(bgp_status_msg, | |
11828 | peer->status, NULL); | |
11829 | ||
11830 | dynamic = peer_dynamic_neighbor(peer); | |
11831 | vty_out(vty, " %s %s %s \n", peer->host, | |
11832 | dynamic ? "(dynamic)" : "", peer_status); | |
11833 | } | |
11834 | } | |
f14e6fdb | 11835 | |
d62a17ae | 11836 | return CMD_SUCCESS; |
11837 | } | |
11838 | ||
ff9959b0 QY |
11839 | static int bgp_show_peer_group_vty(struct vty *vty, const char *name, |
11840 | const char *group_name) | |
d62a17ae | 11841 | { |
ff9959b0 | 11842 | struct bgp *bgp; |
d62a17ae | 11843 | struct listnode *node, *nnode; |
11844 | struct peer_group *group; | |
ff9959b0 QY |
11845 | bool found = false; |
11846 | ||
11847 | bgp = name ? bgp_lookup_by_name(name) : bgp_get_default(); | |
11848 | ||
11849 | if (!bgp) { | |
9f049418 | 11850 | vty_out(vty, "%% BGP instance not found\n"); |
ff9959b0 QY |
11851 | return CMD_WARNING; |
11852 | } | |
d62a17ae | 11853 | |
11854 | for (ALL_LIST_ELEMENTS(bgp->group, node, nnode, group)) { | |
ff9959b0 QY |
11855 | if (group_name) { |
11856 | if (strmatch(group->name, group_name)) { | |
d62a17ae | 11857 | bgp_show_one_peer_group(vty, group); |
ff9959b0 QY |
11858 | found = true; |
11859 | break; | |
d62a17ae | 11860 | } |
ff9959b0 QY |
11861 | } else { |
11862 | bgp_show_one_peer_group(vty, group); | |
d62a17ae | 11863 | } |
f14e6fdb | 11864 | } |
f14e6fdb | 11865 | |
ff9959b0 | 11866 | if (group_name && !found) |
d62a17ae | 11867 | vty_out(vty, "%% No such peer-group\n"); |
f14e6fdb | 11868 | |
d62a17ae | 11869 | return CMD_SUCCESS; |
f14e6fdb DS |
11870 | } |
11871 | ||
f14e6fdb DS |
11872 | DEFUN (show_ip_bgp_peer_groups, |
11873 | show_ip_bgp_peer_groups_cmd, | |
18c57037 | 11874 | "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]", |
f14e6fdb DS |
11875 | SHOW_STR |
11876 | IP_STR | |
11877 | BGP_STR | |
8386ac43 | 11878 | BGP_INSTANCE_HELP_STR |
d6e3c605 QY |
11879 | "Detailed information on BGP peer groups\n" |
11880 | "Peer group name\n") | |
f14e6fdb | 11881 | { |
d62a17ae | 11882 | char *vrf, *pg; |
d62a17ae | 11883 | int idx = 0; |
f14e6fdb | 11884 | |
a4d82a8a PZ |
11885 | vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg |
11886 | : NULL; | |
d62a17ae | 11887 | pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; |
f14e6fdb | 11888 | |
ff9959b0 | 11889 | return bgp_show_peer_group_vty(vty, vrf, pg); |
f14e6fdb | 11890 | } |
3f9c7369 | 11891 | |
d6e3c605 | 11892 | |
718e3744 | 11893 | /* Redistribute VTY commands. */ |
11894 | ||
718e3744 | 11895 | DEFUN (bgp_redistribute_ipv4, |
11896 | bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 11897 | "redistribute " FRR_IP_REDIST_STR_BGPD, |
718e3744 | 11898 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11899 | FRR_IP_REDIST_HELP_STR_BGPD) |
718e3744 | 11900 | { |
d62a17ae | 11901 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11902 | int idx_protocol = 1; | |
11903 | int type; | |
718e3744 | 11904 | |
d62a17ae | 11905 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
11906 | if (type < 0) { | |
11907 | vty_out(vty, "%% Invalid route type\n"); | |
11908 | return CMD_WARNING_CONFIG_FAILED; | |
11909 | } | |
7f323236 | 11910 | |
d62a17ae | 11911 | bgp_redist_add(bgp, AFI_IP, type, 0); |
e923dd62 | 11912 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, false); |
718e3744 | 11913 | } |
11914 | ||
d62a17ae | 11915 | ALIAS_HIDDEN( |
11916 | bgp_redistribute_ipv4, bgp_redistribute_ipv4_hidden_cmd, | |
11917 | "redistribute " FRR_IP_REDIST_STR_BGPD, | |
11918 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD) | |
596c17ba | 11919 | |
718e3744 | 11920 | DEFUN (bgp_redistribute_ipv4_rmap, |
11921 | bgp_redistribute_ipv4_rmap_cmd, | |
40d1cbfb | 11922 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 11923 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11924 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11925 | "Route map reference\n" |
11926 | "Pointer to route-map entries\n") | |
11927 | { | |
d62a17ae | 11928 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11929 | int idx_protocol = 1; | |
11930 | int idx_word = 3; | |
11931 | int type; | |
11932 | struct bgp_redist *red; | |
e923dd62 | 11933 | bool changed; |
1de27621 DA |
11934 | struct route_map *route_map = route_map_lookup_warn_noexist( |
11935 | vty, argv[idx_word]->arg); | |
718e3744 | 11936 | |
d62a17ae | 11937 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); |
11938 | if (type < 0) { | |
11939 | vty_out(vty, "%% Invalid route type\n"); | |
11940 | return CMD_WARNING_CONFIG_FAILED; | |
11941 | } | |
718e3744 | 11942 | |
d62a17ae | 11943 | red = bgp_redist_add(bgp, AFI_IP, type, 0); |
1de27621 DA |
11944 | changed = |
11945 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 11946 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
718e3744 | 11947 | } |
11948 | ||
d62a17ae | 11949 | ALIAS_HIDDEN( |
11950 | bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_hidden_cmd, | |
11951 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", | |
11952 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11953 | "Route map reference\n" | |
11954 | "Pointer to route-map entries\n") | |
596c17ba | 11955 | |
718e3744 | 11956 | DEFUN (bgp_redistribute_ipv4_metric, |
11957 | bgp_redistribute_ipv4_metric_cmd, | |
40d1cbfb | 11958 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 11959 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11960 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11961 | "Metric for redistributed routes\n" |
11962 | "Default metric\n") | |
11963 | { | |
d62a17ae | 11964 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
11965 | int idx_protocol = 1; | |
11966 | int idx_number = 3; | |
11967 | int type; | |
d7c0a89a | 11968 | uint32_t metric; |
d62a17ae | 11969 | struct bgp_redist *red; |
e923dd62 | 11970 | bool changed; |
d62a17ae | 11971 | |
11972 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
11973 | if (type < 0) { | |
11974 | vty_out(vty, "%% Invalid route type\n"); | |
11975 | return CMD_WARNING_CONFIG_FAILED; | |
11976 | } | |
11977 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
11978 | ||
11979 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 11980 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
11981 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 11982 | } |
11983 | ||
11984 | ALIAS_HIDDEN( | |
11985 | bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_hidden_cmd, | |
11986 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295)", | |
11987 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
11988 | "Metric for redistributed routes\n" | |
11989 | "Default metric\n") | |
596c17ba | 11990 | |
718e3744 | 11991 | DEFUN (bgp_redistribute_ipv4_rmap_metric, |
11992 | bgp_redistribute_ipv4_rmap_metric_cmd, | |
40d1cbfb | 11993 | "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 11994 | "Redistribute information from another routing protocol\n" |
ab0181ee | 11995 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 11996 | "Route map reference\n" |
11997 | "Pointer to route-map entries\n" | |
11998 | "Metric for redistributed routes\n" | |
11999 | "Default metric\n") | |
12000 | { | |
d62a17ae | 12001 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12002 | int idx_protocol = 1; | |
12003 | int idx_word = 3; | |
12004 | int idx_number = 5; | |
12005 | int type; | |
d7c0a89a | 12006 | uint32_t metric; |
d62a17ae | 12007 | struct bgp_redist *red; |
e923dd62 | 12008 | bool changed; |
1de27621 DA |
12009 | struct route_map *route_map = |
12010 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12011 | |
12012 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12013 | if (type < 0) { | |
12014 | vty_out(vty, "%% Invalid route type\n"); | |
12015 | return CMD_WARNING_CONFIG_FAILED; | |
12016 | } | |
12017 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
12018 | ||
12019 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
1de27621 DA |
12020 | changed = |
12021 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12022 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
12023 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); | |
d62a17ae | 12024 | } |
12025 | ||
12026 | ALIAS_HIDDEN( | |
12027 | bgp_redistribute_ipv4_rmap_metric, | |
12028 | bgp_redistribute_ipv4_rmap_metric_hidden_cmd, | |
12029 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
12030 | " route-map WORD metric (0-4294967295)", | |
12031 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12032 | "Route map reference\n" | |
12033 | "Pointer to route-map entries\n" | |
12034 | "Metric for redistributed routes\n" | |
12035 | "Default metric\n") | |
596c17ba | 12036 | |
718e3744 | 12037 | DEFUN (bgp_redistribute_ipv4_metric_rmap, |
12038 | bgp_redistribute_ipv4_metric_rmap_cmd, | |
40d1cbfb | 12039 | "redistribute " FRR_IP_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 12040 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12041 | FRR_IP_REDIST_HELP_STR_BGPD |
718e3744 | 12042 | "Metric for redistributed routes\n" |
12043 | "Default metric\n" | |
12044 | "Route map reference\n" | |
12045 | "Pointer to route-map entries\n") | |
12046 | { | |
d62a17ae | 12047 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12048 | int idx_protocol = 1; | |
12049 | int idx_number = 3; | |
12050 | int idx_word = 5; | |
12051 | int type; | |
d7c0a89a | 12052 | uint32_t metric; |
d62a17ae | 12053 | struct bgp_redist *red; |
e923dd62 | 12054 | bool changed; |
1de27621 DA |
12055 | struct route_map *route_map = |
12056 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12057 | |
12058 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12059 | if (type < 0) { | |
12060 | vty_out(vty, "%% Invalid route type\n"); | |
12061 | return CMD_WARNING_CONFIG_FAILED; | |
12062 | } | |
12063 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
12064 | ||
12065 | red = bgp_redist_add(bgp, AFI_IP, type, 0); | |
e923dd62 | 12066 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, type, metric); |
1de27621 DA |
12067 | changed |= |
12068 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12069 | return bgp_redistribute_set(bgp, AFI_IP, type, 0, changed); |
d62a17ae | 12070 | } |
12071 | ||
12072 | ALIAS_HIDDEN( | |
12073 | bgp_redistribute_ipv4_metric_rmap, | |
12074 | bgp_redistribute_ipv4_metric_rmap_hidden_cmd, | |
12075 | "redistribute " FRR_IP_REDIST_STR_BGPD | |
12076 | " metric (0-4294967295) route-map WORD", | |
12077 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12078 | "Metric for redistributed routes\n" | |
12079 | "Default metric\n" | |
12080 | "Route map reference\n" | |
12081 | "Pointer to route-map entries\n") | |
596c17ba | 12082 | |
7c8ff89e DS |
12083 | DEFUN (bgp_redistribute_ipv4_ospf, |
12084 | bgp_redistribute_ipv4_ospf_cmd, | |
6147e2c6 | 12085 | "redistribute <ospf|table> (1-65535)", |
7c8ff89e DS |
12086 | "Redistribute information from another routing protocol\n" |
12087 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12088 | "Non-main Kernel Routing Table\n" |
12089 | "Instance ID/Table ID\n") | |
7c8ff89e | 12090 | { |
d62a17ae | 12091 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12092 | int idx_ospf_table = 1; | |
12093 | int idx_number = 2; | |
d7c0a89a QY |
12094 | unsigned short instance; |
12095 | unsigned short protocol; | |
7c8ff89e | 12096 | |
d62a17ae | 12097 | instance = strtoul(argv[idx_number]->arg, NULL, 10); |
7a4bb9c5 | 12098 | |
d62a17ae | 12099 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) |
12100 | protocol = ZEBRA_ROUTE_OSPF; | |
12101 | else | |
12102 | protocol = ZEBRA_ROUTE_TABLE; | |
7a4bb9c5 | 12103 | |
d62a17ae | 12104 | bgp_redist_add(bgp, AFI_IP, protocol, instance); |
e923dd62 | 12105 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, false); |
7c8ff89e DS |
12106 | } |
12107 | ||
d62a17ae | 12108 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf, bgp_redistribute_ipv4_ospf_hidden_cmd, |
12109 | "redistribute <ospf|table> (1-65535)", | |
12110 | "Redistribute information from another routing protocol\n" | |
12111 | "Open Shortest Path First (OSPFv2)\n" | |
12112 | "Non-main Kernel Routing Table\n" | |
12113 | "Instance ID/Table ID\n") | |
596c17ba | 12114 | |
7c8ff89e DS |
12115 | DEFUN (bgp_redistribute_ipv4_ospf_rmap, |
12116 | bgp_redistribute_ipv4_ospf_rmap_cmd, | |
6147e2c6 | 12117 | "redistribute <ospf|table> (1-65535) route-map WORD", |
7c8ff89e DS |
12118 | "Redistribute information from another routing protocol\n" |
12119 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12120 | "Non-main Kernel Routing Table\n" |
12121 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12122 | "Route map reference\n" |
12123 | "Pointer to route-map entries\n") | |
12124 | { | |
d62a17ae | 12125 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12126 | int idx_ospf_table = 1; | |
12127 | int idx_number = 2; | |
12128 | int idx_word = 4; | |
12129 | struct bgp_redist *red; | |
d7c0a89a | 12130 | unsigned short instance; |
d62a17ae | 12131 | int protocol; |
e923dd62 | 12132 | bool changed; |
1de27621 DA |
12133 | struct route_map *route_map = |
12134 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12135 | |
12136 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12137 | protocol = ZEBRA_ROUTE_OSPF; | |
12138 | else | |
12139 | protocol = ZEBRA_ROUTE_TABLE; | |
12140 | ||
12141 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12142 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
12143 | changed = |
12144 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12145 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 12146 | } |
12147 | ||
12148 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap, | |
12149 | bgp_redistribute_ipv4_ospf_rmap_hidden_cmd, | |
12150 | "redistribute <ospf|table> (1-65535) route-map WORD", | |
12151 | "Redistribute information from another routing protocol\n" | |
12152 | "Open Shortest Path First (OSPFv2)\n" | |
12153 | "Non-main Kernel Routing Table\n" | |
12154 | "Instance ID/Table ID\n" | |
12155 | "Route map reference\n" | |
12156 | "Pointer to route-map entries\n") | |
596c17ba | 12157 | |
7c8ff89e DS |
12158 | DEFUN (bgp_redistribute_ipv4_ospf_metric, |
12159 | bgp_redistribute_ipv4_ospf_metric_cmd, | |
6147e2c6 | 12160 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", |
7c8ff89e DS |
12161 | "Redistribute information from another routing protocol\n" |
12162 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12163 | "Non-main Kernel Routing Table\n" |
12164 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12165 | "Metric for redistributed routes\n" |
12166 | "Default metric\n") | |
12167 | { | |
d62a17ae | 12168 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12169 | int idx_ospf_table = 1; | |
12170 | int idx_number = 2; | |
12171 | int idx_number_2 = 4; | |
d7c0a89a | 12172 | uint32_t metric; |
d62a17ae | 12173 | struct bgp_redist *red; |
d7c0a89a | 12174 | unsigned short instance; |
d62a17ae | 12175 | int protocol; |
e923dd62 | 12176 | bool changed; |
d62a17ae | 12177 | |
12178 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12179 | protocol = ZEBRA_ROUTE_OSPF; | |
12180 | else | |
12181 | protocol = ZEBRA_ROUTE_TABLE; | |
12182 | ||
12183 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12184 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12185 | ||
12186 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 12187 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12188 | metric); | |
12189 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 12190 | } |
12191 | ||
12192 | ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric, | |
12193 | bgp_redistribute_ipv4_ospf_metric_hidden_cmd, | |
12194 | "redistribute <ospf|table> (1-65535) metric (0-4294967295)", | |
12195 | "Redistribute information from another routing protocol\n" | |
12196 | "Open Shortest Path First (OSPFv2)\n" | |
12197 | "Non-main Kernel Routing Table\n" | |
12198 | "Instance ID/Table ID\n" | |
12199 | "Metric for redistributed routes\n" | |
12200 | "Default metric\n") | |
596c17ba | 12201 | |
7c8ff89e DS |
12202 | DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric, |
12203 | bgp_redistribute_ipv4_ospf_rmap_metric_cmd, | |
6147e2c6 | 12204 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", |
7c8ff89e DS |
12205 | "Redistribute information from another routing protocol\n" |
12206 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12207 | "Non-main Kernel Routing Table\n" |
12208 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12209 | "Route map reference\n" |
12210 | "Pointer to route-map entries\n" | |
12211 | "Metric for redistributed routes\n" | |
12212 | "Default metric\n") | |
12213 | { | |
d62a17ae | 12214 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12215 | int idx_ospf_table = 1; | |
12216 | int idx_number = 2; | |
12217 | int idx_word = 4; | |
12218 | int idx_number_2 = 6; | |
d7c0a89a | 12219 | uint32_t metric; |
d62a17ae | 12220 | struct bgp_redist *red; |
d7c0a89a | 12221 | unsigned short instance; |
d62a17ae | 12222 | int protocol; |
e923dd62 | 12223 | bool changed; |
1de27621 DA |
12224 | struct route_map *route_map = |
12225 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12226 | |
12227 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12228 | protocol = ZEBRA_ROUTE_OSPF; | |
12229 | else | |
12230 | protocol = ZEBRA_ROUTE_TABLE; | |
12231 | ||
12232 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12233 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12234 | ||
12235 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
1de27621 DA |
12236 | changed = |
12237 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12238 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12239 | metric); | |
12240 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); | |
d62a17ae | 12241 | } |
12242 | ||
12243 | ALIAS_HIDDEN( | |
12244 | bgp_redistribute_ipv4_ospf_rmap_metric, | |
12245 | bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd, | |
12246 | "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)", | |
12247 | "Redistribute information from another routing protocol\n" | |
12248 | "Open Shortest Path First (OSPFv2)\n" | |
12249 | "Non-main Kernel Routing Table\n" | |
12250 | "Instance ID/Table ID\n" | |
12251 | "Route map reference\n" | |
12252 | "Pointer to route-map entries\n" | |
12253 | "Metric for redistributed routes\n" | |
12254 | "Default metric\n") | |
596c17ba | 12255 | |
7c8ff89e DS |
12256 | DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap, |
12257 | bgp_redistribute_ipv4_ospf_metric_rmap_cmd, | |
6147e2c6 | 12258 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", |
7c8ff89e DS |
12259 | "Redistribute information from another routing protocol\n" |
12260 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 DS |
12261 | "Non-main Kernel Routing Table\n" |
12262 | "Instance ID/Table ID\n" | |
7c8ff89e DS |
12263 | "Metric for redistributed routes\n" |
12264 | "Default metric\n" | |
12265 | "Route map reference\n" | |
12266 | "Pointer to route-map entries\n") | |
12267 | { | |
d62a17ae | 12268 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12269 | int idx_ospf_table = 1; | |
12270 | int idx_number = 2; | |
12271 | int idx_number_2 = 4; | |
12272 | int idx_word = 6; | |
d7c0a89a | 12273 | uint32_t metric; |
d62a17ae | 12274 | struct bgp_redist *red; |
d7c0a89a | 12275 | unsigned short instance; |
d62a17ae | 12276 | int protocol; |
e923dd62 | 12277 | bool changed; |
1de27621 DA |
12278 | struct route_map *route_map = |
12279 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12280 | |
12281 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12282 | protocol = ZEBRA_ROUTE_OSPF; | |
12283 | else | |
12284 | protocol = ZEBRA_ROUTE_TABLE; | |
12285 | ||
12286 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12287 | metric = strtoul(argv[idx_number_2]->arg, NULL, 10); | |
12288 | ||
12289 | red = bgp_redist_add(bgp, AFI_IP, protocol, instance); | |
e923dd62 | 12290 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP, protocol, |
12291 | metric); | |
1de27621 DA |
12292 | changed |= |
12293 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12294 | return bgp_redistribute_set(bgp, AFI_IP, protocol, instance, changed); |
d62a17ae | 12295 | } |
12296 | ||
12297 | ALIAS_HIDDEN( | |
12298 | bgp_redistribute_ipv4_ospf_metric_rmap, | |
12299 | bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd, | |
12300 | "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD", | |
12301 | "Redistribute information from another routing protocol\n" | |
12302 | "Open Shortest Path First (OSPFv2)\n" | |
12303 | "Non-main Kernel Routing Table\n" | |
12304 | "Instance ID/Table ID\n" | |
12305 | "Metric for redistributed routes\n" | |
12306 | "Default metric\n" | |
12307 | "Route map reference\n" | |
12308 | "Pointer to route-map entries\n") | |
596c17ba | 12309 | |
7c8ff89e DS |
12310 | DEFUN (no_bgp_redistribute_ipv4_ospf, |
12311 | no_bgp_redistribute_ipv4_ospf_cmd, | |
d04c479d | 12312 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", |
7c8ff89e DS |
12313 | NO_STR |
12314 | "Redistribute information from another routing protocol\n" | |
12315 | "Open Shortest Path First (OSPFv2)\n" | |
2d627ff5 | 12316 | "Non-main Kernel Routing Table\n" |
31500417 DW |
12317 | "Instance ID/Table ID\n" |
12318 | "Metric for redistributed routes\n" | |
12319 | "Default metric\n" | |
12320 | "Route map reference\n" | |
12321 | "Pointer to route-map entries\n") | |
7c8ff89e | 12322 | { |
d62a17ae | 12323 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12324 | int idx_ospf_table = 2; | |
12325 | int idx_number = 3; | |
d7c0a89a | 12326 | unsigned short instance; |
d62a17ae | 12327 | int protocol; |
12328 | ||
12329 | if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) | |
12330 | protocol = ZEBRA_ROUTE_OSPF; | |
12331 | else | |
12332 | protocol = ZEBRA_ROUTE_TABLE; | |
12333 | ||
12334 | instance = strtoul(argv[idx_number]->arg, NULL, 10); | |
12335 | return bgp_redistribute_unset(bgp, AFI_IP, protocol, instance); | |
12336 | } | |
12337 | ||
12338 | ALIAS_HIDDEN( | |
12339 | no_bgp_redistribute_ipv4_ospf, no_bgp_redistribute_ipv4_ospf_hidden_cmd, | |
12340 | "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]", | |
12341 | NO_STR | |
12342 | "Redistribute information from another routing protocol\n" | |
12343 | "Open Shortest Path First (OSPFv2)\n" | |
12344 | "Non-main Kernel Routing Table\n" | |
12345 | "Instance ID/Table ID\n" | |
12346 | "Metric for redistributed routes\n" | |
12347 | "Default metric\n" | |
12348 | "Route map reference\n" | |
12349 | "Pointer to route-map entries\n") | |
596c17ba | 12350 | |
718e3744 | 12351 | DEFUN (no_bgp_redistribute_ipv4, |
12352 | no_bgp_redistribute_ipv4_cmd, | |
40d1cbfb | 12353 | "no redistribute " FRR_IP_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 12354 | NO_STR |
12355 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12356 | FRR_IP_REDIST_HELP_STR_BGPD |
31500417 DW |
12357 | "Metric for redistributed routes\n" |
12358 | "Default metric\n" | |
12359 | "Route map reference\n" | |
12360 | "Pointer to route-map entries\n") | |
718e3744 | 12361 | { |
d62a17ae | 12362 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12363 | int idx_protocol = 2; | |
12364 | int type; | |
12365 | ||
12366 | type = proto_redistnum(AFI_IP, argv[idx_protocol]->text); | |
12367 | if (type < 0) { | |
12368 | vty_out(vty, "%% Invalid route type\n"); | |
12369 | return CMD_WARNING_CONFIG_FAILED; | |
12370 | } | |
12371 | return bgp_redistribute_unset(bgp, AFI_IP, type, 0); | |
12372 | } | |
12373 | ||
12374 | ALIAS_HIDDEN( | |
12375 | no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_hidden_cmd, | |
12376 | "no redistribute " FRR_IP_REDIST_STR_BGPD | |
12377 | " [metric (0-4294967295)] [route-map WORD]", | |
12378 | NO_STR | |
12379 | "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD | |
12380 | "Metric for redistributed routes\n" | |
12381 | "Default metric\n" | |
12382 | "Route map reference\n" | |
12383 | "Pointer to route-map entries\n") | |
596c17ba | 12384 | |
718e3744 | 12385 | DEFUN (bgp_redistribute_ipv6, |
12386 | bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 12387 | "redistribute " FRR_IP6_REDIST_STR_BGPD, |
718e3744 | 12388 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12389 | FRR_IP6_REDIST_HELP_STR_BGPD) |
718e3744 | 12390 | { |
d62a17ae | 12391 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12392 | int idx_protocol = 1; | |
12393 | int type; | |
718e3744 | 12394 | |
d62a17ae | 12395 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12396 | if (type < 0) { | |
12397 | vty_out(vty, "%% Invalid route type\n"); | |
12398 | return CMD_WARNING_CONFIG_FAILED; | |
12399 | } | |
718e3744 | 12400 | |
d62a17ae | 12401 | bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12402 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, false); |
718e3744 | 12403 | } |
12404 | ||
12405 | DEFUN (bgp_redistribute_ipv6_rmap, | |
12406 | bgp_redistribute_ipv6_rmap_cmd, | |
40d1cbfb | 12407 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", |
718e3744 | 12408 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12409 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12410 | "Route map reference\n" |
12411 | "Pointer to route-map entries\n") | |
12412 | { | |
d62a17ae | 12413 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12414 | int idx_protocol = 1; | |
12415 | int idx_word = 3; | |
12416 | int type; | |
12417 | struct bgp_redist *red; | |
e923dd62 | 12418 | bool changed; |
1de27621 DA |
12419 | struct route_map *route_map = |
12420 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
718e3744 | 12421 | |
d62a17ae | 12422 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12423 | if (type < 0) { | |
12424 | vty_out(vty, "%% Invalid route type\n"); | |
12425 | return CMD_WARNING_CONFIG_FAILED; | |
12426 | } | |
718e3744 | 12427 | |
d62a17ae | 12428 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
12429 | changed = |
12430 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12431 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 12432 | } |
12433 | ||
12434 | DEFUN (bgp_redistribute_ipv6_metric, | |
12435 | bgp_redistribute_ipv6_metric_cmd, | |
40d1cbfb | 12436 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295)", |
718e3744 | 12437 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12438 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12439 | "Metric for redistributed routes\n" |
12440 | "Default metric\n") | |
12441 | { | |
d62a17ae | 12442 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12443 | int idx_protocol = 1; | |
12444 | int idx_number = 3; | |
12445 | int type; | |
d7c0a89a | 12446 | uint32_t metric; |
d62a17ae | 12447 | struct bgp_redist *red; |
e923dd62 | 12448 | bool changed; |
d62a17ae | 12449 | |
12450 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12451 | if (type < 0) { | |
12452 | vty_out(vty, "%% Invalid route type\n"); | |
12453 | return CMD_WARNING_CONFIG_FAILED; | |
12454 | } | |
12455 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12456 | |
d62a17ae | 12457 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12458 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, metric); |
12459 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12460 | } |
12461 | ||
12462 | DEFUN (bgp_redistribute_ipv6_rmap_metric, | |
12463 | bgp_redistribute_ipv6_rmap_metric_cmd, | |
40d1cbfb | 12464 | "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric (0-4294967295)", |
718e3744 | 12465 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12466 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12467 | "Route map reference\n" |
12468 | "Pointer to route-map entries\n" | |
12469 | "Metric for redistributed routes\n" | |
12470 | "Default metric\n") | |
12471 | { | |
d62a17ae | 12472 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12473 | int idx_protocol = 1; | |
12474 | int idx_word = 3; | |
12475 | int idx_number = 5; | |
12476 | int type; | |
d7c0a89a | 12477 | uint32_t metric; |
d62a17ae | 12478 | struct bgp_redist *red; |
e923dd62 | 12479 | bool changed; |
1de27621 DA |
12480 | struct route_map *route_map = |
12481 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12482 | |
12483 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12484 | if (type < 0) { | |
12485 | vty_out(vty, "%% Invalid route type\n"); | |
12486 | return CMD_WARNING_CONFIG_FAILED; | |
12487 | } | |
12488 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12489 | |
d62a17ae | 12490 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
1de27621 DA |
12491 | changed = |
12492 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12493 | changed |= bgp_redistribute_metric_set(bgp, red, AFI_IP6, type, |
12494 | metric); | |
12495 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); | |
718e3744 | 12496 | } |
12497 | ||
12498 | DEFUN (bgp_redistribute_ipv6_metric_rmap, | |
12499 | bgp_redistribute_ipv6_metric_rmap_cmd, | |
40d1cbfb | 12500 | "redistribute " FRR_IP6_REDIST_STR_BGPD " metric (0-4294967295) route-map WORD", |
718e3744 | 12501 | "Redistribute information from another routing protocol\n" |
ab0181ee | 12502 | FRR_IP6_REDIST_HELP_STR_BGPD |
718e3744 | 12503 | "Metric for redistributed routes\n" |
12504 | "Default metric\n" | |
12505 | "Route map reference\n" | |
12506 | "Pointer to route-map entries\n") | |
12507 | { | |
d62a17ae | 12508 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12509 | int idx_protocol = 1; | |
12510 | int idx_number = 3; | |
12511 | int idx_word = 5; | |
12512 | int type; | |
d7c0a89a | 12513 | uint32_t metric; |
d62a17ae | 12514 | struct bgp_redist *red; |
e923dd62 | 12515 | bool changed; |
1de27621 DA |
12516 | struct route_map *route_map = |
12517 | route_map_lookup_warn_noexist(vty, argv[idx_word]->arg); | |
d62a17ae | 12518 | |
12519 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); | |
12520 | if (type < 0) { | |
12521 | vty_out(vty, "%% Invalid route type\n"); | |
12522 | return CMD_WARNING_CONFIG_FAILED; | |
12523 | } | |
12524 | metric = strtoul(argv[idx_number]->arg, NULL, 10); | |
718e3744 | 12525 | |
d62a17ae | 12526 | red = bgp_redist_add(bgp, AFI_IP6, type, 0); |
e923dd62 | 12527 | changed = bgp_redistribute_metric_set(bgp, red, AFI_IP6, SAFI_UNICAST, |
12528 | metric); | |
1de27621 DA |
12529 | changed |= |
12530 | bgp_redistribute_rmap_set(red, argv[idx_word]->arg, route_map); | |
e923dd62 | 12531 | return bgp_redistribute_set(bgp, AFI_IP6, type, 0, changed); |
718e3744 | 12532 | } |
12533 | ||
12534 | DEFUN (no_bgp_redistribute_ipv6, | |
12535 | no_bgp_redistribute_ipv6_cmd, | |
40d1cbfb | 12536 | "no redistribute " FRR_IP6_REDIST_STR_BGPD " [metric (0-4294967295)] [route-map WORD]", |
718e3744 | 12537 | NO_STR |
12538 | "Redistribute information from another routing protocol\n" | |
3b14d86e | 12539 | FRR_IP6_REDIST_HELP_STR_BGPD |
31500417 DW |
12540 | "Metric for redistributed routes\n" |
12541 | "Default metric\n" | |
12542 | "Route map reference\n" | |
12543 | "Pointer to route-map entries\n") | |
718e3744 | 12544 | { |
d62a17ae | 12545 | VTY_DECLVAR_CONTEXT(bgp, bgp); |
12546 | int idx_protocol = 2; | |
12547 | int type; | |
718e3744 | 12548 | |
d62a17ae | 12549 | type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); |
12550 | if (type < 0) { | |
12551 | vty_out(vty, "%% Invalid route type\n"); | |
12552 | return CMD_WARNING_CONFIG_FAILED; | |
12553 | } | |
718e3744 | 12554 | |
d62a17ae | 12555 | return bgp_redistribute_unset(bgp, AFI_IP6, type, 0); |
12556 | } | |
12557 | ||
2b791107 | 12558 | void bgp_config_write_redistribute(struct vty *vty, struct bgp *bgp, afi_t afi, |
60466a63 | 12559 | safi_t safi) |
d62a17ae | 12560 | { |
12561 | int i; | |
12562 | ||
12563 | /* Unicast redistribution only. */ | |
12564 | if (safi != SAFI_UNICAST) | |
2b791107 | 12565 | return; |
d62a17ae | 12566 | |
12567 | for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { | |
12568 | /* Redistribute BGP does not make sense. */ | |
12569 | if (i != ZEBRA_ROUTE_BGP) { | |
12570 | struct list *red_list; | |
12571 | struct listnode *node; | |
12572 | struct bgp_redist *red; | |
12573 | ||
12574 | red_list = bgp->redist[afi][i]; | |
12575 | if (!red_list) | |
12576 | continue; | |
12577 | ||
12578 | for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { | |
d62a17ae | 12579 | /* "redistribute" configuration. */ |
12580 | vty_out(vty, " redistribute %s", | |
12581 | zebra_route_string(i)); | |
12582 | if (red->instance) | |
12583 | vty_out(vty, " %d", red->instance); | |
12584 | if (red->redist_metric_flag) | |
12585 | vty_out(vty, " metric %u", | |
12586 | red->redist_metric); | |
12587 | if (red->rmap.name) | |
12588 | vty_out(vty, " route-map %s", | |
12589 | red->rmap.name); | |
12590 | vty_out(vty, "\n"); | |
12591 | } | |
12592 | } | |
12593 | } | |
718e3744 | 12594 | } |
6b0655a2 | 12595 | |
b9c7bc5a PZ |
12596 | /* This is part of the address-family block (unicast only) */ |
12597 | void bgp_vpn_policy_config_write_afi(struct vty *vty, struct bgp *bgp, | |
ddb5b488 PZ |
12598 | afi_t afi) |
12599 | { | |
b9c7bc5a | 12600 | int indent = 2; |
ddb5b488 | 12601 | |
8a066a70 PG |
12602 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]) { |
12603 | if (listcount(bgp->vpn_policy[afi].import_vrf)) | |
12604 | vty_out(vty, "%*simport vrf route-map %s\n", indent, "", | |
12605 | bgp->vpn_policy[afi] | |
bb4f6190 | 12606 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); |
8a066a70 PG |
12607 | else |
12608 | vty_out(vty, "%*sroute-map vpn import %s\n", indent, "", | |
12609 | bgp->vpn_policy[afi] | |
12610 | .rmap_name[BGP_VPN_POLICY_DIR_FROMVPN]); | |
12611 | } | |
12a844a5 DS |
12612 | if (CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], |
12613 | BGP_CONFIG_VRF_TO_VRF_IMPORT) | |
12614 | || CHECK_FLAG(bgp->af_flags[afi][SAFI_UNICAST], | |
12615 | BGP_CONFIG_VRF_TO_VRF_EXPORT)) | |
12616 | return; | |
12617 | ||
e70e9f8e PZ |
12618 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, |
12619 | BGP_VPN_POLICY_TOVPN_LABEL_AUTO)) { | |
12620 | ||
12621 | vty_out(vty, "%*slabel vpn export %s\n", indent, "", "auto"); | |
12622 | ||
12623 | } else { | |
12624 | if (bgp->vpn_policy[afi].tovpn_label != MPLS_LABEL_NONE) { | |
12625 | vty_out(vty, "%*slabel vpn export %u\n", indent, "", | |
12626 | bgp->vpn_policy[afi].tovpn_label); | |
12627 | } | |
ddb5b488 PZ |
12628 | } |
12629 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12630 | BGP_VPN_POLICY_TOVPN_RD_SET)) { | |
12631 | char buf[RD_ADDRSTRLEN]; | |
b9c7bc5a | 12632 | vty_out(vty, "%*srd vpn export %s\n", indent, "", |
ddb5b488 PZ |
12633 | prefix_rd2str(&bgp->vpn_policy[afi].tovpn_rd, buf, |
12634 | sizeof(buf))); | |
12635 | } | |
12636 | if (CHECK_FLAG(bgp->vpn_policy[afi].flags, | |
12637 | BGP_VPN_POLICY_TOVPN_NEXTHOP_SET)) { | |
12638 | ||
12639 | char buf[PREFIX_STRLEN]; | |
12640 | if (inet_ntop(bgp->vpn_policy[afi].tovpn_nexthop.family, | |
12641 | &bgp->vpn_policy[afi].tovpn_nexthop.u.prefix, buf, | |
12642 | sizeof(buf))) { | |
12643 | ||
b9c7bc5a PZ |
12644 | vty_out(vty, "%*snexthop vpn export %s\n", |
12645 | indent, "", buf); | |
ddb5b488 PZ |
12646 | } |
12647 | } | |
12648 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN] | |
12649 | && bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN] | |
12650 | && ecommunity_cmp( | |
12651 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12652 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN])) { | |
12653 | ||
12654 | char *b = ecommunity_ecom2str( | |
12655 | bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12656 | ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12657 | vty_out(vty, "%*srt vpn both %s\n", indent, "", b); |
ddb5b488 PZ |
12658 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12659 | } else { | |
12660 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_FROMVPN]) { | |
12661 | char *b = ecommunity_ecom2str( | |
12662 | bgp->vpn_policy[afi] | |
12663 | .rtlist[BGP_VPN_POLICY_DIR_FROMVPN], | |
12664 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12665 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12666 | vty_out(vty, "%*srt vpn import %s\n", indent, "", b); |
ddb5b488 PZ |
12667 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12668 | } | |
12669 | if (bgp->vpn_policy[afi].rtlist[BGP_VPN_POLICY_DIR_TOVPN]) { | |
12670 | char *b = ecommunity_ecom2str( | |
12671 | bgp->vpn_policy[afi] | |
12672 | .rtlist[BGP_VPN_POLICY_DIR_TOVPN], | |
12673 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12674 | ECOMMUNITY_ROUTE_TARGET); | |
b9c7bc5a | 12675 | vty_out(vty, "%*srt vpn export %s\n", indent, "", b); |
ddb5b488 PZ |
12676 | XFREE(MTYPE_ECOMMUNITY_STR, b); |
12677 | } | |
12678 | } | |
bb4f6190 DS |
12679 | |
12680 | if (bgp->vpn_policy[afi].rmap_name[BGP_VPN_POLICY_DIR_TOVPN]) | |
b9c7bc5a | 12681 | vty_out(vty, "%*sroute-map vpn export %s\n", indent, "", |
ddb5b488 PZ |
12682 | bgp->vpn_policy[afi] |
12683 | .rmap_name[BGP_VPN_POLICY_DIR_TOVPN]); | |
bb4f6190 | 12684 | |
301ad80a PG |
12685 | if (bgp->vpn_policy[afi].import_redirect_rtlist) { |
12686 | char *b = ecommunity_ecom2str( | |
12687 | bgp->vpn_policy[afi] | |
12688 | .import_redirect_rtlist, | |
12689 | ECOMMUNITY_FORMAT_ROUTE_MAP, | |
12690 | ECOMMUNITY_ROUTE_TARGET); | |
ddb5b488 | 12691 | |
301ad80a PG |
12692 | vty_out(vty, "%*srt redirect import %s\n", indent, "", b); |
12693 | XFREE(MTYPE_ECOMMUNITY_STR, b); | |
12694 | } | |
ddb5b488 PZ |
12695 | } |
12696 | ||
12697 | ||
718e3744 | 12698 | /* BGP node structure. */ |
d62a17ae | 12699 | static struct cmd_node bgp_node = { |
9d303b37 | 12700 | BGP_NODE, "%s(config-router)# ", 1, |
718e3744 | 12701 | }; |
12702 | ||
d62a17ae | 12703 | static struct cmd_node bgp_ipv4_unicast_node = { |
9d303b37 | 12704 | BGP_IPV4_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12705 | }; |
12706 | ||
d62a17ae | 12707 | static struct cmd_node bgp_ipv4_multicast_node = { |
9d303b37 | 12708 | BGP_IPV4M_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12709 | }; |
12710 | ||
d62a17ae | 12711 | static struct cmd_node bgp_ipv4_labeled_unicast_node = { |
9d303b37 | 12712 | BGP_IPV4L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12713 | }; |
12714 | ||
d62a17ae | 12715 | static struct cmd_node bgp_ipv6_unicast_node = { |
9d303b37 | 12716 | BGP_IPV6_NODE, "%s(config-router-af)# ", 1, |
718e3744 | 12717 | }; |
12718 | ||
d62a17ae | 12719 | static struct cmd_node bgp_ipv6_multicast_node = { |
9d303b37 | 12720 | BGP_IPV6M_NODE, "%s(config-router-af)# ", 1, |
25ffbdc1 | 12721 | }; |
12722 | ||
d62a17ae | 12723 | static struct cmd_node bgp_ipv6_labeled_unicast_node = { |
9d303b37 | 12724 | BGP_IPV6L_NODE, "%s(config-router-af)# ", 1, |
f51bae9c DS |
12725 | }; |
12726 | ||
d62a17ae | 12727 | static struct cmd_node bgp_vpnv4_node = {BGP_VPNV4_NODE, |
12728 | "%s(config-router-af)# ", 1}; | |
6b0655a2 | 12729 | |
d62a17ae | 12730 | static struct cmd_node bgp_vpnv6_node = {BGP_VPNV6_NODE, |
12731 | "%s(config-router-af-vpnv6)# ", 1}; | |
8ecd3266 | 12732 | |
d62a17ae | 12733 | static struct cmd_node bgp_evpn_node = {BGP_EVPN_NODE, |
12734 | "%s(config-router-evpn)# ", 1}; | |
4e0b7b6d | 12735 | |
d62a17ae | 12736 | static struct cmd_node bgp_evpn_vni_node = {BGP_EVPN_VNI_NODE, |
12737 | "%s(config-router-af-vni)# ", 1}; | |
90e60aa7 | 12738 | |
7c40bf39 | 12739 | static struct cmd_node bgp_flowspecv4_node = {BGP_FLOWSPECV4_NODE, |
12740 | "%s(config-router-af)# ", 1}; | |
12741 | ||
12742 | static struct cmd_node bgp_flowspecv6_node = {BGP_FLOWSPECV6_NODE, | |
12743 | "%s(config-router-af-vpnv6)# ", 1}; | |
12744 | ||
d62a17ae | 12745 | static void community_list_vty(void); |
1f8ae70b | 12746 | |
d62a17ae | 12747 | static void bgp_ac_neighbor(vector comps, struct cmd_token *token) |
b8a815e5 | 12748 | { |
d62a17ae | 12749 | struct bgp *bgp; |
12750 | struct peer *peer; | |
d62a17ae | 12751 | struct listnode *lnbgp, *lnpeer; |
b8a815e5 | 12752 | |
d62a17ae | 12753 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { |
12754 | for (ALL_LIST_ELEMENTS_RO(bgp->peer, lnpeer, peer)) { | |
12755 | /* only provide suggestions on the appropriate input | |
12756 | * token type, | |
12757 | * they'll otherwise show up multiple times */ | |
12758 | enum cmd_token_type match_type; | |
12759 | char *name = peer->host; | |
d48ed3e0 | 12760 | |
d62a17ae | 12761 | if (peer->conf_if) { |
12762 | match_type = VARIABLE_TKN; | |
12763 | name = peer->conf_if; | |
12764 | } else if (strchr(peer->host, ':')) | |
12765 | match_type = IPV6_TKN; | |
12766 | else | |
12767 | match_type = IPV4_TKN; | |
d48ed3e0 | 12768 | |
d62a17ae | 12769 | if (token->type != match_type) |
12770 | continue; | |
d48ed3e0 | 12771 | |
d62a17ae | 12772 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); |
12773 | } | |
d62a17ae | 12774 | } |
b8a815e5 DL |
12775 | } |
12776 | ||
12777 | static const struct cmd_variable_handler bgp_var_neighbor[] = { | |
d62a17ae | 12778 | {.varname = "neighbor", .completions = bgp_ac_neighbor}, |
12779 | {.varname = "neighbors", .completions = bgp_ac_neighbor}, | |
7d4aea30 | 12780 | {.varname = "peer", .completions = bgp_ac_neighbor}, |
d62a17ae | 12781 | {.completions = NULL}}; |
12782 | ||
47a306a0 DS |
12783 | static void bgp_ac_peergroup(vector comps, struct cmd_token *token) |
12784 | { | |
12785 | struct bgp *bgp; | |
12786 | struct peer_group *group; | |
12787 | struct listnode *lnbgp, *lnpeer; | |
12788 | ||
12789 | for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { | |
12790 | for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) | |
12791 | vector_set(comps, XSTRDUP(MTYPE_COMPLETION, | |
12792 | group->name)); | |
12793 | } | |
12794 | } | |
12795 | ||
12796 | static const struct cmd_variable_handler bgp_var_peergroup[] = { | |
12797 | {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, | |
12798 | {.completions = NULL} }; | |
12799 | ||
d62a17ae | 12800 | void bgp_vty_init(void) |
12801 | { | |
12802 | cmd_variable_handler_register(bgp_var_neighbor); | |
47a306a0 | 12803 | cmd_variable_handler_register(bgp_var_peergroup); |
d62a17ae | 12804 | |
12805 | /* Install bgp top node. */ | |
12806 | install_node(&bgp_node, bgp_config_write); | |
12807 | install_node(&bgp_ipv4_unicast_node, NULL); | |
12808 | install_node(&bgp_ipv4_multicast_node, NULL); | |
12809 | install_node(&bgp_ipv4_labeled_unicast_node, NULL); | |
12810 | install_node(&bgp_ipv6_unicast_node, NULL); | |
12811 | install_node(&bgp_ipv6_multicast_node, NULL); | |
12812 | install_node(&bgp_ipv6_labeled_unicast_node, NULL); | |
12813 | install_node(&bgp_vpnv4_node, NULL); | |
12814 | install_node(&bgp_vpnv6_node, NULL); | |
12815 | install_node(&bgp_evpn_node, NULL); | |
12816 | install_node(&bgp_evpn_vni_node, NULL); | |
7c40bf39 | 12817 | install_node(&bgp_flowspecv4_node, NULL); |
12818 | install_node(&bgp_flowspecv6_node, NULL); | |
d62a17ae | 12819 | |
12820 | /* Install default VTY commands to new nodes. */ | |
12821 | install_default(BGP_NODE); | |
12822 | install_default(BGP_IPV4_NODE); | |
12823 | install_default(BGP_IPV4M_NODE); | |
12824 | install_default(BGP_IPV4L_NODE); | |
12825 | install_default(BGP_IPV6_NODE); | |
12826 | install_default(BGP_IPV6M_NODE); | |
12827 | install_default(BGP_IPV6L_NODE); | |
12828 | install_default(BGP_VPNV4_NODE); | |
12829 | install_default(BGP_VPNV6_NODE); | |
7c40bf39 | 12830 | install_default(BGP_FLOWSPECV4_NODE); |
12831 | install_default(BGP_FLOWSPECV6_NODE); | |
d62a17ae | 12832 | install_default(BGP_EVPN_NODE); |
12833 | install_default(BGP_EVPN_VNI_NODE); | |
12834 | ||
8029b216 AK |
12835 | /* "bgp local-mac" hidden commands. */ |
12836 | install_element(CONFIG_NODE, &bgp_local_mac_cmd); | |
12837 | install_element(CONFIG_NODE, &no_bgp_local_mac_cmd); | |
12838 | ||
d62a17ae | 12839 | /* bgp route-map delay-timer commands. */ |
12840 | install_element(CONFIG_NODE, &bgp_set_route_map_delay_timer_cmd); | |
12841 | install_element(CONFIG_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
12842 | ||
12843 | /* Dummy commands (Currently not supported) */ | |
12844 | install_element(BGP_NODE, &no_synchronization_cmd); | |
12845 | install_element(BGP_NODE, &no_auto_summary_cmd); | |
12846 | ||
12847 | /* "router bgp" commands. */ | |
12848 | install_element(CONFIG_NODE, &router_bgp_cmd); | |
12849 | ||
12850 | /* "no router bgp" commands. */ | |
12851 | install_element(CONFIG_NODE, &no_router_bgp_cmd); | |
12852 | ||
12853 | /* "bgp router-id" commands. */ | |
12854 | install_element(BGP_NODE, &bgp_router_id_cmd); | |
12855 | install_element(BGP_NODE, &no_bgp_router_id_cmd); | |
12856 | ||
12857 | /* "bgp cluster-id" commands. */ | |
12858 | install_element(BGP_NODE, &bgp_cluster_id_cmd); | |
12859 | install_element(BGP_NODE, &no_bgp_cluster_id_cmd); | |
12860 | ||
12861 | /* "bgp confederation" commands. */ | |
12862 | install_element(BGP_NODE, &bgp_confederation_identifier_cmd); | |
12863 | install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); | |
12864 | ||
12865 | /* "bgp confederation peers" commands. */ | |
12866 | install_element(BGP_NODE, &bgp_confederation_peers_cmd); | |
12867 | install_element(BGP_NODE, &no_bgp_confederation_peers_cmd); | |
12868 | ||
12869 | /* bgp max-med command */ | |
12870 | install_element(BGP_NODE, &bgp_maxmed_admin_cmd); | |
12871 | install_element(BGP_NODE, &no_bgp_maxmed_admin_cmd); | |
12872 | install_element(BGP_NODE, &bgp_maxmed_admin_medv_cmd); | |
12873 | install_element(BGP_NODE, &bgp_maxmed_onstartup_cmd); | |
12874 | install_element(BGP_NODE, &no_bgp_maxmed_onstartup_cmd); | |
12875 | ||
12876 | /* bgp disable-ebgp-connected-nh-check */ | |
12877 | install_element(BGP_NODE, &bgp_disable_connected_route_check_cmd); | |
12878 | install_element(BGP_NODE, &no_bgp_disable_connected_route_check_cmd); | |
12879 | ||
12880 | /* bgp update-delay command */ | |
12881 | install_element(BGP_NODE, &bgp_update_delay_cmd); | |
12882 | install_element(BGP_NODE, &no_bgp_update_delay_cmd); | |
12883 | install_element(BGP_NODE, &bgp_update_delay_establish_wait_cmd); | |
12884 | ||
12885 | install_element(BGP_NODE, &bgp_wpkt_quanta_cmd); | |
12886 | install_element(BGP_NODE, &no_bgp_wpkt_quanta_cmd); | |
555e09d4 QY |
12887 | install_element(BGP_NODE, &bgp_rpkt_quanta_cmd); |
12888 | install_element(BGP_NODE, &no_bgp_rpkt_quanta_cmd); | |
d62a17ae | 12889 | |
12890 | install_element(BGP_NODE, &bgp_coalesce_time_cmd); | |
12891 | install_element(BGP_NODE, &no_bgp_coalesce_time_cmd); | |
12892 | ||
12893 | /* "maximum-paths" commands. */ | |
12894 | install_element(BGP_NODE, &bgp_maxpaths_hidden_cmd); | |
12895 | install_element(BGP_NODE, &no_bgp_maxpaths_hidden_cmd); | |
12896 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_cmd); | |
12897 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_cmd); | |
12898 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_cmd); | |
12899 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_cmd); | |
12900 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_hidden_cmd); | |
12901 | install_element(BGP_NODE, &bgp_maxpaths_ibgp_cluster_hidden_cmd); | |
12902 | install_element(BGP_NODE, &no_bgp_maxpaths_ibgp_hidden_cmd); | |
12903 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cmd); | |
12904 | install_element(BGP_IPV4_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12905 | install_element(BGP_IPV4_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12906 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cmd); | |
12907 | install_element(BGP_IPV6_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12908 | install_element(BGP_IPV6_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12909 | ||
12910 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_cmd); | |
12911 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_cmd); | |
12912 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cmd); | |
12913 | install_element(BGP_IPV6L_NODE, &bgp_maxpaths_ibgp_cluster_cmd); | |
12914 | install_element(BGP_IPV6L_NODE, &no_bgp_maxpaths_ibgp_cmd); | |
12915 | ||
12916 | /* "timers bgp" commands. */ | |
12917 | install_element(BGP_NODE, &bgp_timers_cmd); | |
12918 | install_element(BGP_NODE, &no_bgp_timers_cmd); | |
12919 | ||
12920 | /* route-map delay-timer commands - per instance for backwards compat. | |
12921 | */ | |
12922 | install_element(BGP_NODE, &bgp_set_route_map_delay_timer_cmd); | |
12923 | install_element(BGP_NODE, &no_bgp_set_route_map_delay_timer_cmd); | |
12924 | ||
12925 | /* "bgp client-to-client reflection" commands */ | |
12926 | install_element(BGP_NODE, &no_bgp_client_to_client_reflection_cmd); | |
12927 | install_element(BGP_NODE, &bgp_client_to_client_reflection_cmd); | |
12928 | ||
12929 | /* "bgp always-compare-med" commands */ | |
12930 | install_element(BGP_NODE, &bgp_always_compare_med_cmd); | |
12931 | install_element(BGP_NODE, &no_bgp_always_compare_med_cmd); | |
12932 | ||
9dac9fc8 DA |
12933 | /* bgp ebgp-requires-policy */ |
12934 | install_element(BGP_NODE, &bgp_ebgp_requires_policy_cmd); | |
12935 | install_element(BGP_NODE, &no_bgp_ebgp_requires_policy_cmd); | |
12936 | ||
d62a17ae | 12937 | /* "bgp deterministic-med" commands */ |
12938 | install_element(BGP_NODE, &bgp_deterministic_med_cmd); | |
12939 | install_element(BGP_NODE, &no_bgp_deterministic_med_cmd); | |
12940 | ||
12941 | /* "bgp graceful-restart" commands */ | |
12942 | install_element(BGP_NODE, &bgp_graceful_restart_cmd); | |
12943 | install_element(BGP_NODE, &no_bgp_graceful_restart_cmd); | |
12944 | install_element(BGP_NODE, &bgp_graceful_restart_stalepath_time_cmd); | |
12945 | install_element(BGP_NODE, &no_bgp_graceful_restart_stalepath_time_cmd); | |
12946 | install_element(BGP_NODE, &bgp_graceful_restart_restart_time_cmd); | |
12947 | install_element(BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); | |
12948 | ||
12949 | install_element(BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); | |
12950 | install_element(BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); | |
12951 | ||
7f323236 DW |
12952 | /* "bgp graceful-shutdown" commands */ |
12953 | install_element(BGP_NODE, &bgp_graceful_shutdown_cmd); | |
12954 | install_element(BGP_NODE, &no_bgp_graceful_shutdown_cmd); | |
12955 | ||
d62a17ae | 12956 | /* "bgp fast-external-failover" commands */ |
12957 | install_element(BGP_NODE, &bgp_fast_external_failover_cmd); | |
12958 | install_element(BGP_NODE, &no_bgp_fast_external_failover_cmd); | |
12959 | ||
d62a17ae | 12960 | /* "bgp bestpath compare-routerid" commands */ |
12961 | install_element(BGP_NODE, &bgp_bestpath_compare_router_id_cmd); | |
12962 | install_element(BGP_NODE, &no_bgp_bestpath_compare_router_id_cmd); | |
12963 | ||
12964 | /* "bgp bestpath as-path ignore" commands */ | |
12965 | install_element(BGP_NODE, &bgp_bestpath_aspath_ignore_cmd); | |
12966 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_ignore_cmd); | |
12967 | ||
12968 | /* "bgp bestpath as-path confed" commands */ | |
12969 | install_element(BGP_NODE, &bgp_bestpath_aspath_confed_cmd); | |
12970 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_confed_cmd); | |
12971 | ||
12972 | /* "bgp bestpath as-path multipath-relax" commands */ | |
12973 | install_element(BGP_NODE, &bgp_bestpath_aspath_multipath_relax_cmd); | |
12974 | install_element(BGP_NODE, &no_bgp_bestpath_aspath_multipath_relax_cmd); | |
12975 | ||
12976 | /* "bgp log-neighbor-changes" commands */ | |
12977 | install_element(BGP_NODE, &bgp_log_neighbor_changes_cmd); | |
12978 | install_element(BGP_NODE, &no_bgp_log_neighbor_changes_cmd); | |
12979 | ||
12980 | /* "bgp bestpath med" commands */ | |
12981 | install_element(BGP_NODE, &bgp_bestpath_med_cmd); | |
12982 | install_element(BGP_NODE, &no_bgp_bestpath_med_cmd); | |
12983 | ||
12984 | /* "no bgp default ipv4-unicast" commands. */ | |
12985 | install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); | |
12986 | install_element(BGP_NODE, &bgp_default_ipv4_unicast_cmd); | |
12987 | ||
12988 | /* "bgp network import-check" commands. */ | |
12989 | install_element(BGP_NODE, &bgp_network_import_check_cmd); | |
12990 | install_element(BGP_NODE, &bgp_network_import_check_exact_cmd); | |
12991 | install_element(BGP_NODE, &no_bgp_network_import_check_cmd); | |
12992 | ||
12993 | /* "bgp default local-preference" commands. */ | |
12994 | install_element(BGP_NODE, &bgp_default_local_preference_cmd); | |
12995 | install_element(BGP_NODE, &no_bgp_default_local_preference_cmd); | |
12996 | ||
12997 | /* bgp default show-hostname */ | |
12998 | install_element(BGP_NODE, &bgp_default_show_hostname_cmd); | |
12999 | install_element(BGP_NODE, &no_bgp_default_show_hostname_cmd); | |
13000 | ||
13001 | /* "bgp default subgroup-pkt-queue-max" commands. */ | |
13002 | install_element(BGP_NODE, &bgp_default_subgroup_pkt_queue_max_cmd); | |
13003 | install_element(BGP_NODE, &no_bgp_default_subgroup_pkt_queue_max_cmd); | |
13004 | ||
13005 | /* bgp ibgp-allow-policy-mods command */ | |
13006 | install_element(BGP_NODE, &bgp_rr_allow_outbound_policy_cmd); | |
13007 | install_element(BGP_NODE, &no_bgp_rr_allow_outbound_policy_cmd); | |
13008 | ||
13009 | /* "bgp listen limit" commands. */ | |
13010 | install_element(BGP_NODE, &bgp_listen_limit_cmd); | |
13011 | install_element(BGP_NODE, &no_bgp_listen_limit_cmd); | |
13012 | ||
13013 | /* "bgp listen range" commands. */ | |
13014 | install_element(BGP_NODE, &bgp_listen_range_cmd); | |
13015 | install_element(BGP_NODE, &no_bgp_listen_range_cmd); | |
13016 | ||
8175f54a | 13017 | /* "bgp default shutdown" command */ |
f26845f9 QY |
13018 | install_element(BGP_NODE, &bgp_default_shutdown_cmd); |
13019 | ||
d62a17ae | 13020 | /* "neighbor remote-as" commands. */ |
13021 | install_element(BGP_NODE, &neighbor_remote_as_cmd); | |
13022 | install_element(BGP_NODE, &neighbor_interface_config_cmd); | |
13023 | install_element(BGP_NODE, &neighbor_interface_config_v6only_cmd); | |
13024 | install_element(BGP_NODE, &neighbor_interface_config_remote_as_cmd); | |
13025 | install_element(BGP_NODE, | |
13026 | &neighbor_interface_v6only_config_remote_as_cmd); | |
13027 | install_element(BGP_NODE, &no_neighbor_cmd); | |
13028 | install_element(BGP_NODE, &no_neighbor_interface_config_cmd); | |
13029 | ||
13030 | /* "neighbor peer-group" commands. */ | |
13031 | install_element(BGP_NODE, &neighbor_peer_group_cmd); | |
13032 | install_element(BGP_NODE, &no_neighbor_peer_group_cmd); | |
13033 | install_element(BGP_NODE, | |
13034 | &no_neighbor_interface_peer_group_remote_as_cmd); | |
13035 | ||
13036 | /* "neighbor local-as" commands. */ | |
13037 | install_element(BGP_NODE, &neighbor_local_as_cmd); | |
13038 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_cmd); | |
13039 | install_element(BGP_NODE, &neighbor_local_as_no_prepend_replace_as_cmd); | |
13040 | install_element(BGP_NODE, &no_neighbor_local_as_cmd); | |
13041 | ||
13042 | /* "neighbor solo" commands. */ | |
13043 | install_element(BGP_NODE, &neighbor_solo_cmd); | |
13044 | install_element(BGP_NODE, &no_neighbor_solo_cmd); | |
13045 | ||
13046 | /* "neighbor password" commands. */ | |
13047 | install_element(BGP_NODE, &neighbor_password_cmd); | |
13048 | install_element(BGP_NODE, &no_neighbor_password_cmd); | |
13049 | ||
13050 | /* "neighbor activate" commands. */ | |
13051 | install_element(BGP_NODE, &neighbor_activate_hidden_cmd); | |
13052 | install_element(BGP_IPV4_NODE, &neighbor_activate_cmd); | |
13053 | install_element(BGP_IPV4M_NODE, &neighbor_activate_cmd); | |
13054 | install_element(BGP_IPV4L_NODE, &neighbor_activate_cmd); | |
13055 | install_element(BGP_IPV6_NODE, &neighbor_activate_cmd); | |
13056 | install_element(BGP_IPV6M_NODE, &neighbor_activate_cmd); | |
13057 | install_element(BGP_IPV6L_NODE, &neighbor_activate_cmd); | |
13058 | install_element(BGP_VPNV4_NODE, &neighbor_activate_cmd); | |
13059 | install_element(BGP_VPNV6_NODE, &neighbor_activate_cmd); | |
7c40bf39 | 13060 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_activate_cmd); |
13061 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_activate_cmd); | |
d62a17ae | 13062 | install_element(BGP_EVPN_NODE, &neighbor_activate_cmd); |
13063 | ||
13064 | /* "no neighbor activate" commands. */ | |
13065 | install_element(BGP_NODE, &no_neighbor_activate_hidden_cmd); | |
13066 | install_element(BGP_IPV4_NODE, &no_neighbor_activate_cmd); | |
13067 | install_element(BGP_IPV4M_NODE, &no_neighbor_activate_cmd); | |
13068 | install_element(BGP_IPV4L_NODE, &no_neighbor_activate_cmd); | |
13069 | install_element(BGP_IPV6_NODE, &no_neighbor_activate_cmd); | |
13070 | install_element(BGP_IPV6M_NODE, &no_neighbor_activate_cmd); | |
13071 | install_element(BGP_IPV6L_NODE, &no_neighbor_activate_cmd); | |
13072 | install_element(BGP_VPNV4_NODE, &no_neighbor_activate_cmd); | |
13073 | install_element(BGP_VPNV6_NODE, &no_neighbor_activate_cmd); | |
7c40bf39 | 13074 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_activate_cmd); |
13075 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_activate_cmd); | |
d62a17ae | 13076 | install_element(BGP_EVPN_NODE, &no_neighbor_activate_cmd); |
13077 | ||
13078 | /* "neighbor peer-group" set commands. */ | |
13079 | install_element(BGP_NODE, &neighbor_set_peer_group_cmd); | |
13080 | install_element(BGP_IPV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13081 | install_element(BGP_IPV4M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13082 | install_element(BGP_IPV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13083 | install_element(BGP_IPV6M_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13084 | install_element(BGP_IPV6L_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13085 | install_element(BGP_VPNV4_NODE, &neighbor_set_peer_group_hidden_cmd); | |
13086 | install_element(BGP_VPNV6_NODE, &neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 13087 | install_element(BGP_FLOWSPECV4_NODE, |
13088 | &neighbor_set_peer_group_hidden_cmd); | |
13089 | install_element(BGP_FLOWSPECV6_NODE, | |
13090 | &neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 13091 | |
13092 | /* "no neighbor peer-group unset" commands. */ | |
13093 | install_element(BGP_NODE, &no_neighbor_set_peer_group_cmd); | |
13094 | install_element(BGP_IPV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13095 | install_element(BGP_IPV4M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13096 | install_element(BGP_IPV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13097 | install_element(BGP_IPV6M_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13098 | install_element(BGP_IPV6L_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13099 | install_element(BGP_VPNV4_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
13100 | install_element(BGP_VPNV6_NODE, &no_neighbor_set_peer_group_hidden_cmd); | |
7c40bf39 | 13101 | install_element(BGP_FLOWSPECV4_NODE, |
13102 | &no_neighbor_set_peer_group_hidden_cmd); | |
13103 | install_element(BGP_FLOWSPECV6_NODE, | |
13104 | &no_neighbor_set_peer_group_hidden_cmd); | |
d62a17ae | 13105 | |
13106 | /* "neighbor softreconfiguration inbound" commands.*/ | |
13107 | install_element(BGP_NODE, &neighbor_soft_reconfiguration_hidden_cmd); | |
13108 | install_element(BGP_NODE, &no_neighbor_soft_reconfiguration_hidden_cmd); | |
13109 | install_element(BGP_IPV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
13110 | install_element(BGP_IPV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13111 | install_element(BGP_IPV4L_NODE, &neighbor_soft_reconfiguration_cmd); | |
13112 | install_element(BGP_IPV4L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13113 | install_element(BGP_IPV4M_NODE, &neighbor_soft_reconfiguration_cmd); | |
13114 | install_element(BGP_IPV4M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13115 | install_element(BGP_IPV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
13116 | install_element(BGP_IPV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13117 | install_element(BGP_IPV6M_NODE, &neighbor_soft_reconfiguration_cmd); | |
13118 | install_element(BGP_IPV6M_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13119 | install_element(BGP_IPV6L_NODE, &neighbor_soft_reconfiguration_cmd); | |
13120 | install_element(BGP_IPV6L_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13121 | install_element(BGP_VPNV4_NODE, &neighbor_soft_reconfiguration_cmd); | |
13122 | install_element(BGP_VPNV4_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
13123 | install_element(BGP_VPNV6_NODE, &neighbor_soft_reconfiguration_cmd); | |
13124 | install_element(BGP_VPNV6_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
7c40bf39 | 13125 | install_element(BGP_FLOWSPECV4_NODE, |
13126 | &neighbor_soft_reconfiguration_cmd); | |
13127 | install_element(BGP_FLOWSPECV4_NODE, | |
13128 | &no_neighbor_soft_reconfiguration_cmd); | |
13129 | install_element(BGP_FLOWSPECV6_NODE, | |
13130 | &neighbor_soft_reconfiguration_cmd); | |
13131 | install_element(BGP_FLOWSPECV6_NODE, | |
13132 | &no_neighbor_soft_reconfiguration_cmd); | |
616c6ee8 PG |
13133 | install_element(BGP_EVPN_NODE, &neighbor_soft_reconfiguration_cmd); |
13134 | install_element(BGP_EVPN_NODE, &no_neighbor_soft_reconfiguration_cmd); | |
d62a17ae | 13135 | |
13136 | /* "neighbor attribute-unchanged" commands. */ | |
13137 | install_element(BGP_NODE, &neighbor_attr_unchanged_hidden_cmd); | |
13138 | install_element(BGP_NODE, &no_neighbor_attr_unchanged_hidden_cmd); | |
13139 | install_element(BGP_IPV4_NODE, &neighbor_attr_unchanged_cmd); | |
13140 | install_element(BGP_IPV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
13141 | install_element(BGP_IPV4M_NODE, &neighbor_attr_unchanged_cmd); | |
13142 | install_element(BGP_IPV4M_NODE, &no_neighbor_attr_unchanged_cmd); | |
13143 | install_element(BGP_IPV4L_NODE, &neighbor_attr_unchanged_cmd); | |
13144 | install_element(BGP_IPV4L_NODE, &no_neighbor_attr_unchanged_cmd); | |
13145 | install_element(BGP_IPV6_NODE, &neighbor_attr_unchanged_cmd); | |
13146 | install_element(BGP_IPV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
13147 | install_element(BGP_IPV6M_NODE, &neighbor_attr_unchanged_cmd); | |
13148 | install_element(BGP_IPV6M_NODE, &no_neighbor_attr_unchanged_cmd); | |
13149 | install_element(BGP_IPV6L_NODE, &neighbor_attr_unchanged_cmd); | |
13150 | install_element(BGP_IPV6L_NODE, &no_neighbor_attr_unchanged_cmd); | |
13151 | install_element(BGP_VPNV4_NODE, &neighbor_attr_unchanged_cmd); | |
13152 | install_element(BGP_VPNV4_NODE, &no_neighbor_attr_unchanged_cmd); | |
13153 | install_element(BGP_VPNV6_NODE, &neighbor_attr_unchanged_cmd); | |
13154 | install_element(BGP_VPNV6_NODE, &no_neighbor_attr_unchanged_cmd); | |
13155 | ||
13156 | install_element(BGP_EVPN_NODE, &neighbor_attr_unchanged_cmd); | |
13157 | install_element(BGP_EVPN_NODE, &no_neighbor_attr_unchanged_cmd); | |
13158 | ||
13159 | /* "nexthop-local unchanged" commands */ | |
13160 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_local_unchanged_cmd); | |
13161 | install_element(BGP_IPV6_NODE, | |
13162 | &no_neighbor_nexthop_local_unchanged_cmd); | |
13163 | ||
13164 | /* "neighbor next-hop-self" commands. */ | |
13165 | install_element(BGP_NODE, &neighbor_nexthop_self_hidden_cmd); | |
13166 | install_element(BGP_NODE, &no_neighbor_nexthop_self_hidden_cmd); | |
13167 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_cmd); | |
13168 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_cmd); | |
13169 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_cmd); | |
13170 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_cmd); | |
13171 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_cmd); | |
13172 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_cmd); | |
13173 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_cmd); | |
13174 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_cmd); | |
13175 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_cmd); | |
13176 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_cmd); | |
13177 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_cmd); | |
13178 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_cmd); | |
13179 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd); | |
13180 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd); | |
13181 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_cmd); | |
13182 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_cmd); | |
ace295a9 MK |
13183 | install_element(BGP_EVPN_NODE, &neighbor_nexthop_self_cmd); |
13184 | install_element(BGP_EVPN_NODE, &no_neighbor_nexthop_self_cmd); | |
d62a17ae | 13185 | |
13186 | /* "neighbor next-hop-self force" commands. */ | |
13187 | install_element(BGP_NODE, &neighbor_nexthop_self_force_hidden_cmd); | |
13188 | install_element(BGP_NODE, &no_neighbor_nexthop_self_force_hidden_cmd); | |
1bc4e531 DA |
13189 | install_element(BGP_NODE, &neighbor_nexthop_self_all_hidden_cmd); |
13190 | install_element(BGP_NODE, &no_neighbor_nexthop_self_all_hidden_cmd); | |
d62a17ae | 13191 | install_element(BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd); |
13192 | install_element(BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13193 | install_element(BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd); | |
13194 | install_element(BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13195 | install_element(BGP_IPV4L_NODE, &neighbor_nexthop_self_force_cmd); | |
13196 | install_element(BGP_IPV4L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13197 | install_element(BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd); | |
13198 | install_element(BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13199 | install_element(BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd); | |
13200 | install_element(BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13201 | install_element(BGP_IPV6L_NODE, &neighbor_nexthop_self_force_cmd); | |
13202 | install_element(BGP_IPV6L_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13203 | install_element(BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd); | |
13204 | install_element(BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13205 | install_element(BGP_VPNV6_NODE, &neighbor_nexthop_self_force_cmd); | |
13206 | install_element(BGP_VPNV6_NODE, &no_neighbor_nexthop_self_force_cmd); | |
13207 | ||
13208 | /* "neighbor as-override" commands. */ | |
13209 | install_element(BGP_NODE, &neighbor_as_override_hidden_cmd); | |
13210 | install_element(BGP_NODE, &no_neighbor_as_override_hidden_cmd); | |
13211 | install_element(BGP_IPV4_NODE, &neighbor_as_override_cmd); | |
13212 | install_element(BGP_IPV4_NODE, &no_neighbor_as_override_cmd); | |
13213 | install_element(BGP_IPV4M_NODE, &neighbor_as_override_cmd); | |
13214 | install_element(BGP_IPV4M_NODE, &no_neighbor_as_override_cmd); | |
13215 | install_element(BGP_IPV4L_NODE, &neighbor_as_override_cmd); | |
13216 | install_element(BGP_IPV4L_NODE, &no_neighbor_as_override_cmd); | |
13217 | install_element(BGP_IPV6_NODE, &neighbor_as_override_cmd); | |
13218 | install_element(BGP_IPV6_NODE, &no_neighbor_as_override_cmd); | |
13219 | install_element(BGP_IPV6M_NODE, &neighbor_as_override_cmd); | |
13220 | install_element(BGP_IPV6M_NODE, &no_neighbor_as_override_cmd); | |
13221 | install_element(BGP_IPV6L_NODE, &neighbor_as_override_cmd); | |
13222 | install_element(BGP_IPV6L_NODE, &no_neighbor_as_override_cmd); | |
13223 | install_element(BGP_VPNV4_NODE, &neighbor_as_override_cmd); | |
13224 | install_element(BGP_VPNV4_NODE, &no_neighbor_as_override_cmd); | |
13225 | install_element(BGP_VPNV6_NODE, &neighbor_as_override_cmd); | |
13226 | install_element(BGP_VPNV6_NODE, &no_neighbor_as_override_cmd); | |
13227 | ||
13228 | /* "neighbor remove-private-AS" commands. */ | |
13229 | install_element(BGP_NODE, &neighbor_remove_private_as_hidden_cmd); | |
13230 | install_element(BGP_NODE, &no_neighbor_remove_private_as_hidden_cmd); | |
13231 | install_element(BGP_NODE, &neighbor_remove_private_as_all_hidden_cmd); | |
13232 | install_element(BGP_NODE, | |
13233 | &no_neighbor_remove_private_as_all_hidden_cmd); | |
13234 | install_element(BGP_NODE, | |
13235 | &neighbor_remove_private_as_replace_as_hidden_cmd); | |
13236 | install_element(BGP_NODE, | |
13237 | &no_neighbor_remove_private_as_replace_as_hidden_cmd); | |
13238 | install_element(BGP_NODE, | |
13239 | &neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
13240 | install_element( | |
13241 | BGP_NODE, | |
13242 | &no_neighbor_remove_private_as_all_replace_as_hidden_cmd); | |
13243 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_cmd); | |
13244 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_cmd); | |
13245 | install_element(BGP_IPV4_NODE, &neighbor_remove_private_as_all_cmd); | |
13246 | install_element(BGP_IPV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13247 | install_element(BGP_IPV4_NODE, | |
13248 | &neighbor_remove_private_as_replace_as_cmd); | |
13249 | install_element(BGP_IPV4_NODE, | |
13250 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13251 | install_element(BGP_IPV4_NODE, | |
13252 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13253 | install_element(BGP_IPV4_NODE, | |
13254 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13255 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_cmd); | |
13256 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_cmd); | |
13257 | install_element(BGP_IPV4M_NODE, &neighbor_remove_private_as_all_cmd); | |
13258 | install_element(BGP_IPV4M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13259 | install_element(BGP_IPV4M_NODE, | |
13260 | &neighbor_remove_private_as_replace_as_cmd); | |
13261 | install_element(BGP_IPV4M_NODE, | |
13262 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13263 | install_element(BGP_IPV4M_NODE, | |
13264 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13265 | install_element(BGP_IPV4M_NODE, | |
13266 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13267 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_cmd); | |
13268 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_cmd); | |
13269 | install_element(BGP_IPV4L_NODE, &neighbor_remove_private_as_all_cmd); | |
13270 | install_element(BGP_IPV4L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13271 | install_element(BGP_IPV4L_NODE, | |
13272 | &neighbor_remove_private_as_replace_as_cmd); | |
13273 | install_element(BGP_IPV4L_NODE, | |
13274 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13275 | install_element(BGP_IPV4L_NODE, | |
13276 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13277 | install_element(BGP_IPV4L_NODE, | |
13278 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13279 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_cmd); | |
13280 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_cmd); | |
13281 | install_element(BGP_IPV6_NODE, &neighbor_remove_private_as_all_cmd); | |
13282 | install_element(BGP_IPV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13283 | install_element(BGP_IPV6_NODE, | |
13284 | &neighbor_remove_private_as_replace_as_cmd); | |
13285 | install_element(BGP_IPV6_NODE, | |
13286 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13287 | install_element(BGP_IPV6_NODE, | |
13288 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13289 | install_element(BGP_IPV6_NODE, | |
13290 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13291 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_cmd); | |
13292 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_cmd); | |
13293 | install_element(BGP_IPV6M_NODE, &neighbor_remove_private_as_all_cmd); | |
13294 | install_element(BGP_IPV6M_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13295 | install_element(BGP_IPV6M_NODE, | |
13296 | &neighbor_remove_private_as_replace_as_cmd); | |
13297 | install_element(BGP_IPV6M_NODE, | |
13298 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13299 | install_element(BGP_IPV6M_NODE, | |
13300 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13301 | install_element(BGP_IPV6M_NODE, | |
13302 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13303 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_cmd); | |
13304 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_cmd); | |
13305 | install_element(BGP_IPV6L_NODE, &neighbor_remove_private_as_all_cmd); | |
13306 | install_element(BGP_IPV6L_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13307 | install_element(BGP_IPV6L_NODE, | |
13308 | &neighbor_remove_private_as_replace_as_cmd); | |
13309 | install_element(BGP_IPV6L_NODE, | |
13310 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13311 | install_element(BGP_IPV6L_NODE, | |
13312 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13313 | install_element(BGP_IPV6L_NODE, | |
13314 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13315 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_cmd); | |
13316 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_cmd); | |
13317 | install_element(BGP_VPNV4_NODE, &neighbor_remove_private_as_all_cmd); | |
13318 | install_element(BGP_VPNV4_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13319 | install_element(BGP_VPNV4_NODE, | |
13320 | &neighbor_remove_private_as_replace_as_cmd); | |
13321 | install_element(BGP_VPNV4_NODE, | |
13322 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13323 | install_element(BGP_VPNV4_NODE, | |
13324 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13325 | install_element(BGP_VPNV4_NODE, | |
13326 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13327 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_cmd); | |
13328 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_cmd); | |
13329 | install_element(BGP_VPNV6_NODE, &neighbor_remove_private_as_all_cmd); | |
13330 | install_element(BGP_VPNV6_NODE, &no_neighbor_remove_private_as_all_cmd); | |
13331 | install_element(BGP_VPNV6_NODE, | |
13332 | &neighbor_remove_private_as_replace_as_cmd); | |
13333 | install_element(BGP_VPNV6_NODE, | |
13334 | &no_neighbor_remove_private_as_replace_as_cmd); | |
13335 | install_element(BGP_VPNV6_NODE, | |
13336 | &neighbor_remove_private_as_all_replace_as_cmd); | |
13337 | install_element(BGP_VPNV6_NODE, | |
13338 | &no_neighbor_remove_private_as_all_replace_as_cmd); | |
13339 | ||
13340 | /* "neighbor send-community" commands.*/ | |
13341 | install_element(BGP_NODE, &neighbor_send_community_hidden_cmd); | |
13342 | install_element(BGP_NODE, &neighbor_send_community_type_hidden_cmd); | |
13343 | install_element(BGP_NODE, &no_neighbor_send_community_hidden_cmd); | |
13344 | install_element(BGP_NODE, &no_neighbor_send_community_type_hidden_cmd); | |
13345 | install_element(BGP_IPV4_NODE, &neighbor_send_community_cmd); | |
13346 | install_element(BGP_IPV4_NODE, &neighbor_send_community_type_cmd); | |
13347 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_cmd); | |
13348 | install_element(BGP_IPV4_NODE, &no_neighbor_send_community_type_cmd); | |
13349 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_cmd); | |
13350 | install_element(BGP_IPV4M_NODE, &neighbor_send_community_type_cmd); | |
13351 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_cmd); | |
13352 | install_element(BGP_IPV4M_NODE, &no_neighbor_send_community_type_cmd); | |
13353 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_cmd); | |
13354 | install_element(BGP_IPV4L_NODE, &neighbor_send_community_type_cmd); | |
13355 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_cmd); | |
13356 | install_element(BGP_IPV4L_NODE, &no_neighbor_send_community_type_cmd); | |
13357 | install_element(BGP_IPV6_NODE, &neighbor_send_community_cmd); | |
13358 | install_element(BGP_IPV6_NODE, &neighbor_send_community_type_cmd); | |
13359 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_cmd); | |
13360 | install_element(BGP_IPV6_NODE, &no_neighbor_send_community_type_cmd); | |
13361 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_cmd); | |
13362 | install_element(BGP_IPV6M_NODE, &neighbor_send_community_type_cmd); | |
13363 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_cmd); | |
13364 | install_element(BGP_IPV6M_NODE, &no_neighbor_send_community_type_cmd); | |
13365 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_cmd); | |
13366 | install_element(BGP_IPV6L_NODE, &neighbor_send_community_type_cmd); | |
13367 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_cmd); | |
13368 | install_element(BGP_IPV6L_NODE, &no_neighbor_send_community_type_cmd); | |
13369 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_cmd); | |
13370 | install_element(BGP_VPNV4_NODE, &neighbor_send_community_type_cmd); | |
13371 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_cmd); | |
13372 | install_element(BGP_VPNV4_NODE, &no_neighbor_send_community_type_cmd); | |
13373 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_cmd); | |
13374 | install_element(BGP_VPNV6_NODE, &neighbor_send_community_type_cmd); | |
13375 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_cmd); | |
13376 | install_element(BGP_VPNV6_NODE, &no_neighbor_send_community_type_cmd); | |
13377 | ||
13378 | /* "neighbor route-reflector" commands.*/ | |
13379 | install_element(BGP_NODE, &neighbor_route_reflector_client_hidden_cmd); | |
13380 | install_element(BGP_NODE, | |
13381 | &no_neighbor_route_reflector_client_hidden_cmd); | |
13382 | install_element(BGP_IPV4_NODE, &neighbor_route_reflector_client_cmd); | |
13383 | install_element(BGP_IPV4_NODE, &no_neighbor_route_reflector_client_cmd); | |
13384 | install_element(BGP_IPV4M_NODE, &neighbor_route_reflector_client_cmd); | |
13385 | install_element(BGP_IPV4M_NODE, | |
13386 | &no_neighbor_route_reflector_client_cmd); | |
13387 | install_element(BGP_IPV4L_NODE, &neighbor_route_reflector_client_cmd); | |
13388 | install_element(BGP_IPV4L_NODE, | |
13389 | &no_neighbor_route_reflector_client_cmd); | |
13390 | install_element(BGP_IPV6_NODE, &neighbor_route_reflector_client_cmd); | |
13391 | install_element(BGP_IPV6_NODE, &no_neighbor_route_reflector_client_cmd); | |
13392 | install_element(BGP_IPV6M_NODE, &neighbor_route_reflector_client_cmd); | |
13393 | install_element(BGP_IPV6M_NODE, | |
13394 | &no_neighbor_route_reflector_client_cmd); | |
13395 | install_element(BGP_IPV6L_NODE, &neighbor_route_reflector_client_cmd); | |
13396 | install_element(BGP_IPV6L_NODE, | |
13397 | &no_neighbor_route_reflector_client_cmd); | |
13398 | install_element(BGP_VPNV4_NODE, &neighbor_route_reflector_client_cmd); | |
13399 | install_element(BGP_VPNV4_NODE, | |
13400 | &no_neighbor_route_reflector_client_cmd); | |
13401 | install_element(BGP_VPNV6_NODE, &neighbor_route_reflector_client_cmd); | |
13402 | install_element(BGP_VPNV6_NODE, | |
13403 | &no_neighbor_route_reflector_client_cmd); | |
7c40bf39 | 13404 | install_element(BGP_FLOWSPECV4_NODE, |
13405 | &neighbor_route_reflector_client_cmd); | |
13406 | install_element(BGP_FLOWSPECV4_NODE, | |
13407 | &no_neighbor_route_reflector_client_cmd); | |
13408 | install_element(BGP_FLOWSPECV6_NODE, | |
13409 | &neighbor_route_reflector_client_cmd); | |
13410 | install_element(BGP_FLOWSPECV6_NODE, | |
13411 | &no_neighbor_route_reflector_client_cmd); | |
d62a17ae | 13412 | install_element(BGP_EVPN_NODE, &neighbor_route_reflector_client_cmd); |
13413 | install_element(BGP_EVPN_NODE, &no_neighbor_route_reflector_client_cmd); | |
13414 | ||
13415 | /* "neighbor route-server" commands.*/ | |
13416 | install_element(BGP_NODE, &neighbor_route_server_client_hidden_cmd); | |
13417 | install_element(BGP_NODE, &no_neighbor_route_server_client_hidden_cmd); | |
13418 | install_element(BGP_IPV4_NODE, &neighbor_route_server_client_cmd); | |
13419 | install_element(BGP_IPV4_NODE, &no_neighbor_route_server_client_cmd); | |
13420 | install_element(BGP_IPV4M_NODE, &neighbor_route_server_client_cmd); | |
13421 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_server_client_cmd); | |
13422 | install_element(BGP_IPV4L_NODE, &neighbor_route_server_client_cmd); | |
13423 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_server_client_cmd); | |
13424 | install_element(BGP_IPV6_NODE, &neighbor_route_server_client_cmd); | |
13425 | install_element(BGP_IPV6_NODE, &no_neighbor_route_server_client_cmd); | |
13426 | install_element(BGP_IPV6M_NODE, &neighbor_route_server_client_cmd); | |
13427 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_server_client_cmd); | |
13428 | install_element(BGP_IPV6L_NODE, &neighbor_route_server_client_cmd); | |
13429 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_server_client_cmd); | |
13430 | install_element(BGP_VPNV4_NODE, &neighbor_route_server_client_cmd); | |
13431 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_server_client_cmd); | |
13432 | install_element(BGP_VPNV6_NODE, &neighbor_route_server_client_cmd); | |
13433 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_server_client_cmd); | |
a6627c99 LK |
13434 | install_element(BGP_EVPN_NODE, &neighbor_route_server_client_cmd); |
13435 | install_element(BGP_EVPN_NODE, &no_neighbor_route_server_client_cmd); | |
7c40bf39 | 13436 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_server_client_cmd); |
13437 | install_element(BGP_FLOWSPECV4_NODE, | |
13438 | &no_neighbor_route_server_client_cmd); | |
13439 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_server_client_cmd); | |
13440 | install_element(BGP_FLOWSPECV6_NODE, | |
13441 | &no_neighbor_route_server_client_cmd); | |
d62a17ae | 13442 | |
13443 | /* "neighbor addpath-tx-all-paths" commands.*/ | |
13444 | install_element(BGP_NODE, &neighbor_addpath_tx_all_paths_hidden_cmd); | |
13445 | install_element(BGP_NODE, &no_neighbor_addpath_tx_all_paths_hidden_cmd); | |
13446 | install_element(BGP_IPV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13447 | install_element(BGP_IPV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13448 | install_element(BGP_IPV4M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13449 | install_element(BGP_IPV4M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13450 | install_element(BGP_IPV4L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13451 | install_element(BGP_IPV4L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13452 | install_element(BGP_IPV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13453 | install_element(BGP_IPV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13454 | install_element(BGP_IPV6M_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13455 | install_element(BGP_IPV6M_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13456 | install_element(BGP_IPV6L_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13457 | install_element(BGP_IPV6L_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13458 | install_element(BGP_VPNV4_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13459 | install_element(BGP_VPNV4_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13460 | install_element(BGP_VPNV6_NODE, &neighbor_addpath_tx_all_paths_cmd); | |
13461 | install_element(BGP_VPNV6_NODE, &no_neighbor_addpath_tx_all_paths_cmd); | |
13462 | ||
13463 | /* "neighbor addpath-tx-bestpath-per-AS" commands.*/ | |
13464 | install_element(BGP_NODE, | |
13465 | &neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
13466 | install_element(BGP_NODE, | |
13467 | &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd); | |
13468 | install_element(BGP_IPV4_NODE, | |
13469 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13470 | install_element(BGP_IPV4_NODE, | |
13471 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13472 | install_element(BGP_IPV4M_NODE, | |
13473 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13474 | install_element(BGP_IPV4M_NODE, | |
13475 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13476 | install_element(BGP_IPV4L_NODE, | |
13477 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13478 | install_element(BGP_IPV4L_NODE, | |
13479 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13480 | install_element(BGP_IPV6_NODE, | |
13481 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13482 | install_element(BGP_IPV6_NODE, | |
13483 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13484 | install_element(BGP_IPV6M_NODE, | |
13485 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13486 | install_element(BGP_IPV6M_NODE, | |
13487 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13488 | install_element(BGP_IPV6L_NODE, | |
13489 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13490 | install_element(BGP_IPV6L_NODE, | |
13491 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13492 | install_element(BGP_VPNV4_NODE, | |
13493 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13494 | install_element(BGP_VPNV4_NODE, | |
13495 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13496 | install_element(BGP_VPNV6_NODE, | |
13497 | &neighbor_addpath_tx_bestpath_per_as_cmd); | |
13498 | install_element(BGP_VPNV6_NODE, | |
13499 | &no_neighbor_addpath_tx_bestpath_per_as_cmd); | |
13500 | ||
13501 | /* "neighbor passive" commands. */ | |
13502 | install_element(BGP_NODE, &neighbor_passive_cmd); | |
13503 | install_element(BGP_NODE, &no_neighbor_passive_cmd); | |
13504 | ||
13505 | ||
13506 | /* "neighbor shutdown" commands. */ | |
13507 | install_element(BGP_NODE, &neighbor_shutdown_cmd); | |
13508 | install_element(BGP_NODE, &no_neighbor_shutdown_cmd); | |
13509 | install_element(BGP_NODE, &neighbor_shutdown_msg_cmd); | |
13510 | install_element(BGP_NODE, &no_neighbor_shutdown_msg_cmd); | |
13511 | ||
13512 | /* "neighbor capability extended-nexthop" commands.*/ | |
13513 | install_element(BGP_NODE, &neighbor_capability_enhe_cmd); | |
13514 | install_element(BGP_NODE, &no_neighbor_capability_enhe_cmd); | |
13515 | ||
13516 | /* "neighbor capability orf prefix-list" commands.*/ | |
13517 | install_element(BGP_NODE, &neighbor_capability_orf_prefix_hidden_cmd); | |
13518 | install_element(BGP_NODE, | |
13519 | &no_neighbor_capability_orf_prefix_hidden_cmd); | |
13520 | install_element(BGP_IPV4_NODE, &neighbor_capability_orf_prefix_cmd); | |
13521 | install_element(BGP_IPV4_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13522 | install_element(BGP_IPV4M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13523 | install_element(BGP_IPV4M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13524 | install_element(BGP_IPV4L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13525 | install_element(BGP_IPV4L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13526 | install_element(BGP_IPV6_NODE, &neighbor_capability_orf_prefix_cmd); | |
13527 | install_element(BGP_IPV6_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13528 | install_element(BGP_IPV6M_NODE, &neighbor_capability_orf_prefix_cmd); | |
13529 | install_element(BGP_IPV6M_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13530 | install_element(BGP_IPV6L_NODE, &neighbor_capability_orf_prefix_cmd); | |
13531 | install_element(BGP_IPV6L_NODE, &no_neighbor_capability_orf_prefix_cmd); | |
13532 | ||
13533 | /* "neighbor capability dynamic" commands.*/ | |
13534 | install_element(BGP_NODE, &neighbor_capability_dynamic_cmd); | |
13535 | install_element(BGP_NODE, &no_neighbor_capability_dynamic_cmd); | |
13536 | ||
13537 | /* "neighbor dont-capability-negotiate" commands. */ | |
13538 | install_element(BGP_NODE, &neighbor_dont_capability_negotiate_cmd); | |
13539 | install_element(BGP_NODE, &no_neighbor_dont_capability_negotiate_cmd); | |
13540 | ||
13541 | /* "neighbor ebgp-multihop" commands. */ | |
13542 | install_element(BGP_NODE, &neighbor_ebgp_multihop_cmd); | |
13543 | install_element(BGP_NODE, &neighbor_ebgp_multihop_ttl_cmd); | |
13544 | install_element(BGP_NODE, &no_neighbor_ebgp_multihop_cmd); | |
13545 | ||
13546 | /* "neighbor disable-connected-check" commands. */ | |
13547 | install_element(BGP_NODE, &neighbor_disable_connected_check_cmd); | |
13548 | install_element(BGP_NODE, &no_neighbor_disable_connected_check_cmd); | |
13549 | ||
47cbc09b PM |
13550 | /* "neighbor enforce-first-as" commands. */ |
13551 | install_element(BGP_NODE, &neighbor_enforce_first_as_cmd); | |
13552 | install_element(BGP_NODE, &no_neighbor_enforce_first_as_cmd); | |
13553 | ||
d62a17ae | 13554 | /* "neighbor description" commands. */ |
13555 | install_element(BGP_NODE, &neighbor_description_cmd); | |
13556 | install_element(BGP_NODE, &no_neighbor_description_cmd); | |
a14810f4 | 13557 | install_element(BGP_NODE, &no_neighbor_description_comment_cmd); |
d62a17ae | 13558 | |
13559 | /* "neighbor update-source" commands. "*/ | |
13560 | install_element(BGP_NODE, &neighbor_update_source_cmd); | |
13561 | install_element(BGP_NODE, &no_neighbor_update_source_cmd); | |
13562 | ||
13563 | /* "neighbor default-originate" commands. */ | |
13564 | install_element(BGP_NODE, &neighbor_default_originate_hidden_cmd); | |
13565 | install_element(BGP_NODE, &neighbor_default_originate_rmap_hidden_cmd); | |
13566 | install_element(BGP_NODE, &no_neighbor_default_originate_hidden_cmd); | |
13567 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_cmd); | |
13568 | install_element(BGP_IPV4_NODE, &neighbor_default_originate_rmap_cmd); | |
13569 | install_element(BGP_IPV4_NODE, &no_neighbor_default_originate_cmd); | |
13570 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_cmd); | |
13571 | install_element(BGP_IPV4M_NODE, &neighbor_default_originate_rmap_cmd); | |
13572 | install_element(BGP_IPV4M_NODE, &no_neighbor_default_originate_cmd); | |
13573 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_cmd); | |
13574 | install_element(BGP_IPV4L_NODE, &neighbor_default_originate_rmap_cmd); | |
13575 | install_element(BGP_IPV4L_NODE, &no_neighbor_default_originate_cmd); | |
13576 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_cmd); | |
13577 | install_element(BGP_IPV6_NODE, &neighbor_default_originate_rmap_cmd); | |
13578 | install_element(BGP_IPV6_NODE, &no_neighbor_default_originate_cmd); | |
13579 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_cmd); | |
13580 | install_element(BGP_IPV6M_NODE, &neighbor_default_originate_rmap_cmd); | |
13581 | install_element(BGP_IPV6M_NODE, &no_neighbor_default_originate_cmd); | |
13582 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_cmd); | |
13583 | install_element(BGP_IPV6L_NODE, &neighbor_default_originate_rmap_cmd); | |
13584 | install_element(BGP_IPV6L_NODE, &no_neighbor_default_originate_cmd); | |
13585 | ||
13586 | /* "neighbor port" commands. */ | |
13587 | install_element(BGP_NODE, &neighbor_port_cmd); | |
13588 | install_element(BGP_NODE, &no_neighbor_port_cmd); | |
13589 | ||
13590 | /* "neighbor weight" commands. */ | |
13591 | install_element(BGP_NODE, &neighbor_weight_hidden_cmd); | |
13592 | install_element(BGP_NODE, &no_neighbor_weight_hidden_cmd); | |
13593 | ||
13594 | install_element(BGP_IPV4_NODE, &neighbor_weight_cmd); | |
13595 | install_element(BGP_IPV4_NODE, &no_neighbor_weight_cmd); | |
13596 | install_element(BGP_IPV4M_NODE, &neighbor_weight_cmd); | |
13597 | install_element(BGP_IPV4M_NODE, &no_neighbor_weight_cmd); | |
13598 | install_element(BGP_IPV4L_NODE, &neighbor_weight_cmd); | |
13599 | install_element(BGP_IPV4L_NODE, &no_neighbor_weight_cmd); | |
13600 | install_element(BGP_IPV6_NODE, &neighbor_weight_cmd); | |
13601 | install_element(BGP_IPV6_NODE, &no_neighbor_weight_cmd); | |
13602 | install_element(BGP_IPV6M_NODE, &neighbor_weight_cmd); | |
13603 | install_element(BGP_IPV6M_NODE, &no_neighbor_weight_cmd); | |
13604 | install_element(BGP_IPV6L_NODE, &neighbor_weight_cmd); | |
13605 | install_element(BGP_IPV6L_NODE, &no_neighbor_weight_cmd); | |
13606 | install_element(BGP_VPNV4_NODE, &neighbor_weight_cmd); | |
13607 | install_element(BGP_VPNV4_NODE, &no_neighbor_weight_cmd); | |
13608 | install_element(BGP_VPNV6_NODE, &neighbor_weight_cmd); | |
13609 | install_element(BGP_VPNV6_NODE, &no_neighbor_weight_cmd); | |
13610 | ||
13611 | /* "neighbor override-capability" commands. */ | |
13612 | install_element(BGP_NODE, &neighbor_override_capability_cmd); | |
13613 | install_element(BGP_NODE, &no_neighbor_override_capability_cmd); | |
13614 | ||
13615 | /* "neighbor strict-capability-match" commands. */ | |
13616 | install_element(BGP_NODE, &neighbor_strict_capability_cmd); | |
13617 | install_element(BGP_NODE, &no_neighbor_strict_capability_cmd); | |
13618 | ||
13619 | /* "neighbor timers" commands. */ | |
13620 | install_element(BGP_NODE, &neighbor_timers_cmd); | |
13621 | install_element(BGP_NODE, &no_neighbor_timers_cmd); | |
13622 | ||
13623 | /* "neighbor timers connect" commands. */ | |
13624 | install_element(BGP_NODE, &neighbor_timers_connect_cmd); | |
13625 | install_element(BGP_NODE, &no_neighbor_timers_connect_cmd); | |
13626 | ||
13627 | /* "neighbor advertisement-interval" commands. */ | |
13628 | install_element(BGP_NODE, &neighbor_advertise_interval_cmd); | |
13629 | install_element(BGP_NODE, &no_neighbor_advertise_interval_cmd); | |
13630 | ||
13631 | /* "neighbor interface" commands. */ | |
13632 | install_element(BGP_NODE, &neighbor_interface_cmd); | |
13633 | install_element(BGP_NODE, &no_neighbor_interface_cmd); | |
13634 | ||
13635 | /* "neighbor distribute" commands. */ | |
13636 | install_element(BGP_NODE, &neighbor_distribute_list_hidden_cmd); | |
13637 | install_element(BGP_NODE, &no_neighbor_distribute_list_hidden_cmd); | |
13638 | install_element(BGP_IPV4_NODE, &neighbor_distribute_list_cmd); | |
13639 | install_element(BGP_IPV4_NODE, &no_neighbor_distribute_list_cmd); | |
13640 | install_element(BGP_IPV4M_NODE, &neighbor_distribute_list_cmd); | |
13641 | install_element(BGP_IPV4M_NODE, &no_neighbor_distribute_list_cmd); | |
13642 | install_element(BGP_IPV4L_NODE, &neighbor_distribute_list_cmd); | |
13643 | install_element(BGP_IPV4L_NODE, &no_neighbor_distribute_list_cmd); | |
13644 | install_element(BGP_IPV6_NODE, &neighbor_distribute_list_cmd); | |
13645 | install_element(BGP_IPV6_NODE, &no_neighbor_distribute_list_cmd); | |
13646 | install_element(BGP_IPV6M_NODE, &neighbor_distribute_list_cmd); | |
13647 | install_element(BGP_IPV6M_NODE, &no_neighbor_distribute_list_cmd); | |
13648 | install_element(BGP_IPV6L_NODE, &neighbor_distribute_list_cmd); | |
13649 | install_element(BGP_IPV6L_NODE, &no_neighbor_distribute_list_cmd); | |
13650 | install_element(BGP_VPNV4_NODE, &neighbor_distribute_list_cmd); | |
13651 | install_element(BGP_VPNV4_NODE, &no_neighbor_distribute_list_cmd); | |
13652 | install_element(BGP_VPNV6_NODE, &neighbor_distribute_list_cmd); | |
13653 | install_element(BGP_VPNV6_NODE, &no_neighbor_distribute_list_cmd); | |
13654 | ||
13655 | /* "neighbor prefix-list" commands. */ | |
13656 | install_element(BGP_NODE, &neighbor_prefix_list_hidden_cmd); | |
13657 | install_element(BGP_NODE, &no_neighbor_prefix_list_hidden_cmd); | |
13658 | install_element(BGP_IPV4_NODE, &neighbor_prefix_list_cmd); | |
13659 | install_element(BGP_IPV4_NODE, &no_neighbor_prefix_list_cmd); | |
13660 | install_element(BGP_IPV4M_NODE, &neighbor_prefix_list_cmd); | |
13661 | install_element(BGP_IPV4M_NODE, &no_neighbor_prefix_list_cmd); | |
13662 | install_element(BGP_IPV4L_NODE, &neighbor_prefix_list_cmd); | |
13663 | install_element(BGP_IPV4L_NODE, &no_neighbor_prefix_list_cmd); | |
13664 | install_element(BGP_IPV6_NODE, &neighbor_prefix_list_cmd); | |
13665 | install_element(BGP_IPV6_NODE, &no_neighbor_prefix_list_cmd); | |
13666 | install_element(BGP_IPV6M_NODE, &neighbor_prefix_list_cmd); | |
13667 | install_element(BGP_IPV6M_NODE, &no_neighbor_prefix_list_cmd); | |
13668 | install_element(BGP_IPV6L_NODE, &neighbor_prefix_list_cmd); | |
13669 | install_element(BGP_IPV6L_NODE, &no_neighbor_prefix_list_cmd); | |
13670 | install_element(BGP_VPNV4_NODE, &neighbor_prefix_list_cmd); | |
13671 | install_element(BGP_VPNV4_NODE, &no_neighbor_prefix_list_cmd); | |
13672 | install_element(BGP_VPNV6_NODE, &neighbor_prefix_list_cmd); | |
13673 | install_element(BGP_VPNV6_NODE, &no_neighbor_prefix_list_cmd); | |
7c40bf39 | 13674 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_prefix_list_cmd); |
13675 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_prefix_list_cmd); | |
13676 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_prefix_list_cmd); | |
13677 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_prefix_list_cmd); | |
d62a17ae | 13678 | |
13679 | /* "neighbor filter-list" commands. */ | |
13680 | install_element(BGP_NODE, &neighbor_filter_list_hidden_cmd); | |
13681 | install_element(BGP_NODE, &no_neighbor_filter_list_hidden_cmd); | |
13682 | install_element(BGP_IPV4_NODE, &neighbor_filter_list_cmd); | |
13683 | install_element(BGP_IPV4_NODE, &no_neighbor_filter_list_cmd); | |
13684 | install_element(BGP_IPV4M_NODE, &neighbor_filter_list_cmd); | |
13685 | install_element(BGP_IPV4M_NODE, &no_neighbor_filter_list_cmd); | |
13686 | install_element(BGP_IPV4L_NODE, &neighbor_filter_list_cmd); | |
13687 | install_element(BGP_IPV4L_NODE, &no_neighbor_filter_list_cmd); | |
13688 | install_element(BGP_IPV6_NODE, &neighbor_filter_list_cmd); | |
13689 | install_element(BGP_IPV6_NODE, &no_neighbor_filter_list_cmd); | |
13690 | install_element(BGP_IPV6M_NODE, &neighbor_filter_list_cmd); | |
13691 | install_element(BGP_IPV6M_NODE, &no_neighbor_filter_list_cmd); | |
13692 | install_element(BGP_IPV6L_NODE, &neighbor_filter_list_cmd); | |
13693 | install_element(BGP_IPV6L_NODE, &no_neighbor_filter_list_cmd); | |
13694 | install_element(BGP_VPNV4_NODE, &neighbor_filter_list_cmd); | |
13695 | install_element(BGP_VPNV4_NODE, &no_neighbor_filter_list_cmd); | |
13696 | install_element(BGP_VPNV6_NODE, &neighbor_filter_list_cmd); | |
13697 | install_element(BGP_VPNV6_NODE, &no_neighbor_filter_list_cmd); | |
7c40bf39 | 13698 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_filter_list_cmd); |
13699 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_filter_list_cmd); | |
13700 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_filter_list_cmd); | |
13701 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_filter_list_cmd); | |
d62a17ae | 13702 | |
13703 | /* "neighbor route-map" commands. */ | |
13704 | install_element(BGP_NODE, &neighbor_route_map_hidden_cmd); | |
13705 | install_element(BGP_NODE, &no_neighbor_route_map_hidden_cmd); | |
13706 | install_element(BGP_IPV4_NODE, &neighbor_route_map_cmd); | |
13707 | install_element(BGP_IPV4_NODE, &no_neighbor_route_map_cmd); | |
13708 | install_element(BGP_IPV4M_NODE, &neighbor_route_map_cmd); | |
13709 | install_element(BGP_IPV4M_NODE, &no_neighbor_route_map_cmd); | |
13710 | install_element(BGP_IPV4L_NODE, &neighbor_route_map_cmd); | |
13711 | install_element(BGP_IPV4L_NODE, &no_neighbor_route_map_cmd); | |
13712 | install_element(BGP_IPV6_NODE, &neighbor_route_map_cmd); | |
13713 | install_element(BGP_IPV6_NODE, &no_neighbor_route_map_cmd); | |
13714 | install_element(BGP_IPV6M_NODE, &neighbor_route_map_cmd); | |
13715 | install_element(BGP_IPV6M_NODE, &no_neighbor_route_map_cmd); | |
13716 | install_element(BGP_IPV6L_NODE, &neighbor_route_map_cmd); | |
13717 | install_element(BGP_IPV6L_NODE, &no_neighbor_route_map_cmd); | |
13718 | install_element(BGP_VPNV4_NODE, &neighbor_route_map_cmd); | |
13719 | install_element(BGP_VPNV4_NODE, &no_neighbor_route_map_cmd); | |
13720 | install_element(BGP_VPNV6_NODE, &neighbor_route_map_cmd); | |
13721 | install_element(BGP_VPNV6_NODE, &no_neighbor_route_map_cmd); | |
7c40bf39 | 13722 | install_element(BGP_FLOWSPECV4_NODE, &neighbor_route_map_cmd); |
13723 | install_element(BGP_FLOWSPECV4_NODE, &no_neighbor_route_map_cmd); | |
13724 | install_element(BGP_FLOWSPECV6_NODE, &neighbor_route_map_cmd); | |
13725 | install_element(BGP_FLOWSPECV6_NODE, &no_neighbor_route_map_cmd); | |
d37ba549 MK |
13726 | install_element(BGP_EVPN_NODE, &neighbor_route_map_cmd); |
13727 | install_element(BGP_EVPN_NODE, &no_neighbor_route_map_cmd); | |
d62a17ae | 13728 | |
13729 | /* "neighbor unsuppress-map" commands. */ | |
13730 | install_element(BGP_NODE, &neighbor_unsuppress_map_hidden_cmd); | |
13731 | install_element(BGP_NODE, &no_neighbor_unsuppress_map_hidden_cmd); | |
13732 | install_element(BGP_IPV4_NODE, &neighbor_unsuppress_map_cmd); | |
13733 | install_element(BGP_IPV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13734 | install_element(BGP_IPV4M_NODE, &neighbor_unsuppress_map_cmd); | |
13735 | install_element(BGP_IPV4M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13736 | install_element(BGP_IPV4L_NODE, &neighbor_unsuppress_map_cmd); | |
13737 | install_element(BGP_IPV4L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13738 | install_element(BGP_IPV6_NODE, &neighbor_unsuppress_map_cmd); | |
13739 | install_element(BGP_IPV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13740 | install_element(BGP_IPV6M_NODE, &neighbor_unsuppress_map_cmd); | |
13741 | install_element(BGP_IPV6M_NODE, &no_neighbor_unsuppress_map_cmd); | |
13742 | install_element(BGP_IPV6L_NODE, &neighbor_unsuppress_map_cmd); | |
13743 | install_element(BGP_IPV6L_NODE, &no_neighbor_unsuppress_map_cmd); | |
13744 | install_element(BGP_VPNV4_NODE, &neighbor_unsuppress_map_cmd); | |
13745 | install_element(BGP_VPNV4_NODE, &no_neighbor_unsuppress_map_cmd); | |
13746 | install_element(BGP_VPNV6_NODE, &neighbor_unsuppress_map_cmd); | |
13747 | install_element(BGP_VPNV6_NODE, &no_neighbor_unsuppress_map_cmd); | |
13748 | ||
13749 | /* "neighbor maximum-prefix" commands. */ | |
13750 | install_element(BGP_NODE, &neighbor_maximum_prefix_hidden_cmd); | |
13751 | install_element(BGP_NODE, | |
13752 | &neighbor_maximum_prefix_threshold_hidden_cmd); | |
13753 | install_element(BGP_NODE, &neighbor_maximum_prefix_warning_hidden_cmd); | |
13754 | install_element(BGP_NODE, | |
13755 | &neighbor_maximum_prefix_threshold_warning_hidden_cmd); | |
13756 | install_element(BGP_NODE, &neighbor_maximum_prefix_restart_hidden_cmd); | |
13757 | install_element(BGP_NODE, | |
13758 | &neighbor_maximum_prefix_threshold_restart_hidden_cmd); | |
13759 | install_element(BGP_NODE, &no_neighbor_maximum_prefix_hidden_cmd); | |
13760 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_cmd); | |
13761 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13762 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13763 | install_element(BGP_IPV4_NODE, | |
13764 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13765 | install_element(BGP_IPV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13766 | install_element(BGP_IPV4_NODE, | |
13767 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13768 | install_element(BGP_IPV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13769 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_cmd); | |
13770 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13771 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13772 | install_element(BGP_IPV4M_NODE, | |
13773 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13774 | install_element(BGP_IPV4M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13775 | install_element(BGP_IPV4M_NODE, | |
13776 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13777 | install_element(BGP_IPV4M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13778 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_cmd); | |
13779 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13780 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13781 | install_element(BGP_IPV4L_NODE, | |
13782 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13783 | install_element(BGP_IPV4L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13784 | install_element(BGP_IPV4L_NODE, | |
13785 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13786 | install_element(BGP_IPV4L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13787 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_cmd); | |
13788 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13789 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13790 | install_element(BGP_IPV6_NODE, | |
13791 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13792 | install_element(BGP_IPV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13793 | install_element(BGP_IPV6_NODE, | |
13794 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13795 | install_element(BGP_IPV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13796 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_cmd); | |
13797 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13798 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13799 | install_element(BGP_IPV6M_NODE, | |
13800 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13801 | install_element(BGP_IPV6M_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13802 | install_element(BGP_IPV6M_NODE, | |
13803 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13804 | install_element(BGP_IPV6M_NODE, &no_neighbor_maximum_prefix_cmd); | |
13805 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_cmd); | |
13806 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13807 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13808 | install_element(BGP_IPV6L_NODE, | |
13809 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13810 | install_element(BGP_IPV6L_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13811 | install_element(BGP_IPV6L_NODE, | |
13812 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13813 | install_element(BGP_IPV6L_NODE, &no_neighbor_maximum_prefix_cmd); | |
13814 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_cmd); | |
13815 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13816 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13817 | install_element(BGP_VPNV4_NODE, | |
13818 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13819 | install_element(BGP_VPNV4_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13820 | install_element(BGP_VPNV4_NODE, | |
13821 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13822 | install_element(BGP_VPNV4_NODE, &no_neighbor_maximum_prefix_cmd); | |
13823 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_cmd); | |
13824 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_threshold_cmd); | |
13825 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_warning_cmd); | |
13826 | install_element(BGP_VPNV6_NODE, | |
13827 | &neighbor_maximum_prefix_threshold_warning_cmd); | |
13828 | install_element(BGP_VPNV6_NODE, &neighbor_maximum_prefix_restart_cmd); | |
13829 | install_element(BGP_VPNV6_NODE, | |
13830 | &neighbor_maximum_prefix_threshold_restart_cmd); | |
13831 | install_element(BGP_VPNV6_NODE, &no_neighbor_maximum_prefix_cmd); | |
13832 | ||
13833 | /* "neighbor allowas-in" */ | |
13834 | install_element(BGP_NODE, &neighbor_allowas_in_hidden_cmd); | |
13835 | install_element(BGP_NODE, &no_neighbor_allowas_in_hidden_cmd); | |
13836 | install_element(BGP_IPV4_NODE, &neighbor_allowas_in_cmd); | |
13837 | install_element(BGP_IPV4_NODE, &no_neighbor_allowas_in_cmd); | |
13838 | install_element(BGP_IPV4M_NODE, &neighbor_allowas_in_cmd); | |
13839 | install_element(BGP_IPV4M_NODE, &no_neighbor_allowas_in_cmd); | |
13840 | install_element(BGP_IPV4L_NODE, &neighbor_allowas_in_cmd); | |
13841 | install_element(BGP_IPV4L_NODE, &no_neighbor_allowas_in_cmd); | |
13842 | install_element(BGP_IPV6_NODE, &neighbor_allowas_in_cmd); | |
13843 | install_element(BGP_IPV6_NODE, &no_neighbor_allowas_in_cmd); | |
13844 | install_element(BGP_IPV6M_NODE, &neighbor_allowas_in_cmd); | |
13845 | install_element(BGP_IPV6M_NODE, &no_neighbor_allowas_in_cmd); | |
13846 | install_element(BGP_IPV6L_NODE, &neighbor_allowas_in_cmd); | |
13847 | install_element(BGP_IPV6L_NODE, &no_neighbor_allowas_in_cmd); | |
13848 | install_element(BGP_VPNV4_NODE, &neighbor_allowas_in_cmd); | |
13849 | install_element(BGP_VPNV4_NODE, &no_neighbor_allowas_in_cmd); | |
13850 | install_element(BGP_VPNV6_NODE, &neighbor_allowas_in_cmd); | |
13851 | install_element(BGP_VPNV6_NODE, &no_neighbor_allowas_in_cmd); | |
13852 | install_element(BGP_EVPN_NODE, &neighbor_allowas_in_cmd); | |
13853 | install_element(BGP_EVPN_NODE, &no_neighbor_allowas_in_cmd); | |
13854 | ||
13855 | /* address-family commands. */ | |
13856 | install_element(BGP_NODE, &address_family_ipv4_safi_cmd); | |
13857 | install_element(BGP_NODE, &address_family_ipv6_safi_cmd); | |
d6902373 | 13858 | #ifdef KEEP_OLD_VPN_COMMANDS |
d62a17ae | 13859 | install_element(BGP_NODE, &address_family_vpnv4_cmd); |
13860 | install_element(BGP_NODE, &address_family_vpnv6_cmd); | |
d6902373 | 13861 | #endif /* KEEP_OLD_VPN_COMMANDS */ |
8b1fb8be | 13862 | |
d62a17ae | 13863 | install_element(BGP_NODE, &address_family_evpn_cmd); |
13864 | ||
13865 | /* "exit-address-family" command. */ | |
13866 | install_element(BGP_IPV4_NODE, &exit_address_family_cmd); | |
13867 | install_element(BGP_IPV4M_NODE, &exit_address_family_cmd); | |
13868 | install_element(BGP_IPV4L_NODE, &exit_address_family_cmd); | |
13869 | install_element(BGP_IPV6_NODE, &exit_address_family_cmd); | |
13870 | install_element(BGP_IPV6M_NODE, &exit_address_family_cmd); | |
13871 | install_element(BGP_IPV6L_NODE, &exit_address_family_cmd); | |
13872 | install_element(BGP_VPNV4_NODE, &exit_address_family_cmd); | |
13873 | install_element(BGP_VPNV6_NODE, &exit_address_family_cmd); | |
7c40bf39 | 13874 | install_element(BGP_FLOWSPECV4_NODE, &exit_address_family_cmd); |
13875 | install_element(BGP_FLOWSPECV6_NODE, &exit_address_family_cmd); | |
d62a17ae | 13876 | install_element(BGP_EVPN_NODE, &exit_address_family_cmd); |
13877 | ||
13878 | /* "clear ip bgp commands" */ | |
13879 | install_element(ENABLE_NODE, &clear_ip_bgp_all_cmd); | |
13880 | ||
13881 | /* clear ip bgp prefix */ | |
13882 | install_element(ENABLE_NODE, &clear_ip_bgp_prefix_cmd); | |
13883 | install_element(ENABLE_NODE, &clear_bgp_ipv6_safi_prefix_cmd); | |
13884 | install_element(ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); | |
13885 | ||
13886 | /* "show [ip] bgp summary" commands. */ | |
13887 | install_element(VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); | |
43d3f4fc | 13888 | install_element(VIEW_NODE, &show_bgp_l2vpn_evpn_updgrps_cmd); |
d62a17ae | 13889 | install_element(VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); |
d62a17ae | 13890 | install_element(VIEW_NODE, &show_bgp_updgrps_stats_cmd); |
d62a17ae | 13891 | install_element(VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); |
13892 | install_element(VIEW_NODE, &show_ip_bgp_summary_cmd); | |
d62a17ae | 13893 | install_element(VIEW_NODE, &show_ip_bgp_updgrps_cmd); |
13894 | ||
13895 | /* "show [ip] bgp neighbors" commands. */ | |
13896 | install_element(VIEW_NODE, &show_ip_bgp_neighbors_cmd); | |
13897 | ||
13898 | /* "show [ip] bgp peer-group" commands. */ | |
13899 | install_element(VIEW_NODE, &show_ip_bgp_peer_groups_cmd); | |
13900 | ||
13901 | /* "show [ip] bgp paths" commands. */ | |
13902 | install_element(VIEW_NODE, &show_ip_bgp_paths_cmd); | |
13903 | ||
13904 | /* "show [ip] bgp community" commands. */ | |
13905 | install_element(VIEW_NODE, &show_ip_bgp_community_info_cmd); | |
13906 | ||
13907 | /* "show ip bgp large-community" commands. */ | |
13908 | install_element(VIEW_NODE, &show_ip_bgp_lcommunity_info_cmd); | |
13909 | /* "show [ip] bgp attribute-info" commands. */ | |
13910 | install_element(VIEW_NODE, &show_ip_bgp_attr_info_cmd); | |
53089bec | 13911 | /* "show [ip] bgp route-leak" command */ |
13912 | install_element(VIEW_NODE, &show_ip_bgp_route_leak_cmd); | |
d62a17ae | 13913 | |
13914 | /* "redistribute" commands. */ | |
13915 | install_element(BGP_NODE, &bgp_redistribute_ipv4_hidden_cmd); | |
13916 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_hidden_cmd); | |
13917 | install_element(BGP_NODE, &bgp_redistribute_ipv4_rmap_hidden_cmd); | |
13918 | install_element(BGP_NODE, &bgp_redistribute_ipv4_metric_hidden_cmd); | |
13919 | install_element(BGP_NODE, | |
13920 | &bgp_redistribute_ipv4_rmap_metric_hidden_cmd); | |
13921 | install_element(BGP_NODE, | |
13922 | &bgp_redistribute_ipv4_metric_rmap_hidden_cmd); | |
13923 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_hidden_cmd); | |
13924 | install_element(BGP_NODE, &no_bgp_redistribute_ipv4_ospf_hidden_cmd); | |
13925 | install_element(BGP_NODE, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd); | |
13926 | install_element(BGP_NODE, | |
13927 | &bgp_redistribute_ipv4_ospf_metric_hidden_cmd); | |
13928 | install_element(BGP_NODE, | |
13929 | &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd); | |
13930 | install_element(BGP_NODE, | |
13931 | &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd); | |
13932 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_cmd); | |
13933 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_cmd); | |
13934 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_cmd); | |
13935 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_cmd); | |
13936 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_rmap_metric_cmd); | |
13937 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_metric_rmap_cmd); | |
13938 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_cmd); | |
13939 | install_element(BGP_IPV4_NODE, &no_bgp_redistribute_ipv4_ospf_cmd); | |
13940 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_cmd); | |
13941 | install_element(BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); | |
13942 | install_element(BGP_IPV4_NODE, | |
13943 | &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); | |
13944 | install_element(BGP_IPV4_NODE, | |
13945 | &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); | |
13946 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); | |
13947 | install_element(BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); | |
13948 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); | |
13949 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); | |
13950 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); | |
13951 | install_element(BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); | |
13952 | ||
b9c7bc5a PZ |
13953 | /* import|export vpn [route-map WORD] */ |
13954 | install_element(BGP_IPV4_NODE, &bgp_imexport_vpn_cmd); | |
13955 | install_element(BGP_IPV6_NODE, &bgp_imexport_vpn_cmd); | |
ddb5b488 | 13956 | |
12a844a5 DS |
13957 | install_element(BGP_IPV4_NODE, &bgp_imexport_vrf_cmd); |
13958 | install_element(BGP_IPV6_NODE, &bgp_imexport_vrf_cmd); | |
13959 | ||
d62a17ae | 13960 | /* ttl_security commands */ |
13961 | install_element(BGP_NODE, &neighbor_ttl_security_cmd); | |
13962 | install_element(BGP_NODE, &no_neighbor_ttl_security_cmd); | |
13963 | ||
13964 | /* "show [ip] bgp memory" commands. */ | |
13965 | install_element(VIEW_NODE, &show_bgp_memory_cmd); | |
13966 | ||
acf71666 MK |
13967 | /* "show bgp martian next-hop" */ |
13968 | install_element(VIEW_NODE, &show_bgp_martian_nexthop_db_cmd); | |
13969 | ||
48ecf8f5 DS |
13970 | install_element(VIEW_NODE, &show_bgp_mac_hash_cmd); |
13971 | ||
d62a17ae | 13972 | /* "show [ip] bgp views" commands. */ |
13973 | install_element(VIEW_NODE, &show_bgp_views_cmd); | |
13974 | ||
13975 | /* "show [ip] bgp vrfs" commands. */ | |
13976 | install_element(VIEW_NODE, &show_bgp_vrfs_cmd); | |
13977 | ||
13978 | /* Community-list. */ | |
13979 | community_list_vty(); | |
ddb5b488 PZ |
13980 | |
13981 | /* vpn-policy commands */ | |
b9c7bc5a PZ |
13982 | install_element(BGP_IPV4_NODE, &af_rd_vpn_export_cmd); |
13983 | install_element(BGP_IPV6_NODE, &af_rd_vpn_export_cmd); | |
13984 | install_element(BGP_IPV4_NODE, &af_label_vpn_export_cmd); | |
13985 | install_element(BGP_IPV6_NODE, &af_label_vpn_export_cmd); | |
13986 | install_element(BGP_IPV4_NODE, &af_nexthop_vpn_export_cmd); | |
13987 | install_element(BGP_IPV6_NODE, &af_nexthop_vpn_export_cmd); | |
13988 | install_element(BGP_IPV4_NODE, &af_rt_vpn_imexport_cmd); | |
13989 | install_element(BGP_IPV6_NODE, &af_rt_vpn_imexport_cmd); | |
13990 | install_element(BGP_IPV4_NODE, &af_route_map_vpn_imexport_cmd); | |
13991 | install_element(BGP_IPV6_NODE, &af_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
13992 | install_element(BGP_IPV4_NODE, &af_import_vrf_route_map_cmd); |
13993 | install_element(BGP_IPV6_NODE, &af_import_vrf_route_map_cmd); | |
b9c7bc5a | 13994 | |
301ad80a PG |
13995 | install_element(BGP_IPV4_NODE, &af_routetarget_import_cmd); |
13996 | install_element(BGP_IPV6_NODE, &af_routetarget_import_cmd); | |
13997 | ||
b9c7bc5a PZ |
13998 | install_element(BGP_IPV4_NODE, &af_no_rd_vpn_export_cmd); |
13999 | install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); | |
14000 | install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); | |
14001 | install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); | |
14002 | install_element(BGP_IPV4_NODE, &af_no_nexthop_vpn_export_cmd); | |
14003 | install_element(BGP_IPV6_NODE, &af_no_nexthop_vpn_export_cmd); | |
14004 | install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); | |
14005 | install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); | |
14006 | install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); | |
14007 | install_element(BGP_IPV6_NODE, &af_no_route_map_vpn_imexport_cmd); | |
bb4f6190 DS |
14008 | install_element(BGP_IPV4_NODE, &af_no_import_vrf_route_map_cmd); |
14009 | install_element(BGP_IPV6_NODE, &af_no_import_vrf_route_map_cmd); | |
718e3744 | 14010 | } |
6b0655a2 | 14011 | |
718e3744 | 14012 | #include "memory.h" |
14013 | #include "bgp_regex.h" | |
14014 | #include "bgp_clist.h" | |
14015 | #include "bgp_ecommunity.h" | |
14016 | ||
14017 | /* VTY functions. */ | |
14018 | ||
14019 | /* Direction value to string conversion. */ | |
d62a17ae | 14020 | static const char *community_direct_str(int direct) |
14021 | { | |
14022 | switch (direct) { | |
14023 | case COMMUNITY_DENY: | |
14024 | return "deny"; | |
14025 | case COMMUNITY_PERMIT: | |
14026 | return "permit"; | |
14027 | default: | |
14028 | return "unknown"; | |
14029 | } | |
718e3744 | 14030 | } |
14031 | ||
14032 | /* Display error string. */ | |
d62a17ae | 14033 | static void community_list_perror(struct vty *vty, int ret) |
14034 | { | |
14035 | switch (ret) { | |
14036 | case COMMUNITY_LIST_ERR_CANT_FIND_LIST: | |
14037 | vty_out(vty, "%% Can't find community-list\n"); | |
14038 | break; | |
14039 | case COMMUNITY_LIST_ERR_MALFORMED_VAL: | |
14040 | vty_out(vty, "%% Malformed community-list value\n"); | |
14041 | break; | |
14042 | case COMMUNITY_LIST_ERR_STANDARD_CONFLICT: | |
14043 | vty_out(vty, | |
14044 | "%% Community name conflict, previously defined as standard community\n"); | |
14045 | break; | |
14046 | case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT: | |
14047 | vty_out(vty, | |
14048 | "%% Community name conflict, previously defined as expanded community\n"); | |
14049 | break; | |
14050 | } | |
718e3744 | 14051 | } |
14052 | ||
5bf15956 DW |
14053 | /* "community-list" keyword help string. */ |
14054 | #define COMMUNITY_LIST_STR "Add a community list entry\n" | |
14055 | ||
7336e101 SP |
14056 | /*community-list standard */ |
14057 | DEFUN (community_list_standard, | |
14058 | bgp_community_list_standard_cmd, | |
14059 | "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14060 | BGP_STR | |
718e3744 | 14061 | COMMUNITY_LIST_STR |
14062 | "Community list number (standard)\n" | |
5bf15956 | 14063 | "Add an standard community-list entry\n" |
718e3744 | 14064 | "Community list name\n" |
14065 | "Specify community to reject\n" | |
14066 | "Specify community to accept\n" | |
14067 | COMMUNITY_VAL_STR) | |
14068 | { | |
d62a17ae | 14069 | char *cl_name_or_number = NULL; |
14070 | int direct = 0; | |
14071 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 14072 | |
d62a17ae | 14073 | int idx = 0; |
7336e101 SP |
14074 | |
14075 | if (argv_find(argv, argc, "ip", &idx)) { | |
14076 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14077 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14078 | vty_out(vty, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
14079 | zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
14080 | } | |
14081 | ||
d62a17ae | 14082 | argv_find(argv, argc, "(1-99)", &idx); |
14083 | argv_find(argv, argc, "WORD", &idx); | |
14084 | cl_name_or_number = argv[idx]->arg; | |
14085 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14086 | : COMMUNITY_DENY; | |
14087 | argv_find(argv, argc, "AA:NN", &idx); | |
14088 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14089 | |
d62a17ae | 14090 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
14091 | style); | |
42f914d4 | 14092 | |
d62a17ae | 14093 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14094 | |
d62a17ae | 14095 | if (ret < 0) { |
14096 | /* Display error string. */ | |
14097 | community_list_perror(vty, ret); | |
14098 | return CMD_WARNING_CONFIG_FAILED; | |
14099 | } | |
42f914d4 | 14100 | |
d62a17ae | 14101 | return CMD_SUCCESS; |
718e3744 | 14102 | } |
14103 | ||
7336e101 SP |
14104 | #if CONFDATE > 20191005 |
14105 | CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command") | |
14106 | #endif | |
14107 | ALIAS (community_list_standard, | |
14108 | ip_community_list_standard_cmd, | |
14109 | "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 14110 | IP_STR |
14111 | COMMUNITY_LIST_STR | |
14112 | "Community list number (standard)\n" | |
5bf15956 DW |
14113 | "Add an standard community-list entry\n" |
14114 | "Community list name\n" | |
718e3744 | 14115 | "Specify community to reject\n" |
14116 | "Specify community to accept\n" | |
14117 | COMMUNITY_VAL_STR) | |
7336e101 SP |
14118 | |
14119 | DEFUN (no_community_list_standard_all, | |
14120 | no_bgp_community_list_standard_all_cmd, | |
14121 | "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14122 | NO_STR | |
14123 | BGP_STR | |
14124 | COMMUNITY_LIST_STR | |
14125 | "Community list number (standard)\n" | |
14126 | "Add an standard community-list entry\n" | |
14127 | "Community list name\n" | |
14128 | "Specify community to reject\n" | |
14129 | "Specify community to accept\n" | |
14130 | COMMUNITY_VAL_STR) | |
718e3744 | 14131 | { |
d62a17ae | 14132 | char *cl_name_or_number = NULL; |
174b5cb9 | 14133 | char *str = NULL; |
d62a17ae | 14134 | int direct = 0; |
14135 | int style = COMMUNITY_LIST_STANDARD; | |
42f914d4 | 14136 | |
d62a17ae | 14137 | int idx = 0; |
7336e101 SP |
14138 | |
14139 | if (argv_find(argv, argc, "ip", &idx)) { | |
14140 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
14141 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14142 | vty_out(vty, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
14143 | zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used"); | |
14144 | } | |
14145 | ||
174b5cb9 DA |
14146 | argv_find(argv, argc, "permit", &idx); |
14147 | argv_find(argv, argc, "deny", &idx); | |
14148 | ||
14149 | if (idx) { | |
14150 | direct = argv_find(argv, argc, "permit", &idx) | |
14151 | ? COMMUNITY_PERMIT | |
14152 | : COMMUNITY_DENY; | |
14153 | ||
14154 | idx = 0; | |
14155 | argv_find(argv, argc, "AA:NN", &idx); | |
14156 | str = argv_concat(argv, argc, idx); | |
14157 | } | |
14158 | ||
14159 | idx = 0; | |
d62a17ae | 14160 | argv_find(argv, argc, "(1-99)", &idx); |
14161 | argv_find(argv, argc, "WORD", &idx); | |
14162 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 14163 | |
d62a17ae | 14164 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 14165 | direct, style); |
42f914d4 | 14166 | |
d62a17ae | 14167 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 14168 | |
d62a17ae | 14169 | if (ret < 0) { |
14170 | community_list_perror(vty, ret); | |
14171 | return CMD_WARNING_CONFIG_FAILED; | |
14172 | } | |
42f914d4 | 14173 | |
d62a17ae | 14174 | return CMD_SUCCESS; |
718e3744 | 14175 | } |
7336e101 SP |
14176 | ALIAS (no_community_list_standard_all, |
14177 | no_ip_community_list_standard_all_cmd, | |
14178 | "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
14179 | NO_STR | |
718e3744 | 14180 | IP_STR |
14181 | COMMUNITY_LIST_STR | |
7336e101 SP |
14182 | "Community list number (standard)\n" |
14183 | "Add an standard community-list entry\n" | |
14184 | "Community list name\n" | |
14185 | "Specify community to reject\n" | |
14186 | "Specify community to accept\n" | |
14187 | COMMUNITY_VAL_STR) | |
14188 | ||
174b5cb9 DA |
14189 | ALIAS(no_community_list_standard_all, no_bgp_community_list_standard_all_list_cmd, |
14190 | "no bgp community-list <(1-99)|standard WORD>", | |
14191 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
14192 | "Community list number (standard)\n" | |
14193 | "Add an standard community-list entry\n" | |
14194 | "Community list name\n") | |
14195 | ||
14196 | ALIAS(no_community_list_standard_all, no_ip_community_list_standard_all_list_cmd, | |
14197 | "no ip community-list <(1-99)|standard WORD>", | |
14198 | NO_STR BGP_STR COMMUNITY_LIST_STR | |
14199 | "Community list number (standard)\n" | |
14200 | "Add an standard community-list entry\n" | |
14201 | "Community list name\n") | |
14202 | ||
7336e101 SP |
14203 | /*community-list expanded */ |
14204 | DEFUN (community_list_expanded_all, | |
14205 | bgp_community_list_expanded_all_cmd, | |
14206 | "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14207 | BGP_STR | |
14208 | COMMUNITY_LIST_STR | |
718e3744 | 14209 | "Community list number (expanded)\n" |
5bf15956 | 14210 | "Add an expanded community-list entry\n" |
718e3744 | 14211 | "Community list name\n" |
14212 | "Specify community to reject\n" | |
14213 | "Specify community to accept\n" | |
14214 | COMMUNITY_VAL_STR) | |
14215 | { | |
d62a17ae | 14216 | char *cl_name_or_number = NULL; |
14217 | int direct = 0; | |
14218 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 14219 | |
d62a17ae | 14220 | int idx = 0; |
7336e101 SP |
14221 | if (argv_find(argv, argc, "ip", &idx)) { |
14222 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14223 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14224 | vty_out(vty, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); | |
14225 | zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
14226 | } | |
d62a17ae | 14227 | argv_find(argv, argc, "(100-500)", &idx); |
14228 | argv_find(argv, argc, "WORD", &idx); | |
14229 | cl_name_or_number = argv[idx]->arg; | |
14230 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
14231 | : COMMUNITY_DENY; | |
14232 | argv_find(argv, argc, "AA:NN", &idx); | |
14233 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 14234 | |
d62a17ae | 14235 | int ret = community_list_set(bgp_clist, cl_name_or_number, str, direct, |
14236 | style); | |
42f914d4 | 14237 | |
d62a17ae | 14238 | XFREE(MTYPE_TMP, str); |
42f914d4 | 14239 | |
d62a17ae | 14240 | if (ret < 0) { |
14241 | /* Display error string. */ | |
14242 | community_list_perror(vty, ret); | |
14243 | return CMD_WARNING_CONFIG_FAILED; | |
14244 | } | |
42f914d4 | 14245 | |
d62a17ae | 14246 | return CMD_SUCCESS; |
718e3744 | 14247 | } |
14248 | ||
7336e101 SP |
14249 | ALIAS (community_list_expanded_all, |
14250 | ip_community_list_expanded_all_cmd, | |
14251 | "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
718e3744 | 14252 | IP_STR |
14253 | COMMUNITY_LIST_STR | |
5bf15956 DW |
14254 | "Community list number (expanded)\n" |
14255 | "Add an expanded community-list entry\n" | |
718e3744 | 14256 | "Community list name\n" |
14257 | "Specify community to reject\n" | |
14258 | "Specify community to accept\n" | |
5bf15956 | 14259 | COMMUNITY_VAL_STR) |
7336e101 SP |
14260 | |
14261 | DEFUN (no_community_list_expanded_all, | |
14262 | no_bgp_community_list_expanded_all_cmd, | |
14263 | "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14264 | NO_STR | |
14265 | BGP_STR | |
14266 | COMMUNITY_LIST_STR | |
14267 | "Community list number (expanded)\n" | |
14268 | "Add an expanded community-list entry\n" | |
14269 | "Community list name\n" | |
14270 | "Specify community to reject\n" | |
14271 | "Specify community to accept\n" | |
14272 | COMMUNITY_VAL_STR) | |
718e3744 | 14273 | { |
d62a17ae | 14274 | char *cl_name_or_number = NULL; |
174b5cb9 | 14275 | char *str = NULL; |
d62a17ae | 14276 | int direct = 0; |
14277 | int style = COMMUNITY_LIST_EXPANDED; | |
42f914d4 | 14278 | |
d62a17ae | 14279 | int idx = 0; |
7336e101 SP |
14280 | if (argv_find(argv, argc, "ip", &idx)) { |
14281 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14282 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
174b5cb9 DA |
14283 | vty_out(vty, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n"); |
14284 | zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used"); | |
14285 | } | |
14286 | ||
3c4b8fe2 | 14287 | idx = 0; |
174b5cb9 DA |
14288 | argv_find(argv, argc, "permit", &idx); |
14289 | argv_find(argv, argc, "deny", &idx); | |
14290 | ||
14291 | if (idx) { | |
14292 | direct = argv_find(argv, argc, "permit", &idx) | |
14293 | ? COMMUNITY_PERMIT | |
14294 | : COMMUNITY_DENY; | |
14295 | ||
14296 | idx = 0; | |
14297 | argv_find(argv, argc, "AA:NN", &idx); | |
14298 | str = argv_concat(argv, argc, idx); | |
7336e101 | 14299 | } |
174b5cb9 DA |
14300 | |
14301 | idx = 0; | |
d62a17ae | 14302 | argv_find(argv, argc, "(100-500)", &idx); |
14303 | argv_find(argv, argc, "WORD", &idx); | |
14304 | cl_name_or_number = argv[idx]->arg; | |
42f914d4 | 14305 | |
d62a17ae | 14306 | int ret = community_list_unset(bgp_clist, cl_name_or_number, str, |
7298a8e1 | 14307 | direct, style); |
42f914d4 | 14308 | |
d62a17ae | 14309 | XFREE(MTYPE_TMP, str); |
daf9ddbb | 14310 | |
d62a17ae | 14311 | if (ret < 0) { |
14312 | community_list_perror(vty, ret); | |
14313 | return CMD_WARNING_CONFIG_FAILED; | |
14314 | } | |
42f914d4 | 14315 | |
d62a17ae | 14316 | return CMD_SUCCESS; |
718e3744 | 14317 | } |
14318 | ||
7336e101 SP |
14319 | ALIAS (no_community_list_expanded_all, |
14320 | no_ip_community_list_expanded_all_cmd, | |
14321 | "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...", | |
14322 | NO_STR | |
14323 | IP_STR | |
14324 | COMMUNITY_LIST_STR | |
14325 | "Community list number (expanded)\n" | |
14326 | "Add an expanded community-list entry\n" | |
14327 | "Community list name\n" | |
14328 | "Specify community to reject\n" | |
14329 | "Specify community to accept\n" | |
14330 | COMMUNITY_VAL_STR) | |
14331 | ||
174b5cb9 DA |
14332 | ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd, |
14333 | "no bgp community-list <(100-500)|expanded WORD>", | |
14334 | NO_STR IP_STR COMMUNITY_LIST_STR | |
14335 | "Community list number (expanded)\n" | |
14336 | "Add an expanded community-list entry\n" | |
14337 | "Community list name\n") | |
14338 | ||
14339 | ALIAS(no_community_list_expanded_all, no_ip_community_list_expanded_all_list_cmd, | |
14340 | "no ip community-list <(100-500)|expanded WORD>", | |
14341 | NO_STR IP_STR COMMUNITY_LIST_STR | |
14342 | "Community list number (expanded)\n" | |
14343 | "Add an expanded community-list entry\n" | |
14344 | "Community list name\n") | |
14345 | ||
8d9b8ed9 PM |
14346 | /* Return configuration string of community-list entry. */ |
14347 | static const char *community_list_config_str(struct community_entry *entry) | |
14348 | { | |
14349 | const char *str; | |
14350 | ||
14351 | if (entry->any) | |
14352 | str = ""; | |
14353 | else { | |
14354 | if (entry->style == COMMUNITY_LIST_STANDARD) | |
14355 | str = community_str(entry->u.com, false); | |
14356 | else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) | |
14357 | str = lcommunity_str(entry->u.lcom, false); | |
14358 | else | |
14359 | str = entry->config; | |
14360 | } | |
14361 | return str; | |
14362 | } | |
14363 | ||
d62a17ae | 14364 | static void community_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 14365 | { |
d62a17ae | 14366 | struct community_entry *entry; |
718e3744 | 14367 | |
d62a17ae | 14368 | for (entry = list->head; entry; entry = entry->next) { |
14369 | if (entry == list->head) { | |
14370 | if (all_digit(list->name)) | |
14371 | vty_out(vty, "Community %s list %s\n", | |
14372 | entry->style == COMMUNITY_LIST_STANDARD | |
14373 | ? "standard" | |
14374 | : "(expanded) access", | |
14375 | list->name); | |
14376 | else | |
14377 | vty_out(vty, "Named Community %s list %s\n", | |
14378 | entry->style == COMMUNITY_LIST_STANDARD | |
14379 | ? "standard" | |
14380 | : "expanded", | |
14381 | list->name); | |
14382 | } | |
14383 | if (entry->any) | |
14384 | vty_out(vty, " %s\n", | |
14385 | community_direct_str(entry->direct)); | |
14386 | else | |
14387 | vty_out(vty, " %s %s\n", | |
14388 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14389 | community_list_config_str(entry)); |
d62a17ae | 14390 | } |
718e3744 | 14391 | } |
14392 | ||
7336e101 SP |
14393 | DEFUN (show_community_list, |
14394 | show_bgp_community_list_cmd, | |
14395 | "show bgp community-list", | |
718e3744 | 14396 | SHOW_STR |
7336e101 | 14397 | BGP_STR |
718e3744 | 14398 | "List community-list\n") |
14399 | { | |
d62a17ae | 14400 | struct community_list *list; |
14401 | struct community_list_master *cm; | |
718e3744 | 14402 | |
7336e101 SP |
14403 | int idx = 0; |
14404 | if (argv_find(argv, argc, "ip", &idx)) { | |
14405 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14406 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14407 | vty_out(vty, "'show bgp community-list <(1-500)|WORD>'\n"); | |
14408 | zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used"); | |
14409 | } | |
d62a17ae | 14410 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); |
14411 | if (!cm) | |
14412 | return CMD_SUCCESS; | |
718e3744 | 14413 | |
d62a17ae | 14414 | for (list = cm->num.head; list; list = list->next) |
14415 | community_list_show(vty, list); | |
718e3744 | 14416 | |
d62a17ae | 14417 | for (list = cm->str.head; list; list = list->next) |
14418 | community_list_show(vty, list); | |
718e3744 | 14419 | |
d62a17ae | 14420 | return CMD_SUCCESS; |
718e3744 | 14421 | } |
14422 | ||
7336e101 SP |
14423 | ALIAS (show_community_list, |
14424 | show_ip_community_list_cmd, | |
14425 | "show ip community-list", | |
718e3744 | 14426 | SHOW_STR |
14427 | IP_STR | |
7336e101 SP |
14428 | "List community-list\n") |
14429 | ||
14430 | DEFUN (show_community_list_arg, | |
14431 | show_bgp_community_list_arg_cmd, | |
14432 | "show bgp community-list <(1-500)|WORD>", | |
14433 | SHOW_STR | |
14434 | BGP_STR | |
718e3744 | 14435 | "List community-list\n" |
14436 | "Community-list number\n" | |
14437 | "Community-list name\n") | |
14438 | { | |
d62a17ae | 14439 | int idx_comm_list = 3; |
14440 | struct community_list *list; | |
718e3744 | 14441 | |
7336e101 SP |
14442 | int idx = 0; |
14443 | if (argv_find(argv, argc, "ip", &idx)) { | |
14444 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14445 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14446 | vty_out(vty, "'show bgp community-list <(1-500)|WORD>'\n"); | |
14447 | zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used"); | |
14448 | } | |
e237b0d2 | 14449 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 14450 | COMMUNITY_LIST_MASTER); |
14451 | if (!list) { | |
14452 | vty_out(vty, "%% Can't find community-list\n"); | |
14453 | return CMD_WARNING; | |
14454 | } | |
718e3744 | 14455 | |
d62a17ae | 14456 | community_list_show(vty, list); |
718e3744 | 14457 | |
d62a17ae | 14458 | return CMD_SUCCESS; |
718e3744 | 14459 | } |
6b0655a2 | 14460 | |
7336e101 SP |
14461 | ALIAS (show_community_list_arg, |
14462 | show_ip_community_list_arg_cmd, | |
14463 | "show ip community-list <(1-500)|WORD>", | |
14464 | SHOW_STR | |
14465 | IP_STR | |
14466 | "List community-list\n" | |
14467 | "Community-list number\n" | |
14468 | "Community-list name\n") | |
14469 | ||
57d187bc JS |
14470 | /* |
14471 | * Large Community code. | |
14472 | */ | |
d62a17ae | 14473 | static int lcommunity_list_set_vty(struct vty *vty, int argc, |
14474 | struct cmd_token **argv, int style, | |
14475 | int reject_all_digit_name) | |
14476 | { | |
14477 | int ret; | |
14478 | int direct; | |
14479 | char *str; | |
14480 | int idx = 0; | |
14481 | char *cl_name; | |
14482 | ||
7336e101 SP |
14483 | if (argv_find(argv, argc, "ip", &idx)) { |
14484 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14485 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14486 | vty_out(vty, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n"); | |
14487 | zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used"); | |
14488 | } | |
d62a17ae | 14489 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT |
14490 | : COMMUNITY_DENY; | |
14491 | ||
14492 | /* All digit name check. */ | |
14493 | idx = 0; | |
14494 | argv_find(argv, argc, "WORD", &idx); | |
14495 | argv_find(argv, argc, "(1-99)", &idx); | |
14496 | argv_find(argv, argc, "(100-500)", &idx); | |
14497 | cl_name = argv[idx]->arg; | |
14498 | if (reject_all_digit_name && all_digit(cl_name)) { | |
14499 | vty_out(vty, "%% Community name cannot have all digits\n"); | |
14500 | return CMD_WARNING_CONFIG_FAILED; | |
14501 | } | |
14502 | ||
14503 | idx = 0; | |
14504 | argv_find(argv, argc, "AA:BB:CC", &idx); | |
14505 | argv_find(argv, argc, "LINE", &idx); | |
14506 | /* Concat community string argument. */ | |
14507 | if (idx) | |
14508 | str = argv_concat(argv, argc, idx); | |
14509 | else | |
14510 | str = NULL; | |
14511 | ||
14512 | ret = lcommunity_list_set(bgp_clist, cl_name, str, direct, style); | |
14513 | ||
14514 | /* Free temporary community list string allocated by | |
14515 | argv_concat(). */ | |
0a22ddfb | 14516 | XFREE(MTYPE_TMP, str); |
d62a17ae | 14517 | |
14518 | if (ret < 0) { | |
14519 | community_list_perror(vty, ret); | |
14520 | return CMD_WARNING_CONFIG_FAILED; | |
14521 | } | |
14522 | return CMD_SUCCESS; | |
14523 | } | |
14524 | ||
14525 | static int lcommunity_list_unset_vty(struct vty *vty, int argc, | |
14526 | struct cmd_token **argv, int style) | |
14527 | { | |
14528 | int ret; | |
14529 | int direct = 0; | |
14530 | char *str = NULL; | |
14531 | int idx = 0; | |
14532 | ||
7336e101 SP |
14533 | if (argv_find(argv, argc, "ip", &idx)) { |
14534 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14535 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14536 | vty_out(vty, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n"); | |
16941c05 | 14537 | zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used"); |
7336e101 | 14538 | } |
d62a17ae | 14539 | argv_find(argv, argc, "permit", &idx); |
14540 | argv_find(argv, argc, "deny", &idx); | |
14541 | ||
14542 | if (idx) { | |
14543 | /* Check the list direct. */ | |
14544 | if (strncmp(argv[idx]->arg, "p", 1) == 0) | |
14545 | direct = COMMUNITY_PERMIT; | |
14546 | else | |
14547 | direct = COMMUNITY_DENY; | |
14548 | ||
14549 | idx = 0; | |
14550 | argv_find(argv, argc, "LINE", &idx); | |
14551 | argv_find(argv, argc, "AA:AA:NN", &idx); | |
14552 | /* Concat community string argument. */ | |
14553 | str = argv_concat(argv, argc, idx); | |
14554 | } | |
14555 | ||
14556 | idx = 0; | |
14557 | argv_find(argv, argc, "(1-99)", &idx); | |
14558 | argv_find(argv, argc, "(100-500)", &idx); | |
14559 | argv_find(argv, argc, "WORD", &idx); | |
14560 | ||
14561 | /* Unset community list. */ | |
14562 | ret = lcommunity_list_unset(bgp_clist, argv[idx]->arg, str, direct, | |
14563 | style); | |
14564 | ||
14565 | /* Free temporary community list string allocated by | |
14566 | argv_concat(). */ | |
0a22ddfb | 14567 | XFREE(MTYPE_TMP, str); |
d62a17ae | 14568 | |
14569 | if (ret < 0) { | |
14570 | community_list_perror(vty, ret); | |
14571 | return CMD_WARNING_CONFIG_FAILED; | |
14572 | } | |
14573 | ||
14574 | return CMD_SUCCESS; | |
57d187bc JS |
14575 | } |
14576 | ||
14577 | /* "large-community-list" keyword help string. */ | |
14578 | #define LCOMMUNITY_LIST_STR "Add a large community list entry\n" | |
14579 | #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n" | |
14580 | ||
7336e101 SP |
14581 | #if CONFDATE > 20191005 |
14582 | CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command") | |
14583 | #endif | |
14584 | DEFUN (lcommunity_list_standard, | |
14585 | bgp_lcommunity_list_standard_cmd, | |
14586 | "bgp large-community-list (1-99) <deny|permit>", | |
14587 | BGP_STR | |
14588 | LCOMMUNITY_LIST_STR | |
14589 | "Large Community list number (standard)\n" | |
14590 | "Specify large community to reject\n" | |
14591 | "Specify large community to accept\n") | |
14592 | { | |
14593 | return lcommunity_list_set_vty(vty, argc, argv, | |
14594 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
14595 | } | |
14596 | ||
14597 | ALIAS (lcommunity_list_standard, | |
57d187bc | 14598 | ip_lcommunity_list_standard_cmd, |
52951b63 DS |
14599 | "ip large-community-list (1-99) <deny|permit>", |
14600 | IP_STR | |
14601 | LCOMMUNITY_LIST_STR | |
14602 | "Large Community list number (standard)\n" | |
14603 | "Specify large community to reject\n" | |
7111c1a0 | 14604 | "Specify large community to accept\n") |
7336e101 SP |
14605 | |
14606 | DEFUN (lcommunity_list_standard1, | |
14607 | bgp_lcommunity_list_standard1_cmd, | |
14608 | "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
14609 | BGP_STR | |
14610 | LCOMMUNITY_LIST_STR | |
14611 | "Large Community list number (standard)\n" | |
14612 | "Specify large community to reject\n" | |
14613 | "Specify large community to accept\n" | |
14614 | LCOMMUNITY_VAL_STR) | |
52951b63 | 14615 | { |
d62a17ae | 14616 | return lcommunity_list_set_vty(vty, argc, argv, |
14617 | LARGE_COMMUNITY_LIST_STANDARD, 0); | |
52951b63 DS |
14618 | } |
14619 | ||
7336e101 | 14620 | ALIAS (lcommunity_list_standard1, |
52951b63 DS |
14621 | ip_lcommunity_list_standard1_cmd, |
14622 | "ip large-community-list (1-99) <deny|permit> AA:BB:CC...", | |
57d187bc JS |
14623 | IP_STR |
14624 | LCOMMUNITY_LIST_STR | |
14625 | "Large Community list number (standard)\n" | |
14626 | "Specify large community to reject\n" | |
14627 | "Specify large community to accept\n" | |
14628 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14629 | |
14630 | DEFUN (lcommunity_list_expanded, | |
14631 | bgp_lcommunity_list_expanded_cmd, | |
14632 | "bgp large-community-list (100-500) <deny|permit> LINE...", | |
14633 | BGP_STR | |
14634 | LCOMMUNITY_LIST_STR | |
14635 | "Large Community list number (expanded)\n" | |
14636 | "Specify large community to reject\n" | |
14637 | "Specify large community to accept\n" | |
14638 | "An ordered list as a regular-expression\n") | |
57d187bc | 14639 | { |
d62a17ae | 14640 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14641 | LARGE_COMMUNITY_LIST_EXPANDED, 0); |
57d187bc JS |
14642 | } |
14643 | ||
7336e101 | 14644 | ALIAS (lcommunity_list_expanded, |
57d187bc JS |
14645 | ip_lcommunity_list_expanded_cmd, |
14646 | "ip large-community-list (100-500) <deny|permit> LINE...", | |
14647 | IP_STR | |
14648 | LCOMMUNITY_LIST_STR | |
14649 | "Large Community list number (expanded)\n" | |
14650 | "Specify large community to reject\n" | |
14651 | "Specify large community to accept\n" | |
14652 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14653 | |
14654 | DEFUN (lcommunity_list_name_standard, | |
14655 | bgp_lcommunity_list_name_standard_cmd, | |
14656 | "bgp large-community-list standard WORD <deny|permit>", | |
14657 | BGP_STR | |
14658 | LCOMMUNITY_LIST_STR | |
14659 | "Specify standard large-community-list\n" | |
14660 | "Large Community list name\n" | |
14661 | "Specify large community to reject\n" | |
14662 | "Specify large community to accept\n") | |
57d187bc | 14663 | { |
d62a17ae | 14664 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14665 | LARGE_COMMUNITY_LIST_STANDARD, 1); |
57d187bc JS |
14666 | } |
14667 | ||
7336e101 | 14668 | ALIAS (lcommunity_list_name_standard, |
57d187bc | 14669 | ip_lcommunity_list_name_standard_cmd, |
52951b63 DS |
14670 | "ip large-community-list standard WORD <deny|permit>", |
14671 | IP_STR | |
14672 | LCOMMUNITY_LIST_STR | |
14673 | "Specify standard large-community-list\n" | |
14674 | "Large Community list name\n" | |
14675 | "Specify large community to reject\n" | |
14676 | "Specify large community to accept\n") | |
7336e101 SP |
14677 | |
14678 | DEFUN (lcommunity_list_name_standard1, | |
14679 | bgp_lcommunity_list_name_standard1_cmd, | |
14680 | "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
14681 | BGP_STR | |
14682 | LCOMMUNITY_LIST_STR | |
14683 | "Specify standard large-community-list\n" | |
14684 | "Large Community list name\n" | |
14685 | "Specify large community to reject\n" | |
14686 | "Specify large community to accept\n" | |
14687 | LCOMMUNITY_VAL_STR) | |
52951b63 | 14688 | { |
d62a17ae | 14689 | return lcommunity_list_set_vty(vty, argc, argv, |
14690 | LARGE_COMMUNITY_LIST_STANDARD, 1); | |
52951b63 DS |
14691 | } |
14692 | ||
7336e101 | 14693 | ALIAS (lcommunity_list_name_standard1, |
52951b63 DS |
14694 | ip_lcommunity_list_name_standard1_cmd, |
14695 | "ip large-community-list standard WORD <deny|permit> AA:BB:CC...", | |
57d187bc JS |
14696 | IP_STR |
14697 | LCOMMUNITY_LIST_STR | |
14698 | "Specify standard large-community-list\n" | |
14699 | "Large Community list name\n" | |
14700 | "Specify large community to reject\n" | |
14701 | "Specify large community to accept\n" | |
14702 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14703 | |
14704 | DEFUN (lcommunity_list_name_expanded, | |
14705 | bgp_lcommunity_list_name_expanded_cmd, | |
14706 | "bgp large-community-list expanded WORD <deny|permit> LINE...", | |
14707 | BGP_STR | |
14708 | LCOMMUNITY_LIST_STR | |
14709 | "Specify expanded large-community-list\n" | |
14710 | "Large Community list name\n" | |
14711 | "Specify large community to reject\n" | |
14712 | "Specify large community to accept\n" | |
14713 | "An ordered list as a regular-expression\n") | |
57d187bc | 14714 | { |
d62a17ae | 14715 | return lcommunity_list_set_vty(vty, argc, argv, |
7336e101 | 14716 | LARGE_COMMUNITY_LIST_EXPANDED, 1); |
57d187bc JS |
14717 | } |
14718 | ||
7336e101 | 14719 | ALIAS (lcommunity_list_name_expanded, |
57d187bc JS |
14720 | ip_lcommunity_list_name_expanded_cmd, |
14721 | "ip large-community-list expanded WORD <deny|permit> LINE...", | |
14722 | IP_STR | |
14723 | LCOMMUNITY_LIST_STR | |
14724 | "Specify expanded large-community-list\n" | |
14725 | "Large Community list name\n" | |
14726 | "Specify large community to reject\n" | |
14727 | "Specify large community to accept\n" | |
14728 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14729 | |
14730 | DEFUN (no_lcommunity_list_standard_all, | |
14731 | no_bgp_lcommunity_list_standard_all_cmd, | |
14732 | "no bgp large-community-list <(1-99)|(100-500)|WORD>", | |
14733 | NO_STR | |
14734 | BGP_STR | |
14735 | LCOMMUNITY_LIST_STR | |
14736 | "Large Community list number (standard)\n" | |
14737 | "Large Community list number (expanded)\n" | |
14738 | "Large Community list name\n") | |
57d187bc | 14739 | { |
7336e101 SP |
14740 | return lcommunity_list_unset_vty(vty, argc, argv, |
14741 | LARGE_COMMUNITY_LIST_STANDARD); | |
57d187bc JS |
14742 | } |
14743 | ||
7336e101 | 14744 | ALIAS (no_lcommunity_list_standard_all, |
57d187bc JS |
14745 | no_ip_lcommunity_list_standard_all_cmd, |
14746 | "no ip large-community-list <(1-99)|(100-500)|WORD>", | |
14747 | NO_STR | |
14748 | IP_STR | |
14749 | LCOMMUNITY_LIST_STR | |
14750 | "Large Community list number (standard)\n" | |
14751 | "Large Community list number (expanded)\n" | |
14752 | "Large Community list name\n") | |
7336e101 SP |
14753 | |
14754 | DEFUN (no_lcommunity_list_name_expanded_all, | |
14755 | no_bgp_lcommunity_list_name_expanded_all_cmd, | |
14756 | "no bgp large-community-list expanded WORD", | |
14757 | NO_STR | |
14758 | BGP_STR | |
14759 | LCOMMUNITY_LIST_STR | |
14760 | "Specify expanded large-community-list\n" | |
14761 | "Large Community list name\n") | |
57d187bc | 14762 | { |
d62a17ae | 14763 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14764 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14765 | } |
14766 | ||
7336e101 | 14767 | ALIAS (no_lcommunity_list_name_expanded_all, |
57d187bc JS |
14768 | no_ip_lcommunity_list_name_expanded_all_cmd, |
14769 | "no ip large-community-list expanded WORD", | |
14770 | NO_STR | |
14771 | IP_STR | |
14772 | LCOMMUNITY_LIST_STR | |
14773 | "Specify expanded large-community-list\n" | |
14774 | "Large Community list name\n") | |
7336e101 SP |
14775 | |
14776 | DEFUN (no_lcommunity_list_standard, | |
14777 | no_bgp_lcommunity_list_standard_cmd, | |
14778 | "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
14779 | NO_STR | |
14780 | BGP_STR | |
14781 | LCOMMUNITY_LIST_STR | |
14782 | "Large Community list number (standard)\n" | |
14783 | "Specify large community to reject\n" | |
14784 | "Specify large community to accept\n" | |
14785 | LCOMMUNITY_VAL_STR) | |
57d187bc | 14786 | { |
d62a17ae | 14787 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14788 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
14789 | } |
14790 | ||
7336e101 | 14791 | ALIAS (no_lcommunity_list_standard, |
57d187bc JS |
14792 | no_ip_lcommunity_list_standard_cmd, |
14793 | "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...", | |
14794 | NO_STR | |
14795 | IP_STR | |
14796 | LCOMMUNITY_LIST_STR | |
14797 | "Large Community list number (standard)\n" | |
14798 | "Specify large community to reject\n" | |
14799 | "Specify large community to accept\n" | |
14800 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14801 | |
14802 | DEFUN (no_lcommunity_list_expanded, | |
14803 | no_bgp_lcommunity_list_expanded_cmd, | |
14804 | "no bgp large-community-list (100-500) <deny|permit> LINE...", | |
14805 | NO_STR | |
14806 | BGP_STR | |
14807 | LCOMMUNITY_LIST_STR | |
14808 | "Large Community list number (expanded)\n" | |
14809 | "Specify large community to reject\n" | |
14810 | "Specify large community to accept\n" | |
14811 | "An ordered list as a regular-expression\n") | |
57d187bc | 14812 | { |
d62a17ae | 14813 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14814 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14815 | } |
14816 | ||
7336e101 | 14817 | ALIAS (no_lcommunity_list_expanded, |
57d187bc JS |
14818 | no_ip_lcommunity_list_expanded_cmd, |
14819 | "no ip large-community-list (100-500) <deny|permit> LINE...", | |
14820 | NO_STR | |
14821 | IP_STR | |
14822 | LCOMMUNITY_LIST_STR | |
14823 | "Large Community list number (expanded)\n" | |
14824 | "Specify large community to reject\n" | |
14825 | "Specify large community to accept\n" | |
14826 | "An ordered list as a regular-expression\n") | |
7336e101 SP |
14827 | |
14828 | DEFUN (no_lcommunity_list_name_standard, | |
14829 | no_bgp_lcommunity_list_name_standard_cmd, | |
14830 | "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
14831 | NO_STR | |
14832 | BGP_STR | |
14833 | LCOMMUNITY_LIST_STR | |
14834 | "Specify standard large-community-list\n" | |
14835 | "Large Community list name\n" | |
14836 | "Specify large community to reject\n" | |
14837 | "Specify large community to accept\n" | |
14838 | LCOMMUNITY_VAL_STR) | |
57d187bc | 14839 | { |
d62a17ae | 14840 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14841 | LARGE_COMMUNITY_LIST_STANDARD); |
57d187bc JS |
14842 | } |
14843 | ||
7336e101 | 14844 | ALIAS (no_lcommunity_list_name_standard, |
57d187bc JS |
14845 | no_ip_lcommunity_list_name_standard_cmd, |
14846 | "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...", | |
14847 | NO_STR | |
14848 | IP_STR | |
14849 | LCOMMUNITY_LIST_STR | |
14850 | "Specify standard large-community-list\n" | |
14851 | "Large Community list name\n" | |
14852 | "Specify large community to reject\n" | |
14853 | "Specify large community to accept\n" | |
14854 | LCOMMUNITY_VAL_STR) | |
7336e101 SP |
14855 | |
14856 | DEFUN (no_lcommunity_list_name_expanded, | |
14857 | no_bgp_lcommunity_list_name_expanded_cmd, | |
14858 | "no bgp large-community-list expanded WORD <deny|permit> LINE...", | |
14859 | NO_STR | |
14860 | BGP_STR | |
14861 | LCOMMUNITY_LIST_STR | |
14862 | "Specify expanded large-community-list\n" | |
14863 | "Large community list name\n" | |
14864 | "Specify large community to reject\n" | |
14865 | "Specify large community to accept\n" | |
14866 | "An ordered list as a regular-expression\n") | |
57d187bc | 14867 | { |
d62a17ae | 14868 | return lcommunity_list_unset_vty(vty, argc, argv, |
7336e101 | 14869 | LARGE_COMMUNITY_LIST_EXPANDED); |
57d187bc JS |
14870 | } |
14871 | ||
7336e101 | 14872 | ALIAS (no_lcommunity_list_name_expanded, |
57d187bc JS |
14873 | no_ip_lcommunity_list_name_expanded_cmd, |
14874 | "no ip large-community-list expanded WORD <deny|permit> LINE...", | |
14875 | NO_STR | |
14876 | IP_STR | |
14877 | LCOMMUNITY_LIST_STR | |
14878 | "Specify expanded large-community-list\n" | |
14879 | "Large community list name\n" | |
14880 | "Specify large community to reject\n" | |
14881 | "Specify large community to accept\n" | |
14882 | "An ordered list as a regular-expression\n") | |
d62a17ae | 14883 | |
14884 | static void lcommunity_list_show(struct vty *vty, struct community_list *list) | |
14885 | { | |
14886 | struct community_entry *entry; | |
14887 | ||
14888 | for (entry = list->head; entry; entry = entry->next) { | |
14889 | if (entry == list->head) { | |
14890 | if (all_digit(list->name)) | |
14891 | vty_out(vty, "Large community %s list %s\n", | |
169b72c8 | 14892 | entry->style == |
14893 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 14894 | ? "standard" |
14895 | : "(expanded) access", | |
14896 | list->name); | |
14897 | else | |
14898 | vty_out(vty, | |
14899 | "Named large community %s list %s\n", | |
169b72c8 | 14900 | entry->style == |
14901 | LARGE_COMMUNITY_LIST_STANDARD | |
d62a17ae | 14902 | ? "standard" |
14903 | : "expanded", | |
14904 | list->name); | |
14905 | } | |
14906 | if (entry->any) | |
14907 | vty_out(vty, " %s\n", | |
14908 | community_direct_str(entry->direct)); | |
14909 | else | |
14910 | vty_out(vty, " %s %s\n", | |
14911 | community_direct_str(entry->direct), | |
8d9b8ed9 | 14912 | community_list_config_str(entry)); |
d62a17ae | 14913 | } |
57d187bc JS |
14914 | } |
14915 | ||
7336e101 SP |
14916 | DEFUN (show_lcommunity_list, |
14917 | show_bgp_lcommunity_list_cmd, | |
14918 | "show bgp large-community-list", | |
57d187bc | 14919 | SHOW_STR |
7336e101 | 14920 | BGP_STR |
57d187bc JS |
14921 | "List large-community list\n") |
14922 | { | |
d62a17ae | 14923 | struct community_list *list; |
14924 | struct community_list_master *cm; | |
7336e101 SP |
14925 | int idx = 0; |
14926 | ||
14927 | if (argv_find(argv, argc, "ip", &idx)) { | |
14928 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14929 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14930 | vty_out(vty, "'show bgp large-community-list <(1-500)|WORD>'\n"); | |
14931 | zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used"); | |
14932 | } | |
57d187bc | 14933 | |
d62a17ae | 14934 | cm = community_list_master_lookup(bgp_clist, |
14935 | LARGE_COMMUNITY_LIST_MASTER); | |
14936 | if (!cm) | |
14937 | return CMD_SUCCESS; | |
57d187bc | 14938 | |
d62a17ae | 14939 | for (list = cm->num.head; list; list = list->next) |
14940 | lcommunity_list_show(vty, list); | |
57d187bc | 14941 | |
d62a17ae | 14942 | for (list = cm->str.head; list; list = list->next) |
14943 | lcommunity_list_show(vty, list); | |
57d187bc | 14944 | |
d62a17ae | 14945 | return CMD_SUCCESS; |
57d187bc JS |
14946 | } |
14947 | ||
7336e101 SP |
14948 | ALIAS (show_lcommunity_list, |
14949 | show_ip_lcommunity_list_cmd, | |
14950 | "show ip large-community-list", | |
57d187bc JS |
14951 | SHOW_STR |
14952 | IP_STR | |
7336e101 SP |
14953 | "List large-community list\n") |
14954 | ||
14955 | DEFUN (show_lcommunity_list_arg, | |
14956 | show_bgp_lcommunity_list_arg_cmd, | |
14957 | "show bgp large-community-list <(1-500)|WORD>", | |
14958 | SHOW_STR | |
14959 | BGP_STR | |
57d187bc JS |
14960 | "List large-community list\n" |
14961 | "large-community-list number\n" | |
14962 | "large-community-list name\n") | |
14963 | { | |
d62a17ae | 14964 | struct community_list *list; |
7336e101 SP |
14965 | int idx = 0; |
14966 | ||
14967 | if (argv_find(argv, argc, "ip", &idx)) { | |
14968 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
14969 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
14970 | vty_out(vty, "'show bgp large-community-list <(1-500)|WORD>'\n"); | |
14971 | zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used"); | |
14972 | } | |
57d187bc | 14973 | |
e237b0d2 | 14974 | list = community_list_lookup(bgp_clist, argv[3]->arg, 0, |
d62a17ae | 14975 | LARGE_COMMUNITY_LIST_MASTER); |
14976 | if (!list) { | |
14977 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
14978 | return CMD_WARNING; | |
14979 | } | |
57d187bc | 14980 | |
d62a17ae | 14981 | lcommunity_list_show(vty, list); |
57d187bc | 14982 | |
d62a17ae | 14983 | return CMD_SUCCESS; |
57d187bc JS |
14984 | } |
14985 | ||
7336e101 SP |
14986 | ALIAS (show_lcommunity_list_arg, |
14987 | show_ip_lcommunity_list_arg_cmd, | |
14988 | "show ip large-community-list <(1-500)|WORD>", | |
14989 | SHOW_STR | |
14990 | IP_STR | |
14991 | "List large-community list\n" | |
14992 | "large-community-list number\n" | |
14993 | "large-community-list name\n") | |
14994 | ||
718e3744 | 14995 | /* "extcommunity-list" keyword help string. */ |
14996 | #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n" | |
14997 | #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n" | |
14998 | ||
7336e101 SP |
14999 | DEFUN (extcommunity_list_standard, |
15000 | bgp_extcommunity_list_standard_cmd, | |
15001 | "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
15002 | BGP_STR | |
718e3744 | 15003 | EXTCOMMUNITY_LIST_STR |
15004 | "Extended Community list number (standard)\n" | |
718e3744 | 15005 | "Specify standard extcommunity-list\n" |
5bf15956 | 15006 | "Community list name\n" |
718e3744 | 15007 | "Specify community to reject\n" |
15008 | "Specify community to accept\n" | |
15009 | EXTCOMMUNITY_VAL_STR) | |
15010 | { | |
d62a17ae | 15011 | int style = EXTCOMMUNITY_LIST_STANDARD; |
15012 | int direct = 0; | |
15013 | char *cl_number_or_name = NULL; | |
42f914d4 | 15014 | |
d62a17ae | 15015 | int idx = 0; |
7336e101 SP |
15016 | if (argv_find(argv, argc, "ip", &idx)) { |
15017 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15018 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15019 | vty_out(vty, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15020 | zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15021 | } | |
d62a17ae | 15022 | argv_find(argv, argc, "(1-99)", &idx); |
15023 | argv_find(argv, argc, "WORD", &idx); | |
15024 | cl_number_or_name = argv[idx]->arg; | |
15025 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
15026 | : COMMUNITY_DENY; | |
15027 | argv_find(argv, argc, "AA:NN", &idx); | |
15028 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 15029 | |
d62a17ae | 15030 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
15031 | direct, style); | |
42f914d4 | 15032 | |
d62a17ae | 15033 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15034 | |
d62a17ae | 15035 | if (ret < 0) { |
15036 | community_list_perror(vty, ret); | |
15037 | return CMD_WARNING_CONFIG_FAILED; | |
15038 | } | |
42f914d4 | 15039 | |
d62a17ae | 15040 | return CMD_SUCCESS; |
718e3744 | 15041 | } |
15042 | ||
7336e101 SP |
15043 | #if CONFDATE > 20191005 |
15044 | CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command") | |
15045 | #endif | |
15046 | ALIAS (extcommunity_list_standard, | |
15047 | ip_extcommunity_list_standard_cmd, | |
15048 | "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 15049 | IP_STR |
15050 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
15051 | "Extended Community list number (standard)\n" |
15052 | "Specify standard extcommunity-list\n" | |
15053 | "Community list name\n" | |
15054 | "Specify community to reject\n" | |
15055 | "Specify community to accept\n" | |
15056 | EXTCOMMUNITY_VAL_STR) | |
15057 | ||
15058 | DEFUN (extcommunity_list_name_expanded, | |
15059 | bgp_extcommunity_list_name_expanded_cmd, | |
15060 | "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15061 | BGP_STR | |
15062 | EXTCOMMUNITY_LIST_STR | |
5bf15956 | 15063 | "Extended Community list number (expanded)\n" |
718e3744 | 15064 | "Specify expanded extcommunity-list\n" |
15065 | "Extended Community list name\n" | |
15066 | "Specify community to reject\n" | |
15067 | "Specify community to accept\n" | |
15068 | "An ordered list as a regular-expression\n") | |
15069 | { | |
d62a17ae | 15070 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
15071 | int direct = 0; | |
15072 | char *cl_number_or_name = NULL; | |
42f914d4 | 15073 | |
d62a17ae | 15074 | int idx = 0; |
7336e101 SP |
15075 | if (argv_find(argv, argc, "ip", &idx)) { |
15076 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15077 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15078 | vty_out(vty, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15079 | zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15080 | } | |
15081 | ||
d62a17ae | 15082 | argv_find(argv, argc, "(100-500)", &idx); |
15083 | argv_find(argv, argc, "WORD", &idx); | |
15084 | cl_number_or_name = argv[idx]->arg; | |
15085 | direct = argv_find(argv, argc, "permit", &idx) ? COMMUNITY_PERMIT | |
15086 | : COMMUNITY_DENY; | |
15087 | argv_find(argv, argc, "LINE", &idx); | |
15088 | char *str = argv_concat(argv, argc, idx); | |
42f914d4 | 15089 | |
d62a17ae | 15090 | int ret = extcommunity_list_set(bgp_clist, cl_number_or_name, str, |
15091 | direct, style); | |
42f914d4 | 15092 | |
d62a17ae | 15093 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15094 | |
d62a17ae | 15095 | if (ret < 0) { |
15096 | community_list_perror(vty, ret); | |
15097 | return CMD_WARNING_CONFIG_FAILED; | |
15098 | } | |
42f914d4 | 15099 | |
d62a17ae | 15100 | return CMD_SUCCESS; |
718e3744 | 15101 | } |
15102 | ||
7336e101 SP |
15103 | ALIAS (extcommunity_list_name_expanded, |
15104 | ip_extcommunity_list_name_expanded_cmd, | |
15105 | "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
813d4307 DW |
15106 | IP_STR |
15107 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
15108 | "Extended Community list number (expanded)\n" |
15109 | "Specify expanded extcommunity-list\n" | |
15110 | "Extended Community list name\n" | |
15111 | "Specify community to reject\n" | |
15112 | "Specify community to accept\n" | |
15113 | "An ordered list as a regular-expression\n") | |
15114 | ||
15115 | DEFUN (no_extcommunity_list_standard_all, | |
15116 | no_bgp_extcommunity_list_standard_all_cmd, | |
15117 | "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
15118 | NO_STR | |
15119 | BGP_STR | |
15120 | EXTCOMMUNITY_LIST_STR | |
813d4307 | 15121 | "Extended Community list number (standard)\n" |
718e3744 | 15122 | "Specify standard extcommunity-list\n" |
5bf15956 | 15123 | "Community list name\n" |
718e3744 | 15124 | "Specify community to reject\n" |
15125 | "Specify community to accept\n" | |
15126 | EXTCOMMUNITY_VAL_STR) | |
15127 | { | |
d62a17ae | 15128 | int style = EXTCOMMUNITY_LIST_STANDARD; |
15129 | int direct = 0; | |
15130 | char *cl_number_or_name = NULL; | |
d4455c89 | 15131 | char *str = NULL; |
42f914d4 | 15132 | |
d62a17ae | 15133 | int idx = 0; |
7336e101 SP |
15134 | if (argv_find(argv, argc, "ip", &idx)) { |
15135 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
15136 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15137 | vty_out(vty, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15138 | zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15139 | } | |
d4455c89 DA |
15140 | |
15141 | idx = 0; | |
15142 | argv_find(argv, argc, "permit", &idx); | |
15143 | argv_find(argv, argc, "deny", &idx); | |
15144 | ||
15145 | if (idx) { | |
15146 | direct = argv_find(argv, argc, "permit", &idx) | |
15147 | ? COMMUNITY_PERMIT | |
15148 | : COMMUNITY_DENY; | |
15149 | ||
15150 | idx = 0; | |
15151 | argv_find(argv, argc, "AA:NN", &idx); | |
15152 | str = argv_concat(argv, argc, idx); | |
15153 | } | |
15154 | ||
15155 | idx = 0; | |
d62a17ae | 15156 | argv_find(argv, argc, "(1-99)", &idx); |
15157 | argv_find(argv, argc, "WORD", &idx); | |
15158 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 15159 | |
d62a17ae | 15160 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 15161 | direct, style); |
42f914d4 | 15162 | |
d62a17ae | 15163 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15164 | |
d62a17ae | 15165 | if (ret < 0) { |
15166 | community_list_perror(vty, ret); | |
15167 | return CMD_WARNING_CONFIG_FAILED; | |
15168 | } | |
42f914d4 | 15169 | |
d62a17ae | 15170 | return CMD_SUCCESS; |
718e3744 | 15171 | } |
15172 | ||
7336e101 SP |
15173 | ALIAS (no_extcommunity_list_standard_all, |
15174 | no_ip_extcommunity_list_standard_all_cmd, | |
15175 | "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...", | |
718e3744 | 15176 | NO_STR |
15177 | IP_STR | |
15178 | EXTCOMMUNITY_LIST_STR | |
7336e101 SP |
15179 | "Extended Community list number (standard)\n" |
15180 | "Specify standard extcommunity-list\n" | |
15181 | "Community list name\n" | |
15182 | "Specify community to reject\n" | |
15183 | "Specify community to accept\n" | |
15184 | EXTCOMMUNITY_VAL_STR) | |
15185 | ||
d4455c89 DA |
15186 | ALIAS(no_extcommunity_list_standard_all, |
15187 | no_bgp_extcommunity_list_standard_all_list_cmd, | |
15188 | "no bgp extcommunity-list <(1-99)|standard WORD>", | |
15189 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15190 | "Extended Community list number (standard)\n" | |
15191 | "Specify standard extcommunity-list\n" | |
15192 | "Community list name\n") | |
15193 | ||
15194 | ALIAS(no_extcommunity_list_standard_all, | |
15195 | no_ip_extcommunity_list_standard_all_list_cmd, | |
15196 | "no ip extcommunity-list <(1-99)|standard WORD>", | |
15197 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15198 | "Extended Community list number (standard)\n" | |
15199 | "Specify standard extcommunity-list\n" | |
15200 | "Community list name\n") | |
15201 | ||
7336e101 SP |
15202 | DEFUN (no_extcommunity_list_expanded_all, |
15203 | no_bgp_extcommunity_list_expanded_all_cmd, | |
15204 | "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15205 | NO_STR | |
15206 | BGP_STR | |
15207 | EXTCOMMUNITY_LIST_STR | |
718e3744 | 15208 | "Extended Community list number (expanded)\n" |
718e3744 | 15209 | "Specify expanded extcommunity-list\n" |
5bf15956 | 15210 | "Extended Community list name\n" |
718e3744 | 15211 | "Specify community to reject\n" |
15212 | "Specify community to accept\n" | |
15213 | "An ordered list as a regular-expression\n") | |
15214 | { | |
d62a17ae | 15215 | int style = EXTCOMMUNITY_LIST_EXPANDED; |
15216 | int direct = 0; | |
15217 | char *cl_number_or_name = NULL; | |
d4455c89 | 15218 | char *str = NULL; |
42f914d4 | 15219 | |
d62a17ae | 15220 | int idx = 0; |
7336e101 SP |
15221 | if (argv_find(argv, argc, "ip", &idx)) { |
15222 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15223 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15224 | vty_out(vty, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n"); | |
15225 | zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used"); | |
15226 | } | |
d4455c89 DA |
15227 | |
15228 | idx = 0; | |
15229 | argv_find(argv, argc, "permit", &idx); | |
15230 | argv_find(argv, argc, "deny", &idx); | |
15231 | ||
15232 | if (idx) { | |
15233 | direct = argv_find(argv, argc, "permit", &idx) | |
15234 | ? COMMUNITY_PERMIT | |
15235 | : COMMUNITY_DENY; | |
15236 | ||
15237 | idx = 0; | |
15238 | argv_find(argv, argc, "LINE", &idx); | |
15239 | str = argv_concat(argv, argc, idx); | |
15240 | } | |
15241 | ||
15242 | idx = 0; | |
d62a17ae | 15243 | argv_find(argv, argc, "(100-500)", &idx); |
15244 | argv_find(argv, argc, "WORD", &idx); | |
15245 | cl_number_or_name = argv[idx]->arg; | |
42f914d4 | 15246 | |
d62a17ae | 15247 | int ret = extcommunity_list_unset(bgp_clist, cl_number_or_name, str, |
7298a8e1 | 15248 | direct, style); |
42f914d4 | 15249 | |
d62a17ae | 15250 | XFREE(MTYPE_TMP, str); |
42f914d4 | 15251 | |
d62a17ae | 15252 | if (ret < 0) { |
15253 | community_list_perror(vty, ret); | |
15254 | return CMD_WARNING_CONFIG_FAILED; | |
15255 | } | |
42f914d4 | 15256 | |
d62a17ae | 15257 | return CMD_SUCCESS; |
718e3744 | 15258 | } |
15259 | ||
7336e101 SP |
15260 | ALIAS (no_extcommunity_list_expanded_all, |
15261 | no_ip_extcommunity_list_expanded_all_cmd, | |
15262 | "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...", | |
15263 | NO_STR | |
15264 | IP_STR | |
15265 | EXTCOMMUNITY_LIST_STR | |
15266 | "Extended Community list number (expanded)\n" | |
15267 | "Specify expanded extcommunity-list\n" | |
15268 | "Extended Community list name\n" | |
15269 | "Specify community to reject\n" | |
15270 | "Specify community to accept\n" | |
15271 | "An ordered list as a regular-expression\n") | |
15272 | ||
d4455c89 DA |
15273 | ALIAS(no_extcommunity_list_expanded_all, |
15274 | no_ip_extcommunity_list_expanded_all_list_cmd, | |
15275 | "no ip extcommunity-list <(100-500)|expanded WORD>", | |
15276 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15277 | "Extended Community list number (expanded)\n" | |
15278 | "Specify expanded extcommunity-list\n" | |
15279 | "Extended Community list name\n") | |
15280 | ||
15281 | ALIAS(no_extcommunity_list_expanded_all, | |
15282 | no_bgp_extcommunity_list_expanded_all_list_cmd, | |
15283 | "no bgp extcommunity-list <(100-500)|expanded WORD>", | |
15284 | NO_STR IP_STR EXTCOMMUNITY_LIST_STR | |
15285 | "Extended Community list number (expanded)\n" | |
15286 | "Specify expanded extcommunity-list\n" | |
15287 | "Extended Community list name\n") | |
15288 | ||
d62a17ae | 15289 | static void extcommunity_list_show(struct vty *vty, struct community_list *list) |
718e3744 | 15290 | { |
d62a17ae | 15291 | struct community_entry *entry; |
718e3744 | 15292 | |
d62a17ae | 15293 | for (entry = list->head; entry; entry = entry->next) { |
15294 | if (entry == list->head) { | |
15295 | if (all_digit(list->name)) | |
15296 | vty_out(vty, "Extended community %s list %s\n", | |
15297 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
15298 | ? "standard" | |
15299 | : "(expanded) access", | |
15300 | list->name); | |
15301 | else | |
15302 | vty_out(vty, | |
15303 | "Named extended community %s list %s\n", | |
15304 | entry->style == EXTCOMMUNITY_LIST_STANDARD | |
15305 | ? "standard" | |
15306 | : "expanded", | |
15307 | list->name); | |
15308 | } | |
15309 | if (entry->any) | |
15310 | vty_out(vty, " %s\n", | |
15311 | community_direct_str(entry->direct)); | |
15312 | else | |
15313 | vty_out(vty, " %s %s\n", | |
15314 | community_direct_str(entry->direct), | |
8d9b8ed9 | 15315 | community_list_config_str(entry)); |
d62a17ae | 15316 | } |
718e3744 | 15317 | } |
15318 | ||
7336e101 SP |
15319 | DEFUN (show_extcommunity_list, |
15320 | show_bgp_extcommunity_list_cmd, | |
15321 | "show bgp extcommunity-list", | |
718e3744 | 15322 | SHOW_STR |
7336e101 | 15323 | BGP_STR |
718e3744 | 15324 | "List extended-community list\n") |
15325 | { | |
d62a17ae | 15326 | struct community_list *list; |
15327 | struct community_list_master *cm; | |
7336e101 | 15328 | int idx = 0; |
718e3744 | 15329 | |
7336e101 SP |
15330 | if (argv_find(argv, argc, "ip", &idx)) { |
15331 | vty_out(vty, "This config option is deprecated, and is scheduled for removal\n"); | |
15332 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15333 | vty_out(vty, "'show bgp extcommunity-list <(1-500)|WORD>'\n"); | |
15334 | zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used"); | |
15335 | } | |
d62a17ae | 15336 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); |
15337 | if (!cm) | |
15338 | return CMD_SUCCESS; | |
718e3744 | 15339 | |
d62a17ae | 15340 | for (list = cm->num.head; list; list = list->next) |
15341 | extcommunity_list_show(vty, list); | |
718e3744 | 15342 | |
d62a17ae | 15343 | for (list = cm->str.head; list; list = list->next) |
15344 | extcommunity_list_show(vty, list); | |
718e3744 | 15345 | |
d62a17ae | 15346 | return CMD_SUCCESS; |
718e3744 | 15347 | } |
15348 | ||
7336e101 SP |
15349 | ALIAS (show_extcommunity_list, |
15350 | show_ip_extcommunity_list_cmd, | |
15351 | "show ip extcommunity-list", | |
718e3744 | 15352 | SHOW_STR |
15353 | IP_STR | |
7336e101 SP |
15354 | "List extended-community list\n") |
15355 | ||
15356 | DEFUN (show_extcommunity_list_arg, | |
15357 | show_bgp_extcommunity_list_arg_cmd, | |
15358 | "show bgp extcommunity-list <(1-500)|WORD>", | |
15359 | SHOW_STR | |
15360 | BGP_STR | |
718e3744 | 15361 | "List extended-community list\n" |
15362 | "Extcommunity-list number\n" | |
15363 | "Extcommunity-list name\n") | |
15364 | { | |
d62a17ae | 15365 | int idx_comm_list = 3; |
15366 | struct community_list *list; | |
7336e101 | 15367 | int idx = 0; |
718e3744 | 15368 | |
7336e101 SP |
15369 | if (argv_find(argv, argc, "ip", &idx)) { |
15370 | vty_out(vty, "This config option is deprecated, and is scheduled for removal.\n"); | |
15371 | vty_out(vty, "if you are using this please migrate to the below command.\n"); | |
15372 | vty_out(vty, "'show bgp extcommunity-list <(1-500)|WORD>'\n"); | |
15373 | zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used"); | |
15374 | } | |
e237b0d2 | 15375 | list = community_list_lookup(bgp_clist, argv[idx_comm_list]->arg, 0, |
d62a17ae | 15376 | EXTCOMMUNITY_LIST_MASTER); |
15377 | if (!list) { | |
15378 | vty_out(vty, "%% Can't find extcommunity-list\n"); | |
15379 | return CMD_WARNING; | |
15380 | } | |
718e3744 | 15381 | |
d62a17ae | 15382 | extcommunity_list_show(vty, list); |
718e3744 | 15383 | |
d62a17ae | 15384 | return CMD_SUCCESS; |
718e3744 | 15385 | } |
6b0655a2 | 15386 | |
7336e101 SP |
15387 | ALIAS (show_extcommunity_list_arg, |
15388 | show_ip_extcommunity_list_arg_cmd, | |
15389 | "show ip extcommunity-list <(1-500)|WORD>", | |
15390 | SHOW_STR | |
15391 | IP_STR | |
15392 | "List extended-community list\n" | |
15393 | "Extcommunity-list number\n" | |
15394 | "Extcommunity-list name\n") | |
15395 | ||
718e3744 | 15396 | /* Display community-list and extcommunity-list configuration. */ |
d62a17ae | 15397 | static int community_list_config_write(struct vty *vty) |
15398 | { | |
15399 | struct community_list *list; | |
15400 | struct community_entry *entry; | |
15401 | struct community_list_master *cm; | |
15402 | int write = 0; | |
15403 | ||
15404 | /* Community-list. */ | |
15405 | cm = community_list_master_lookup(bgp_clist, COMMUNITY_LIST_MASTER); | |
15406 | ||
15407 | for (list = cm->num.head; list; list = list->next) | |
15408 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15409 | vty_out(vty, "bgp community-list %s %s %s\n", list->name, |
d62a17ae | 15410 | community_direct_str(entry->direct), |
15411 | community_list_config_str(entry)); | |
15412 | write++; | |
15413 | } | |
15414 | for (list = cm->str.head; list; list = list->next) | |
15415 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15416 | vty_out(vty, "bgp community-list %s %s %s %s\n", |
d62a17ae | 15417 | entry->style == COMMUNITY_LIST_STANDARD |
15418 | ? "standard" | |
15419 | : "expanded", | |
15420 | list->name, community_direct_str(entry->direct), | |
15421 | community_list_config_str(entry)); | |
15422 | write++; | |
15423 | } | |
15424 | ||
15425 | /* Extcommunity-list. */ | |
15426 | cm = community_list_master_lookup(bgp_clist, EXTCOMMUNITY_LIST_MASTER); | |
15427 | ||
15428 | for (list = cm->num.head; list; list = list->next) | |
15429 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15430 | vty_out(vty, "bgp extcommunity-list %s %s %s\n", |
d62a17ae | 15431 | list->name, community_direct_str(entry->direct), |
15432 | community_list_config_str(entry)); | |
15433 | write++; | |
15434 | } | |
15435 | for (list = cm->str.head; list; list = list->next) | |
15436 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15437 | vty_out(vty, "bgp extcommunity-list %s %s %s %s\n", |
d62a17ae | 15438 | entry->style == EXTCOMMUNITY_LIST_STANDARD |
15439 | ? "standard" | |
15440 | : "expanded", | |
15441 | list->name, community_direct_str(entry->direct), | |
15442 | community_list_config_str(entry)); | |
15443 | write++; | |
15444 | } | |
15445 | ||
15446 | ||
15447 | /* lcommunity-list. */ | |
15448 | cm = community_list_master_lookup(bgp_clist, | |
15449 | LARGE_COMMUNITY_LIST_MASTER); | |
15450 | ||
15451 | for (list = cm->num.head; list; list = list->next) | |
15452 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15453 | vty_out(vty, "bgp large-community-list %s %s %s\n", |
d62a17ae | 15454 | list->name, community_direct_str(entry->direct), |
15455 | community_list_config_str(entry)); | |
15456 | write++; | |
15457 | } | |
15458 | for (list = cm->str.head; list; list = list->next) | |
15459 | for (entry = list->head; entry; entry = entry->next) { | |
7336e101 | 15460 | vty_out(vty, "bgp large-community-list %s %s %s %s\n", |
d62a17ae | 15461 | entry->style == LARGE_COMMUNITY_LIST_STANDARD |
15462 | ? "standard" | |
15463 | : "expanded", | |
15464 | list->name, community_direct_str(entry->direct), | |
15465 | community_list_config_str(entry)); | |
15466 | write++; | |
15467 | } | |
15468 | ||
15469 | return write; | |
15470 | } | |
15471 | ||
15472 | static struct cmd_node community_list_node = { | |
15473 | COMMUNITY_LIST_NODE, "", 1 /* Export to vtysh. */ | |
718e3744 | 15474 | }; |
15475 | ||
d62a17ae | 15476 | static void community_list_vty(void) |
15477 | { | |
15478 | install_node(&community_list_node, community_list_config_write); | |
15479 | ||
15480 | /* Community-list. */ | |
7336e101 SP |
15481 | install_element(CONFIG_NODE, &bgp_community_list_standard_cmd); |
15482 | install_element(CONFIG_NODE, &bgp_community_list_expanded_all_cmd); | |
15483 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_cmd); | |
174b5cb9 | 15484 | install_element(CONFIG_NODE, &no_bgp_community_list_standard_all_list_cmd); |
7336e101 | 15485 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_cmd); |
174b5cb9 | 15486 | install_element(CONFIG_NODE, &no_bgp_community_list_expanded_all_list_cmd); |
7336e101 SP |
15487 | install_element(VIEW_NODE, &show_bgp_community_list_cmd); |
15488 | install_element(VIEW_NODE, &show_bgp_community_list_arg_cmd); | |
d62a17ae | 15489 | install_element(CONFIG_NODE, &ip_community_list_standard_cmd); |
15490 | install_element(CONFIG_NODE, &ip_community_list_expanded_all_cmd); | |
15491 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_cmd); | |
174b5cb9 | 15492 | install_element(CONFIG_NODE, &no_ip_community_list_standard_all_list_cmd); |
d62a17ae | 15493 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_cmd); |
174b5cb9 | 15494 | install_element(CONFIG_NODE, &no_ip_community_list_expanded_all_list_cmd); |
d62a17ae | 15495 | install_element(VIEW_NODE, &show_ip_community_list_cmd); |
15496 | install_element(VIEW_NODE, &show_ip_community_list_arg_cmd); | |
15497 | ||
15498 | /* Extcommunity-list. */ | |
7336e101 SP |
15499 | install_element(CONFIG_NODE, &bgp_extcommunity_list_standard_cmd); |
15500 | install_element(CONFIG_NODE, &bgp_extcommunity_list_name_expanded_cmd); | |
15501 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_standard_all_cmd); | |
d4455c89 DA |
15502 | install_element(CONFIG_NODE, |
15503 | &no_bgp_extcommunity_list_standard_all_list_cmd); | |
7336e101 | 15504 | install_element(CONFIG_NODE, &no_bgp_extcommunity_list_expanded_all_cmd); |
d4455c89 DA |
15505 | install_element(CONFIG_NODE, |
15506 | &no_bgp_extcommunity_list_expanded_all_list_cmd); | |
7336e101 SP |
15507 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_cmd); |
15508 | install_element(VIEW_NODE, &show_bgp_extcommunity_list_arg_cmd); | |
d62a17ae | 15509 | install_element(CONFIG_NODE, &ip_extcommunity_list_standard_cmd); |
15510 | install_element(CONFIG_NODE, &ip_extcommunity_list_name_expanded_cmd); | |
15511 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_cmd); | |
d4455c89 | 15512 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_standard_all_list_cmd); |
d62a17ae | 15513 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_cmd); |
d4455c89 | 15514 | install_element(CONFIG_NODE, &no_ip_extcommunity_list_expanded_all_list_cmd); |
d62a17ae | 15515 | install_element(VIEW_NODE, &show_ip_extcommunity_list_cmd); |
15516 | install_element(VIEW_NODE, &show_ip_extcommunity_list_arg_cmd); | |
15517 | ||
15518 | /* Large Community List */ | |
7336e101 SP |
15519 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard_cmd); |
15520 | install_element(CONFIG_NODE, &bgp_lcommunity_list_standard1_cmd); | |
15521 | install_element(CONFIG_NODE, &bgp_lcommunity_list_expanded_cmd); | |
15522 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard_cmd); | |
15523 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_standard1_cmd); | |
15524 | install_element(CONFIG_NODE, &bgp_lcommunity_list_name_expanded_cmd); | |
15525 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_all_cmd); | |
15526 | install_element(CONFIG_NODE, | |
15527 | &no_bgp_lcommunity_list_name_expanded_all_cmd); | |
15528 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_standard_cmd); | |
15529 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_expanded_cmd); | |
15530 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_standard_cmd); | |
15531 | install_element(CONFIG_NODE, &no_bgp_lcommunity_list_name_expanded_cmd); | |
15532 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_cmd); | |
15533 | install_element(VIEW_NODE, &show_bgp_lcommunity_list_arg_cmd); | |
d62a17ae | 15534 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard_cmd); |
15535 | install_element(CONFIG_NODE, &ip_lcommunity_list_standard1_cmd); | |
15536 | install_element(CONFIG_NODE, &ip_lcommunity_list_expanded_cmd); | |
15537 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard_cmd); | |
15538 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_standard1_cmd); | |
15539 | install_element(CONFIG_NODE, &ip_lcommunity_list_name_expanded_cmd); | |
15540 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_all_cmd); | |
15541 | install_element(CONFIG_NODE, | |
15542 | &no_ip_lcommunity_list_name_expanded_all_cmd); | |
15543 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_standard_cmd); | |
15544 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_expanded_cmd); | |
15545 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_standard_cmd); | |
15546 | install_element(CONFIG_NODE, &no_ip_lcommunity_list_name_expanded_cmd); | |
15547 | install_element(VIEW_NODE, &show_ip_lcommunity_list_cmd); | |
15548 | install_element(VIEW_NODE, &show_ip_lcommunity_list_arg_cmd); | |
5bf15956 | 15549 | } |